From c114cce52656e6ace2ffdfd075b0e8cd140cd498 Mon Sep 17 00:00:00 2001 From: roldenburg Date: Mon, 16 Oct 2017 17:00:00 -0700 Subject: Move Duo related constants out of interface Fixed notifying for Duo missed calls using the new constants to check if a call is a Duo call. Bug: 66946794 Test: existing tests, manual PiperOrigin-RevId: 172400311 Change-Id: I84ec0ac5c933cf1aec68b6d1f422c2effe6b69ec --- java/com/android/dialer/app/calllog/CallLogAdapter.java | 17 ++++++----------- .../android/dialer/app/calllog/CallLogGroupBuilder.java | 7 +++---- .../dialer/app/calllog/CallLogListItemViewHolder.java | 13 +++---------- .../android/dialer/app/calllog/MissedCallNotifier.java | 6 ++++++ 4 files changed, 18 insertions(+), 25 deletions(-) (limited to 'java/com/android/dialer/app') diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index 679901e9f..016bce322 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -75,6 +75,7 @@ import com.android.dialer.compat.android.provider.VoicemailCompat; import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.duo.Duo; import com.android.dialer.duo.DuoComponent; +import com.android.dialer.duo.DuoConstants; import com.android.dialer.duo.DuoListener; import com.android.dialer.enrichedcall.EnrichedCallCapabilities; import com.android.dialer.enrichedcall.EnrichedCallComponent; @@ -399,11 +400,7 @@ public class CallLogAdapter extends GroupingListAdapter if (intentProvider == null) { return false; } - String packageName = DuoComponent.get(mActivity).getDuo().getPackageName(); - if (packageName == null) { - return false; - } - return packageName.equals(intentProvider.getIntent(mActivity).getPackage()); + return DuoConstants.PACKAGE_NAME.equals(intentProvider.getIntent(mActivity).getPackage()); } }; @@ -697,7 +694,7 @@ public class CallLogAdapter extends GroupingListAdapter @Override protected void addGroups(Cursor cursor) { - mCallLogGroupBuilder.addGroups(cursor, mActivity); + mCallLogGroupBuilder.addGroups(cursor); } @Override @@ -981,11 +978,9 @@ public class CallLogAdapter extends GroupingListAdapter .setFeatures(cursor.getInt(CallLogQuery.FEATURES)); String phoneAccountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME); - if (getDuo().getPhoneAccountComponentName() != null - && getDuo() - .getPhoneAccountComponentName() - .flattenToString() - .equals(phoneAccountComponentName)) { + if (DuoConstants.PHONE_ACCOUNT_COMPONENT_NAME + .flattenToString() + .equals(phoneAccountComponentName)) { entry.setIsDuoCall(true); } diff --git a/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java b/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java index 57a8be730..513c8aa59 100644 --- a/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java +++ b/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java @@ -16,7 +16,6 @@ package com.android.dialer.app.calllog; -import android.content.Context; import android.database.Cursor; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; @@ -74,7 +73,7 @@ public class CallLogGroupBuilder { * * @see GroupingListAdapter#addGroups(Cursor) */ - public void addGroups(Cursor cursor, Context context) { + public void addGroups(Cursor cursor) { final int count = cursor.getCount(); if (count == 0) { return; @@ -99,7 +98,7 @@ public class CallLogGroupBuilder { int groupFeatures = cursor.getInt(CallLogQuery.FEATURES); int groupCallbackAction = CallbackActionHelper.getCallbackAction( - groupNumber, groupFeatures, groupAccountComponentName, context); + groupNumber, groupFeatures, groupAccountComponentName); mGroupCreator.setCallbackAction(firstRowId, groupCallbackAction); // Instantiate other group values to those of the first call in the cursor. @@ -134,7 +133,7 @@ public class CallLogGroupBuilder { accountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME); accountId = cursor.getString(CallLogQuery.ACCOUNT_ID); callbackAction = - CallbackActionHelper.getCallbackAction(number, features, accountComponentName, context); + CallbackActionHelper.getCallbackAction(number, features, accountComponentName); final boolean isSameNumber = equalNumbers(groupNumber, number); final boolean isSamePostDialDigits = groupPostDialDigits.equals(numberPostDialDigits); diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index f0852bdb5..d5dfb06dc 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -27,7 +27,6 @@ import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.annotation.IntDef; -import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.v7.widget.CardView; @@ -75,8 +74,7 @@ import com.android.dialer.constants.ActivityRequestCodes; import com.android.dialer.contactphoto.ContactPhotoManager; import com.android.dialer.dialercontact.DialerContact; import com.android.dialer.dialercontact.SimDetails; -import com.android.dialer.duo.Duo; -import com.android.dialer.duo.DuoComponent; +import com.android.dialer.duo.DuoConstants; import com.android.dialer.lettertile.LetterTileDrawable; import com.android.dialer.lettertile.LetterTileDrawable.ContactType; import com.android.dialer.logging.ContactSource; @@ -746,7 +744,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder private boolean showDuoPrimaryButton() { return accountHandle != null - && accountHandle.getComponentName().equals(getDuo().getPhoneAccountComponentName()) + && accountHandle.getComponentName().equals(DuoConstants.PHONE_ACCOUNT_COMPONENT_NAME) && duoReady; } @@ -961,7 +959,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder // We check to see if we are starting a Duo intent. The reason is Duo // intents need to be started using startActivityForResult instead of the usual startActivity String packageName = intent.getPackage(); - if (packageName != null && packageName.equals(getDuo().getPackageName())) { + if (DuoConstants.PACKAGE_NAME.equals(packageName)) { Logger.get(mContext) .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_CALL_LOG); if (isNonContactEntry(info)) { @@ -1125,11 +1123,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder return callDetailsEntries; } - @NonNull - private Duo getDuo() { - return DuoComponent.get(mContext).getDuo(); - } - @Override public void onCreateContextMenu( final ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java index f50751e2b..fff68d4c4 100644 --- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java +++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java @@ -53,6 +53,7 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor.Worker; import com.android.dialer.compat.android.provider.VoicemailCompat; +import com.android.dialer.duo.DuoConstants; import com.android.dialer.enrichedcall.FuzzyPhoneNumberMatcher; import com.android.dialer.notification.DialerNotificationManager; import com.android.dialer.notification.NotificationChannelId; @@ -253,6 +254,7 @@ public class MissedCallNotifier implements Worker, Void> { if (newCalls == null) { return; } + TelecomManager telecomManager = context.getSystemService(TelecomManager.class); Iterator iterator = newCalls.iterator(); while (iterator.hasNext()) { @@ -269,6 +271,10 @@ public class MissedCallNotifier implements Worker, Void> { if (phoneAccount == null) { continue; } + if (DuoConstants.PHONE_ACCOUNT_HANDLE.equals(phoneAccountHandle)) { + iterator.remove(); + continue; + } if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)) { LogUtil.i( "MissedCallNotifier.removeSelfManagedCalls", -- cgit v1.2.3