Loading src/com/android/settings/network/CarrierConfigChangedReceiver.java +14 −2 Original line number Diff line number Diff line Loading @@ -32,9 +32,20 @@ public class CarrierConfigChangedReceiver extends BroadcastReceiver { CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED; private final CountDownLatch mLatch; private final boolean mIsWaitingForValidSubId; public CarrierConfigChangedReceiver(CountDownLatch latch) { /** * This is the CarrierConfigChanged receiver. If it receives the carrier config changed, then it * call the CountDownLatch.countDown(). * If the "isWaitingForValidSubId" is true, then the receiver skip the carrier config changed * with the subId = -1. The receiver executes the countDown when the CarrierConfigChanged * with valid subId. * If the "isWaitingForValidSubId" is false, then the receiver executes the countDown when * receiving any CarrierConfigChanged. */ public CarrierConfigChangedReceiver(CountDownLatch latch, boolean isWaitingForValidSubId) { mLatch = latch; mIsWaitingForValidSubId = isWaitingForValidSubId; } public void registerOn(Context context) { Loading @@ -53,7 +64,8 @@ public class CarrierConfigChangedReceiver extends BroadcastReceiver { } private void checkSubscriptionIndex(Intent intent) { if (intent.hasExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX)) { if (intent.hasExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX) || !mIsWaitingForValidSubId) { int subId = intent.getIntExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, -1); Log.i(TAG, "subId from config changed: " + subId); mLatch.countDown(); Loading src/com/android/settings/network/UiccSlotUtil.java +7 −4 Original line number Diff line number Diff line Loading @@ -141,7 +141,8 @@ public class UiccSlotUtil { inactiveRemovableSlot, /*removable sim's port Id*/ TelephonyManager.DEFAULT_PORT_INDEX, excludedLogicalSlotIndex), context); context, /*isWaitingForValidSubId=*/ true); } /** Loading Loading @@ -179,7 +180,8 @@ public class UiccSlotUtil { performSwitchToSlot(telMgr, prepareUiccSlotMappings(uiccSlotMappings, /*slot is not psim*/ false, physicalSlotId, port, excludedLogicalSlotIndex), context); context, /*isWaitingForValidSubId=*/ false); } /** Loading Loading @@ -231,7 +233,8 @@ public class UiccSlotUtil { } private static void performSwitchToSlot(TelephonyManager telMgr, Collection<UiccSlotMapping> uiccSlotMappings, Context context) Collection<UiccSlotMapping> uiccSlotMappings, Context context, boolean isWaitingForValidSubId) throws UiccSlotsException { CarrierConfigChangedReceiver receiver = null; long waitingTimeMillis = Loading @@ -241,7 +244,7 @@ public class UiccSlotUtil { DEFAULT_WAIT_AFTER_SWITCH_TIMEOUT_MILLIS); try { CountDownLatch latch = new CountDownLatch(1); receiver = new CarrierConfigChangedReceiver(latch); receiver = new CarrierConfigChangedReceiver(latch, isWaitingForValidSubId); receiver.registerOn(context); telMgr.setSimSlotMapping(uiccSlotMappings); latch.await(waitingTimeMillis, TimeUnit.MILLISECONDS); Loading Loading
src/com/android/settings/network/CarrierConfigChangedReceiver.java +14 −2 Original line number Diff line number Diff line Loading @@ -32,9 +32,20 @@ public class CarrierConfigChangedReceiver extends BroadcastReceiver { CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED; private final CountDownLatch mLatch; private final boolean mIsWaitingForValidSubId; public CarrierConfigChangedReceiver(CountDownLatch latch) { /** * This is the CarrierConfigChanged receiver. If it receives the carrier config changed, then it * call the CountDownLatch.countDown(). * If the "isWaitingForValidSubId" is true, then the receiver skip the carrier config changed * with the subId = -1. The receiver executes the countDown when the CarrierConfigChanged * with valid subId. * If the "isWaitingForValidSubId" is false, then the receiver executes the countDown when * receiving any CarrierConfigChanged. */ public CarrierConfigChangedReceiver(CountDownLatch latch, boolean isWaitingForValidSubId) { mLatch = latch; mIsWaitingForValidSubId = isWaitingForValidSubId; } public void registerOn(Context context) { Loading @@ -53,7 +64,8 @@ public class CarrierConfigChangedReceiver extends BroadcastReceiver { } private void checkSubscriptionIndex(Intent intent) { if (intent.hasExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX)) { if (intent.hasExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX) || !mIsWaitingForValidSubId) { int subId = intent.getIntExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, -1); Log.i(TAG, "subId from config changed: " + subId); mLatch.countDown(); Loading
src/com/android/settings/network/UiccSlotUtil.java +7 −4 Original line number Diff line number Diff line Loading @@ -141,7 +141,8 @@ public class UiccSlotUtil { inactiveRemovableSlot, /*removable sim's port Id*/ TelephonyManager.DEFAULT_PORT_INDEX, excludedLogicalSlotIndex), context); context, /*isWaitingForValidSubId=*/ true); } /** Loading Loading @@ -179,7 +180,8 @@ public class UiccSlotUtil { performSwitchToSlot(telMgr, prepareUiccSlotMappings(uiccSlotMappings, /*slot is not psim*/ false, physicalSlotId, port, excludedLogicalSlotIndex), context); context, /*isWaitingForValidSubId=*/ false); } /** Loading Loading @@ -231,7 +233,8 @@ public class UiccSlotUtil { } private static void performSwitchToSlot(TelephonyManager telMgr, Collection<UiccSlotMapping> uiccSlotMappings, Context context) Collection<UiccSlotMapping> uiccSlotMappings, Context context, boolean isWaitingForValidSubId) throws UiccSlotsException { CarrierConfigChangedReceiver receiver = null; long waitingTimeMillis = Loading @@ -241,7 +244,7 @@ public class UiccSlotUtil { DEFAULT_WAIT_AFTER_SWITCH_TIMEOUT_MILLIS); try { CountDownLatch latch = new CountDownLatch(1); receiver = new CarrierConfigChangedReceiver(latch); receiver = new CarrierConfigChangedReceiver(latch, isWaitingForValidSubId); receiver.registerOn(context); telMgr.setSimSlotMapping(uiccSlotMappings); latch.await(waitingTimeMillis, TimeUnit.MILLISECONDS); Loading