Loading src/com/android/settings/network/telephony/MobileNetworkUtils.java +6 −3 Original line number Diff line number Diff line Loading @@ -358,7 +358,8 @@ public class MobileNetworkUtils { .createForSubscriptionId(subId); final SubscriptionManager subscriptionManager = context.getSystemService( SubscriptionManager.class).createForAllUserProfiles(); telephonyManager.setDataEnabled(enabled); telephonyManager.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, enabled); if (disableOtherSubscriptions) { final List<SubscriptionInfo> subInfoList = Loading @@ -367,8 +368,10 @@ public class MobileNetworkUtils { for (SubscriptionInfo subInfo : subInfoList) { // We never disable mobile data for opportunistic subscriptions. if (subInfo.getSubscriptionId() != subId && !subInfo.isOpportunistic()) { context.getSystemService(TelephonyManager.class).createForSubscriptionId( subInfo.getSubscriptionId()).setDataEnabled(false); context.getSystemService(TelephonyManager.class) .createForSubscriptionId(subInfo.getSubscriptionId()) .setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, false); } } } Loading tests/unit/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java +12 −6 Original line number Diff line number Diff line Loading @@ -148,24 +148,30 @@ public class MobileNetworkUtilsTest { public void setMobileDataEnabled_setEnabled_enabled() { MobileNetworkUtils.setMobileDataEnabled(mContext, SUB_ID_1, true, false); verify(mTelephonyManager).setDataEnabled(true); verify(mTelephonyManager2, never()).setDataEnabled(anyBoolean()); verify(mTelephonyManager) .setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true); verify(mTelephonyManager2, never()) .setDataEnabledForReason(anyInt(), anyBoolean()); } @Test public void setMobileDataEnabled_setDisabled_disabled() { MobileNetworkUtils.setMobileDataEnabled(mContext, SUB_ID_2, true, false); verify(mTelephonyManager2).setDataEnabled(true); verify(mTelephonyManager, never()).setDataEnabled(anyBoolean()); verify(mTelephonyManager2) .setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true); verify(mTelephonyManager, never()) .setDataEnabledForReason(anyInt(), anyBoolean()); } @Test public void setMobileDataEnabled_disableOtherSubscriptions() { MobileNetworkUtils.setMobileDataEnabled(mContext, SUB_ID_1, true, true); verify(mTelephonyManager).setDataEnabled(true); verify(mTelephonyManager2).setDataEnabled(false); verify(mTelephonyManager) .setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true); verify(mTelephonyManager2) .setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, false); } @Test Loading Loading
src/com/android/settings/network/telephony/MobileNetworkUtils.java +6 −3 Original line number Diff line number Diff line Loading @@ -358,7 +358,8 @@ public class MobileNetworkUtils { .createForSubscriptionId(subId); final SubscriptionManager subscriptionManager = context.getSystemService( SubscriptionManager.class).createForAllUserProfiles(); telephonyManager.setDataEnabled(enabled); telephonyManager.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, enabled); if (disableOtherSubscriptions) { final List<SubscriptionInfo> subInfoList = Loading @@ -367,8 +368,10 @@ public class MobileNetworkUtils { for (SubscriptionInfo subInfo : subInfoList) { // We never disable mobile data for opportunistic subscriptions. if (subInfo.getSubscriptionId() != subId && !subInfo.isOpportunistic()) { context.getSystemService(TelephonyManager.class).createForSubscriptionId( subInfo.getSubscriptionId()).setDataEnabled(false); context.getSystemService(TelephonyManager.class) .createForSubscriptionId(subInfo.getSubscriptionId()) .setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, false); } } } Loading
tests/unit/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java +12 −6 Original line number Diff line number Diff line Loading @@ -148,24 +148,30 @@ public class MobileNetworkUtilsTest { public void setMobileDataEnabled_setEnabled_enabled() { MobileNetworkUtils.setMobileDataEnabled(mContext, SUB_ID_1, true, false); verify(mTelephonyManager).setDataEnabled(true); verify(mTelephonyManager2, never()).setDataEnabled(anyBoolean()); verify(mTelephonyManager) .setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true); verify(mTelephonyManager2, never()) .setDataEnabledForReason(anyInt(), anyBoolean()); } @Test public void setMobileDataEnabled_setDisabled_disabled() { MobileNetworkUtils.setMobileDataEnabled(mContext, SUB_ID_2, true, false); verify(mTelephonyManager2).setDataEnabled(true); verify(mTelephonyManager, never()).setDataEnabled(anyBoolean()); verify(mTelephonyManager2) .setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true); verify(mTelephonyManager, never()) .setDataEnabledForReason(anyInt(), anyBoolean()); } @Test public void setMobileDataEnabled_disableOtherSubscriptions() { MobileNetworkUtils.setMobileDataEnabled(mContext, SUB_ID_1, true, true); verify(mTelephonyManager).setDataEnabled(true); verify(mTelephonyManager2).setDataEnabled(false); verify(mTelephonyManager) .setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true); verify(mTelephonyManager2) .setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, false); } @Test Loading