summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2015-07-14 20:52:20 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-14 20:53:16 +0000
commitd3719ab07a0ba66c019979ce19c45b77c4aae92e (patch)
tree76b81deeac39788424cfccc5904ba08da26d7348
parent6eec00ecf456b8a24487828b6f515cccc465cc1a (diff)
parent983294596e65a0226aa69e42bda9db322727fee5 (diff)
downloadframeworks_base-d3719ab07a0ba66c019979ce19c45b77c4aae92e.zip
frameworks_base-d3719ab07a0ba66c019979ce19c45b77c4aae92e.tar.gz
frameworks_base-d3719ab07a0ba66c019979ce19c45b77c4aae92e.tar.bz2
Merge "Better handling of storage paths." into mnc-dev
-rw-r--r--core/java/android/app/ContextImpl.java13
-rw-r--r--core/java/android/os/storage/StorageManager.java14
2 files changed, 15 insertions, 12 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 6639486..75dd35c 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -1925,13 +1925,14 @@ class ContextImpl extends Context {
// enough permissions; ask vold to create on our behalf.
final IMountService mount = IMountService.Stub.asInterface(
ServiceManager.getService("mount"));
- int res = -1;
try {
- res = mount.mkdirs(getPackageName(), dir.getAbsolutePath());
- } catch (Exception ignored) {
- }
- if (res != 0) {
- Log.w(TAG, "Failed to ensure directory: " + dir);
+ final int res = mount.mkdirs(getPackageName(), dir.getAbsolutePath());
+ if (res != 0) {
+ Log.w(TAG, "Failed to ensure " + dir + ": " + res);
+ dir = null;
+ }
+ } catch (Exception e) {
+ Log.w(TAG, "Failed to ensure " + dir + ": " + e);
dir = null;
}
}
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index 320aa2c..2b75f31 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -817,17 +817,19 @@ public class StorageManager {
/** {@hide} */
private static @Nullable StorageVolume getStorageVolume(StorageVolume[] volumes, File file) {
- File canonicalFile = null;
try {
- canonicalFile = file.getCanonicalFile();
+ file = file.getCanonicalFile();
} catch (IOException ignored) {
- canonicalFile = null;
+ return null;
}
for (StorageVolume volume : volumes) {
- if (volume.getPathFile().equals(file)) {
- return volume;
+ File volumeFile = volume.getPathFile();
+ try {
+ volumeFile = volumeFile.getCanonicalFile();
+ } catch (IOException ignored) {
+ continue;
}
- if (FileUtils.contains(volume.getPathFile(), canonicalFile)) {
+ if (FileUtils.contains(volumeFile, file)) {
return volume;
}
}