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

Commit dd48bb45 authored by Steve Kondik's avatar Steve Kondik Committed by Steve Kondik
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
parent b87d33d8
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -2445,9 +2445,12 @@ class ContextImpl extends Context {
     * unable to create, they are filtered by replacing with {@code null}.
     */
    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++) {
            File dir = dirs[i];
            if (Environment.MEDIA_REMOVED.equals(Environment.getStorageState(dir))) {
                continue;
            }
            if (!dir.exists()) {
                if (!dir.mkdirs()) {
                    // recheck existence in case of cross-process race
@@ -2468,9 +2471,9 @@ class ContextImpl extends Context {
                    }
                }
            }
            result[i] = dir;
            result.add(dir);
        }
        return result;
        return result.toArray(new File[result.size()]);
    }

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