Merge "Expose LRJ related APIs."

This commit is contained in:
TreeHugger Robot
2022-12-17 03:39:11 +00:00
committed by Android (Google) Code Review
5 changed files with 21 additions and 32 deletions

View File

@@ -739,7 +739,6 @@ public class JobInfo implements Parcelable {
/**
* @see JobInfo.Builder#setDataTransfer(boolean)
* @hide
*/
public boolean isDataTransfer() {
return (flags & FLAG_DATA_TRANSFER) != 0;
@@ -747,7 +746,6 @@ public class JobInfo implements Parcelable {
/**
* @see JobInfo.Builder#setUserInitiated(boolean)
* @hide
*/
public boolean isUserInitiated() {
return (flags & FLAG_USER_INITIATED) != 0;
@@ -1445,6 +1443,7 @@ public class JobInfo implements Parcelable {
* reasonable estimates should use the sentinel value
* {@link JobInfo#NETWORK_BYTES_UNKNOWN}.
* </ul>
* TODO(255371817): update documentation to reflect how this data will be used
* 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 and possible network costs.
@@ -1852,11 +1851,6 @@ public class JobInfo implements Parcelable {
* being transferred is potentially very large and can take a long time to complete.
*
* <p>
* The app must hold the {@link android.Manifest.permission#RUN_LONG_JOBS} permission to
* use this API. JobScheduler will throw a {@link SecurityException} if an app without the
* permission granted attempts to schedule a data transfer job.
*
* <p>
* You must provide an estimate of the payload size via
* {@link #setEstimatedNetworkBytes(long, long)} when scheduling the job or use
* {@link JobService#updateEstimatedNetworkBytes(JobParameters, long, long)} or
@@ -1873,7 +1867,6 @@ public class JobInfo implements Parcelable {
* {@link JobWorkItem JobWorkItems} along with {@link #setDataTransfer(boolean)}.
*
* @see JobInfo#isDataTransfer()
* @hide
*/
@NonNull
public Builder setDataTransfer(boolean dataTransfer) {
@@ -1903,12 +1896,17 @@ public class JobInfo implements Parcelable {
* shown in the Task Manager when running.
*
* <p>
* If the app doesn't hold the {@link android.Manifest.permission#RUN_LONG_JOBS} permission
* when scheduling a user-initiated job, JobScheduler will throw a
* {@link SecurityException}.
*
* <p>
* These jobs will not be subject to quotas and will be started immediately once scheduled
* if all constraints are met and the device system health allows for additional tasks.
*
* @see JobInfo#isUserInitiated()
* @hide
*/
@RequiresPermission(android.Manifest.permission.RUN_LONG_JOBS)
@NonNull
public Builder setUserInitiated(boolean userInitiated) {
if (userInitiated) {

View File

@@ -403,7 +403,6 @@ public class JobParameters implements Parcelable {
* {@link android.Manifest.permission#RUN_LONG_JOBS} permission.
*
* @see JobInfo.Builder#setUserInitiated(boolean)
* @hide
*/
public boolean isUserInitiatedJob() {
return mIsUserInitiated;

View File

@@ -232,16 +232,8 @@ public abstract class JobService extends Service {
public abstract boolean onStopJob(JobParameters params);
/**
* Update how much data this job will transfer. This method can
* be called multiple times within the first 30 seconds after
* {@link #onStartJob(JobParameters)} has been called. Only
* one call will be heeded after that time has passed.
* Update the amount of data this job is estimated to transfer after the job has started.
*
* This method (or an overload) must be called within the first
* 30 seconds for a data transfer job if a payload size estimate
* was not provided at the time of scheduling.
*
* @hide
* @see JobInfo.Builder#setEstimatedNetworkBytes(long, long)
*/
public final void updateEstimatedNetworkBytes(@NonNull JobParameters params,
@@ -250,16 +242,9 @@ public abstract class JobService extends Service {
}
/**
* Update how much data will transfer for the JobWorkItem. This
* method can be called multiple times within the first 30 seconds
* after {@link #onStartJob(JobParameters)} has been called.
* Only one call will be heeded after that time has passed.
* Update the amount of data this JobWorkItem is estimated to transfer after the job has
* started.
*
* This method (or an overload) must be called within the first
* 30 seconds for a data transfer job if a payload size estimate
* was not provided at the time of scheduling.
*
* @hide
* @see JobInfo.Builder#setEstimatedNetworkBytes(long, long)
*/
public final void updateEstimatedNetworkBytes(@NonNull JobParameters params,
@@ -270,7 +255,6 @@ public abstract class JobService extends Service {
/**
* Tell JobScheduler how much data has successfully been transferred for the data transfer job.
* @hide
*/
public final void updateTransferredNetworkBytes(@NonNull JobParameters params,
@BytesLong long transferredDownloadBytes, @BytesLong long transferredUploadBytes) {
@@ -281,7 +265,6 @@ public abstract class JobService extends Service {
/**
* Tell JobScheduler how much data has been transferred for the data transfer
* {@link JobWorkItem}.
* @hide
*/
public final void updateTransferredNetworkBytes(@NonNull JobParameters params,
@NonNull JobWorkItem item,
@@ -428,7 +411,6 @@ public abstract class JobService extends Service {
* Notification)}.
* @param notification The notification to be displayed.
* @param jobEndNotificationPolicy The policy to apply to the notification when the job stops.
* @hide
*/
public final void setNotification(@NonNull JobParameters params, int notificationId,
@NonNull Notification notification,

View File

@@ -3885,7 +3885,7 @@ public class JobSchedulerService extends com.android.server.SystemService
final int callingUid = Binder.getCallingUid();
if (callingUid != uid && !UserHandle.isCore(callingUid)) {
throw new SecurityException("Uid " + callingUid
+ " cannot query canRunLongJobs for package " + packageName);
+ " cannot query hasRunLongJobsPermission for package " + packageName);
}
return checkRunLongJobsPermission(uid, packageName);

View File

@@ -8389,6 +8389,7 @@ package android.app.job {
method public long getTriggerContentMaxDelay();
method public long getTriggerContentUpdateDelay();
method @Nullable public android.app.job.JobInfo.TriggerContentUri[] getTriggerContentUris();
method public boolean isDataTransfer();
method public boolean isExpedited();
method public boolean isImportantWhileForeground();
method public boolean isPeriodic();
@@ -8398,6 +8399,7 @@ package android.app.job {
method public boolean isRequireCharging();
method public boolean isRequireDeviceIdle();
method public boolean isRequireStorageNotLow();
method public boolean isUserInitiated();
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
@@ -8424,6 +8426,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(@Nullable android.content.ClipData, int);
method @NonNull public android.app.job.JobInfo.Builder setDataTransfer(boolean);
method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long, long);
method @NonNull public android.app.job.JobInfo.Builder setExpedited(boolean);
method public android.app.job.JobInfo.Builder setExtras(@NonNull android.os.PersistableBundle);
@@ -8445,6 +8448,7 @@ package android.app.job {
method public android.app.job.JobInfo.Builder setTransientExtras(@NonNull android.os.Bundle);
method public android.app.job.JobInfo.Builder setTriggerContentMaxDelay(long);
method public android.app.job.JobInfo.Builder setTriggerContentUpdateDelay(long);
method @NonNull @RequiresPermission(android.Manifest.permission.RUN_LONG_JOBS) public android.app.job.JobInfo.Builder setUserInitiated(boolean);
}
public static final class JobInfo.TriggerContentUri implements android.os.Parcelable {
@@ -8472,6 +8476,7 @@ package android.app.job {
method @Nullable public android.net.Uri[] getTriggeredContentUris();
method public boolean isExpeditedJob();
method public boolean isOverrideDeadlineExpired();
method public boolean isUserInitiatedJob();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.app.job.JobParameters> CREATOR;
field public static final int STOP_REASON_APP_STANDBY = 12; // 0xc
@@ -8530,6 +8535,11 @@ package android.app.job {
method public final android.os.IBinder onBind(android.content.Intent);
method public abstract boolean onStartJob(android.app.job.JobParameters);
method public abstract boolean onStopJob(android.app.job.JobParameters);
method public final void setNotification(@NonNull android.app.job.JobParameters, int, @NonNull android.app.Notification, int);
method public final void updateEstimatedNetworkBytes(@NonNull android.app.job.JobParameters, long, long);
method public final void updateEstimatedNetworkBytes(@NonNull android.app.job.JobParameters, @NonNull android.app.job.JobWorkItem, long, long);
method public final void updateTransferredNetworkBytes(@NonNull android.app.job.JobParameters, long, long);
method public final void updateTransferredNetworkBytes(@NonNull android.app.job.JobParameters, @NonNull android.app.job.JobWorkItem, long, long);
field public static final String PERMISSION_BIND = "android.permission.BIND_JOB_SERVICE";
}