Add Assisted Dialing iconography to the incallui.

* Abstracts reference to telecom constant until available in the platform.
* Implements a new "Assisted Dialing" token/icon until final UX mocks are available.
* Adds unit test for outgoing call.

In a subsequent, related change:
* Modifications to fragments that contain contacts, the extra key will be inserted via call details to indicate the outgoing intent should use assisted dialing.

Bug: 64205446
Test: New Unit Test
PiperOrigin-RevId: 164788082
Change-Id: I5d388f7b6c4e55c42773d314d2417b6dbc38b972
diff --git a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
index cea137c..22ec70c 100644
--- a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
+++ b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java
@@ -50,6 +50,23 @@
 
   private static final String SECRET_CODE_ACTION = "android.provider.Telephony.SECRET_CODE";
 
+  // TODO(erfanian): b/63995261 Replace with the platform/telecom constant when available.
+  /**
+   * Indicates that the call being placed originated from a known contact.
+   *
+   * <p>This signals to the telephony platform that an outgoing call qualifies for assisted dialing.
+   */
+  public static final String ALLOW_ASSISTED_DIAL = "android.telecom.extra.ALLOW_ASSISTED_DIAL";
+
+  // TODO(erfanian): b/63995261 Replace with the platform/telecom constant when available.
+  /**
+   * Indicates that an outgoing call has undergone assisted dialing.
+   *
+   * <p>Unlike {@link ALLOW_ASSISTED_DIAL}, the presence of this key further indicates that a call
+   * has undergone Assisted Dialing -- not just that it qualified for Assisted Dialing.
+   */
+  public static final String IS_ASSISTED_DIALED = "android.telecom.extra.IS_ASSISTED_DIALED";
+
   /**
    * Returns the number of phones available. Returns 1 for Single standby mode (Single SIM
    * functionality) Returns 2 for Dual standby mode.(Dual SIM functionality)
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java
index b02c989..824d875 100644
--- a/java/com/android/incallui/CallCardPresenter.java
+++ b/java/com/android/incallui/CallCardPresenter.java
@@ -480,7 +480,8 @@
                   mPrimary.isRemotelyHeld(),
                   isBusiness,
                   supports2ndCallOnHold(),
-                  getSwapToSecondaryButtonState()));
+                  getSwapToSecondaryButtonState(),
+                  mPrimary.isAssistedDialed()));
 
       InCallActivity activity =
           (InCallActivity) (mInCallScreen.getInCallScreenFragment().getActivity());
diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java
index 7ef8ad2..4d80688 100644
--- a/java/com/android/incallui/call/DialerCall.java
+++ b/java/com/android/incallui/call/DialerCall.java
@@ -1005,6 +1005,13 @@
     return mLogState.isIncoming;
   }
 
+  public boolean isAssistedDialed() {
+    if (getIntentExtras() != null) {
+      return getIntentExtras().getBoolean(TelephonyManagerCompat.IS_ASSISTED_DIALED, false);
+    }
+    return false;
+  }
+
   public LatencyReport getLatencyReport() {
     return mLatencyReport;
   }
diff --git a/java/com/android/incallui/contactgrid/BottomRow.java b/java/com/android/incallui/contactgrid/BottomRow.java
index 76e0289..6068cc0 100644
--- a/java/com/android/incallui/contactgrid/BottomRow.java
+++ b/java/com/android/incallui/contactgrid/BottomRow.java
@@ -49,6 +49,7 @@
     public final boolean isForwardIconVisible;
     public final boolean isSpamIconVisible;
     public final boolean shouldPopulateAccessibilityEvent;
+    public final boolean isAssistedDialedVisisble;
 
     public Info(
         @Nullable CharSequence label,
@@ -58,7 +59,8 @@
         boolean isHdIconVisible,
         boolean isForwardIconVisible,
         boolean isSpamIconVisible,
-        boolean shouldPopulateAccessibilityEvent) {
+        boolean shouldPopulateAccessibilityEvent,
+        boolean isAssistedDialedVisisble) {
       this.label = label;
       this.isTimerVisible = isTimerVisible;
       this.isWorkIconVisible = isWorkIconVisible;
@@ -67,6 +69,7 @@
       this.isForwardIconVisible = isForwardIconVisible;
       this.isSpamIconVisible = isSpamIconVisible;
       this.shouldPopulateAccessibilityEvent = shouldPopulateAccessibilityEvent;
+      this.isAssistedDialedVisisble = isAssistedDialedVisisble;
     }
   }
 
@@ -81,6 +84,7 @@
     boolean isHdAttemptingIconVisible = state.isHdAttempting;
     boolean isSpamIconVisible = false;
     boolean shouldPopulateAccessibilityEvent = true;
+    boolean isAssistedDialedVisisble = state.isAssistedDialed;
 
     if (isIncoming(state) && primaryInfo.isSpam) {
       label = context.getString(R.string.contact_grid_incoming_suspected_spam);
@@ -117,7 +121,8 @@
         isHdIconVisible,
         isForwardIconVisible,
         isSpamIconVisible,
-        shouldPopulateAccessibilityEvent);
+        shouldPopulateAccessibilityEvent,
+        isAssistedDialedVisisble);
   }
 
   private static CharSequence getLabelForPhoneNumber(PrimaryInfo primaryInfo) {
diff --git a/java/com/android/incallui/contactgrid/ContactGridManager.java b/java/com/android/incallui/contactgrid/ContactGridManager.java
index e4a8a1c..ddf16e3 100644
--- a/java/com/android/incallui/contactgrid/ContactGridManager.java
+++ b/java/com/android/incallui/contactgrid/ContactGridManager.java
@@ -60,7 +60,7 @@
   @Nullable private ImageView avatarImageView;
 
   // Row 2: Mobile +1 (650) 253-0000
-  // Row 2: [HD attempting icon]/[HD icon] 00:15
+  // Row 2: [HD attempting icon]/[HD icon] [Assisted Dialing Icon] 00:15
   // Row 2: Call ended
   // Row 2: Hanging up
   // Row 2: [Alert sign] Suspected spam caller
@@ -68,6 +68,7 @@
   private final ImageView workIconImageView;
   private final ImageView hdIconImageView;
   private final ImageView forwardIconImageView;
+  private final ImageView assistedDialingImageView;
   private final TextView forwardedNumberView;
   private final ImageView spamIconImageView;
   private final ViewAnimator bottomTextSwitcher;
@@ -98,6 +99,7 @@
     hdIconImageView = view.findViewById(R.id.contactgrid_hdIcon);
     forwardIconImageView = view.findViewById(R.id.contactgrid_forwardIcon);
     forwardedNumberView = view.findViewById(R.id.contactgrid_forwardNumber);
+    assistedDialingImageView = view.findViewById(R.id.contactgrid_assistedDialingIcon);
     spamIconImageView = view.findViewById(R.id.contactgrid_spamIcon);
     bottomTextSwitcher = view.findViewById(R.id.contactgrid_bottom_text_switcher);
     bottomTextView = view.findViewById(R.id.contactgrid_bottom_text);
@@ -309,6 +311,8 @@
     bottomTextView.setText(info.label);
     bottomTextView.setAllCaps(info.isSpamIconVisible);
     workIconImageView.setVisibility(info.isWorkIconVisible ? View.VISIBLE : View.GONE);
+    assistedDialingImageView.setVisibility(
+        info.isAssistedDialedVisisble ? View.VISIBLE : View.GONE);
     if (hdIconImageView.getVisibility() == View.GONE) {
       if (info.isHdAttemptingIconVisible) {
         hdIconImageView.setVisibility(View.VISIBLE);
diff --git a/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml b/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml
index c74017e..8850dd8 100644
--- a/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml
+++ b/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml
@@ -1,4 +1,19 @@
 <?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ 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
+  -->
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
@@ -17,6 +32,10 @@
       android:src="@drawable/asd_hd_icon"
       android:visibility="gone"/>
   <ImageView
+      android:id="@+id/contactgrid_assistedDialingIcon"
+      style="@style/BottomRowIcon"
+      android:src="@drawable/quantum_ic_language_vd_theme_24"/>
+  <ImageView
       android:id="@id/contactgrid_forwardIcon"
       style="@style/BottomRowIcon"
       android:src="@drawable/quantum_ic_forward_vd_theme_24"/>
diff --git a/java/com/android/incallui/incall/protocol/PrimaryCallState.java b/java/com/android/incallui/incall/protocol/PrimaryCallState.java
index aac6ff9..791f22e 100644
--- a/java/com/android/incallui/incall/protocol/PrimaryCallState.java
+++ b/java/com/android/incallui/incall/protocol/PrimaryCallState.java
@@ -62,6 +62,7 @@
   public final boolean isBusinessNumber;
   public final boolean supportsCallOnHold;
   public final @ButtonState int swapToSecondaryButtonState;
+  public final boolean isAssistedDialed;
 
   // TODO: Convert to autovalue. b/34502119
   public static PrimaryCallState createEmptyPrimaryCallState() {
@@ -87,7 +88,8 @@
         false /* isRemotelyHeld */,
         false /* isBusinessNumber */,
         true /* supportsCallOnHold */,
-        ButtonState.NOT_SUPPORT /* swapToSecondaryButtonState */);
+        ButtonState.NOT_SUPPORT /* swapToSecondaryButtonState */,
+        false /* isAssistedDialed */);
   }
 
   public PrimaryCallState(
@@ -112,7 +114,8 @@
       boolean isRemotelyHeld,
       boolean isBusinessNumber,
       boolean supportsCallOnHold,
-      @ButtonState int swapToSecondaryButtonState) {
+      @ButtonState int swapToSecondaryButtonState,
+      boolean isAssistedDialed) {
     this.state = state;
     this.isVideoCall = isVideoCall;
     this.sessionModificationState = sessionModificationState;
@@ -135,6 +138,7 @@
     this.isBusinessNumber = isBusinessNumber;
     this.supportsCallOnHold = supportsCallOnHold;
     this.swapToSecondaryButtonState = swapToSecondaryButtonState;
+    this.isAssistedDialed = isAssistedDialed;
   }
 
   @Override