Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[droid] Check external storage state before using it #1850

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+12 −6
Split
@@ -558,12 +558,18 @@ void CXBMCApp::SetupEnv()
setenv("XBMC_HOME", (cacheDir + "/apk/assets").c_str(), 0);
std::string externalDir;
- CJNIFile androidPath = getExternalFilesDir("");
- if (!androidPath)
- androidPath = getDir("org.xbmc.xbmc", 1);
-
- if (androidPath)
- externalDir = androidPath.getAbsolutePath();
+ std::string mountedState = CJNIEnvironment::getExternalStorageState();
+ bool mounted = mountedState == "mounted";
+
+ if (mounted)
+ {
+ CJNIFile androidPath = getExternalFilesDir("");
+ if (!androidPath)
+ androidPath = getDir("org.xbmc.xbmc", 1);
+
+ if (androidPath)
+ externalDir = androidPath.getAbsolutePath();
+ }
if (!externalDir.empty())
setenv("HOME", externalDir.c_str(), 0);