Closed batcholi closed 5 years ago
The getExternalSdCardDetails()
function is intended to find paths of external removable SD cards on which the SD card adapter is directly mounted on the device, such as those in the Samsung Galaxy S range of devices.
OTG access is entirely different on Android 6+: OTG storage devices must be accessed via the Storage Access Framework (see this SO post). This is how dedicated File Manager apps support OTG storage devices.
getExternalSdCardDetails()
explicitly attempts to filter out non-SD card storage paths such as OTG devices, as can be seen in the source code. The reason for this is that even if the paths are found, on Android 6+ root access is required to read/write to them via the File API. Feel free to fork the plugin and comment out those lines but I think you will not be able to access the returned paths via the File API.
But in general, storage access via OTG is beyond the scope of the getExternalSdCardDetails()
function.
I will update the plugin documentation to make this explicitly clear.
File access via the Storage Access Framework is not trivial (as can be seen from the documentation). However it may be possible in future to add support for it as a new feature of this plugin's ExternalStorage module.
I'm submitting a ... (check one with "x"):
Bug report
On some android devices, the app cannot see removable devices (such as micro-sd cards or USB Flash drives via OTG adapter).
https://stackoverflow.com/questions/56085400/cordova-app-cant-find-removable-storage-on-some-devices-only
Current behavior: Outputs :
GRANTED
GRANTED
[ ]
Required permissions are granted, but no drive/sdcard is listed. But we can browse the files in the OTG and SD Card with other File Manager apps. This behavior happens only on some devices including a Pixel 3, Pixel 2, Mi MIX 3, HTC U11, Samsung S9+.
Expected behavior:
GRANTED
GRANTED
[ {...}, {...} ]
App can list the drives. This works on most devices including a Samsung Note 9 on Android 9 and a Note 3 on Android 5 and lots of other devices of all brands and android versions.
Steps to reproduce:
Code above, on certain devices only, I have not yet found a common difference between the ones that do work and the ones that do not.
Environment information
cordova -v
8.1.2 (cordova-lib@8.1.1)cordova platform ls
android 7.1.4cordova plugin ls
cordova-plugin-file 6.0.1 "File" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova.plugins.diagnostic 4.0.12 "Diagnostic"Runtime issue
Android build issue:
node -v
v11.13.0ls platforms/android/.gradle
4.1 5.2.1 buildOutputCleanupandroid:targetSdkVersion
inAndroidManifest.xml
android:minSdkVersion="19" android:targetSdkVersion="27"sdkmanager --list | sed -e '/Available Packages/q'
build-tools;24.0.3 | 24.0.3 | Android SDK Build-Tools 24.0.3 | build-tools/24.0.3/
build-tools;26.0.3 | 26.0.3 | Android SDK Build-Tools 26.0.3 | build-tools/26.0.3/
build-tools;27.0.3 | 27.0.3 | Android SDK Build-Tools 27.0.3 | build-tools/27.0.3/
build-tools;28.0.3 | 28.0.3 | Android SDK Build-Tools 28.0.3 | build-tools/28.0.3/
emulator | 29.0.6 | Android Emulator | emulator/
extras;android;m2repository | 47.0.0 | Android Support Repository | extras/android/m2repository/ patcher;v4 | 1 | SDK Patch Applier v4 | patcher/v4/
platform-tools | 28.0.2 | Android SDK Platform-Tools | platform-tools/
platforms;android-24 | 2 | Android SDK Platform 24 | platforms/android-24/
platforms;android-25 | 3 | Android SDK Platform 25 | platforms/android-25/
platforms;android-26 | 2 | Android SDK Platform 26 | platforms/android-26/
platforms;android-27 | 3 | Android SDK Platform 27 | platforms/android-27/
platforms;android-28 | 6 | Android SDK Platform 28 | platforms/android-28/
tools | 26.1.1 | Android SDK Tools | tools/
Related code:
Console output
GRANTED GRANTED [ ]
# AndroidManifest.xml ```