private int getPermissionIndex ( PackageInfo packageInfo , String permissionName ) { if ( packageInfo . requestedPermissions != null ) { for ( int i = 0 ; i < packageInfo . requestedPermissions . length ; i ++ ) { if ( permissionName . equals ( packageInfo . requestedPermissions [ i ] ) ) { return i ; } } } return - 1 ; }
Returns the index of the given permission in the PackageInfo . requestedPermissions array or - 1 if it s not found .