diff options
| author | 2017-02-23 12:36:03 -0800 | |
|---|---|---|
| committer | 2017-02-23 12:36:03 -0800 | |
| commit | 9acc4f40c8e31140c2034dc48b75d23dadf7e0c6 (patch) | |
| tree | 7893100aa17e28a6028b3d5f25912ac02bc6afcd /services/usage/java | |
| parent | 90f096f47508bf81f348f2181d80639747b6d90b (diff) | |
Add a debug flag to disable time correction.
This allows manual QA folks to change the datetime to test events
which depend on a large gap between uses of an app.
Currently, if the system detects a drift of more than 2 seconds,
it will automatically correct the usage stats. This means that manual
time changes will cause the usage stats to update to match, making it
impossible to test manually.
Bug: 34400961
Test: Manual
Change-Id: Iffb92c929872d841d22f089ec71922bf120cc544
Diffstat (limited to 'services/usage/java')
| -rw-r--r-- | services/usage/java/com/android/server/usage/UsageStatsService.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java index 3c743b5cb355..a68b5e8fdef5 100644 --- a/services/usage/java/com/android/server/usage/UsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UsageStatsService.java @@ -60,6 +60,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; +import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; @@ -96,6 +97,8 @@ public class UsageStatsService extends SystemService implements UserUsageStatsService.StatsUpdatedListener { static final String TAG = "UsageStatsService"; + public static final boolean ENABLE_TIME_CHANGE_CORRECTION + = SystemProperties.getBoolean("debug.time_change_correction", true); static final boolean DEBUG = false; // Never submit with true static final boolean COMPRESS_TIME = false; @@ -639,7 +642,8 @@ public class UsageStatsService extends SystemService implements final long actualRealtime = SystemClock.elapsedRealtime(); final long expectedSystemTime = (actualRealtime - mRealTimeSnapshot) + mSystemTimeSnapshot; final long diffSystemTime = actualSystemTime - expectedSystemTime; - if (Math.abs(diffSystemTime) > TIME_CHANGE_THRESHOLD_MILLIS) { + if (Math.abs(diffSystemTime) > TIME_CHANGE_THRESHOLD_MILLIS + && ENABLE_TIME_CHANGE_CORRECTION) { // The time has changed. Slog.i(TAG, "Time changed in UsageStats by " + (diffSystemTime / 1000) + " seconds"); final int userCount = mUserState.size(); |