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

Commit 8f9d048e authored by Brad Ebinger's avatar Brad Ebinger
Browse files

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

When UNAVAILABLE_REASON_SERVER_UNAVAILABLE is returned in imsFeatureRemoved,
the connection to the telephony process itself is not available and
connect() will need to be retried. In this case, we do not want to
de-dupe the same state updates to connectionUnavailable, as this
will require the caller to retry using connect() again.

Fixes: 186288282
Test: atest ImsCommonTests
Change-Id: I5a683543ebc9e3ea2add6e311853cae827a448a6
parent 26b1e963
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 {