I am working on an application for pre-Marshmallow devices. The source code was not written by me and the project itself is quite big. I am currently making the app to request permissions when needed.
The question is: How to find all places in code where permission should be requested? I am using Android Studio.
EDIT
Some people suggest to change api to 23 and just run the app and see the places where it crashes.
The problem is that the app does not crash in every place.
For example, running this code without a permission will crash the app:
TelephonyManager manager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
While this one just returns an empty array, instead of crashing.
final String[] SELF_PROJECTION = new String[]{
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,};
Cursor cursor = context.getContentResolver()
.query(ContactsContract.Profile.CONTENT_URI, SELF_PROJECTION, null, null, null);
Also, Android Lint does not show these places. I'm not sure if it should be.
According to the developer page regarding security permissions :
In almost all cases, however, a permission failure will be printed to the system log.
So run the app and search the log for "permissions" or similar.
Use unit testing to ensure coverage of all the places in the code where permissions may be required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With