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

Commit a9975804 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "API council requested tweaks to JobInfo." into pi-dev

parents 87c24a65 8474ca02
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -7041,7 +7041,8 @@ package android.app.job {
    method public int getBackoffPolicy();
    method public android.content.ClipData getClipData();
    method public int getClipGrantFlags();
    method public long getEstimatedNetworkBytes();
    method public long getEstimatedNetworkDownloadBytes();
    method public long getEstimatedNetworkUploadBytes();
    method public android.os.PersistableBundle getExtras();
    method public long getFlexMillis();
    method public int getId();
@@ -7058,8 +7059,10 @@ package android.app.job {
    method public long getTriggerContentMaxDelay();
    method public long getTriggerContentUpdateDelay();
    method public android.app.job.JobInfo.TriggerContentUri[] getTriggerContentUris();
    method public boolean isImportantWhileForeground();
    method public boolean isPeriodic();
    method public boolean isPersisted();
    method public boolean isPrefetch();
    method public boolean isRequireBatteryNotLow();
    method public boolean isRequireCharging();
    method public boolean isRequireDeviceIdle();
@@ -7085,15 +7088,15 @@ 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 setEstimatedNetworkBytes(long, long);
    method public android.app.job.JobInfo.Builder setExtras(android.os.PersistableBundle);
    method public android.app.job.JobInfo.Builder setImportantWhileForeground(boolean);
    method public android.app.job.JobInfo.Builder setIsPrefetch(boolean);
    method public android.app.job.JobInfo.Builder setMinimumLatency(long);
    method public android.app.job.JobInfo.Builder setOverrideDeadline(long);
    method public android.app.job.JobInfo.Builder setPeriodic(long);
    method public android.app.job.JobInfo.Builder setPeriodic(long, long);
    method public android.app.job.JobInfo.Builder setPersisted(boolean);
    method public android.app.job.JobInfo.Builder setPrefetch(boolean);
    method public android.app.job.JobInfo.Builder setRequiredNetwork(android.net.NetworkRequest);
    method public android.app.job.JobInfo.Builder setRequiredNetworkType(int);
    method public android.app.job.JobInfo.Builder setRequiresBatteryNotLow(boolean);
@@ -7163,10 +7166,11 @@ 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);
    ctor public JobWorkItem(android.content.Intent, long, long);
    method public int describeContents();
    method public int getDeliveryCount();
    method public long getEstimatedNetworkBytes();
    method public long getEstimatedNetworkDownloadBytes();
    method public long getEstimatedNetworkUploadBytes();
    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;
+18 −0
Original line number Diff line number Diff line
@@ -54,6 +54,24 @@ package android.app.admin {

}

package android.app.job {

  public class JobInfo implements android.os.Parcelable {
    method public deprecated long getEstimatedNetworkBytes();
  }

  public static final class JobInfo.Builder {
    method public deprecated android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long);
    method public deprecated android.app.job.JobInfo.Builder setIsPrefetch(boolean);
  }

  public final class JobWorkItem implements android.os.Parcelable {
    ctor public deprecated JobWorkItem(android.content.Intent, long);
    method public deprecated long getEstimatedNetworkBytes();
  }

}

package android.app.usage {

  public final class StorageStats implements android.os.Parcelable {
+153 −47

File changed.

Preview size limit exceeded, changes collapsed.

+71 −18
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.app.job;

import static android.app.job.JobInfo.NETWORK_BYTES_UNKNOWN;

import android.annotation.BytesLong;
import android.content.Intent;
import android.os.Parcel;
@@ -28,7 +30,8 @@ import android.os.Parcelable;
 */
final public class JobWorkItem implements Parcelable {
    final Intent mIntent;
    final long mNetworkBytes;
    final long mNetworkDownloadBytes;
    final long mNetworkUploadBytes;
    int mDeliveryCount;
    int mWorkId;
    Object mGrants;
@@ -41,22 +44,36 @@ final public class JobWorkItem implements Parcelable {
     */
    public JobWorkItem(Intent intent) {
        mIntent = intent;
        mNetworkBytes = JobInfo.NETWORK_BYTES_UNKNOWN;
        mNetworkDownloadBytes = NETWORK_BYTES_UNKNOWN;
        mNetworkUploadBytes = NETWORK_BYTES_UNKNOWN;
    }

    /**
     * @deprecated replaced by {@link #JobWorkItem(Intent, long, long)}
     * @removed
     */
    @Deprecated
    public JobWorkItem(Intent intent, @BytesLong long networkBytes) {
        this(intent, networkBytes, NETWORK_BYTES_UNKNOWN);
    }

    /**
     * Create a new piece of work, which can be submitted to
     * {@link JobScheduler#enqueue JobScheduler.enqueue}.
     * <p>
     * See {@link JobInfo.Builder#setEstimatedNetworkBytes(long, long)} for
     * details about how to estimate network traffic.
     *
     * @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.
     * @param downloadBytes The estimated size of network traffic that will be
     *            downloaded by this job work item, in bytes.
     * @param uploadBytes The estimated size of network traffic that will be
     *            uploaded by this job work item, in bytes.
     */
    public JobWorkItem(Intent intent, @BytesLong long networkBytes) {
    public JobWorkItem(Intent intent, @BytesLong long downloadBytes, @BytesLong long uploadBytes) {
        mIntent = intent;
        mNetworkBytes = networkBytes;
        mNetworkDownloadBytes = downloadBytes;
        mNetworkUploadBytes = uploadBytes;
    }

    /**
@@ -67,14 +84,44 @@ final public class JobWorkItem implements Parcelable {
    }

    /**
     * Return the estimated size of network traffic that will be performed by
     * @deprecated replaced by {@link #getEstimatedNetworkDownloadBytes()} and
     *             {@link #getEstimatedNetworkUploadBytes()}.
     * @removed
     */
    @Deprecated
    public @BytesLong long getEstimatedNetworkBytes() {
        if (mNetworkDownloadBytes == NETWORK_BYTES_UNKNOWN
                && mNetworkUploadBytes == NETWORK_BYTES_UNKNOWN) {
            return NETWORK_BYTES_UNKNOWN;
        } else if (mNetworkDownloadBytes == NETWORK_BYTES_UNKNOWN) {
            return mNetworkUploadBytes;
        } else if (mNetworkUploadBytes == NETWORK_BYTES_UNKNOWN) {
            return mNetworkDownloadBytes;
        } else {
            return mNetworkDownloadBytes + mNetworkUploadBytes;
        }
    }

    /**
     * Return the estimated size of download traffic that will be performed by
     * this job, in bytes.
     *
     * @return Estimated size of download traffic, or
     *         {@link JobInfo#NETWORK_BYTES_UNKNOWN} when unknown.
     */
    public @BytesLong long getEstimatedNetworkDownloadBytes() {
        return mNetworkDownloadBytes;
    }

    /**
     * Return the estimated size of upload traffic that will be performed by
     * this job work item, in bytes.
     *
     * @return estimated size, or {@link JobInfo#NETWORK_BYTES_UNKNOWN} when
     *         unknown.
     * @return Estimated size of upload traffic, or
     *         {@link JobInfo#NETWORK_BYTES_UNKNOWN} when unknown.
     */
    public @BytesLong long getEstimatedNetworkBytes() {
        return mNetworkBytes;
    public @BytesLong long getEstimatedNetworkUploadBytes() {
        return mNetworkUploadBytes;
    }

    /**
@@ -128,9 +175,13 @@ 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 (mNetworkDownloadBytes != NETWORK_BYTES_UNKNOWN) {
            sb.append(" downloadBytes=");
            sb.append(mNetworkDownloadBytes);
        }
        if (mNetworkUploadBytes != NETWORK_BYTES_UNKNOWN) {
            sb.append(" uploadBytes=");
            sb.append(mNetworkUploadBytes);
        }
        if (mDeliveryCount != 0) {
            sb.append(" dcount=");
@@ -151,7 +202,8 @@ final public class JobWorkItem implements Parcelable {
        } else {
            out.writeInt(0);
        }
        out.writeLong(mNetworkBytes);
        out.writeLong(mNetworkDownloadBytes);
        out.writeLong(mNetworkUploadBytes);
        out.writeInt(mDeliveryCount);
        out.writeInt(mWorkId);
    }
@@ -173,7 +225,8 @@ final public class JobWorkItem implements Parcelable {
        } else {
            mIntent = null;
        }
        mNetworkBytes = in.readLong();
        mNetworkDownloadBytes = in.readLong();
        mNetworkUploadBytes = in.readLong();
        mDeliveryCount = in.readInt();
        mWorkId = in.readInt();
    }
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ public final class ConnectivityController extends StateController implements
    private static boolean isRelaxedSatisfied(JobStatus jobStatus, Network network,
            NetworkCapabilities capabilities, Constants constants) {
        // Only consider doing this for prefetching jobs
        if ((jobStatus.getJob().getFlags() & JobInfo.FLAG_IS_PREFETCH) == 0) {
        if (!jobStatus.getJob().isPrefetch()) {
            return false;
        }