Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45888614 authored by Zimuzo Ezeozue's avatar Zimuzo Ezeozue Committed by Android (Google) Code Review
Browse files

Merge "Fix canonicalizing /sdcard"

parents 0258f9f2 50e73370
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -876,7 +876,14 @@ public class StorageManager {
     */
    public @NonNull UUID getUuidForPath(@NonNull File path) throws IOException {
        Preconditions.checkNotNull(path);
        final String pathString = path.getCanonicalPath();
        String pathString = path.getCanonicalPath();
        if (path.getPath().startsWith("/sdcard")) {
            // On FUSE enabled devices, realpath(2) /sdcard is /mnt/user/<userid>/emulated/<userid>
            // as opposed to /storage/emulated/<userid>.
            // And vol.path below expects to match with a path starting with /storage
            pathString = pathString.replaceFirst("^/mnt/user/[0-9]+/", "/storage/");
        }

        if (FileUtils.contains(Environment.getDataDirectory().getAbsolutePath(), pathString)) {
            return UUID_DEFAULT;
        }