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
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user