Loading src/java/com/android/internal/telephony/Phone.java +5 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony; import android.annotation.Nullable; import android.app.BroadcastOptions; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -2438,10 +2439,12 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { */ public void sendDialerSpecialCode(String code) { if (!TextUtils.isEmpty(code)) { final BroadcastOptions options = BroadcastOptions.makeBasic(); options.setAllowBackgroundActivityStarts(true); Intent intent = new Intent(TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://" + code)); intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mContext.sendBroadcast(intent); mContext.sendBroadcast(intent, null, options.toBundle()); // {@link TelephonyManager.ACTION_SECRET_CODE} will replace {@link // TelephonyIntents#SECRET_CODE_ACTION} in the next Android version. Before Loading @@ -2449,7 +2452,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { Intent secrectCodeIntent = new Intent(TelephonyManager.ACTION_SECRET_CODE, Uri.parse("android_secret_code://" + code)); intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mContext.sendBroadcast(secrectCodeIntent); mContext.sendBroadcast(secrectCodeIntent, null, options.toBundle()); } } Loading src/java/com/android/internal/telephony/SubscriptionController.java +20 −2 Original line number Diff line number Diff line Loading @@ -2268,12 +2268,30 @@ public class SubscriptionController extends ISub.Stub { return allSubs; } private boolean isInvisibleSubscription(int subId) { for (SubscriptionInfo info : mCacheOpportunisticSubInfoList) { if (info.getSubscriptionId() == subId) { return SubscriptionManager.isInvisibleSubscription(info); } } return false; } /** * @return the list of subId's that are active, is never null but the length maybe 0. */ @Override public int[] getActiveSubIdList() { ArrayList<Integer> allSubs = getActiveSubIdArrayList(); public int[] getActiveSubIdList(boolean visibleOnly) { List<Integer> allSubs = getActiveSubIdArrayList(); if (visibleOnly) { // Grouped opportunistic subscriptions should be hidden. allSubs = allSubs.stream().filter(subId -> isInvisibleSubscription(subId)) .collect(Collectors.toList()); } int[] subIdArr = new int[allSubs.size()]; int i = 0; for (int sub : allSubs) { Loading src/java/com/android/internal/telephony/uicc/UiccController.java +5 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony.uicc; import android.app.BroadcastOptions; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; Loading Loading @@ -807,10 +808,13 @@ public class UiccController extends Handler { } // broadcast slot status changed final BroadcastOptions options = BroadcastOptions.makeBasic(); options.setAllowBackgroundActivityStarts(true); Intent intent = new Intent(TelephonyManager.ACTION_SIM_SLOT_STATUS_CHANGED); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mContext.sendBroadcast(intent, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); mContext.sendBroadcast(intent, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, options.toBundle()); } private boolean slotStatusChanged(ArrayList<IccSlotStatus> slotStatusList) { Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +7 −7 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ public class SubscriptionControllerTest extends TelephonyTest { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(); int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); int subID = subIds[0]; Loading Loading @@ -189,7 +189,7 @@ public class SubscriptionControllerTest extends TelephonyTest { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(); int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); int subID = subIds[0]; Loading Loading @@ -300,7 +300,7 @@ public class SubscriptionControllerTest extends TelephonyTest { @SmallTest public void testMigrateImsSettings() throws Exception { testInsertSim(); int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(); int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); int subID = subIds[0]; Loading Loading @@ -554,7 +554,7 @@ public class SubscriptionControllerTest extends TelephonyTest { /* insert some sims */ testInsertMultipleRemoteSims(); assertEquals(1, mSubscriptionControllerUT.getDefaultSubId()); int[] subIdsArray = mSubscriptionControllerUT.getActiveSubIdList(); int[] subIdsArray = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIdsArray.length > 0); int len = subIdsArray.length; Loading @@ -564,7 +564,7 @@ public class SubscriptionControllerTest extends TelephonyTest { assertTrue(result > 0); // now check the number of subs left. should be one less than earlier int[] newSubIdsArray = mSubscriptionControllerUT.getActiveSubIdList(); int[] newSubIdsArray = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(newSubIdsArray.length > 0); assertEquals(len - 1, newSubIdsArray.length); Loading Loading @@ -802,8 +802,8 @@ public class SubscriptionControllerTest extends TelephonyTest { mSubscriptionControllerUT.addSubInfoRecord("123", 1); // sub 1 mSubscriptionControllerUT.addSubInfoRecord("456", 0); // sub 2 int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); // Make sure the return sub ids are sorted by slot index assertTrue("active sub ids = " + mSubscriptionControllerUT.getActiveSubIdList(), Arrays.equals(mSubscriptionControllerUT.getActiveSubIdList(), new int[]{2, 1})); assertTrue("active sub ids = " + subIds, Arrays.equals(subIds, new int[]{2, 1})); } } tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -151,7 +151,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { ((MockContentResolver) mContext.getContentResolver()).addProvider( SubscriptionManager.CONTENT_URI.getAuthority(), new FakeSubscriptionContentProvider()); doReturn(new int[]{}).when(mSubscriptionController).getActiveSubIdList(); doReturn(new int[]{}).when(mSubscriptionController) .getActiveSubIdList(/*visibleOnly*/false); mIccRecord = mUiccProfile.getIccRecords(); mSubscriptionInfoUpdaterHandlerThread = new SubscriptionInfoUpdaterHandlerThread(TAG); Loading @@ -170,7 +171,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { public void testSimAbsent() throws Exception { doReturn(Arrays.asList(mSubInfo)).when(mSubscriptionController) .getSubInfoUsingSlotIndexPrivileged(eq(FAKE_SUB_ID_1), anyBoolean()); doReturn(new int[]{FAKE_SUB_ID_1}).when(mSubscriptionController).getActiveSubIdList(); doReturn(new int[]{FAKE_SUB_ID_1}).when(mSubscriptionController) .getActiveSubIdList(/*visibleOnly*/false); mUpdater.updateInternalIccState( IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, FAKE_SUB_ID_1); Loading Loading
src/java/com/android/internal/telephony/Phone.java +5 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony; import android.annotation.Nullable; import android.app.BroadcastOptions; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -2438,10 +2439,12 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { */ public void sendDialerSpecialCode(String code) { if (!TextUtils.isEmpty(code)) { final BroadcastOptions options = BroadcastOptions.makeBasic(); options.setAllowBackgroundActivityStarts(true); Intent intent = new Intent(TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://" + code)); intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mContext.sendBroadcast(intent); mContext.sendBroadcast(intent, null, options.toBundle()); // {@link TelephonyManager.ACTION_SECRET_CODE} will replace {@link // TelephonyIntents#SECRET_CODE_ACTION} in the next Android version. Before Loading @@ -2449,7 +2452,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { Intent secrectCodeIntent = new Intent(TelephonyManager.ACTION_SECRET_CODE, Uri.parse("android_secret_code://" + code)); intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mContext.sendBroadcast(secrectCodeIntent); mContext.sendBroadcast(secrectCodeIntent, null, options.toBundle()); } } Loading
src/java/com/android/internal/telephony/SubscriptionController.java +20 −2 Original line number Diff line number Diff line Loading @@ -2268,12 +2268,30 @@ public class SubscriptionController extends ISub.Stub { return allSubs; } private boolean isInvisibleSubscription(int subId) { for (SubscriptionInfo info : mCacheOpportunisticSubInfoList) { if (info.getSubscriptionId() == subId) { return SubscriptionManager.isInvisibleSubscription(info); } } return false; } /** * @return the list of subId's that are active, is never null but the length maybe 0. */ @Override public int[] getActiveSubIdList() { ArrayList<Integer> allSubs = getActiveSubIdArrayList(); public int[] getActiveSubIdList(boolean visibleOnly) { List<Integer> allSubs = getActiveSubIdArrayList(); if (visibleOnly) { // Grouped opportunistic subscriptions should be hidden. allSubs = allSubs.stream().filter(subId -> isInvisibleSubscription(subId)) .collect(Collectors.toList()); } int[] subIdArr = new int[allSubs.size()]; int i = 0; for (int sub : allSubs) { Loading
src/java/com/android/internal/telephony/uicc/UiccController.java +5 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony.uicc; import android.app.BroadcastOptions; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; Loading Loading @@ -807,10 +808,13 @@ public class UiccController extends Handler { } // broadcast slot status changed final BroadcastOptions options = BroadcastOptions.makeBasic(); options.setAllowBackgroundActivityStarts(true); Intent intent = new Intent(TelephonyManager.ACTION_SIM_SLOT_STATUS_CHANGED); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mContext.sendBroadcast(intent, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); mContext.sendBroadcast(intent, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, options.toBundle()); } private boolean slotStatusChanged(ArrayList<IccSlotStatus> slotStatusList) { Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +7 −7 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ public class SubscriptionControllerTest extends TelephonyTest { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(); int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); int subID = subIds[0]; Loading Loading @@ -189,7 +189,7 @@ public class SubscriptionControllerTest extends TelephonyTest { testInsertSim(); /* Get SUB ID */ int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(); int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); int subID = subIds[0]; Loading Loading @@ -300,7 +300,7 @@ public class SubscriptionControllerTest extends TelephonyTest { @SmallTest public void testMigrateImsSettings() throws Exception { testInsertSim(); int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(); int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); int subID = subIds[0]; Loading Loading @@ -554,7 +554,7 @@ public class SubscriptionControllerTest extends TelephonyTest { /* insert some sims */ testInsertMultipleRemoteSims(); assertEquals(1, mSubscriptionControllerUT.getDefaultSubId()); int[] subIdsArray = mSubscriptionControllerUT.getActiveSubIdList(); int[] subIdsArray = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIdsArray.length > 0); int len = subIdsArray.length; Loading @@ -564,7 +564,7 @@ public class SubscriptionControllerTest extends TelephonyTest { assertTrue(result > 0); // now check the number of subs left. should be one less than earlier int[] newSubIdsArray = mSubscriptionControllerUT.getActiveSubIdList(); int[] newSubIdsArray = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(newSubIdsArray.length > 0); assertEquals(len - 1, newSubIdsArray.length); Loading Loading @@ -802,8 +802,8 @@ public class SubscriptionControllerTest extends TelephonyTest { mSubscriptionControllerUT.addSubInfoRecord("123", 1); // sub 1 mSubscriptionControllerUT.addSubInfoRecord("456", 0); // sub 2 int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); // Make sure the return sub ids are sorted by slot index assertTrue("active sub ids = " + mSubscriptionControllerUT.getActiveSubIdList(), Arrays.equals(mSubscriptionControllerUT.getActiveSubIdList(), new int[]{2, 1})); assertTrue("active sub ids = " + subIds, Arrays.equals(subIds, new int[]{2, 1})); } }
tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -151,7 +151,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { ((MockContentResolver) mContext.getContentResolver()).addProvider( SubscriptionManager.CONTENT_URI.getAuthority(), new FakeSubscriptionContentProvider()); doReturn(new int[]{}).when(mSubscriptionController).getActiveSubIdList(); doReturn(new int[]{}).when(mSubscriptionController) .getActiveSubIdList(/*visibleOnly*/false); mIccRecord = mUiccProfile.getIccRecords(); mSubscriptionInfoUpdaterHandlerThread = new SubscriptionInfoUpdaterHandlerThread(TAG); Loading @@ -170,7 +171,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { public void testSimAbsent() throws Exception { doReturn(Arrays.asList(mSubInfo)).when(mSubscriptionController) .getSubInfoUsingSlotIndexPrivileged(eq(FAKE_SUB_ID_1), anyBoolean()); doReturn(new int[]{FAKE_SUB_ID_1}).when(mSubscriptionController).getActiveSubIdList(); doReturn(new int[]{FAKE_SUB_ID_1}).when(mSubscriptionController) .getActiveSubIdList(/*visibleOnly*/false); mUpdater.updateInternalIccState( IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, FAKE_SUB_ID_1); Loading