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

Commit f33b5bff authored by Joe LaPenna's avatar Joe LaPenna
Browse files

Allow setting doze timeouts based on system feature

BUG: 25678232
Change-Id: Ic9c8e5001a9202242308effb38de879b5f30bd36
parent df4c40df
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -7698,6 +7698,16 @@ public final class Settings {
         */
        public static final String DEVICE_IDLE_CONSTANTS = "device_idle_constants";

        /**
         * Device Idle (Doze) specific settings for watches. See {@code #DEVICE_IDLE_CONSTANTS}
         *
         * <p>
         * Type: string
         * @hide
         * @see com.android.server.DeviceIdleController.Constants
         */
        public static final String DEVICE_IDLE_CONSTANTS_WATCH = "device_idle_constants_watch";

        /**
         * App standby (app idle) specific settings.
         * This is encoded as a key=value list, separated by commas. Ex:
+15 −3
Original line number Diff line number Diff line
@@ -684,13 +684,18 @@ public class DeviceIdleController extends SystemService
        public long SMS_TEMP_APP_WHITELIST_DURATION;

        private final ContentResolver mResolver;
        private final boolean mHasWatch;
        private final KeyValueListParser mParser = new KeyValueListParser(',');

        public Constants(Handler handler, ContentResolver resolver) {
            super(handler);
            mResolver = resolver;
            mResolver.registerContentObserver(
                    Settings.Global.getUriFor(Settings.Global.DEVICE_IDLE_CONSTANTS), false, this);
            mHasWatch = getContext().getPackageManager().hasSystemFeature(
                    PackageManager.FEATURE_WATCH);
            mResolver.registerContentObserver(Settings.Global.getUriFor(
                    mHasWatch ? Settings.Global.DEVICE_IDLE_CONSTANTS_WATCH
                              : Settings.Global.DEVICE_IDLE_CONSTANTS),
                    false, this);
            updateConstants();
        }

@@ -703,13 +708,20 @@ public class DeviceIdleController extends SystemService
            synchronized (DeviceIdleController.this) {
                try {
                    mParser.setString(Settings.Global.getString(mResolver,
                            Settings.Global.DEVICE_IDLE_CONSTANTS));
                            mHasWatch ? Settings.Global.DEVICE_IDLE_CONSTANTS_WATCH
                                      : Settings.Global.DEVICE_IDLE_CONSTANTS));
                } catch (IllegalArgumentException e) {
                    // Failed to parse the settings string, log this and move on
                    // with defaults.
                    Slog.e(TAG, "Bad device idle settings", e);
                }

                // For now, the default values for watches and non-watches are the same. After
                // investigation, we will likely decrease KEY_INACTIVE_TIMEOUT and other keys in the
                // style of:
                // long inactiveTimeoutDefault = (mHasWatch ? 15 : 30) * 60 * 1000L;
                // INACTIVE_TIMEOUT = mParser.getLong(KEY_INACTIVE_TIMEOUT,
                //         !COMPRESS_TIME ? inactiveTimeoutDefault : (inactiveTimeoutDefault / 10));
                LIGHT_IDLE_TIMEOUT = mParser.getLong(KEY_LIGHT_IDLE_TIMEOUT,
                        !COMPRESS_TIME ? 15 * 60 * 1000L : 60 * 1000L);
                LIGHT_IDLE_MAINTENANCE_MIN_BUDGET = mParser.getLong(