From 785f494e8752ca3bcffe1d648ecf05b0734df31c Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 14 Jul 2016 10:31:15 -0600 Subject: [PATCH] Require permission for FLAG_WILL_BE_FOREGROUND. We caught scheduleAsPackage(), but not schedule(), oops. Bug: 28998999 Change-Id: I0642c2265ff61eead8747cc6b4d0f852f1ca3ef2 --- core/java/android/app/job/JobInfo.java | 3 +++ .../java/com/android/server/job/JobSchedulerService.java | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/core/java/android/app/job/JobInfo.java b/core/java/android/app/job/JobInfo.java index 5823abf9d78fd..734bf6917eca4 100644 --- a/core/java/android/app/job/JobInfo.java +++ b/core/java/android/app/job/JobInfo.java @@ -165,6 +165,9 @@ public class JobInfo implements Parcelable { * network restrictions for the requesting app. Note that this flag alone * doesn't actually place your {@link JobService} in the foreground; you * still need to post the notification yourself. + *

+ * To use this flag, the caller must hold the + * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL} permission. * * @hide */ diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java index 8589de1a18849..8f212db7d90a3 100644 --- a/services/core/java/com/android/server/job/JobSchedulerService.java +++ b/services/core/java/com/android/server/job/JobSchedulerService.java @@ -1556,6 +1556,11 @@ public final class JobSchedulerService extends com.android.server.SystemService } } + if ((job.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0) { + getContext().enforceCallingOrSelfPermission( + android.Manifest.permission.CONNECTIVITY_INTERNAL, TAG); + } + long ident = Binder.clearCallingIdentity(); try { return JobSchedulerService.this.schedule(job, uid);