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

Commit 4fa5446f authored by Xin Guan's avatar Xin Guan
Browse files

JobScheduler: Enforce quota to jobs started from TOP state

Jobs started when the app was on TOP proc state are not exempted
from quota controller after the app leaves the top states

Bug: 374323858
Test: atest CtsJobSchedulerTestCases
Test: atest FrameworksMockingServicesTests:com.android.server.job.controllers.QuotaControllerTest
Flag: com.android.server.job.enforce_quota_policy_to_top_started_jobs
Change-Id: I31b565da698d73f1f989098d5afb62315cc34782
parent 48804996
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -89,3 +89,10 @@ flag {
   description: "Adjust quota default parameters"
   bug: "347058927"
}

flag {
   name: "enforce_quota_policy_to_top_started_jobs"
   namespace: "backstage_power"
   description: "Apply the quota policy to jobs started when the app was in TOP state"
   bug: "374323858"
}
 No newline at end of file
+8 −4
Original line number Diff line number Diff line
@@ -619,7 +619,7 @@ public final class QuotaController extends StateController {
        }

        final int uid = jobStatus.getSourceUid();
        if (mTopAppCache.get(uid)) {
        if (!Flags.enforceQuotaPolicyToTopStartedJobs() && mTopAppCache.get(uid)) {
            if (DEBUG) {
                Slog.d(TAG, jobStatus.toShortString() + " is top started job");
            }
@@ -656,8 +656,10 @@ public final class QuotaController extends StateController {
                timer.stopTrackingJob(jobStatus);
            }
        }
        if (!Flags.enforceQuotaPolicyToTopStartedJobs()) {
            mTopStartedJobs.remove(jobStatus);
        }
    }

    @Override
    @GuardedBy("mLock")
@@ -767,7 +769,7 @@ public final class QuotaController extends StateController {

    /** @return true if the job was started while the app was in the TOP state. */
    private boolean isTopStartedJobLocked(@NonNull final JobStatus jobStatus) {
        return mTopStartedJobs.contains(jobStatus);
        return !Flags.enforceQuotaPolicyToTopStartedJobs() && mTopStartedJobs.contains(jobStatus);
    }

    /** Returns the maximum amount of time this job could run for. */
@@ -4379,11 +4381,13 @@ public final class QuotaController extends StateController {
    @Override
    public void dumpControllerStateLocked(final IndentingPrintWriter pw,
            final Predicate<JobStatus> predicate) {
        pw.println("Flags: ");
        pw.println("Aconfig Flags:");
        pw.println("    " + Flags.FLAG_ADJUST_QUOTA_DEFAULT_CONSTANTS
                + ": " + Flags.adjustQuotaDefaultConstants());
        pw.println("    " + Flags.FLAG_ENFORCE_QUOTA_POLICY_TO_FGS_JOBS
                + ": " + Flags.enforceQuotaPolicyToFgsJobs());
        pw.println("    " + Flags.FLAG_ENFORCE_QUOTA_POLICY_TO_TOP_STARTED_JOBS
                + ": " + Flags.enforceQuotaPolicyToTopStartedJobs());
        pw.println();

        pw.println("Current elapsed time: " + sElapsedRealtimeClock.millis());
+473 −2

File changed.

Preview size limit exceeded, changes collapsed.