diff options
author | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2021-04-06 13:32:17 +0200 |
---|---|---|
committer | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2021-04-07 12:10:18 +0200 |
commit | 90452f1f6f21ee62c5be8cf30efb74f9041ccb75 (patch) | |
tree | 4a7441cc60a7bbe672a8c5b0db75ba910a9fca29 | |
parent | 9c31fd818c221b7f7db33fa91ccc36d069dfd0ca (diff) |
[Android] CAndroidStorageProvider::GetRemovableDrives() : Fix JNI call signature for StorageManager.getStorageVolumes.
-rw-r--r-- | tools/depends/target/libandroidjni/Makefile | 2 | ||||
-rw-r--r-- | xbmc/platform/android/storage/AndroidStorageProvider.cpp | 17 |
2 files changed, 16 insertions, 3 deletions
diff --git a/tools/depends/target/libandroidjni/Makefile b/tools/depends/target/libandroidjni/Makefile index 13f62b5493..962100029e 100644 --- a/tools/depends/target/libandroidjni/Makefile +++ b/tools/depends/target/libandroidjni/Makefile @@ -3,7 +3,7 @@ DEPS= ../../Makefile.include Makefile # lib name, version LIBNAME=libandroidjni -VERSION=ee5cc102101d9cb04ab4dbfd7a65db1c52345faf +VERSION=2b24db871a55a72897e3fedc354e1396ad01defd SOURCE=archive ARCHIVE=$(VERSION).tar.gz GIT_BASE_URL=https://github.com/xbmc diff --git a/xbmc/platform/android/storage/AndroidStorageProvider.cpp b/xbmc/platform/android/storage/AndroidStorageProvider.cpp index fc7cce6c22..98a87ee6c0 100644 --- a/xbmc/platform/android/storage/AndroidStorageProvider.cpp +++ b/xbmc/platform/android/storage/AndroidStorageProvider.cpp @@ -27,6 +27,7 @@ #include <androidjni/Context.h> #include <androidjni/Environment.h> #include <androidjni/StorageManager.h> +#include <androidjni/StorageVolume.h> static const char * typeWL[] = { "vfat", "exfat", "sdcardfs", "fuse", "ntfs", "fat32", "ext3", "ext4", "esdfs", "cifs" }; static const char * mountWL[] = { "/mnt", "/Removable", "/storage" }; @@ -118,13 +119,13 @@ void CAndroidStorageProvider::GetLocalDrives(VECSOURCES &localDrives) void CAndroidStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives) { - // Uses non-public API: be extra carefull bool inError = false; VECSOURCES droidDrives; CJNIStorageManager manager(CJNIContext::getSystemService("storage")); if (xbmc_jnienv()->ExceptionCheck()) { + xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); inError = true; } @@ -134,25 +135,31 @@ void CAndroidStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives) CJNIStorageVolumes vols = manager.getStorageVolumes(); if (xbmc_jnienv()->ExceptionCheck()) { + xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); inError = true; } if (!inError) { - for (auto vol : vols) + for (int i = 0; i < vols.size(); ++i) { + CJNIStorageVolume vol = vols.get(i); // CLog::Log(LOGDEBUG, "-- Volume: %s(%s) -- %s", vol.getPath().c_str(), vol.getUserLabel().c_str(), vol.getState().c_str()); + bool removable = vol.isRemovable(); if (xbmc_jnienv()->ExceptionCheck()) { + xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); inError = true; break; } + std::string state = vol.getState(); if (xbmc_jnienv()->ExceptionCheck()) { + xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); inError = true; break; @@ -161,23 +168,29 @@ void CAndroidStorageProvider::GetRemovableDrives(VECSOURCES &removableDrives) if (removable && state == CJNIEnvironment::MEDIA_MOUNTED) { CMediaSource share; + share.strPath = vol.getPath(); if (xbmc_jnienv()->ExceptionCheck()) { + xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); inError = true; break; } + share.strName = vol.getUserLabel(); if (xbmc_jnienv()->ExceptionCheck()) { + xbmc_jnienv()->ExceptionDescribe(); xbmc_jnienv()->ExceptionClear(); inError = true; break; } + StringUtils::Trim(share.strName); if (share.strName.empty() || share.strName == "?" || StringUtils::EqualsNoCase(share.strName, "null")) share.strName = URIUtils::GetFileName(share.strPath); + share.m_ignore = true; droidDrives.push_back(share); } |