null check

Fixes: 34598376
Test: Manual
Change-Id: Ia2508434f6fada2219c1eea9b05f9101fc4490e3
(cherry picked from commit 540dcb222e14522e037fd0c6b69b21f14ac92b24)
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index e40b30f..6044561 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -3449,7 +3449,7 @@
     }
 
 
-    private boolean filterSharedLibPackageLPr(PackageSetting ps, int uid, int userId) {
+    private boolean filterSharedLibPackageLPr(@Nullable PackageSetting ps, int uid, int userId) {
         // System/shell/root get to see all static libs
         final int appId = UserHandle.getAppId(uid);
         if (appId == Process.SYSTEM_UID || appId == Process.SHELL_UID
@@ -3458,7 +3458,7 @@
         }
 
         // No package means no static lib as it is always on internal storage
-        if (ps.pkg == null || !ps.pkg.applicationInfo.isStaticSharedLibrary()) {
+        if (ps == null || ps.pkg == null || !ps.pkg.applicationInfo.isStaticSharedLibrary()) {
             return false;
         }