MediaSessionService: Send MEDIA_BUTTON intents with foreground priority
Bug: 27179450
Change-Id: Id4f530e87fff67b0582d13ef5b5333f3eae2d927
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index e3c540a..a4d2cd2 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -962,6 +962,7 @@
mKeyEventReceiver.aquireWakeLockLocked();
}
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
+ mediaButtonIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
mediaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
try {
if (user.mLastMediaButtonReceiver != null) {
@@ -986,6 +987,7 @@
}
// Fallback to legacy behavior
Intent keyIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null);
+ keyIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
keyIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
if (needWakeLock) {
keyIntent.putExtra(EXTRA_WAKELOCK_ACQUIRED,