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

Commit 40b92d9e authored by Xin Guan's avatar Xin Guan Committed by Android (Google) Code Review
Browse files

Merge "JobScheduler: Enforce quota to jobs started from TOP state" into main

parents 7a986b30 4fa5446f
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.