Loading src/java/com/android/internal/telephony/MultiSimSettingController.java +1 −1 Original line number Diff line number Diff line Loading @@ -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. Loading src/java/com/android/internal/telephony/dataconnection/DataEnabledSettings.java +16 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); } } } Loading tests/telephonytests/src/com/android/internal/telephony/MultiSimSettingControllerTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -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)); Loading @@ -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()); } Loading Loading @@ -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); Loading @@ -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 Loading Loading
src/java/com/android/internal/telephony/MultiSimSettingController.java +1 −1 Original line number Diff line number Diff line Loading @@ -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. Loading
src/java/com/android/internal/telephony/dataconnection/DataEnabledSettings.java +16 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); } } } Loading
tests/telephonytests/src/com/android/internal/telephony/MultiSimSettingControllerTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -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)); Loading @@ -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()); } Loading Loading @@ -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); Loading @@ -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 Loading