Loading src/java/com/android/internal/telephony/ServiceStateTracker.java +21 −1 Original line number Diff line number Diff line Loading @@ -211,6 +211,7 @@ public class ServiceStateTracker extends Handler { protected static final int EVENT_PHONE_TYPE_SWITCHED = 50; protected static final int EVENT_RADIO_POWER_FROM_CARRIER = 51; protected static final int EVENT_SIM_NOT_INSERTED = 52; protected static final int EVENT_IMS_SERVICE_STATE_CHANGED = 53; protected static final String TIMEZONE_PROPERTY = "persist.sys.timezone"; Loading Loading @@ -1349,6 +1350,15 @@ public class ServiceStateTracker extends Handler { updateSpnDisplay(); break; case EVENT_IMS_SERVICE_STATE_CHANGED: if (DBG) log("EVENT_IMS_SERVICE_STATE_CHANGED"); // IMS state will only affect the merged service state if the service state of // GsmCdma phone is not STATE_IN_SERVICE. if (mSS.getState() != ServiceState.STATE_IN_SERVICE) { mPhone.notifyServiceStateChanged(mPhone.getServiceState()); } break; //CDMA case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED: handleCdmaSubscriptionSource(mCdmaSSM.getCdmaSubscriptionSource()); Loading Loading @@ -2551,6 +2561,11 @@ public class ServiceStateTracker extends Handler { } } /** Called when the service state of ImsPhone is changed. */ public void onImsServiceStateChanged() { sendMessage(obtainMessage(EVENT_IMS_SERVICE_STATE_CHANGED)); } public void setImsRegistrationState(boolean registered) { log("ImsRegistrationState - registered : " + registered); Loading Loading @@ -2813,6 +2828,8 @@ public class ServiceStateTracker extends Handler { mRejectCode = mNewRejectCode; } ServiceState oldMergedSS = mPhone.getServiceState(); // swap mSS and mNewSS to put new state in mSS ServiceState tss = mSS; mSS = mNewSS; Loading Loading @@ -2924,7 +2941,10 @@ public class ServiceStateTracker extends Handler { setRoamingType(mSS); log("Broadcasting ServiceState : " + mSS); // notify using PhoneStateListener and the legacy intent ACTION_SERVICE_STATE_CHANGED mPhone.notifyServiceStateChanged(mSS); // notify service state changed only if the merged service state is changed. if (!oldMergedSS.equals(mPhone.getServiceState())) { mPhone.notifyServiceStateChanged(mPhone.getServiceState()); } // insert into ServiceStateProvider. This will trigger apps to wake through JobScheduler mPhone.getContext().getContentResolver() Loading src/java/com/android/internal/telephony/imsphone/ImsPhone.java +4 −3 Original line number Diff line number Diff line Loading @@ -260,16 +260,17 @@ public class ImsPhone extends ImsPhoneBase { @VisibleForTesting public void setServiceState(int state) { boolean isVoiceRegStateChanged = false; synchronized (this) { isVoiceRegStateChanged = mSS.getVoiceRegState() != state; mSS.setVoiceRegState(state); } updateDataServiceState(); // Notifies the service state to the listeners. The service state combined from ImsPhone // and GsmCdmaPhone, it may be changed when the service state in ImsPhone is changed. if (isVoiceRegStateChanged) { mNotifier.notifyServiceState(mDefaultPhone); if (mDefaultPhone.getServiceStateTracker() != null) { mDefaultPhone.getServiceStateTracker().onImsServiceStateChanged(); } } } Loading tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -333,6 +333,31 @@ public class ServiceStateTrackerTest extends TelephonyTest { assertFalse(sst.isImsRegistered()); } @Test public void testOnImsServiceStateChanged() { // The service state of GsmCdmaPhone is STATE_OUT_OF_SERVICE, and IMS is unregistered. ServiceState ss = new ServiceState(); ss.setVoiceRegState(ServiceState.STATE_OUT_OF_SERVICE); sst.mSS = ss; sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_IMS_SERVICE_STATE_CHANGED)); waitForMs(200); // The listener will be notified that the service state was changed. verify(mPhone).notifyServiceStateChanged(any(ServiceState.class)); // The service state of GsmCdmaPhone is STATE_IN_SERVICE, and IMS is registered. ss = new ServiceState(); ss.setVoiceRegState(ServiceState.STATE_IN_SERVICE); sst.mSS = ss; sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_IMS_SERVICE_STATE_CHANGED)); waitForMs(200); // Nothing happened because the IMS service state was not affected the merged service state. verify(mPhone, times(1)).notifyServiceStateChanged(any(ServiceState.class)); } @Test @MediumTest public void testSignalStrength() { Loading tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java +4 −6 Original line number Diff line number Diff line Loading @@ -488,23 +488,21 @@ public class ImsPhoneTest extends TelephonyTest { } @Test @SmallTest public void testShouldSendNotificationWhenServiceStateIsChanged() { mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); reset(mNotifier); reset(mSST); mImsPhoneUT.setServiceState(ServiceState.STATE_OUT_OF_SERVICE); verify(mNotifier).notifyServiceState(mPhone); verify(mSST).onImsServiceStateChanged(); } @Test @SmallTest public void testShouldNotSendNotificationWhenServiceStateIsNotChanged() { mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); reset(mNotifier); reset(mSST); mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); verify(mNotifier, never()).notifyServiceState(mPhone); verify(mSST, never()).onImsServiceStateChanged(); } @Test Loading Loading
src/java/com/android/internal/telephony/ServiceStateTracker.java +21 −1 Original line number Diff line number Diff line Loading @@ -211,6 +211,7 @@ public class ServiceStateTracker extends Handler { protected static final int EVENT_PHONE_TYPE_SWITCHED = 50; protected static final int EVENT_RADIO_POWER_FROM_CARRIER = 51; protected static final int EVENT_SIM_NOT_INSERTED = 52; protected static final int EVENT_IMS_SERVICE_STATE_CHANGED = 53; protected static final String TIMEZONE_PROPERTY = "persist.sys.timezone"; Loading Loading @@ -1349,6 +1350,15 @@ public class ServiceStateTracker extends Handler { updateSpnDisplay(); break; case EVENT_IMS_SERVICE_STATE_CHANGED: if (DBG) log("EVENT_IMS_SERVICE_STATE_CHANGED"); // IMS state will only affect the merged service state if the service state of // GsmCdma phone is not STATE_IN_SERVICE. if (mSS.getState() != ServiceState.STATE_IN_SERVICE) { mPhone.notifyServiceStateChanged(mPhone.getServiceState()); } break; //CDMA case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED: handleCdmaSubscriptionSource(mCdmaSSM.getCdmaSubscriptionSource()); Loading Loading @@ -2551,6 +2561,11 @@ public class ServiceStateTracker extends Handler { } } /** Called when the service state of ImsPhone is changed. */ public void onImsServiceStateChanged() { sendMessage(obtainMessage(EVENT_IMS_SERVICE_STATE_CHANGED)); } public void setImsRegistrationState(boolean registered) { log("ImsRegistrationState - registered : " + registered); Loading Loading @@ -2813,6 +2828,8 @@ public class ServiceStateTracker extends Handler { mRejectCode = mNewRejectCode; } ServiceState oldMergedSS = mPhone.getServiceState(); // swap mSS and mNewSS to put new state in mSS ServiceState tss = mSS; mSS = mNewSS; Loading Loading @@ -2924,7 +2941,10 @@ public class ServiceStateTracker extends Handler { setRoamingType(mSS); log("Broadcasting ServiceState : " + mSS); // notify using PhoneStateListener and the legacy intent ACTION_SERVICE_STATE_CHANGED mPhone.notifyServiceStateChanged(mSS); // notify service state changed only if the merged service state is changed. if (!oldMergedSS.equals(mPhone.getServiceState())) { mPhone.notifyServiceStateChanged(mPhone.getServiceState()); } // insert into ServiceStateProvider. This will trigger apps to wake through JobScheduler mPhone.getContext().getContentResolver() Loading
src/java/com/android/internal/telephony/imsphone/ImsPhone.java +4 −3 Original line number Diff line number Diff line Loading @@ -260,16 +260,17 @@ public class ImsPhone extends ImsPhoneBase { @VisibleForTesting public void setServiceState(int state) { boolean isVoiceRegStateChanged = false; synchronized (this) { isVoiceRegStateChanged = mSS.getVoiceRegState() != state; mSS.setVoiceRegState(state); } updateDataServiceState(); // Notifies the service state to the listeners. The service state combined from ImsPhone // and GsmCdmaPhone, it may be changed when the service state in ImsPhone is changed. if (isVoiceRegStateChanged) { mNotifier.notifyServiceState(mDefaultPhone); if (mDefaultPhone.getServiceStateTracker() != null) { mDefaultPhone.getServiceStateTracker().onImsServiceStateChanged(); } } } Loading
tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -333,6 +333,31 @@ public class ServiceStateTrackerTest extends TelephonyTest { assertFalse(sst.isImsRegistered()); } @Test public void testOnImsServiceStateChanged() { // The service state of GsmCdmaPhone is STATE_OUT_OF_SERVICE, and IMS is unregistered. ServiceState ss = new ServiceState(); ss.setVoiceRegState(ServiceState.STATE_OUT_OF_SERVICE); sst.mSS = ss; sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_IMS_SERVICE_STATE_CHANGED)); waitForMs(200); // The listener will be notified that the service state was changed. verify(mPhone).notifyServiceStateChanged(any(ServiceState.class)); // The service state of GsmCdmaPhone is STATE_IN_SERVICE, and IMS is registered. ss = new ServiceState(); ss.setVoiceRegState(ServiceState.STATE_IN_SERVICE); sst.mSS = ss; sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_IMS_SERVICE_STATE_CHANGED)); waitForMs(200); // Nothing happened because the IMS service state was not affected the merged service state. verify(mPhone, times(1)).notifyServiceStateChanged(any(ServiceState.class)); } @Test @MediumTest public void testSignalStrength() { Loading
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java +4 −6 Original line number Diff line number Diff line Loading @@ -488,23 +488,21 @@ public class ImsPhoneTest extends TelephonyTest { } @Test @SmallTest public void testShouldSendNotificationWhenServiceStateIsChanged() { mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); reset(mNotifier); reset(mSST); mImsPhoneUT.setServiceState(ServiceState.STATE_OUT_OF_SERVICE); verify(mNotifier).notifyServiceState(mPhone); verify(mSST).onImsServiceStateChanged(); } @Test @SmallTest public void testShouldNotSendNotificationWhenServiceStateIsNotChanged() { mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); reset(mNotifier); reset(mSST); mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); verify(mNotifier, never()).notifyServiceState(mPhone); verify(mSST, never()).onImsServiceStateChanged(); } @Test Loading