Loading apex/jobscheduler/framework/java/android/app/JobSchedulerImpl.java +3 −2 Original line number Diff line number Diff line Loading @@ -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) { } } Loading apex/jobscheduler/framework/java/android/app/job/IJobScheduler.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -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); } apex/jobscheduler/framework/java/android/app/job/JobInfo.java +5 −1 Original line number Diff line number Diff line Loading @@ -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 Loading apex/jobscheduler/framework/java/android/app/job/JobScheduler.java +2 −1 Original line number Diff line number Diff line Loading @@ -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); } apex/jobscheduler/framework/java/android/app/job/JobService.java +12 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading
apex/jobscheduler/framework/java/android/app/JobSchedulerImpl.java +3 −2 Original line number Diff line number Diff line Loading @@ -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) { } } Loading
apex/jobscheduler/framework/java/android/app/job/IJobScheduler.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -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); }
apex/jobscheduler/framework/java/android/app/job/JobInfo.java +5 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
apex/jobscheduler/framework/java/android/app/job/JobScheduler.java +2 −1 Original line number Diff line number Diff line Loading @@ -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); }
apex/jobscheduler/framework/java/android/app/job/JobService.java +12 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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