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

Commit 60277c4a authored by hhshin's avatar hhshin
Browse files

[UCE] Reset the retry count and times related publish when the publish status...

[UCE] Reset the retry count and times related publish when the publish status changed to not_published

we do not reset the PUBLISH throttling timer when CapabilityExchangeEventListener#onUnpublish is called and PDN is torn down. This means that PUBLISH is delayed up to a minute when IMS PDN comes back up. Instead, we should be resetting this timer when the onUnpublish event is received

Bug: http://b/204198074
Test: atest PublishControllerImplTest
Change-Id: I3a01bf33921922fcc440fc5d8f4efb3d99916b28
parent f9cc835d
Loading
Loading
Loading
Loading
+34 −2
Original line number Diff line number Diff line
@@ -330,8 +330,7 @@ public class PublishControllerImpl implements PublishController {
    public void onUnpublish() {
        logd("onUnpublish");
        if (mIsDestroyedFlag) return;
        mPublishHandler.sendPublishStateChangedMessage(RcsUceAdapter.PUBLISH_STATE_NOT_PUBLISHED,
                Instant.now(), null /*pidfXml*/);
        mPublishHandler.sendUnpublishedMessage(RcsUceAdapter.PUBLISH_STATE_NOT_PUBLISHED);
    }

    @Override
@@ -416,6 +415,7 @@ public class PublishControllerImpl implements PublishController {
        private static final int MSG_REQUEST_NETWORK_RESPONSE = 10;
        private static final int MSG_REQUEST_CANCELED = 11;
        private static final int MSG_RESET_DEVICE_STATE = 12;
        private static final int MSG_UNPUBLISHED = 13;

        private final WeakReference<PublishControllerImpl> mPublishControllerRef;

@@ -496,6 +496,14 @@ public class PublishControllerImpl implements PublishController {
                    publishCtrl.handleResetDeviceStateMessage();
                    break;

                case MSG_UNPUBLISHED: {
                    SomeArgs args = (SomeArgs) message.obj;
                    int newPublishState = (Integer) args.arg1;
                    Instant updatedTimestamp = (Instant) args.arg2;
                    args.recycle();
                    publishCtrl.handleUnpublishedMessage(newPublishState, updatedTimestamp);
                    break;
                }
                default:
                    publishCtrl.logd("invalid message: " + message.what);
                    break;
@@ -583,6 +591,22 @@ public class PublishControllerImpl implements PublishController {
            sendMessage(message);
        }

        /**
         * Send the message to notify the publish state is changed.
         */
        public void sendUnpublishedMessage(@PublishState int publishState) {
            PublishControllerImpl publishCtrl = mPublishControllerRef.get();
            if (publishCtrl == null) return;
            if (publishCtrl.mIsDestroyedFlag) return;

            SomeArgs args = SomeArgs.obtain();
            args.arg1 = publishState;
            args.arg2 = Instant.now();
            Message message = obtainMessage();
            message.what = MSG_UNPUBLISHED;
            message.obj = args;
            sendMessage(message);
        }
        /**
         * Send the message to notify the new added callback of the latest publish state.
         */
@@ -703,6 +727,7 @@ public class PublishControllerImpl implements PublishController {
            EVENT_DESCRIPTION.put(MSG_REQUEST_NETWORK_RESPONSE, "REQUEST_NETWORK_RESPONSE");
            EVENT_DESCRIPTION.put(MSG_REQUEST_CANCELED, "REQUEST_CANCELED");
            EVENT_DESCRIPTION.put(MSG_RESET_DEVICE_STATE, "RESET_DEVICE_STATE");
            EVENT_DESCRIPTION.put(MSG_UNPUBLISHED, "MSG_UNPUBLISHED");
        }
    }

@@ -988,6 +1013,13 @@ public class PublishControllerImpl implements PublishController {
        mUceCtrlCallback.resetDeviceState();
    }

    private void handleUnpublishedMessage(@PublishState int newPublishState,
            Instant updatedTimestamp) {
        if (mIsDestroyedFlag) return;
        mPublishProcessor.resetState();
        handlePublishStateChangedMessage(newPublishState, updatedTimestamp, null);
    }

    @VisibleForTesting
    public void setCapabilityType(int type) {
        mCapabilityType = type;
+6 −0
Original line number Diff line number Diff line
@@ -445,6 +445,12 @@ public class PublishProcessor {
        return mProcessorState.isPublishingNow();
    }

    /**
     * Reset the retry count and time related publish.
     */
    public void resetState() {
        mProcessorState.resetState();
    }
    @VisibleForTesting
    public void setProcessorState(PublishProcessorState processorState) {
        mProcessorState = processorState;
+10 −0
Original line number Diff line number Diff line
@@ -348,6 +348,16 @@ public class PublishProcessorState {
        }
    }

    /**
     * Reset the retry count and related time when the publication status has
     * changed to not_published.
     */
    public void resetState() {
        synchronized (mLock) {
            mPublishThrottle.resetState();
        }
    }

    /*
     * Check if it has reached the maximum retry count.
     */
+3 −0
Original line number Diff line number Diff line
@@ -162,6 +162,8 @@ public class PublishControllerImplTest extends ImsTestBase {
    @SmallTest
    public void testUnpublish() throws Exception {
        PublishControllerImpl publishController = createPublishController();
        //To initialize the public state to publish_ok.
        publishController.setCapabilityType(RcsImsCapabilities.CAPABILITY_TYPE_OPTIONS_UCE);

        publishController.onUnpublish();

@@ -169,6 +171,7 @@ public class PublishControllerImplTest extends ImsTestBase {
        waitForHandlerAction(handler, 1000);
        int publishState = publishController.getUcePublishState();
        assertEquals(RcsUceAdapter.PUBLISH_STATE_NOT_PUBLISHED, publishState);
        verify(mPublishProcessor).resetState();
    }

    @Test