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

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

Merge "JobScheduler: Trunk flag cleanup for job count fix" into main

parents c7b882bc 9622aee3
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -29,16 +29,6 @@ flag {
    bug: "299329948"
}

flag {
    name: "count_quota_fix"
    namespace: "backstage_power"
    description: "Fix job count quota check"
    bug: "300862949"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
   name: "thermal_restrictions_to_fgs_jobs"
   namespace: "backstage_power"
+2 −2
Original line number Diff line number Diff line
@@ -1652,7 +1652,7 @@ class JobConcurrencyManager {
                    continue;
                }

                if (Flags.countQuotaFix() && !nextPending.isReady()) {
                if (!nextPending.isReady()) {
                    // This could happen when the constraints for the job have been marked
                    // as unsatisfiled but hasn't been removed from the pending queue yet.
                    if (DEBUG) {
@@ -1749,7 +1749,7 @@ class JobConcurrencyManager {
                    continue;
                }

                if (Flags.countQuotaFix() && !nextPending.isReady()) {
                if (!nextPending.isReady()) {
                    // This could happen when the constraints for the job have been marked
                    // as unsatisfiled but hasn't been removed from the pending queue yet.
                    if (DEBUG) {
+6 −18
Original line number Diff line number Diff line
@@ -953,14 +953,6 @@ public final class QuotaController extends StateController {
        //   1. it was started while the app was in the TOP state
        //   2. the app is currently in the foreground
        //   3. the app overall is within its quota
        if (!Flags.countQuotaFix()) {
            return jobStatus.shouldTreatAsUserInitiatedJob()
                    || isTopStartedJobLocked(jobStatus)
                    || isUidInForeground(jobStatus.getSourceUid())
                    || isWithinQuotaLocked(
                    jobStatus.getSourceUserId(), jobStatus.getSourcePackageName(), standbyBucket);
        }

        if (jobStatus.shouldTreatAsUserInitiatedJob()
                || isTopStartedJobLocked(jobStatus)
                || isUidInForeground(jobStatus.getSourceUid())) {
@@ -1531,11 +1523,9 @@ public final class QuotaController extends StateController {
                stats.jobCountInRateLimitingWindow = 0;
            }
            stats.jobCountInRateLimitingWindow += count;
            if (Flags.countQuotaFix()) {
            stats.bgJobCountInWindow += count;
        }
    }
    }

    private boolean isCompatOverridedForQuotaConstantAdjustment() {
        return mPlatformCompat.isChangeEnabledByPackageName(
@@ -1774,7 +1764,7 @@ public final class QuotaController extends StateController {
                }
            } else if (realStandbyBucket != EXEMPTED_INDEX && realStandbyBucket != ACTIVE_INDEX
                    && realStandbyBucket == js.getEffectiveStandbyBucket()
                    && !(Flags.countQuotaFix() && mService.isCurrentlyRunningLocked(js))) {
                    && !mService.isCurrentlyRunningLocked(js)) {
                // An app in the ACTIVE bucket may be out of quota while the job could be in quota
                // for some reason. Therefore, avoid setting the real value here and check each job
                // individually. Running job need to determine its own quota status as well.
@@ -2195,14 +2185,12 @@ public final class QuotaController extends StateController {
                mBgJobCount++;
                if (mRegularJobTimer) {
                    incrementJobCountLocked(mPkg.userId, mPkg.packageName, 1);
                    if (Flags.countQuotaFix()) {
                    final ExecutionStats stats = getExecutionStatsLocked(mPkg.userId,
                            mPkg.packageName, jobStatus.getEffectiveStandbyBucket(), false);
                    if (!isUnderJobCountQuotaLocked(stats)) {
                        mHandler.obtainMessage(MSG_REACHED_COUNT_QUOTA, mPkg).sendToTarget();
                    }
                }
                }
                if (mRunningBgJobs.size() == 1) {
                    // Started tracking the first job.
                    mStartTimeElapsed = sElapsedRealtimeClock.millis();
+0 −2
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
import static com.android.server.job.Flags.FLAG_COUNT_QUOTA_FIX;
import static com.android.server.job.JobSchedulerService.ACTIVE_INDEX;
import static com.android.server.job.JobSchedulerService.EXEMPTED_INDEX;
import static com.android.server.job.JobSchedulerService.FREQUENT_INDEX;
@@ -3292,7 +3291,6 @@ public class QuotaControllerTest {
    }

    @Test
    @RequiresFlagsEnabled(FLAG_COUNT_QUOTA_FIX)
    public void testIsWithinQuotaLocked_UnderDuration_OverJobCountInWindow() {
        setDischarging();