Loading src/java/com/android/internal/telephony/ims/ImsResolver.java +23 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony.ims; import android.Manifest; import android.annotation.Nullable; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; Loading @@ -40,6 +41,7 @@ import android.util.SparseArray; import com.android.ims.internal.IImsMMTelFeature; import com.android.ims.internal.IImsRcsFeature; import com.android.ims.internal.IImsRegistration; import com.android.ims.internal.IImsServiceFeatureCallback; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.PhoneConstants; Loading Loading @@ -344,9 +346,20 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal return (controller != null) ? controller.getRcsFeature(slotId) : null; } /** * Returns the ImsRegistration structure associated with the slotId and feature specified. */ public @Nullable IImsRegistration getImsRegistration(int slotId, int feature) throws RemoteException { ImsServiceController controller = getImsServiceController(slotId, feature); if (controller != null) { return controller.getRegistration(slotId); } return null; } @VisibleForTesting public ImsServiceController getImsServiceControllerAndListen(int slotId, int feature, IImsServiceFeatureCallback callback) { public ImsServiceController getImsServiceController(int slotId, int feature) { if (slotId < 0 || slotId >= mNumSlots) { return null; } Loading @@ -358,6 +371,14 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal } controller = services.get(feature); } return controller; } @VisibleForTesting public ImsServiceController getImsServiceControllerAndListen(int slotId, int feature, IImsServiceFeatureCallback callback) { ImsServiceController controller = getImsServiceController(slotId, feature); if (controller != null) { controller.addImsServiceFeatureListener(callback); return controller; Loading src/java/com/android/internal/telephony/ims/ImsServiceController.java +12 −4 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.util.Pair; import com.android.ims.internal.IImsFeatureStatusCallback; import com.android.ims.internal.IImsMMTelFeature; import com.android.ims.internal.IImsRcsFeature; import com.android.ims.internal.IImsRegistration; import com.android.ims.internal.IImsServiceController; import com.android.ims.internal.IImsServiceFeatureCallback; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -366,10 +367,8 @@ public class ImsServiceController { } /** * Finds the difference between the set of features that the ImsService has active and the new * set defined in newImsFeatures. For every feature that is added, * {@link IImsServiceController#createImsFeature} is called on the service. For every ImsFeature * that is removed, {@link IImsServiceController#removeImsFeature} is called. * For every feature that is added, the service calls the associated create. For every * ImsFeature that is removed, {@link IImsServiceController#removeImsFeature} is called. */ public void changeImsServiceFeatures(HashSet<Pair<Integer, Integer>> newImsFeatures) throws RemoteException { Loading Loading @@ -466,6 +465,15 @@ public class ImsServiceController { } } /** * @return the IImsRegistration that corresponds to the slot id specified. */ public IImsRegistration getRegistration(int slotId) throws RemoteException { synchronized (mLock) { return mIImsServiceController.getRegistration(slotId); } } private void removeImsServiceFeatureListener() { synchronized (mLock) { mImsStatusCallbacks.clear(); Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +35 −23 Original line number Diff line number Diff line Loading @@ -665,7 +665,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { }; // Callback fires when ImsManager MMTel Feature changes state private ImsServiceProxy.INotifyStatusChanged mNotifyStatusChangedCallback = () -> { private ImsServiceProxy.IFeatureUpdate mNotifyStatusChangedCallback = new ImsServiceProxy.IFeatureUpdate() { @Override public void notifyStateChanged() { try { int status = mImsManager.getImsServiceStatus(); log("Status Changed: " + status); Loading @@ -688,6 +691,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { // Could not get the ImsService, retry! retryGetImsService(); } } @Override public void notifyUnavailable() { retryGetImsService(); } }; @VisibleForTesting Loading Loading @@ -794,7 +803,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { mImsManager.addNotifyStatusChangedCallbackIfAvailable(mNotifyStatusChangedCallback); // Wait for ImsService.STATE_READY to start listening for calls. // Call the callback right away for compatibility with older devices that do not use states. mNotifyStatusChangedCallback.notifyStatusChanged(); mNotifyStatusChangedCallback.notifyStateChanged(); } private void startListeningForCalls() throws ImsException { Loading Loading @@ -3301,6 +3310,9 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { if (mImsManager.isServiceAvailable()) { return; } // remove callback so we do not receive updates from old ImsServiceProxy when switching // between ImsServices. mImsManager.removeNotifyStatusChangedCallback(mNotifyStatusChangedCallback); //Leave mImsManager as null, then CallStateException will be thrown when dialing mImsManager = null; // Exponential backoff during retry, limited to 32 seconds. Loading tests/telephonytests/src/android/telephony/ims/internal/ImsRegistrationTests.java→tests/telephonytests/src/android/telephony/ims/ImsRegistrationTests.java +30 −9 Original line number Diff line number Diff line Loading @@ -14,26 +14,28 @@ * limitations under the License. */ package android.telephony.ims.internal; package android.telephony.ims; import static junit.framework.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import android.net.Uri; import android.os.Parcel; import android.os.RemoteException; import android.support.test.runner.AndroidJUnit4; import android.telephony.ServiceState; import android.telephony.ims.internal.aidl.IImsRegistration; import android.telephony.ims.internal.feature.ImsFeature; import android.telephony.ims.internal.stub.ImsFeatureConfiguration; import android.telephony.ims.internal.stub.ImsRegistrationImplBase; import android.telephony.ims.stub.ImsRegistrationImplBase; import android.test.suitebuilder.annotation.SmallTest; import com.android.ims.ImsReasonInfo; import com.android.ims.internal.IImsRegistration; import com.android.ims.internal.IImsRegistrationCallback; import org.junit.After; import org.junit.Before; Loading @@ -45,14 +47,15 @@ import org.mockito.Spy; @RunWith(AndroidJUnit4.class) public class ImsRegistrationTests { @Spy private ImsRegistrationImplBase.Callback mCallback; private TestImsRegistration mRegistration; @Spy private IImsRegistrationCallback.Stub mCallback; @Spy private IImsRegistrationCallback.Stub mCallback2; private ImsRegistrationImplBase mRegistration; private IImsRegistration mRegBinder; @Before public void setup() throws RemoteException { MockitoAnnotations.initMocks(this); mRegistration = new TestImsRegistration(); mRegistration = new ImsRegistrationImplBase(); mRegBinder = mRegistration.getBinder(); mRegBinder.addRegistrationCallback(mCallback); } Loading Loading @@ -148,6 +151,17 @@ public class ImsRegistrationTests { eq(ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN), eq(info)); } @SmallTest @Test public void testSubscriberUrisChanged() throws RemoteException { Uri[] uris = new Uri[1]; uris[0] = Uri.fromParts("tel", "5555551212", null); mRegistration.onSubscriberAssociatedUriChanged(uris); verify(mCallback).onSubscriberAssociatedUriChanged(eq(uris)); } @SmallTest @Test public void testRegistrationCallbackAfterUnregistered() throws RemoteException { Loading @@ -161,7 +175,6 @@ public class ImsRegistrationTests { @SmallTest @Test public void testRegistrationCallbackSendCurrentState() throws RemoteException { ImsRegistrationImplBase.Callback mCallback2 = spy(new ImsRegistrationImplBase.Callback()); mRegistration.onRegistered(ImsRegistrationImplBase.REGISTRATION_TECH_LTE); mRegBinder.addRegistrationCallback(mCallback2); Loading @@ -181,7 +194,6 @@ public class ImsRegistrationTests { @SmallTest @Test public void testRegistrationCallbackSendCurrentStateDisconnected() throws RemoteException { ImsRegistrationImplBase.Callback mCallback2 = spy(new ImsRegistrationImplBase.Callback()); ImsReasonInfo info = new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_NETWORK_NO_LTE_COVERAGE, 0); mRegistration.onDeregistered(info); Loading @@ -206,4 +218,13 @@ public class ImsRegistrationTests { assertEquals(ImsRegistrationImplBase.REGISTRATION_TECH_NONE, mRegBinder.getRegistrationTechnology()); } @SmallTest @Test public void testRegistrationCallbackNoCallbackIfUnknown() throws RemoteException { mRegBinder.addRegistrationCallback(mCallback2); // Verify that if we have never set the registration state, we do not callback immediately // with onDeregistered. verify(mCallback2, never()).onDeregistered(any(ImsReasonInfo.class)); } } tests/telephonytests/src/android/telephony/ims/internal/ImsFeatureTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.internal.feature.CapabilityChangeRequest; import android.telephony.ims.internal.feature.ImsFeature; import android.telephony.ims.internal.feature.MmTelFeature; import android.telephony.ims.internal.stub.ImsRegistrationImplBase; import android.telephony.ims.stub.ImsRegistrationImplBase; import android.test.suitebuilder.annotation.SmallTest; import com.android.ims.internal.IImsFeatureStatusCallback; Loading Loading
src/java/com/android/internal/telephony/ims/ImsResolver.java +23 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony.ims; import android.Manifest; import android.annotation.Nullable; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; Loading @@ -40,6 +41,7 @@ import android.util.SparseArray; import com.android.ims.internal.IImsMMTelFeature; import com.android.ims.internal.IImsRcsFeature; import com.android.ims.internal.IImsRegistration; import com.android.ims.internal.IImsServiceFeatureCallback; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.PhoneConstants; Loading Loading @@ -344,9 +346,20 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal return (controller != null) ? controller.getRcsFeature(slotId) : null; } /** * Returns the ImsRegistration structure associated with the slotId and feature specified. */ public @Nullable IImsRegistration getImsRegistration(int slotId, int feature) throws RemoteException { ImsServiceController controller = getImsServiceController(slotId, feature); if (controller != null) { return controller.getRegistration(slotId); } return null; } @VisibleForTesting public ImsServiceController getImsServiceControllerAndListen(int slotId, int feature, IImsServiceFeatureCallback callback) { public ImsServiceController getImsServiceController(int slotId, int feature) { if (slotId < 0 || slotId >= mNumSlots) { return null; } Loading @@ -358,6 +371,14 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal } controller = services.get(feature); } return controller; } @VisibleForTesting public ImsServiceController getImsServiceControllerAndListen(int slotId, int feature, IImsServiceFeatureCallback callback) { ImsServiceController controller = getImsServiceController(slotId, feature); if (controller != null) { controller.addImsServiceFeatureListener(callback); return controller; Loading
src/java/com/android/internal/telephony/ims/ImsServiceController.java +12 −4 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.util.Pair; import com.android.ims.internal.IImsFeatureStatusCallback; import com.android.ims.internal.IImsMMTelFeature; import com.android.ims.internal.IImsRcsFeature; import com.android.ims.internal.IImsRegistration; import com.android.ims.internal.IImsServiceController; import com.android.ims.internal.IImsServiceFeatureCallback; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -366,10 +367,8 @@ public class ImsServiceController { } /** * Finds the difference between the set of features that the ImsService has active and the new * set defined in newImsFeatures. For every feature that is added, * {@link IImsServiceController#createImsFeature} is called on the service. For every ImsFeature * that is removed, {@link IImsServiceController#removeImsFeature} is called. * For every feature that is added, the service calls the associated create. For every * ImsFeature that is removed, {@link IImsServiceController#removeImsFeature} is called. */ public void changeImsServiceFeatures(HashSet<Pair<Integer, Integer>> newImsFeatures) throws RemoteException { Loading Loading @@ -466,6 +465,15 @@ public class ImsServiceController { } } /** * @return the IImsRegistration that corresponds to the slot id specified. */ public IImsRegistration getRegistration(int slotId) throws RemoteException { synchronized (mLock) { return mIImsServiceController.getRegistration(slotId); } } private void removeImsServiceFeatureListener() { synchronized (mLock) { mImsStatusCallbacks.clear(); Loading
src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +35 −23 Original line number Diff line number Diff line Loading @@ -665,7 +665,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { }; // Callback fires when ImsManager MMTel Feature changes state private ImsServiceProxy.INotifyStatusChanged mNotifyStatusChangedCallback = () -> { private ImsServiceProxy.IFeatureUpdate mNotifyStatusChangedCallback = new ImsServiceProxy.IFeatureUpdate() { @Override public void notifyStateChanged() { try { int status = mImsManager.getImsServiceStatus(); log("Status Changed: " + status); Loading @@ -688,6 +691,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { // Could not get the ImsService, retry! retryGetImsService(); } } @Override public void notifyUnavailable() { retryGetImsService(); } }; @VisibleForTesting Loading Loading @@ -794,7 +803,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { mImsManager.addNotifyStatusChangedCallbackIfAvailable(mNotifyStatusChangedCallback); // Wait for ImsService.STATE_READY to start listening for calls. // Call the callback right away for compatibility with older devices that do not use states. mNotifyStatusChangedCallback.notifyStatusChanged(); mNotifyStatusChangedCallback.notifyStateChanged(); } private void startListeningForCalls() throws ImsException { Loading Loading @@ -3301,6 +3310,9 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { if (mImsManager.isServiceAvailable()) { return; } // remove callback so we do not receive updates from old ImsServiceProxy when switching // between ImsServices. mImsManager.removeNotifyStatusChangedCallback(mNotifyStatusChangedCallback); //Leave mImsManager as null, then CallStateException will be thrown when dialing mImsManager = null; // Exponential backoff during retry, limited to 32 seconds. Loading
tests/telephonytests/src/android/telephony/ims/internal/ImsRegistrationTests.java→tests/telephonytests/src/android/telephony/ims/ImsRegistrationTests.java +30 −9 Original line number Diff line number Diff line Loading @@ -14,26 +14,28 @@ * limitations under the License. */ package android.telephony.ims.internal; package android.telephony.ims; import static junit.framework.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import android.net.Uri; import android.os.Parcel; import android.os.RemoteException; import android.support.test.runner.AndroidJUnit4; import android.telephony.ServiceState; import android.telephony.ims.internal.aidl.IImsRegistration; import android.telephony.ims.internal.feature.ImsFeature; import android.telephony.ims.internal.stub.ImsFeatureConfiguration; import android.telephony.ims.internal.stub.ImsRegistrationImplBase; import android.telephony.ims.stub.ImsRegistrationImplBase; import android.test.suitebuilder.annotation.SmallTest; import com.android.ims.ImsReasonInfo; import com.android.ims.internal.IImsRegistration; import com.android.ims.internal.IImsRegistrationCallback; import org.junit.After; import org.junit.Before; Loading @@ -45,14 +47,15 @@ import org.mockito.Spy; @RunWith(AndroidJUnit4.class) public class ImsRegistrationTests { @Spy private ImsRegistrationImplBase.Callback mCallback; private TestImsRegistration mRegistration; @Spy private IImsRegistrationCallback.Stub mCallback; @Spy private IImsRegistrationCallback.Stub mCallback2; private ImsRegistrationImplBase mRegistration; private IImsRegistration mRegBinder; @Before public void setup() throws RemoteException { MockitoAnnotations.initMocks(this); mRegistration = new TestImsRegistration(); mRegistration = new ImsRegistrationImplBase(); mRegBinder = mRegistration.getBinder(); mRegBinder.addRegistrationCallback(mCallback); } Loading Loading @@ -148,6 +151,17 @@ public class ImsRegistrationTests { eq(ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN), eq(info)); } @SmallTest @Test public void testSubscriberUrisChanged() throws RemoteException { Uri[] uris = new Uri[1]; uris[0] = Uri.fromParts("tel", "5555551212", null); mRegistration.onSubscriberAssociatedUriChanged(uris); verify(mCallback).onSubscriberAssociatedUriChanged(eq(uris)); } @SmallTest @Test public void testRegistrationCallbackAfterUnregistered() throws RemoteException { Loading @@ -161,7 +175,6 @@ public class ImsRegistrationTests { @SmallTest @Test public void testRegistrationCallbackSendCurrentState() throws RemoteException { ImsRegistrationImplBase.Callback mCallback2 = spy(new ImsRegistrationImplBase.Callback()); mRegistration.onRegistered(ImsRegistrationImplBase.REGISTRATION_TECH_LTE); mRegBinder.addRegistrationCallback(mCallback2); Loading @@ -181,7 +194,6 @@ public class ImsRegistrationTests { @SmallTest @Test public void testRegistrationCallbackSendCurrentStateDisconnected() throws RemoteException { ImsRegistrationImplBase.Callback mCallback2 = spy(new ImsRegistrationImplBase.Callback()); ImsReasonInfo info = new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_NETWORK_NO_LTE_COVERAGE, 0); mRegistration.onDeregistered(info); Loading @@ -206,4 +218,13 @@ public class ImsRegistrationTests { assertEquals(ImsRegistrationImplBase.REGISTRATION_TECH_NONE, mRegBinder.getRegistrationTechnology()); } @SmallTest @Test public void testRegistrationCallbackNoCallbackIfUnknown() throws RemoteException { mRegBinder.addRegistrationCallback(mCallback2); // Verify that if we have never set the registration state, we do not callback immediately // with onDeregistered. verify(mCallback2, never()).onDeregistered(any(ImsReasonInfo.class)); } }
tests/telephonytests/src/android/telephony/ims/internal/ImsFeatureTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.internal.feature.CapabilityChangeRequest; import android.telephony.ims.internal.feature.ImsFeature; import android.telephony.ims.internal.feature.MmTelFeature; import android.telephony.ims.internal.stub.ImsRegistrationImplBase; import android.telephony.ims.stub.ImsRegistrationImplBase; import android.test.suitebuilder.annotation.SmallTest; import com.android.ims.internal.IImsFeatureStatusCallback; Loading