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

Commit 036e64e8 authored by Hyunho's avatar Hyunho Committed by Automerger Merge Worker
Browse files

When the IMS unregistered, reset the PUBLISH throttle timer am: d92dddbb am: 045556c1

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ims/+/1958880

Change-Id: I429e52f08d637d8601f75052bef1a01ea8b08af2
parents 58a7d7bd 045556c1
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ public class DeviceCapabilityListener {
        private static final int EVENT_REGISTER_IMS_CONTENT_CHANGE = 1;
        private static final int EVENT_UNREGISTER_IMS_CHANGE = 2;
        private static final int EVENT_REQUEST_PUBLISH = 3;
        private static final int EVENT_IMS_UNREGISTERED = 4;

        DeviceCapabilityHandler(Looper looper) {
            super(looper);
@@ -127,6 +128,9 @@ public class DeviceCapabilityListener {
                    int triggerType = msg.arg1;
                    mCallback.requestPublishFromInternal(triggerType);
                    break;
                case EVENT_IMS_UNREGISTERED:
                    mCallback.updateImsUnregistered();
                    break;
            }
        }

@@ -155,6 +159,14 @@ public class DeviceCapabilityListener {
            message.arg1 = type;
            sendMessageDelayed(message, TRIGGER_PUBLISH_REQUEST_DELAY_MS);
        }

        public void sendImsUnregisteredMessage() {
            logd("sendImsUnregisteredMessage");
            // Remove the existing message and resend a new message.
            removeMessages(EVENT_IMS_UNREGISTERED);
            Message msg = obtainMessage(EVENT_IMS_UNREGISTERED);
            sendMessageDelayed(msg, TRIGGER_PUBLISH_REQUEST_DELAY_MS);
        }
    }

    private final int mSubId;
@@ -601,8 +613,11 @@ public class DeviceCapabilityListener {
        mCapabilityInfo.updateImsMmtelUnregistered();
        // When the MMTEL is unregistered, the mmtel associated uri should be cleared.
        handleMmTelSubscriberAssociatedUriChanged(null, false);
        mHandler.sendTriggeringPublishMessage(
                PublishController.PUBLISH_TRIGGER_MMTEL_UNREGISTERED);

        // If the RCS is already unregistered, it informs that the IMS is unregistered.
        if (mCapabilityInfo.isImsRegistered() == false) {
            mHandler.sendImsUnregisteredMessage();
        }
    }

    /*
@@ -648,10 +663,9 @@ public class DeviceCapabilityListener {
        boolean hasChanged = mCapabilityInfo.updateImsRcsUnregistered();
        // When the RCS is unregistered, the rcs associated uri should be cleared.
        handleRcsSubscriberAssociatedUriChanged(null, false);
        // Trigger publish if the state has changed.
        if (hasChanged) {
            mHandler.sendTriggeringPublishMessage(
                    PublishController.PUBLISH_TRIGGER_RCS_UNREGISTERED);
        // If the MMTEL is already unregistered, it informs that the IMS is unregistered.
        if (mCapabilityInfo.isImsRegistered() == false) {
            mHandler.sendImsUnregisteredMessage();
        }
    }

+10 −1
Original line number Diff line number Diff line
@@ -84,6 +84,9 @@ public interface PublishController extends ControllerBase {
    /** The Carrier Config for the subscription has Changed **/
    int PUBLISH_TRIGGER_CARRIER_CONFIG_CHANGED = 16;

    /** MMTEL and RCS are unregistered. **/
    int PUBLISH_TRIGGER_MMTEL_RCS_UNREGISTERED = 17;

    @IntDef(value = {
            PUBLISH_TRIGGER_SERVICE,
            PUBLISH_TRIGGER_RETRY,
@@ -100,7 +103,8 @@ public interface PublishController extends ControllerBase {
            PUBLISH_TRIGGER_RCS_URI_CHANGE,
            PUBLISH_TRIGGER_PROVISIONING_CHANGE,
            PUBLISH_TRIGGER_OVERRIDE_CAPS,
            PUBLISH_TRIGGER_CARRIER_CONFIG_CHANGED
            PUBLISH_TRIGGER_CARRIER_CONFIG_CHANGED,
            PUBLISH_TRIGGER_MMTEL_RCS_UNREGISTERED
    }, prefix="PUBLISH_TRIGGER_")
    @Retention(RetentionPolicy.SOURCE)
    @interface PublishTriggerType {}
@@ -154,6 +158,11 @@ public interface PublishController extends ControllerBase {
         * Sent the publish request to ImsService.
         */
        void notifyPendingPublishRequest();

        /**
         * Update the Ims unregistered. This api will be called if the IMS unregistered.
         */
        void updateImsUnregistered();
    }

    /**
+23 −0
Original line number Diff line number Diff line
@@ -434,6 +434,12 @@ public class PublishControllerImpl implements PublishController {
                    logd("notifyPendingPublishRequest");
                    mPublishHandler.sendPublishSentMessage();
                }

                @Override
                public void updateImsUnregistered() {
                    logd("updateImsUnregistered");
                    mPublishHandler.sendImsUnregisteredMessage();
                }
            };

    /**
@@ -461,6 +467,7 @@ public class PublishControllerImpl implements PublishController {
        private static final int MSG_UNPUBLISHED = 13;
        private static final int MSG_PUBLISH_SENT = 14;
        private static final int MSG_PUBLISH_UPDATED = 15;
        private static final int MSG_IMS_UNREGISTERED = 16;

        private final WeakReference<PublishControllerImpl> mPublishControllerRef;

@@ -569,6 +576,12 @@ public class PublishControllerImpl implements PublishController {
                            reasonHeaderCause, reasonHeaderText);
                    break;
                }

                case MSG_IMS_UNREGISTERED:
                    publishCtrl.handleUnpublishedMessage(RcsUceAdapter.PUBLISH_STATE_NOT_PUBLISHED,
                            Instant.now());
                    break;

                default:
                    publishCtrl.logd("invalid message: " + message.what);
                    break;
@@ -812,6 +825,15 @@ public class PublishControllerImpl implements PublishController {
            removeMessages(MSG_RESET_DEVICE_STATE);
        }

        public void sendImsUnregisteredMessage() {
            PublishControllerImpl publishCtrl = mPublishControllerRef.get();
            if (publishCtrl == null) return;
            if (publishCtrl.mIsDestroyedFlag) return;
            Message message = obtainMessage();
            message.what = MSG_IMS_UNREGISTERED;
            sendMessage(message);
        }

        private static Map<Integer, String> EVENT_DESCRIPTION = new HashMap<>();
        static {
            EVENT_DESCRIPTION.put(MSG_RCS_CONNECTED, "RCS_CONNECTED");
@@ -829,6 +851,7 @@ public class PublishControllerImpl implements PublishController {
            EVENT_DESCRIPTION.put(MSG_UNPUBLISHED, "MSG_UNPUBLISHED");
            EVENT_DESCRIPTION.put(MSG_PUBLISH_SENT, "MSG_PUBLISH_SENT");
            EVENT_DESCRIPTION.put(MSG_PUBLISH_UPDATED, "MSG_PUBLISH_UPDATED");
            EVENT_DESCRIPTION.put(MSG_IMS_UNREGISTERED, "MSG_IMS_UNREGISTERED");
        }
    }

+39 −36
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.refEq;
import static org.mockito.Mockito.verify;

@@ -174,24 +175,6 @@ public class DeviceCapabilityListenerTest extends ImsTestBase {
                PublishController.PUBLISH_TRIGGER_MMTEL_REGISTERED);
    }

    @Test
    @SmallTest
    public void testMmTelUnregistration() throws Exception {
        DeviceCapabilityListener deviceCapListener = createDeviceCapabilityListener();
        deviceCapListener.setImsCallbackRegistered(true);
        RegistrationCallback registrationCallback = deviceCapListener.mMmtelRegistrationCallback;

        ImsReasonInfo info = new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_NOT_REGISTERED, -1, "");
        registrationCallback.onUnregistered(info);

        Handler handler = deviceCapListener.getHandler();
        waitForHandlerActionDelayed(handler, HANDLER_WAIT_TIMEOUT_MS, HANDLER_SENT_DELAY_MS);

        verify(mDeviceCapability).updateImsMmtelUnregistered();
        verify(mCallback).requestPublishFromInternal(
                PublishController.PUBLISH_TRIGGER_MMTEL_UNREGISTERED);
    }

    @Test
    @SmallTest
    public void testRcsRegistration() throws Exception {
@@ -226,41 +209,61 @@ public class DeviceCapabilityListenerTest extends ImsTestBase {

    @Test
    @SmallTest
    public void testRcsUnregistration() throws Exception {
    public void testMmtelCapabilityChange() throws Exception {
        DeviceCapabilityListener deviceCapListener = createDeviceCapabilityListener();
        deviceCapListener.setImsCallbackRegistered(true);
        RegistrationCallback registrationCallback = deviceCapListener.mRcsRegistrationCallback;
        // Notify DeviceCapabilityListener that unregistered has caused a change and requires
        // publish.
        doReturn(true).when(mDeviceCapability).updateImsRcsUnregistered();
        ImsMmTelManager.CapabilityCallback callback = deviceCapListener.mMmtelCapabilityCallback;

        ImsReasonInfo info = new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_NOT_REGISTERED, -1, "");
        registrationCallback.onUnregistered(info);
        MmTelFeature.MmTelCapabilities capabilities = new MmTelFeature.MmTelCapabilities();
        callback.onCapabilitiesStatusChanged(capabilities);

        Handler handler = deviceCapListener.getHandler();
        waitForHandlerActionDelayed(handler, HANDLER_WAIT_TIMEOUT_MS, HANDLER_SENT_DELAY_MS);

        verify(mDeviceCapability).updateImsRcsUnregistered();
        verify(mDeviceCapability).updateMmtelCapabilitiesChanged(capabilities);
        verify(mCallback).requestPublishFromInternal(
                PublishController.PUBLISH_TRIGGER_RCS_UNREGISTERED);
        verify(mUceStatsWriter).setStoreCompleteImsRegistrationFeatureTagStats(anyInt());
                PublishController.PUBLISH_TRIGGER_MMTEL_CAPABILITY_CHANGE);
    }

    @Test
    @SmallTest
    public void testMmtelCapabilityChange() throws Exception {
    public void testImsUnregistration() throws Exception {
        DeviceCapabilityListener deviceCapListener = createDeviceCapabilityListener();
        ImsMmTelManager.CapabilityCallback callback = deviceCapListener.mMmtelCapabilityCallback;
        deviceCapListener.setImsCallbackRegistered(true);

        MmTelFeature.MmTelCapabilities capabilities = new MmTelFeature.MmTelCapabilities();
        callback.onCapabilitiesStatusChanged(capabilities);
        // set the Ims is registered
        doReturn(true).when(mDeviceCapability).isImsRegistered();
        // MMTEL unregistered
        RegistrationCallback mmtelRegiCallback = deviceCapListener.mMmtelRegistrationCallback;

        ImsReasonInfo info = new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_NOT_REGISTERED, -1, "");
        mmtelRegiCallback.onUnregistered(info);

        Handler handler = deviceCapListener.getHandler();
        waitForHandlerActionDelayed(handler, HANDLER_WAIT_TIMEOUT_MS, HANDLER_SENT_DELAY_MS);

        verify(mDeviceCapability).updateMmtelCapabilitiesChanged(capabilities);
        verify(mCallback).requestPublishFromInternal(
                PublishController.PUBLISH_TRIGGER_MMTEL_CAPABILITY_CHANGE);
        verify(mDeviceCapability).updateImsMmtelUnregistered();

        // Do not send internal publish trigger
        verify(mCallback, never()).requestPublishFromInternal(anyInt());
        // Only MMTEL unregistered. Verify do not send ImsUnregistered.
        verify(mCallback, never()).updateImsUnregistered();

        // set the Ims Unregistered
        doReturn(false).when(mDeviceCapability).isImsRegistered();
        // RCS unregistered
        RegistrationCallback rcsRegiCallback = deviceCapListener.mRcsRegistrationCallback;
        doReturn(true).when(mDeviceCapability).updateImsRcsUnregistered();

        rcsRegiCallback.onUnregistered(info);

        waitForHandlerActionDelayed(handler, HANDLER_WAIT_TIMEOUT_MS, HANDLER_SENT_DELAY_MS);

        verify(mDeviceCapability).updateImsRcsUnregistered();
        // Do not send internal publish trigger
        verify(mCallback, never()).requestPublishFromInternal(anyInt());
        verify(mUceStatsWriter).setStoreCompleteImsRegistrationFeatureTagStats(anyInt());

        verify(mCallback).updateImsUnregistered();
    }

    private DeviceCapabilityListener createDeviceCapabilityListener() {
+19 −0
Original line number Diff line number Diff line
@@ -199,6 +199,25 @@ public class PublishControllerImplTest extends ImsTestBase {
        verify(mUceStatsWriter).setUnPublish(eq(mSubId));
    }

    @Test
    @SmallTest
    public void testImsUnregistered() throws Exception {
        PublishControllerImpl publishController = createPublishController();
        //To initialize the public state to publish_ok.
        publishController.setCapabilityType(RcsImsCapabilities.CAPABILITY_TYPE_OPTIONS_UCE);

        // Trigger a ims unregistered
        PublishControllerCallback callback = publishController.getPublishControllerCallback();
        callback.updateImsUnregistered();

        Handler handler = publishController.getPublishHandler();
        waitForHandlerAction(handler, 1000);
        int publishState = publishController.getUcePublishState(false);
        assertEquals(RcsUceAdapter.PUBLISH_STATE_NOT_PUBLISHED, publishState);
        verify(mPublishProcessor).resetState();
        verify(mUceStatsWriter).setUnPublish(eq(mSubId));
    }

    @Test
    @SmallTest
    public void testPublishUpdated() throws Exception {