aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/android
diff options
context:
space:
mode:
authorEugene Sandulenko2019-09-26 00:01:30 +0200
committerEugene Sandulenko2019-09-27 00:22:20 +0200
commitf12d7160f840eaa2607002cf0be2e3e8c1b17941 (patch)
tree341c0bb69f99580bd3e9597ee9d269c51cb062fb /backends/platform/android
parent23211392c0310179bf27612d7a7b58eec106b8ce (diff)
downloadscummvm-rg350-f12d7160f840eaa2607002cf0be2e3e8c1b17941.tar.gz
scummvm-rg350-f12d7160f840eaa2607002cf0be2e3e8c1b17941.tar.bz2
scummvm-rg350-f12d7160f840eaa2607002cf0be2e3e8c1b17941.zip
ANDROID: Added list of external storages to the list of accessible directories
Diffstat (limited to 'backends/platform/android')
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ExternalStorage.java36
1 files changed, 32 insertions, 4 deletions
diff --git a/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java b/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
index d8bab31517..acfd2393a4 100644
--- a/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
+++ b/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
@@ -115,7 +115,7 @@ public class ExternalStorage {
}
}
hash += "]";
- if (!mountHash.contains(hash)){
+ if (!mountHash.contains(hash)) {
String key = SD_CARD + "_" + (map.size() / 2);
if (map.size() == 0) {
key = SD_CARD;
@@ -134,10 +134,38 @@ public class ExternalStorage {
map.add(DATA_DIRECTORY);
map.add(Environment.getDataDirectory().getAbsolutePath());
- if (map.isEmpty()) {
- map.add(SD_CARD);
- map.add(Environment.getExternalStorageDirectory().getAbsolutePath());
+ // Now go through the external storage
+ String state = Environment.getExternalStorageState();
+
+ if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state) ) { // we can read the External Storage...
+ // Retrieve the primary External Storage:
+ File primaryExternalStorage = Environment.getExternalStorageDirectory();
+
+ //Retrieve the External Storages root directory:
+ String externalStorageRootDir;
+ int count = 0;
+ if ((externalStorageRootDir = primaryExternalStorage.getParent()) == null) { // no parent...
+ String key = primaryExternalStorage.getAbsolutePath();
+ if (!map.contains(key)) {
+ map.add(key); // Make name as directory
+ map.add(key);
+ }
+ } else {
+ File externalStorageRoot = new File(externalStorageRootDir);
+ File[] files = externalStorageRoot.listFiles();
+
+ for (final File file : files) {
+ if (file.isDirectory() && file.canRead() && (file.listFiles().length > 0)) { // it is a real directory (not a USB drive)...
+ String key = file.getAbsolutePath();
+ if (!map.contains(key)) {
+ map.add(key); // Make name as directory
+ map.add(key);
+ }
+ }
+ }
+ }
}
+
return map;
}
}