Merge "Better handling of storage paths." into mnc-dev
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user