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

Commit 33369bbd authored by Christopher Tate's avatar Christopher Tate Committed by android-build-merger
Browse files

Guard pre-O apps from malicious startForegroundService()

am: 0a826908

Change-Id: I4dbab603ba2d42b5301539cc3110bef02868ee1e
parents 96efd907 0a826908
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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);