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

Commit 25582ecb authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by Gerrit Code Review
Browse files

Merge "Avoid send back and forth message."

parents f59e841c 4380918a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -694,7 +694,7 @@ public class MultiSimSettingController extends Handler {
                // If enable is true and it's not opportunistic subscription, we don't enable it,
                // as there can't e two
                if (phone != null) {
                    phone.getDataEnabledSettings().setUserDataEnabled(enable);
                    phone.getDataEnabledSettings().setUserDataEnabled(enable, false);
                }
            } else {
                // For inactive subscription, directly write into global settings.
+16 −2
Original line number Diff line number Diff line
@@ -203,6 +203,18 @@ public class DataEnabledSettings {
    }

    public synchronized void setUserDataEnabled(boolean enabled) {
        // By default the change should propagate to the group.
        setUserDataEnabled(enabled, true);
    }

    /**
     * @param notifyMultiSimSettingController if setUserDataEnabled is already from propagating
     *        from MultiSimSettingController, don't notify MultiSimSettingController again.
     *        For example, if sub1 and sub2 are in the same group and user enables data for sub
     *        1, sub 2 will also be enabled but with propagateToGroup = false.
     */
    public synchronized void setUserDataEnabled(boolean enabled,
            boolean notifyMultiSimSettingController) {
        // Can't disable data for stand alone opportunistic subscription.
        if (isStandAloneOpportunistic(mPhone.getSubId(), mPhone.getContext()) && !enabled) return;

@@ -212,8 +224,10 @@ public class DataEnabledSettings {
            localLog("UserDataEnabled", enabled);
            mPhone.notifyUserMobileDataStateChanged(enabled);
            updateDataEnabledAndNotify(REASON_USER_DATA_ENABLED);
            MultiSimSettingController.getInstance().notifyUserDataEnabled(mPhone.getSubId(),
                    enabled);
            if (notifyMultiSimSettingController) {
                MultiSimSettingController.getInstance().notifyUserDataEnabled(
                        mPhone.getSubId(), enabled);
            }
        }
    }

+4 −4
Original line number Diff line number Diff line
@@ -491,7 +491,7 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        mMultiSimSettingControllerUT.notifySubscriptionGroupChanged(mGroupUuid1);
        waitABit();
        // This should result in setting sync.
        verify(mDataEnabledSettingsMock1).setUserDataEnabled(false);
        verify(mDataEnabledSettingsMock1).setUserDataEnabled(false, false);
        assertFalse(GlobalSettingsHelper.getBoolean(
                mContext, Settings.Global.DATA_ROAMING, 1, true));

@@ -500,7 +500,7 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        // Turning data on on sub 2. Sub 1 should also be turned on.
        mMultiSimSettingControllerUT.notifyUserDataEnabled(2, true);
        waitABit();
        verify(mDataEnabledSettingsMock1).setUserDataEnabled(true);
        verify(mDataEnabledSettingsMock1).setUserDataEnabled(true, false);
        // No user selection needed, no intent should be sent.
        verify(mContext, never()).sendBroadcast(any());
    }
@@ -531,7 +531,7 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        mMultiSimSettingControllerUT.notifySubscriptionGroupChanged(mGroupUuid1);
        waitABit();
        // This should result in setting sync.
        verify(mDataEnabledSettingsMock2).setUserDataEnabled(true);
        verify(mDataEnabledSettingsMock2).setUserDataEnabled(true, false);
        assertFalse(GlobalSettingsHelper.getBoolean(
                mContext, Settings.Global.DATA_ROAMING, 2, true));
        verify(mSubControllerMock).setDataRoaming(/*enable*/0, /*subId*/1);
@@ -540,7 +540,7 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        doReturn(false).when(mPhoneMock1).isUserDataEnabled();
        mMultiSimSettingControllerUT.notifyUserDataEnabled(1, false);
        waitABit();
        verify(mDataEnabledSettingsMock2).setUserDataEnabled(false);
        verify(mDataEnabledSettingsMock2).setUserDataEnabled(false, false);
    }

    @Test