I have a few places in my code where state of permissions is not properly checked before the function requiring a permission is called. As a result I'm getting random SecurityException
reports as my users encounter unprotected function calls.
(long introduction, please skip to last paragraph if tl;dr)
The code was originally written long before Android Marshmallow which introduced on-demand permissions. When migrating it was tested pretty much on "first occurrence" basis, meaning that first occurrence of required permission was identified and appropriate premission check / request code was wrapped around that.
However, once this is passed, the user may decide to revoke an already given permission and my app will not encounter the first occurrence code path. Instead an "already active" code path will be run resulting in SecurityExceptions as the permissions in question are no longer granted.
I'm obviously struggling with finding the affected code segments and thus tried (once more) to try and determine the functions requiring permissions through the use of lint. There are some posts on SO dealing with the issue.
However, I have been unsuccessful setting lint tool up such that it would actually identify the code lines invoking functions requiring permissions. All I ever get is one identified line where I'm warned that I should either wrap the call in checkPermisison
or explicitly catch SecurityException
.
This is of course not adequate as I know that my app requires 7 distinct permissions and I'm pretty sure the functions involved are there too (since I had to wrap some of them already).
Anyway, I'm guessing this needs to be set up somehow. Currently I'm using pretty much vanilla Android Studio 3.0.1 except for colour settings and code format settings. No code checks have been touched.
After just spending two days trying to set up the lint tool using all my Google-fu & SO-fu, I'm giving up writing this question. And yes, I HAVE removed the permissions from manifest.
I'm using both a library and flavors, if this makes any difference.
Can you give me a step-by-step guide on what needs to be done for lint to successfully identify functions requiring permissions?