Loading packages/SystemUI/src/com/android/keyguard/CarrierTextController.java +3 −3 Original line number Diff line number Diff line Loading @@ -400,8 +400,11 @@ public class CarrierTextController { } } if (TextUtils.isEmpty(displayText)) displayText = joinNotEmpty(mSeparator, carrierNames); displayText = updateCarrierTextWithSimIoError(displayText, carrierNames, subOrderBySlot, allSimsMissing); boolean airplaneMode = false; // APM (airplane mode) != no carrier state. There are carrier services // (e.g. WFC = Wi-Fi calling) which may operate in APM. Loading @@ -410,9 +413,6 @@ public class CarrierTextController { airplaneMode = true; } if (TextUtils.isEmpty(displayText) && !airplaneMode) { displayText = joinNotEmpty(mSeparator, carrierNames); } final CarrierTextCallbackInfo info = new CarrierTextCallbackInfo( displayText, carrierNames, Loading packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java +54 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.Context; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; import android.os.Handler; import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -65,6 +66,8 @@ import java.util.List; public class CarrierTextControllerTest extends SysuiTestCase { private static final CharSequence SEPARATOR = " \u2014 "; private static final CharSequence INVALID_CARD_TEXT = "Invalid card"; private static final CharSequence AIRPLANE_MODE_TEXT = "Airplane mode"; private static final String TEST_CARRIER = "TEST_CARRIER"; private static final String TEST_CARRIER_2 = "TEST_CARRIER_2"; private static final String TEST_GROUP_UUID = "59b5c870-fc4c-47a4-a99e-9db826b48b24"; Loading Loading @@ -106,6 +109,10 @@ public class CarrierTextControllerTest extends SysuiTestCase { mContext.addMockSystemService(ConnectivityManager.class, mConnectivityManager); mContext.addMockSystemService(TelephonyManager.class, mTelephonyManager); mContext.addMockSystemService(SubscriptionManager.class, mSubscriptionManager); mContext.getOrCreateTestableResources().addOverride( R.string.keyguard_sim_error_message_short, INVALID_CARD_TEXT); mContext.getOrCreateTestableResources().addOverride( R.string.airplane_mode, AIRPLANE_MODE_TEXT); mDependency.injectMockDependency(WakefulnessLifecycle.class); mDependency.injectTestDependency(Dependency.MAIN_HANDLER, new Handler(mTestableLooper.getLooper())); Loading @@ -121,6 +128,53 @@ public class CarrierTextControllerTest extends SysuiTestCase { mCarrierTextController.updateDisplayOpportunisticSubscriptionCarrierText(false); } @Test public void testAirplaneMode() { Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1); reset(mCarrierTextCallback); List<SubscriptionInfo> list = new ArrayList<>(); list.add(TEST_SUBSCRIPTION); when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list); when(mKeyguardUpdateMonitor.getSimState(0)).thenReturn(IccCardConstants.State.READY); mKeyguardUpdateMonitor.mServiceStates = new HashMap<>(); mCarrierTextController.updateCarrierText(); ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor = ArgumentCaptor.forClass( CarrierTextController.CarrierTextCallbackInfo.class); mTestableLooper.processAllMessages(); verify(mCarrierTextCallback).updateCarrierInfo(captor.capture()); assertEquals(AIRPLANE_MODE_TEXT, captor.getValue().carrierText); } @Test public void testCardIOError() { reset(mCarrierTextCallback); List<SubscriptionInfo> list = new ArrayList<>(); list.add(TEST_SUBSCRIPTION); when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list); when(mKeyguardUpdateMonitor.getSimState(0)).thenReturn(IccCardConstants.State.READY); when(mKeyguardUpdateMonitor.getSimState(1)).thenReturn( IccCardConstants.State.CARD_IO_ERROR); mKeyguardUpdateMonitor.mServiceStates = new HashMap<>(); mCarrierTextController.mCallback.onSimStateChanged(3, 1, IccCardConstants.State.CARD_IO_ERROR); ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor = ArgumentCaptor.forClass( CarrierTextController.CarrierTextCallbackInfo.class); mTestableLooper.processAllMessages(); verify(mCarrierTextCallback).updateCarrierInfo(captor.capture()); assertEquals("TEST_CARRIER" + SEPARATOR + INVALID_CARD_TEXT, captor.getValue().carrierText); // There's only one subscription in the list assertEquals(1, captor.getValue().listOfCarriers.length); assertEquals(TEST_CARRIER, captor.getValue().listOfCarriers[0]); } @Test public void testWrongSlots() { reset(mCarrierTextCallback); Loading Loading
packages/SystemUI/src/com/android/keyguard/CarrierTextController.java +3 −3 Original line number Diff line number Diff line Loading @@ -400,8 +400,11 @@ public class CarrierTextController { } } if (TextUtils.isEmpty(displayText)) displayText = joinNotEmpty(mSeparator, carrierNames); displayText = updateCarrierTextWithSimIoError(displayText, carrierNames, subOrderBySlot, allSimsMissing); boolean airplaneMode = false; // APM (airplane mode) != no carrier state. There are carrier services // (e.g. WFC = Wi-Fi calling) which may operate in APM. Loading @@ -410,9 +413,6 @@ public class CarrierTextController { airplaneMode = true; } if (TextUtils.isEmpty(displayText) && !airplaneMode) { displayText = joinNotEmpty(mSeparator, carrierNames); } final CarrierTextCallbackInfo info = new CarrierTextCallbackInfo( displayText, carrierNames, Loading
packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java +54 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.Context; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; import android.os.Handler; import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -65,6 +66,8 @@ import java.util.List; public class CarrierTextControllerTest extends SysuiTestCase { private static final CharSequence SEPARATOR = " \u2014 "; private static final CharSequence INVALID_CARD_TEXT = "Invalid card"; private static final CharSequence AIRPLANE_MODE_TEXT = "Airplane mode"; private static final String TEST_CARRIER = "TEST_CARRIER"; private static final String TEST_CARRIER_2 = "TEST_CARRIER_2"; private static final String TEST_GROUP_UUID = "59b5c870-fc4c-47a4-a99e-9db826b48b24"; Loading Loading @@ -106,6 +109,10 @@ public class CarrierTextControllerTest extends SysuiTestCase { mContext.addMockSystemService(ConnectivityManager.class, mConnectivityManager); mContext.addMockSystemService(TelephonyManager.class, mTelephonyManager); mContext.addMockSystemService(SubscriptionManager.class, mSubscriptionManager); mContext.getOrCreateTestableResources().addOverride( R.string.keyguard_sim_error_message_short, INVALID_CARD_TEXT); mContext.getOrCreateTestableResources().addOverride( R.string.airplane_mode, AIRPLANE_MODE_TEXT); mDependency.injectMockDependency(WakefulnessLifecycle.class); mDependency.injectTestDependency(Dependency.MAIN_HANDLER, new Handler(mTestableLooper.getLooper())); Loading @@ -121,6 +128,53 @@ public class CarrierTextControllerTest extends SysuiTestCase { mCarrierTextController.updateDisplayOpportunisticSubscriptionCarrierText(false); } @Test public void testAirplaneMode() { Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1); reset(mCarrierTextCallback); List<SubscriptionInfo> list = new ArrayList<>(); list.add(TEST_SUBSCRIPTION); when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list); when(mKeyguardUpdateMonitor.getSimState(0)).thenReturn(IccCardConstants.State.READY); mKeyguardUpdateMonitor.mServiceStates = new HashMap<>(); mCarrierTextController.updateCarrierText(); ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor = ArgumentCaptor.forClass( CarrierTextController.CarrierTextCallbackInfo.class); mTestableLooper.processAllMessages(); verify(mCarrierTextCallback).updateCarrierInfo(captor.capture()); assertEquals(AIRPLANE_MODE_TEXT, captor.getValue().carrierText); } @Test public void testCardIOError() { reset(mCarrierTextCallback); List<SubscriptionInfo> list = new ArrayList<>(); list.add(TEST_SUBSCRIPTION); when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list); when(mKeyguardUpdateMonitor.getSimState(0)).thenReturn(IccCardConstants.State.READY); when(mKeyguardUpdateMonitor.getSimState(1)).thenReturn( IccCardConstants.State.CARD_IO_ERROR); mKeyguardUpdateMonitor.mServiceStates = new HashMap<>(); mCarrierTextController.mCallback.onSimStateChanged(3, 1, IccCardConstants.State.CARD_IO_ERROR); ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor = ArgumentCaptor.forClass( CarrierTextController.CarrierTextCallbackInfo.class); mTestableLooper.processAllMessages(); verify(mCarrierTextCallback).updateCarrierInfo(captor.capture()); assertEquals("TEST_CARRIER" + SEPARATOR + INVALID_CARD_TEXT, captor.getValue().carrierText); // There's only one subscription in the list assertEquals(1, captor.getValue().listOfCarriers.length); assertEquals(TEST_CARRIER, captor.getValue().listOfCarriers[0]); } @Test public void testWrongSlots() { reset(mCarrierTextCallback); Loading