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

Commit 10c7e08c authored by Hunsuk Choi's avatar Hunsuk Choi
Browse files

Add imsRadioTech param to handleImsUnregistered

Bug: 219242990
Bug: 260953481
Test: astest ImsRegistrationCallbackHelperTest
Change-Id: If44ade51f508035e1a5fa68cead5d1e1449229bf
parent 7c4d8d73
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -303,6 +303,8 @@ public class ImsPhone extends ImsPhoneBase {
    private @ImsRegistrationImplBase.ImsRegistrationTech int mImsRegistrationTech =
            REGISTRATION_TECH_NONE;
    private @RegistrationManager.SuggestedAction int mImsRegistrationSuggestedAction;
    private @ImsRegistrationImplBase.ImsRegistrationTech int mImsDeregistrationTech =
            REGISTRATION_TECH_NONE;
    private int mImsRegistrationCapabilities;
    private boolean mNotifiedRegisteredState;

@@ -2513,10 +2515,12 @@ public class ImsPhone extends ImsPhoneBase {

        @Override
        public void handleImsUnregistered(ImsReasonInfo imsReasonInfo,
                @RegistrationManager.SuggestedAction int suggestedAction) {
                @RegistrationManager.SuggestedAction int suggestedAction,
                @ImsRegistrationImplBase.ImsRegistrationTech int imsRadioTech) {
            if (DBG) {
                logd("handleImsUnregistered: onImsMmTelDisconnected imsReasonInfo="
                        + imsReasonInfo + ", suggestedAction=" + suggestedAction);
                        + imsReasonInfo + ", suggestedAction=" + suggestedAction
                        + ", disconnectedRadioTech=" + imsRadioTech);
            }
            mRegLocalLog.log("handleImsUnregistered: onImsMmTelDisconnected imsRadioTech="
                    + imsReasonInfo);
@@ -2535,7 +2539,7 @@ public class ImsPhone extends ImsPhoneBase {
                }
            }
            updateImsRegistrationInfo(REGISTRATION_STATE_NOT_REGISTERED,
                    REGISTRATION_TECH_NONE, suggestedModemAction);
                    imsRadioTech, suggestedModemAction);
        }

        @Override
@@ -2708,7 +2712,8 @@ public class ImsPhone extends ImsPhoneBase {
        if (regState == mImsRegistrationState) {
            if ((regState == REGISTRATION_STATE_REGISTERED && imsRadioTech == mImsRegistrationTech)
                    || (regState == REGISTRATION_STATE_NOT_REGISTERED
                            && suggestedAction == mImsRegistrationSuggestedAction)) {
                            && suggestedAction == mImsRegistrationSuggestedAction
                            && imsRadioTech == mImsDeregistrationTech)) {
                // Filter duplicate notification.
                return;
            }
@@ -2732,6 +2737,11 @@ public class ImsPhone extends ImsPhoneBase {
        mImsRegistrationState = regState;
        mImsRegistrationTech = imsRadioTech;
        mImsRegistrationSuggestedAction = suggestedAction;
        if (regState == REGISTRATION_STATE_NOT_REGISTERED) {
            mImsDeregistrationTech = imsRadioTech;
        } else {
            mImsDeregistrationTech = REGISTRATION_TECH_NONE;
        }
        mImsRegistrationCapabilities = 0;
        // REGISTRATION_STATE_REGISTERED will be notified when the capability is updated.
        mNotifiedRegisteredState = false;
+9 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsRegistrationAttributes;
import android.telephony.ims.RegistrationManager;
import android.telephony.ims.aidl.IImsRegistrationCallback;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;

import java.util.concurrent.Executor;
@@ -52,7 +53,8 @@ public class ImsRegistrationCallbackHelper {
         * Handle the callback when IMS is unregistered.
         */
        void handleImsUnregistered(ImsReasonInfo imsReasonInfo,
                @RegistrationManager.SuggestedAction int suggestedAction);
                @RegistrationManager.SuggestedAction int suggestedAction,
                @ImsRegistrationImplBase.ImsRegistrationTech int imsRadioTech);

        /**
         * Handle the callback when the list of subscriber {@link Uri}s associated with this IMS
@@ -81,14 +83,17 @@ public class ImsRegistrationCallbackHelper {

                @Override
                public void onUnregistered(ImsReasonInfo imsReasonInfo) {
                    onUnregistered(imsReasonInfo, RegistrationManager.SUGGESTED_ACTION_NONE);
                    onUnregistered(imsReasonInfo, RegistrationManager.SUGGESTED_ACTION_NONE,
                            ImsRegistrationImplBase.REGISTRATION_TECH_NONE);
                }

                @Override
                public void onUnregistered(ImsReasonInfo imsReasonInfo,
                        @RegistrationManager.SuggestedAction int suggestedAction) {
                        @RegistrationManager.SuggestedAction int suggestedAction,
                        @ImsRegistrationImplBase.ImsRegistrationTech int imsRadioTech) {
                    updateRegistrationState(RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED);
                    mImsRegistrationUpdate.handleImsUnregistered(imsReasonInfo, suggestedAction);
                    mImsRegistrationUpdate.handleImsUnregistered(imsReasonInfo, suggestedAction,
                            imsRadioTech);
                }

                @Override
+19 −5
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package android.telephony.ims;

import static android.telephony.ims.RegistrationManager.SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_LTE;

import static junit.framework.Assert.assertEquals;

import static org.mockito.ArgumentMatchers.any;
@@ -148,7 +151,18 @@ public class ImsRegistrationTests {
        ImsReasonInfo info = new ImsReasonInfo();
        mRegistration.onDeregistered(info);

        verify(mCallback).onDeregistered(eq(info), anyInt());
        verify(mCallback).onDeregistered(eq(info), anyInt(), anyInt());
    }

    @SmallTest
    @Test
    public void testRegistrationCallbackOnDeregisteredWithSuggestedAction() throws RemoteException {
        ImsReasonInfo info = new ImsReasonInfo();
        mRegistration.onDeregistered(info,
                SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK, REGISTRATION_TECH_LTE);

        verify(mCallback).onDeregistered(eq(info),
                eq(SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK), eq(REGISTRATION_TECH_LTE));
    }

    @SmallTest
@@ -219,10 +233,10 @@ public class ImsRegistrationTests {

        // The original callback that has been registered should get LTE tech in disconnected
        // message
        verify(mCallback).onDeregistered(eq(info), anyInt());
        verify(mCallback).onDeregistered(eq(info), anyInt(), anyInt());
        // A callback that has just been registered should get NONE for tech in disconnected
        // message
        verify(mCallback2).onDeregistered(eq(info), anyInt());
        verify(mCallback2).onDeregistered(eq(info), anyInt(), anyInt());
    }

    @SmallTest
@@ -232,7 +246,7 @@ public class ImsRegistrationTests {

        mRegistration.onDeregistered(info);

        verify(mCallback).onDeregistered(eq(info), anyInt());
        verify(mCallback).onDeregistered(eq(info), anyInt(), anyInt());
        assertEquals(ImsRegistrationImplBase.REGISTRATION_TECH_NONE,
                mRegBinder.getRegistrationTechnology());
    }
@@ -243,7 +257,7 @@ public class ImsRegistrationTests {
        mRegBinder.addRegistrationCallback(mCallback2);
        // Verify that if we have never set the registration state, we do not callback immediately
        // with onUnregistered.
        verify(mCallback2, never()).onDeregistered(any(ImsReasonInfo.class), anyInt());
        verify(mCallback2, never()).onDeregistered(any(ImsReasonInfo.class), anyInt(), anyInt());
    }

    @SmallTest
+33 −12
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import static android.telephony.ims.RegistrationManager.SUGGESTED_ACTION_TRIGGER
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_3G;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_LTE;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_NONE;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_NR;

import static com.android.internal.telephony.CommandsInterface.CF_ACTION_ENABLE;
@@ -1306,11 +1305,27 @@ public class ImsPhoneTest extends TelephonyTest {
                ImsReasonInfo.CODE_UNSPECIFIED, "");

        // unregistered with fatal error
        registrationCallback.onUnregistered(reasonInfo, SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK);
        registrationCallback.onUnregistered(reasonInfo,
                SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK, REGISTRATION_TECH_NR);
        regInfo = mSimulatedCommands.getImsRegistrationInfo();

        assertTrue(regInfo[0] == RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED
                && regInfo[1] == REGISTRATION_TECH_NR
                && regInfo[2] == SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK);

        // reset the registration info saved in the SimulatedCommands
        mSimulatedCommands.updateImsRegistrationInfo(0, 0, 0, 0, null);
        regInfo = mSimulatedCommands.getImsRegistrationInfo();

        assertTrue(regInfo[0] == 0 && regInfo[1] == 0 && regInfo[2] == 0);

        // unregistered with fatal error but rat changed
        registrationCallback.onUnregistered(reasonInfo,
                SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK, REGISTRATION_TECH_LTE);
        regInfo = mSimulatedCommands.getImsRegistrationInfo();

        assertTrue(regInfo[0] == RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED
                && regInfo[1] == REGISTRATION_TECH_NONE
                && regInfo[1] == REGISTRATION_TECH_LTE
                && regInfo[2] == SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK);

        // reset the registration info saved in the SimulatedCommands
@@ -1320,7 +1335,8 @@ public class ImsPhoneTest extends TelephonyTest {
        assertTrue(regInfo[0] == 0 && regInfo[1] == 0 && regInfo[2] == 0);

        // duplicated notification with the same suggested action
        registrationCallback.onUnregistered(reasonInfo, SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK);
        registrationCallback.onUnregistered(reasonInfo,
                SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK, REGISTRATION_TECH_LTE);
        regInfo = mSimulatedCommands.getImsRegistrationInfo();

        // verify that there is no update in the SimulatedCommands
@@ -1328,11 +1344,12 @@ public class ImsPhoneTest extends TelephonyTest {

        // unregistered with repeated error
        registrationCallback.onUnregistered(reasonInfo,
                SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK_WITH_TIMEOUT);
                SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK_WITH_TIMEOUT,
                REGISTRATION_TECH_LTE);
        regInfo = mSimulatedCommands.getImsRegistrationInfo();

        assertTrue(regInfo[0] == RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED
                && regInfo[1] == REGISTRATION_TECH_NONE
                && regInfo[1] == REGISTRATION_TECH_LTE
                && regInfo[2] == SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK_WITH_TIMEOUT);

        // reset the registration info saved in the SimulatedCommands
@@ -1343,28 +1360,31 @@ public class ImsPhoneTest extends TelephonyTest {

        // duplicated notification with the same suggested action
        registrationCallback.onUnregistered(reasonInfo,
                SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK_WITH_TIMEOUT);
                SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK_WITH_TIMEOUT,
                REGISTRATION_TECH_LTE);
        regInfo = mSimulatedCommands.getImsRegistrationInfo();

        // verify that there is no update in the SimulatedCommands
        assertTrue(regInfo[0] == 0 && regInfo[1] == 0 && regInfo[2] == 0);

        // unregistered with temporary error
        registrationCallback.onUnregistered(reasonInfo, SUGGESTED_ACTION_NONE);
        registrationCallback.onUnregistered(reasonInfo,
                SUGGESTED_ACTION_NONE, REGISTRATION_TECH_LTE);
        regInfo = mSimulatedCommands.getImsRegistrationInfo();

        assertTrue(regInfo[0] == RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED
                && regInfo[1] == REGISTRATION_TECH_NONE
                && regInfo[1] == REGISTRATION_TECH_LTE
                && regInfo[2] == SUGGESTED_ACTION_NONE);

        // verifies that reason codes except ImsReasonInfo.CODE_REGISTRATION_ERROR are discarded.
        reasonInfo = new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_NETWORK_NO_SERVICE,
                ImsReasonInfo.CODE_UNSPECIFIED, "");
        registrationCallback.onUnregistered(reasonInfo, SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK);
        registrationCallback.onUnregistered(reasonInfo,
                SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK, REGISTRATION_TECH_NR);
        regInfo = mSimulatedCommands.getImsRegistrationInfo();

        assertTrue(regInfo[0] == RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED
                && regInfo[1] == REGISTRATION_TECH_NONE
                && regInfo[1] == REGISTRATION_TECH_NR
                && regInfo[2] == SUGGESTED_ACTION_NONE);

        // change the registration info saved in the SimulatedCommands
@@ -1374,7 +1394,8 @@ public class ImsPhoneTest extends TelephonyTest {
        assertTrue(regInfo[0] == 1 && regInfo[1] == 1 && regInfo[2] == 1);

        // duplicated notification with the same suggested action
        registrationCallback.onUnregistered(reasonInfo, SUGGESTED_ACTION_NONE);
        registrationCallback.onUnregistered(reasonInfo,
                SUGGESTED_ACTION_NONE, REGISTRATION_TECH_NR);
        regInfo = mSimulatedCommands.getImsRegistrationInfo();

        // verify that there is no update in the SimulatedCommands
+21 −1
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
package com.android.internal.telephony.imsphone;

import static android.telephony.ims.RegistrationManager.SUGGESTED_ACTION_NONE;
import static android.telephony.ims.RegistrationManager.SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_LTE;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_NONE;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -166,7 +169,24 @@ public class ImsRegistrationCallbackHelperTest extends TelephonyTest {
        assertEquals(RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED,
                mRegistrationCallbackHelper.getImsRegistrationState());
        verify(mMockRegistrationUpdate).handleImsUnregistered(eq(reasonInfo),
                eq(SUGGESTED_ACTION_NONE));
                eq(SUGGESTED_ACTION_NONE), eq(REGISTRATION_TECH_NONE));
    }

    @Test
    @SmallTest
    public void testImsUnRegisteredWithSuggestedAction() {
        // Verify the RegistrationCallback should not be null
        RegistrationCallback callback = mRegistrationCallbackHelper.getCallback();
        assertNotNull(callback);

        ImsReasonInfo reasonInfo = new ImsReasonInfo(ImsReasonInfo.CODE_REGISTRATION_ERROR, 0);
        callback.onUnregistered(reasonInfo, SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK,
                REGISTRATION_TECH_LTE);

        assertEquals(RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED,
                mRegistrationCallbackHelper.getImsRegistrationState());
        verify(mMockRegistrationUpdate).handleImsUnregistered(eq(reasonInfo),
                eq(SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK), eq(REGISTRATION_TECH_LTE));
    }

    @Test