From bc7c4ed0ba503fb3855d001b1de1247f79affcb7 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Tue, 24 Nov 2020 14:02:35 -0800 Subject: [PATCH] Fix NPE Reported by zezeozue@; if no package defines an application tag, getProperty() was throwing an NPE within the package manager service. NOTE: There's now a CTS test to ensure this works. However, it's not sufficient. As soon as there's a single system application that defines an application tag, the test will no longer catch the condition. We need to re-write the CTS test as a Package Manager Service unit test and verity the behaviour outside of the running service. Bug: 169258655 Test: atest CtsContentTestCases:PackageManagerGetPropertyTest#testPackageRemoval Change-Id: I117272b9b831061b9e915e0eb310d809b3afca2f --- services/core/java/com/android/server/pm/PackageProperty.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/pm/PackageProperty.java b/services/core/java/com/android/server/pm/PackageProperty.java index d18a02d9f3157..ee9ed3b905992 100644 --- a/services/core/java/com/android/server/pm/PackageProperty.java +++ b/services/core/java/com/android/server/pm/PackageProperty.java @@ -274,7 +274,7 @@ public class PackageProperty { private Property getApplicationProperty(String propertyName, String packageName) { final ArrayMap> packagePropertyMap = - mApplicationProperties.get(propertyName); + mApplicationProperties != null ? mApplicationProperties.get(propertyName) : null; if (packagePropertyMap == null) { return null; }