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

Commit aa1ec435 authored by Steve Kondik's avatar Steve Kondik Committed by Ricardo Cerqueira
Browse files

storage: Don't list removed volumes in storage list

 * Don't tell apps that USB storage or empty SD slots are available for
   use. This fixes errors about trying to create dirs in vold as well
   as the relevant CTS cases.

Change-Id: Ic763d40c19b0bb9f7497cc1515baf1661d76e9ee
(cherry picked from commit 5a3c6b05)
parent 6150919f
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -2183,9 +2183,12 @@ class ContextImpl extends Context {
     * unable to create, they are filtered by replacing with {@code null}.
     * unable to create, they are filtered by replacing with {@code null}.
     */
     */
    private File[] ensureDirsExistOrFilter(File[] dirs) {
    private File[] ensureDirsExistOrFilter(File[] dirs) {
        File[] result = new File[dirs.length];
        ArrayList<File> result = new ArrayList<File>(dirs.length);
        for (int i = 0; i < dirs.length; i++) {
        for (int i = 0; i < dirs.length; i++) {
            File dir = dirs[i];
            File dir = dirs[i];
            if (Environment.MEDIA_REMOVED.equals(Environment.getStorageState(dir))) {
                continue;
            }
            if (!dir.exists()) {
            if (!dir.exists()) {
                if (!dir.mkdirs()) {
                if (!dir.mkdirs()) {
                    // recheck existence in case of cross-process race
                    // recheck existence in case of cross-process race
@@ -2206,9 +2209,9 @@ class ContextImpl extends Context {
                    }
                    }
                }
                }
            }
            }
            result[i] = dir;
            result.add(dir);
        }
        }
        return result;
        return result.toArray(new File[result.size()]);
    }
    }


    // ----------------------------------------------------------------------
    // ----------------------------------------------------------------------