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

Commit 0fa2574e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #32180780: Sync adapters inappropriately being run..." into oc-dev

parents ede054a7 f9bac16d
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ public class JobInfo implements Parcelable {
    /**
     * Bundle of extras which are returned to your application at execution time.
     */
    public PersistableBundle getExtras() {
    public @NonNull PersistableBundle getExtras() {
        return extras;
    }

@@ -252,7 +252,7 @@ public class JobInfo implements Parcelable {
     * Bundle of transient extras which are returned to your application at execution time,
     * but not persisted by the system.
     */
    public Bundle getTransientExtras() {
    public @NonNull Bundle getTransientExtras() {
        return transientExtras;
    }

@@ -260,7 +260,7 @@ public class JobInfo implements Parcelable {
     * ClipData of information that is returned to your application at execution time,
     * but not persisted by the system.
     */
    public ClipData getClipData() {
    public @Nullable ClipData getClipData() {
        return clipData;
    }

@@ -274,7 +274,7 @@ public class JobInfo implements Parcelable {
    /**
     * Name of the service endpoint that will be called back into by the JobScheduler.
     */
    public ComponentName getService() {
    public @NonNull ComponentName getService() {
        return service;
    }

@@ -327,8 +327,7 @@ public class JobInfo implements Parcelable {
     * Which content: URIs must change for the job to be scheduled.  Returns null
     * if there are none required.
     */
    @Nullable
    public TriggerContentUri[] getTriggerContentUris() {
    public @Nullable TriggerContentUri[] getTriggerContentUris() {
        return triggerContentUris;
    }

@@ -811,7 +810,7 @@ public class JobInfo implements Parcelable {
         * @param jobService The endpoint that you implement that will receive the callback from the
         * JobScheduler.
         */
        public Builder(int jobId, ComponentName jobService) {
        public Builder(int jobId, @NonNull ComponentName jobService) {
            mJobService = jobService;
            mJobId = jobId;
        }
@@ -832,7 +831,7 @@ public class JobInfo implements Parcelable {
         * Set optional extras. This is persisted, so we only allow primitive types.
         * @param extras Bundle containing extras you want the scheduler to hold on to for you.
         */
        public Builder setExtras(PersistableBundle extras) {
        public Builder setExtras(@NonNull PersistableBundle extras) {
            mExtras = extras;
            return this;
        }
@@ -842,7 +841,7 @@ public class JobInfo implements Parcelable {
         * persisted with {@link #setPersisted(boolean)}; mixing the two is not allowed.
         * @param extras Bundle containing extras you want the scheduler to hold on to for you.
         */
        public Builder setTransientExtras(Bundle extras) {
        public Builder setTransientExtras(@NonNull Bundle extras) {
            mTransientExtras = extras;
            return this;
        }
@@ -869,7 +868,7 @@ public class JobInfo implements Parcelable {
         * {@link android.content.Intent#FLAG_GRANT_WRITE_URI_PERMISSION}, and
         * {@link android.content.Intent#FLAG_GRANT_PREFIX_URI_PERMISSION}.
         */
        public Builder setClipData(ClipData clip, int grantFlags) {
        public Builder setClipData(@Nullable ClipData clip, int grantFlags) {
            mClipData = clip;
            mClipGrantFlags = grantFlags;
            return this;
+9 −7
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.app.job;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.job.IJobCallback;
import android.content.ClipData;
import android.net.Uri;
@@ -91,7 +93,7 @@ public class JobParameters implements Parcelable {
     * {@link android.app.job.JobInfo.Builder#setExtras(android.os.PersistableBundle)}. This will
     * never be null. If you did not set any extras this will be an empty bundle.
     */
    public PersistableBundle getExtras() {
    public @NonNull PersistableBundle getExtras() {
        return extras;
    }

@@ -100,7 +102,7 @@ public class JobParameters implements Parcelable {
     * {@link android.app.job.JobInfo.Builder#setTransientExtras(android.os.Bundle)}. This will
     * never be null. If you did not set any extras this will be an empty bundle.
     */
    public Bundle getTransientExtras() {
    public @NonNull Bundle getTransientExtras() {
        return transientExtras;
    }

@@ -109,7 +111,7 @@ public class JobParameters implements Parcelable {
     * {@link android.app.job.JobInfo.Builder#setClipData(ClipData, int)}. Will be null
     * if it was not set.
     */
    public ClipData getClipData() {
    public @Nullable ClipData getClipData() {
        return clipData;
    }

@@ -140,7 +142,7 @@ public class JobParameters implements Parcelable {
     * always use {@link #getTriggeredContentAuthorities()} to determine whether the job was
     * triggered due to any content changes and the authorities they are associated with.
     */
    public Uri[] getTriggeredContentUris() {
    public @Nullable Uri[] getTriggeredContentUris() {
        return mTriggeredContentUris;
    }

@@ -152,7 +154,7 @@ public class JobParameters implements Parcelable {
     * to retrieve the details of which URIs changed (as long as that has not exceeded the maximum
     * number it can reported).
     */
    public String[] getTriggeredContentAuthorities() {
    public @Nullable String[] getTriggeredContentAuthorities() {
        return mTriggeredContentAuthorities;
    }

@@ -183,7 +185,7 @@ public class JobParameters implements Parcelable {
     * (This means that for correct operation, you must always call dequeueWork() after you have
     * completed other work, to check either for more work or allow the system to stop the job.)
     */
    public JobWorkItem dequeueWork() {
    public @Nullable JobWorkItem dequeueWork() {
        try {
            return getCallback().dequeueWork(getJobId());
        } catch (RemoteException e) {
@@ -207,7 +209,7 @@ public class JobParameters implements Parcelable {
     * @param work The work you have completed processing, as previously returned by
     * {@link #dequeueWork()}
     */
    public void completeWork(JobWorkItem work) {
    public void completeWork(@NonNull JobWorkItem work) {
        try {
            if (!getCallback().completeWork(getJobId(), work.getWorkId())) {
                throw new IllegalArgumentException("Given work is not active: " + work);
+4 −3
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public abstract class JobScheduler {
     * you can schedule.
     * @return An int representing ({@link #RESULT_SUCCESS} or {@link #RESULT_FAILURE}).
     */
    public abstract int schedule(JobInfo job);
    public abstract int schedule(@NonNull JobInfo job);

    /**
     * Similar to {@link #schedule}, but allows you to enqueue work for an existing job.  If a job
@@ -108,7 +108,7 @@ public abstract class JobScheduler {
     * @param work New work to enqueue.  This will be available later when the job starts running.
     * @return An int representing ({@link #RESULT_SUCCESS} or {@link #RESULT_FAILURE}).
     */
    public abstract int enqueue(JobInfo job, JobWorkItem work);
    public abstract int enqueue(@NonNull JobInfo job, @NonNull JobWorkItem work);

    /**
     *
@@ -121,7 +121,8 @@ public abstract class JobScheduler {
     * @hide
     */
    @SystemApi
    public abstract int scheduleAsPackage(JobInfo job, String packageName, int userId, String tag);
    public abstract int scheduleAsPackage(@NonNull JobInfo job, @NonNull String packageName,
            int userId, String tag);

    /**
     * Cancel a job that is pending in the JobScheduler.
+27 −0
Original line number Diff line number Diff line
@@ -358,6 +358,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import com.android.server.job.JobSchedulerInternal;
import com.google.android.collect.Lists;
import com.google.android.collect.Maps;
@@ -18179,6 +18180,9 @@ public class ActivityManagerService extends IActivityManager.Stub
            return false;
        }
        int oldBackupUid;
        int newBackupUid;
        synchronized(this) {
            // !!! TODO: currently no check here that we're already bound
            BatteryStatsImpl.Uid.Pkg.Serv ss = null;
@@ -18219,6 +18223,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                proc.inFullBackup = true;
            }
            r.app = proc;
            oldBackupUid = mBackupTarget != null ? mBackupTarget.appInfo.uid : -1;
            newBackupUid = proc.inFullBackup ? r.appInfo.uid : -1;
            mBackupTarget = r;
            mBackupAppName = app.packageName;
@@ -18244,6 +18250,14 @@ public class ActivityManagerService extends IActivityManager.Stub
            // know that it's scheduled for a backup-agent operation.
        }
        JobSchedulerInternal js = LocalServices.getService(JobSchedulerInternal.class);
        if (oldBackupUid != -1) {
            js.removeBackingUpUid(oldBackupUid);
        }
        if (newBackupUid != -1) {
            js.addBackingUpUid(newBackupUid);
        }
        return true;
    }
@@ -18256,6 +18270,9 @@ public class ActivityManagerService extends IActivityManager.Stub
            mBackupTarget = null;
            mBackupAppName = null;
        }
        JobSchedulerInternal js = LocalServices.getService(JobSchedulerInternal.class);
        js.clearAllBackingUpUids();
    }
    // A backup agent has just come up
@@ -18293,6 +18310,8 @@ public class ActivityManagerService extends IActivityManager.Stub
            return;
        }
        int oldBackupUid;
        synchronized(this) {
            try {
                if (mBackupAppName == null) {
@@ -18310,6 +18329,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                updateOomAdjLocked(proc);
                proc.inFullBackup = false;
                oldBackupUid = mBackupTarget != null ? mBackupTarget.appInfo.uid : -1;
                // If the app crashed during backup, 'thread' will be null here
                if (proc.thread != null) {
                    try {
@@ -18325,7 +18346,13 @@ public class ActivityManagerService extends IActivityManager.Stub
                mBackupAppName = null;
            }
        }
        if (oldBackupUid != -1) {
            JobSchedulerInternal js = LocalServices.getService(JobSchedulerInternal.class);
            js.removeBackingUpUid(oldBackupUid);
        }
    }
    // =========================================================
    // BROADCASTS
    // =========================================================
+7 −0
Original line number Diff line number Diff line
@@ -30,4 +30,11 @@ public interface JobSchedulerInternal {
     * Returns a list of pending jobs scheduled by the system service.
     */
    List<JobInfo> getSystemScheduledPendingJobs();

    /**
     * These are for activity manager to communicate to use what is currently performing backups.
     */
    void addBackingUpUid(int uid);
    void removeBackingUpUid(int uid);
    void clearAllBackingUpUids();
}
Loading