summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2015-05-11 14:36:27 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2015-05-11 14:36:27 -0700
commite492d43512fd7c56e9c63d1701238d2595d58d8c (patch)
treea3711f975e8d078e304f885cdfd80e9eee645f03 /services
parent3ce72722ca14ad9e84ca54920bb2829696f68d53 (diff)
downloadframeworks_base-e492d43512fd7c56e9c63d1701238d2595d58d8c.zip
frameworks_base-e492d43512fd7c56e9c63d1701238d2595d58d8c.tar.gz
frameworks_base-e492d43512fd7c56e9c63d1701238d2595d58d8c.tar.bz2
Prevent NPE in MediaSessionService
Guard against null UserRecord when dispatching a media key event. Change-Id: I0c4a60b9c35f51a2c93baeecb80106633740de8b
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/media/MediaSessionService.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index 65949bf..8086461 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -765,8 +765,9 @@ public class MediaSessionService extends SystemService implements Monitor {
// If we don't have a media button receiver to fall back on
// include non-playing sessions for dispatching
UserRecord ur = mUserRecords.get(ActivityManager.getCurrentUser());
- boolean useNotPlayingSessions = ur.mLastMediaButtonReceiver == null
- && ur.mRestoredMediaButtonReceiver == null;
+ boolean useNotPlayingSessions = (ur == null) ||
+ (ur.mLastMediaButtonReceiver == null
+ && ur.mRestoredMediaButtonReceiver == null);
MediaSessionRecord session = mPriorityStack
.getDefaultMediaButtonSession(mCurrentUserId, useNotPlayingSessions);
if (isVoiceKey(keyEvent.getKeyCode())) {