Loading api/current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -6834,6 +6834,7 @@ package android.app.job { method public int getBackoffPolicy(); method public android.content.ClipData getClipData(); method public int getClipGrantFlags(); method public long getEstimatedNetworkBytes(); method public android.os.PersistableBundle getExtras(); method public long getFlexMillis(); method public int getId(); Loading Loading @@ -6861,6 +6862,7 @@ package android.app.job { field 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 field public static final int NETWORK_BYTES_UNKNOWN = -1; // 0xffffffff field public static final int NETWORK_TYPE_ANY = 1; // 0x1 field public static final int NETWORK_TYPE_METERED = 4; // 0x4 field public static final int NETWORK_TYPE_NONE = 0; // 0x0 Loading @@ -6874,6 +6876,7 @@ package android.app.job { method public android.app.job.JobInfo build(); method public android.app.job.JobInfo.Builder setBackoffCriteria(long, int); method public android.app.job.JobInfo.Builder setClipData(android.content.ClipData, int); method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long); method public android.app.job.JobInfo.Builder setExtras(android.os.PersistableBundle); method public android.app.job.JobInfo.Builder setMinimumLatency(long); method public android.app.job.JobInfo.Builder setOverrideDeadline(long); Loading Loading @@ -6948,8 +6951,10 @@ package android.app.job { public final class JobWorkItem implements android.os.Parcelable { ctor public JobWorkItem(android.content.Intent); ctor public JobWorkItem(android.content.Intent, long); method public int describeContents(); method public int getDeliveryCount(); method public long getEstimatedNetworkBytes(); method public android.content.Intent getIntent(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.app.job.JobWorkItem> CREATOR; api/system-current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -7276,6 +7276,7 @@ package android.app.job { method public int getBackoffPolicy(); method public android.content.ClipData getClipData(); method public int getClipGrantFlags(); method public long getEstimatedNetworkBytes(); method public android.os.PersistableBundle getExtras(); method public long getFlexMillis(); method public int getId(); Loading Loading @@ -7303,6 +7304,7 @@ package android.app.job { field 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 field public static final int NETWORK_BYTES_UNKNOWN = -1; // 0xffffffff field public static final int NETWORK_TYPE_ANY = 1; // 0x1 field public static final int NETWORK_TYPE_METERED = 4; // 0x4 field public static final int NETWORK_TYPE_NONE = 0; // 0x0 Loading @@ -7316,6 +7318,7 @@ package android.app.job { method public android.app.job.JobInfo build(); method public android.app.job.JobInfo.Builder setBackoffCriteria(long, int); method public android.app.job.JobInfo.Builder setClipData(android.content.ClipData, int); method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long); method public android.app.job.JobInfo.Builder setExtras(android.os.PersistableBundle); method public android.app.job.JobInfo.Builder setMinimumLatency(long); method public android.app.job.JobInfo.Builder setOverrideDeadline(long); Loading Loading @@ -7391,8 +7394,10 @@ package android.app.job { public final class JobWorkItem implements android.os.Parcelable { ctor public JobWorkItem(android.content.Intent); ctor public JobWorkItem(android.content.Intent, long); method public int describeContents(); method public int getDeliveryCount(); method public long getEstimatedNetworkBytes(); method public android.content.Intent getIntent(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.app.job.JobWorkItem> CREATOR; api/test-current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -6905,6 +6905,7 @@ package android.app.job { method public int getBackoffPolicy(); method public android.content.ClipData getClipData(); method public int getClipGrantFlags(); method public long getEstimatedNetworkBytes(); method public android.os.PersistableBundle getExtras(); method public long getFlexMillis(); method public int getId(); Loading Loading @@ -6932,6 +6933,7 @@ package android.app.job { field 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 field public static final int NETWORK_BYTES_UNKNOWN = -1; // 0xffffffff field public static final int NETWORK_TYPE_ANY = 1; // 0x1 field public static final int NETWORK_TYPE_METERED = 4; // 0x4 field public static final int NETWORK_TYPE_NONE = 0; // 0x0 Loading @@ -6945,6 +6947,7 @@ package android.app.job { method public android.app.job.JobInfo build(); method public android.app.job.JobInfo.Builder setBackoffCriteria(long, int); method public android.app.job.JobInfo.Builder setClipData(android.content.ClipData, int); method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long); method public android.app.job.JobInfo.Builder setExtras(android.os.PersistableBundle); method public android.app.job.JobInfo.Builder setMinimumLatency(long); method public android.app.job.JobInfo.Builder setOverrideDeadline(long); Loading Loading @@ -7019,8 +7022,10 @@ package android.app.job { public final class JobWorkItem implements android.os.Parcelable { ctor public JobWorkItem(android.content.Intent); ctor public JobWorkItem(android.content.Intent, long); method public int describeContents(); method public int getDeliveryCount(); method public long getEstimatedNetworkBytes(); method public android.content.Intent getIntent(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.app.job.JobWorkItem> CREATOR; core/java/android/app/job/JobInfo.java +67 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.app.job; import static android.util.TimeUtils.formatDuration; import android.annotation.BytesLong; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -71,6 +72,9 @@ public class JobInfo implements Parcelable { /** This job requires metered connectivity such as most cellular data networks. */ public static final int NETWORK_TYPE_METERED = 4; /** Sentinel value indicating that bytes are unknown. */ public static final int NETWORK_BYTES_UNKNOWN = -1; /** * Amount of backoff a job has initially by default, in milliseconds. */ Loading Loading @@ -250,6 +254,7 @@ public class JobInfo implements Parcelable { private final boolean hasEarlyConstraint; private final boolean hasLateConstraint; private final int networkType; private final long networkBytes; private final long minLatencyMillis; private final long maxExecutionDelayMillis; private final boolean isPeriodic; Loading Loading @@ -386,6 +391,18 @@ public class JobInfo implements Parcelable { return networkType; } /** * Return the estimated size of network traffic that will be performed by * this job, in bytes. * * @return Estimated size of network traffic, or * {@link #NETWORK_BYTES_UNKNOWN} when unknown. * @see Builder#setEstimatedNetworkBytes(long) */ public @BytesLong long getEstimatedNetworkBytes() { return networkBytes; } /** * Set for a job that does not recur periodically, to specify a delay after which the job * will be eligible for execution. This value is not set if the job recurs periodically. Loading Loading @@ -524,6 +541,9 @@ public class JobInfo implements Parcelable { if (networkType != j.networkType) { return false; } if (networkBytes != j.networkBytes) { return false; } if (minLatencyMillis != j.minLatencyMillis) { return false; } Loading Loading @@ -582,6 +602,7 @@ public class JobInfo implements Parcelable { hashCode = 31 * hashCode + Boolean.hashCode(hasEarlyConstraint); hashCode = 31 * hashCode + Boolean.hashCode(hasLateConstraint); hashCode = 31 * hashCode + networkType; hashCode = 31 * hashCode + Long.hashCode(networkBytes); hashCode = 31 * hashCode + Long.hashCode(minLatencyMillis); hashCode = 31 * hashCode + Long.hashCode(maxExecutionDelayMillis); hashCode = 31 * hashCode + Boolean.hashCode(isPeriodic); Loading Loading @@ -612,6 +633,7 @@ public class JobInfo implements Parcelable { triggerContentUpdateDelay = in.readLong(); triggerContentMaxDelay = in.readLong(); networkType = in.readInt(); networkBytes = in.readLong(); minLatencyMillis = in.readLong(); maxExecutionDelayMillis = in.readLong(); isPeriodic = in.readInt() == 1; Loading Loading @@ -640,6 +662,7 @@ public class JobInfo implements Parcelable { triggerContentUpdateDelay = b.mTriggerContentUpdateDelay; triggerContentMaxDelay = b.mTriggerContentMaxDelay; networkType = b.mNetworkType; networkBytes = b.mNetworkBytes; minLatencyMillis = b.mMinLatencyMillis; maxExecutionDelayMillis = b.mMaxExecutionDelayMillis; isPeriodic = b.mIsPeriodic; Loading Loading @@ -677,6 +700,7 @@ public class JobInfo implements Parcelable { out.writeLong(triggerContentUpdateDelay); out.writeLong(triggerContentMaxDelay); out.writeInt(networkType); out.writeLong(networkBytes); out.writeLong(minLatencyMillis); out.writeLong(maxExecutionDelayMillis); out.writeInt(isPeriodic ? 1 : 0); Loading Loading @@ -810,6 +834,7 @@ public class JobInfo implements Parcelable { // Requirements. private int mConstraintFlags; private int mNetworkType; private long mNetworkBytes = NETWORK_BYTES_UNKNOWN; private ArrayList<TriggerContentUri> mTriggerContentUris; private long mTriggerContentUpdateDelay = -1; private long mTriggerContentMaxDelay = -1; Loading Loading @@ -930,6 +955,43 @@ public class JobInfo implements Parcelable { return this; } /** * Set the estimated size of network traffic that will be performed by * this job, in bytes. * <p> * Apps are encouraged to provide values that are as accurate as * possible, but when the exact size isn't available, an * order-of-magnitude estimate can be provided instead. Here are some * specific examples: * <ul> * <li>A job that is backing up a photo knows the exact size of that * photo, so it should provide that size as the estimate. * <li>A job that refreshes top news stories wouldn't know an exact * size, but if the size is expected to be consistently around 100KB, it * can provide that order-of-magnitude value as the estimate. * <li>A job that synchronizes email could end up using an extreme range * of data, from under 1KB when nothing has changed, to dozens of MB * when there are new emails with attachments. Jobs that cannot provide * reasonable estimates should leave this estimated value undefined. * </ul> * Note that the system may choose to delay jobs with large network * usage estimates when the device has a poor network connection, in * order to save battery. * * @param networkBytes The estimated size of network traffic that will * be performed by this job, in bytes. This value only * reflects the traffic that will be performed by the base * job; if you're using {@link JobWorkItem} then you also * need to define the network traffic used by each work item * when constructing them. * @see JobInfo#getEstimatedNetworkBytes() * @see JobWorkItem#JobWorkItem(android.content.Intent, long) */ public Builder setEstimatedNetworkBytes(@BytesLong long networkBytes) { mNetworkBytes = networkBytes; return this; } /** * Specify that to run this job, the device must be charging (or be a * non-battery-powered device connected to permanent power, such as Android TV Loading Loading @@ -1156,6 +1218,11 @@ public class JobInfo implements Parcelable { throw new IllegalArgumentException("You're trying to build a job with no " + "constraints, this is not allowed."); } // Check that network estimates require network type if (mNetworkBytes > 0 && mNetworkType == NETWORK_TYPE_NONE) { throw new IllegalArgumentException( "Can't provide estimated network usage without requiring a network"); } // Check that a deadline was not set on a periodic job. if (mIsPeriodic) { if (mMaxExecutionDelayMillis != 0L) { Loading core/java/android/app/job/JobWorkItem.java +35 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.app.job; import android.annotation.BytesLong; import android.content.Intent; import android.os.Parcel; import android.os.Parcelable; Loading @@ -27,6 +28,7 @@ import android.os.Parcelable; */ final public class JobWorkItem implements Parcelable { final Intent mIntent; final long mNetworkBytes; int mDeliveryCount; int mWorkId; Object mGrants; Loading @@ -39,6 +41,22 @@ final public class JobWorkItem implements Parcelable { */ public JobWorkItem(Intent intent) { mIntent = intent; mNetworkBytes = JobInfo.NETWORK_BYTES_UNKNOWN; } /** * Create a new piece of work, which can be submitted to * {@link JobScheduler#enqueue JobScheduler.enqueue}. * * @param intent The general Intent describing this work. * @param networkBytes The estimated size of network traffic that will be * performed by this job work item, in bytes. See * {@link JobInfo.Builder#setEstimatedNetworkBytes(long)} for * details about how to estimate. */ public JobWorkItem(Intent intent, @BytesLong long networkBytes) { mIntent = intent; mNetworkBytes = networkBytes; } /** Loading @@ -48,6 +66,17 @@ final public class JobWorkItem implements Parcelable { return mIntent; } /** * Return the estimated size of network traffic that will be performed by * this job work item, in bytes. * * @return estimated size, or {@link JobInfo#NETWORK_BYTES_UNKNOWN} when * unknown. */ public @BytesLong long getEstimatedNetworkBytes() { return mNetworkBytes; } /** * Return the count of the number of times this work item has been delivered * to the job. The value will be > 1 if it has been redelivered because the job Loading Loading @@ -99,6 +128,10 @@ final public class JobWorkItem implements Parcelable { sb.append(mWorkId); sb.append(" intent="); sb.append(mIntent); if (mNetworkBytes != JobInfo.NETWORK_BYTES_UNKNOWN) { sb.append(" networkBytes="); sb.append(mNetworkBytes); } if (mDeliveryCount != 0) { sb.append(" dcount="); sb.append(mDeliveryCount); Loading @@ -118,6 +151,7 @@ final public class JobWorkItem implements Parcelable { } else { out.writeInt(0); } out.writeLong(mNetworkBytes); out.writeInt(mDeliveryCount); out.writeInt(mWorkId); } Loading @@ -139,6 +173,7 @@ final public class JobWorkItem implements Parcelable { } else { mIntent = null; } mNetworkBytes = in.readLong(); mDeliveryCount = in.readInt(); mWorkId = in.readInt(); } Loading Loading
api/current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -6834,6 +6834,7 @@ package android.app.job { method public int getBackoffPolicy(); method public android.content.ClipData getClipData(); method public int getClipGrantFlags(); method public long getEstimatedNetworkBytes(); method public android.os.PersistableBundle getExtras(); method public long getFlexMillis(); method public int getId(); Loading Loading @@ -6861,6 +6862,7 @@ package android.app.job { field 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 field public static final int NETWORK_BYTES_UNKNOWN = -1; // 0xffffffff field public static final int NETWORK_TYPE_ANY = 1; // 0x1 field public static final int NETWORK_TYPE_METERED = 4; // 0x4 field public static final int NETWORK_TYPE_NONE = 0; // 0x0 Loading @@ -6874,6 +6876,7 @@ package android.app.job { method public android.app.job.JobInfo build(); method public android.app.job.JobInfo.Builder setBackoffCriteria(long, int); method public android.app.job.JobInfo.Builder setClipData(android.content.ClipData, int); method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long); method public android.app.job.JobInfo.Builder setExtras(android.os.PersistableBundle); method public android.app.job.JobInfo.Builder setMinimumLatency(long); method public android.app.job.JobInfo.Builder setOverrideDeadline(long); Loading Loading @@ -6948,8 +6951,10 @@ package android.app.job { public final class JobWorkItem implements android.os.Parcelable { ctor public JobWorkItem(android.content.Intent); ctor public JobWorkItem(android.content.Intent, long); method public int describeContents(); method public int getDeliveryCount(); method public long getEstimatedNetworkBytes(); method public android.content.Intent getIntent(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.app.job.JobWorkItem> CREATOR;
api/system-current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -7276,6 +7276,7 @@ package android.app.job { method public int getBackoffPolicy(); method public android.content.ClipData getClipData(); method public int getClipGrantFlags(); method public long getEstimatedNetworkBytes(); method public android.os.PersistableBundle getExtras(); method public long getFlexMillis(); method public int getId(); Loading Loading @@ -7303,6 +7304,7 @@ package android.app.job { field 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 field public static final int NETWORK_BYTES_UNKNOWN = -1; // 0xffffffff field public static final int NETWORK_TYPE_ANY = 1; // 0x1 field public static final int NETWORK_TYPE_METERED = 4; // 0x4 field public static final int NETWORK_TYPE_NONE = 0; // 0x0 Loading @@ -7316,6 +7318,7 @@ package android.app.job { method public android.app.job.JobInfo build(); method public android.app.job.JobInfo.Builder setBackoffCriteria(long, int); method public android.app.job.JobInfo.Builder setClipData(android.content.ClipData, int); method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long); method public android.app.job.JobInfo.Builder setExtras(android.os.PersistableBundle); method public android.app.job.JobInfo.Builder setMinimumLatency(long); method public android.app.job.JobInfo.Builder setOverrideDeadline(long); Loading Loading @@ -7391,8 +7394,10 @@ package android.app.job { public final class JobWorkItem implements android.os.Parcelable { ctor public JobWorkItem(android.content.Intent); ctor public JobWorkItem(android.content.Intent, long); method public int describeContents(); method public int getDeliveryCount(); method public long getEstimatedNetworkBytes(); method public android.content.Intent getIntent(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.app.job.JobWorkItem> CREATOR;
api/test-current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -6905,6 +6905,7 @@ package android.app.job { method public int getBackoffPolicy(); method public android.content.ClipData getClipData(); method public int getClipGrantFlags(); method public long getEstimatedNetworkBytes(); method public android.os.PersistableBundle getExtras(); method public long getFlexMillis(); method public int getId(); Loading Loading @@ -6932,6 +6933,7 @@ package android.app.job { field 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 field public static final int NETWORK_BYTES_UNKNOWN = -1; // 0xffffffff field public static final int NETWORK_TYPE_ANY = 1; // 0x1 field public static final int NETWORK_TYPE_METERED = 4; // 0x4 field public static final int NETWORK_TYPE_NONE = 0; // 0x0 Loading @@ -6945,6 +6947,7 @@ package android.app.job { method public android.app.job.JobInfo build(); method public android.app.job.JobInfo.Builder setBackoffCriteria(long, int); method public android.app.job.JobInfo.Builder setClipData(android.content.ClipData, int); method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long); method public android.app.job.JobInfo.Builder setExtras(android.os.PersistableBundle); method public android.app.job.JobInfo.Builder setMinimumLatency(long); method public android.app.job.JobInfo.Builder setOverrideDeadline(long); Loading Loading @@ -7019,8 +7022,10 @@ package android.app.job { public final class JobWorkItem implements android.os.Parcelable { ctor public JobWorkItem(android.content.Intent); ctor public JobWorkItem(android.content.Intent, long); method public int describeContents(); method public int getDeliveryCount(); method public long getEstimatedNetworkBytes(); method public android.content.Intent getIntent(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.app.job.JobWorkItem> CREATOR;
core/java/android/app/job/JobInfo.java +67 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.app.job; import static android.util.TimeUtils.formatDuration; import android.annotation.BytesLong; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -71,6 +72,9 @@ public class JobInfo implements Parcelable { /** This job requires metered connectivity such as most cellular data networks. */ public static final int NETWORK_TYPE_METERED = 4; /** Sentinel value indicating that bytes are unknown. */ public static final int NETWORK_BYTES_UNKNOWN = -1; /** * Amount of backoff a job has initially by default, in milliseconds. */ Loading Loading @@ -250,6 +254,7 @@ public class JobInfo implements Parcelable { private final boolean hasEarlyConstraint; private final boolean hasLateConstraint; private final int networkType; private final long networkBytes; private final long minLatencyMillis; private final long maxExecutionDelayMillis; private final boolean isPeriodic; Loading Loading @@ -386,6 +391,18 @@ public class JobInfo implements Parcelable { return networkType; } /** * Return the estimated size of network traffic that will be performed by * this job, in bytes. * * @return Estimated size of network traffic, or * {@link #NETWORK_BYTES_UNKNOWN} when unknown. * @see Builder#setEstimatedNetworkBytes(long) */ public @BytesLong long getEstimatedNetworkBytes() { return networkBytes; } /** * Set for a job that does not recur periodically, to specify a delay after which the job * will be eligible for execution. This value is not set if the job recurs periodically. Loading Loading @@ -524,6 +541,9 @@ public class JobInfo implements Parcelable { if (networkType != j.networkType) { return false; } if (networkBytes != j.networkBytes) { return false; } if (minLatencyMillis != j.minLatencyMillis) { return false; } Loading Loading @@ -582,6 +602,7 @@ public class JobInfo implements Parcelable { hashCode = 31 * hashCode + Boolean.hashCode(hasEarlyConstraint); hashCode = 31 * hashCode + Boolean.hashCode(hasLateConstraint); hashCode = 31 * hashCode + networkType; hashCode = 31 * hashCode + Long.hashCode(networkBytes); hashCode = 31 * hashCode + Long.hashCode(minLatencyMillis); hashCode = 31 * hashCode + Long.hashCode(maxExecutionDelayMillis); hashCode = 31 * hashCode + Boolean.hashCode(isPeriodic); Loading Loading @@ -612,6 +633,7 @@ public class JobInfo implements Parcelable { triggerContentUpdateDelay = in.readLong(); triggerContentMaxDelay = in.readLong(); networkType = in.readInt(); networkBytes = in.readLong(); minLatencyMillis = in.readLong(); maxExecutionDelayMillis = in.readLong(); isPeriodic = in.readInt() == 1; Loading Loading @@ -640,6 +662,7 @@ public class JobInfo implements Parcelable { triggerContentUpdateDelay = b.mTriggerContentUpdateDelay; triggerContentMaxDelay = b.mTriggerContentMaxDelay; networkType = b.mNetworkType; networkBytes = b.mNetworkBytes; minLatencyMillis = b.mMinLatencyMillis; maxExecutionDelayMillis = b.mMaxExecutionDelayMillis; isPeriodic = b.mIsPeriodic; Loading Loading @@ -677,6 +700,7 @@ public class JobInfo implements Parcelable { out.writeLong(triggerContentUpdateDelay); out.writeLong(triggerContentMaxDelay); out.writeInt(networkType); out.writeLong(networkBytes); out.writeLong(minLatencyMillis); out.writeLong(maxExecutionDelayMillis); out.writeInt(isPeriodic ? 1 : 0); Loading Loading @@ -810,6 +834,7 @@ public class JobInfo implements Parcelable { // Requirements. private int mConstraintFlags; private int mNetworkType; private long mNetworkBytes = NETWORK_BYTES_UNKNOWN; private ArrayList<TriggerContentUri> mTriggerContentUris; private long mTriggerContentUpdateDelay = -1; private long mTriggerContentMaxDelay = -1; Loading Loading @@ -930,6 +955,43 @@ public class JobInfo implements Parcelable { return this; } /** * Set the estimated size of network traffic that will be performed by * this job, in bytes. * <p> * Apps are encouraged to provide values that are as accurate as * possible, but when the exact size isn't available, an * order-of-magnitude estimate can be provided instead. Here are some * specific examples: * <ul> * <li>A job that is backing up a photo knows the exact size of that * photo, so it should provide that size as the estimate. * <li>A job that refreshes top news stories wouldn't know an exact * size, but if the size is expected to be consistently around 100KB, it * can provide that order-of-magnitude value as the estimate. * <li>A job that synchronizes email could end up using an extreme range * of data, from under 1KB when nothing has changed, to dozens of MB * when there are new emails with attachments. Jobs that cannot provide * reasonable estimates should leave this estimated value undefined. * </ul> * Note that the system may choose to delay jobs with large network * usage estimates when the device has a poor network connection, in * order to save battery. * * @param networkBytes The estimated size of network traffic that will * be performed by this job, in bytes. This value only * reflects the traffic that will be performed by the base * job; if you're using {@link JobWorkItem} then you also * need to define the network traffic used by each work item * when constructing them. * @see JobInfo#getEstimatedNetworkBytes() * @see JobWorkItem#JobWorkItem(android.content.Intent, long) */ public Builder setEstimatedNetworkBytes(@BytesLong long networkBytes) { mNetworkBytes = networkBytes; return this; } /** * Specify that to run this job, the device must be charging (or be a * non-battery-powered device connected to permanent power, such as Android TV Loading Loading @@ -1156,6 +1218,11 @@ public class JobInfo implements Parcelable { throw new IllegalArgumentException("You're trying to build a job with no " + "constraints, this is not allowed."); } // Check that network estimates require network type if (mNetworkBytes > 0 && mNetworkType == NETWORK_TYPE_NONE) { throw new IllegalArgumentException( "Can't provide estimated network usage without requiring a network"); } // Check that a deadline was not set on a periodic job. if (mIsPeriodic) { if (mMaxExecutionDelayMillis != 0L) { Loading
core/java/android/app/job/JobWorkItem.java +35 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.app.job; import android.annotation.BytesLong; import android.content.Intent; import android.os.Parcel; import android.os.Parcelable; Loading @@ -27,6 +28,7 @@ import android.os.Parcelable; */ final public class JobWorkItem implements Parcelable { final Intent mIntent; final long mNetworkBytes; int mDeliveryCount; int mWorkId; Object mGrants; Loading @@ -39,6 +41,22 @@ final public class JobWorkItem implements Parcelable { */ public JobWorkItem(Intent intent) { mIntent = intent; mNetworkBytes = JobInfo.NETWORK_BYTES_UNKNOWN; } /** * Create a new piece of work, which can be submitted to * {@link JobScheduler#enqueue JobScheduler.enqueue}. * * @param intent The general Intent describing this work. * @param networkBytes The estimated size of network traffic that will be * performed by this job work item, in bytes. See * {@link JobInfo.Builder#setEstimatedNetworkBytes(long)} for * details about how to estimate. */ public JobWorkItem(Intent intent, @BytesLong long networkBytes) { mIntent = intent; mNetworkBytes = networkBytes; } /** Loading @@ -48,6 +66,17 @@ final public class JobWorkItem implements Parcelable { return mIntent; } /** * Return the estimated size of network traffic that will be performed by * this job work item, in bytes. * * @return estimated size, or {@link JobInfo#NETWORK_BYTES_UNKNOWN} when * unknown. */ public @BytesLong long getEstimatedNetworkBytes() { return mNetworkBytes; } /** * Return the count of the number of times this work item has been delivered * to the job. The value will be > 1 if it has been redelivered because the job Loading Loading @@ -99,6 +128,10 @@ final public class JobWorkItem implements Parcelable { sb.append(mWorkId); sb.append(" intent="); sb.append(mIntent); if (mNetworkBytes != JobInfo.NETWORK_BYTES_UNKNOWN) { sb.append(" networkBytes="); sb.append(mNetworkBytes); } if (mDeliveryCount != 0) { sb.append(" dcount="); sb.append(mDeliveryCount); Loading @@ -118,6 +151,7 @@ final public class JobWorkItem implements Parcelable { } else { out.writeInt(0); } out.writeLong(mNetworkBytes); out.writeInt(mDeliveryCount); out.writeInt(mWorkId); } Loading @@ -139,6 +173,7 @@ final public class JobWorkItem implements Parcelable { } else { mIntent = null; } mNetworkBytes = in.readLong(); mDeliveryCount = in.readInt(); mWorkId = in.readInt(); } Loading