Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26238] Android: Storage-permissions issue on Android 8 (API 26+)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionInvalid
Resolution Date2018-07-26T16:31:04.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
LabelsAndroid8.0, Permissions
ReporterJorge Macias Garcia
AssigneeShak Hossain
Created2018-07-26T08:52:39.000+0000
Updated2018-07-26T16:34:11.000+0000

Description

I've made a four different ways to check and request storage permissions. One of them fails, combining *Ti.Android.hasPermission* and *Ti.filesystem.requestStoragePermissions* I attached the sample app. Special attention in tiapp.xml. The permission WRITE_EXTERNAL_STORAGE is declared explicitly in the android manifest section and the override property set to true. After each test, if you disable storage permissions manually from app settings page the log will be disconnected. For a correct testing: Uninstall the app and build again. Behaviour: *First execution trace* Check permissions with: Ti.Android.hasPermission Requesting permissions with: Ti.Filesystem.requestStoragePermissions hasStoragePermission Ti.Android.hasPermission("android.permission.WRITE_EXTERNAL_STORAGE"): false requestFilesystemPermission Ti.Filesystem.requestStoragePermissions [Prompt permission grant dialog] Allow requestPermissionCallback Permission Filesystem permission granted. Finished OK -> Permission granted Trying again Check permissions with: Ti.Android.hasPermission Requesting permissions with: Ti.Filesystem.requestStoragePermissions hasStoragePermission Ti.Android.hasPermission("android.permission.WRITE_EXTERNAL_STORAGE"): false requestFilesystemPermission Ti.Filesystem.requestStoragePermissions FAIL *Second execution trace* Check permissions with: Ti.Android.hasPermission Requesting permissions with: Ti.Filesystem.requestStoragePermissions hasStoragePermission Ti.Android.hasPermission("android.permission.WRITE_EXTERNAL_STORAGE"): false requestFilesystemPermission Ti.Filesystem.requestStoragePermissions FAIL Other 3 combinations works fine: *Native method:* Check permissions with: Ti.Android.hasPermission Requesting permissions with: Ti.Android.requestPermissions OK *Filesystem method:* Check permissions with: Ti.Filesystem.hasStoragePermissions Requesting permissions with: Ti.Filesystem.requestStoragePermissions OK *Mixed method B:* Check permissions with: Ti.Filesystem.hasStoragePermissions Requesting permissions with: Ti.Android.requestPermissions OK

Attachments

FileDateSize
CameraExternalTest.js2018-07-26T16:28:23.000+00001268
PermissionTest.zip2018-07-26T08:46:33.000+00009206506
test-result.txt2018-07-26T09:10:11.000+00005152

Comments

  1. Joshua Quick 2018-07-26

    This is not a bug. The Ti.Filesystem.requestStoragePermission() requests the READ_EXTERNAL_STORAGE permission. It does *+not+* request the WRITE_EXTERNAL_STORAGE. https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-method-requestStoragePermissions Android used to be lenient about this where if the end-user granted READ_EXTERNAL_STORAGE permission, your app would also be granted WRITE_EXTERNAL_STORAGE permission since they were both in the same permission group. But Google has changed this for apps which target Android 8.0 or higher, which Titanium 7.3.0 does by default now. Google documents this here... https://developer.android.com/about/versions/oreo/android-8.0-changes#rmp Please see the attached [^CameraExternalTest.js]. You would not normally request permissions separately like this, but it proves that permission request/detection works. The point being, is if you want WRITE_EXTERNAL_STORAGE, you need to specifically request it. I hope this helps.
  2. Jorge Macias Garcia 2018-07-26

    It's clear! Thanks.

JSON Source