Loading src/java/com/android/internal/telephony/ims/ImsResolver.java +16 −0 Original line number Diff line number Diff line Loading @@ -767,6 +767,22 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal return null; } /** * Unregister a previously registered IImsServiceFeatureCallback through * {@link #getImsServiceControllerAndListen(int, int, IImsServiceFeatureCallback)} . * @param slotId The slot id associated with the ImsFeature. * @param feature The {@link ImsFeature.FeatureType} * @param callback The callback to be unregistered. */ public void unregisterImsFeatureCallback(int slotId, int feature, IImsServiceFeatureCallback callback) { ImsServiceController controller = getImsServiceController(slotId, feature); if (controller != null) { controller.removeImsServiceFeatureCallback(callback); } } // Used for testing only. public boolean overrideImsServiceConfiguration(int slotId, boolean isCarrierService, Map<Integer, String> featureConfig) { Loading src/java/com/android/internal/telephony/ims/ImsServiceController.java +16 −7 Original line number Diff line number Diff line Loading @@ -504,19 +504,28 @@ public class ImsServiceController { */ public void addImsServiceFeatureCallback(IImsServiceFeatureCallback callback) { mImsStatusCallbacks.add(callback); Set<ImsFeatureConfiguration.FeatureSlotPair> features; synchronized (mLock) { if (mImsFeatures == null || mImsFeatures.isEmpty()) { return; } features = new HashSet<>(mImsFeatures); } // notify the new status callback of the features that are available. try { for (ImsFeatureConfiguration.FeatureSlotPair i : mImsFeatures) { for (ImsFeatureConfiguration.FeatureSlotPair i : features) { callback.imsFeatureCreated(i.slotId, i.featureType); } } catch (RemoteException e) { Log.w(LOG_TAG, "addImsServiceFeatureCallback: exception notifying callback"); } } /** * Removes a previously registered callback if it was associated with this feature. */ public void removeImsServiceFeatureCallback(IImsServiceFeatureCallback callback) { mImsStatusCallbacks.remove(callback); } public void enableIms(int slotId) { Loading tests/telephonytests/src/com/android/internal/telephony/ims/FeatureConnectionTest.java +29 −4 Original line number Diff line number Diff line Loading @@ -28,7 +28,9 @@ import android.content.Context; import android.content.pm.PackageManager; import android.os.IBinder; import android.os.RemoteException; import android.telephony.ims.aidl.IImsRegistration; import android.telephony.ims.feature.ImsFeature; import android.telephony.ims.stub.ImsRegistrationImplBase; import android.test.suitebuilder.annotation.SmallTest; import com.android.ims.FeatureConnection; Loading Loading @@ -59,8 +61,8 @@ public class FeatureConnectionTest extends TelephonyTest { public boolean isFeatureRemovedCalled = false; public int mNewStatus = ImsFeature.STATE_UNAVAILABLE; TestFeatureConnection(Context context, int slotId, int featureType) { super(context, slotId, featureType); TestFeatureConnection(Context context, int slotId) { super(context, slotId); if (!ImsManager.isImsSupportedOnDevice(context)) { sImsSupportedOnDevice = false; } Loading Loading @@ -91,6 +93,11 @@ public class FeatureConnectionTest extends TelephonyTest { return mFeatureState; } @Override protected IImsRegistration getRegistrationBinder() { return getTestRegistrationBinder(); } public void setFeatureState(int state) { mFeatureState = state; } Loading @@ -99,6 +106,7 @@ public class FeatureConnectionTest extends TelephonyTest { private int mPhoneId; private TestFeatureConnection mTestFeatureConnection; @Mock IBinder mBinder; @Mock IImsRegistration mRegistrationBinder; @Before public void setUp() throws Exception { Loading @@ -108,8 +116,7 @@ public class FeatureConnectionTest extends TelephonyTest { doReturn(null).when(mContext).getMainLooper(); doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS); mTestFeatureConnection = new TestFeatureConnection( mContext, mPhoneId, ImsFeature.FEATURE_RCS); mTestFeatureConnection = new TestFeatureConnection(mContext, mPhoneId); mTestFeatureConnection.mExecutor = mSimpleExecutor; mTestFeatureConnection.setBinder(mBinder); } Loading Loading @@ -163,6 +170,20 @@ public class FeatureConnectionTest extends TelephonyTest { } } /** * Test registration tech callbacks. */ @Test @SmallTest public void testRegistrationTech() throws Exception { when(mRegistrationBinder.getRegistrationTechnology()).thenReturn( ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN); assertEquals(ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, mTestFeatureConnection.getRegistrationTech()); } /** * Test callback is called when IMS feature created/removed/changed. */ Loading Loading @@ -192,4 +213,8 @@ public class FeatureConnectionTest extends TelephonyTest { throw new AssertionFailedError("testListenerCallback(Changed): " + e); } } private IImsRegistration getTestRegistrationBinder() { return mRegistrationBinder; } } Loading
src/java/com/android/internal/telephony/ims/ImsResolver.java +16 −0 Original line number Diff line number Diff line Loading @@ -767,6 +767,22 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal return null; } /** * Unregister a previously registered IImsServiceFeatureCallback through * {@link #getImsServiceControllerAndListen(int, int, IImsServiceFeatureCallback)} . * @param slotId The slot id associated with the ImsFeature. * @param feature The {@link ImsFeature.FeatureType} * @param callback The callback to be unregistered. */ public void unregisterImsFeatureCallback(int slotId, int feature, IImsServiceFeatureCallback callback) { ImsServiceController controller = getImsServiceController(slotId, feature); if (controller != null) { controller.removeImsServiceFeatureCallback(callback); } } // Used for testing only. public boolean overrideImsServiceConfiguration(int slotId, boolean isCarrierService, Map<Integer, String> featureConfig) { Loading
src/java/com/android/internal/telephony/ims/ImsServiceController.java +16 −7 Original line number Diff line number Diff line Loading @@ -504,19 +504,28 @@ public class ImsServiceController { */ public void addImsServiceFeatureCallback(IImsServiceFeatureCallback callback) { mImsStatusCallbacks.add(callback); Set<ImsFeatureConfiguration.FeatureSlotPair> features; synchronized (mLock) { if (mImsFeatures == null || mImsFeatures.isEmpty()) { return; } features = new HashSet<>(mImsFeatures); } // notify the new status callback of the features that are available. try { for (ImsFeatureConfiguration.FeatureSlotPair i : mImsFeatures) { for (ImsFeatureConfiguration.FeatureSlotPair i : features) { callback.imsFeatureCreated(i.slotId, i.featureType); } } catch (RemoteException e) { Log.w(LOG_TAG, "addImsServiceFeatureCallback: exception notifying callback"); } } /** * Removes a previously registered callback if it was associated with this feature. */ public void removeImsServiceFeatureCallback(IImsServiceFeatureCallback callback) { mImsStatusCallbacks.remove(callback); } public void enableIms(int slotId) { Loading
tests/telephonytests/src/com/android/internal/telephony/ims/FeatureConnectionTest.java +29 −4 Original line number Diff line number Diff line Loading @@ -28,7 +28,9 @@ import android.content.Context; import android.content.pm.PackageManager; import android.os.IBinder; import android.os.RemoteException; import android.telephony.ims.aidl.IImsRegistration; import android.telephony.ims.feature.ImsFeature; import android.telephony.ims.stub.ImsRegistrationImplBase; import android.test.suitebuilder.annotation.SmallTest; import com.android.ims.FeatureConnection; Loading Loading @@ -59,8 +61,8 @@ public class FeatureConnectionTest extends TelephonyTest { public boolean isFeatureRemovedCalled = false; public int mNewStatus = ImsFeature.STATE_UNAVAILABLE; TestFeatureConnection(Context context, int slotId, int featureType) { super(context, slotId, featureType); TestFeatureConnection(Context context, int slotId) { super(context, slotId); if (!ImsManager.isImsSupportedOnDevice(context)) { sImsSupportedOnDevice = false; } Loading Loading @@ -91,6 +93,11 @@ public class FeatureConnectionTest extends TelephonyTest { return mFeatureState; } @Override protected IImsRegistration getRegistrationBinder() { return getTestRegistrationBinder(); } public void setFeatureState(int state) { mFeatureState = state; } Loading @@ -99,6 +106,7 @@ public class FeatureConnectionTest extends TelephonyTest { private int mPhoneId; private TestFeatureConnection mTestFeatureConnection; @Mock IBinder mBinder; @Mock IImsRegistration mRegistrationBinder; @Before public void setUp() throws Exception { Loading @@ -108,8 +116,7 @@ public class FeatureConnectionTest extends TelephonyTest { doReturn(null).when(mContext).getMainLooper(); doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS); mTestFeatureConnection = new TestFeatureConnection( mContext, mPhoneId, ImsFeature.FEATURE_RCS); mTestFeatureConnection = new TestFeatureConnection(mContext, mPhoneId); mTestFeatureConnection.mExecutor = mSimpleExecutor; mTestFeatureConnection.setBinder(mBinder); } Loading Loading @@ -163,6 +170,20 @@ public class FeatureConnectionTest extends TelephonyTest { } } /** * Test registration tech callbacks. */ @Test @SmallTest public void testRegistrationTech() throws Exception { when(mRegistrationBinder.getRegistrationTechnology()).thenReturn( ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN); assertEquals(ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, mTestFeatureConnection.getRegistrationTech()); } /** * Test callback is called when IMS feature created/removed/changed. */ Loading Loading @@ -192,4 +213,8 @@ public class FeatureConnectionTest extends TelephonyTest { throw new AssertionFailedError("testListenerCallback(Changed): " + e); } } private IImsRegistration getTestRegistrationBinder() { return mRegistrationBinder; } }