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

Commit df33ae1b authored by Kweku Adams's avatar Kweku Adams
Browse files

Removing periodic parole window.

The periodic parole window is the 10 minute window that occurs every
24 hours to let RARE apps run. Now that we have the quota system in
place, there's no need to have the periodic parole window. Alarms and
jobs will still be allowed to run when charging. Network will continue
to be restricted for RARE apps even when charging. JobScheduler requests
an exception for RARE jobs in quota, so they will still be able to run.

Bug: 136184981
Test: atest AppStandbyControllerTests
Test: atest CtsAlarmManagerTestCases
Test: atest NetworkPolicyManagerServiceTest
Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Test: atest com.android.server.AlarmManagerServiceTest
Test: atest com.android.server.AppStateTrackerTest
Test: atest com.android.server.job.controllers.QuotaControllerTest
Test: atest com.android.server.net.ConnOnActivityStartTest
Change-Id: Ide382ad7fb9c7441f0a5232833ad39bf8c3a1e94
parent a9da1921
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -35,8 +35,6 @@ public interface AppStandbyInternal {

    void onBootPhase(int phase);

    boolean isParoledOrCharging();

    void postCheckIdleStates(int userId);

    /**
@@ -59,13 +57,15 @@ public interface AppStandbyInternal {

    int getAppId(String packageName);

    boolean isAppIdleFilteredOrParoled(String packageName, int userId, long elapsedRealtime,
    /**
     * @see #isAppIdleFiltered(String, int, int, long)
     */
    boolean isAppIdleFiltered(String packageName, int userId, long elapsedRealtime,
            boolean shouldObfuscateInstantApps);

    /**
     * Checks if an app has been idle for a while and filters out apps that are excluded.
     * It returns false if the current system state allows all apps to be considered active.
     * This happens if the device is plugged in or temporarily allowed to make exceptions.
     * Called by interface impls.
     */
    boolean isAppIdleFiltered(String packageName, int appId, int userId,
+0 −18
Original line number Diff line number Diff line
@@ -265,11 +265,6 @@ public class JobSchedulerService extends com.android.server.SystemService
     */
    boolean mReportedActive;

    /**
     * Are we currently in device-wide standby parole?
     */
    volatile boolean mInParole;

    /**
     * A mapping of which uids are currently in the foreground to their effective priority.
     */
@@ -2360,14 +2355,6 @@ public class JobSchedulerService extends com.android.server.SystemService
            // QuotaController handles this now.
        }

        @Override
        public void onParoleStateChanged(boolean isParoleOn) {
            if (DEBUG_STANDBY) {
                Slog.i(TAG, "Global parole state now " + (isParoleOn ? "ON" : "OFF"));
            }
            mInParole = isParoleOn;
        }

        @Override
        public void onUserInteractionStarted(String packageName, int userId) {
            final int uid = mLocalPM.getPackageUid(packageName,
@@ -3031,10 +3018,6 @@ public class JobSchedulerService extends com.android.server.SystemService
            }
            pw.println();

            pw.print("    In parole?: ");
            pw.print(mInParole);
            pw.println();

            for (int i = mJobRestrictions.size() - 1; i >= 0; i--) {
                pw.print("    ");
                mJobRestrictions.get(i).dumpConstants(pw);
@@ -3222,7 +3205,6 @@ public class JobSchedulerService extends com.android.server.SystemService
            }
            proto.end(settingsToken);

            proto.write(JobSchedulerServiceDumpProto.IN_PAROLE, mInParole);
            for (int i = mJobRestrictions.size() - 1; i >= 0; i--) {
                mJobRestrictions.get(i).dumpConstants(proto);
            }
+2 −21
Original line number Diff line number Diff line
@@ -414,8 +414,6 @@ public final class QuotaController extends StateController {
    private final Handler mHandler;
    private final QcConstants mQcConstants;

    private volatile boolean mInParole;

    /** How much time each app will have to run jobs within their standby bucket window. */
    private long mAllowedTimePerPeriodMs = QcConstants.DEFAULT_ALLOWED_TIME_PER_PERIOD_MS;

@@ -711,7 +709,6 @@ public final class QuotaController extends StateController {
    public long getMaxJobExecutionTimeMsLocked(@NonNull final JobStatus jobStatus) {
        // If quota is currently "free", then the job can run for the full amount of time.
        if (mChargeTracker.isCharging()
                || mInParole
                || isTopStartedJobLocked(jobStatus)
                || isUidInForeground(jobStatus.getSourceUid())) {
            return JobServiceContext.EXECUTING_TIMESLICE_MILLIS;
@@ -737,8 +734,8 @@ public final class QuotaController extends StateController {
            final int standbyBucket) {
        if (standbyBucket == NEVER_INDEX) return false;

        // Quota constraint is not enforced while charging or when parole is on.
        if (mChargeTracker.isCharging() || mInParole) {
        // Quota constraint is not enforced while charging.
        if (mChargeTracker.isCharging()) {
            return true;
        }

@@ -1780,20 +1777,6 @@ public final class QuotaController extends StateController {
                }
            });
        }

        @Override
        public void onParoleStateChanged(final boolean isParoleOn) {
            mInParole = isParoleOn;
            if (DEBUG) {
                Slog.i(TAG, "Global parole state now " + (isParoleOn ? "ON" : "OFF"));
            }
            // Update job bookkeeping out of band.
            BackgroundThread.getHandler().post(() -> {
                synchronized (mLock) {
                    maybeUpdateAllConstraintsLocked();
                }
            });
        }
    }

    private final class DeleteTimingSessionsFunctor implements Consumer<List<TimingSession>> {
@@ -2515,7 +2498,6 @@ public final class QuotaController extends StateController {
    public void dumpControllerStateLocked(final IndentingPrintWriter pw,
            final Predicate<JobStatus> predicate) {
        pw.println("Is charging: " + mChargeTracker.isCharging());
        pw.println("In parole: " + mInParole);
        pw.println("Current elapsed time: " + sElapsedRealtimeClock.millis());
        pw.println();

@@ -2639,7 +2621,6 @@ public final class QuotaController extends StateController {
        final long mToken = proto.start(StateControllerProto.QUOTA);

        proto.write(StateControllerProto.QuotaController.IS_CHARGING, mChargeTracker.isCharging());
        proto.write(StateControllerProto.QuotaController.IS_IN_PAROLE, mInParole);
        proto.write(StateControllerProto.QuotaController.ELAPSED_REALTIME,
                sElapsedRealtimeClock.millis());

+2 −286

File changed.

Preview size limit exceeded, changes collapsed.

+0 −12

File changed.

Preview size limit exceeded, changes collapsed.

Loading