am 4406302d: am bbd08ff7: am a6a832e5: am 52cf109d: Merge "Set CALL_SUBJECT capability on phone accts if instant lettering available." into mnc-dr-dev

* commit '4406302d5c2377739af4e7e07bda86665a4887ef':
  Set CALL_SUBJECT capability on phone accts if instant lettering available.
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index df458fd..3127eb8 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -168,8 +168,9 @@
             if (mIsVideoCapable) {
                 capabilities |= PhoneAccount.CAPABILITY_VIDEO_CALLING;
             }
-            if (record != null) {
-                updateVideoPauseSupport(record);
+            mIsVideoPauseSupported = isCarrierVideoPauseSupported();
+            if (isCarrierInstantLetteringSupported()) {
+                capabilities |= PhoneAccount.CAPABILITY_CALL_SUBJECT;
             }
 
             if (icon == null) {
@@ -211,34 +212,26 @@
         }
 
         /**
-         * Updates indicator for this {@link AccountEntry} to determine if the carrier supports
-         * pause/resume signalling for IMS video calls.  The carrier setting is stored in MNC/MCC
-         * configuration files.
+         * Determines from carrier configuration whether pausing of IMS video calls is supported.
          *
-         * @param subscriptionInfo The subscription info.
+         * @return {@code true} if pausing IMS video calls is supported.
          */
-        private void updateVideoPauseSupport(SubscriptionInfo subscriptionInfo) {
-            // Get the configuration for the MNC/MCC specified in the current subscription info.
-            Configuration configuration = new Configuration();
-            if (subscriptionInfo.getMcc() == 0 && subscriptionInfo.getMnc() == 0) {
-                Configuration config = mContext.getResources().getConfiguration();
-                configuration.mcc = config.mcc;
-                configuration.mnc = config.mnc;
-                Log.i(this, "updateVideoPauseSupport -- no mcc/mnc for sub: " + subscriptionInfo +
-                        " using mcc/mnc from main context: " + configuration.mcc + "/" +
-                        configuration.mnc);
-            } else {
-                Log.i(this, "updateVideoPauseSupport -- mcc/mnc for sub: " + subscriptionInfo);
-
-                configuration.mcc = subscriptionInfo.getMcc();
-                configuration.mnc = subscriptionInfo.getMnc();
-            }
-
+        private boolean isCarrierVideoPauseSupported() {
             // Check if IMS video pause is supported.
             PersistableBundle b =
                     PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
-            mIsVideoPauseSupported
-                    = b.getBoolean(CarrierConfigManager.KEY_SUPPORT_PAUSE_IMS_VIDEO_CALLS_BOOL);
+            return b.getBoolean(CarrierConfigManager.KEY_SUPPORT_PAUSE_IMS_VIDEO_CALLS_BOOL);
+        }
+
+        /**
+         * Determines from carrier config whether instant lettering is supported.
+         *
+         * @return {@code true} if instant lettering is supported, {@code false} otherwise.
+         */
+        private boolean isCarrierInstantLetteringSupported() {
+            PersistableBundle b =
+                    PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
+            return b.getBoolean(CarrierConfigManager.KEY_CARRIER_INSTANT_LETTERING_AVAILABLE_BOOL);
         }
 
         /**
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 913595b..0375073 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -16,7 +16,6 @@
 
 package com.android.services.telephony;
 
-import android.content.ComponentName;
 import android.content.Context;
 import android.graphics.drawable.Icon;
 import android.net.Uri;
@@ -30,6 +29,7 @@
 import android.telecom.PhoneAccount;
 import android.telecom.StatusHints;
 
+import com.android.ims.ImsCallProfile;
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.Connection.PostDialListener;
@@ -43,7 +43,9 @@
 import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -59,6 +61,12 @@
     private static final int MSG_MULTIPARTY_STATE_CHANGED = 5;
     private static final int MSG_CONFERENCE_MERGE_FAILED = 6;
     private static final int MSG_SUPP_SERVICE_NOTIFY = 7;
+    /**
+     * Mappings from {@link com.android.internal.telephony.Connection} extras keys to their
+     * equivalents defined in {@link android.telecom.Connection}.
+     */
+    private static final Map<String, String> sExtrasMap = createExtrasMap();
+
     private SuppServiceNotification mSsNotification = null;
 
     private final Handler mHandler = new Handler() {
@@ -122,12 +130,12 @@
                         mSsNotification =
                                 (SuppServiceNotification)((AsyncResult) msg.obj).result;
                         if (mOriginalConnection != null && mSsNotification.history != null) {
-                            Bundle extras = mOriginalConnection.getExtras();
+                            Bundle extras = getExtras();
                             if (extras != null) {
                                 Log.v(TelephonyConnection.this,
                                         "Updating call history info in extras.");
-                                /*extras.putStringArrayList(EXTRA_CALL_HISTORY_INFO,
-                                        new ArrayList(Arrays.asList(mSsNotification.history)));*/
+                                extras.putStringArrayList(Connection.EXTRA_LAST_FORWARDED_NUMBER,
+                                        new ArrayList(Arrays.asList(mSsNotification.history)));
                                 setExtras(extras);
                             }
                         }
@@ -753,8 +761,18 @@
                         }
                     }
                     mOriginalConnectionExtras.clear();
+
                     mOriginalConnectionExtras.putAll(extras);
 
+                    // Remap any string extras that have a remapping defined.
+                    for (String key : mOriginalConnectionExtras.keySet()) {
+                        if (sExtrasMap.containsKey(key)) {
+                            String newKey = sExtrasMap.get(key);
+                            mOriginalConnectionExtras.putString(newKey, extras.getString(key));
+                            mOriginalConnectionExtras.remove(key);
+                        }
+                    }
+
                     // Ensure extras are propagated to Telecom.
                     Bundle connectionExtras = getExtras();
                     if (connectionExtras == null) {
@@ -1124,6 +1142,23 @@
         }
     }
 
+
+    /**
+     * Provides a mapping from extras keys which may be found in the
+     * {@link com.android.internal.telephony.Connection} to their equivalents defined in
+     * {@link android.telecom.Connection}.
+     *
+     * @return Map containing key mappings.
+     */
+    private static Map<String, String> createExtrasMap() {
+        Map<String, String> result = new HashMap<String, String>();
+        result.put(ImsCallProfile.EXTRA_CHILD_NUMBER,
+                android.telecom.Connection.EXTRA_CHILD_ADDRESS);
+        result.put(ImsCallProfile.EXTRA_DISPLAY_TEXT,
+                android.telecom.Connection.EXTRA_CALL_SUBJECT);
+        return Collections.unmodifiableMap(result);
+    }
+
     /**
      * Creates a string representation of this {@link TelephonyConnection}.  Primarily intended for
      * use in log statements.