Loading src/java/com/android/internal/telephony/Phone.java +6 −3 Original line number Diff line number Diff line Loading @@ -533,15 +533,18 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { synchronized(Phone.lockForRadioTechnologyChange) { IntentFilter filter = new IntentFilter(); ImsManager imsManager = ImsManager.getInstance(mContext, getPhoneId()); // Don't listen to deprecated intents using the new dynamic binding. if (imsManager != null && !imsManager.isDynamicBinding()) { filter.addAction(ImsManager.ACTION_IMS_SERVICE_UP); filter.addAction(ImsManager.ACTION_IMS_SERVICE_DOWN); } filter.addAction(ImsConfig.ACTION_IMS_CONFIG_CHANGED); mContext.registerReceiver(mImsIntentReceiver, filter); // Monitor IMS service - but first poll to see if already up (could miss // intent). Also, when using new ImsResolver APIs, the service will be available soon, // so start trying to bind. ImsManager imsManager = ImsManager.getInstance(mContext, getPhoneId()); if (imsManager != null) { // If it is dynamic binding, kick off ImsPhone creation now instead of waiting for // the service to be available. Loading src/java/com/android/internal/telephony/ims/ImsServiceController.java +10 −5 Original line number Diff line number Diff line Loading @@ -284,7 +284,7 @@ public class ImsServiceController { } /** * Calls {@link IImsServiceController#removeImsFeature(int, int)} on all features that the * Calls {@link IImsServiceController#removeImsFeature} on all features that the * ImsService supports and then unbinds the service. */ public void unbind() throws RemoteException { Loading Loading @@ -459,7 +459,15 @@ public class ImsServiceController { Log.w(LOG_TAG, "removeImsServiceFeature called with null values."); return; } mIImsServiceController.removeImsFeature(featurePair.first, featurePair.second); ImsFeatureStatusCallback callbackToRemove = mFeatureStatusCallbacks.stream().filter(c -> c.mSlotId == featurePair.first && c.mFeatureType == featurePair.second) .findFirst().orElse(null); // Remove status callbacks from list. if (callbackToRemove != null) { mFeatureStatusCallbacks.remove(callbackToRemove); } mIImsServiceController.removeImsFeature(featurePair.first, featurePair.second, (callbackToRemove != null ? callbackToRemove.getCallback() : null)); // Signal ImsResolver to change supported ImsFeatures for this ImsServiceController mCallbacks.imsServiceFeatureRemoved(featurePair.first, featurePair.second, this); // Send callback to ImsServiceProxy to change supported ImsFeatures Loading @@ -467,9 +475,6 @@ public class ImsServiceController { // ImsManager requests the ImsService while it is being removed in ImsResolver, this // callback will clean it up after. sendImsFeatureRemovedCallback(featurePair.first, featurePair.second); // Remove status callbacks from list. mFeatureStatusCallbacks.removeIf(c -> c.mSlotId == featurePair.first && c.mFeatureType == featurePair.second); } private void notifyAllFeaturesRemoved() { Loading tests/telephonytests/src/android/telephony/ims/ImsFeatureTest.java +8 −2 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ public class ImsFeatureTest { @Mock private IImsFeatureStatusCallback mTestStatusCallback; @Mock private IImsFeatureStatusCallback mTestStatusCallback2; @Mock private ImsFeature.INotifyFeatureRemoved mTestRemovedCallback; private class TestImsFeature extends ImsFeature { Loading Loading @@ -73,19 +75,23 @@ public class ImsFeatureTest { @Test @SmallTest public void testSetCallbackAndNotify() throws Exception { mTestImsService.setImsFeatureStatusCallback(mTestStatusCallback); mTestImsService.addImsFeatureStatusCallback(mTestStatusCallback); mTestImsService.addImsFeatureStatusCallback(mTestStatusCallback2); verify(mTestStatusCallback).notifyImsFeatureStatus(eq(ImsFeature.STATE_NOT_AVAILABLE)); verify(mTestStatusCallback2).notifyImsFeatureStatus(eq(ImsFeature.STATE_NOT_AVAILABLE)); } @Test @SmallTest public void testSetFeatureAndCheckCallback() throws Exception { mTestImsService.setImsFeatureStatusCallback(mTestStatusCallback); mTestImsService.addImsFeatureStatusCallback(mTestStatusCallback); mTestImsService.addImsFeatureStatusCallback(mTestStatusCallback2); mTestImsService.testSetFeatureState(ImsFeature.STATE_READY); verify(mTestStatusCallback).notifyImsFeatureStatus(eq(ImsFeature.STATE_READY)); verify(mTestStatusCallback2).notifyImsFeatureStatus(eq(ImsFeature.STATE_READY)); assertEquals(ImsFeature.STATE_READY, mTestImsService.getFeatureState()); } Loading tests/telephonytests/src/android/telephony/ims/ImsServiceTest.java +9 −33 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public class ImsServiceTest { mTestImsService.getImsFeatureFromType(features, ImsFeature.MMTEL)); // Verify that upon creating a feature, we assign the callback and get the set feature state // when querying it. verify(mTestImsService.mSpyMMTelFeature).setImsFeatureStatusCallback(eq(mTestCallback)); verify(mTestImsService.mSpyMMTelFeature).addImsFeatureStatusCallback(eq(mTestCallback)); assertEquals(ImsFeature.STATE_READY, mTestImsServiceBinder.getFeatureStatus(TEST_SLOT_0, ImsFeature.MMTEL)); } Loading @@ -108,10 +108,10 @@ public class ImsServiceTest { public void testRemoveMMTelFeature() throws RemoteException { mTestImsServiceBinder.createImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback); mTestImsServiceBinder.removeImsFeature(TEST_SLOT_0, ImsFeature.MMTEL); mTestImsServiceBinder.removeImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback); verify(mTestImsService.mSpyMMTelFeature).notifyFeatureRemoved(eq(0)); verify(mTestImsService.mSpyMMTelFeature).setImsFeatureStatusCallback(null); verify(mTestImsService.mSpyMMTelFeature).removeImsFeatureStatusCallback(mTestCallback); SparseArray<ImsFeature> features = mTestImsService.getImsFeatureMap(TEST_SLOT_0); assertNull(mTestImsService.getImsFeatureFromType(features, ImsFeature.MMTEL)); } Loading Loading @@ -184,14 +184,11 @@ public class ImsServiceTest { mTestImsService.mSpyMMTelFeature.sendSetFeatureState(ImsFeature.STATE_READY); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mMockContext, times(2)).sendBroadcast(intentCaptor.capture()); verify(mMockContext).sendBroadcast(intentCaptor.capture()); try { // IMS_SERVICE_DOWN is always sent when createImsFeature completes assertNotNull(intentCaptor.getAllValues().get(0)); verifyServiceDownSent(intentCaptor.getAllValues().get(0)); // Verify IMS_SERVICE_UP is sent assertNotNull(intentCaptor.getAllValues().get(1)); verifyServiceUpSent(intentCaptor.getAllValues().get(1)); assertNotNull(intentCaptor.getValue()); verifyServiceUpSent(intentCaptor.getValue()); } catch (IndexOutOfBoundsException e) { fail("Did not receive all intents"); } Loading @@ -209,37 +206,16 @@ public class ImsServiceTest { mTestImsService.mSpyMMTelFeature.sendSetFeatureState(ImsFeature.STATE_INITIALIZING); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mMockContext, times(2)).sendBroadcast(intentCaptor.capture()); verify(mMockContext).sendBroadcast(intentCaptor.capture()); try { // IMS_SERVICE_DOWN is always sent when createImsFeature completes. assertNotNull(intentCaptor.getAllValues().get(0)); verifyServiceDownSent(intentCaptor.getAllValues().get(0)); // IMS_SERVICE_DOWN is sent when the service is STATE_INITIALIZING. assertNotNull(intentCaptor.getAllValues().get(1)); verifyServiceDownSent(intentCaptor.getAllValues().get(1)); assertNotNull(intentCaptor.getValue()); verifyServiceDownSent(intentCaptor.getValue()); } catch (IndexOutOfBoundsException e) { fail("Did not receive all intents"); } } /** * Tests that the new ImsService still sends the IMS_SERVICE_DOWN broadcast when the feature is * set to not available. */ @Test @SmallTest public void testImsServiceDownSentCompatNotAvailable() throws RemoteException { mTestImsServiceBinder.createImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback); // The ImsService will send the STATE_NOT_AVAILABLE status as soon as the feature is // created. ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mMockContext).sendBroadcast(intentCaptor.capture()); assertNotNull(intentCaptor.getValue()); verifyServiceDownSent(intentCaptor.getValue()); } private void verifyServiceDownSent(Intent testIntent) { assertEquals(ImsManager.ACTION_IMS_SERVICE_DOWN, testIntent.getAction()); assertEquals(TEST_SLOT_0, testIntent.getIntExtra(ImsManager.EXTRA_PHONE_ID, -1)); Loading tests/telephonytests/src/com/android/internal/telephony/ims/TestImsServiceControllerAdapter.java +2 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ public class TestImsServiceControllerAdapter { } @Override public void removeImsFeature(int slotId, int feature) throws RemoteException { public void removeImsFeature(int slotId, int feature, IImsFeatureStatusCallback c) throws RemoteException { TestImsServiceControllerAdapter.this.removeImsFeature(slotId, feature); } Loading Loading
src/java/com/android/internal/telephony/Phone.java +6 −3 Original line number Diff line number Diff line Loading @@ -533,15 +533,18 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { synchronized(Phone.lockForRadioTechnologyChange) { IntentFilter filter = new IntentFilter(); ImsManager imsManager = ImsManager.getInstance(mContext, getPhoneId()); // Don't listen to deprecated intents using the new dynamic binding. if (imsManager != null && !imsManager.isDynamicBinding()) { filter.addAction(ImsManager.ACTION_IMS_SERVICE_UP); filter.addAction(ImsManager.ACTION_IMS_SERVICE_DOWN); } filter.addAction(ImsConfig.ACTION_IMS_CONFIG_CHANGED); mContext.registerReceiver(mImsIntentReceiver, filter); // Monitor IMS service - but first poll to see if already up (could miss // intent). Also, when using new ImsResolver APIs, the service will be available soon, // so start trying to bind. ImsManager imsManager = ImsManager.getInstance(mContext, getPhoneId()); if (imsManager != null) { // If it is dynamic binding, kick off ImsPhone creation now instead of waiting for // the service to be available. Loading
src/java/com/android/internal/telephony/ims/ImsServiceController.java +10 −5 Original line number Diff line number Diff line Loading @@ -284,7 +284,7 @@ public class ImsServiceController { } /** * Calls {@link IImsServiceController#removeImsFeature(int, int)} on all features that the * Calls {@link IImsServiceController#removeImsFeature} on all features that the * ImsService supports and then unbinds the service. */ public void unbind() throws RemoteException { Loading Loading @@ -459,7 +459,15 @@ public class ImsServiceController { Log.w(LOG_TAG, "removeImsServiceFeature called with null values."); return; } mIImsServiceController.removeImsFeature(featurePair.first, featurePair.second); ImsFeatureStatusCallback callbackToRemove = mFeatureStatusCallbacks.stream().filter(c -> c.mSlotId == featurePair.first && c.mFeatureType == featurePair.second) .findFirst().orElse(null); // Remove status callbacks from list. if (callbackToRemove != null) { mFeatureStatusCallbacks.remove(callbackToRemove); } mIImsServiceController.removeImsFeature(featurePair.first, featurePair.second, (callbackToRemove != null ? callbackToRemove.getCallback() : null)); // Signal ImsResolver to change supported ImsFeatures for this ImsServiceController mCallbacks.imsServiceFeatureRemoved(featurePair.first, featurePair.second, this); // Send callback to ImsServiceProxy to change supported ImsFeatures Loading @@ -467,9 +475,6 @@ public class ImsServiceController { // ImsManager requests the ImsService while it is being removed in ImsResolver, this // callback will clean it up after. sendImsFeatureRemovedCallback(featurePair.first, featurePair.second); // Remove status callbacks from list. mFeatureStatusCallbacks.removeIf(c -> c.mSlotId == featurePair.first && c.mFeatureType == featurePair.second); } private void notifyAllFeaturesRemoved() { Loading
tests/telephonytests/src/android/telephony/ims/ImsFeatureTest.java +8 −2 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ public class ImsFeatureTest { @Mock private IImsFeatureStatusCallback mTestStatusCallback; @Mock private IImsFeatureStatusCallback mTestStatusCallback2; @Mock private ImsFeature.INotifyFeatureRemoved mTestRemovedCallback; private class TestImsFeature extends ImsFeature { Loading Loading @@ -73,19 +75,23 @@ public class ImsFeatureTest { @Test @SmallTest public void testSetCallbackAndNotify() throws Exception { mTestImsService.setImsFeatureStatusCallback(mTestStatusCallback); mTestImsService.addImsFeatureStatusCallback(mTestStatusCallback); mTestImsService.addImsFeatureStatusCallback(mTestStatusCallback2); verify(mTestStatusCallback).notifyImsFeatureStatus(eq(ImsFeature.STATE_NOT_AVAILABLE)); verify(mTestStatusCallback2).notifyImsFeatureStatus(eq(ImsFeature.STATE_NOT_AVAILABLE)); } @Test @SmallTest public void testSetFeatureAndCheckCallback() throws Exception { mTestImsService.setImsFeatureStatusCallback(mTestStatusCallback); mTestImsService.addImsFeatureStatusCallback(mTestStatusCallback); mTestImsService.addImsFeatureStatusCallback(mTestStatusCallback2); mTestImsService.testSetFeatureState(ImsFeature.STATE_READY); verify(mTestStatusCallback).notifyImsFeatureStatus(eq(ImsFeature.STATE_READY)); verify(mTestStatusCallback2).notifyImsFeatureStatus(eq(ImsFeature.STATE_READY)); assertEquals(ImsFeature.STATE_READY, mTestImsService.getFeatureState()); } Loading
tests/telephonytests/src/android/telephony/ims/ImsServiceTest.java +9 −33 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public class ImsServiceTest { mTestImsService.getImsFeatureFromType(features, ImsFeature.MMTEL)); // Verify that upon creating a feature, we assign the callback and get the set feature state // when querying it. verify(mTestImsService.mSpyMMTelFeature).setImsFeatureStatusCallback(eq(mTestCallback)); verify(mTestImsService.mSpyMMTelFeature).addImsFeatureStatusCallback(eq(mTestCallback)); assertEquals(ImsFeature.STATE_READY, mTestImsServiceBinder.getFeatureStatus(TEST_SLOT_0, ImsFeature.MMTEL)); } Loading @@ -108,10 +108,10 @@ public class ImsServiceTest { public void testRemoveMMTelFeature() throws RemoteException { mTestImsServiceBinder.createImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback); mTestImsServiceBinder.removeImsFeature(TEST_SLOT_0, ImsFeature.MMTEL); mTestImsServiceBinder.removeImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback); verify(mTestImsService.mSpyMMTelFeature).notifyFeatureRemoved(eq(0)); verify(mTestImsService.mSpyMMTelFeature).setImsFeatureStatusCallback(null); verify(mTestImsService.mSpyMMTelFeature).removeImsFeatureStatusCallback(mTestCallback); SparseArray<ImsFeature> features = mTestImsService.getImsFeatureMap(TEST_SLOT_0); assertNull(mTestImsService.getImsFeatureFromType(features, ImsFeature.MMTEL)); } Loading Loading @@ -184,14 +184,11 @@ public class ImsServiceTest { mTestImsService.mSpyMMTelFeature.sendSetFeatureState(ImsFeature.STATE_READY); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mMockContext, times(2)).sendBroadcast(intentCaptor.capture()); verify(mMockContext).sendBroadcast(intentCaptor.capture()); try { // IMS_SERVICE_DOWN is always sent when createImsFeature completes assertNotNull(intentCaptor.getAllValues().get(0)); verifyServiceDownSent(intentCaptor.getAllValues().get(0)); // Verify IMS_SERVICE_UP is sent assertNotNull(intentCaptor.getAllValues().get(1)); verifyServiceUpSent(intentCaptor.getAllValues().get(1)); assertNotNull(intentCaptor.getValue()); verifyServiceUpSent(intentCaptor.getValue()); } catch (IndexOutOfBoundsException e) { fail("Did not receive all intents"); } Loading @@ -209,37 +206,16 @@ public class ImsServiceTest { mTestImsService.mSpyMMTelFeature.sendSetFeatureState(ImsFeature.STATE_INITIALIZING); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mMockContext, times(2)).sendBroadcast(intentCaptor.capture()); verify(mMockContext).sendBroadcast(intentCaptor.capture()); try { // IMS_SERVICE_DOWN is always sent when createImsFeature completes. assertNotNull(intentCaptor.getAllValues().get(0)); verifyServiceDownSent(intentCaptor.getAllValues().get(0)); // IMS_SERVICE_DOWN is sent when the service is STATE_INITIALIZING. assertNotNull(intentCaptor.getAllValues().get(1)); verifyServiceDownSent(intentCaptor.getAllValues().get(1)); assertNotNull(intentCaptor.getValue()); verifyServiceDownSent(intentCaptor.getValue()); } catch (IndexOutOfBoundsException e) { fail("Did not receive all intents"); } } /** * Tests that the new ImsService still sends the IMS_SERVICE_DOWN broadcast when the feature is * set to not available. */ @Test @SmallTest public void testImsServiceDownSentCompatNotAvailable() throws RemoteException { mTestImsServiceBinder.createImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback); // The ImsService will send the STATE_NOT_AVAILABLE status as soon as the feature is // created. ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mMockContext).sendBroadcast(intentCaptor.capture()); assertNotNull(intentCaptor.getValue()); verifyServiceDownSent(intentCaptor.getValue()); } private void verifyServiceDownSent(Intent testIntent) { assertEquals(ImsManager.ACTION_IMS_SERVICE_DOWN, testIntent.getAction()); assertEquals(TEST_SLOT_0, testIntent.getIntExtra(ImsManager.EXTRA_PHONE_ID, -1)); Loading
tests/telephonytests/src/com/android/internal/telephony/ims/TestImsServiceControllerAdapter.java +2 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ public class TestImsServiceControllerAdapter { } @Override public void removeImsFeature(int slotId, int feature) throws RemoteException { public void removeImsFeature(int slotId, int feature, IImsFeatureStatusCallback c) throws RemoteException { TestImsServiceControllerAdapter.this.removeImsFeature(slotId, feature); } Loading