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

Commit 25104d78 authored by Hui Yu's avatar Hui Yu Committed by Automerger Merge Worker
Browse files

BG-FGS while-in-use restriction uses the same grace period mechanism as...

BG-FGS while-in-use restriction uses the same grace period mechanism as BG-Activity-Launch. am: 28644e3b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13857624

Change-Id: Ie81a9bad37152aef941d072c12e45e4d16516927
parents 6d83bdfc 28644e3b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4891,6 +4891,10 @@ public final class ActiveServices {
                if (!pr.mAllowBackgroundActivityStartsTokens.isEmpty()) {
                    return true;
                }
                if (pr.getWindowProcessController()
                        .areBackgroundActivityStartsAllowedByGracePeriodSafe()) {
                    return true;
                }
            }
        }

+22 −8
Original line number Diff line number Diff line
@@ -455,15 +455,13 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
        mAllowBackgroundActivityStarts = allowBackgroundActivityStarts;
    }

    boolean areBackgroundActivityStartsAllowed() {
        // allow if the whitelisting flag was explicitly set
        if (mAllowBackgroundActivityStarts) {
            if (DEBUG_ACTIVITY_STARTS) {
                Slog.d(TAG, "[WindowProcessController(" + mPid
                        + ")] Activity start allowed: mAllowBackgroundActivityStarts = true");
    public boolean areBackgroundActivityStartsAllowedByGracePeriodSafe() {
        synchronized (mAtm.mGlobalLockWithoutBoost) {
            return areBackgroundActivityStartsAllowedByGracePeriod();
        }
            return true;
    }

    boolean areBackgroundActivityStartsAllowedByGracePeriod() {
        // allow if any activity in the caller has either started or finished very recently, and
        // it must be started or finished after last stop app switches time.
        final long now = SystemClock.uptimeMillis();
@@ -485,8 +483,24 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
                        + ACTIVITY_BG_START_GRACE_PERIOD_MS
                        + "ms grace period but also within stop app switch window");
            }
        }
        return false;
    }

    boolean areBackgroundActivityStartsAllowed() {
        // allow if the whitelisting flag was explicitly set
        if (mAllowBackgroundActivityStarts) {
            if (DEBUG_ACTIVITY_STARTS) {
                Slog.d(TAG, "[WindowProcessController(" + mPid
                        + ")] Activity start allowed: mAllowBackgroundActivityStarts = true");
            }
            return true;
        }

        if (areBackgroundActivityStartsAllowedByGracePeriod()) {
            return true;
        }

        // allow if the proc is instrumenting with background activity starts privs
        if (mInstrumentingWithBackgroundActivityStartPrivileges) {
            if (DEBUG_ACTIVITY_STARTS) {