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

Commit 71324c44 authored by Kweku Adams's avatar Kweku Adams
Browse files

Expose job namespace APIs.

Bug: 253649458
Test: atest CtsJobSchedulerTestCases:JobParametersTest
Test: atest CtsJobSchedulerTestCases:JobSchedulingTest
Change-Id: I6f14816ff161dda4ccc6711c6dedb109dd97af8b
parent ce03ab0b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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() {
+9 −5
Original line number Diff line number Diff line
@@ -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() {
@@ -385,14 +383,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.");
@@ -414,7 +419,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() {
+5 −0
Original line number Diff line number Diff line
@@ -8498,6 +8498,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();
@@ -8531,10 +8532,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