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

Commit daff8c50 authored by Brad Ebinger's avatar Brad Ebinger Committed by android-build-merger
Browse files

Merge "Integrate Registration APIs" am: f728c0c0

am: 6d7ef63f

Change-Id: Ifdf256d00b4dd15f8d4d4131889aa33a691e906c
parents af714fa6 6d7ef63f
Loading
Loading
Loading
Loading
+23 −2
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.telephony.ims;
package com.android.internal.telephony.ims;


import android.Manifest;
import android.Manifest;
import android.annotation.Nullable;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
@@ -40,6 +41,7 @@ import android.util.SparseArray;


import com.android.ims.internal.IImsMMTelFeature;
import com.android.ims.internal.IImsMMTelFeature;
import com.android.ims.internal.IImsRcsFeature;
import com.android.ims.internal.IImsRcsFeature;
import com.android.ims.internal.IImsRegistration;
import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneConstants;
@@ -344,9 +346,20 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal
        return (controller != null) ? controller.getRcsFeature(slotId) : null;
        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
    @VisibleForTesting
    public ImsServiceController getImsServiceControllerAndListen(int slotId, int feature,
    public ImsServiceController getImsServiceController(int slotId, int feature) {
            IImsServiceFeatureCallback callback) {
        if (slotId < 0 || slotId >= mNumSlots) {
        if (slotId < 0 || slotId >= mNumSlots) {
            return null;
            return null;
        }
        }
@@ -358,6 +371,14 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal
            }
            }
            controller = services.get(feature);
            controller = services.get(feature);
        }
        }
        return controller;
    }

    @VisibleForTesting
    public ImsServiceController getImsServiceControllerAndListen(int slotId, int feature,
            IImsServiceFeatureCallback callback) {
        ImsServiceController controller = getImsServiceController(slotId, feature);

        if (controller != null) {
        if (controller != null) {
            controller.addImsServiceFeatureListener(callback);
            controller.addImsServiceFeatureListener(callback);
            return controller;
            return controller;
+12 −4
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import android.util.Pair;
import com.android.ims.internal.IImsFeatureStatusCallback;
import com.android.ims.internal.IImsFeatureStatusCallback;
import com.android.ims.internal.IImsMMTelFeature;
import com.android.ims.internal.IImsMMTelFeature;
import com.android.ims.internal.IImsRcsFeature;
import com.android.ims.internal.IImsRcsFeature;
import com.android.ims.internal.IImsRegistration;
import com.android.ims.internal.IImsServiceController;
import com.android.ims.internal.IImsServiceController;
import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
@@ -366,10 +367,8 @@ public class ImsServiceController {
    }
    }


    /**
    /**
     * Finds the difference between the set of features that the ImsService has active and the new
     * For every feature that is added, the service calls the associated create. For every
     * set defined in newImsFeatures. For every feature that is added,
     * ImsFeature that is removed, {@link IImsServiceController#removeImsFeature} is called.
     * {@link IImsServiceController#createImsFeature} is called on the service. For every ImsFeature
     * that is removed, {@link IImsServiceController#removeImsFeature} is called.
     */
     */
    public void changeImsServiceFeatures(HashSet<Pair<Integer, Integer>> newImsFeatures)
    public void changeImsServiceFeatures(HashSet<Pair<Integer, Integer>> newImsFeatures)
            throws RemoteException {
            throws RemoteException {
@@ -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() {
    private void removeImsServiceFeatureListener() {
        synchronized (mLock) {
        synchronized (mLock) {
            mImsStatusCallbacks.clear();
            mImsStatusCallbacks.clear();
+35 −23
Original line number Original line Diff line number Diff line
@@ -665,7 +665,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    };
    };


    // Callback fires when ImsManager MMTel Feature changes state
    // Callback fires when ImsManager MMTel Feature changes state
    private ImsServiceProxy.INotifyStatusChanged mNotifyStatusChangedCallback = () -> {
    private ImsServiceProxy.IFeatureUpdate mNotifyStatusChangedCallback =
            new ImsServiceProxy.IFeatureUpdate() {
                @Override
                public void notifyStateChanged() {
                    try {
                    try {
                        int status = mImsManager.getImsServiceStatus();
                        int status = mImsManager.getImsServiceStatus();
                        log("Status Changed: " + status);
                        log("Status Changed: " + status);
@@ -688,6 +691,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                        // Could not get the ImsService, retry!
                        // Could not get the ImsService, retry!
                        retryGetImsService();
                        retryGetImsService();
                    }
                    }
                }

                @Override
                public void notifyUnavailable() {
                    retryGetImsService();
                }
            };
            };


    @VisibleForTesting
    @VisibleForTesting
@@ -794,7 +803,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        mImsManager.addNotifyStatusChangedCallbackIfAvailable(mNotifyStatusChangedCallback);
        mImsManager.addNotifyStatusChangedCallbackIfAvailable(mNotifyStatusChangedCallback);
        // Wait for ImsService.STATE_READY to start listening for calls.
        // 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.
        // Call the callback right away for compatibility with older devices that do not use states.
        mNotifyStatusChangedCallback.notifyStatusChanged();
        mNotifyStatusChangedCallback.notifyStateChanged();
    }
    }


    private void startListeningForCalls() throws ImsException {
    private void startListeningForCalls() throws ImsException {
@@ -3306,6 +3315,9 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        if (mImsManager.isServiceAvailable()) {
        if (mImsManager.isServiceAvailable()) {
            return;
            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
        //Leave mImsManager as null, then CallStateException will be thrown when dialing
        mImsManager = null;
        mImsManager = null;
        // Exponential backoff during retry, limited to 32 seconds.
        // Exponential backoff during retry, limited to 32 seconds.
+30 −9
Original line number Original line Diff line number Diff line
@@ -14,26 +14,28 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


package android.telephony.ims.internal;
package android.telephony.ims;


import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertEquals;


import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;


import android.net.Uri;
import android.os.Parcel;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.RemoteException;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.runner.AndroidJUnit4;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.telephony.ims.internal.aidl.IImsRegistration;
import android.telephony.ims.internal.feature.ImsFeature;
import android.telephony.ims.internal.feature.ImsFeature;
import android.telephony.ims.internal.stub.ImsFeatureConfiguration;
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 android.test.suitebuilder.annotation.SmallTest;


import com.android.ims.ImsReasonInfo;
import com.android.ims.ImsReasonInfo;
import com.android.ims.internal.IImsRegistration;
import com.android.ims.internal.IImsRegistrationCallback;


import org.junit.After;
import org.junit.After;
import org.junit.Before;
import org.junit.Before;
@@ -45,14 +47,15 @@ import org.mockito.Spy;
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4.class)
public class ImsRegistrationTests {
public class ImsRegistrationTests {


    @Spy private ImsRegistrationImplBase.Callback mCallback;
    @Spy private IImsRegistrationCallback.Stub mCallback;
    private TestImsRegistration mRegistration;
    @Spy private IImsRegistrationCallback.Stub mCallback2;
    private ImsRegistrationImplBase mRegistration;
    private IImsRegistration mRegBinder;
    private IImsRegistration mRegBinder;


    @Before
    @Before
    public void setup() throws RemoteException {
    public void setup() throws RemoteException {
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);
        mRegistration = new TestImsRegistration();
        mRegistration = new ImsRegistrationImplBase();
        mRegBinder = mRegistration.getBinder();
        mRegBinder = mRegistration.getBinder();
        mRegBinder.addRegistrationCallback(mCallback);
        mRegBinder.addRegistrationCallback(mCallback);
    }
    }
@@ -148,6 +151,17 @@ public class ImsRegistrationTests {
                eq(ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN), eq(info));
                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
    @SmallTest
    @Test
    @Test
    public void testRegistrationCallbackAfterUnregistered() throws RemoteException {
    public void testRegistrationCallbackAfterUnregistered() throws RemoteException {
@@ -161,7 +175,6 @@ public class ImsRegistrationTests {
    @SmallTest
    @SmallTest
    @Test
    @Test
    public void testRegistrationCallbackSendCurrentState() throws RemoteException {
    public void testRegistrationCallbackSendCurrentState() throws RemoteException {
        ImsRegistrationImplBase.Callback mCallback2 = spy(new ImsRegistrationImplBase.Callback());
        mRegistration.onRegistered(ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
        mRegistration.onRegistered(ImsRegistrationImplBase.REGISTRATION_TECH_LTE);


        mRegBinder.addRegistrationCallback(mCallback2);
        mRegBinder.addRegistrationCallback(mCallback2);
@@ -181,7 +194,6 @@ public class ImsRegistrationTests {
    @SmallTest
    @SmallTest
    @Test
    @Test
    public void testRegistrationCallbackSendCurrentStateDisconnected() throws RemoteException {
    public void testRegistrationCallbackSendCurrentStateDisconnected() throws RemoteException {
        ImsRegistrationImplBase.Callback mCallback2 = spy(new ImsRegistrationImplBase.Callback());
        ImsReasonInfo info = new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_NETWORK_NO_LTE_COVERAGE, 0);
        ImsReasonInfo info = new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_NETWORK_NO_LTE_COVERAGE, 0);
        mRegistration.onDeregistered(info);
        mRegistration.onDeregistered(info);


@@ -206,4 +218,13 @@ public class ImsRegistrationTests {
        assertEquals(ImsRegistrationImplBase.REGISTRATION_TECH_NONE,
        assertEquals(ImsRegistrationImplBase.REGISTRATION_TECH_NONE,
                mRegBinder.getRegistrationTechnology());
                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));
    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -27,7 +27,7 @@ import android.support.test.runner.AndroidJUnit4;
import android.telephony.ims.internal.feature.CapabilityChangeRequest;
import android.telephony.ims.internal.feature.CapabilityChangeRequest;
import android.telephony.ims.internal.feature.ImsFeature;
import android.telephony.ims.internal.feature.ImsFeature;
import android.telephony.ims.internal.feature.MmTelFeature;
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 android.test.suitebuilder.annotation.SmallTest;


import com.android.ims.internal.IImsFeatureStatusCallback;
import com.android.ims.internal.IImsFeatureStatusCallback;
Loading