Fix NPE in MediaRouterService
Bug: 63970300
Test: manual and passed MediaRouterTest
Change-Id: I2e8d09d16ca8693b1bdf51397ad4f10c4aa6d87b
(cherry picked from commit 2d36ae9d2f2e286c205adb20af23eebe554f3dd8)
diff --git a/services/core/java/com/android/server/media/MediaRouterService.java b/services/core/java/com/android/server/media/MediaRouterService.java
index 5ba8f48..922df1e 100644
--- a/services/core/java/com/android/server/media/MediaRouterService.java
+++ b/services/core/java/com/android/server/media/MediaRouterService.java
@@ -355,7 +355,7 @@
void restoreRoute(int uid) {
ClientRecord clientRecord = null;
UserRecord userRecord = mUserRecords.get(UserHandle.getUserId(uid));
- if (userRecord.mClientRecords != null) {
+ if (userRecord != null && userRecord.mClientRecords != null) {
for (ClientRecord cr : userRecord.mClientRecords) {
if (validatePackageName(uid, cr.mPackageName)) {
clientRecord = cr;