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

Commit c79a568f authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "API changes for DownloadManager and JobScheduler." into nyc-dev

parents 3cabb2a6 f07c7b9f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4359,6 +4359,8 @@ package android.app {
    method public android.app.DownloadManager.Request setDestinationUri(android.net.Uri);
    method public android.app.DownloadManager.Request setMimeType(java.lang.String);
    method public android.app.DownloadManager.Request setNotificationVisibility(int);
    method public android.app.DownloadManager.Request setRequiresCharging(boolean);
    method public android.app.DownloadManager.Request setRequiresDeviceIdle(boolean);
    method public deprecated android.app.DownloadManager.Request setShowRunningNotification(boolean);
    method public android.app.DownloadManager.Request setTitle(java.lang.CharSequence);
    method public android.app.DownloadManager.Request setVisibleInDownloadsUi(boolean);
@@ -6335,6 +6337,7 @@ package android.app.job {
    field public static final long MAX_BACKOFF_DELAY_MILLIS = 18000000L; // 0x112a880L
    field public static final int NETWORK_TYPE_ANY = 1; // 0x1
    field public static final int NETWORK_TYPE_NONE = 0; // 0x0
    field public static final int NETWORK_TYPE_NOT_ROAMING = 3; // 0x3
    field public static final int NETWORK_TYPE_UNMETERED = 2; // 0x2
  }
@@ -6382,6 +6385,7 @@ package android.app.job {
    method public abstract void cancel(int);
    method public abstract void cancelAll();
    method public abstract java.util.List<android.app.job.JobInfo> getAllPendingJobs();
    method public abstract android.app.job.JobInfo getPendingJob(int);
    method public abstract int schedule(android.app.job.JobInfo);
    field public static final int RESULT_FAILURE = 0; // 0x0
    field public static final int RESULT_SUCCESS = 1; // 0x1
@@ -23757,8 +23761,10 @@ package android.net {
    method public boolean isConnected();
    method public boolean isConnectedOrConnecting();
    method public boolean isFailover();
    method public boolean isMetered();
    method public boolean isRoaming();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.NetworkInfo> CREATOR;
  }
  public static final class NetworkInfo.DetailedState extends java.lang.Enum {
+6 −0
Original line number Diff line number Diff line
@@ -4502,6 +4502,8 @@ package android.app {
    method public android.app.DownloadManager.Request setDestinationUri(android.net.Uri);
    method public android.app.DownloadManager.Request setMimeType(java.lang.String);
    method public android.app.DownloadManager.Request setNotificationVisibility(int);
    method public android.app.DownloadManager.Request setRequiresCharging(boolean);
    method public android.app.DownloadManager.Request setRequiresDeviceIdle(boolean);
    method public deprecated android.app.DownloadManager.Request setShowRunningNotification(boolean);
    method public android.app.DownloadManager.Request setTitle(java.lang.CharSequence);
    method public android.app.DownloadManager.Request setVisibleInDownloadsUi(boolean);
@@ -6614,6 +6616,7 @@ package android.app.job {
    field public static final long MAX_BACKOFF_DELAY_MILLIS = 18000000L; // 0x112a880L
    field public static final int NETWORK_TYPE_ANY = 1; // 0x1
    field public static final int NETWORK_TYPE_NONE = 0; // 0x0
    field public static final int NETWORK_TYPE_NOT_ROAMING = 3; // 0x3
    field public static final int NETWORK_TYPE_UNMETERED = 2; // 0x2
  }
@@ -6661,6 +6664,7 @@ package android.app.job {
    method public abstract void cancel(int);
    method public abstract void cancelAll();
    method public abstract java.util.List<android.app.job.JobInfo> getAllPendingJobs();
    method public abstract android.app.job.JobInfo getPendingJob(int);
    method public abstract int schedule(android.app.job.JobInfo);
    field public static final int RESULT_FAILURE = 0; // 0x0
    field public static final int RESULT_SUCCESS = 1; // 0x1
@@ -25584,8 +25588,10 @@ package android.net {
    method public boolean isConnected();
    method public boolean isConnectedOrConnecting();
    method public boolean isFailover();
    method public boolean isMetered();
    method public boolean isRoaming();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.NetworkInfo> CREATOR;
  }
  public static final class NetworkInfo.DetailedState extends java.lang.Enum {
+6 −0
Original line number Diff line number Diff line
@@ -4359,6 +4359,8 @@ package android.app {
    method public android.app.DownloadManager.Request setDestinationUri(android.net.Uri);
    method public android.app.DownloadManager.Request setMimeType(java.lang.String);
    method public android.app.DownloadManager.Request setNotificationVisibility(int);
    method public android.app.DownloadManager.Request setRequiresCharging(boolean);
    method public android.app.DownloadManager.Request setRequiresDeviceIdle(boolean);
    method public deprecated android.app.DownloadManager.Request setShowRunningNotification(boolean);
    method public android.app.DownloadManager.Request setTitle(java.lang.CharSequence);
    method public android.app.DownloadManager.Request setVisibleInDownloadsUi(boolean);
@@ -6339,6 +6341,7 @@ package android.app.job {
    field public static final long MAX_BACKOFF_DELAY_MILLIS = 18000000L; // 0x112a880L
    field public static final int NETWORK_TYPE_ANY = 1; // 0x1
    field public static final int NETWORK_TYPE_NONE = 0; // 0x0
    field public static final int NETWORK_TYPE_NOT_ROAMING = 3; // 0x3
    field public static final int NETWORK_TYPE_UNMETERED = 2; // 0x2
  }
@@ -6386,6 +6389,7 @@ package android.app.job {
    method public abstract void cancel(int);
    method public abstract void cancelAll();
    method public abstract java.util.List<android.app.job.JobInfo> getAllPendingJobs();
    method public abstract android.app.job.JobInfo getPendingJob(int);
    method public abstract int schedule(android.app.job.JobInfo);
    field public static final int RESULT_FAILURE = 0; // 0x0
    field public static final int RESULT_SUCCESS = 1; // 0x1
@@ -23825,8 +23829,10 @@ package android.net {
    method public boolean isConnected();
    method public boolean isConnectedOrConnecting();
    method public boolean isFailover();
    method public boolean isMetered();
    method public boolean isRoaming();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.NetworkInfo> CREATOR;
  }
  public static final class NetworkInfo.DetailedState extends java.lang.Enum {
+58 −10
Original line number Diff line number Diff line
@@ -370,6 +370,7 @@ public class DownloadManager {
         * {@link ConnectivityManager#TYPE_BLUETOOTH}.
         * @hide
         */
        @Deprecated
        public static final int NETWORK_BLUETOOTH = 1 << 2;

        private Uri mUri;
@@ -381,6 +382,7 @@ public class DownloadManager {
        private int mAllowedNetworkTypes = ~0; // default to all network types allowed
        private boolean mRoamingAllowed = true;
        private boolean mMeteredAllowed = true;
        private int mFlags = 0;
        private boolean mIsVisibleInDownloadsUi = true;
        private boolean mScannable = false;
        private boolean mUseSystemCache = false;
@@ -669,6 +671,10 @@ public class DownloadManager {
         * By default, all network types are allowed. Consider using
         * {@link #setAllowedOverMetered(boolean)} instead, since it's more
         * flexible.
         * <p>
         * As of {@link android.os.Build.VERSION_CODES#N}, setting only the
         * {@link #NETWORK_WIFI} flag here is equivalent to calling
         * {@link #setAllowedOverMetered(boolean)} with {@code false}.
         *
         * @param flags any combination of the NETWORK_* bit flags.
         * @return this object
@@ -700,6 +706,42 @@ public class DownloadManager {
            return this;
        }

        /**
         * Specify that to run this download, the device needs to be plugged in.
         * This defaults to false.
         *
         * @param requiresCharging Whether or not the device is plugged in.
         * @see android.app.job.JobInfo.Builder#setRequiresCharging(boolean)
         */
        public Request setRequiresCharging(boolean requiresCharging) {
            if (requiresCharging) {
                mFlags |= Downloads.Impl.FLAG_REQUIRES_CHARGING;
            } else {
                mFlags &= ~Downloads.Impl.FLAG_REQUIRES_CHARGING;
            }
            return this;
        }

        /**
         * Specify that to run, the download needs the device to be in idle
         * mode. This defaults to false.
         * <p>
         * Idle mode is a loose definition provided by the system, which means
         * that the device is not in use, and has not been in use for some time.
         *
         * @param requiresDeviceIdle Whether or not the device need be within an
         *            idle maintenance window.
         * @see android.app.job.JobInfo.Builder#setRequiresDeviceIdle(boolean)
         */
        public Request setRequiresDeviceIdle(boolean requiresDeviceIdle) {
            if (requiresDeviceIdle) {
                mFlags |= Downloads.Impl.FLAG_REQUIRES_DEVICE_IDLE;
            } else {
                mFlags &= ~Downloads.Impl.FLAG_REQUIRES_DEVICE_IDLE;
            }
            return this;
        }

        /**
         * Set whether this download should be displayed in the system's Downloads UI. True by
         * default.
@@ -746,6 +788,7 @@ public class DownloadManager {
            values.put(Downloads.Impl.COLUMN_ALLOWED_NETWORK_TYPES, mAllowedNetworkTypes);
            values.put(Downloads.Impl.COLUMN_ALLOW_ROAMING, mRoamingAllowed);
            values.put(Downloads.Impl.COLUMN_ALLOW_METERED, mMeteredAllowed);
            values.put(Downloads.Impl.COLUMN_FLAGS, mFlags);
            values.put(Downloads.Impl.COLUMN_IS_VISIBLE_IN_DOWNLOADS_UI, mIsVisibleInDownloadsUi);

            return values;
@@ -983,16 +1026,7 @@ public class DownloadManager {
            // called with nothing to remove!
            throw new IllegalArgumentException("input param 'ids' can't be null");
        }
        ContentValues values = new ContentValues();
        values.put(Downloads.Impl.COLUMN_DELETED, 1);
        // if only one id is passed in, then include it in the uri itself.
        // this will eliminate a full database scan in the download service.
        if (ids.length == 1) {
            return mResolver.update(ContentUris.withAppendedId(mBaseUri, ids[0]), values,
                    null, null);
        } 
        return mResolver.update(mBaseUri, values, getWhereClauseForIds(ids),
                getWhereArgsForIds(ids));
        return mResolver.delete(mBaseUri, getWhereClauseForIds(ids), getWhereArgsForIds(ids));
    }

    /**
@@ -1120,6 +1154,20 @@ public class DownloadManager {
        mResolver.update(mBaseUri, values, getWhereClauseForIds(ids), getWhereArgsForIds(ids));
    }

    /**
     * Force the given downloads to proceed even if their size is larger than
     * {@link #getMaxBytesOverMobile(Context)}.
     *
     * @hide
     */
    public void forceDownload(long... ids) {
        ContentValues values = new ContentValues();
        values.put(Downloads.Impl.COLUMN_STATUS, Downloads.Impl.STATUS_PENDING);
        values.put(Downloads.Impl.COLUMN_CONTROL, Downloads.Impl.CONTROL_RUN);
        values.put(Downloads.Impl.COLUMN_BYPASS_RECOMMENDED_SIZE_LIMIT, 1);
        mResolver.update(mBaseUri, values, getWhereClauseForIds(ids), getWhereArgsForIds(ids));
    }

    /**
     * Returns maximum size, in bytes, of downloads that may go over a mobile connection; or null if
     * there's no limit
+9 −0
Original line number Diff line number Diff line
@@ -78,4 +78,13 @@ public class JobSchedulerImpl extends JobScheduler {
            return null;
        }
    }

    @Override
    public JobInfo getPendingJob(int jobId) {
        try {
            return mBinder.getPendingJob(jobId);
        } catch (RemoteException e) {
            return null;
        }
    }
}
Loading