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

Commit db1b3cfb authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Add new "storage not low" job scheduler constraint."

parents a9795ca6 532ea26c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6749,6 +6749,7 @@ package android.app.job {
    method public boolean isRequireBatteryNotLow();
    method public boolean isRequireCharging();
    method public boolean isRequireDeviceIdle();
    method public boolean isRequireStorageNotLow();
    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
@@ -6776,6 +6777,7 @@ package android.app.job {
    method public android.app.job.JobInfo.Builder setRequiresBatteryNotLow(boolean);
    method public android.app.job.JobInfo.Builder setRequiresCharging(boolean);
    method public android.app.job.JobInfo.Builder setRequiresDeviceIdle(boolean);
    method public android.app.job.JobInfo.Builder setRequiresStorageNotLow(boolean);
    method public android.app.job.JobInfo.Builder setTransientExtras(android.os.Bundle);
    method public android.app.job.JobInfo.Builder setTriggerContentMaxDelay(long);
    method public android.app.job.JobInfo.Builder setTriggerContentUpdateDelay(long);
+2 −0
Original line number Diff line number Diff line
@@ -7183,6 +7183,7 @@ package android.app.job {
    method public boolean isRequireBatteryNotLow();
    method public boolean isRequireCharging();
    method public boolean isRequireDeviceIdle();
    method public boolean isRequireStorageNotLow();
    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
@@ -7210,6 +7211,7 @@ package android.app.job {
    method public android.app.job.JobInfo.Builder setRequiresBatteryNotLow(boolean);
    method public android.app.job.JobInfo.Builder setRequiresCharging(boolean);
    method public android.app.job.JobInfo.Builder setRequiresDeviceIdle(boolean);
    method public android.app.job.JobInfo.Builder setRequiresStorageNotLow(boolean);
    method public android.app.job.JobInfo.Builder setTransientExtras(android.os.Bundle);
    method public android.app.job.JobInfo.Builder setTriggerContentMaxDelay(long);
    method public android.app.job.JobInfo.Builder setTriggerContentUpdateDelay(long);
+2 −0
Original line number Diff line number Diff line
@@ -6776,6 +6776,7 @@ package android.app.job {
    method public boolean isRequireBatteryNotLow();
    method public boolean isRequireCharging();
    method public boolean isRequireDeviceIdle();
    method public boolean isRequireStorageNotLow();
    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
@@ -6803,6 +6804,7 @@ package android.app.job {
    method public android.app.job.JobInfo.Builder setRequiresBatteryNotLow(boolean);
    method public android.app.job.JobInfo.Builder setRequiresCharging(boolean);
    method public android.app.job.JobInfo.Builder setRequiresDeviceIdle(boolean);
    method public android.app.job.JobInfo.Builder setRequiresStorageNotLow(boolean);
    method public android.app.job.JobInfo.Builder setTransientExtras(android.os.Bundle);
    method public android.app.job.JobInfo.Builder setTriggerContentMaxDelay(long);
    method public android.app.job.JobInfo.Builder setTriggerContentUpdateDelay(long);
+32 −2
Original line number Diff line number Diff line
@@ -189,6 +189,11 @@ public class JobInfo implements Parcelable {
     */
    public static final int CONSTRAINT_FLAG_DEVICE_IDLE = 1 << 2;

    /**
     * @hide
     */
    public static final int CONSTRAINT_FLAG_STORAGE_NOT_LOW = 1 << 3;

    private final int jobId;
    private final PersistableBundle extras;
    private final Bundle transientExtras;
@@ -272,6 +277,13 @@ public class JobInfo implements Parcelable {
        return (constraintFlags & CONSTRAINT_FLAG_DEVICE_IDLE) != 0;
    }

    /**
     * Whether this job needs the device's storage to not be low.
     */
    public boolean isRequireStorageNotLow() {
        return (constraintFlags & CONSTRAINT_FLAG_STORAGE_NOT_LOW) != 0;
    }

    /**
     * @hide
     */
@@ -709,16 +721,34 @@ public class JobInfo implements Parcelable {
            return this;
        }

        /**
         * Specify that to run this job, the device's available storage must not be low.
         * This defaults to false.  If true, the job will only run when the device is not
         * in a low storage state, which is generally the point where the user is given a
         * "low storage" warning.
         * @param storageNotLow Whether or not the device's available storage must not be low.
         */
        public Builder setRequiresStorageNotLow(boolean storageNotLow) {
            mConstraintFlags = (mConstraintFlags&~CONSTRAINT_FLAG_STORAGE_NOT_LOW)
                    | (storageNotLow ? CONSTRAINT_FLAG_STORAGE_NOT_LOW : 0);
            return this;
        }

        /**
         * Add a new content: URI that will be monitored with a
         * {@link android.database.ContentObserver}, and will cause the job to execute if changed.
         * If you have any trigger content URIs associated with a job, it will not execute until
         * there has been a change report for one or more of them.
         *
         * <p>Note that trigger URIs can not be used in combination with
         * {@link #setPeriodic(long)} or {@link #setPersisted(boolean)}.  To continually monitor
         * for content changes, you need to schedule a new JobInfo observing the same URIs
         * before you finish execution of the JobService handling the most recent changes.</p>
         * <p>Because because setting this property is not compatible with periodic or
         * before you finish execution of the JobService handling the most recent changes.
         * Following this pattern will ensure you do not lost any content changes: while your
         * job is running, the system will continue monitoring for content changes, and propagate
         * any it sees over to the next job you schedule.</p>
         *
         * <p>Because setting this property is not compatible with periodic or
         * persisted jobs, doing so will throw an {@link java.lang.IllegalArgumentException} when
         * {@link android.app.job.JobInfo.Builder#build()} is called.</p>
         *
+1 −1
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ public abstract class JobService extends Service {
    public abstract boolean onStopJob(JobParameters params);

    /**
     * Callback to inform the JobManager you've finished executing. This can be called from any
     * Call this to inform the JobManager you've finished executing. This can be called from any
     * thread, as it will ultimately be run on your application's main thread. When the system
     * receives this message it will release the wakelock being held.
     * <p>
Loading