summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Daichi Hirono <hirono@google.com> 2015-08-17 18:01:23 +0900
committer Daichi Hirono <hirono@google.com> 2015-08-17 18:17:33 +0900
commitb1870e922e9e149f632bddcd8b50fcc8220014d7 (patch)
treef3e67ac745ef835da54984532b529ea9dddd3607
parent5e491c91e85998cbb42d796aec507431b05068ba (diff)
Handle null value returned by MtpDevice#getRoots.
BUG=23169303 Change-Id: I9602dda01f3b8919a471c1f4c88acdd19f391684
-rw-r--r--packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java
index 088315787e8f..3afc173fcc52 100644
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java
+++ b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpManager.java
@@ -95,6 +95,9 @@ class MtpManager {
synchronized MtpRoot[] getRoots(int deviceId) throws IOException {
final MtpDevice device = getDevice(deviceId);
final int[] storageIds = device.getStorageIds();
+ if (storageIds == null) {
+ throw new IOException("Failed to obtain storage IDs.");
+ }
final MtpRoot[] results = new MtpRoot[storageIds.length];
for (int i = 0; i < storageIds.length; i++) {
results[i] = new MtpRoot(deviceId, device.getStorageInfo(storageIds[i]));