android: better error checking for external drives
This commit is contained in:
parent
3876a3e3ad
commit
98dbcf0aff
|
@ -95,22 +95,19 @@ public class FileBrowser extends Fragment {
|
|||
public static HashSet<String> getExternalMounts() {
|
||||
final HashSet<String> out = new HashSet<String>();
|
||||
String reg = "(?i).*vold.*(vfat|ntfs|exfat|fat32|ext3|ext4|fuse).*rw.*";
|
||||
String s = "";
|
||||
StringBuilder s = new StringBuilder();
|
||||
try {
|
||||
final Process process = new ProcessBuilder().command("mount")
|
||||
.redirectErrorStream(true).start();
|
||||
process.waitFor();
|
||||
final InputStream is = process.getInputStream();
|
||||
final byte[] buffer = new byte[1024];
|
||||
InputStream is = process.getInputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
while (is.read(buffer) != -1) {
|
||||
s = s + new String(buffer);
|
||||
s.append(new String(buffer));
|
||||
}
|
||||
is.close();
|
||||
} catch (final Exception e) {
|
||||
|
||||
}
|
||||
|
||||
final String[] lines = s.split("\n");
|
||||
String[] lines = s.toString().split("\n");
|
||||
for (String line : lines) {
|
||||
if (StringUtils.containsIgnoreCase(line, "secure"))
|
||||
continue;
|
||||
|
@ -125,6 +122,9 @@ public class FileBrowser extends Fragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue