From 08718c4e74e36d26051da65c80f4d61707d943c1 Mon Sep 17 00:00:00 2001 From: lpeter Date: Thu, 21 Sep 2023 10:47:58 +0000 Subject: Fix the command problem "adb shell pm list permissions -f" After using the command adb shell pm list permissions -f, it will break the list when dealing with a malformed APEX. We think that we should not break the list. We should print the error and continue to list all permissions. Bug: 300268371 Bug: 301211657 Test: Manual by using adb shell pm list permissions -f Change-Id: I8322900989385d360e3d0a7be66a334ffc1091cf --- .../core/java/com/android/server/pm/PackageManagerShellCommand.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java index e1f010f62232..b6f4aeea3704 100644 --- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java +++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java @@ -4126,6 +4126,10 @@ class PackageManagerShellCommand extends ShellCommand { PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS, 0); + if (ai == null) { + Slog.e(TAG, "Failed to get ApplicationInfo for package name(" + pii.packageName + ")."); + return null; + } AssetManager am = new AssetManager(); am.addAssetPath(ai.publicSourceDir); res = new Resources(am, null, null); -- cgit v1.2.3-59-g8ed1b