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

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

Merge "Remove the Job category APIs." into main

parents 549670eb 38cc09ef
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -58,12 +58,3 @@ flag {
        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
}
+0 −98
Original line number Diff line number Diff line
@@ -464,46 +464,6 @@ public class JobInfo implements Parcelable {
    /** @hide */
    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;

    /**
     * Maximum value for {@link Category}.
     *
     * @hide
     */
    @FlaggedApi(Flags.FLAG_JOB_CATEGORY_APIS)
    public static final int CATEGORY_MAX = CATEGORY_BACKUP;

    @UnsupportedAppUsage
    private final int jobId;
    private final PersistableBundle extras;
@@ -538,8 +498,6 @@ public class JobInfo implements Parcelable {
    private final ArraySet<String> mDebugTags;
    @Nullable
    private final String mTraceTag;
    @Category
    private final int mCategory;

    /**
     * Unique job id associated with this application (uid).  This is the same job ID
@@ -836,21 +794,6 @@ public class JobInfo implements Parcelable {
        return mTraceTag;
    }

    /**
     * Gets the category of this job, which was previously defined using
     * {@link JobInfo.Builder#setCategory(int)}. If no category has been set, then
     * {@link JobInfo#CATEGORY_UNKNOWN} will be returned.
     *
     * @return The category of this job, or {@link JobInfo#CATEGORY_UNKNOWN} if no category has
     *         been set using {@link JobInfo.Builder#setCategory(int)}.
     * @see JobInfo.Builder#setCategory(int)
     */
    @FlaggedApi(Flags.FLAG_JOB_CATEGORY_APIS)
    @Category
    public int getCategory() {
        return mCategory;
    }

    /**
     * @see JobInfo.Builder#setExpedited(boolean)
     */
@@ -1002,9 +945,6 @@ public class JobInfo implements Parcelable {
        if (!Objects.equals(mTraceTag, j.mTraceTag)) {
            return false;
        }
        if (mCategory != j.mCategory) {
            return false;
        }
        return true;
    }

@@ -1055,7 +995,6 @@ public class JobInfo implements Parcelable {
        if (mTraceTag != null) {
            hashCode = 31 * hashCode + mTraceTag.hashCode();
        }
        hashCode = 31 * hashCode + mCategory;
        return hashCode;
    }

@@ -1109,7 +1048,6 @@ public class JobInfo implements Parcelable {
        }
        final String traceTag = in.readString();
        mTraceTag = traceTag == null ? null : traceTag.intern();
        mCategory = in.readInt();
    }

    private JobInfo(JobInfo.Builder b) {
@@ -1144,7 +1082,6 @@ public class JobInfo implements Parcelable {
        flags = b.mFlags;
        mDebugTags = b.mDebugTags;
        mTraceTag = b.mTraceTag;
        mCategory = b.mCategory;
    }

    @Override
@@ -1199,7 +1136,6 @@ public class JobInfo implements Parcelable {
            out.writeString(mDebugTags.valueAt(i));
        }
        out.writeString(mTraceTag);
        out.writeInt(mCategory);
    }

    public static final @android.annotation.NonNull Creator<JobInfo> CREATOR = new Creator<JobInfo>() {
@@ -1346,8 +1282,6 @@ public class JobInfo implements Parcelable {
        private boolean mBackoffPolicySet = false;
        private final ArraySet<String> mDebugTags = new ArraySet<>();
        private String mTraceTag;
        @Category
        private int mCategory;

        /**
         * Initialize a new Builder to construct a {@link JobInfo}.
@@ -2278,28 +2212,6 @@ public class JobInfo implements Parcelable {
            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 system resource 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) {
            mCategory = validateCategory(category);
            return this;
        }

        /**
         * @return The job object to hand to the JobScheduler. This object is immutable.
         */
@@ -2623,16 +2535,6 @@ public class JobInfo implements Parcelable {
        return traceTag.intern();
    }

    /**
     * Returns the {@code category} if valid, or throws an exception if not.
     */
    private static int validateCategory(@Category int category) {
        if (category < CATEGORY_UNKNOWN || category > CATEGORY_MAX) {
            throw new IllegalArgumentException("Not a valid category: " + category);
        }
        return category;
    }

    /**
     * Convert a bias integer into a human readable string for debugging.
     * @hide
+0 −4
Original line number Diff line number Diff line
@@ -9442,7 +9442,6 @@ package android.app.job {
  public class JobInfo implements android.os.Parcelable {
    method public int describeContents();
    method public int getBackoffPolicy();
    method @FlaggedApi("android.app.job.job_category_apis") public int getCategory();
    method @Nullable public android.content.ClipData getClipData();
    method public int getClipGrantFlags();
    method @FlaggedApi("android.app.job.job_debug_info_apis") @NonNull public java.util.Set<java.lang.String> getDebugTags();
@@ -9480,8 +9479,6 @@ package android.app.job {
    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_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 public static final long DEFAULT_INITIAL_BACKOFF_MILLIS = 30000L; // 0x7530L
    field public static final long MAX_BACKOFF_DELAY_MILLIS = 18000000L; // 0x112a880L
@@ -9506,7 +9503,6 @@ package android.app.job {
    method public android.app.job.JobInfo build();
    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 @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 setEstimatedNetworkBytes(long, long);
    method @NonNull public android.app.job.JobInfo.Builder setExpedited(boolean);