From 6bdadaf0a01b7efd4347c99c6e2a23f151d01970 Mon Sep 17 00:00:00 2001 From: Winson Date: Wed, 10 Jun 2020 11:06:37 -0700 Subject: [PATCH] Fix PackagePartitions contains null check The subfolders can be null depending on the partition. Bug: 158671002 Test: manual was tested as part of not yet merged Ie09ccf4b64a0be26d19c9034a68ca4877ca49b81 Change-Id: Ic3a07867cb50b6b0b0e265e9540c52ee94c68050 --- core/java/android/content/pm/PackagePartitions.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/content/pm/PackagePartitions.java b/core/java/android/content/pm/PackagePartitions.java index 653b9ec9e8f23..98a20f73a1200 100644 --- a/core/java/android/content/pm/PackagePartitions.java +++ b/core/java/android/content/pm/PackagePartitions.java @@ -183,17 +183,20 @@ public class PackagePartitions { /** Returns whether the partition contains the specified file in its priv-app folder. */ public boolean containsPrivApp(@NonNull File scanFile) { - return FileUtils.contains(mPrivAppFolder.getFile(), canonicalize(scanFile)); + return mPrivAppFolder != null + && FileUtils.contains(mPrivAppFolder.getFile(), canonicalize(scanFile)); } /** Returns whether the partition contains the specified file in its app folder. */ public boolean containsApp(@NonNull File scanFile) { - return FileUtils.contains(mAppFolder.getFile(), canonicalize(scanFile)); + return mAppFolder != null + && FileUtils.contains(mAppFolder.getFile(), canonicalize(scanFile)); } /** Returns whether the partition contains the specified file in its overlay folder. */ public boolean containsOverlay(@NonNull File scanFile) { - return FileUtils.contains(mOverlayFolder.getFile(), canonicalize(scanFile)); + return mOverlayFolder != null + && FileUtils.contains(mOverlayFolder.getFile(), canonicalize(scanFile)); } }