Loading src/java/com/android/internal/telephony/imsphone/ImsPhone.java +14 −4 Original line number Diff line number Diff line Loading @@ -253,14 +253,24 @@ public class ImsPhone extends ImsPhoneBase { } @Override public ServiceState getServiceState() { public ServiceState getServiceState() { return mSS; } /* package */ void setServiceState(int state) { @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); } } @Override Loading tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java +23 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import static org.mockito.Matchers.nullable; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; Loading @@ -47,6 +49,7 @@ import android.os.PersistableBundle; import android.os.SystemProperties; import android.support.test.filters.FlakyTest; import android.telephony.CarrierConfigManager; import android.telephony.ServiceState; import android.test.suitebuilder.annotation.SmallTest; import com.android.ims.ImsCallProfile; Loading Loading @@ -484,6 +487,26 @@ public class ImsPhoneTest extends TelephonyTest { assertEquals(msg, messageArgumentCaptor.getValue().obj); } @Test @SmallTest public void testShouldSendNotificationWhenServiceStateIsChanged() { mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); reset(mNotifier); mImsPhoneUT.setServiceState(ServiceState.STATE_OUT_OF_SERVICE); verify(mNotifier).notifyServiceState(mPhone); } @Test @SmallTest public void testShouldNotSendNotificationWhenServiceStateIsNotChanged() { mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); reset(mNotifier); mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); verify(mNotifier, never()).notifyServiceState(mPhone); } @Test @SmallTest public void testCellBarring() throws Exception { Loading Loading
src/java/com/android/internal/telephony/imsphone/ImsPhone.java +14 −4 Original line number Diff line number Diff line Loading @@ -253,14 +253,24 @@ public class ImsPhone extends ImsPhoneBase { } @Override public ServiceState getServiceState() { public ServiceState getServiceState() { return mSS; } /* package */ void setServiceState(int state) { @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); } } @Override Loading
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java +23 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import static org.mockito.Matchers.nullable; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; Loading @@ -47,6 +49,7 @@ import android.os.PersistableBundle; import android.os.SystemProperties; import android.support.test.filters.FlakyTest; import android.telephony.CarrierConfigManager; import android.telephony.ServiceState; import android.test.suitebuilder.annotation.SmallTest; import com.android.ims.ImsCallProfile; Loading Loading @@ -484,6 +487,26 @@ public class ImsPhoneTest extends TelephonyTest { assertEquals(msg, messageArgumentCaptor.getValue().obj); } @Test @SmallTest public void testShouldSendNotificationWhenServiceStateIsChanged() { mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); reset(mNotifier); mImsPhoneUT.setServiceState(ServiceState.STATE_OUT_OF_SERVICE); verify(mNotifier).notifyServiceState(mPhone); } @Test @SmallTest public void testShouldNotSendNotificationWhenServiceStateIsNotChanged() { mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); reset(mNotifier); mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE); verify(mNotifier, never()).notifyServiceState(mPhone); } @Test @SmallTest public void testCellBarring() throws Exception { Loading