diff options
| author | 2018-05-29 15:23:25 -0700 | |
|---|---|---|
| committer | 2018-05-29 15:23:25 -0700 | |
| commit | 33369bbd2a2eceb5da94996fc2c463b33ae75423 (patch) | |
| tree | c346e28975a14afc1ba051bf8c6d8c3722a48f99 | |
| parent | 96efd907c515f25d5b3db12ab7ec73c2441ee01a (diff) | |
| parent | 0a82690868b58fde22d6aaaebe1d01b7bb9b8658 (diff) | |
Guard pre-O apps from malicious startForegroundService()
am: 0a82690868
Change-Id: I4dbab603ba2d42b5301539cc3110bef02868ee1e
| -rw-r--r-- | services/core/java/com/android/server/am/ActiveServices.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index faa245c58d61..ca715b51a328 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -501,6 +501,18 @@ public final class ActiveServices { } } + // At this point we've applied allowed-to-start policy based on whether this was + // an ordinary startService() or a startForegroundService(). Now, only require that + // the app follow through on the startForegroundService() -> startForeground() + // contract if it actually targets O+. + if (r.appInfo.targetSdkVersion < Build.VERSION_CODES.O && fgRequired) { + if (DEBUG_BACKGROUND_CHECK || DEBUG_FOREGROUND_SERVICE) { + Slog.i(TAG, "startForegroundService() but host targets " + + r.appInfo.targetSdkVersion + " - not requiring startForeground()"); + } + fgRequired = false; + } + NeededUriGrants neededGrants = mAm.checkGrantUriPermissionFromIntentLocked( callingUid, r.packageName, service, service.getFlags(), null, r.userId); |