Loading src/java/com/android/internal/telephony/DefaultPhoneNotifier.java +2 −4 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.VoLteServiceState; import java.util.List; Loading Loading @@ -296,10 +295,9 @@ public class DefaultPhoneNotifier implements PhoneNotifier { } @Override public void notifyVoLteServiceStateChanged(Phone sender, VoLteServiceState lteState) { // FIXME: subID public void notifySrvccStateChanged(Phone sender, @TelephonyManager.SrvccState int state) { try { mRegistry.notifyVoLteServiceStateChanged(lteState); mRegistry.notifySrvccStateChanged(sender.getSubId(), state); } catch (RemoteException ex) { // system process is dead } Loading src/java/com/android/internal/telephony/Phone.java +10 −9 Original line number Diff line number Diff line Loading @@ -53,7 +53,6 @@ import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.VoLteServiceState; import android.telephony.ims.stub.ImsRegistrationImplBase; import android.text.TextUtils; Loading Loading @@ -741,7 +740,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { if (ret != null && ret.length != 0) { int state = ret[0]; switch(state) { case VoLteServiceState.HANDOVER_STARTED: case TelephonyManager.SRVCC_STATE_HANDOVER_STARTED: srvccState = Call.SrvccState.STARTED; if (imsPhone != null) { conn = imsPhone.getHandoverConnection(); Loading @@ -750,7 +749,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { Rlog.d(LOG_TAG, "HANDOVER_STARTED: mImsPhone null"); } break; case VoLteServiceState.HANDOVER_COMPLETED: case TelephonyManager.SRVCC_STATE_HANDOVER_COMPLETED: srvccState = Call.SrvccState.COMPLETED; if (imsPhone != null) { imsPhone.notifySrvccState(srvccState); Loading @@ -758,8 +757,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { Rlog.d(LOG_TAG, "HANDOVER_COMPLETED: mImsPhone null"); } break; case VoLteServiceState.HANDOVER_FAILED: case VoLteServiceState.HANDOVER_CANCELED: case TelephonyManager.SRVCC_STATE_HANDOVER_FAILED: case TelephonyManager.SRVCC_STATE_HANDOVER_CANCELED: srvccState = Call.SrvccState.FAILED; break; Loading @@ -770,8 +769,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { getCallTracker().notifySrvccState(srvccState, conn); VoLteServiceState lteState = new VoLteServiceState(state); notifyVoLteServiceStateChanged(lteState); notifySrvccStateChanged(state); } } Loading Loading @@ -2228,8 +2226,11 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { mNotifier.notifyPhysicalChannelConfiguration(this, configs); } public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) { mNotifier.notifyVoLteServiceStateChanged(this, lteState); /** * Notify listeners that SRVCC state has changed. */ public void notifySrvccStateChanged(int state) { mNotifier.notifySrvccStateChanged(this, state); } /** Loading src/java/com/android/internal/telephony/PhoneNotifier.java +2 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.telephony.CellLocation; import android.telephony.PhoneCapability; import android.telephony.PhysicalChannelConfig; import android.telephony.TelephonyManager; import android.telephony.VoLteServiceState; import java.util.List; Loading Loading @@ -65,7 +64,8 @@ public interface PhoneNotifier { public void notifyPreciseDataConnectionFailed(Phone sender, String reason, String apnType, String apn, String failCause); public void notifyVoLteServiceStateChanged(Phone sender, VoLteServiceState lteState); /** send a notification that the SRVCC state has changed.*/ void notifySrvccStateChanged(Phone sender, @TelephonyManager.SrvccState int state); public void notifyVoiceActivationStateChanged(Phone sender, int activationState); Loading tests/telephonytests/src/com/android/internal/telephony/DefaultPhoneNotifierTest.java +0 −12 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import android.telephony.PreciseCallState; import android.telephony.PreciseDisconnectCause; import android.telephony.SignalStrength; import android.telephony.TelephonyManager; import android.telephony.VoLteServiceState; import android.telephony.gsm.GsmCellLocation; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -271,15 +270,4 @@ public class DefaultPhoneNotifierTest extends TelephonyTest { mDefaultPhoneNotifierUT.notifyOtaspChanged(mPhone, TelephonyManager.OTASP_UNKNOWN); verify(mTelephonyRegisteryMock).notifyOtaspChanged(TelephonyManager.OTASP_UNKNOWN); } @Test @SmallTest public void testNotifyVoLteServiceStateChanged() throws Exception { VoLteServiceState state = new VoLteServiceState(VoLteServiceState.NOT_SUPPORTED); mDefaultPhoneNotifierUT.notifyVoLteServiceStateChanged(mPhone, state); verify(mTelephonyRegisteryMock).notifyVoLteServiceStateChanged(state); state = new VoLteServiceState(VoLteServiceState.HANDOVER_COMPLETED); mDefaultPhoneNotifierUT.notifyVoLteServiceStateChanged(mPhone, state); verify(mTelephonyRegisteryMock).notifyVoLteServiceStateChanged(state); } } tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +63 −0 Original line number Diff line number Diff line Loading @@ -17,13 +17,18 @@ package com.android.internal.telephony; import static android.telephony.PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doReturn; import android.os.HandlerThread; import android.os.ServiceManager; import android.telephony.PhoneCapability; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; import com.android.server.TelephonyRegistry; Loading @@ -40,8 +45,15 @@ public class TelephonyRegistryTest extends TelephonyTest { private TelephonyRegistry mTelephonyRegistry; private PhoneCapability mPhoneCapability; private int mPreferredSubId; private int mSrvccState = -1; public class PhoneStateListenerWrapper extends PhoneStateListener { @Override public void onSrvccStateChanged(int srvccState) { mSrvccState = srvccState; setReady(true); } @Override public void onPhoneCapabilityChanged(PhoneCapability capability) { mPhoneCapability = capability; Loading Loading @@ -71,6 +83,8 @@ public class TelephonyRegistryTest extends TelephonyTest { @Before public void setUp() throws Exception { super.setUp("TelephonyRegistryTest"); // ServiceManager.getService("isub") will return this stub for any call to // SubscriptionManager. mServiceManagerMockedServices.put("isub", mISubStub); mHandlerThread.start(); waitUntilReady(); Loading Loading @@ -125,4 +139,53 @@ public class TelephonyRegistryTest extends TelephonyTest { waitUntilReady(); assertEquals(preferredSubId, mPreferredSubId); } /** * Test that we first receive a callback when listen(...) is called that contains the latest * notify(...) response and then that the callback is called correctly when notify(...) is * called. */ @Test @SmallTest public void testSrvccStateChanged() throws Exception { // Return a phone ID of 0 for all sub ids given. doReturn(0/*phoneId*/).when(mISubStub).getPhoneId(anyInt()); setReady(false); int srvccState = TelephonyManager.SRVCC_STATE_HANDOVER_STARTED; mTelephonyRegistry.notifySrvccStateChanged(0 /*subId*/, srvccState); // Should receive callback when listen is called that contains the latest notify result. mTelephonyRegistry.listenForSubscriber(0 /*subId*/, mContext.getOpPackageName(), mPhoneStateListener.callback, LISTEN_SRVCC_STATE_CHANGED, true); waitUntilReady(); assertEquals(srvccState, mSrvccState); // trigger callback setReady(false); srvccState = TelephonyManager.SRVCC_STATE_HANDOVER_COMPLETED; mTelephonyRegistry.notifySrvccStateChanged(0 /*subId*/, srvccState); waitUntilReady(); assertEquals(srvccState, mSrvccState); } /** * Test that a SecurityException is thrown when we try to listen to a SRVCC state change without * READ_PRIVILEGED_PHONE_STATE. */ @Test @SmallTest public void testSrvccStateChangedNoPermission() { // Clear all permission grants for test. mContextFixture.addCallingOrSelfPermission(""); int srvccState = TelephonyManager.SRVCC_STATE_HANDOVER_STARTED; mTelephonyRegistry.notifySrvccStateChanged(0 /*subId*/, srvccState); try { mTelephonyRegistry.listenForSubscriber(0 /*subId*/, mContext.getOpPackageName(), mPhoneStateListener.callback, LISTEN_SRVCC_STATE_CHANGED, true); fail(); } catch (SecurityException e) { // pass test! } } } Loading
src/java/com/android/internal/telephony/DefaultPhoneNotifier.java +2 −4 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.VoLteServiceState; import java.util.List; Loading Loading @@ -296,10 +295,9 @@ public class DefaultPhoneNotifier implements PhoneNotifier { } @Override public void notifyVoLteServiceStateChanged(Phone sender, VoLteServiceState lteState) { // FIXME: subID public void notifySrvccStateChanged(Phone sender, @TelephonyManager.SrvccState int state) { try { mRegistry.notifyVoLteServiceStateChanged(lteState); mRegistry.notifySrvccStateChanged(sender.getSubId(), state); } catch (RemoteException ex) { // system process is dead } Loading
src/java/com/android/internal/telephony/Phone.java +10 −9 Original line number Diff line number Diff line Loading @@ -53,7 +53,6 @@ import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.VoLteServiceState; import android.telephony.ims.stub.ImsRegistrationImplBase; import android.text.TextUtils; Loading Loading @@ -741,7 +740,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { if (ret != null && ret.length != 0) { int state = ret[0]; switch(state) { case VoLteServiceState.HANDOVER_STARTED: case TelephonyManager.SRVCC_STATE_HANDOVER_STARTED: srvccState = Call.SrvccState.STARTED; if (imsPhone != null) { conn = imsPhone.getHandoverConnection(); Loading @@ -750,7 +749,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { Rlog.d(LOG_TAG, "HANDOVER_STARTED: mImsPhone null"); } break; case VoLteServiceState.HANDOVER_COMPLETED: case TelephonyManager.SRVCC_STATE_HANDOVER_COMPLETED: srvccState = Call.SrvccState.COMPLETED; if (imsPhone != null) { imsPhone.notifySrvccState(srvccState); Loading @@ -758,8 +757,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { Rlog.d(LOG_TAG, "HANDOVER_COMPLETED: mImsPhone null"); } break; case VoLteServiceState.HANDOVER_FAILED: case VoLteServiceState.HANDOVER_CANCELED: case TelephonyManager.SRVCC_STATE_HANDOVER_FAILED: case TelephonyManager.SRVCC_STATE_HANDOVER_CANCELED: srvccState = Call.SrvccState.FAILED; break; Loading @@ -770,8 +769,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { getCallTracker().notifySrvccState(srvccState, conn); VoLteServiceState lteState = new VoLteServiceState(state); notifyVoLteServiceStateChanged(lteState); notifySrvccStateChanged(state); } } Loading Loading @@ -2228,8 +2226,11 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { mNotifier.notifyPhysicalChannelConfiguration(this, configs); } public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) { mNotifier.notifyVoLteServiceStateChanged(this, lteState); /** * Notify listeners that SRVCC state has changed. */ public void notifySrvccStateChanged(int state) { mNotifier.notifySrvccStateChanged(this, state); } /** Loading
src/java/com/android/internal/telephony/PhoneNotifier.java +2 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.telephony.CellLocation; import android.telephony.PhoneCapability; import android.telephony.PhysicalChannelConfig; import android.telephony.TelephonyManager; import android.telephony.VoLteServiceState; import java.util.List; Loading Loading @@ -65,7 +64,8 @@ public interface PhoneNotifier { public void notifyPreciseDataConnectionFailed(Phone sender, String reason, String apnType, String apn, String failCause); public void notifyVoLteServiceStateChanged(Phone sender, VoLteServiceState lteState); /** send a notification that the SRVCC state has changed.*/ void notifySrvccStateChanged(Phone sender, @TelephonyManager.SrvccState int state); public void notifyVoiceActivationStateChanged(Phone sender, int activationState); Loading
tests/telephonytests/src/com/android/internal/telephony/DefaultPhoneNotifierTest.java +0 −12 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import android.telephony.PreciseCallState; import android.telephony.PreciseDisconnectCause; import android.telephony.SignalStrength; import android.telephony.TelephonyManager; import android.telephony.VoLteServiceState; import android.telephony.gsm.GsmCellLocation; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -271,15 +270,4 @@ public class DefaultPhoneNotifierTest extends TelephonyTest { mDefaultPhoneNotifierUT.notifyOtaspChanged(mPhone, TelephonyManager.OTASP_UNKNOWN); verify(mTelephonyRegisteryMock).notifyOtaspChanged(TelephonyManager.OTASP_UNKNOWN); } @Test @SmallTest public void testNotifyVoLteServiceStateChanged() throws Exception { VoLteServiceState state = new VoLteServiceState(VoLteServiceState.NOT_SUPPORTED); mDefaultPhoneNotifierUT.notifyVoLteServiceStateChanged(mPhone, state); verify(mTelephonyRegisteryMock).notifyVoLteServiceStateChanged(state); state = new VoLteServiceState(VoLteServiceState.HANDOVER_COMPLETED); mDefaultPhoneNotifierUT.notifyVoLteServiceStateChanged(mPhone, state); verify(mTelephonyRegisteryMock).notifyVoLteServiceStateChanged(state); } }
tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +63 −0 Original line number Diff line number Diff line Loading @@ -17,13 +17,18 @@ package com.android.internal.telephony; import static android.telephony.PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doReturn; import android.os.HandlerThread; import android.os.ServiceManager; import android.telephony.PhoneCapability; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; import com.android.server.TelephonyRegistry; Loading @@ -40,8 +45,15 @@ public class TelephonyRegistryTest extends TelephonyTest { private TelephonyRegistry mTelephonyRegistry; private PhoneCapability mPhoneCapability; private int mPreferredSubId; private int mSrvccState = -1; public class PhoneStateListenerWrapper extends PhoneStateListener { @Override public void onSrvccStateChanged(int srvccState) { mSrvccState = srvccState; setReady(true); } @Override public void onPhoneCapabilityChanged(PhoneCapability capability) { mPhoneCapability = capability; Loading Loading @@ -71,6 +83,8 @@ public class TelephonyRegistryTest extends TelephonyTest { @Before public void setUp() throws Exception { super.setUp("TelephonyRegistryTest"); // ServiceManager.getService("isub") will return this stub for any call to // SubscriptionManager. mServiceManagerMockedServices.put("isub", mISubStub); mHandlerThread.start(); waitUntilReady(); Loading Loading @@ -125,4 +139,53 @@ public class TelephonyRegistryTest extends TelephonyTest { waitUntilReady(); assertEquals(preferredSubId, mPreferredSubId); } /** * Test that we first receive a callback when listen(...) is called that contains the latest * notify(...) response and then that the callback is called correctly when notify(...) is * called. */ @Test @SmallTest public void testSrvccStateChanged() throws Exception { // Return a phone ID of 0 for all sub ids given. doReturn(0/*phoneId*/).when(mISubStub).getPhoneId(anyInt()); setReady(false); int srvccState = TelephonyManager.SRVCC_STATE_HANDOVER_STARTED; mTelephonyRegistry.notifySrvccStateChanged(0 /*subId*/, srvccState); // Should receive callback when listen is called that contains the latest notify result. mTelephonyRegistry.listenForSubscriber(0 /*subId*/, mContext.getOpPackageName(), mPhoneStateListener.callback, LISTEN_SRVCC_STATE_CHANGED, true); waitUntilReady(); assertEquals(srvccState, mSrvccState); // trigger callback setReady(false); srvccState = TelephonyManager.SRVCC_STATE_HANDOVER_COMPLETED; mTelephonyRegistry.notifySrvccStateChanged(0 /*subId*/, srvccState); waitUntilReady(); assertEquals(srvccState, mSrvccState); } /** * Test that a SecurityException is thrown when we try to listen to a SRVCC state change without * READ_PRIVILEGED_PHONE_STATE. */ @Test @SmallTest public void testSrvccStateChangedNoPermission() { // Clear all permission grants for test. mContextFixture.addCallingOrSelfPermission(""); int srvccState = TelephonyManager.SRVCC_STATE_HANDOVER_STARTED; mTelephonyRegistry.notifySrvccStateChanged(0 /*subId*/, srvccState); try { mTelephonyRegistry.listenForSubscriber(0 /*subId*/, mContext.getOpPackageName(), mPhoneStateListener.callback, LISTEN_SRVCC_STATE_CHANGED, true); fail(); } catch (SecurityException e) { // pass test! } } }