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

Commit 2082302a authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Add new JobScheduler APIs to enable apps to specific category." into main

parents 0ae51392 85564f0f
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -58,3 +58,12 @@ flag {
        purpose: PURPOSE_BUGFIX
        purpose: PURPOSE_BUGFIX
    }
    }
}
}

flag {
    name: "job_category_apis"
    namespace: "backstage_power"
    description: "Introduce new APIs to allow apps to specify job category"
    bug: "415081367"
    is_exported: true
    is_fixed_read_only: true
}
+66 −0
Original line number Original line Diff line number Diff line
@@ -464,6 +464,38 @@ public class JobInfo implements Parcelable {
    /** @hide */
    /** @hide */
    public static final int MAX_TRACE_TAG_LENGTH = Trace.MAX_SECTION_NAME_LEN;
    public static final int MAX_TRACE_TAG_LENGTH = Trace.MAX_SECTION_NAME_LEN;


    /** @hide */
    @IntDef(prefix = {"CATEGORY_"}, value = {
            CATEGORY_UNKNOWN,
            CATEGORY_BACKUP,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Category {
    }

    /**
     * Category: Default or unspecified job category.
     */
    @FlaggedApi(Flags.FLAG_JOB_CATEGORY_APIS)
    public static final int CATEGORY_UNKNOWN = 0;

    /**
     * Category: The job is used for backing up user-generated data.
     * <p>
     * This is a hint to the system. Jobs marked with this use case
     * <i>may</i> receive additional quota or be subject to different
     * scheduling heuristics, but this is not guaranteed.
     * <p>
     * Since backup operations are inherently network dependent, jobs of this
     * category must have network constraint set using
     * {@link Builder#setRequiredNetworkType(int)}. If it is not set,
     * {@link Builder#build()} will throw an {@link IllegalArgumentException}.
     */
    // TODO: b/419047126 - Expand the javadoc to be more specific about the backup use case and
    // in what conditions this category will be respected.
    @FlaggedApi(Flags.FLAG_JOB_CATEGORY_APIS)
    public static final int CATEGORY_BACKUP = 1;

    @UnsupportedAppUsage
    @UnsupportedAppUsage
    private final int jobId;
    private final int jobId;
    private final PersistableBundle extras;
    private final PersistableBundle extras;
@@ -2233,6 +2265,40 @@ public class JobInfo implements Parcelable {
            return this;
            return this;
        }
        }


        /**
         * Sets the category for this job.
         * <p>
         * The category provides a hint to the system about the purpose
         * of the job, which <i>may</i> influence scheduling and quota allocation.
         *
         * <p>
         * Each category can have specific requirements. For instance, jobs of category
         * {@link JobInfo#CATEGORY_BACKUP} must have network constraint set. If
         * these requirements are not met, {@link Builder#build()} will throw an
         * {@link IllegalArgumentException}.
         *
         * @param category The category for this job, e.g., {@link #CATEGORY_BACKUP}.
         * @return This Builder object to allow method chaining.
         */
        @FlaggedApi(Flags.FLAG_JOB_CATEGORY_APIS)
        @NonNull
        public Builder setCategory(@Category int category) {
            // TODO: b/419047126 - Store the category
            return this;
        }

        /**
         * Gets the category of this job, which was previously defined using
         * {@link #setCategory(int)}.
         *
         * @return The category of this job.
         */
        @FlaggedApi(Flags.FLAG_JOB_CATEGORY_APIS)
        @Category
        public int getCategory() {
            return JobInfo.CATEGORY_UNKNOWN;
        }

        /**
        /**
         * @return The job object to hand to the JobScheduler. This object is immutable.
         * @return The job object to hand to the JobScheduler. This object is immutable.
         */
         */
+4 −0
Original line number Original line Diff line number Diff line
@@ -9495,6 +9495,8 @@ package android.app.job {
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int BACKOFF_POLICY_EXPONENTIAL = 1; // 0x1
    field public static final int BACKOFF_POLICY_EXPONENTIAL = 1; // 0x1
    field public static final int BACKOFF_POLICY_LINEAR = 0; // 0x0
    field public static final int BACKOFF_POLICY_LINEAR = 0; // 0x0
    field @FlaggedApi("android.app.job.job_category_apis") public static final int CATEGORY_BACKUP = 1; // 0x1
    field @FlaggedApi("android.app.job.job_category_apis") public static final int CATEGORY_UNKNOWN = 0; // 0x0
    field @NonNull public static final android.os.Parcelable.Creator<android.app.job.JobInfo> CREATOR;
    field @NonNull public static final android.os.Parcelable.Creator<android.app.job.JobInfo> CREATOR;
    field public static final long DEFAULT_INITIAL_BACKOFF_MILLIS = 30000L; // 0x7530L
    field public static final long DEFAULT_INITIAL_BACKOFF_MILLIS = 30000L; // 0x7530L
    field public static final long MAX_BACKOFF_DELAY_MILLIS = 18000000L; // 0x112a880L
    field public static final long MAX_BACKOFF_DELAY_MILLIS = 18000000L; // 0x112a880L
@@ -9517,8 +9519,10 @@ package android.app.job {
    method @FlaggedApi("android.app.job.job_debug_info_apis") @NonNull public android.app.job.JobInfo.Builder addDebugTag(@NonNull String);
    method @FlaggedApi("android.app.job.job_debug_info_apis") @NonNull public android.app.job.JobInfo.Builder addDebugTag(@NonNull String);
    method public android.app.job.JobInfo.Builder addTriggerContentUri(@NonNull android.app.job.JobInfo.TriggerContentUri);
    method public android.app.job.JobInfo.Builder addTriggerContentUri(@NonNull android.app.job.JobInfo.TriggerContentUri);
    method public android.app.job.JobInfo build();
    method public android.app.job.JobInfo build();
    method @FlaggedApi("android.app.job.job_category_apis") public int getCategory();
    method @FlaggedApi("android.app.job.job_debug_info_apis") @NonNull public android.app.job.JobInfo.Builder removeDebugTag(@NonNull String);
    method @FlaggedApi("android.app.job.job_debug_info_apis") @NonNull public android.app.job.JobInfo.Builder removeDebugTag(@NonNull String);
    method public android.app.job.JobInfo.Builder setBackoffCriteria(long, int);
    method public android.app.job.JobInfo.Builder setBackoffCriteria(long, int);
    method @FlaggedApi("android.app.job.job_category_apis") @NonNull public android.app.job.JobInfo.Builder setCategory(int);
    method public android.app.job.JobInfo.Builder setClipData(@Nullable android.content.ClipData, int);
    method public android.app.job.JobInfo.Builder setClipData(@Nullable android.content.ClipData, int);
    method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long, long);
    method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long, long);
    method @NonNull public android.app.job.JobInfo.Builder setExpedited(boolean);
    method @NonNull public android.app.job.JobInfo.Builder setExpedited(boolean);