- attempt to fix storage location list issue on Android 4.3+

This commit is contained in:
Rolzad73
2016-08-04 14:53:52 -04:00
parent 77dfd51b28
commit 0c4e72ece2
2 changed files with 19 additions and 13 deletions
@@ -149,7 +149,7 @@ public class StorageOptions
mMounts.add(defaultMountPoint); mMounts.add(defaultMountPoint);
} catch (Exception e) } catch (Exception e)
{ {
Log.e(TAG, e.getMessage() + ": unknown exception while reading mounts file"); Log.e(TAG, e.getMessage() + ": unknown exception while reading vold.fstab file");
mMounts.add(defaultMountPoint); mMounts.add(defaultMountPoint);
} }
} }
@@ -179,11 +179,14 @@ public class StorageOptions
* Compare the two lists together and remove items that are not in both lists. * Compare the two lists together and remove items that are not in both lists.
*/ */
for (int i = 0; i < mMounts.size(); i++) if (mVold.size() > 0)
{ {
String mount = mMounts.get(i); for (int i = 0; i < mMounts.size(); i++)
if (!mVold.contains(mount)) {
mMounts.remove(i--); String mount = mMounts.get(i);
if (!mVold.contains(mount))
mMounts.remove(i--);
}
} }
// don't need this anymore, clear the vold list to reduce memory // don't need this anymore, clear the vold list to reduce memory
@@ -207,7 +210,8 @@ public class StorageOptions
} }
if (t == 0 && Build.VERSION.SDK_INT >= 16 && findForcemount()) if (t == 0 && Build.VERSION.SDK_INT >= 16 && findForcemount())
{//if none is found lets force it for Jellybean and above... {
//if none is found lets force it for Jellybean and above...
if (System.getenv("EXTERNAL_STORAGE") != null) if (System.getenv("EXTERNAL_STORAGE") != null)
{ {
File root = new File(System.getenv("EXTERNAL_STORAGE")); File root = new File(System.getenv("EXTERNAL_STORAGE"));
@@ -248,6 +252,7 @@ public class StorageOptions
private static void setProperties() private static void setProperties()
{ {
Log.d(TAG, "setProperties()");
/* /*
* At this point all the paths in the list should be valid. Build the public properties. * At this point all the paths in the list should be valid. Build the public properties.
*/ */
@@ -269,7 +274,8 @@ public class StorageOptions
else else
{ {
for (String path : mMounts) 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 {
// 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)) if ("/mnt/sdcard".equalsIgnoreCase(path))
mLabels.add("Built-in Storage"); mLabels.add("Built-in Storage");
else else
@@ -389,6 +395,7 @@ public class StorageOptions
private static boolean findForcemount() private static boolean findForcemount()
{ {
Log.d(TAG, "findForcemount()");
try try
{ {
File file = new File(System.getenv("EXTERNAL_STORAGE") + "/forcemount"); File file = new File(System.getenv("EXTERNAL_STORAGE") + "/forcemount");
@@ -396,8 +403,9 @@ public class StorageOptions
{ {
return true; return true;
} }
} catch (Exception e1) } catch (Exception e)
{ {
Log.w(TAG, e.getMessage());
return false; return false;
} }
return false; return false;
@@ -500,8 +500,6 @@ public class SDLActivity extends Activity implements OnKeyListener
// So we can call stuff from static callbacks // So we can call stuff from static callbacks
mSingleton = this; mSingleton = this;
mContext = this.getApplicationContext(); mContext = this.getApplicationContext();
// get the current version of the app to set the core filename
String versionCodeString = getApplicationCode();
RES_FILENAME = getResourceName(); RES_FILENAME = getResourceName();
StorageOptions.determineStorageOptions(); StorageOptions.determineStorageOptions();