Skip to content

Commit

Permalink
Settings: enable power save config of system apps
Browse files Browse the repository at this point in the history
Change-Id: I5b459295cc383fd4f60aeef55ad9020da5a9ebcc

Signed-off-by: xyyx <[email protected]>
  • Loading branch information
maxwen authored and Klozz committed Jul 22, 2017
1 parent a3b7a60 commit 30ff31f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1185,11 +1185,7 @@ public boolean areAllItemsEnabled() {

@Override
public boolean isEnabled(int position) {
if (mManageApplications.mListType != LIST_TYPE_HIGH_POWER) {
return true;
}
ApplicationsState.AppEntry entry = mEntries.get(position);
return !PowerWhitelistBackend.getInstance().isSysWhitelisted(entry.info.packageName);
return true;
}

public View getView(int position, View convertView, ViewGroup parent) {
Expand Down
10 changes: 2 additions & 8 deletions src/com/android/settings/fuelgauge/HighPowerDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ public Checkable setup(View view, boolean on) {
? R.string.ignore_optimizations_on_desc : R.string.ignore_optimizations_off_desc);
view.setClickable(true);
view.setOnClickListener(this);
if (!on && mBackend.isSysWhitelisted(mPackageName)) {
view.setEnabled(false);
}
return (Checkable) view;
}

Expand All @@ -82,9 +79,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
.setTitle(mLabel)
.setNegativeButton(R.string.cancel, null)
.setView(R.layout.ignore_optimizations_content);
if (!mBackend.isSysWhitelisted(mPackageName)) {
b.setPositiveButton(R.string.done, this);
}
b.setPositiveButton(R.string.done, this);
return b.create();
}

Expand Down Expand Up @@ -142,8 +137,7 @@ public static CharSequence getSummary(Context context, AppEntry entry) {

public static CharSequence getSummary(Context context, String pkg) {
PowerWhitelistBackend powerWhitelist = PowerWhitelistBackend.getInstance();
return context.getString(powerWhitelist.isSysWhitelisted(pkg) ? R.string.high_power_system
: powerWhitelist.isWhitelisted(pkg) ? R.string.high_power_on
return context.getString(powerWhitelist.isWhitelisted(pkg) ? R.string.high_power_on
: R.string.high_power_off);
}

Expand Down
14 changes: 11 additions & 3 deletions src/com/android/settings/fuelgauge/PowerWhitelistBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ public boolean isWhitelisted(String pkg) {

public void addApp(String pkg) {
try {
mDeviceIdleService.addPowerSaveWhitelistApp(pkg);
if (isSysWhitelisted(pkg)) {
mDeviceIdleService.addSystemPowerSaveWhitelistApp(pkg);
} else {
mDeviceIdleService.addPowerSaveWhitelistApp(pkg);
}
mWhitelistedApps.add(pkg);
} catch (RemoteException e) {
Log.w(TAG, "Unable to reach IDeviceIdleController", e);
Expand All @@ -66,7 +70,11 @@ public void addApp(String pkg) {

public void removeApp(String pkg) {
try {
mDeviceIdleService.removePowerSaveWhitelistApp(pkg);
if (isSysWhitelisted(pkg)) {
mDeviceIdleService.removeSystemPowerSaveWhitelistApp(pkg);
} else {
mDeviceIdleService.removePowerSaveWhitelistApp(pkg);
}
mWhitelistedApps.remove(pkg);
} catch (RemoteException e) {
Log.w(TAG, "Unable to reach IDeviceIdleController", e);
Expand All @@ -81,7 +89,7 @@ private void refreshList() {
for (String app : whitelistedApps) {
mWhitelistedApps.add(app);
}
String[] sysWhitelistedApps = mDeviceIdleService.getSystemPowerWhitelist();
String[] sysWhitelistedApps = mDeviceIdleService.getSystemPowerWhitelistOriginal();
for (String app : sysWhitelistedApps) {
mSysWhitelistedApps.add(app);
}
Expand Down

0 comments on commit 30ff31f

Please sign in to comment.