Resolve symlinks when listing scan paths.
Some paths like /product might be symlinks to /system/product. Bug: 124070462, 124074176, 124074218, 124074430 Test: atest CtsMediaTestCases Change-Id: Ic0aa388f385d13a124ae170686dea18e716016e0
This commit is contained in:
@@ -3166,20 +3166,29 @@ public final class MediaStore {
|
||||
|
||||
final ArrayList<File> res = new ArrayList<>();
|
||||
if (VOLUME_INTERNAL.equals(volumeName)) {
|
||||
res.add(new File(Environment.getRootDirectory(), "media"));
|
||||
res.add(new File(Environment.getOemDirectory(), "media"));
|
||||
res.add(new File(Environment.getProductDirectory(), "media"));
|
||||
addCanoncialFile(res, new File(Environment.getRootDirectory(), "media"));
|
||||
addCanoncialFile(res, new File(Environment.getOemDirectory(), "media"));
|
||||
addCanoncialFile(res, new File(Environment.getProductDirectory(), "media"));
|
||||
} else {
|
||||
res.add(getVolumePath(volumeName));
|
||||
addCanoncialFile(res, getVolumePath(volumeName));
|
||||
final UserManager um = AppGlobals.getInitialApplication()
|
||||
.getSystemService(UserManager.class);
|
||||
if (VOLUME_EXTERNAL.equals(volumeName) && um.isDemoUser()) {
|
||||
res.add(Environment.getDataPreloadsMediaDirectory());
|
||||
addCanoncialFile(res, Environment.getDataPreloadsMediaDirectory());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private static void addCanoncialFile(List<File> list, File file) {
|
||||
try {
|
||||
list.add(file.getCanonicalFile());
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "Failed to resolve " + file + ": " + e);
|
||||
list.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uri for querying the state of the media scanner.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user