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

Commit be48465e authored by James.cf Lin's avatar James.cf Lin Committed by Automerger Merge Worker
Browse files

Fix PUBLISH gets stuck when toggle VT capabilities am: fb403b00 am: de01cbf3 am: 25287cc9

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I653c3b047920d9946d9c0f332f97398dc1822d85
parents fb1f7ce7 25287cc9
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -440,12 +440,20 @@ public class PublishControllerImpl implements PublishController {
                return;
            }

            // Don't send duplicated publish request because it always publish the latest device
            // capabilities.
            // If the trigger type is not RETRY, it means that the device capabilities have been
            // changed. To make sure that the publish request can be processed immediately, remove
            // the existing one and send a new publish request without delayed.
            if (type != PublishController.PUBLISH_TRIGGER_RETRY) {
                removeMessages(MSG_REQUEST_PUBLISH);
            } else {
                // Skip this request if the trigger type is RETRY and there's alreay a publish
                // request in the queue.
                if (hasMessages(MSG_REQUEST_PUBLISH)) {
                publishCtrl.logd("requestPublish: Skip. there is already a request in the queue");
                    publishCtrl.logd(
                            "requestPublish: Skip. There's already a request in the queue");
                    return;
                }
            }

            Message message = obtainMessage();
            message.what = MSG_REQUEST_PUBLISH;
@@ -587,6 +595,11 @@ public class PublishControllerImpl implements PublishController {
        return mRcsCapabilitiesCallback;
    }

    @VisibleForTesting
    public PublishControllerCallback getPublishControllerCallback() {
        return mPublishControllerCallback;
    }

    private void logd(String log) {
        Log.d(LOG_TAG, getLogPrefix().append(log).toString());
    }
+26 −0
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@

package com.android.ims.rcs.uce.presence.publish;

import static com.android.ims.rcs.uce.presence.publish.PublishController.PUBLISH_TRIGGER_RETRY;
import static com.android.ims.rcs.uce.presence.publish.PublishController.PUBLISH_TRIGGER_VT_SETTING_CHANGE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -36,6 +39,7 @@ import androidx.test.filters.SmallTest;

import com.android.ims.RcsFeatureManager;
import com.android.ims.rcs.uce.UceController;
import com.android.ims.rcs.uce.presence.publish.PublishController.PublishControllerCallback;
import com.android.ims.rcs.uce.presence.publish.PublishControllerImpl.DeviceCapListenerFactory;
import com.android.ims.rcs.uce.presence.publish.PublishControllerImpl.PublishProcessorFactory;
import com.android.ims.ImsTestBase;
@@ -168,6 +172,28 @@ public class PublishControllerImplTest extends ImsTestBase {
        verify(mPublishProcessor).checkAndSendPendingRequest();
    }

    @Test
    @SmallTest
    public void testRequestPublishWhenDeviceCapabilitiesChange() throws Exception {
        PublishControllerImpl publishController = createPublishController();

        // Set the PRESENCE is capable
        IImsCapabilityCallback RcsCapCallback = publishController.getRcsCapabilitiesCallback();
        RcsCapCallback.onCapabilitiesStatusChanged(RcsUceAdapter.CAPABILITY_TYPE_PRESENCE_UCE);

        // Trigger the first publish (RETRY)
        PublishControllerCallback callback = publishController.getPublishControllerCallback();
        callback.requestPublishFromInternal(PUBLISH_TRIGGER_RETRY, 60000);

        // Trigger another publish request (VT changes)
        callback.requestPublishFromInternal(PUBLISH_TRIGGER_VT_SETTING_CHANGE, 0);
        Handler handler = publishController.getPublishHandler();
        waitForHandlerAction(handler, 1000);

        // Verify the publish request can be processed immediately
        verify(mPublishProcessor).doPublish(PUBLISH_TRIGGER_VT_SETTING_CHANGE);
    }

    private PublishControllerImpl createPublishController() {
        PublishControllerImpl publishController = new PublishControllerImpl(mContext, mSubId,
                mUceCtrlCallback, Looper.getMainLooper(), mDeviceCapListenerFactory,