diff options
author | Amith Yamasani <yamasani@google.com> | 2015-05-29 15:35:26 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2015-06-02 11:05:03 -0700 |
commit | af575b9f8e1b59be9c8862b6a65c0dcb88145a23 (patch) | |
tree | c2bbc1b2a63b28a7de83b04d83010c56ee2771fc /services/usage | |
parent | 242b9c4eee9d42d02fd2259ffe2124234653aaf2 (diff) | |
download | frameworks_base-af575b9f8e1b59be9c8862b6a65c0dcb88145a23.zip frameworks_base-af575b9f8e1b59be9c8862b6a65c0dcb88145a23.tar.gz frameworks_base-af575b9f8e1b59be9c8862b6a65c0dcb88145a23.tar.bz2 |
Temporarily whitelist an app for network during doze
API to allow an app to be whitelisted for network and wakelock
access for a short period. So even if the device is in idle
mode, such apps can be given a chance to download the payload
related to a high priority cloud-to-device message.
This API is meant for system apps only.
A new permission CHANGE_DEVICE_IDLE_TEMP_WHITELIST is required
to make this call.
Bug: 21525864
Change-Id: Id7a761a664f21af5d7ff55aa56e8df98d15511ca
Diffstat (limited to 'services/usage')
-rw-r--r-- | services/usage/java/com/android/server/usage/UsageStatsService.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java index ff3bb28..23057c4 100644 --- a/services/usage/java/com/android/server/usage/UsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UsageStatsService.java @@ -90,23 +90,24 @@ public class UsageStatsService extends SystemService implements static final String TAG = "UsageStatsService"; - static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); + static final boolean DEBUG = false; + private static final boolean COMPRESS_TIME = false; private static final long TEN_SECONDS = 10 * 1000; private static final long ONE_MINUTE = 60 * 1000; private static final long TWENTY_MINUTES = 20 * 60 * 1000; - private static final long FLUSH_INTERVAL = DEBUG ? TEN_SECONDS : TWENTY_MINUTES; + private static final long FLUSH_INTERVAL = COMPRESS_TIME ? TEN_SECONDS : TWENTY_MINUTES; private static final long TIME_CHANGE_THRESHOLD_MILLIS = 2 * 1000; // Two seconds. - static final long DEFAULT_APP_IDLE_THRESHOLD_MILLIS = DEBUG ? ONE_MINUTE * 4 + static final long DEFAULT_APP_IDLE_THRESHOLD_MILLIS = COMPRESS_TIME ? ONE_MINUTE * 4 : 12 * 60 * ONE_MINUTE; // 12 hours of screen-on time sans dream-time - static final long DEFAULT_WALLCLOCK_APP_IDLE_THRESHOLD_MILLIS = DEBUG ? ONE_MINUTE * 8 + static final long DEFAULT_WALLCLOCK_APP_IDLE_THRESHOLD_MILLIS = COMPRESS_TIME ? ONE_MINUTE * 8 : 2L * 24 * 60 * ONE_MINUTE; // 2 days - static final long DEFAULT_CHECK_IDLE_INTERVAL = DEBUG ? ONE_MINUTE + static final long DEFAULT_CHECK_IDLE_INTERVAL = COMPRESS_TIME ? ONE_MINUTE : 8 * 60 * ONE_MINUTE; // 8 hours - static final long DEFAULT_PAROLE_INTERVAL = DEBUG ? ONE_MINUTE * 10 + static final long DEFAULT_PAROLE_INTERVAL = COMPRESS_TIME ? ONE_MINUTE * 10 : 24 * 60 * ONE_MINUTE; // 24 hours between paroles - static final long DEFAULT_PAROLE_DURATION = DEBUG ? ONE_MINUTE + static final long DEFAULT_PAROLE_DURATION = COMPRESS_TIME ? ONE_MINUTE : 10 * ONE_MINUTE; // 10 minutes // Handler message types. @@ -338,7 +339,6 @@ public class UsageStatsService extends SystemService implements /** Check all running users' apps to see if they enter an idle state. */ void checkIdleStates() { - if (DEBUG) Slog.d(TAG, "Checking idle state"); final int[] runningUsers; try { runningUsers = ActivityManagerNative.getDefault().getRunningUserIds(); @@ -994,6 +994,12 @@ public class UsageStatsService extends SystemService implements } @Override + public void whitelistAppTemporarily(String packageName, long duration, int userId) + throws RemoteException { + mDeviceIdleController.addPowerSaveTempWhitelistApp(packageName, duration, userId); + } + + @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) { |