diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-01-13 12:26:07 -0800 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2016-03-01 13:19:14 -0800 |
commit | 5b23737021d756e079230f68cda8920a505c27a1 (patch) | |
tree | 2cc51ceb4a8a42b4513192aee3d8d070f2f4689c | |
parent | f396a9504880785c95daa5b4d7387a64405d6dfd (diff) | |
download | base-5b23737021d756e079230f68cda8920a505c27a1.tar.gz |
DO NOT MERGE ANYWHERE: UsageStats: Use new settings key idle_duration2 for app idle
Ignores the old, re-appropriated key "idle_duration" which is now
set to a high value in order to force disable app idle on devices
with bug b/26355386
Bug:26355386
Change-Id: Iff9de843ad6e547d29c1583687fc7f7ce7e15090
(cherry picked from commit 1559fed4c47a4bd219e61f7d34e50d46b8929f8a)
3 files changed, 20 insertions, 4 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 23f8cfc46916..14f8fdd270dc 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -7286,10 +7286,12 @@ public final class Settings { * The following keys are supported: * * <pre> - * idle_duration (long) + * idle_duration2 (long) * wallclock_threshold (long) * parole_interval (long) * parole_duration (long) + * + * idle_duration (long) // This is deprecated and used to circumvent b/26355386. * </pre> * * <p> diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java index b042d7bb1b69..6a0056afe60a 100644 --- a/services/usage/java/com/android/server/usage/UsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UsageStatsService.java @@ -280,6 +280,11 @@ public class UsageStatsService extends SystemService implements mHandler.sendEmptyMessageDelayed(MSG_FLUSH_TO_DISK, FLUSH_INTERVAL); } + @Override + public long getAppIdleRollingWindowDurationMillis() { + return mAppIdleWallclockThresholdMillis * 2; + } + private void cleanUpRemovedUsersLocked() { final List<UserInfo> users = mUserManager.getUsers(true); if (users == null || users.size() == 0) { @@ -1108,7 +1113,13 @@ public class UsageStatsService extends SystemService implements * Observe settings changes for {@link Settings.Global#APP_IDLE_CONSTANTS}. */ private class SettingsObserver extends ContentObserver { - private static final String KEY_IDLE_DURATION = "idle_duration"; + /** + * This flag has been used to disable app idle on older builds with bug b/26355386. + */ + @Deprecated + private static final String KEY_IDLE_DURATION_OLD = "idle_duration"; + + private static final String KEY_IDLE_DURATION = "idle_duration2"; private static final String KEY_WALLCLOCK_THRESHOLD = "wallclock_threshold"; private static final String KEY_PAROLE_INTERVAL = "parole_interval"; private static final String KEY_PAROLE_DURATION = "parole_duration"; diff --git a/services/usage/java/com/android/server/usage/UserUsageStatsService.java b/services/usage/java/com/android/server/usage/UserUsageStatsService.java index addb1a1737d4..25cc13c34050 100644 --- a/services/usage/java/com/android/server/usage/UserUsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UserUsageStatsService.java @@ -68,6 +68,7 @@ class UserUsageStatsService { interface StatsUpdatedListener { void onStatsUpdated(); + long getAppIdleRollingWindowDurationMillis(); } UserUsageStatsService(Context context, int userId, File usageStatsDir, @@ -581,9 +582,11 @@ class UserUsageStatsService { */ void refreshAppIdleRollingWindow(final long currentTimeMillis, final long deviceUsageTime) { // Start the rolling window for AppIdle requests. + final long startRangeMillis = currentTimeMillis - + mListener.getAppIdleRollingWindowDurationMillis(); + List<IntervalStats> stats = mDatabase.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, - currentTimeMillis - (1000 * 60 * 60 * 24 * 2), currentTimeMillis, - new StatCombiner<IntervalStats>() { + startRangeMillis, currentTimeMillis, new StatCombiner<IntervalStats>() { @Override public void combine(IntervalStats stats, boolean mutable, List<IntervalStats> accumulatedResult) { |