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
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java
index 679901e..016bce3 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.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 @@
           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 @@
 
   @Override
   protected void addGroups(Cursor cursor) {
-    mCallLogGroupBuilder.addGroups(cursor, mActivity);
+    mCallLogGroupBuilder.addGroups(cursor);
   }
 
   @Override
@@ -981,11 +978,9 @@
               .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 57a8be7..513c8aa 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 @@
    *
    * @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 @@
     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 @@
       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 f0852bd..d5dfb06 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.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.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 @@
 
   private boolean showDuoPrimaryButton() {
     return accountHandle != null
-        && accountHandle.getComponentName().equals(getDuo().getPhoneAccountComponentName())
+        && accountHandle.getComponentName().equals(DuoConstants.PHONE_ACCOUNT_COMPONENT_NAME)
         && duoReady;
   }
 
@@ -961,7 +959,7 @@
       // 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 @@
     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 f50751e..fff68d4 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.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 @@
     if (newCalls == null) {
       return;
     }
+
     TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
     Iterator<NewCall> iterator = newCalls.iterator();
     while (iterator.hasNext()) {
@@ -269,6 +271,10 @@
       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",
diff --git a/java/com/android/dialer/calllogutils/CallbackActionHelper.java b/java/com/android/dialer/calllogutils/CallbackActionHelper.java
index 3049943..1e219f1 100644
--- a/java/com/android/dialer/calllogutils/CallbackActionHelper.java
+++ b/java/com/android/dialer/calllogutils/CallbackActionHelper.java
@@ -16,12 +16,10 @@
 
 package com.android.dialer.calllogutils;
 
-import android.content.Context;
 import android.provider.CallLog.Calls;
 import android.support.annotation.IntDef;
 import android.text.TextUtils;
-import com.android.dialer.duo.Duo;
-import com.android.dialer.duo.DuoComponent;
+import com.android.dialer.duo.DuoConstants;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
@@ -45,12 +43,11 @@
    * @param features Value of features in column {@link android.provider.CallLog.Calls#FEATURES}.
    * @param phoneAccountComponentName Account name in column {@link
    *     android.provider.CallLog.Calls#PHONE_ACCOUNT_COMPONENT_NAME}.
-   * @param context The context in which the method is called.
    * @return One of the values in {@link CallbackAction}
    */
   public static @CallbackAction int getCallbackAction(
-      String number, int features, String phoneAccountComponentName, Context context) {
-    return getCallbackAction(number, features, isDuoCall(phoneAccountComponentName, context));
+      String number, int features, String phoneAccountComponentName) {
+    return getCallbackAction(number, features, isDuoCall(phoneAccountComponentName));
   }
 
   /**
@@ -78,12 +75,9 @@
     return CallbackAction.VOICE;
   }
 
-  private static boolean isDuoCall(String phoneAccountComponentName, Context context) {
-    Duo lightBringer = DuoComponent.get(context).getDuo();
-    return lightBringer.getPhoneAccountComponentName() != null
-        && lightBringer
-            .getPhoneAccountComponentName()
-            .flattenToString()
-            .equals(phoneAccountComponentName);
+  private static boolean isDuoCall(String phoneAccountComponentName) {
+    return DuoConstants.PHONE_ACCOUNT_COMPONENT_NAME
+        .flattenToString()
+        .equals(phoneAccountComponentName);
   }
 }
diff --git a/java/com/android/dialer/duo/Duo.java b/java/com/android/dialer/duo/Duo.java
index ec07ad4..839c1d3 100644
--- a/java/com/android/dialer/duo/Duo.java
+++ b/java/com/android/dialer/duo/Duo.java
@@ -16,7 +16,6 @@
 
 package com.android.dialer.duo;
 
-import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.support.annotation.MainThread;
@@ -24,7 +23,6 @@
 import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
 import android.telecom.Call;
-import android.telecom.PhoneAccountHandle;
 import com.google.auto.value.AutoValue;
 import com.google.common.base.Optional;
 import java.util.List;
@@ -55,18 +53,6 @@
   @MainThread
   void unregisterListener(@NonNull DuoListener listener);
 
-  @Nullable
-  @MainThread
-  ComponentName getPhoneAccountComponentName();
-
-  @Nullable
-  @MainThread
-  PhoneAccountHandle getPhoneAccountHandle();
-
-  @Nullable
-  @MainThread
-  String getPackageName();
-
   @StringRes
   @MainThread
   int getOutgoingCallTypeText();
diff --git a/java/com/android/dialer/duo/DuoConstants.java b/java/com/android/dialer/duo/DuoConstants.java
new file mode 100644
index 0000000..50254ee
--- /dev/null
+++ b/java/com/android/dialer/duo/DuoConstants.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dialer.duo;
+
+import android.content.ComponentName;
+import android.telecom.PhoneAccountHandle;
+
+/** Constants to reference the Duo application. */
+public final class DuoConstants {
+  public static final String PACKAGE_NAME = "com.google.android.apps.tachyon";
+
+  public static final String CONNECTION_SERVICE =
+      "com.google.android.apps.tachyon.telecom.TachyonTelecomConnectionService";
+
+  public static final String PHONE_ACCOUNT_ID = "0";
+
+  public static final ComponentName PHONE_ACCOUNT_COMPONENT_NAME =
+      new ComponentName(PACKAGE_NAME, CONNECTION_SERVICE);
+
+  public static final PhoneAccountHandle PHONE_ACCOUNT_HANDLE =
+      new PhoneAccountHandle(PHONE_ACCOUNT_COMPONENT_NAME, PHONE_ACCOUNT_ID);
+
+  private DuoConstants() {}
+}
diff --git a/java/com/android/dialer/duo/stub/DuoStub.java b/java/com/android/dialer/duo/stub/DuoStub.java
index 99f03ad..82b9c79 100644
--- a/java/com/android/dialer/duo/stub/DuoStub.java
+++ b/java/com/android/dialer/duo/stub/DuoStub.java
@@ -16,7 +16,6 @@
 
 package com.android.dialer.duo.stub;
 
-import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.support.annotation.MainThread;
@@ -24,7 +23,6 @@
 import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
 import android.telecom.Call;
-import android.telecom.PhoneAccountHandle;
 import com.android.dialer.common.Assert;
 import com.android.dialer.duo.Duo;
 import com.android.dialer.duo.DuoListener;
@@ -95,24 +93,6 @@
     Assert.isNotNull(listener);
   }
 
-  @Nullable
-  @Override
-  public ComponentName getPhoneAccountComponentName() {
-    return null;
-  }
-
-  @Nullable
-  @Override
-  public PhoneAccountHandle getPhoneAccountHandle() {
-    return null;
-  }
-
-  @Nullable
-  @Override
-  public String getPackageName() {
-    return null;
-  }
-
   @StringRes
   @Override
   public int getOutgoingCallTypeText() {