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

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

Merge "Remove deprecated & removed JobInfo methods."

parents f4ae97f0 316b1414
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -32,24 +32,6 @@ package android.app.admin {

}

package android.app.job {

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

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

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

}

package android.app.slice {

  public final class Slice implements android.os.Parcelable {
+0 −38
Original line number Diff line number Diff line
@@ -480,25 +480,6 @@ public class JobInfo implements Parcelable {
        return networkRequest;
    }

    /**
     * @deprecated replaced by {@link #getEstimatedNetworkDownloadBytes()} and
     *             {@link #getEstimatedNetworkUploadBytes()}.
     * @removed
     */
    @Deprecated
    public @BytesLong long getEstimatedNetworkBytes() {
        if (networkDownloadBytes == NETWORK_BYTES_UNKNOWN
                && networkUploadBytes == NETWORK_BYTES_UNKNOWN) {
            return NETWORK_BYTES_UNKNOWN;
        } else if (networkDownloadBytes == NETWORK_BYTES_UNKNOWN) {
            return networkUploadBytes;
        } else if (networkUploadBytes == NETWORK_BYTES_UNKNOWN) {
            return networkDownloadBytes;
        } else {
            return networkDownloadBytes + networkUploadBytes;
        }
    }

    /**
     * Return the estimated size of download traffic that will be performed by
     * this job, in bytes.
@@ -1177,16 +1158,6 @@ public class JobInfo implements Parcelable {
            return this;
        }

        /**
         * @deprecated replaced by
         *             {@link #setEstimatedNetworkBytes(long, long)}.
         * @removed
         */
        @Deprecated
        public Builder setEstimatedNetworkBytes(@BytesLong long networkBytes) {
            return setEstimatedNetworkBytes(networkBytes, NETWORK_BYTES_UNKNOWN);
        }

        /**
         * Set the estimated size of network traffic that will be performed by
         * this job, in bytes.
@@ -1496,15 +1467,6 @@ public class JobInfo implements Parcelable {
            return this;
        }

        /**
         * @removed
         * @deprecated replaced with {@link #setPrefetch(boolean)}
         */
        @Deprecated
        public Builder setIsPrefetch(boolean isPrefetch) {
            return setPrefetch(isPrefetch);
        }

        /**
         * Setting this to true indicates that this job is designed to prefetch
         * content that will make a material improvement to the experience of
+0 −28
Original line number Diff line number Diff line
@@ -54,15 +54,6 @@ final public class JobWorkItem implements Parcelable {
        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}.
@@ -89,25 +80,6 @@ final public class JobWorkItem implements Parcelable {
        return mIntent;
    }

    /**
     * @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.
+11 −1
Original line number Diff line number Diff line
@@ -833,7 +833,15 @@ message JobStatusDumpProto {

        optional .android.net.NetworkRequestProto required_network = 18;

        optional int64 total_network_bytes = 19;
        reserved 19; // total_network_bytes

        // The estimated download bytes of the job. Will have a value of
        // {@link JobInfo.NETWORK_BYTES_UNKNOWN} if any part of the job download is unknown.
        optional int64 total_network_download_bytes = 25;

        // The estimated upload bytes of the job. Will have a value of
        // {@link JobInfo.NETWORK_BYTES_UNKNOWN} if any part of the job upload is unknown.
        optional int64 total_network_upload_bytes = 26;

        optional int64 min_latency_ms = 20;
        optional int64 max_execution_delay_ms = 21;
@@ -852,6 +860,8 @@ message JobStatusDumpProto {

        optional bool has_early_constraint = 23;
        optional bool has_late_constraint = 24;

        // Next tag: 27
    }
    optional JobInfo job_info = 6;

+32 −23
Original line number Diff line number Diff line
@@ -29,13 +29,13 @@ import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkPolicyManager;
import android.net.NetworkRequest;
import android.net.TrafficStats;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.UserHandle;
import android.text.format.DateUtils;
import android.util.ArraySet;
import android.util.DataUnit;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
@@ -321,33 +321,42 @@ public final class ConnectivityController extends StateController implements
    @SuppressWarnings("unused")
    private static boolean isInsane(JobStatus jobStatus, Network network,
            NetworkCapabilities capabilities, Constants constants) {
        final long estimatedBytes = jobStatus.getEstimatedNetworkBytes();
        if (estimatedBytes == JobInfo.NETWORK_BYTES_UNKNOWN) {
            // We don't know how large the job is; cross our fingers!
            return false;
        final long downloadBytes = jobStatus.getEstimatedNetworkDownloadBytes();
        if (downloadBytes != JobInfo.NETWORK_BYTES_UNKNOWN) {
            final long bandwidth = capabilities.getLinkDownstreamBandwidthKbps();
            // If we don't know the bandwidth, all we can do is hope the job finishes in time.
            if (bandwidth != LINK_BANDWIDTH_UNSPECIFIED) {
                // Divide by 8 to convert bits to bytes.
                final long estimatedMillis = ((downloadBytes * DateUtils.SECOND_IN_MILLIS)
                        / (DataUnit.KIBIBYTES.toBytes(bandwidth) / 8));
                if (estimatedMillis > JobServiceContext.EXECUTING_TIMESLICE_MILLIS) {
                    // If we'd never finish before the timeout, we'd be insane!
                    Slog.w(TAG, "Estimated " + downloadBytes + " download bytes over " + bandwidth
                            + " kbps network would take " + estimatedMillis + "ms; that's insane!");
                    return true;
                }
            }

        // We don't ask developers to differentiate between upstream/downstream
        // in their size estimates, so test against the slowest link direction.
        final long slowest = NetworkCapabilities.minBandwidth(
                capabilities.getLinkDownstreamBandwidthKbps(),
                capabilities.getLinkUpstreamBandwidthKbps());
        if (slowest == LINK_BANDWIDTH_UNSPECIFIED) {
            // We don't know what the network is like; cross our fingers!
            return false;
        }

        final long estimatedMillis = ((estimatedBytes * DateUtils.SECOND_IN_MILLIS)
                / (slowest * TrafficStats.KB_IN_BYTES / 8));
        final long uploadBytes = jobStatus.getEstimatedNetworkUploadBytes();
        if (uploadBytes != JobInfo.NETWORK_BYTES_UNKNOWN) {
            final long bandwidth = capabilities.getLinkUpstreamBandwidthKbps();
            // If we don't know the bandwidth, all we can do is hope the job finishes in time.
            if (bandwidth != LINK_BANDWIDTH_UNSPECIFIED) {
                // Divide by 8 to convert bits to bytes.
                final long estimatedMillis = ((uploadBytes * DateUtils.SECOND_IN_MILLIS)
                        / (DataUnit.KIBIBYTES.toBytes(bandwidth) / 8));
                if (estimatedMillis > JobServiceContext.EXECUTING_TIMESLICE_MILLIS) {
                    // If we'd never finish before the timeout, we'd be insane!
            Slog.w(TAG, "Estimated " + estimatedBytes + " bytes over " + slowest
                    Slog.w(TAG, "Estimated " + uploadBytes + " upload bytes over " + bandwidth
                            + " kbps network would take " + estimatedMillis + "ms; that's insane!");
                    return true;
        } else {
            return false;
                }
            }
        }

        return false;
    }

    @SuppressWarnings("unused")
    private static boolean isCongestionDelayed(JobStatus jobStatus, Network network,
Loading