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

Commit fbc26072 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Fix race in short FGS timeout

Bug: 257270313
Test: atest CtsShortFgsTestCases
Test: atest  CtsShortFgsTestCases:android.app.cts.shortfgstest.ActivityManagerShortFgsTest#testTimeout --rerun-until-failure 20
Change-Id: I7dfa3e5c4854eaa578e6a7899078b0d09feb40c3
parent 06a7fbc4
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2981,6 +2981,9 @@ public final class ActiveServices {
    void onShortFgsTimeout(ServiceRecord sr) {
        synchronized (mAm) {
            if (!sr.shouldTriggerShortFgsTimeout()) {
                if (DEBUG_SHORT_SERVICE) {
                    Slog.d(TAG_SERVICE, "[STALE] Short FGS timed out: " + sr);
                }
                return;
            }
            Slog.e(TAG_SERVICE, "Short FGS timed out: " + sr);
@@ -3021,6 +3024,9 @@ public final class ActiveServices {
            tr.mLatencyTracker.waitingOnAMSLockEnded();

            if (!sr.shouldTriggerShortFgsAnr()) {
                if (DEBUG_SHORT_SERVICE) {
                    Slog.d(TAG_SERVICE, "[STALE] Short FGS ANR'ed: " + sr);
                }
                return;
            }

+2 −2
Original line number Diff line number Diff line
@@ -1416,7 +1416,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
                || !mShortFgsInfo.isCurrent()) {
            return false;
        }
        return mShortFgsInfo.getTimeoutTime() < SystemClock.uptimeMillis();
        return mShortFgsInfo.getTimeoutTime() <= SystemClock.uptimeMillis();
    }

    /**
@@ -1431,7 +1431,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
                || !mShortFgsInfo.isCurrent()) {
            return false;
        }
        return mShortFgsInfo.getAnrTime() < SystemClock.uptimeMillis();
        return mShortFgsInfo.getAnrTime() <= SystemClock.uptimeMillis();
    }

    private boolean isAppAlive() {