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

Commit 4620d9b3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add ADAPTIVE_BATTERY_MANAGEMENT_ENABLED" into pi-dev

parents 630f58ea 4b976ad2
Loading
Loading
Loading
Loading
+15 −2
Original line number Original line Diff line number Diff line
@@ -10796,14 +10796,27 @@ public final class Settings {
        public static final String SYNC_MANAGER_CONSTANTS = "sync_manager_constants";
        public static final String SYNC_MANAGER_CONSTANTS = "sync_manager_constants";
        /**
        /**
         * Whether or not App Standby feature is enabled. This controls throttling of apps
         * Whether or not App Standby feature is enabled by system. This controls throttling of apps
         * based on usage patterns and predictions.
         * based on usage patterns and predictions. Platform will turn on this feature if both this
         * flag and {@link #ADAPTIVE_BATTERY_MANAGEMENT_ENABLED} is on.
         * Type: int (0 for false, 1 for true)
         * Type: int (0 for false, 1 for true)
         * Default: 1
         * Default: 1
         * @hide
         * @hide
         * @see #ADAPTIVE_BATTERY_MANAGEMENT_ENABLED
         */
         */
        public static final String APP_STANDBY_ENABLED = "app_standby_enabled";
        public static final String APP_STANDBY_ENABLED = "app_standby_enabled";
        /**
         * Whether or not adaptive battery feature is enabled by user. Platform will turn on this
         * feature if both this flag and {@link #APP_STANDBY_ENABLED} is on.
         * Type: int (0 for false, 1 for true)
         * Default: 1
         * @hide
         * @see #APP_STANDBY_ENABLED
         */
        public static final String ADAPTIVE_BATTERY_MANAGEMENT_ENABLED =
                "adaptive_battery_management_enabled";
        /**
        /**
         * Whether or not app auto restriction is enabled. When it is enabled, settings app will
         * Whether or not app auto restriction is enabled. When it is enabled, settings app will
         * auto restrict the app if it has bad behavior(e.g. hold wakelock for long time).
         * auto restrict the app if it has bad behavior(e.g. hold wakelock for long time).
+1 −0
Original line number Original line Diff line number Diff line
@@ -98,6 +98,7 @@ public class SettingsBackupTest {
    private static final Set<String> BACKUP_BLACKLISTED_GLOBAL_SETTINGS =
    private static final Set<String> BACKUP_BLACKLISTED_GLOBAL_SETTINGS =
            newHashSet(
            newHashSet(
                    Settings.Global.ACTIVITY_MANAGER_CONSTANTS,
                    Settings.Global.ACTIVITY_MANAGER_CONSTANTS,
                    Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED,
                    Settings.Global.ADB_ENABLED,
                    Settings.Global.ADB_ENABLED,
                    Settings.Global.ADD_USERS_WHEN_LOCKED,
                    Settings.Global.ADD_USERS_WHEN_LOCKED,
                    Settings.Global.AIRPLANE_MODE_ON,
                    Settings.Global.AIRPLANE_MODE_ON,
+20 −14
Original line number Original line Diff line number Diff line
@@ -81,7 +81,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.util.ArraySet;
import android.util.ArraySet;
import android.util.KeyValueListParser;
import android.util.KeyValueListParser;
@@ -1439,8 +1439,10 @@ public class AppStandbyController {
        boolean isAppIdleEnabled() {
        boolean isAppIdleEnabled() {
            final boolean buildFlag = mContext.getResources().getBoolean(
            final boolean buildFlag = mContext.getResources().getBoolean(
                    com.android.internal.R.bool.config_enableAutoPowerModes);
                    com.android.internal.R.bool.config_enableAutoPowerModes);
            final boolean runtimeFlag = Settings.Global.getInt(mContext.getContentResolver(),
            final boolean runtimeFlag = Global.getInt(mContext.getContentResolver(),
                    Settings.Global.APP_STANDBY_ENABLED, 1) == 1;
                    Global.APP_STANDBY_ENABLED, 1) == 1
                    && Global.getInt(mContext.getContentResolver(),
                    Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, 1) == 1;
            return buildFlag && runtimeFlag;
            return buildFlag && runtimeFlag;
        }
        }


@@ -1489,8 +1491,8 @@ public class AppStandbyController {
        }
        }


        String getAppIdleSettings() {
        String getAppIdleSettings() {
            return Settings.Global.getString(mContext.getContentResolver(),
            return Global.getString(mContext.getContentResolver(),
                    Settings.Global.APP_IDLE_CONSTANTS);
                    Global.APP_IDLE_CONSTANTS);
        }
        }
    }
    }


@@ -1610,7 +1612,7 @@ public class AppStandbyController {
    };
    };


    /**
    /**
     * Observe settings changes for {@link Settings.Global#APP_IDLE_CONSTANTS}.
     * Observe settings changes for {@link Global#APP_IDLE_CONSTANTS}.
     */
     */
    private class SettingsObserver extends ContentObserver {
    private class SettingsObserver extends ContentObserver {
        /**
        /**
@@ -1650,10 +1652,11 @@ public class AppStandbyController {
        }
        }


        void registerObserver() {
        void registerObserver() {
            mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(
            final ContentResolver cr = mContext.getContentResolver();
                    Settings.Global.APP_IDLE_CONSTANTS), false, this);
            cr.registerContentObserver(Global.getUriFor(Global.APP_IDLE_CONSTANTS), false, this);
            mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(
            cr.registerContentObserver(Global.getUriFor(Global.APP_STANDBY_ENABLED), false, this);
                    Settings.Global.APP_STANDBY_ENABLED), false, this);
            cr.registerContentObserver(Global.getUriFor(Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED),
                    false, this);
        }
        }


        @Override
        @Override
@@ -1665,11 +1668,14 @@ public class AppStandbyController {
        void updateSettings() {
        void updateSettings() {
            if (DEBUG) {
            if (DEBUG) {
                Slog.d(TAG,
                Slog.d(TAG,
                        "appidle=" + Settings.Global.getString(mContext.getContentResolver(),
                        "appidle=" + Global.getString(mContext.getContentResolver(),
                                Settings.Global.APP_STANDBY_ENABLED));
                                Global.APP_STANDBY_ENABLED));
                Slog.d(TAG, "appidleconstants=" + Settings.Global.getString(
                Slog.d(TAG,
                        "adaptivebat=" + Global.getString(mContext.getContentResolver(),
                                Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED));
                Slog.d(TAG, "appidleconstants=" + Global.getString(
                        mContext.getContentResolver(),
                        mContext.getContentResolver(),
                        Settings.Global.APP_IDLE_CONSTANTS));
                        Global.APP_IDLE_CONSTANTS));
            }
            }
            // Check if app_idle_enabled has changed
            // Check if app_idle_enabled has changed
            setAppIdleEnabled(mInjector.isAppIdleEnabled());
            setAppIdleEnabled(mInjector.isAppIdleEnabled());