InCallUI: Add sim name for call notification

There isn't sim name in call notification.

Append sim name to the content of notification.

(cherry-picked from commit 79885948d97009f805d2503788a16ba76dce77ea)

Change-Id: Ic3cb5f690391f35c789e75bf12a1de36badd90ba
CRs-Fixed: 729954
diff --git a/Android.mk b/Android.mk
index a91f52c..16c4adc 100755
--- a/Android.mk
+++ b/Android.mk
@@ -62,7 +62,8 @@
     guava \
     libphonenumber \
     ims-ext-common \
-    phonebook_wrapper
+    phonebook_wrapper \
+    telephony-common
 
 LOCAL_PACKAGE_NAME := Dialer
 LOCAL_CERTIFICATE := shared
@@ -70,7 +71,7 @@
 
 LOCAL_PROGUARD_FLAG_FILES := proguard.flags $(incallui_dir)/proguard.flags
 
-LOCAL_SDK_VERSION := current
+# LOCAL_SDK_VERSION := current
 
 include $(BUILD_PACKAGE)
 
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java
index d20f977..666535f 100644
--- a/InCallUI/src/com/android/incallui/Call.java
+++ b/InCallUI/src/com/android/incallui/Call.java
@@ -21,6 +21,7 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Trace;
+import android.os.RemoteException;
 import android.telecom.Call.Details;
 import android.telecom.Connection;
 import android.telecom.DisconnectCause;
@@ -29,6 +30,7 @@
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
 import android.telecom.TelecomManager;
+import android.telephony.SubscriptionManager;
 import android.telecom.VideoProfile;
 import android.telephony.SubscriptionManager;
 import android.text.TextUtils;
@@ -793,6 +795,22 @@
         return mTelecomCall == null ? null : mTelecomCall.getDetails().getAccountHandle();
     }
 
+    public int getSubId() {
+        PhoneAccountHandle ph = getAccountHandle();
+        if (ph != null) {
+            try {
+                if (ph.getId() != null) {
+                    return Integer.parseInt(getAccountHandle().getId());
+                }
+            } catch (NumberFormatException e) {
+                Log.w(this, "sub id is not a number" + e);
+            }
+            return SubscriptionManager.getDefaultVoiceSubscriptionId();
+        } else {
+            return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+        }
+    }
+
     /**
      * @return The {@link VideoCall} instance associated with the {@link android.telecom.Call}.
      *      Will return {@code null} until {@link #updateFromTelecomCall()} has registered a valid
diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
index 601f8f3..71fee57 100644
--- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java
+++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
@@ -42,6 +42,9 @@
 import android.telecom.Call.Details;
 import android.telecom.PhoneAccount;
 import android.telecom.TelecomManager;
+import android.telephony.TelephonyManager;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
 import android.text.BidiFormatter;
 import android.text.TextDirectionHeuristics;
 import android.text.TextUtils;
@@ -87,6 +90,7 @@
     @Nullable private ContactsPreferences mContactsPreferences;
     private final ContactInfoCache mContactInfoCache;
     private final NotificationManager mNotificationManager;
+    private final TelephonyManager mTelephonyManager;
     private final DialerRingtoneManager mDialerRingtoneManager;
     private int mCurrentNotification = NOTIFICATION_NONE;
     private int mCallState = Call.State.INVALID;
@@ -108,6 +112,8 @@
         mContext = context;
         mContactsPreferences = ContactsPreferencesFactory.newContactsPreferences(mContext);
         mContactInfoCache = contactInfoCache;
+        mTelephonyManager =
+                (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
         mNotificationManager =
                 (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
         mDialerRingtoneManager = new DialerRingtoneManager(
@@ -318,7 +324,7 @@
         // Check if data has changed; if nothing is different, don't issue another notification.
         final int iconResId;
         Bitmap largeIcon = getLargeIconToDisplay(contactInfo, call);
-        final String content =
+        String content =
                 getContentString(call, contactInfo.userType);
         int wifiQualityValue = call.getWifiQuality();
         if (wifiQualityValue != QtiCallConstants.VOWIFI_QUALITY_NONE) {
@@ -348,6 +354,16 @@
             largeIcon = getRoundedIcon(largeIcon);
         }
 
+        //set the content
+        boolean isMultiSimDevice = mTelephonyManager.isMultiSimEnabled();
+        if (isMultiSimDevice) {
+            SubscriptionInfo info =
+                    SubscriptionManager.from(mContext).getActiveSubscriptionInfo(call.getSubId());
+            if (info != null) {
+                content += " (" + info.getDisplayName() + ")";
+            }
+        }
+
         /*
          * This builder is used for the notification shown when the device is locked and the user
          * has set their notification settings to 'hide sensitive content'