diff --git a/res/values/strings.xml b/res/values/strings.xml index 825a818fa82..6897c656dea 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12066,4 +12066,7 @@ When using 2 SIMs, this device will be limited to 4G. Learn more. + + + Suspend execution for cached apps diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml index b781636ff7f..d1473e5da63 100644 --- a/res/xml/development_settings.xml +++ b/res/xml/development_settings.xml @@ -584,6 +584,12 @@ android:title="@string/show_all_anrs" android:summary="@string/show_all_anrs_summary" /> + + { + Settings.Global.putString(mContext.getContentResolver(), + Settings.Global.CACHED_APPS_FREEZER_ENABLED, + newValue.toString()); + + updateState(mPreference); + + PowerManager pm = mContext.getSystemService(PowerManager.class); + pm.reboot(null); + }; + } + + private DialogInterface.OnClickListener getRebootDialogCancelListener() { + return (dialog, which) -> { + updateState(mPreference); + }; + } + + @Override + public void updateState(Preference preference) { + final ListPreference listPreference = (ListPreference) preference; + final String currentValue = Settings.Global.getString(mContext.getContentResolver(), + Settings.Global.CACHED_APPS_FREEZER_ENABLED); + + int index = 0; // Defaults to device default + for (int i = 0; i < mListValues.length; i++) { + if (TextUtils.equals(currentValue, mListValues[i])) { + index = i; + break; + } + } + + listPreference.setValue(mListValues[index]); + listPreference.setSummary(mListSummaries[index]); + } + + @Override + public void onDeveloperOptionsDisabled() { + super.onDeveloperOptionsDisabled(); + + Settings.Global.putString(mContext.getContentResolver(), + Settings.Global.CACHED_APPS_FREEZER_ENABLED, + mListValues[0].toString()); + } +} diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java index 4df641efa65..649256098da 100644 --- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java @@ -505,6 +505,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra controllers.add(new ProfileGpuRenderingPreferenceController(context)); controllers.add(new KeepActivitiesPreferenceController(context)); controllers.add(new BackgroundProcessLimitPreferenceController(context)); + controllers.add(new CachedAppsFreezerPreferenceController(context)); controllers.add(new ShowFirstCrashDialogPreferenceController(context)); controllers.add(new AppsNotRespondingPreferenceController(context)); controllers.add(new NotificationChannelWarningsPreferenceController(context));