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

Commit f91fac20 authored by Michael Wachenschwanz's avatar Michael Wachenschwanz Committed by Android (Google) Code Review
Browse files

Merge changes I5e422dbf,I7ec22e4e into main

* changes:
  Remove FlakyTest annotations from most AppStandbyControllerTests
  Add a method to flush AppStandbyController's handler
parents 29b2d153 f39aa99b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -591,6 +591,16 @@ public class AppIdleHistory {
        if (idle) {
            newBucket = IDLE_BUCKET_CUTOFF;
            reason = REASON_MAIN_FORCED_BY_USER;
            final AppUsageHistory appHistory = getAppUsageHistory(packageName, userId,
                    elapsedRealtime);
            // Wipe all expiry times that could raise the bucket on reevaluation.
            if (appHistory.bucketExpiryTimesMs != null) {
                for (int i = appHistory.bucketExpiryTimesMs.size() - 1; i >= 0; --i) {
                    if (appHistory.bucketExpiryTimesMs.keyAt(i) < newBucket) {
                        appHistory.bucketExpiryTimesMs.removeAt(i);
                    }
                }
            }
        } else {
            newBucket = STANDBY_BUCKET_ACTIVE;
            // This is to pretend that the app was just used, don't freeze the state anymore.
+10 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import static com.android.server.SystemService.PHASE_SYSTEM_SERVICES_READY;
import static com.android.server.usage.AppIdleHistory.STANDBY_BUCKET_UNKNOWN;

import android.annotation.CurrentTimeMillisLong;
import android.annotation.DurationMillisLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
@@ -2146,6 +2147,15 @@ public class AppStandbyController
        }
    }

    /**
     * Flush the handler.
     * Returns true if successfully flushed within the timeout, otherwise return false.
     */
    @VisibleForTesting
    boolean flushHandler(@DurationMillisLong long timeoutMillis) {
        return mHandler.runWithScissors(() -> {}, timeoutMillis);
    }

    @Override
    public void flushToDisk() {
        synchronized (mAppIdleLock) {
+262 −244

File changed.

Preview size limit exceeded, changes collapsed.