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

Commit 0bc4d069 authored by Uday Kiran jandhyala's avatar Uday Kiran jandhyala Committed by Gerrit - the friendly Code Review server
Browse files

MediaSessionService: Error checks for UserRecord object

Checking UserRecord object for NULL, before accessing its members

Change-Id: Icf1fbbe35647a9cbc22cb4418c468c4a275db36d
CRs-Fixed: 817083
parent feba6ba3
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -723,8 +723,13 @@ public class MediaSessionService extends SystemService implements Monitor {
                synchronized (mLock) {
                    // If we don't have a media button receiver to fall back on
                    // include non-playing sessions for dispatching
                    boolean useNotPlayingSessions = mUserRecords.get(
                            ActivityManager.getCurrentUser()).mLastMediaButtonReceiver == null;
                    UserRecord user = mUserRecords.get(mCurrentUserId);
                    if (user == null) {
                        Log.e(TAG, "Invalid UserRecord for current user : " + mCurrentUserId);
                        return;
                    }

                    boolean useNotPlayingSessions = user.mLastMediaButtonReceiver == null;
                    MediaSessionRecord session = mPriorityStack
                            .getDefaultMediaButtonSession(mCurrentUserId, useNotPlayingSessions);
                    if (isVoiceKey(keyEvent.getKeyCode())) {
@@ -799,7 +804,7 @@ public class MediaSessionService extends SystemService implements Monitor {
                count = mUserRecords.size();
                for (int i = 0; i < count; i++) {
                    UserRecord user = mUserRecords.get(i);
                    user.dumpLocked(pw, "");
                    if (user != null) user.dumpLocked(pw, "");
                }
            }
        }
@@ -929,7 +934,7 @@ 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) {
                if ((user != null) && (user.mLastMediaButtonReceiver != null)) {
                    if (DEBUG) {
                        Log.d(TAG, "Sending media key to last known PendingIntent");
                    }