Loading src/java/com/android/internal/telephony/SmsController.java +33 −3 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.internal.util.DumpUtils.checkDumpPermission; import android.annotation.Nullable; import android.annotation.UnsupportedAppUsage; import android.app.ActivityManager; import android.app.ActivityThread; import android.app.AppOpsManager; import android.app.PendingIntent; Loading Loading @@ -365,6 +366,16 @@ public class SmsController extends ISmsImplBase { @Override public boolean isSmsSimPickActivityNeeded(int subId) { final Context context = ActivityThread.currentApplication().getApplicationContext(); ActivityManager am = context.getSystemService(ActivityManager.class); // Don't show the SMS SIM Pick activity if it is not foreground. boolean isCallingProcessForeground = am != null && am.getUidImportance(Binder.getCallingUid()) == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; if (!isCallingProcessForeground) { Rlog.d(LOG_TAG, "isSmsSimPickActivityNeeded: calling process not foreground. " + "Suppressing activity."); return false; } TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); List<SubscriptionInfo> subInfoList; Loading Loading @@ -421,14 +432,33 @@ public class SmsController extends ISmsImplBase { } /** * Get User preferred SMS subscription * Get preferred SMS subscription. * * @return User preferred SMS subscription * @return User-defined default SMS subscription. If there is no default, return the active * subscription if there is only one active. If no preference can be found, return * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}. */ @UnsupportedAppUsage @Override public int getPreferredSmsSubscription() { return SubscriptionController.getInstance().getDefaultSmsSubId(); // If there is a default, choose that one. int defaultSubId = SubscriptionController.getInstance().getDefaultSmsSubId(); if (SubscriptionManager.isValidSubscriptionId(defaultSubId)) { return defaultSubId; } // No default, if there is only one sub active, choose that as the "preferred" sub id. long token = Binder.clearCallingIdentity(); try { int[] activeSubs = SubscriptionController.getInstance() .getActiveSubIdList(true /*visibleOnly*/); if (activeSubs.length == 1) { return activeSubs[0]; } } finally { Binder.restoreCallingIdentity(token); } // No preference can be found. return SubscriptionManager.INVALID_SUBSCRIPTION_ID; } /** Loading Loading
src/java/com/android/internal/telephony/SmsController.java +33 −3 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.internal.util.DumpUtils.checkDumpPermission; import android.annotation.Nullable; import android.annotation.UnsupportedAppUsage; import android.app.ActivityManager; import android.app.ActivityThread; import android.app.AppOpsManager; import android.app.PendingIntent; Loading Loading @@ -365,6 +366,16 @@ public class SmsController extends ISmsImplBase { @Override public boolean isSmsSimPickActivityNeeded(int subId) { final Context context = ActivityThread.currentApplication().getApplicationContext(); ActivityManager am = context.getSystemService(ActivityManager.class); // Don't show the SMS SIM Pick activity if it is not foreground. boolean isCallingProcessForeground = am != null && am.getUidImportance(Binder.getCallingUid()) == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; if (!isCallingProcessForeground) { Rlog.d(LOG_TAG, "isSmsSimPickActivityNeeded: calling process not foreground. " + "Suppressing activity."); return false; } TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); List<SubscriptionInfo> subInfoList; Loading Loading @@ -421,14 +432,33 @@ public class SmsController extends ISmsImplBase { } /** * Get User preferred SMS subscription * Get preferred SMS subscription. * * @return User preferred SMS subscription * @return User-defined default SMS subscription. If there is no default, return the active * subscription if there is only one active. If no preference can be found, return * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}. */ @UnsupportedAppUsage @Override public int getPreferredSmsSubscription() { return SubscriptionController.getInstance().getDefaultSmsSubId(); // If there is a default, choose that one. int defaultSubId = SubscriptionController.getInstance().getDefaultSmsSubId(); if (SubscriptionManager.isValidSubscriptionId(defaultSubId)) { return defaultSubId; } // No default, if there is only one sub active, choose that as the "preferred" sub id. long token = Binder.clearCallingIdentity(); try { int[] activeSubs = SubscriptionController.getInstance() .getActiveSubIdList(true /*visibleOnly*/); if (activeSubs.length == 1) { return activeSubs[0]; } } finally { Binder.restoreCallingIdentity(token); } // No preference can be found. return SubscriptionManager.INVALID_SUBSCRIPTION_ID; } /** Loading