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

Commit 826403d3 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 d163fcb5
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

class ReceiverRestrictedContext extends ContextWrapper {
    ReceiverRestrictedContext(Context base) {
@@ -1976,9 +1977,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
@@ -2000,9 +2004,9 @@ class ContextImpl extends Context {
                    }
                }
            }
            result[i] = dir;
            result.add(dir);
        }
        return result;
        return result.toArray(new File[result.size()]);
    }

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