How to check if Android Permission is actually being used?

Aung Pyae picture Aung Pyae · Jul 21, 2014 · Viewed 10k times · Source


I am maintaining one existing (very-huge, very-sensitive) Android Application.
The other day, I have received an email from my client that, the Application might be declaring the Permissions that are not actively being used.

For example, they wants me to remove "WRITE_EXTERNAL_STORAGE" permission.
I have removed it and compiled it and run the App. There is NO error at all.
But, just because of that, I don't think I can assume that permission is not actively being used at all.

My question is "Is there anyway I can easily and simply check the permission if it is actively being used ?"

Frankly, I don't want to go through every little detail aspect of that application just to fine out the permission is required or not.
I just don't have time.

My goal is check if the permission is actively being used. If not, remove the permission.
Hope there is an less-time consuming way for that.

Regards

Answer

Vasanth picture Vasanth · Aug 10, 2015

In Android Studio 1.3 & Android Support Library v7:22.2.0, you have solution for it.

Steps:

  1. Update Android Studio to V1.3
  2. Update your Android Support Library to v7:22.2.0
  3. Run Android Lint (Analyse -> Inspect Code), In Lint Error see for Type "Android -> Constant & Resource Type MisMatch", Which shows all methods which requires permission.

Explanation

  1. Android has introduced new annotation @requirespermission.
  2. All SDK methods which requires permission are annotated with @requirespermission.
  3. When we call any sdk method which requires permission without properly checking whether we have permission or not, Android studio will through lint error.