2

I have a large project with lots of features that require permissions. The problem is that the developer who started this project a year ago, just added ALL possible permissions to the manifest. Now the problem is that i need to remove all permissions that are never used. Is there a nice way or tool to do that?

The way i thought about was to remove all permissions, then test, and add one by one after seeing a crash with SECURITY EXCEPTION. Also the stack trace contains a hint for which permission is missing. I do not think it is a nice or safe way to do it...

I tried the method explained here: How to check if Android Permission is actually being used? but it did only partial work. I removed all permissions and run inspection, but not all permissions were found. I use bluetooth in my code, and there were no notice of this permission missing...

Community
  • 1
  • 1
Pavel B.
  • 805
  • 10
  • 13
  • 1
    See This: http://stackoverflow.com/questions/24858462/how-to-check-if-android-permission-is-actually-being-used – Amy Sep 06 '16 at 10:58
  • 1
    run code inspection with lint..? – lelloman Sep 06 '16 at 11:39
  • Thank You, tried this on newer version of Android Studio and it worked. But not all permissions were found. I use bluetooth in my code, and there were no notice of this permission missing... – Pavel B. Sep 06 '16 at 11:44

1 Answers1

0

in my guess first of All just look at the Dangerous permission list recognize your permissions from manifest file and all these permissions in a list just here in this library they did it in a same way it will handle all permission one by one just look at the example

askCompactPermissions(new String[]{PermissionUtils.Manifest_CAMERA, PermissionUtils.Manifest_WRITE_EXTERNAL_STORAGE}, new PermissionResult() {
        @Override
        public void permissionGranted() {
            //permission granted
            //replace with your action
        }

        @Override
        public void permissionDenied() {
            //permission denied
            //replace with your action
        }
         @Override
                public void permissionForeverDenied() {
                 // user has check 'never ask again'
                 // you need to open setting manually
                 //  Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                 //  Uri uri = Uri.fromParts("package", getPackageName(),  
                  null);
                 //   intent.setData(uri);
                 //  startActivityForResult(intent,   
                 REQUEST_PERMISSION_SETTING); 
                }
    });

for Activity extent yourActivityClass from ActivityManagePermission like below

public class MainActivity extends ActivityManagePermission {

}

and for Fragement extends yourFragmentClass from FragmentManagePermission

public class FragmentHome extends FragmentManagePermission {

}
Nowshad
  • 294
  • 1
  • 14
  • Thank You, but the problem is that there is a very large amount of code and i need to find which permissions i should ask for... Or, on the opposite, which permissions i do not use, because as for now, my app has all possible permissions in its manifest, but i need to get rid of the unused ones... – Pavel B. Sep 06 '16 at 12:04
  • that all will be handle when you look at the Dangerous Permissions article the article i give you after that recognize permission from your manifest file and add all of your Dangerous permissions from your manifest file in a list to the method askCompactPermissions(new String[]{yourpermission1, yourpermission2,....}); – Nowshad Sep 06 '16 at 12:10
  • The article You provided is very usefull, i read it before even asking the question, but it does not describe the solution to what i ask... – Pavel B. Sep 06 '16 at 12:59