Merge "Do not consider SIM state for inactive SIM/modem slot."

This commit is contained in:
Treehugger Robot
2019-11-25 21:22:09 +00:00
committed by Gerrit Code Review
2 changed files with 17 additions and 5 deletions

View File

@@ -171,14 +171,17 @@ public class CarrierTextController {
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
mSeparator = separator; mSeparator = separator;
mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class); mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
mSimSlotsNumber = ((TelephonyManager) context.getSystemService( mSimSlotsNumber = getTelephonyManager().getSupportedModemCount();
Context.TELEPHONY_SERVICE)).getSupportedModemCount();
mSimErrorState = new boolean[mSimSlotsNumber]; mSimErrorState = new boolean[mSimSlotsNumber];
updateDisplayOpportunisticSubscriptionCarrierText(SystemProperties.getBoolean( updateDisplayOpportunisticSubscriptionCarrierText(SystemProperties.getBoolean(
TelephonyProperties.DISPLAY_OPPORTUNISTIC_SUBSCRIPTION_CARRIER_TEXT_PROPERTY_NAME, TelephonyProperties.DISPLAY_OPPORTUNISTIC_SUBSCRIPTION_CARRIER_TEXT_PROPERTY_NAME,
false)); false));
} }
private TelephonyManager getTelephonyManager() {
return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
}
/** /**
* Checks if there are faulty cards. Adds the text depending on the slot of the card * Checks if there are faulty cards. Adds the text depending on the slot of the card
* *
@@ -194,7 +197,7 @@ public class CarrierTextController {
CharSequence carrierTextForSimIOError = getCarrierTextForSimState( CharSequence carrierTextForSimIOError = getCarrierTextForSimState(
IccCardConstants.State.CARD_IO_ERROR, carrier); IccCardConstants.State.CARD_IO_ERROR, carrier);
// mSimErrorState has the state of each sim indexed by slotID. // mSimErrorState has the state of each sim indexed by slotID.
for (int index = 0; index < mSimErrorState.length; index++) { for (int index = 0; index < getTelephonyManager().getActiveModemCount(); index++) {
if (!mSimErrorState[index]) { if (!mSimErrorState[index]) {
continue; continue;
} }
@@ -227,8 +230,7 @@ public class CarrierTextController {
* @param callback Callback to provide text updates * @param callback Callback to provide text updates
*/ */
public void setListening(CarrierTextCallback callback) { public void setListening(CarrierTextCallback callback) {
TelephonyManager telephonyManager = ((TelephonyManager) mContext TelephonyManager telephonyManager = getTelephonyManager();
.getSystemService(Context.TELEPHONY_SERVICE));
if (callback != null) { if (callback != null) {
mCarrierTextCallback = callback; mCarrierTextCallback = callback;
if (ConnectivityManager.from(mContext).isNetworkSupported( if (ConnectivityManager.from(mContext).isNetworkSupported(

View File

@@ -120,6 +120,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
mCarrierTextCallbackInfo = new CarrierTextController.CarrierTextCallbackInfo("", mCarrierTextCallbackInfo = new CarrierTextController.CarrierTextCallbackInfo("",
new CharSequence[]{}, false, new int[]{}); new CharSequence[]{}, false, new int[]{});
when(mTelephonyManager.getSupportedModemCount()).thenReturn(3); when(mTelephonyManager.getSupportedModemCount()).thenReturn(3);
when(mTelephonyManager.getActiveModemCount()).thenReturn(3);
mCarrierTextController = new TestCarrierTextController(mContext, SEPARATOR, true, true, mCarrierTextController = new TestCarrierTextController(mContext, SEPARATOR, true, true,
mKeyguardUpdateMonitor); mKeyguardUpdateMonitor);
@@ -173,6 +174,15 @@ public class CarrierTextControllerTest extends SysuiTestCase {
// There's only one subscription in the list // There's only one subscription in the list
assertEquals(1, captor.getValue().listOfCarriers.length); assertEquals(1, captor.getValue().listOfCarriers.length);
assertEquals(TEST_CARRIER, captor.getValue().listOfCarriers[0]); assertEquals(TEST_CARRIER, captor.getValue().listOfCarriers[0]);
// Now it becomes single SIM active mode.
reset(mCarrierTextCallback);
when(mTelephonyManager.getActiveModemCount()).thenReturn(1);
// Update carrier text. It should ignore error state of subId 3 in inactive slotId.
mCarrierTextController.updateCarrierText();
mTestableLooper.processAllMessages();
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
assertEquals("TEST_CARRIER", captor.getValue().carrierText);
} }
@Test @Test