diff --git a/apex/jobscheduler/framework/java/android/app/job/JobInfo.java b/apex/jobscheduler/framework/java/android/app/job/JobInfo.java index 19ab5bcc9967d..deb97a5873ab9 100644 --- a/apex/jobscheduler/framework/java/android/app/job/JobInfo.java +++ b/apex/jobscheduler/framework/java/android/app/job/JobInfo.java @@ -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}. * + * 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. * *
- * 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. - * - *
* 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. * *
+ * 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}. + * + *
* 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) {
diff --git a/apex/jobscheduler/framework/java/android/app/job/JobParameters.java b/apex/jobscheduler/framework/java/android/app/job/JobParameters.java
index 1720534e1183c..a5a7f93137d66 100644
--- a/apex/jobscheduler/framework/java/android/app/job/JobParameters.java
+++ b/apex/jobscheduler/framework/java/android/app/job/JobParameters.java
@@ -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;
diff --git a/apex/jobscheduler/framework/java/android/app/job/JobService.java b/apex/jobscheduler/framework/java/android/app/job/JobService.java
index 898557dfb4f96..449c316c1c65c 100644
--- a/apex/jobscheduler/framework/java/android/app/job/JobService.java
+++ b/apex/jobscheduler/framework/java/android/app/job/JobService.java
@@ -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,
diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
index f6aba74b676cf..1898e499f7e51 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
@@ -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);
diff --git a/core/api/current.txt b/core/api/current.txt
index b94fa9e8ca971..5df8b81ae1f23 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -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