Android 8.1 来电显示SIM卡

需求:来电要求显示哪张SIM来电。

--- a/alps/vendor/mediatek/proprietary/packages/apps/Dialer/java/com/android/incallui/contactgrid/ContactGridManager.java
+++ b/alps/vendor/mediatek/proprietary/packages/apps/Dialer/java/com/android/incallui/contactgrid/ContactGridManager.java
@@ -41,6 +41,11 @@ import com.android.incallui.incall.protocol.PrimaryInfo;
 import com.mediatek.incallui.plugin.ExtensionManager;
 import java.util.List;

+// add Caller ID SIM card Monkey.20181206
+import com.android.incallui.call.CallList;
+import com.android.incallui.call.DialerCall;
+import android.telephony.SubscriptionManager;
+import android.telephony.SubscriptionInfo;
+// end
 /** Utility to manage the Contact grid */
 public class ContactGridManager {
 
@@ -261,6 +266,35 @@ public class ContactGridManager {
               ? PhoneNumberUtilsCompat.createTtsSpannable(primaryInfo.name)
               : primaryInfo.name);
 
+        //getOutgoingOrActive
+        //getIncomingCall
+        //add Caller ID SIM card Monkey.20181206
+     List mSubInfoList=SubscriptionManager.from(context).getActiveSubscriptionInfoList();
+        int getSubId = -1;
+        if(CallList.getInstance().getIncomingCall() != null){
+                getSubId = CallList.getInstance().getIncomingCall().getCallSubId();
+        }       
+        if(mSubInfoList != null){
+                if(mSubInfoList.size() >= 2 && getSubId != -1){
+                        for(SubscriptionInfo s:mSubInfoList){
+                               android.util.Log.e("Monkey_Dialer","getSubscriptionId  ----->>>"+s.getSubscriptionId());
+                               if(s.getSubscriptionId() == getSubId){
+                                       contactNameTextView.setText
+                                               ("SIM1:" + (primaryInfo.nameIsNumber
+                                                       ? PhoneNumberUtilsCompat.createTtsSpannable(primaryInfo.name)
+                                                       : primaryInfo.name));
+                               }else{
+                                       contactNameTextView.setText
+                                               ("SIM2:" + (primaryInfo.nameIsNumber
+                                                       ? PhoneNumberUtilsCompat.createTtsSpannable(primaryInfo.name)
+                                                       : primaryInfo.name));
+                               }
+                               break;
+                        }
+                }
+        }
+        //end
+        
       // Set direction of the name field
       int nameDirection = View.TEXT_DIRECTION_INHERIT;

 

你可能感兴趣的:(MTK随记)