bool CXBMCApp::GetExternalStorage(std::string &path, const std::string &type /* = "" */) { std::string sType; std::string mountedState; bool mounted = false; if(type == "files" || type.empty()) { CJNIFile external = CJNIEnvironment::getExternalStorageDirectory(); if (external) path = external.getAbsolutePath(); } else { if (type == "music") sType = "Music"; // Environment.DIRECTORY_MUSIC else if (type == "videos") sType = "Movies"; // Environment.DIRECTORY_MOVIES else if (type == "pictures") sType = "Pictures"; // Environment.DIRECTORY_PICTURES else if (type == "photos") sType = "DCIM"; // Environment.DIRECTORY_DCIM else if (type == "downloads") sType = "Download"; // Environment.DIRECTORY_DOWNLOADS if (!sType.empty()) { CJNIFile external = CJNIEnvironment::getExternalStoragePublicDirectory(sType); if (external) path = external.getAbsolutePath(); } } mountedState = CJNIEnvironment::getExternalStorageState(); mounted = (mountedState == "mounted" || mountedState == "mounted_ro"); return mounted && !path.empty(); }
void CXBMCApp::SetupEnv() { setenv("XBMC_ANDROID_SYSTEM_LIBS", CJNISystem::getProperty("java.library.path").c_str(), 0); setenv("XBMC_ANDROID_DATA", getApplicationInfo().dataDir.c_str(), 0); setenv("XBMC_ANDROID_LIBS", getApplicationInfo().nativeLibraryDir.c_str(), 0); setenv("XBMC_ANDROID_APK", getPackageResourcePath().c_str(), 0); std::string cacheDir = getCacheDir().getAbsolutePath(); setenv("XBMC_TEMP", (cacheDir + "/temp").c_str(), 0); setenv("XBMC_BIN_HOME", (cacheDir + "/apk/assets").c_str(), 0); 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(); if (!externalDir.empty()) setenv("HOME", externalDir.c_str(), 0); else setenv("HOME", getenv("XBMC_TEMP"), 0); }
void CXBMCApp::SetupEnv() { setenv("KODI_ANDROID_SYSTEM_LIBS", CJNISystem::getProperty("java.library.path").c_str(), 0); setenv("KODI_ANDROID_LIBS", getApplicationInfo().nativeLibraryDir.c_str(), 0); setenv("KODI_ANDROID_APK", getPackageResourcePath().c_str(), 0); std::string appName = CCompileInfo::GetAppName(); StringUtils::ToLower(appName); std::string className = CCompileInfo::GetPackage(); std::string cacheDir = getCacheDir().getAbsolutePath(); std::string xbmcHome = CJNISystem::getProperty("xbmc.home", ""); if (xbmcHome.empty()) { setenv("KODI_BIN_HOME", (cacheDir + "/apk/assets").c_str(), 0); setenv("KODI_HOME", (cacheDir + "/apk/assets").c_str(), 0); } else { setenv("KODI_BIN_HOME", (xbmcHome + "/assets").c_str(), 0); setenv("KODI_HOME", (xbmcHome + "/assets").c_str(), 0); } setenv("KODI_BINADDON_PATH", (cacheDir + "/lib").c_str(), 0); std::string externalDir = CJNISystem::getProperty("xbmc.data", ""); if (externalDir.empty()) { CJNIFile androidPath = getExternalFilesDir(""); if (!androidPath) androidPath = getDir(className.c_str(), 1); if (androidPath) externalDir = androidPath.getAbsolutePath(); } if (!externalDir.empty()) setenv("HOME", externalDir.c_str(), 0); else setenv("HOME", getenv("KODI_TEMP"), 0); std::string apkPath = getenv("KODI_ANDROID_APK"); apkPath += "/assets/python2.7"; setenv("PYTHONHOME", apkPath.c_str(), 1); setenv("PYTHONPATH", "", 1); setenv("PYTHONOPTIMIZE","", 1); setenv("PYTHONNOUSERSITE", "1", 1); }