From 30f63cf1f958cf5e8ee77875ac38c579a4a783d1 Mon Sep 17 00:00:00 2001 From: Jerry Zhang Date: Wed, 6 Jun 2018 11:04:46 -0700 Subject: [PATCH] Check for null path in getInternalPathForUser In some situations, path could be null resulting in a crash. Test: no crash Bug: 109730998 Change-Id: I2ce0410162d1327905d690331f461f9187e20906 (cherry picked from commit 6f6154bf0493cf66628c8f2418827fe54679b1eb) --- core/java/android/os/storage/VolumeInfo.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/java/android/os/storage/VolumeInfo.java b/core/java/android/os/storage/VolumeInfo.java index a21e05e314b2..932f0c2b52ef 100644 --- a/core/java/android/os/storage/VolumeInfo.java +++ b/core/java/android/os/storage/VolumeInfo.java @@ -318,7 +318,9 @@ public class VolumeInfo implements Parcelable { * {@link android.Manifest.permission#WRITE_MEDIA_STORAGE}. */ public File getInternalPathForUser(int userId) { - if (type == TYPE_PUBLIC) { + if (path == null) { + return null; + } else if (type == TYPE_PUBLIC) { // TODO: plumb through cleaner path from vold return new File(path.replace("/storage/", "/mnt/media_rw/")); } else { -- 2.11.0