Merge "Expose job namespace APIs."

This commit is contained in:
TreeHugger Robot
2023-01-13 02:52:51 +00:00
committed by Android (Google) Code Review
3 changed files with 14 additions and 6 deletions

View File

@@ -330,7 +330,6 @@ public class JobParameters implements Parcelable {
* @see JobScheduler#forNamespace(String)
* @return The namespace this job was scheduled in. Will be {@code null} if there was no
* explicit namespace set and this job is therefore in the default namespace.
* @hide
*/
@Nullable
public String getJobNamespace() {

View File

@@ -271,7 +271,6 @@ public abstract class JobScheduler {
* but will instead create or update the job inside the current namespace. A JobScheduler
* instance dedicated to a namespace must be used to schedule or update jobs in that namespace.
* @see #getNamespace()
* @hide
*/
@NonNull
public JobScheduler forNamespace(@NonNull String namespace) {
@@ -282,7 +281,6 @@ public abstract class JobScheduler {
* Get the namespace this JobScheduler instance is operating in. A {@code null} value means
* that the app has not specified a namespace for this instance, and it is therefore using the
* default namespace.
* @hide
*/
@Nullable
public String getNamespace() {
@@ -395,14 +393,21 @@ public abstract class JobScheduler {
public abstract void cancel(int jobId);
/**
* Cancel <em>all</em> jobs that have been scheduled by the calling application.
* Cancel all jobs that have been scheduled in the current namespace by the
* calling application.
*
* <p>
* Starting with Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, this
* will only cancel within the current namespace. If a namespace hasn't been explicitly set
* with {@link #forNamespace(String)}, then this will cancel jobs in the default namespace.
* To cancel all jobs scheduled by the application,
* use {@link #cancelInAllNamespaces()} instead.
*/
public abstract void cancelAll();
/**
* Cancel <em>all</em> jobs that have been scheduled by the calling application, regardless of
* namespace.
* @hide
*/
public void cancelInAllNamespaces() {
throw new RuntimeException("Not implemented. Must override in a subclass.");
@@ -424,7 +429,6 @@ public abstract class JobScheduler {
* If a namespace hasn't been explicitly set with {@link #forNamespace(String)},
* then this will return jobs in the default namespace.
* This includes jobs that are currently started as well as those that are still waiting to run.
* @hide
*/
@NonNull
public Map<String, List<JobInfo>> getPendingJobsInAllNamespaces() {

View File

@@ -8563,6 +8563,7 @@ package android.app.job {
method public int getClipGrantFlags();
method @NonNull public android.os.PersistableBundle getExtras();
method public int getJobId();
method @Nullable public String getJobNamespace();
method @Nullable public android.net.Network getNetwork();
method public int getStopReason();
method @NonNull public android.os.Bundle getTransientExtras();
@@ -8596,10 +8597,14 @@ package android.app.job {
method public boolean canRunLongJobs();
method public abstract void cancel(int);
method public abstract void cancelAll();
method public void cancelInAllNamespaces();
method public abstract int enqueue(@NonNull android.app.job.JobInfo, @NonNull android.app.job.JobWorkItem);
method @NonNull public android.app.job.JobScheduler forNamespace(@NonNull String);
method @NonNull public abstract java.util.List<android.app.job.JobInfo> getAllPendingJobs();
method @Nullable public String getNamespace();
method @Nullable public abstract android.app.job.JobInfo getPendingJob(int);
method public int getPendingJobReason(int);
method @NonNull public java.util.Map<java.lang.String,java.util.List<android.app.job.JobInfo>> getPendingJobsInAllNamespaces();
method public abstract int schedule(@NonNull android.app.job.JobInfo);
field public static final int PENDING_JOB_REASON_APP = 1; // 0x1
field public static final int PENDING_JOB_REASON_APP_STANDBY = 2; // 0x2