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

Commit 75208d7f authored by Kweku Adams's avatar Kweku Adams Committed by Android (Google) Code Review
Browse files

Merge "Update response to Task Manager stops."

parents 47dfdabe 677c6ae1
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -230,9 +230,10 @@ public class JobSchedulerImpl extends JobScheduler {
            android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
            android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
    @Override
    public void stopUserVisibleJobsForUser(@NonNull String packageName, int userId) {
    public void notePendingUserRequestedAppStop(@NonNull String packageName, int userId,
            @Nullable String debugReason) {
        try {
            mBinder.stopUserVisibleJobsForUser(packageName, userId);
            mBinder.notePendingUserRequestedAppStop(packageName, userId, debugReason);
        } catch (RemoteException e) {
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -48,5 +48,5 @@ interface IJobScheduler {
    @EnforcePermission(allOf={"MANAGE_ACTIVITY_TASKS", "INTERACT_ACROSS_USERS_FULL"})
    void unregisterUserVisibleJobObserver(in IUserVisibleJobObserver observer);
    @EnforcePermission(allOf={"MANAGE_ACTIVITY_TASKS", "INTERACT_ACROSS_USERS_FULL"})
    void stopUserVisibleJobsForUser(String packageName, int userId);
    void notePendingUserRequestedAppStop(String packageName, int userId, String debugReason);
}
+5 −1
Original line number Diff line number Diff line
@@ -1897,7 +1897,11 @@ public class JobInfo implements Parcelable {
         * <p>
         * All user-initiated jobs must have an associated notification, set via
         * {@link JobService#setNotification(JobParameters, int, Notification, int)}, and will be
         * shown in the Task Manager when running.
         * shown in the Task Manager when running. These jobs cannot be rescheduled by the app
         * if the user stops the job via system provided affordance (such as the Task Manager).
         * Thus, it is best practice and recommended to provide action buttons in the
         * associated notification to allow the user to stop the job gracefully
         * and allow for rescheduling.
         *
         * <p>
         * If the app doesn't hold the {@link android.Manifest.permission#RUN_LONG_JOBS} permission
+2 −1
Original line number Diff line number Diff line
@@ -515,5 +515,6 @@ public abstract class JobScheduler {
            android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
            android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
    @SuppressWarnings("HiddenAbstractMethod")
    public abstract void stopUserVisibleJobsForUser(@NonNull String packageName, int userId);
    public abstract void notePendingUserRequestedAppStop(@NonNull String packageName, int userId,
            @Nullable String debugReason);
}
+12 −0
Original line number Diff line number Diff line
@@ -156,6 +156,12 @@ public abstract class JobService extends Service {
     * a future idle maintenance window.
     * </p>
     *
     * <p class="note">
     * Any {@link JobInfo.Builder#setUserInitiated(boolean) user-initiated job}
     * cannot be rescheduled when the user has asked to stop the app
     * via a system provided affordance (such as the Task Manager).
     * In such situations, the value of {@code wantsReschedule} is always treated as {@code false}.
     *
     * @param params The parameters identifying this job, as supplied to
     *               the job in the {@link #onStartJob(JobParameters)} callback.
     * @param wantsReschedule {@code true} if this job should be rescheduled according
@@ -220,6 +226,12 @@ public abstract class JobService extends Service {
     * Once this method returns (or times out), the system releases the wakelock that it is holding
     * on behalf of the job.</p>
     *
     * <p class="note">
     * Any {@link JobInfo.Builder#setUserInitiated(boolean) user-initiated job}
     * cannot be rescheduled when stopped by the user via a system provided affordance (such as
     * the Task Manager). In such situations, the returned value from this method call is always
     * treated as {@code false}.
     *
     * <p class="caution"><strong>Note:</strong> When a job is stopped and rescheduled via this
     * method call, the deadline constraint is excluded from the rescheduled job's constraint set.
     * The rescheduled job will run again once all remaining constraints are satisfied.
Loading