From 778d38a551e40ed9d3fe391c5b76bf00a0bf5825 Mon Sep 17 00:00:00 2001 From: Varun Shah Date: Mon, 26 Aug 2019 14:08:20 -0700 Subject: [PATCH] Don't allow Settings to change its own standby bucket. When on the "Standby apps" developer options screen, the Settings app will be greyed out, indicating that its standby bucket cannot be changed. Manual Test 1: Go to the "Standby apps" screen in developer options and observe that the Settings app is greyed out. Manual Test 2: Turn off "Adaptive Battery" in Settings and then go to the "Standby apps" screen in developer options - observe that the Settings app is greyed out. Bug: 132922935 Test: manual (listed above) Change-Id: Idb29e6105024feacc270867e46156fc6a0396b01 --- src/com/android/settings/fuelgauge/InactiveApps.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/com/android/settings/fuelgauge/InactiveApps.java b/src/com/android/settings/fuelgauge/InactiveApps.java index fdfcaabef9e..6c8a954d44a 100644 --- a/src/com/android/settings/fuelgauge/InactiveApps.java +++ b/src/com/android/settings/fuelgauge/InactiveApps.java @@ -31,6 +31,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.os.Bundle; +import android.text.TextUtils; import androidx.preference.ListPreference; import androidx.preference.Preference; @@ -82,6 +83,7 @@ public class InactiveApps extends SettingsPreferenceFragment final Context context = getActivity(); final PackageManager pm = context.getPackageManager(); final UsageStatsManager usm = context.getSystemService(UsageStatsManager.class); + final String settingsPackage = context.getPackageName(); Intent launcherIntent = new Intent(Intent.ACTION_MAIN); launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER); @@ -95,6 +97,10 @@ public class InactiveApps extends SettingsPreferenceFragment p.setEntries(SETTABLE_BUCKETS_NAMES); p.setEntryValues(SETTABLE_BUCKETS_VALUES); updateSummary(p); + // Don't allow Settings to change its own standby bucket. + if (TextUtils.equals(packageName, settingsPackage)) { + p.setEnabled(false); + } p.setOnPreferenceChangeListener(this); screen.addPreference(p);