aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/dialogs/GUIDialogMediaSource.cpp14
-rw-r--r--xbmc/platform/android/PlatformAndroid.cpp3
-rw-r--r--xbmc/platform/android/activity/XBMCApp.cpp37
-rw-r--r--xbmc/platform/android/activity/XBMCApp.h7
-rw-r--r--xbmc/platform/android/storage/AndroidStorageProvider.cpp45
-rw-r--r--xbmc/platform/android/storage/AndroidStorageProvider.h8
6 files changed, 59 insertions, 55 deletions
diff --git a/xbmc/dialogs/GUIDialogMediaSource.cpp b/xbmc/dialogs/GUIDialogMediaSource.cpp
index 0afbc2d060..1109157c63 100644
--- a/xbmc/dialogs/GUIDialogMediaSource.cpp
+++ b/xbmc/dialogs/GUIDialogMediaSource.cpp
@@ -36,7 +36,7 @@
#if defined(TARGET_ANDROID)
#include "utils/FileUtils.h"
-#include "platform/android/activity/XBMCApp.h"
+#include "platform/android/storage/AndroidStorageProvider.h"
#endif
#ifdef TARGET_WINDOWS_STORE
@@ -249,7 +249,8 @@ void CGUIDialogMediaSource::OnPathBrowse(int item)
#if defined(TARGET_ANDROID)
// add the default android music directory
std::string path;
- if (CXBMCApp::GetExternalStorage(path, "music") && !path.empty() && CDirectory::Exists(path))
+ if (CAndroidStorageProvider::GetExternalStorage(path, "music") && !path.empty() &&
+ CDirectory::Exists(path))
{
share1.strPath = path;
share1.strName = g_localizeStrings.Get(20240);
@@ -303,7 +304,8 @@ void CGUIDialogMediaSource::OnPathBrowse(int item)
#if defined(TARGET_ANDROID)
// add the default android video directory
std::string path;
- if (CXBMCApp::GetExternalStorage(path, "videos") && !path.empty() && CFileUtils::Exists(path))
+ if (CAndroidStorageProvider::GetExternalStorage(path, "videos") && !path.empty() &&
+ CFileUtils::Exists(path))
{
share1.strPath = path;
share1.strName = g_localizeStrings.Get(20241);
@@ -349,7 +351,8 @@ void CGUIDialogMediaSource::OnPathBrowse(int item)
#if defined(TARGET_ANDROID)
// add the default android music directory
std::string path;
- if (CXBMCApp::GetExternalStorage(path, "pictures") && !path.empty() && CFileUtils::Exists(path))
+ if (CAndroidStorageProvider::GetExternalStorage(path, "pictures") && !path.empty() &&
+ CFileUtils::Exists(path))
{
share1.strPath = path;
share1.strName = g_localizeStrings.Get(20242);
@@ -358,7 +361,8 @@ void CGUIDialogMediaSource::OnPathBrowse(int item)
}
path.clear();
- if (CXBMCApp::GetExternalStorage(path, "photos") && !path.empty() && CFileUtils::Exists(path))
+ if (CAndroidStorageProvider::GetExternalStorage(path, "photos") && !path.empty() &&
+ CFileUtils::Exists(path))
{
share1.strPath = path;
share1.strName = g_localizeStrings.Get(20243);
diff --git a/xbmc/platform/android/PlatformAndroid.cpp b/xbmc/platform/android/PlatformAndroid.cpp
index ba9208f6f5..d35896cd14 100644
--- a/xbmc/platform/android/PlatformAndroid.cpp
+++ b/xbmc/platform/android/PlatformAndroid.cpp
@@ -17,6 +17,7 @@
#include "platform/android/activity/XBMCApp.h"
#include "platform/android/powermanagement/AndroidPowerSyscall.h"
+#include "platform/android/storage/AndroidStorageProvider.h"
#include <stdlib.h>
@@ -66,7 +67,7 @@ void CPlatformAndroid::PlatformSyslog()
CJNIBuild::BRAND, CJNIBuild::MODEL, CJNIBuild::HARDWARE);
std::string extstorage;
- bool extready = CXBMCApp::GetExternalStorage(extstorage);
+ const bool extready = CAndroidStorageProvider::GetExternalStorage(extstorage);
CLog::Log(
LOGINFO, "External storage path = {}; status = {}; Permissions = {}{}", extstorage,
extready ? "ok" : "nok",
diff --git a/xbmc/platform/android/activity/XBMCApp.cpp b/xbmc/platform/android/activity/XBMCApp.cpp
index b4cdde669c..10e00d0146 100644
--- a/xbmc/platform/android/activity/XBMCApp.cpp
+++ b/xbmc/platform/android/activity/XBMCApp.cpp
@@ -81,7 +81,6 @@
#include <androidjni/Cursor.h>
#include <androidjni/Display.h>
#include <androidjni/DisplayManager.h>
-#include <androidjni/Environment.h>
#include <androidjni/File.h>
#include <androidjni/Intent.h>
#include <androidjni/IntentFilter.h>
@@ -1091,42 +1090,6 @@ int CXBMCApp::GetBatteryLevel() const
return m_batteryLevel;
}
-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();
-}
-
// Used in Application.cpp to figure out volume steps
int CXBMCApp::GetMaxSystemVolume()
{
diff --git a/xbmc/platform/android/activity/XBMCApp.h b/xbmc/platform/android/activity/XBMCApp.h
index 6fa89cbce3..73f5dcdf09 100644
--- a/xbmc/platform/android/activity/XBMCApp.h
+++ b/xbmc/platform/android/activity/XBMCApp.h
@@ -166,13 +166,6 @@ public:
const std::string& className = std::string());
std::vector<androidPackage> GetApplications() const;
- /*!
- * \brief If external storage is available, it returns the path for the external storage (for the specified type)
- * \param path will contain the path of the external storage (for the specified type)
- * \param type optional type. Possible values are "", "files", "music", "videos", "pictures", "photos, "downloads"
- * \return true if external storage is available and a valid path has been stored in the path parameter
- */
- static bool GetExternalStorage(std::string& path, const std::string& type = "");
static int GetMaxSystemVolume();
static float GetSystemVolume();
static void SetSystemVolume(float percent);
diff --git a/xbmc/platform/android/storage/AndroidStorageProvider.cpp b/xbmc/platform/android/storage/AndroidStorageProvider.cpp
index 33f7ab8a23..59fe3d6ae2 100644
--- a/xbmc/platform/android/storage/AndroidStorageProvider.cpp
+++ b/xbmc/platform/android/storage/AndroidStorageProvider.cpp
@@ -17,8 +17,6 @@
#include "utils/URIUtils.h"
#include "utils/log.h"
-#include "platform/android/activity/XBMCApp.h"
-
#include <array>
#include <cstdio>
#include <cstdlib>
@@ -131,7 +129,7 @@ void CAndroidStorageProvider::GetLocalDrives(VECSOURCES &localDrives)
// external directory
std::string path;
- if (CXBMCApp::GetExternalStorage(path) && !path.empty() && XFILE::CDirectory::Exists(path))
+ if (GetExternalStorage(path) && !path.empty() && XFILE::CDirectory::Exists(path))
{
share.strPath = path;
share.strName = g_localizeStrings.Get(21456);
@@ -391,8 +389,7 @@ std::vector<std::string> CAndroidStorageProvider::GetDiskUsage()
usage.clear();
// add external storage if available
std::string path;
- if (CXBMCApp::GetExternalStorage(path) && !path.empty() && GetStorageUsage(path, usage) &&
- !usage.empty())
+ if (GetExternalStorage(path) && !path.empty() && GetStorageUsage(path, usage) && !usage.empty())
result.push_back(usage);
// add removable storage
@@ -451,3 +448,41 @@ bool CAndroidStorageProvider::GetStorageUsage(const std::string& path, std::stri
PATH_MAXLEN, totalSize, "G", usedSize, "G", freeSize, "G", usedPercentage, "%");
return true;
}
+
+bool CAndroidStorageProvider::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();
+}
diff --git a/xbmc/platform/android/storage/AndroidStorageProvider.h b/xbmc/platform/android/storage/AndroidStorageProvider.h
index e39ff60dea..abd7b8e3b2 100644
--- a/xbmc/platform/android/storage/AndroidStorageProvider.h
+++ b/xbmc/platform/android/storage/AndroidStorageProvider.h
@@ -30,6 +30,14 @@ public:
bool PumpDriveChangeEvents(IStorageEventsCallback* callback) override;
+ /*!
+ * \brief If external storage is available, it returns the path for the external storage (for the specified type)
+ * \param path will contain the path of the external storage (for the specified type)
+ * \param type optional type. Possible values are "", "files", "music", "videos", "pictures", "photos, "downloads"
+ * \return true if external storage is available and a valid path has been stored in the path parameter
+ */
+ static bool GetExternalStorage(std::string& path, const std::string& type = "");
+
private:
std::string unescape(const std::string& str);
VECSOURCES m_removableDrives;