summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorBill Lin <lbill@google.com>2018-08-23 19:24:07 +0800
committerBill Lin <lbill@google.com>2018-08-23 23:06:17 +0800
commitfe5a9edac0bf939b0b00aa8df826212112c97e58 (patch)
treeac195f976feb06dab2c5d653d60b907172f8b30f /core/java
parent94390ecd1d7fb841d0e5479f95fe398045161de2 (diff)
Unable to load BRs in SAF of FileSystemProvider
Files.listFiles() indicate if this abstract pathname does "not denote a directory" It will returns null and cause "NullPointerException: Attempt to get length of null array" in the queryChildDocuments() Solution: Use FileUtils.listFilesOrEmpty(parent) and check parent.isDirectory() to avoid NPE Bug: 111565816 Test: Manual, trigger bugreport rm -rf /data/user_de/0/com.android.shell/files/bugreports launch Files/Bugreport observe there should not happen exception Change-Id: I9d0835d562af7cf3c9bdaeab52cf41e86e3a8f62
Diffstat (limited to 'core/java')
-rw-r--r--core/java/com/android/internal/content/FileSystemProvider.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/java/com/android/internal/content/FileSystemProvider.java b/core/java/com/android/internal/content/FileSystemProvider.java
index f89a9d990b76..0c6f832ff33a 100644
--- a/core/java/com/android/internal/content/FileSystemProvider.java
+++ b/core/java/com/android/internal/content/FileSystemProvider.java
@@ -374,8 +374,12 @@ public abstract class FileSystemProvider extends DocumentsProvider {
final File parent = getFileForDocId(parentDocumentId);
final MatrixCursor result = new DirectoryCursor(
resolveProjection(projection), parentDocumentId, parent);
- for (File file : parent.listFiles()) {
- includeFile(result, null, file);
+ if (parent.isDirectory()) {
+ for (File file : FileUtils.listFilesOrEmpty(parent)) {
+ includeFile(result, null, file);
+ }
+ } else {
+ Log.w(TAG, "parentDocumentId '" + parentDocumentId + "' is not Directory");
}
return result;
}