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

Commit 221247d0 authored by Brad Ebinger's avatar Brad Ebinger Committed by Gerrit Code Review
Browse files

Merge "Expose MMTEL IMS registration technology to TelephonyManager"

parents d3b21e2b 006c213c
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import android.telephony.SignalStrength;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.VoLteServiceState;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.text.TextUtils;

import com.android.ims.ImsCall;
@@ -3192,6 +3193,20 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return isVolteEnabled;
    }

    /**
     * @return the IMS MmTel Registration technology for this Phone, defined in
     * {@link ImsRegistrationImplBase}.
     */
    public int getImsRegistrationTech() {
        Phone imsPhone = mImsPhone;
        int regTech = ImsRegistrationImplBase.REGISTRATION_TECH_NONE;
        if (imsPhone != null) {
            regTech = imsPhone.getImsRegistrationTech();
        }
        Rlog.d(LOG_TAG, "getImsRegistrationTechnology =" + regTech);
        return regTech;
    }

    private boolean getRoamingOverrideHelper(String prefix, String key) {
        String iccId = getIccSerialNumber();
        if (TextUtils.isEmpty(iccId) || TextUtils.isEmpty(key)) {
+9 −4
Original line number Diff line number Diff line
@@ -67,16 +67,16 @@ import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.UssdResponse;
import android.text.TextUtils;

import android.telephony.ims.ImsCallForwardInfo;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsSsInfo;
import android.text.TextUtils;

import com.android.ims.ImsEcbm;
import com.android.ims.ImsEcbmStateListener;
import com.android.ims.ImsException;
import com.android.ims.ImsManager;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsSsInfo;
import com.android.ims.ImsUtInterface;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.Call;
@@ -1613,6 +1613,11 @@ public class ImsPhone extends ImsPhoneBase {
        return mCT.isVideoCallEnabled();
    }

    @Override
    public int getImsRegistrationTech() {
        return mCT.getImsRegistrationTech();
    }

    @Override
    public Phone getDefaultPhone() {
        return mDefaultPhone;
+1 −1
Original line number Diff line number Diff line
@@ -3233,7 +3233,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        return mState;
    }

    private int getImsRegistrationTech() {
    public int getImsRegistrationTech() {
        if (mImsManager != null) {
            return mImsManager.getRegistrationTech();
        }
+77 −4
Original line number Diff line number Diff line
@@ -45,19 +45,20 @@ import android.support.test.filters.FlakyTest;
import android.telecom.VideoProfile;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.telephony.ServiceState;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsCallSession;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsStreamMediaProfile;
import android.telephony.ims.feature.ImsFeature;
import android.telephony.ims.feature.MmTelFeature;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.ims.ImsCall;
import android.telephony.ims.ImsCallProfile;
import com.android.ims.ImsConfig;
import com.android.ims.ImsException;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsStreamMediaProfile;
import com.android.ims.internal.IImsCallSession;
import android.telephony.ims.ImsCallSession;
import com.android.internal.telephony.Call;
import com.android.internal.telephony.CallStateException;
import com.android.internal.telephony.CommandsInterface;
@@ -79,6 +80,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
    private ImsPhoneCallTracker mCTUT;
    private ImsCTHandlerThread mImsCTHandlerThread;
    private MmTelFeature.Listener mMmTelListener;
    private ImsRegistrationImplBase.Callback mRegistrationCallback;
    private ImsFeature.CapabilityCallback mCapabilityCallback;
    private ImsCall.Listener mImsCallListener;
    private ImsCall mImsCall;
@@ -203,6 +205,11 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        }).when(mImsManager).makeCall(eq(mImsCallProfile), (String []) any(),
                (ImsCall.Listener) any());

        doAnswer(invocation -> {
            mRegistrationCallback = invocation.getArgument(0);
            return mRegistrationCallback;
        }).when(mImsManager).addRegistrationCallback(any(ImsRegistrationImplBase.Callback.class));

        doAnswer(invocation -> {
            mCapabilityCallback = (ImsFeature.CapabilityCallback) invocation.getArguments()[0];
            return mCapabilityCallback;
@@ -227,6 +234,72 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        super.tearDown();
    }

    @Test
    @SmallTest
    public void testImsRegistered() {
        // when IMS is registered
        mRegistrationCallback.onRegistered(ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
        // then service state should be IN_SERVICE and ImsPhone state set to registered
        verify(mImsPhone).setServiceState(eq(ServiceState.STATE_IN_SERVICE));
        verify(mImsPhone).setImsRegistered(eq(true));
    }

    @Test
    @SmallTest
    public void testImsRegistering() {
        // when IMS is registering
        mRegistrationCallback.onRegistering(ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
        // then service state should be OUT_OF_SERVICE and ImsPhone state set to not registered
        verify(mImsPhone).setServiceState(eq(ServiceState.STATE_OUT_OF_SERVICE));
        verify(mImsPhone).setImsRegistered(eq(false));
    }

    @Test
    @SmallTest
    public void testImsDeregistered() {
        // when IMS is deregistered
        mRegistrationCallback.onDeregistered(new ImsReasonInfo());
        // then service state should be OUT_OF_SERVICE and ImsPhone state set to not registered
        verify(mImsPhone).setServiceState(eq(ServiceState.STATE_OUT_OF_SERVICE));
        verify(mImsPhone).setImsRegistered(eq(false));
    }

    @Test
    @SmallTest
    public void testVowifiDisabledOnLte() {
        // LTE is registered.
        doReturn(ImsRegistrationImplBase.REGISTRATION_TECH_LTE).when(
                mImsManager).getRegistrationTech();
        assertFalse(mCTUT.isVowifiEnabled());

        // enable Voice over LTE
        ImsFeature.Capabilities caps = new ImsFeature.Capabilities();
        caps.addCapabilities(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE);
        mCapabilityCallback.onCapabilitiesStatusChanged(caps);
        waitForHandlerAction(mCTHander, 1000);

        // Voice over IWLAN is still disabled
        assertFalse(mCTUT.isVowifiEnabled());
    }

    @Test
    @SmallTest
    public void testVowifiDisabledOnIwlan() {
        // LTE is registered.
        doReturn(ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN).when(
                mImsManager).getRegistrationTech();
        assertFalse(mCTUT.isVowifiEnabled());

        // enable Voice over IWLAN
        ImsFeature.Capabilities caps = new ImsFeature.Capabilities();
        caps.addCapabilities(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE);
        mCapabilityCallback.onCapabilitiesStatusChanged(caps);
        waitForHandlerAction(mCTHander, 1000);

        // Voice over IWLAN is enabled
        assertTrue(mCTUT.isVowifiEnabled());
    }

    @Test
    @SmallTest
    public void testImsFeatureCapabilityChange() {