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

Commit 12fce993 authored by Kweku Adams's avatar Kweku Adams
Browse files

Migrate QuotaController to DeviceConfig.

This migrates flags inside QuotaController to DeviceConfig.
DeviceConfig is the recommended way and using it means
that we only operate/parse the set of flags that changed instead of
every single flag whenever one of them changes.

This uses the JobScheduler DeviceConfig namespace instead of creating a
wholly separate namespace just for the controller.

Bug: 124466289
Test: atest CtsJobSchedulerTestCases
Test: atest FrameworksMockingServicesTests:ConnectivityControllerTest
Test: atest FrameworksMockingServicesTests:JobSchedulerServiceTest
Test: atest FrameworksMockingServicesTests:JobStatusTest
Test: atest FrameworksMockingServicesTests:QuotaControllerTest
Test: atest FrameworksServicesTests:JobStoreTest
Change-Id: Id397dccc6d9c40bac1a9837addcab514f509a721
parent f82f0bc2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -339,6 +339,11 @@ public class JobSchedulerService extends com.android.server.SystemService
        public void onPropertiesChanged(DeviceConfig.Properties properties) {
            boolean apiQuotaScheduleUpdated = false;
            boolean concurrencyUpdated = false;
            for (int controller = 0; controller < mControllers.size(); controller++) {
                final StateController sc = mControllers.get(controller);
                sc.prepareForUpdatedConstantsLocked();
            }

            synchronized (mLock) {
                for (String name : properties.getKeyset()) {
                    if (name == null) {
@@ -384,6 +389,11 @@ public class JobSchedulerService extends com.android.server.SystemService
                                    && !concurrencyUpdated) {
                                mConstants.updateConcurrencyConstantsLocked();
                                concurrencyUpdated = true;
                            } else {
                                for (int ctrlr = 0; ctrlr < mControllers.size(); ctrlr++) {
                                    final StateController sc = mControllers.get(ctrlr);
                                    sc.processConstantLocked(properties, name);
                                }
                            }
                            break;
                    }
+5 −0
Original line number Diff line number Diff line
@@ -1388,6 +1388,11 @@ public final class JobStatus {
        }
        if (isReady()) {
            sb.append(" READY");
        } else {
            sb.append(" satisfied:0x").append(Integer.toHexString(satisfiedConstraints));
            sb.append(" unsatisfied:0x").append(Integer.toHexString(
                    (satisfiedConstraints & mRequiredConstraintsOfInterest)
                            ^ mRequiredConstraintsOfInterest));
        }
        sb.append("}");
        return sb.toString();
+371 −269

File changed.

Preview size limit exceeded, changes collapsed.

+9 −0
Original line number Diff line number Diff line
@@ -18,7 +18,9 @@ package com.android.server.job.controllers;

import static com.android.server.job.JobSchedulerService.DEBUG;

import android.annotation.NonNull;
import android.content.Context;
import android.provider.DeviceConfig;
import android.util.IndentingPrintWriter;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
@@ -84,6 +86,13 @@ public abstract class StateController {
    public void rescheduleForFailureLocked(JobStatus newJob, JobStatus failureToReschedule) {
    }

    /** Notice that updated configuration constants are about to be read. */
    public void prepareForUpdatedConstantsLocked() {}

    /** Process the specified constant and update internal constants if relevant. */
    public void processConstantLocked(@NonNull DeviceConfig.Properties properties,
            @NonNull String key) {}

    /**
     * Called when the JobScheduler.Constants are updated.
     */
+0 −15
Original line number Diff line number Diff line
@@ -11912,21 +11912,6 @@ public final class Settings {
         */
        public static final String POWER_MANAGER_CONSTANTS = "power_manager_constants";
        /**
         * Job scheduler QuotaController specific settings.
         * This is encoded as a key=value list, separated by commas. Ex:
         *
         * "max_job_count_working=5,max_job_count_rare=2"
         *
         * <p>
         * Type: string
         *
         * @hide
         * @see com.android.server.job.JobSchedulerService.Constants
         */
        public static final String JOB_SCHEDULER_QUOTA_CONTROLLER_CONSTANTS =
                "job_scheduler_quota_controller_constants";
        /**
         * ShortcutManager specific settings.
         * This is encoded as a key=value list, separated by commas. Ex:
Loading