Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9038dca authored by Brad Ebinger's avatar Brad Ebinger Committed by Automerger Merge Worker
Browse files

Merge "Add the ability to remove FeatureConnection callbacks" am: 2f3350dd

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1344740

Change-Id: I34ff2d3addbccd61c22196aaf7c07d3ad6322575
parents 9e4e6945 2f3350dd
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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) {
+16 −7
Original line number Diff line number Diff line
@@ -501,19 +501,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) {
+29 −4
Original line number Diff line number Diff line
@@ -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;
@@ -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;
            }
@@ -91,6 +93,11 @@ public class FeatureConnectionTest extends TelephonyTest {
            return mFeatureState;
        }

        @Override
        protected IImsRegistration getRegistrationBinder() {
            return getTestRegistrationBinder();
        }

        public void setFeatureState(int state) {
            mFeatureState = state;
        }
@@ -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 {
@@ -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);
    }
@@ -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.
     */
@@ -192,4 +213,8 @@ public class FeatureConnectionTest extends TelephonyTest {
            throw new AssertionFailedError("testListenerCallback(Changed): " + e);
        }
    }

    private IImsRegistration getTestRegistrationBinder() {
        return mRegistrationBinder;
    }
}