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

Commit 86f4c940 authored by Kweku Adams's avatar Kweku Adams
Browse files

Split allowed time by standby bucket.

Make it so that each standby bucket can have a different "allowed time"
per its window size. That way, we can say apps in bucket X can run for Y
minutes total in a Z time period.

Also separating EXEMPTED from ACTIVE so that any changes to ACTIVE quota
don't affect EXEMPTED apps when we don't want it to.

Bug: 143495340
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I2a3f6da75a328505e4091a314a73c0f9d8bbb050
parent d0ee4efd
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -357,6 +357,9 @@ public class JobSchedulerService extends com.android.server.SystemService
    // Putting RESTRICTED_INDEX after NEVER_INDEX to make it easier for proto dumping
    // (ScheduledJobStateChanged and JobStatusDumpProto).
    public static final int RESTRICTED_INDEX = 5;
    // Putting EXEMPTED_INDEX after RESTRICTED_INDEX to make it easier for proto dumping
    // (ScheduledJobStateChanged and JobStatusDumpProto).
    public static final int EXEMPTED_INDEX = 6;

    private class ConstantsObserver implements DeviceConfig.OnPropertiesChangedListener,
            EconomyManagerInternal.TareStateChangeListener {
@@ -2492,6 +2495,7 @@ public class JobSchedulerService extends com.android.server.SystemService
                    shouldForceBatchJob =
                            mConstants.MIN_READY_NON_ACTIVE_JOBS_COUNT > 1
                                    && job.getEffectiveStandbyBucket() != ACTIVE_INDEX
                                    && job.getEffectiveStandbyBucket() != EXEMPTED_INDEX
                                    && !batchDelayExpired;
                }

@@ -3086,8 +3090,10 @@ public class JobSchedulerService extends com.android.server.SystemService
            return FREQUENT_INDEX;
        } else if (bucket > UsageStatsManager.STANDBY_BUCKET_ACTIVE) {
            return WORKING_INDEX;
        } else {
        } else if (bucket > UsageStatsManager.STANDBY_BUCKET_EXEMPTED) {
            return ACTIVE_INDEX;
        } else {
            return EXEMPTED_INDEX;
        }
    }

+5 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.job.controllers;

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.NEVER_INDEX;
import static com.android.server.job.JobSchedulerService.RESTRICTED_INDEX;
import static com.android.server.job.JobSchedulerService.WORKING_INDEX;
@@ -844,12 +845,15 @@ public final class JobStatus {
     * exemptions.
     */
    public int getEffectiveStandbyBucket() {
        final int actualBucket = getStandbyBucket();
        if (actualBucket == EXEMPTED_INDEX) {
            return actualBucket;
        }
        if (uidActive || getJob().isExemptedFromAppStandby()) {
            // Treat these cases as if they're in the ACTIVE bucket so that they get throttled
            // like other ACTIVE apps.
            return ACTIVE_INDEX;
        }
        final int actualBucket = getStandbyBucket();
        if (actualBucket != RESTRICTED_INDEX && actualBucket != NEVER_INDEX
                && mHasMediaBackupExemption) {
            // Cap it at WORKING_INDEX as media back up jobs are important to the user, and the
+312 −68

File changed.

Preview size limit exceeded, changes collapsed.

+117 −16

File changed.

Preview size limit exceeded, changes collapsed.