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

Commit 1e1fff7a authored by Malcolm Chen's avatar Malcolm Chen
Browse files

Allow mobile data on for grouped primary subscriptions.

We have two rules now:

1) If multiple non-oppt subscriptions are active, disable mobile data
for those other than default data sub.
2) When mobile data setting changes in a subscription, the corresponding
value of other subscriptions in the same group are also changed.

So if there are two grouped primary subscriptions, we end up disabling
mobile data on both. Which is bad. So we are making the exception to
allow mobile data to be on both if they are grouped.

Bug: 132204817
Test: unittest
Change-Id: Ie01bcb948d2f63e694cf99f36a7cb2edb0fc0acb
Merged-In: Ie01bcb948d2f63e694cf99f36a7cb2edb0fc0acb
parent a36b35cf
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -484,7 +484,8 @@ public class MultiSimSettingController extends Handler {
            if (phone.getSubId() != defaultDataSub
                    && SubscriptionManager.isValidSubscriptionId(phone.getSubId())
                    && !mSubController.isOpportunistic(phone.getSubId())
                    && phone.isUserDataEnabled()) {
                    && phone.isUserDataEnabled()
                    && !areSubscriptionsInSameGroup(defaultDataSub, phone.getSubId())) {
                log("setting data to false on " + phone.getSubId());
                phone.getDataEnabledSettings().setUserDataEnabled(false);
            }
@@ -516,15 +517,6 @@ public class MultiSimSettingController extends Handler {
            int currentSubId = info.getSubscriptionId();
            // TODO: simplify when setUserDataEnabled becomes singleton
            if (mSubController.isActiveSubId(currentSubId)) {
                // If we end up enabling two active primary subscriptions, don't enable the
                // non-default data sub. This will only happen if two primary subscriptions
                // in a group are both active. This is not a valid use-case now, but we are
                // handling it just in case.
                if (enable && !mSubController.isOpportunistic(currentSubId)
                        && currentSubId != mSubController.getDefaultSubId()) {
                    loge("Can not enable two active primary subscriptions.");
                    continue;
                }
                // For active subscription, call setUserDataEnabled through DataEnabledSettings.
                Phone phone = PhoneFactory.getPhone(mSubController.getPhoneId(currentSubId));
                // If enable is true and it's not opportunistic subscription, we don't enable it,
+30 −0
Original line number Diff line number Diff line
@@ -486,4 +486,34 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        verify(mContext).sendBroadcast(intentCapture.capture());
        return intentCapture.getValue();
    }

    @Test
    @SmallTest
    public void testGroupedPrimarySubscriptions() throws Exception {
        doReturn(1).when(mSubControllerMock).getDefaultDataSubId();
        doReturn(true).when(mPhoneMock1).isUserDataEnabled();
        doReturn(false).when(mPhoneMock2).isUserDataEnabled();
        GlobalSettingsHelper.setBoolean(mContext, Settings.Global.MOBILE_DATA, 1, true);
        GlobalSettingsHelper.setBoolean(mContext, Settings.Global.DATA_ROAMING, 1, false);
        mMultiSimSettingControllerUT.notifyAllSubscriptionLoaded();
        waitABit();

        // Create subscription grouping.
        replaceInstance(SubscriptionInfo.class, "mGroupUUID", mSubInfo1, mGroupUuid1);
        doReturn(Arrays.asList(mSubInfo1, mSubInfo2)).when(mSubControllerMock)
                .getSubscriptionsInGroup(any(), anyString());
        mMultiSimSettingControllerUT.notifySubscriptionGroupChanged(mGroupUuid1);
        waitABit();
        // This should result in setting sync.
        verify(mDataEnabledSettingsMock2).setUserDataEnabled(true);
        assertFalse(GlobalSettingsHelper.getBoolean(
                mContext, Settings.Global.DATA_ROAMING, 2, true));
        verify(mSubControllerMock).setDataRoaming(/*enable*/0, /*subId*/1);

        // Turning off user data on sub 1.
        doReturn(false).when(mPhoneMock1).isUserDataEnabled();
        mMultiSimSettingControllerUT.notifyUserDataEnabled(1, false);
        waitABit();
        verify(mDataEnabledSettingsMock2).setUserDataEnabled(false);
    }
}