aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Kaijser <martijn@xbmc.org>2016-03-25 19:48:04 +0100
committerMartijn Kaijser <martijn@xbmc.org>2016-03-25 19:48:04 +0100
commit3a056a3b2a816f7d5f370346eb491ac3ebfe2995 (patch)
tree1be90d1fcd9da22f73c9882010c32f959a2898cb
parentc19f21aca89e05ea72cdbebae05ae9ff39c4ec86 (diff)
parent8128cbaccc432b0dc6c909fadf00c79e7f449a8d (diff)
Merge pull request #9422 from fritsch/jarvis-mount
Partial backport of 9250
-rw-r--r--xbmc/storage/android/AndroidStorageProvider.cpp42
-rw-r--r--xbmc/storage/android/AndroidStorageProvider.h4
2 files changed, 29 insertions, 17 deletions
diff --git a/xbmc/storage/android/AndroidStorageProvider.cpp b/xbmc/storage/android/AndroidStorageProvider.cpp
index dc0c4189ab..a8091781e4 100644
--- a/xbmc/storage/android/AndroidStorageProvider.cpp
+++ b/xbmc/storage/android/AndroidStorageProvider.cpp
@@ -45,7 +45,8 @@ static const char * mountBL[] = {
"/mnt/media_rw/extSdCard",
"/mnt/media_rw/sdcard",
"/mnt/media_rw/usbdisk",
- "/storage/emulated"
+ "/storage/emulated",
+ "/mnt/runtime"
};
static const char * deviceWL[] = {
"/dev/block/vold",
@@ -55,7 +56,6 @@ static const char * deviceWL[] = {
CAndroidStorageProvider::CAndroidStorageProvider()
{
- m_removableLength = 0;
PumpDriveChangeEvents(NULL);
}
@@ -117,8 +117,10 @@ void CAndroidStorageProvider::GetLocalDrives(VECSOURCES &localDrives)
localDrives.push_back(share);
}
-void CAndroidStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives)
+std::set<std::string> CAndroidStorageProvider::GetRemovableDrives()
{
+ std::set<std::string> result;
+
// mounted usb disks
char* buf = NULL;
FILE* pipe;
@@ -210,15 +212,7 @@ void CAndroidStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives)
if(devok && (fsok || mountok))
{
- // Reject unreadable
- if (XFILE::CDirectory::Exists(mountStr))
- {
- CMediaSource share;
- share.strPath = unescape(mountStr);
- share.strName = URIUtils::GetFileName(mountStr);
- share.m_ignore = true;
- removableDrives.push_back(share);
- }
+ result.insert(mountStr);
}
}
}
@@ -226,6 +220,23 @@ void CAndroidStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives)
}
free(buf);
}
+ return result;
+}
+
+void CAndroidStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives)
+{
+ for (const auto& mountStr : GetRemovableDrives())
+ {
+ // Reject unreadable
+ if (XFILE::CDirectory::Exists(mountStr))
+ {
+ CMediaSource share;
+ share.strPath = unescape(mountStr);
+ share.strName = URIUtils::GetFileName(mountStr);
+ share.m_ignore = true;
+ removableDrives.push_back(share);
+ }
+ }
}
std::vector<std::string> CAndroidStorageProvider::GetDiskUsage()
@@ -269,9 +280,8 @@ bool CAndroidStorageProvider::Eject(const std::string& mountpath)
bool CAndroidStorageProvider::PumpDriveChangeEvents(IStorageEventsCallback *callback)
{
- VECSOURCES drives;
- GetRemovableDrives(drives);
- bool changed = drives.size() != m_removableLength;
- m_removableLength = drives.size();
+ auto drives = GetRemovableDrives();
+ bool changed = m_removableDrives != drives;
+ m_removableDrives = std::move(drives);
return changed;
}
diff --git a/xbmc/storage/android/AndroidStorageProvider.h b/xbmc/storage/android/AndroidStorageProvider.h
index 876d478f98..d405c206ed 100644
--- a/xbmc/storage/android/AndroidStorageProvider.h
+++ b/xbmc/storage/android/AndroidStorageProvider.h
@@ -19,6 +19,7 @@
*
*/
+#include <set>
#include "storage/IStorageProvider.h"
class CAndroidStorageProvider : public IStorageProvider
@@ -40,6 +41,7 @@ public:
virtual bool PumpDriveChangeEvents(IStorageEventsCallback *callback);
private:
+ static std::set<std::string> GetRemovableDrives();
std::string unescape(const std::string& str);
- unsigned int m_removableLength;
+ std::set<std::string> m_removableDrives;
};