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

Commit a5a85bd4 authored by Christopher Tate's avatar Christopher Tate
Browse files

Jobs now ignore standby bucketing while device is in parole

Bug: TBD
Test: manual
Change-Id: I18eeb0cd660968ab79fdf2343a53cfe1bb4cbc86
parent dce50021
Loading
Loading
Loading
Loading
+32 −21
Original line number Diff line number Diff line
@@ -184,6 +184,11 @@ public final class JobSchedulerService extends com.android.server.SystemService
     */
    boolean mReportedActive;

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

    /**
     * Current limit on the number of concurrent JobServiceContext entries we want to
     * keep actively running a job.
@@ -1720,7 +1725,9 @@ public final class JobSchedulerService extends com.android.server.SystemService
        }

        // If the app is in a non-active standby bucket, make sure we've waited
        // an appropriate amount of time since the last invocation
        // an appropriate amount of time since the last invocation.  During device-
        // wide parole, standby bucketing is ignored.
        if (!mInParole) {
            final int bucket = job.getStandbyBucket();
            if (mHeartbeat < mNextBucketHeartbeat[bucket]) {
                // Only skip this job if it's still waiting for the end of its (initial) nominal
@@ -1745,6 +1752,7 @@ public final class JobSchedulerService extends com.android.server.SystemService
                    }
                }
            }
        }

        // The expensive check last: validate that the defined package+service is
        // still present & viable.
@@ -2086,7 +2094,10 @@ public final class JobSchedulerService extends com.android.server.SystemService

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