Closed stephanepechard closed 9 years ago
@stephanepechard Is this due to the new permissions in Android 6? I got a stacktrace like:
11-01 14:24:43.004 5248-5266/? W/System.err: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=5248, uid=10113 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
The docs indicate that "dangerous" permissions aren't granted anymore on install, and rather need to use requestPermissions
.
I started working to add this, but didn't know what you would think would be the best location:
PBMediaStore.doInBackground
)Yeah, the problem is probably due to the new permissions system. For me, the best location would be 1. as it does not interfere with the nominal action of taking a picture (in 2.). The thing is, if the user does not give permission, the PB service should not even run, so we should ask for it at the first launch of the service. Don't you think?
That is what I was thinking as well.
However, what do you think about the corner case when the user goes into settings and revokes the storage permission? Should we then "re-ask" for permission?
Yes, we should. In fact, we should check permission each time the service is started. This is just another check, like checking if server address is set, password is set, etc.
I created PR #9 to start addressing this. I'm not a java programmer, and even less an Android one, so keep that in mind while reviewing it.
I think we will still need to address checking for permissions in PBMediaStore.doInBackground
to make sure the user hasn't revoked the permission, but at least this will prompt them to grant READ_EXTERNAL_STORAGE
when attempting to start the service for the first time.
@stephanepechard Have you had a chance to look over the PR? I only ask because I will have some time this weekend to make any suggested changes/improvements.
Yes, I took a look and it helped me implementing the bugfix. I made it a bit simpler, that's why I didn't pull your contribution. I want to test a bit before commiting, I will to do it this week-end, or even today if I can. Thanks again!
Excellent, glad I could be of some help!
Fixed in v0.6.5
On Android 6 (Marshmallow), the service starts and the test to the server is ok, but the upload journal is not accessible after launch and taking a picture does not trigger the service.