Handle case for missing permissions - fix NPE am: 39cc33f192 am: 6e527d0ec5
am: a2ab662f9b

Change-Id: Ib882462b4b23fdf6247e4de1b4e4eefe4e450dcf
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 815d871..06359b0 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4233,8 +4233,10 @@
             final BasePermission p = mSettings.mPermissions.get(name);
             // If the caller is an app that targets pre 26 SDK drop protection flags.
             final PermissionInfo permissionInfo = generatePermissionInfo(p, flags);
-            permissionInfo.protectionLevel = adjustPermissionProtectionFlagsLPr(
-                    permissionInfo.protectionLevel, packageName, callingUid);
+            if (permissionInfo != null) {
+                permissionInfo.protectionLevel = adjustPermissionProtectionFlagsLPr(
+                        permissionInfo.protectionLevel, packageName, callingUid);
+            }
             return permissionInfo;
         }
     }