Fix mobile data on/off switch for multi-sim case

In multi-sim, the on/off switch for mobile data on the mobile network
details page doesn't quite work right. The thing it's missing is
checking whether the current sim is the default one used for data - if
it's not the default, then the switch should be off even if mobile data
is turned on. And clicking to enable needs to prompt the user to ask if
this sim should be become the new default one, which we already have
code for, but we weren't triggering it properly.

Bug: 124005813
Test: make RunSettingsRoboTests
Change-Id: Ifdf58addfde94b3bac85c68e4b22ddfbaf01dff7
This commit is contained in:
Antony Sargent
2019-02-06 13:55:08 -08:00
parent 12cec79889
commit 8af118bd87
2 changed files with 14 additions and 8 deletions

View File

@@ -118,7 +118,8 @@ public class MobileDataPreferenceController extends TogglePreferenceController
@Override
public boolean isChecked() {
return mTelephonyManager.isDataEnabled();
return mTelephonyManager.isDataEnabled()
&& mSubId == SubscriptionManager.getDefaultDataSubscriptionId();
}
public void init(FragmentManager fragmentManager, int subId) {
@@ -129,7 +130,7 @@ public class MobileDataPreferenceController extends TogglePreferenceController
@VisibleForTesting
boolean isDialogNeeded() {
final boolean enableData = !mTelephonyManager.isDataEnabled();
final boolean enableData = !isChecked();
final boolean isMultiSim = (mTelephonyManager.getSimCount() > 1);
final int defaultSubId = mSubscriptionManager.getDefaultDataSubscriptionId();
final boolean needToDisableOthers = mSubscriptionManager