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

Commit 50ce7684 authored by Brad Ebinger's avatar Brad Ebinger Committed by Automerger Merge Worker
Browse files

Do not de-dupe feature removed requests when the server is unavailable am:...

Do not de-dupe feature removed requests when the server is unavailable am: 8f9d048e am: 659b23ec

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

Change-Id: I412d508adf021554de9712bca2e0dfb76151f030
parents 9eb74c39 659b23ec
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -130,8 +130,12 @@ public class FeatureConnector<U extends FeatureUpdates> {
        public void imsFeatureRemoved(@UnavailableReason int reason) {
            log("imsFeatureRemoved: reason=" + reason);
            synchronized (mLock) {
                // only generate new events if the disconnect event isn't the same as before.
                if (mDisconnectedReason != null && mDisconnectedReason.equals(reason)) {
                // only generate new events if the disconnect event isn't the same as before, except
                // for UNAVAILABLE_REASON_SERVER_UNAVAILABLE, which indicates a local issue and
                // each event is actionable.
                if (mDisconnectedReason != null
                        && (mDisconnectedReason == reason
                        && mDisconnectedReason != UNAVAILABLE_REASON_SERVER_UNAVAILABLE)) {
                    log("imsFeatureRemoved: ignore");
                    return;
                }
+28 −0
Original line number Diff line number Diff line
@@ -263,6 +263,34 @@ public class FeatureConnectorTest extends ImsTestBase {
        verify(mListener, never()).connectionUnavailable(anyInt());
    }

    @Test
    @SmallTest
    public void testCantConnectToServer() throws Exception {
        ArrayList<Integer> filterList = new ArrayList<>();
        filterList.add(ImsFeature.STATE_READY);
        filterList.add(ImsFeature.STATE_INITIALIZING);
        filterList.add(ImsFeature.STATE_UNAVAILABLE);
        createFeatureConnector(filterList);

        mFeatureConnector.connect();
        mTestManager.callback.imsFeatureRemoved(
                FeatureConnector.UNAVAILABLE_REASON_SERVER_UNAVAILABLE);
        verify(mListener).connectionUnavailable(
                FeatureConnector.UNAVAILABLE_REASON_SERVER_UNAVAILABLE);

        // Clear callback and ensure that the second connect tries to register a callback.
        mTestManager.registerFeatureCallback(PHONE_ID, null);
        mFeatureConnector.connect();
        assertNotNull("The register request should happen the second time as well.",
                mTestManager.callback);
        mTestManager.callback.imsFeatureRemoved(
                FeatureConnector.UNAVAILABLE_REASON_SERVER_UNAVAILABLE);
        // In the special case that UNAVAILABLE_REASON_SERVER_UNAVAILABLE is returned, we should get
        // an unavailable callback every time because it will require connect to be called again.
        verify(mListener,times(2)).connectionUnavailable(
                FeatureConnector.UNAVAILABLE_REASON_SERVER_UNAVAILABLE);
    }

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