OSDN Git Service

Prevent NPE in MediaSessionService
authorSungsoo Lim <sungsoo@google.com>
Mon, 16 Nov 2015 05:00:52 +0000 (14:00 +0900)
committerSungsoo Lim <sungsoo@google.com>
Mon, 16 Nov 2015 05:06:01 +0000 (14:06 +0900)
Guard against null UserRecord when dispatching a media key event.

Bug: 22966229
Change-Id: I32f4f87e06d8af13b94bb8f28180a66517c23c33

services/core/java/com/android/server/media/MediaSessionService.java

index 7028fa6..90dd10e 100644 (file)
@@ -948,8 +948,8 @@ public class MediaSessionService extends SystemService implements Monitor {
                 // Launch the last PendingIntent we had with priority
                 int userId = ActivityManager.getCurrentUser();
                 UserRecord user = mUserRecords.get(userId);
-                if (user.mLastMediaButtonReceiver != null
-                        || user.mRestoredMediaButtonReceiver != null) {
+                if (user != null && (user.mLastMediaButtonReceiver != null
+                        || user.mRestoredMediaButtonReceiver != null)) {
                     if (DEBUG) {
                         Log.d(TAG, "Sending media key to last known PendingIntent "
                                 + user.mLastMediaButtonReceiver + " or restored Intent "