Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7cca4cd authored by Wesley.CW Wang's avatar Wesley.CW Wang Committed by YUKAI HUNG
Browse files

Add PowerSaveWhitelistExceptIdle as Optimizted modes condition

 - Check PowerSaveWhitelistExceptIdle list before update each apps
 optimizaton mode to avoid duplicate remove action
 - Make those apps which under PowerSaveWhitelistExceptIdle list keep at
 optimized mode only

BYPASS_INCLUSIVE_LANGUAGE_REASON=legacy naming, not edit by this code change


Bug: 199892006
Test: make SettingsRoboTests
Change-Id: I3cd10cf51b5132fc12a83e9554801ec4e8578cd1
Merged-In: I3cd10cf51b5132fc12a83e9554801ec4e8578cd1
parent e5644441
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ package com.android.settings.fuelgauge;
import android.annotation.UserIdInt;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.settings.SettingsEnums;
import android.app.backup.BackupManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -361,8 +361,10 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
        final String stateString;
        final String footerString;

        if (!mBatteryOptimizeUtils.isValidPackageName()) {
            //Present optimized only string when the package name is invalid.
        if (!mBatteryOptimizeUtils.isValidPackageName()
                || mBatteryOptimizeUtils.isAllowlistedExceptIdleApp()) {
            // Present optimized only string when the package name is invalid or
            // it's in allow list not idle app.
            stateString = context.getString(R.string.manager_battery_usage_optimized_only);
            footerString = context.getString(
                    R.string.manager_battery_usage_footer_limited, stateString);
+7 −0
Original line number Diff line number Diff line
@@ -130,6 +130,13 @@ public class BatteryOptimizeUtils {
                || mPowerAllowListBackend.isDefaultActiveApp(mPackageName);
    }

    /**
     * Return {@code true} if this package is in allow list except idle app.
     */
    public boolean isAllowlistedExceptIdleApp() {
        return mPowerAllowListBackend.isAllowlistedExceptIdle(mPackageName);
    }

    String getPackageName() {
        return mPackageName == null ? UNKNOWN_PACKAGE : mPackageName;
    }
+4 −0
Original line number Diff line number Diff line
@@ -57,6 +57,10 @@ public class OptimizedPreferenceController extends AbstractPreferenceController
            Log.d(TAG, "is system or default app, disable pref");
            ((RadioButtonPreference) preference).setChecked(false);
            preference.setEnabled(false);
        } else if (mBatteryOptimizeUtils.isAllowlistedExceptIdleApp()) {
            Log.d(TAG, "in allow list not idle app, optimized states only");
            preference.setEnabled(true);
            ((RadioButtonPreference) preference).setChecked(true);
        } else if (mBatteryOptimizeUtils.getAppOptimizationMode()
                == BatteryOptimizeUtils.MODE_OPTIMIZED) {
            Log.d(TAG, "is optimized states");
+3 −0
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ public class RestrictedPreferenceController extends AbstractPreferenceController
            Log.d(TAG, "is system or default app, disable pref");
            ((RadioButtonPreference) preference).setChecked(false);
            preference.setEnabled(false);
        } else if (mBatteryOptimizeUtils.isAllowlistedExceptIdleApp()) {
            Log.d(TAG, "in allow list not idle app, disable perf");
            preference.setEnabled(false);
        } else if (mBatteryOptimizeUtils.getAppOptimizationMode()
                == BatteryOptimizeUtils.MODE_RESTRICTED) {
            Log.d(TAG, "is restricted states");
+3 −0
Original line number Diff line number Diff line
@@ -53,6 +53,9 @@ public class UnrestrictedPreferenceController extends AbstractPreferenceControll
        if (mBatteryOptimizeUtils.isSystemOrDefaultApp()) {
            Log.d(TAG, "is system or default app, unrestricted states only");
            ((RadioButtonPreference) preference).setChecked(true);
        } else if (mBatteryOptimizeUtils.isAllowlistedExceptIdleApp()) {
            Log.d(TAG, "in allow list not idle app, disable perf");
            preference.setEnabled(false);
        } else if (mBatteryOptimizeUtils.getAppOptimizationMode()
                == BatteryOptimizeUtils.MODE_UNRESTRICTED) {
            Log.d(TAG, "is unrestricted states");
Loading