Loading apex/jobscheduler/service/java/com/android/server/usage/AppIdleHistory.java +9 −9 Original line number Diff line number Diff line Loading @@ -623,7 +623,8 @@ public class AppIdleHistory { * @param elapsedRealtime current time * @param screenTimeThresholds Array of screen times, in ascending order, first one is 0 * @param elapsedTimeThresholds Array of elapsed time, in ascending order, first one is 0 * @return The index whose values the app's used time exceeds (in both arrays) * @return The index whose values the app's used time exceeds (in both arrays) or {@code -1} to * indicate that the app has never been used. */ int getThresholdIndex(String packageName, int userId, long elapsedRealtime, long[] screenTimeThresholds, long[] elapsedTimeThresholds) { Loading @@ -631,14 +632,13 @@ public class AppIdleHistory { AppUsageHistory appUsageHistory = getPackageHistory(userHistory, packageName, elapsedRealtime, false); // If we don't have any state for the app, assume never used if (appUsageHistory == null) return screenTimeThresholds.length - 1; long screenOnDelta = appUsageHistory.lastUsedScreenTime >= 0 ? getScreenOnTime(elapsedRealtime) - appUsageHistory.lastUsedScreenTime : Long.MAX_VALUE; long elapsedDelta = appUsageHistory.lastUsedElapsedTime >= 0 ? getElapsedTime(elapsedRealtime) - appUsageHistory.lastUsedElapsedTime : Long.MAX_VALUE; if (appUsageHistory == null || appUsageHistory.lastUsedElapsedTime < 0 || appUsageHistory.lastUsedScreenTime < 0) { return -1; } long screenOnDelta = getScreenOnTime(elapsedRealtime) - appUsageHistory.lastUsedScreenTime; long elapsedDelta = getElapsedTime(elapsedRealtime) - appUsageHistory.lastUsedElapsedTime; if (DEBUG) Slog.d(TAG, packageName + " lastUsedScreen=" + appUsageHistory.lastUsedScreenTime Loading apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +4 −6 Original line number Diff line number Diff line Loading @@ -898,11 +898,9 @@ public class AppStandbyController } } final long elapsedLastUsedByUserTimeDelta = app.lastUsedByUserElapsedTime >= 0 ? elapsedTimeAdjusted - app.lastUsedByUserElapsedTime : Long.MAX_VALUE; if (app.lastRestrictAttemptElapsedTime > app.lastUsedByUserElapsedTime && elapsedLastUsedByUserTimeDelta if (app.lastUsedByUserElapsedTime >= 0 && app.lastRestrictAttemptElapsedTime > app.lastUsedByUserElapsedTime && elapsedTimeAdjusted - app.lastUsedByUserElapsedTime >= mInjector.getAutoRestrictedBucketDelayMs()) { newBucket = STANDBY_BUCKET_RESTRICTED; reason = app.lastRestrictReason; Loading Loading @@ -974,7 +972,7 @@ public class AppStandbyController long elapsedRealtime) { int bucketIndex = mAppIdleHistory.getThresholdIndex(packageName, userId, elapsedRealtime, mAppStandbyScreenThresholds, mAppStandbyElapsedThresholds); return THRESHOLD_BUCKETS[bucketIndex]; return bucketIndex >= 0 ? THRESHOLD_BUCKETS[bucketIndex] : STANDBY_BUCKET_NEVER; } private void notifyBatteryStats(String packageName, int userId, boolean idle) { Loading Loading
apex/jobscheduler/service/java/com/android/server/usage/AppIdleHistory.java +9 −9 Original line number Diff line number Diff line Loading @@ -623,7 +623,8 @@ public class AppIdleHistory { * @param elapsedRealtime current time * @param screenTimeThresholds Array of screen times, in ascending order, first one is 0 * @param elapsedTimeThresholds Array of elapsed time, in ascending order, first one is 0 * @return The index whose values the app's used time exceeds (in both arrays) * @return The index whose values the app's used time exceeds (in both arrays) or {@code -1} to * indicate that the app has never been used. */ int getThresholdIndex(String packageName, int userId, long elapsedRealtime, long[] screenTimeThresholds, long[] elapsedTimeThresholds) { Loading @@ -631,14 +632,13 @@ public class AppIdleHistory { AppUsageHistory appUsageHistory = getPackageHistory(userHistory, packageName, elapsedRealtime, false); // If we don't have any state for the app, assume never used if (appUsageHistory == null) return screenTimeThresholds.length - 1; long screenOnDelta = appUsageHistory.lastUsedScreenTime >= 0 ? getScreenOnTime(elapsedRealtime) - appUsageHistory.lastUsedScreenTime : Long.MAX_VALUE; long elapsedDelta = appUsageHistory.lastUsedElapsedTime >= 0 ? getElapsedTime(elapsedRealtime) - appUsageHistory.lastUsedElapsedTime : Long.MAX_VALUE; if (appUsageHistory == null || appUsageHistory.lastUsedElapsedTime < 0 || appUsageHistory.lastUsedScreenTime < 0) { return -1; } long screenOnDelta = getScreenOnTime(elapsedRealtime) - appUsageHistory.lastUsedScreenTime; long elapsedDelta = getElapsedTime(elapsedRealtime) - appUsageHistory.lastUsedElapsedTime; if (DEBUG) Slog.d(TAG, packageName + " lastUsedScreen=" + appUsageHistory.lastUsedScreenTime Loading
apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +4 −6 Original line number Diff line number Diff line Loading @@ -898,11 +898,9 @@ public class AppStandbyController } } final long elapsedLastUsedByUserTimeDelta = app.lastUsedByUserElapsedTime >= 0 ? elapsedTimeAdjusted - app.lastUsedByUserElapsedTime : Long.MAX_VALUE; if (app.lastRestrictAttemptElapsedTime > app.lastUsedByUserElapsedTime && elapsedLastUsedByUserTimeDelta if (app.lastUsedByUserElapsedTime >= 0 && app.lastRestrictAttemptElapsedTime > app.lastUsedByUserElapsedTime && elapsedTimeAdjusted - app.lastUsedByUserElapsedTime >= mInjector.getAutoRestrictedBucketDelayMs()) { newBucket = STANDBY_BUCKET_RESTRICTED; reason = app.lastRestrictReason; Loading Loading @@ -974,7 +972,7 @@ public class AppStandbyController long elapsedRealtime) { int bucketIndex = mAppIdleHistory.getThresholdIndex(packageName, userId, elapsedRealtime, mAppStandbyScreenThresholds, mAppStandbyElapsedThresholds); return THRESHOLD_BUCKETS[bucketIndex]; return bucketIndex >= 0 ? THRESHOLD_BUCKETS[bucketIndex] : STANDBY_BUCKET_NEVER; } private void notifyBatteryStats(String packageName, int userId, boolean idle) { Loading