{"action":"created","issue":{"url":"https://api.github.com/repos/frostwire/frostwire/issues/111","repository_url":"https://api.github.com/repos/frostwire/frostwire","labels_url":"https://api.github.com/repos/frostwire/frostwire/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/frostwire/frostwire/issues/111/comments","events_url":"https://api.github.com/repos/frostwire/frostwire/issues/111/events","html_url":"https://github.com/frostwire/frostwire/issues/111","id":144326353,"number":111,"title":"[android] CRITICAL: Audio downloads to SD Card (Android 6) not being scanned","user":{"login":"gubatron","id":163977,"avatar_url":"https://avatars.githubusercontent.com/u/163977?v=3","gravatar_id":"","url":"https://api.github.com/users/gubatron","html_url":"https://github.com/gubatron","followers_url":"https://api.github.com/users/gubatron/followers","following_url":"https://api.github.com/users/gubatron/following{/other_user}","gists_url":"https://api.github.com/users/gubatron/gists{/gist_id}","starred_url":"https://api.github.com/users/gubatron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gubatron/subscriptions","organizations_url":"https://api.github.com/users/gubatron/orgs","repos_url":"https://api.github.com/users/gubatron/repos","events_url":"https://api.github.com/users/gubatron/events{/privacy}","received_events_url":"https://api.github.com/users/gubatron/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/frostwire/frostwire/labels/android","name":"android","color":"bfe5bf"},{"url":"https://api.github.com/repos/frostwire/frostwire/labels/broken","name":"broken","color":"eb6420"},{"url":"https://api.github.com/repos/frostwire/frostwire/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-03-29T17:03:44Z","updated_at":"2016-03-31T23:35:27Z","closed_at":null,"body":"Steps to reproduce:\r\n\r\n1. Install from source.\r\n2. Change save location to \"SD Card\" root (I saw there already was a \"FrostWire\" folder)\r\n3. Download an audio file from SoundCloud.\r\n4. Play it, it will play.\r\n5. The file is nowhere to be found in \"My Files\" nor in \"My Music\" even after a restart of the application.\r\n\r\nCC: @aldenml \r\n\r\nHere's the only hint I saw after the download was completed, even though permissions were granted.\r\nI'll try reinstalling and restarting the app right after permissions have been granted. I think I liked it better when the app would restart fresh after permissions were granted I've a feeling this is due to an inconsistent state. I'll revise the code on how permissions are granted, I'll need another pair of eyes with me. I can reproduce this every time, this bug is very severe and it's probably the one many users keep reporting saying they played a file but then it's not there anymore (even though the file has been saved to the SD card)\r\n```\r\n03-29 12:57:57.615  1925  3061 I ActivityManager: Start proc 22961:com.android.externalstorage/u0a39 for content provider com.android.externalstorage/.ExternalStorageProvider\r\n03-29 12:57:57.648 12544 12913 E DatabaseUtils: Writing exception to parcel\r\n03-29 12:57:57.648 12544 12913 E DatabaseUtils: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/fs_id from pid=22454, uid=10274 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()\r\n03-29 12:57:57.648 12544 12913 E DatabaseUtils: \tat android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:605)\r\n03-29 12:57:57.648 12544 12913 E DatabaseUtils: \tat android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:480)\r\n03-29 12:57:57.648 12544 12913 E DatabaseUtils: \tat android.content.ContentProvider$Transport.query(ContentProvider.java:211)\r\n03-29 12:57:57.648 12544 12913 E DatabaseUtils: \tat android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)\r\n03-29 12:57:57.648 12544 12913 E DatabaseUtils: \tat android.os.Binder.execTransact(Binder.java:453)\r\n```"},"comment":{"url":"https://api.github.com/repos/frostwire/frostwire/issues/comments/204175368","html_url":"https://github.com/frostwire/frostwire/issues/111#issuecomment-204175368","issue_url":"https://api.github.com/repos/frostwire/frostwire/issues/111","id":204175368,"user":{"login":"gubatron","id":163977,"avatar_url":"https://avatars.githubusercontent.com/u/163977?v=3","gravatar_id":"","url":"https://api.github.com/users/gubatron","html_url":"https://github.com/gubatron","followers_url":"https://api.github.com/users/gubatron/followers","following_url":"https://api.github.com/users/gubatron/following{/other_user}","gists_url":"https://api.github.com/users/gubatron/gists{/gist_id}","starred_url":"https://api.github.com/users/gubatron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gubatron/subscriptions","organizations_url":"https://api.github.com/users/gubatron/orgs","repos_url":"https://api.github.com/users/gubatron/repos","events_url":"https://api.github.com/users/gubatron/events{/privacy}","received_events_url":"https://api.github.com/users/gubatron/received_events","type":"User","site_admin":false},"created_at":"2016-03-31T23:35:27Z","updated_at":"2016-03-31T23:35:27Z","body":"After testing and attempting to fix this issue, we've figured out:\r\n\r\n1. Files are saved correctly by the SAF framework.\r\n2. On some devices, the Media Provider cannot scan the folder because it needs system-level permission (`MANAGE_DOCUMENT`)\r\n\r\nThe final solution will be to have a custom provider that keeps track of the files on the FrostWire SD Card save folder. Our app will have no issues tracking when files have finished downloading, when files are removed (with our app), and perhaps everytime the app is started we can do a once-per-session scan in case users have added/removed files in the frostwire save folder with 3rd party apps.\r\n\r\nWe can now do this because we can  scan mp3s now without android's underlying media scanner."}}