Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fab8e716 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Make "am set-standby-bucket" reset active/working left time" into pi-dev

parents b2b69629 a0058b47
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -340,15 +340,27 @@ public class AppIdleHistory {

    public void setAppStandbyBucket(String packageName, int userId, long elapsedRealtime,
            int bucket, int reason) {
        setAppStandbyBucket(packageName, userId, elapsedRealtime, bucket, reason, false);
    }

    public void setAppStandbyBucket(String packageName, int userId, long elapsedRealtime,
            int bucket, int reason, boolean resetTimeout) {
        ArrayMap<String, AppUsageHistory> userHistory = getUserHistory(userId);
        AppUsageHistory appUsageHistory =
                getPackageHistory(userHistory, packageName, elapsedRealtime, true);
        appUsageHistory.currentBucket = bucket;
        appUsageHistory.bucketingReason = reason;

        final long elapsed = getElapsedTime(elapsedRealtime);

        if ((reason & REASON_MAIN_MASK) == REASON_MAIN_PREDICTED) {
            appUsageHistory.lastPredictedTime = getElapsedTime(elapsedRealtime);
            appUsageHistory.lastPredictedTime = elapsed;
            appUsageHistory.lastPredictedBucket = bucket;
        }
        if (resetTimeout) {
            appUsageHistory.bucketActiveTimeoutTime = elapsed;
            appUsageHistory.bucketWorkingSetTimeoutTime = elapsed;
        }
        if (DEBUG) {
            Slog.d(TAG, "Moved " + packageName + " to bucket=" + appUsageHistory.currentBucket
                    + ", reason=0x0" + Integer.toHexString(appUsageHistory.bucketingReason));
+9 −1
Original line number Diff line number Diff line
@@ -113,6 +113,9 @@ import java.util.concurrent.CountDownLatch;

/**
 * Manages the standby state of an app, listening to various events.
 *
 * Unit test:
   atest ${ANDROID_BUILD_TOP}/frameworks/base/services/tests/servicestests/src/com/android/server/usage/AppStandbyControllerTests.java
 */
public class AppStandbyController {

@@ -1106,6 +1109,11 @@ public class AppStandbyController {

    void setAppStandbyBucket(String packageName, int userId, @StandbyBuckets int newBucket,
            int reason, long elapsedRealtime) {
        setAppStandbyBucket(packageName, userId, newBucket, reason, elapsedRealtime, false);
    }

    void setAppStandbyBucket(String packageName, int userId, @StandbyBuckets int newBucket,
            int reason, long elapsedRealtime, boolean resetTimeout) {
        synchronized (mAppIdleLock) {
            AppIdleHistory.AppUsageHistory app = mAppIdleHistory.getAppUsageHistory(packageName,
                    userId, elapsedRealtime);
@@ -1155,7 +1163,7 @@ public class AppStandbyController {
            }

            mAppIdleHistory.setAppStandbyBucket(packageName, userId, elapsedRealtime, newBucket,
                    reason);
                    reason, resetTimeout);
        }
        maybeInformListeners(packageName, userId, elapsedRealtime, newBucket, reason, false);
    }
+3 −2
Original line number Diff line number Diff line
@@ -900,6 +900,7 @@ public class UsageStatsService extends SystemService implements
            } catch (RemoteException re) {
                throw re.rethrowFromSystemServer();
            }
            final boolean shellCaller = callingUid == 0 || callingUid == Process.SHELL_UID;
            final boolean systemCaller = UserHandle.isCore(callingUid);
            final int reason = systemCaller
                    ? UsageStatsManager.REASON_MAIN_FORCED
@@ -918,7 +919,7 @@ public class UsageStatsService extends SystemService implements
                                    + ")");
                }
                mAppStandby.setAppStandbyBucket(packageName, userId, bucket, reason,
                        SystemClock.elapsedRealtime());
                        SystemClock.elapsedRealtime(), shellCaller);
            } finally {
                Binder.restoreCallingIdentity(token);
            }
@@ -985,7 +986,7 @@ public class UsageStatsService extends SystemService implements
                        throw new IllegalArgumentException("Cannot set your own standby bucket");
                    }
                    mAppStandby.setAppStandbyBucket(packageName, userId, bucket, reason,
                            elapsedRealtime);
                            elapsedRealtime, shellCaller);
                }
            } finally {
                Binder.restoreCallingIdentity(token);