diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/os/storage/StorageManager.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index ece12280bb80..da215c61641a 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -824,7 +824,9 @@ public class StorageManager { } } - /** {@hide} */ + /** + * Return the {@link StorageVolume} that contains the given file, or {@code null} if none. + */ public @Nullable StorageVolume getStorageVolume(File file) { return getStorageVolume(getVolumeList(), file); } @@ -836,9 +838,13 @@ public class StorageManager { /** {@hide} */ private static @Nullable StorageVolume getStorageVolume(StorageVolume[] volumes, File file) { + if (file == null) { + return null; + } try { file = file.getCanonicalFile(); } catch (IOException ignored) { + Slog.d(TAG, "Could not get canonical path for " + file); return null; } for (StorageVolume volume : volumes) { |
