diff --git a/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java b/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java index 8a61c75286a..d26517a0283 100644 --- a/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java +++ b/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java @@ -62,7 +62,7 @@ public class AllowBackgroundActivityStartsPreferenceController @Override protected void onDeveloperOptionsSwitchDisabled() { super.onDeveloperOptionsSwitchDisabled(); - writeSetting(false); - ((SwitchPreference) mPreference).setChecked(false); + writeSetting(true); + ((SwitchPreference) mPreference).setChecked(true); } } diff --git a/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java index 41a3b60b437..8e95aa109c6 100644 --- a/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java @@ -24,6 +24,9 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.provider.Settings; +import androidx.preference.PreferenceScreen; +import androidx.preference.SwitchPreference; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,9 +35,6 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; -import androidx.preference.PreferenceScreen; -import androidx.preference.SwitchPreference; - @RunWith(RobolectricTestRunner.class) public class AllowBackgroundActivityStartsPreferenceControllerTest { @@ -52,7 +52,7 @@ public class AllowBackgroundActivityStartsPreferenceControllerTest { mContext = RuntimeEnvironment.application; mController = new AllowBackgroundActivityStartsPreferenceController(mContext); when(mPreferenceScreen.findPreference(mController.getPreferenceKey())) - .thenReturn(mPreference); + .thenReturn(mPreference); mController.displayPreference(mPreferenceScreen); } @@ -98,11 +98,7 @@ public class AllowBackgroundActivityStartsPreferenceControllerTest { public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() { mController.onDeveloperOptionsSwitchDisabled(); - final int mode = Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, 1 /* default */); - - assertThat(mode).isEqualTo(0); - verify(mPreference).setChecked(false); + verify(mPreference).setChecked(true); verify(mPreference).setEnabled(false); } }