Loading src/java/com/android/internal/telephony/emergency/EmergencyStateTracker.java +16 −4 Original line number Diff line number Diff line Loading @@ -227,6 +227,7 @@ public class EmergencyStateTracker { @VisibleForTesting public interface TelephonyManagerProxy { int getPhoneCount(); int getSimState(int slotIndex); } private final TelephonyManagerProxy mTelephonyManagerProxy; Loading @@ -242,6 +243,11 @@ public class EmergencyStateTracker { public int getPhoneCount() { return mTelephonyManager.getActiveModemCount(); } @Override public int getSimState(int slotIndex) { return mTelephonyManager.getSimState(slotIndex); } } /** Loading Loading @@ -1072,10 +1078,10 @@ public class EmergencyStateTracker { @VisibleForTesting public boolean isEmergencyCallbackModeSupported(Phone phone) { int subId = phone.getSubId(); if (!SubscriptionManager.isValidSubscriptionId(subId)) { int phoneId = phone.getPhoneId(); if (!isSimReady(phoneId, subId)) { // If there is no SIM, refer to the saved last carrier configuration with valid // subscription. int phoneId = phone.getPhoneId(); Boolean savedConfig = mNoSimEcbmSupported.get(Integer.valueOf(phoneId)); if (savedConfig == null) { // Exceptional case such as with poor boot performance. Loading Loading @@ -1788,8 +1794,8 @@ public class EmergencyStateTracker { + ", ecbmSupported=" + savedConfig); } if (!SubscriptionManager.isValidSubscriptionId(subId)) { // invalid subId if (!isSimReady(slotIndex, subId)) { Rlog.i(TAG, "onCarrierConfigChanged SIM not ready"); return; } Loading Loading @@ -1833,6 +1839,12 @@ public class EmergencyStateTracker { + ", ecbmSupported=" + carrierConfig); } private boolean isSimReady(int slotIndex, int subId) { return SubscriptionManager.isValidSubscriptionId(subId) && mTelephonyManagerProxy.getSimState(slotIndex) == TelephonyManager.SIM_STATE_READY; } private boolean getBroadcastEmergencyCallStateChanges(Phone phone) { Boolean broadcast = mBroadcastEmergencyCallStateChanges.get( Integer.valueOf(phone.getPhoneId())); Loading tests/telephonytests/src/com/android/internal/telephony/emergency/EmergencyStateTrackerTest.java +33 −1 Original line number Diff line number Diff line Loading @@ -118,6 +118,9 @@ public class EmergencyStateTrackerTest extends TelephonyTest { public void setUp() throws Exception { super.setUp(getClass().getSimpleName()); MockitoAnnotations.initMocks(this); doReturn(TelephonyManager.SIM_STATE_READY) .when(mTelephonyManagerProxy).getSimState(anyInt()); } @After Loading Loading @@ -2395,6 +2398,7 @@ public class EmergencyStateTrackerTest extends TelephonyTest { // Verify carrier config for valid subscription assertTrue(testEst.isEmergencyCallbackModeSupported(phone)); // onCarrierConfigurationChanged is not called yet. // SIM removed when(phone.getSubId()).thenReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID); setEcmSupportedConfig(phone, false); Loading Loading @@ -2423,7 +2427,35 @@ public class EmergencyStateTrackerTest extends TelephonyTest { // Verify saved config for valid subscription assertTrue(testEst.isEmergencyCallbackModeSupported(phone)); // Insert SIM again, but emergency callback mode not supported // Insert SIM in PIN locked again, but emergency callback mode not supported doReturn(TelephonyManager.SIM_STATE_PIN_REQUIRED) .when(mTelephonyManagerProxy).getSimState(anyInt()); when(phone.getSubId()).thenReturn(1); setEcmSupportedConfig(phone, false); // onCarrierConfigChanged with valid subscription carrierConfigChangeListener.onCarrierConfigChanged( phone.getPhoneId(), phone.getSubId(), TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID); // Verify carrier config for valid subscription in PIN locked state, saved configuration assertTrue(testEst.isEmergencyCallbackModeSupported(phone)); // SIM removed again when(phone.getSubId()).thenReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID); setEcmSupportedConfig(phone, false); // onCarrierConfigChanged with invalid subscription carrierConfigChangeListener.onCarrierConfigChanged( phone.getPhoneId(), phone.getSubId(), TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID); // Verify saved config for valid subscription assertTrue(testEst.isEmergencyCallbackModeSupported(phone)); // Insert SIM, PIN verified, again, but emergency callback mode not supported doReturn(TelephonyManager.SIM_STATE_READY) .when(mTelephonyManagerProxy).getSimState(anyInt()); when(phone.getSubId()).thenReturn(1); setEcmSupportedConfig(phone, false); Loading Loading
src/java/com/android/internal/telephony/emergency/EmergencyStateTracker.java +16 −4 Original line number Diff line number Diff line Loading @@ -227,6 +227,7 @@ public class EmergencyStateTracker { @VisibleForTesting public interface TelephonyManagerProxy { int getPhoneCount(); int getSimState(int slotIndex); } private final TelephonyManagerProxy mTelephonyManagerProxy; Loading @@ -242,6 +243,11 @@ public class EmergencyStateTracker { public int getPhoneCount() { return mTelephonyManager.getActiveModemCount(); } @Override public int getSimState(int slotIndex) { return mTelephonyManager.getSimState(slotIndex); } } /** Loading Loading @@ -1072,10 +1078,10 @@ public class EmergencyStateTracker { @VisibleForTesting public boolean isEmergencyCallbackModeSupported(Phone phone) { int subId = phone.getSubId(); if (!SubscriptionManager.isValidSubscriptionId(subId)) { int phoneId = phone.getPhoneId(); if (!isSimReady(phoneId, subId)) { // If there is no SIM, refer to the saved last carrier configuration with valid // subscription. int phoneId = phone.getPhoneId(); Boolean savedConfig = mNoSimEcbmSupported.get(Integer.valueOf(phoneId)); if (savedConfig == null) { // Exceptional case such as with poor boot performance. Loading Loading @@ -1788,8 +1794,8 @@ public class EmergencyStateTracker { + ", ecbmSupported=" + savedConfig); } if (!SubscriptionManager.isValidSubscriptionId(subId)) { // invalid subId if (!isSimReady(slotIndex, subId)) { Rlog.i(TAG, "onCarrierConfigChanged SIM not ready"); return; } Loading Loading @@ -1833,6 +1839,12 @@ public class EmergencyStateTracker { + ", ecbmSupported=" + carrierConfig); } private boolean isSimReady(int slotIndex, int subId) { return SubscriptionManager.isValidSubscriptionId(subId) && mTelephonyManagerProxy.getSimState(slotIndex) == TelephonyManager.SIM_STATE_READY; } private boolean getBroadcastEmergencyCallStateChanges(Phone phone) { Boolean broadcast = mBroadcastEmergencyCallStateChanges.get( Integer.valueOf(phone.getPhoneId())); Loading
tests/telephonytests/src/com/android/internal/telephony/emergency/EmergencyStateTrackerTest.java +33 −1 Original line number Diff line number Diff line Loading @@ -118,6 +118,9 @@ public class EmergencyStateTrackerTest extends TelephonyTest { public void setUp() throws Exception { super.setUp(getClass().getSimpleName()); MockitoAnnotations.initMocks(this); doReturn(TelephonyManager.SIM_STATE_READY) .when(mTelephonyManagerProxy).getSimState(anyInt()); } @After Loading Loading @@ -2395,6 +2398,7 @@ public class EmergencyStateTrackerTest extends TelephonyTest { // Verify carrier config for valid subscription assertTrue(testEst.isEmergencyCallbackModeSupported(phone)); // onCarrierConfigurationChanged is not called yet. // SIM removed when(phone.getSubId()).thenReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID); setEcmSupportedConfig(phone, false); Loading Loading @@ -2423,7 +2427,35 @@ public class EmergencyStateTrackerTest extends TelephonyTest { // Verify saved config for valid subscription assertTrue(testEst.isEmergencyCallbackModeSupported(phone)); // Insert SIM again, but emergency callback mode not supported // Insert SIM in PIN locked again, but emergency callback mode not supported doReturn(TelephonyManager.SIM_STATE_PIN_REQUIRED) .when(mTelephonyManagerProxy).getSimState(anyInt()); when(phone.getSubId()).thenReturn(1); setEcmSupportedConfig(phone, false); // onCarrierConfigChanged with valid subscription carrierConfigChangeListener.onCarrierConfigChanged( phone.getPhoneId(), phone.getSubId(), TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID); // Verify carrier config for valid subscription in PIN locked state, saved configuration assertTrue(testEst.isEmergencyCallbackModeSupported(phone)); // SIM removed again when(phone.getSubId()).thenReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID); setEcmSupportedConfig(phone, false); // onCarrierConfigChanged with invalid subscription carrierConfigChangeListener.onCarrierConfigChanged( phone.getPhoneId(), phone.getSubId(), TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID); // Verify saved config for valid subscription assertTrue(testEst.isEmergencyCallbackModeSupported(phone)); // Insert SIM, PIN verified, again, but emergency callback mode not supported doReturn(TelephonyManager.SIM_STATE_READY) .when(mTelephonyManagerProxy).getSimState(anyInt()); when(phone.getSubId()).thenReturn(1); setEcmSupportedConfig(phone, false); Loading