Details
Description
Hi,
i try to create a copy of a File thats URI is created by the Android FileChooser. Reading the file works, but when i try to get the parent and call getFile, I get an "Permission Denial" error.
This is the given URI:
content://com.android.externalstorage.documents/document/primary%3ADCIM%2FMA128%2Fparam_MA128_SX20_WWS24_S%C3%9CSSTD_FBK_RadgemRF_FBHgemTele.txt
This is my code:
console.log("resolving file system " + uri); window.resolveLocalFileSystemURL(uri, function (fileSystemEntry) { console.log("getting parent from: " + uri); fileSystemEntry.getParent(function (parent) { console.log("creating backup file: " + JSON.stringify(parent)); parent.getFile("myBackup.txt", {create: true, exclusive: false}, function (backupFileEntry) { callback(null, backupFileEntry); }, callback); }, callback); }, callback);
config.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <widget id="com.ionicframework.solvisparam100159" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>Solvis Param</name> <description> An Ionic Framework and Cordova project. </description> <author email="you@example.com" href="http://example.com.com/"> Your Name Here </author> <content src="index.html"/> <access origin="*"/> <preference name="webviewbounce" value="false"/> <preference name="UIWebViewBounce" value="false"/> <preference name="DisallowOverscroll" value="true"/> <preference name="SplashScreenDelay" value="2000"/> <preference name="FadeSplashScreenDuration" value="2000"/> <preference name="android-minSdkVersion" value="19"/> <preference name="BackupWebStorage" value="none"/> <preference name="SplashScreen" value="screen"/> <preference name="AndroidPersistentFileLocation" value="Compatibility"/> <preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,assets,root"/> <feature name="StatusBar"> <param name="ios-package" onload="true" value="CDVStatusBar"/> </feature> <plugin name="cordova-plugin-file" spec="~4.3.0"/> <plugin name="com.megster.cordova.FileChooser" spec="https://github.com/uklawitter/cordova-filechooser.git"/> <plugin name="cordova-plugin-android-permissions" spec="https://github.com/uklawitter/cordova-plugin-android-permission.git"/> <plugin name="cordova-plugin-console" spec="~1.0.4"/> <plugin name="cordova-plugin-whitelist" spec="~1.2.2"/> <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/> <plugin name="cordova-plugin-splashscreen" spec="x~3.2.2"/> <plugin name="cordova-plugin-device" spec="~1.1.3"/> <plugin name="cordova-plugin-statusbar" spec="~2.1.3"/> <plugin name="cordova-plugin-settings-hook" spec="~0.2.3"/> <platform name="android"> <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png"/> <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png"/> <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png"/> <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png"/> <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png"/> <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png"/> <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png"/> <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png"/> <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png"/> <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png"/> <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png"/> <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png"/> <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png"/> <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png"/> <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png"/> <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png"/> <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png"/> <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png"/> <config-file parent="/*" target="AndroidManifest.xml"> </config-file> </platform> <icon src="resources/android/icon/drawable-xhdpi-icon.png"/> </widget>
Log:
10-31 11:23:03.377 22424 22424 I chromium: [INFO:CONSOLE(73)] "resolving file system content://com.android.externalstorage.documents/document/primary%3ADCIM%2FMA128%2Fparam_MA128_SX20_WWS24_S%C3%9CSSTD_FBK_RadgemRF_FBHgemTele.txt", source: file:///android_asset/www/js/import/import.js (73) 10-31 11:23:03.379 197 810 D audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none) 10-31 11:23:03.379 197 810 D msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15) 10-31 11:23:03.379 197 810 D audio_hw_primary: enable_snd_device: snd_device(2: speaker) 10-31 11:23:03.381 197 810 D audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback 10-31 11:23:03.414 2363 2363 W Binder_C: type=1400 audit(0.0:24379): avc: denied { ioctl } for path="socket:[1314222]" dev="sockfs" ino=1314222 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0 10-31 11:23:03.414 2363 2363 W Binder_C: type=1400 audit(0.0:24380): avc: denied { ioctl } for path="socket:[1314222]" dev="sockfs" ino=1314222 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0 10-31 11:23:03.489 8164 8195 D OpenGLRenderer: endAllStagingAnimators on 0x9f527a00 (ListView) with handle 0xa093d470 10-31 11:23:03.562 22424 22424 I chromium: [INFO:CONSOLE(75)] "getting parent from: content://com.android.externalstorage.documents/document/primary%3ADCIM%2FMA128%2Fparam_MA128_SX20_WWS24_S%C3%9CSSTD_FBK_RadgemRF_FBHgemTele.txt", source: file:///android_asset/www/js/import/import.js (75) 10-31 11:23:03.566 22424 22424 I chromium: [INFO:CONSOLE(77)] "creating backup file: {"isFile":false,"isDirectory":true,"name":"MA128","fullPath":"/com.android.externalstorage.documents/document/primary:DCIM/MA128/","filesystem":"<FileSystem: content>","nativeURL":"content://com.android.externalstorage.documents/document/primary%3ADCIM/MA128/"}", source: file:///android_asset/www/js/import/import.js (77) 10-31 11:23:03.571 8179 8509 E DatabaseUtils: Writing exception to parcel 10-31 11:23:03.571 8179 8509 E DatabaseUtils: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/document/primary%3ADCIM/MA128/ from pid=22424, uid=10094 requires android.permission.MANAGE_DOCUMENTS, or grantUriPermission() 10-31 11:23:03.571 8179 8509 E DatabaseUtils: at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:605) 10-31 11:23:03.571 8179 8509 E DatabaseUtils: at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:480) 10-31 11:23:03.571 8179 8509 E DatabaseUtils: at android.content.ContentProvider$Transport.query(ContentProvider.java:211) 10-31 11:23:03.571 8179 8509 E DatabaseUtils: at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112) 10-31 11:23:03.571 8179 8509 E DatabaseUtils: at android.os.Binder.execTransact(Binder.java:453) 10-31 11:23:03.574 22424 22424 I chromium: [INFO:CONSOLE(60)] "err {"code":2}", source: file:///android_asset/www/js/main/main.js (60)