diff --git a/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java b/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java index 95b712017..e90a5fa7a 100644 --- a/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java +++ b/projects/mtg/Android/src/net/wagic/utils/StorageOptions.java @@ -25,10 +25,14 @@ public class StorageOptions public static void determineStorageOptions() { initializeMountPoints(); - readMountsFileTest(); + if (findForcemount()){ + readMountsFileTest(); + } readMountsFile(); readVoldFile(); - removeDuplicates(mMounts); + if (findForcemount()){ + removeDuplicates(mMounts); + } compareMountsWithVold(); testAndCleanMountsList(); setProperties(); @@ -201,7 +205,7 @@ public class StorageOptions mMounts.remove(i--); } - if (t == 0 && Build.VERSION.SDK_INT >= 16) + if (t == 0 && Build.VERSION.SDK_INT >= 16 && findForcemount()) {//if none is found lets force it for Jellybean and above... if (System.getenv("EXTERNAL_STORAGE") != null) { @@ -210,7 +214,7 @@ public class StorageOptions { if(!isRooted()) { - File folder = new File(System.getenv("EXTERNAL_STORAGE")+"/Android/data/net.wagic.app/files"); + File folder = new File(System.getenv("EXTERNAL_STORAGE")+"/Android/data/net.wagic.app"); folder.mkdirs(); mMounts.add(folder.toString()); } @@ -228,7 +232,7 @@ public class StorageOptions { if(!isRooted()) { - File folder = new File(System.getenv("SECONDARY_STORAGE")+"/Android/data/net.wagic.app/files"); + File folder = new File(System.getenv("SECONDARY_STORAGE")+"/Android/data/net.wagic.app"); folder.mkdirs(); mMounts.add(folder.toString()); } @@ -250,16 +254,28 @@ public class StorageOptions ArrayList mLabels = new ArrayList(); int i = 1; - for (String path : mMounts) - { // TODO: /mnt/sdcard is assumed to always mean internal storage. Use this comparison until there is a better way to do this - if ("/mnt/sdcard".equalsIgnoreCase(path) || "/storage/sdcard0".equalsIgnoreCase(path)) - mLabels.add("Internal SD " + "[" + path + "]"); - else if (path.contains("emulated")) - mLabels.add("Emulated SD " + " [" + path + "]"); - else - mLabels.add("External SD " + " [" + path + "]"); + if(findForcemount()){ + for (String path : mMounts) + {//with forcemount menu + if ("/mnt/sdcard".equalsIgnoreCase(path) || "/storage/sdcard0".equalsIgnoreCase(path)) + mLabels.add("Internal SD " + "[" + path + "]"); + else if (path.contains("emulated")) + mLabels.add("Emulated SD " + " [" + path + "]"); + else + mLabels.add("External SD " + " [" + path + "]"); + } } - + else + { + for (String path : mMounts) + { // TODO: /mnt/sdcard is assumed to always mean internal storage. Use this comparison until there is a better way to do this + if ("/mnt/sdcard".equalsIgnoreCase(path)) + mLabels.add("Built-in Storage"); + else + mLabels.add("External SD Card " + i++); + } + } + labels = new String[mLabels.size()]; mLabels.toArray(labels); @@ -358,4 +374,20 @@ public class StorageOptions return executedSuccesfully; } + + private static boolean findForcemount(){ + try + { + File file = new File(System.getenv("EXTERNAL_STORAGE")+"/forcemount"); + if (file.exists()) + { + return true; + } + } + catch (Exception e1) + { + return false; + } + return false; + } }