Merge "Allow setting doze timeouts based on system feature" into nyc-dev
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index d8937b4..b2e479a 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -7699,6 +7699,16 @@
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:
*
diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java
index b57e14e..fb4acf2 100644
--- a/services/core/java/com/android/server/DeviceIdleController.java
+++ b/services/core/java/com/android/server/DeviceIdleController.java
@@ -684,13 +684,18 @@
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 @@
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(