Loading src/java/com/android/internal/telephony/ServiceStateTracker.java +16 −14 Original line number Diff line number Diff line Loading @@ -279,7 +279,6 @@ public class ServiceStateTracker extends Handler { protected static final int EVENT_RADIO_POWER_OFF_DONE = 54; protected static final int EVENT_PHYSICAL_CHANNEL_CONFIG = 55; protected static final int EVENT_CELL_LOCATION_RESPONSE = 56; protected static final int EVENT_CARRIER_CONFIG_CHANGED = 57; private static final int EVENT_POLL_STATE_REQUEST = 58; // Timeout event used when delaying radio power off to wait for IMS deregistration to happen. private static final int EVENT_POWER_OFF_RADIO_IMS_DEREG_TIMEOUT = 62; Loading Loading @@ -557,13 +556,7 @@ public class ServiceStateTracker extends Handler { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) { int phoneId = intent.getExtras().getInt(CarrierConfigManager.EXTRA_SLOT_INDEX); // Ignore the carrier config changed if the phoneId is not matched. if (phoneId == mPhone.getPhoneId()) { sendEmptyMessage(EVENT_CARRIER_CONFIG_CHANGED); } } else if (action.equals(Intent.ACTION_LOCALE_CHANGED)) { if (action.equals(Intent.ACTION_LOCALE_CHANGED)) { // Update emergency string or operator name, polling service state. pollState(); } else if (action.equals(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED)) { Loading @@ -576,6 +569,10 @@ public class ServiceStateTracker extends Handler { } }; private final CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener = (slotIndex, subId, carrierId, specificCarrierId) -> onCarrierConfigurationChanged(slotIndex); //CDMA // Min values used to by getOtasp() public static final String UNACTIVATED_MIN2_VALUE = "000000"; Loading Loading @@ -662,7 +659,11 @@ public class ServiceStateTracker extends Handler { mSubscriptionManager.addOnSubscriptionsChangedListener( new android.os.HandlerExecutor(this), mOnSubscriptionsChangedListener); mRestrictedState = new RestrictedState(); mCarrierConfig = getCarrierConfig(); CarrierConfigManager ccm = mPhone.getContext().getSystemService(CarrierConfigManager.class); // Callback which directly handle config change should be executed in handler thread ccm.registerCarrierConfigChangeListener(this::post, mCarrierConfigChangeListener); mAccessNetworksManager = mPhone.getAccessNetworksManager(); mOutOfServiceSS = new ServiceState(); Loading Loading @@ -701,7 +702,6 @@ public class ServiceStateTracker extends Handler { Context context = mPhone.getContext(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_LOCALE_CHANGED); filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); filter.addAction(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED); context.registerReceiver(mIntentReceiver, filter); Loading Loading @@ -862,6 +862,10 @@ public class ServiceStateTracker extends Handler { mPhone.getCarrierActionAgent().unregisterForCarrierAction(this, CARRIER_ACTION_SET_RADIO_ENABLED); mPhone.getContext().unregisterReceiver(mIntentReceiver); CarrierConfigManager ccm = mPhone.getContext().getSystemService(CarrierConfigManager.class); if (ccm != null && mCarrierConfigChangeListener != null) { ccm.unregisterCarrierConfigChangeListener(mCarrierConfigChangeListener); } if (mCSST != null) { mCSST.dispose(); mCSST = null; Loading Loading @@ -1730,10 +1734,6 @@ public class ServiceStateTracker extends Handler { rspRspMsg.sendToTarget(); break; case EVENT_CARRIER_CONFIG_CHANGED: onCarrierConfigChanged(); break; case EVENT_POLL_STATE_REQUEST: pollStateInternal(false); break; Loading Loading @@ -5055,7 +5055,9 @@ public class ServiceStateTracker extends Handler { } } private void onCarrierConfigChanged() { private void onCarrierConfigurationChanged(int slotIndex) { if (slotIndex != mPhone.getPhoneId()) return; mCarrierConfig = getCarrierConfig(); log("CarrierConfigChange " + mCarrierConfig); Loading tests/telephonytests/src/com/android/internal/telephony/DisplayInfoControllerTest.java +20 −18 Original line number Diff line number Diff line Loading @@ -18,13 +18,12 @@ package com.android.internal.telephony; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.when; import static org.mockito.Mockito.verify; import android.content.Context; import android.content.Intent; import android.os.AsyncResult; import android.os.HandlerThread; import android.os.PersistableBundle; Loading @@ -36,6 +35,7 @@ import android.telephony.CellIdentityLte; import android.telephony.LteVopsSupportInfo; import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.testing.AndroidTestingRunner; Loading @@ -46,7 +46,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.mockito.ArgumentCaptor; import java.util.Collections; import java.util.concurrent.Executor; Loading @@ -66,6 +66,7 @@ public class DisplayInfoControllerTest extends TelephonyTest { private ServiceStateTrackerTestHandler mSstHandler; private SignalStrengthController mSsc; private PersistableBundle mBundle; private CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener; private class ServiceStateTrackerTestHandler extends HandlerThread { private ServiceStateTrackerTestHandler(String name) { Loading @@ -80,7 +81,16 @@ public class DisplayInfoControllerTest extends TelephonyTest { doReturn(NUMERIC).when(mTelephonyManager).getSimOperatorNumericForPhone(eq(PHONE_ID)); doReturn(NETWORK).when(mTelephonyManager).getSimOperatorNameForPhone(eq(PHONE_ID)); // Capture listener registered for ServiceStateTracker to emulate the carrier config // change notification used later. In this test, it's the second one. The first one // comes from RatRatcheter. ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor = ArgumentCaptor.forClass( CarrierConfigManager.CarrierConfigChangeListener.class); mSst = new ServiceStateTracker(mPhone, mSimulatedCommands); verify(mCarrierConfigManager, atLeast(2)).registerCarrierConfigChangeListener(any(), listenerArgumentCaptor.capture()); mCarrierConfigChangeListener = listenerArgumentCaptor.getAllValues().get(1); doReturn(mSst).when(mPhone).getServiceStateTracker(); setReady(true); } Loading @@ -92,6 +102,7 @@ public class DisplayInfoControllerTest extends TelephonyTest { super.setUp(getClass().getSimpleName()); doReturn((Executor) Runnable::run).when(mContext).getMainExecutor(); mBundle = mContextFixture.getCarrierConfigBundle(); mSstHandler = new ServiceStateTrackerTestHandler(getClass().getSimpleName()); mSstHandler.start(); waitUntilReady(); Loading @@ -106,18 +117,14 @@ public class DisplayInfoControllerTest extends TelephonyTest { mSstHandler.join(); mSstHandler = null; mBundle = null; mCarrierConfigChangeListener = null; super.tearDown(); } private void sendCarrierConfigUpdate() { CarrierConfigManager mockConfigManager = Mockito.mock(CarrierConfigManager.class); when(mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE)) .thenReturn(mockConfigManager); when(mockConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle); Intent intent = new Intent().setAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); intent.putExtra(CarrierConfigManager.EXTRA_SLOT_INDEX, PHONE_ID); mContext.sendBroadcast(intent); mCarrierConfigChangeListener.onCarrierConfigChanged(PHONE_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID, TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID); waitForLastHandlerAction(mSstHandler.getThreadHandler()); } Loading Loading @@ -174,7 +181,6 @@ public class DisplayInfoControllerTest extends TelephonyTest { public void testIsRoamingOverride_NonRoamingOperator() { doReturn(true).when(mPhone).isPhoneTypeGsm(); mBundle = mContextFixture.getCarrierConfigBundle(); mBundle.putStringArray( CarrierConfigManager.KEY_NON_ROAMING_OPERATOR_STRING_ARRAY, new String[] {NUMERIC}); sendCarrierConfigUpdate(); Loading @@ -196,7 +202,6 @@ public class DisplayInfoControllerTest extends TelephonyTest { public void testIsRoamingOverride_ForceHomeNetwork() { doReturn(true).when(mPhone).isPhoneTypeGsm(); mBundle = mContextFixture.getCarrierConfigBundle(); mBundle.putBoolean(CarrierConfigManager.KEY_FORCE_HOME_NETWORK_BOOL, true); sendCarrierConfigUpdate(); Loading @@ -217,7 +222,6 @@ public class DisplayInfoControllerTest extends TelephonyTest { public void testIsRoamingOverride_RoamingOperator() { doReturn(true).when(mPhone).isPhoneTypeGsm(); mBundle = mContextFixture.getCarrierConfigBundle(); mBundle.putStringArray( CarrierConfigManager.KEY_ROAMING_OPERATOR_STRING_ARRAY, new String[] {"60101"}); sendCarrierConfigUpdate(); Loading @@ -239,7 +243,6 @@ public class DisplayInfoControllerTest extends TelephonyTest { public void testIsRoamingOverride_NonRoamingGsmOperator() { doReturn(true).when(mPhone).isPhoneTypeGsm(); mBundle = mContextFixture.getCarrierConfigBundle(); mBundle.putStringArray( CarrierConfigManager.KEY_GSM_NONROAMING_NETWORKS_STRING_ARRAY, new String[] {NUMERIC}); Loading @@ -262,7 +265,6 @@ public class DisplayInfoControllerTest extends TelephonyTest { public void testIsRoamingOverride_RoamingGsmOperator() { doReturn(true).when(mPhone).isPhoneTypeGsm(); mBundle = mContextFixture.getCarrierConfigBundle(); mBundle.putStringArray( CarrierConfigManager.KEY_GSM_ROAMING_NETWORKS_STRING_ARRAY, new String[] {NUMERIC}); sendCarrierConfigUpdate(); Loading tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java +20 −14 Original line number Diff line number Diff line Loading @@ -127,6 +127,7 @@ public class ServiceStateTrackerTest extends TelephonyTest { private ServiceStateStats mServiceStateStats; private CellularNetworkService mCellularNetworkService; private CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener; // SST now delegates all signal strength operations to SSC // Add Mock SSC as the dependency to avoid NPE Loading Loading @@ -184,7 +185,18 @@ public class ServiceStateTrackerTest extends TelephonyTest { mSsc = new SignalStrengthController(mPhone); doReturn(mSsc).when(mPhone).getSignalStrengthController(); // Capture listener registered for ServiceStateTracker to emulate the carrier config // change notification used later. In this test, it's the third one. The first one // comes from RatRatcheter and the second one comes from SignalStrengthController. ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor = ArgumentCaptor.forClass( CarrierConfigManager.CarrierConfigChangeListener.class); sst = new ServiceStateTracker(mPhone, mSimulatedCommands); verify(mCarrierConfigManager, atLeast(3)).registerCarrierConfigChangeListener(any(), listenerArgumentCaptor.capture()); mCarrierConfigChangeListener = listenerArgumentCaptor.getAllValues().get(2); sst.setServiceStateStats(mServiceStateStats); doReturn(sst).when(mPhone).getServiceStateTracker(); setReady(true); Loading Loading @@ -253,6 +265,7 @@ public class ServiceStateTrackerTest extends TelephonyTest { replaceInstance(ProxyController.class, "sProxyController", null, mProxyController); mBundle = mContextFixture.getCarrierConfigBundle(); when(mCarrierConfigManager.getConfigForSubId(anyInt(), any())).thenReturn(mBundle); when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle); mBundle.putStringArray( CarrierConfigManager.KEY_ROAMING_OPERATOR_STRING_ARRAY, new String[]{"123456"}); Loading Loading @@ -355,9 +368,7 @@ public class ServiceStateTrackerTest extends TelephonyTest { 30 /* SIGNAL_STRENGTH_GREAT */ }); Intent intent = new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); intent.putExtra(CarrierConfigManager.EXTRA_SLOT_INDEX, 0); mContext.sendBroadcast(intent); sendCarrierConfigUpdate(PHONE_ID); waitForLastHandlerAction(mSSTTestHandler.getThreadHandler()); logd("ServiceStateTrackerTest -Setup!"); Loading Loading @@ -826,15 +837,10 @@ public class ServiceStateTrackerTest extends TelephonyTest { verify(mPhone, times(1)).notifyServiceStateChanged(any(ServiceState.class)); } private void sendCarrierConfigUpdate() { CarrierConfigManager mockConfigManager = Mockito.mock(CarrierConfigManager.class); when(mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE)) .thenReturn(mockConfigManager); when(mockConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle); Intent intent = new Intent().setAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); intent.putExtra(CarrierConfigManager.EXTRA_SLOT_INDEX, PHONE_ID); mContext.sendBroadcast(intent); private void sendCarrierConfigUpdate(int phoneId) { mCarrierConfigChangeListener.onCarrierConfigChanged(phoneId, SubscriptionManager.INVALID_SUBSCRIPTION_ID, TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID); waitForLastHandlerAction(mSSTTestHandler.getThreadHandler()); } Loading Loading @@ -2869,7 +2875,7 @@ public class ServiceStateTrackerTest extends TelephonyTest { public void testUpdateSpnDisplay_spnEmptyAndWifiCallingEnabled_showPlmnOnly() { // set empty service provider name mBundle.putString(CarrierConfigManager.KEY_CARRIER_NAME_STRING, ""); sendCarrierConfigUpdate(); sendCarrierConfigUpdate(PHONE_ID); // GSM phone doReturn(true).when(mPhone).isPhoneTypeGsm(); Loading Loading @@ -2949,7 +2955,7 @@ public class ServiceStateTrackerTest extends TelephonyTest { public void testUpdateSpnDisplayLegacy_WlanServiceNoWifiCalling_displayOOS() { mBundle.putBoolean( CarrierConfigManager.KEY_ENABLE_CARRIER_DISPLAY_NAME_RESOLVER_BOOL, false); sendCarrierConfigUpdate(); sendCarrierConfigUpdate(PHONE_ID); // GSM phone doReturn(true).when(mPhone).isPhoneTypeGsm(); Loading Loading
src/java/com/android/internal/telephony/ServiceStateTracker.java +16 −14 Original line number Diff line number Diff line Loading @@ -279,7 +279,6 @@ public class ServiceStateTracker extends Handler { protected static final int EVENT_RADIO_POWER_OFF_DONE = 54; protected static final int EVENT_PHYSICAL_CHANNEL_CONFIG = 55; protected static final int EVENT_CELL_LOCATION_RESPONSE = 56; protected static final int EVENT_CARRIER_CONFIG_CHANGED = 57; private static final int EVENT_POLL_STATE_REQUEST = 58; // Timeout event used when delaying radio power off to wait for IMS deregistration to happen. private static final int EVENT_POWER_OFF_RADIO_IMS_DEREG_TIMEOUT = 62; Loading Loading @@ -557,13 +556,7 @@ public class ServiceStateTracker extends Handler { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) { int phoneId = intent.getExtras().getInt(CarrierConfigManager.EXTRA_SLOT_INDEX); // Ignore the carrier config changed if the phoneId is not matched. if (phoneId == mPhone.getPhoneId()) { sendEmptyMessage(EVENT_CARRIER_CONFIG_CHANGED); } } else if (action.equals(Intent.ACTION_LOCALE_CHANGED)) { if (action.equals(Intent.ACTION_LOCALE_CHANGED)) { // Update emergency string or operator name, polling service state. pollState(); } else if (action.equals(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED)) { Loading @@ -576,6 +569,10 @@ public class ServiceStateTracker extends Handler { } }; private final CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener = (slotIndex, subId, carrierId, specificCarrierId) -> onCarrierConfigurationChanged(slotIndex); //CDMA // Min values used to by getOtasp() public static final String UNACTIVATED_MIN2_VALUE = "000000"; Loading Loading @@ -662,7 +659,11 @@ public class ServiceStateTracker extends Handler { mSubscriptionManager.addOnSubscriptionsChangedListener( new android.os.HandlerExecutor(this), mOnSubscriptionsChangedListener); mRestrictedState = new RestrictedState(); mCarrierConfig = getCarrierConfig(); CarrierConfigManager ccm = mPhone.getContext().getSystemService(CarrierConfigManager.class); // Callback which directly handle config change should be executed in handler thread ccm.registerCarrierConfigChangeListener(this::post, mCarrierConfigChangeListener); mAccessNetworksManager = mPhone.getAccessNetworksManager(); mOutOfServiceSS = new ServiceState(); Loading Loading @@ -701,7 +702,6 @@ public class ServiceStateTracker extends Handler { Context context = mPhone.getContext(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_LOCALE_CHANGED); filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); filter.addAction(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED); context.registerReceiver(mIntentReceiver, filter); Loading Loading @@ -862,6 +862,10 @@ public class ServiceStateTracker extends Handler { mPhone.getCarrierActionAgent().unregisterForCarrierAction(this, CARRIER_ACTION_SET_RADIO_ENABLED); mPhone.getContext().unregisterReceiver(mIntentReceiver); CarrierConfigManager ccm = mPhone.getContext().getSystemService(CarrierConfigManager.class); if (ccm != null && mCarrierConfigChangeListener != null) { ccm.unregisterCarrierConfigChangeListener(mCarrierConfigChangeListener); } if (mCSST != null) { mCSST.dispose(); mCSST = null; Loading Loading @@ -1730,10 +1734,6 @@ public class ServiceStateTracker extends Handler { rspRspMsg.sendToTarget(); break; case EVENT_CARRIER_CONFIG_CHANGED: onCarrierConfigChanged(); break; case EVENT_POLL_STATE_REQUEST: pollStateInternal(false); break; Loading Loading @@ -5055,7 +5055,9 @@ public class ServiceStateTracker extends Handler { } } private void onCarrierConfigChanged() { private void onCarrierConfigurationChanged(int slotIndex) { if (slotIndex != mPhone.getPhoneId()) return; mCarrierConfig = getCarrierConfig(); log("CarrierConfigChange " + mCarrierConfig); Loading
tests/telephonytests/src/com/android/internal/telephony/DisplayInfoControllerTest.java +20 −18 Original line number Diff line number Diff line Loading @@ -18,13 +18,12 @@ package com.android.internal.telephony; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.when; import static org.mockito.Mockito.verify; import android.content.Context; import android.content.Intent; import android.os.AsyncResult; import android.os.HandlerThread; import android.os.PersistableBundle; Loading @@ -36,6 +35,7 @@ import android.telephony.CellIdentityLte; import android.telephony.LteVopsSupportInfo; import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.testing.AndroidTestingRunner; Loading @@ -46,7 +46,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.mockito.ArgumentCaptor; import java.util.Collections; import java.util.concurrent.Executor; Loading @@ -66,6 +66,7 @@ public class DisplayInfoControllerTest extends TelephonyTest { private ServiceStateTrackerTestHandler mSstHandler; private SignalStrengthController mSsc; private PersistableBundle mBundle; private CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener; private class ServiceStateTrackerTestHandler extends HandlerThread { private ServiceStateTrackerTestHandler(String name) { Loading @@ -80,7 +81,16 @@ public class DisplayInfoControllerTest extends TelephonyTest { doReturn(NUMERIC).when(mTelephonyManager).getSimOperatorNumericForPhone(eq(PHONE_ID)); doReturn(NETWORK).when(mTelephonyManager).getSimOperatorNameForPhone(eq(PHONE_ID)); // Capture listener registered for ServiceStateTracker to emulate the carrier config // change notification used later. In this test, it's the second one. The first one // comes from RatRatcheter. ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor = ArgumentCaptor.forClass( CarrierConfigManager.CarrierConfigChangeListener.class); mSst = new ServiceStateTracker(mPhone, mSimulatedCommands); verify(mCarrierConfigManager, atLeast(2)).registerCarrierConfigChangeListener(any(), listenerArgumentCaptor.capture()); mCarrierConfigChangeListener = listenerArgumentCaptor.getAllValues().get(1); doReturn(mSst).when(mPhone).getServiceStateTracker(); setReady(true); } Loading @@ -92,6 +102,7 @@ public class DisplayInfoControllerTest extends TelephonyTest { super.setUp(getClass().getSimpleName()); doReturn((Executor) Runnable::run).when(mContext).getMainExecutor(); mBundle = mContextFixture.getCarrierConfigBundle(); mSstHandler = new ServiceStateTrackerTestHandler(getClass().getSimpleName()); mSstHandler.start(); waitUntilReady(); Loading @@ -106,18 +117,14 @@ public class DisplayInfoControllerTest extends TelephonyTest { mSstHandler.join(); mSstHandler = null; mBundle = null; mCarrierConfigChangeListener = null; super.tearDown(); } private void sendCarrierConfigUpdate() { CarrierConfigManager mockConfigManager = Mockito.mock(CarrierConfigManager.class); when(mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE)) .thenReturn(mockConfigManager); when(mockConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle); Intent intent = new Intent().setAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); intent.putExtra(CarrierConfigManager.EXTRA_SLOT_INDEX, PHONE_ID); mContext.sendBroadcast(intent); mCarrierConfigChangeListener.onCarrierConfigChanged(PHONE_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID, TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID); waitForLastHandlerAction(mSstHandler.getThreadHandler()); } Loading Loading @@ -174,7 +181,6 @@ public class DisplayInfoControllerTest extends TelephonyTest { public void testIsRoamingOverride_NonRoamingOperator() { doReturn(true).when(mPhone).isPhoneTypeGsm(); mBundle = mContextFixture.getCarrierConfigBundle(); mBundle.putStringArray( CarrierConfigManager.KEY_NON_ROAMING_OPERATOR_STRING_ARRAY, new String[] {NUMERIC}); sendCarrierConfigUpdate(); Loading @@ -196,7 +202,6 @@ public class DisplayInfoControllerTest extends TelephonyTest { public void testIsRoamingOverride_ForceHomeNetwork() { doReturn(true).when(mPhone).isPhoneTypeGsm(); mBundle = mContextFixture.getCarrierConfigBundle(); mBundle.putBoolean(CarrierConfigManager.KEY_FORCE_HOME_NETWORK_BOOL, true); sendCarrierConfigUpdate(); Loading @@ -217,7 +222,6 @@ public class DisplayInfoControllerTest extends TelephonyTest { public void testIsRoamingOverride_RoamingOperator() { doReturn(true).when(mPhone).isPhoneTypeGsm(); mBundle = mContextFixture.getCarrierConfigBundle(); mBundle.putStringArray( CarrierConfigManager.KEY_ROAMING_OPERATOR_STRING_ARRAY, new String[] {"60101"}); sendCarrierConfigUpdate(); Loading @@ -239,7 +243,6 @@ public class DisplayInfoControllerTest extends TelephonyTest { public void testIsRoamingOverride_NonRoamingGsmOperator() { doReturn(true).when(mPhone).isPhoneTypeGsm(); mBundle = mContextFixture.getCarrierConfigBundle(); mBundle.putStringArray( CarrierConfigManager.KEY_GSM_NONROAMING_NETWORKS_STRING_ARRAY, new String[] {NUMERIC}); Loading @@ -262,7 +265,6 @@ public class DisplayInfoControllerTest extends TelephonyTest { public void testIsRoamingOverride_RoamingGsmOperator() { doReturn(true).when(mPhone).isPhoneTypeGsm(); mBundle = mContextFixture.getCarrierConfigBundle(); mBundle.putStringArray( CarrierConfigManager.KEY_GSM_ROAMING_NETWORKS_STRING_ARRAY, new String[] {NUMERIC}); sendCarrierConfigUpdate(); Loading
tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java +20 −14 Original line number Diff line number Diff line Loading @@ -127,6 +127,7 @@ public class ServiceStateTrackerTest extends TelephonyTest { private ServiceStateStats mServiceStateStats; private CellularNetworkService mCellularNetworkService; private CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener; // SST now delegates all signal strength operations to SSC // Add Mock SSC as the dependency to avoid NPE Loading Loading @@ -184,7 +185,18 @@ public class ServiceStateTrackerTest extends TelephonyTest { mSsc = new SignalStrengthController(mPhone); doReturn(mSsc).when(mPhone).getSignalStrengthController(); // Capture listener registered for ServiceStateTracker to emulate the carrier config // change notification used later. In this test, it's the third one. The first one // comes from RatRatcheter and the second one comes from SignalStrengthController. ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor = ArgumentCaptor.forClass( CarrierConfigManager.CarrierConfigChangeListener.class); sst = new ServiceStateTracker(mPhone, mSimulatedCommands); verify(mCarrierConfigManager, atLeast(3)).registerCarrierConfigChangeListener(any(), listenerArgumentCaptor.capture()); mCarrierConfigChangeListener = listenerArgumentCaptor.getAllValues().get(2); sst.setServiceStateStats(mServiceStateStats); doReturn(sst).when(mPhone).getServiceStateTracker(); setReady(true); Loading Loading @@ -253,6 +265,7 @@ public class ServiceStateTrackerTest extends TelephonyTest { replaceInstance(ProxyController.class, "sProxyController", null, mProxyController); mBundle = mContextFixture.getCarrierConfigBundle(); when(mCarrierConfigManager.getConfigForSubId(anyInt(), any())).thenReturn(mBundle); when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle); mBundle.putStringArray( CarrierConfigManager.KEY_ROAMING_OPERATOR_STRING_ARRAY, new String[]{"123456"}); Loading Loading @@ -355,9 +368,7 @@ public class ServiceStateTrackerTest extends TelephonyTest { 30 /* SIGNAL_STRENGTH_GREAT */ }); Intent intent = new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); intent.putExtra(CarrierConfigManager.EXTRA_SLOT_INDEX, 0); mContext.sendBroadcast(intent); sendCarrierConfigUpdate(PHONE_ID); waitForLastHandlerAction(mSSTTestHandler.getThreadHandler()); logd("ServiceStateTrackerTest -Setup!"); Loading Loading @@ -826,15 +837,10 @@ public class ServiceStateTrackerTest extends TelephonyTest { verify(mPhone, times(1)).notifyServiceStateChanged(any(ServiceState.class)); } private void sendCarrierConfigUpdate() { CarrierConfigManager mockConfigManager = Mockito.mock(CarrierConfigManager.class); when(mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE)) .thenReturn(mockConfigManager); when(mockConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle); Intent intent = new Intent().setAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); intent.putExtra(CarrierConfigManager.EXTRA_SLOT_INDEX, PHONE_ID); mContext.sendBroadcast(intent); private void sendCarrierConfigUpdate(int phoneId) { mCarrierConfigChangeListener.onCarrierConfigChanged(phoneId, SubscriptionManager.INVALID_SUBSCRIPTION_ID, TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID); waitForLastHandlerAction(mSSTTestHandler.getThreadHandler()); } Loading Loading @@ -2869,7 +2875,7 @@ public class ServiceStateTrackerTest extends TelephonyTest { public void testUpdateSpnDisplay_spnEmptyAndWifiCallingEnabled_showPlmnOnly() { // set empty service provider name mBundle.putString(CarrierConfigManager.KEY_CARRIER_NAME_STRING, ""); sendCarrierConfigUpdate(); sendCarrierConfigUpdate(PHONE_ID); // GSM phone doReturn(true).when(mPhone).isPhoneTypeGsm(); Loading Loading @@ -2949,7 +2955,7 @@ public class ServiceStateTrackerTest extends TelephonyTest { public void testUpdateSpnDisplayLegacy_WlanServiceNoWifiCalling_displayOOS() { mBundle.putBoolean( CarrierConfigManager.KEY_ENABLE_CARRIER_DISPLAY_NAME_RESOLVER_BOOL, false); sendCarrierConfigUpdate(); sendCarrierConfigUpdate(PHONE_ID); // GSM phone doReturn(true).when(mPhone).isPhoneTypeGsm(); Loading