Set setting back to default when turning off dev option

When turning off developer options, mobile data always on setting should
be set back to default, which is ON not OFF.

Change-Id: I257ba108976b05162fa3cea6e48f3490e9c64f80
Fixes: 119719605
Test: robotests
This commit is contained in:
Fan Zhang
2018-12-12 13:40:22 -08:00
parent 6718986bb9
commit 07933cb967
2 changed files with 5 additions and 5 deletions

View File

@@ -66,7 +66,7 @@ public class MobileDataAlwaysOnPreferenceController extends
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled(); super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON, Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON,
SETTING_VALUE_OFF); SETTING_VALUE_ON);
((SwitchPreference) mPreference).setChecked(false); ((SwitchPreference) mPreference).setChecked(true);
} }
} }

View File

@@ -96,13 +96,13 @@ public class MobileDataAlwaysOnPreferenceControllerTest {
} }
@Test @Test
public void onDeveloperOptionsSwitchDisabled_preferenceShouldBeDisabled() { public void onDeveloperOptionsSwitchDisabled_shouldDisableMobileDataAlwaysOn() {
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();
final int mode = Settings.Global.getInt(mContext.getContentResolver(), final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.MOBILE_DATA_ALWAYS_ON, -1 /* default */); Settings.Global.MOBILE_DATA_ALWAYS_ON, -1 /* default */);
assertThat(mode).isEqualTo(MobileDataAlwaysOnPreferenceController.SETTING_VALUE_OFF); assertThat(mode).isEqualTo(MobileDataAlwaysOnPreferenceController.SETTING_VALUE_ON);
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(true);
} }
} }