Where can I get a list of Android permissions

2019-01-13 15:25发布

问题:

I'm trying to get a list of valid Android permissions. I know the 'official' ones at http://developer.android.com/reference/android/Manifest.permission.html but it seems there are more out there.

For example

android.permission.READ_SETTINGS
android.permission.ACCESS_LOCATION
android.permission.ACCESS_GPS

com.android.vending.CHECK_LICENSE

com.android.browser.permission.READ_HISTORY_BOOKMARKS
com.android.browser.permission.WRITE_HISTORY_BOOKMARKS

com.google.android.googleapps.permission.GOOGLE_AUTH
com.google.android.googleapps.permission.GOOGLE_AUTH.OTHER_SERVICES

com.google.android.c2dm.permission.RECEIVE

Where can I get such a list? Where do I get a description for these permissions?

回答1:

There is no such thing as a comprehensive "list" for all permissions. New permissions can be defined by any application that wants to enforce its own: https://developer.android.com/guide/topics/security/security.html#declaring.

The Manifest.permission class lists the "system" permissions, and you're already aware of those. The other things you've listed aren't system permissions, but rather are specific to certain apps, and or are old names (ACCESS_LOCATION and ACCESS_GPS were pre 1.0 names, for example).

A grep for something like <permission android:name= in the source would reveal all the included app permissions (for the open source apps), but in general you should stick to the documented permission names.



回答2:

adb shell pm list permissions -s

This might be what you're looking for.



回答3:

Use the following snippet to get all the permissions declared on your device:

Context context = this;
PackageManager pm = context.getPackageManager();
CharSequence csPermissionGroupLabel;
CharSequence csPermissionLabel;

List<PermissionGroupInfo> lstGroups = pm.getAllPermissionGroups(0);
for (PermissionGroupInfo pgi : lstGroups) {
    csPermissionGroupLabel = pgi.loadLabel(pm);
    Log.e("perm", pgi.name + ": " + csPermissionGroupLabel.toString());

    try {
        List<PermissionInfo> lstPermissions = pm.queryPermissionsByGroup(pgi.name, 0);
        for (PermissionInfo pi : lstPermissions) {
            csPermissionLabel = pi.loadLabel(pm);
            Log.e("perm", "   " + pi.name + ": " + csPermissionLabel.toString());
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}


回答4:

Where can I get such a list?

You can't.

Where do I get a description for these permissions?

Wherever those permissions are documented. In many cases, they are undocumented and therefore should not be used.

For example, your first three were removed from Android a couple of years ago, IIRC. The last one is documented in the C2DM documentation.



回答5:

To list all permissions on your phone

adb shell pm list permissions -g

The -s argument is a short summary



回答6:

There are definitely "more permissions out there". The reference you've linked is just the "official list" – and even for that, it's quite incomplete. I've researched for existing permissions, what they are for, and what impacts they have on the end-user, for about a year now – and really wonder how developers find what they need. Good guessing seems to be part of it, as for many permissions a Google search just yielded content of several apps' Manifest files ("uses …").

Added to that, next to the "official permissions" (or rather "Android core permissions"), each developer can define its own for his app (as Charlie Collins already pointed out in his answer).

During my research, I've setup a list with my findings from several sources (which I listed along) – adding any explanations I could find. This list is rather focused on the end-user, but still might prove helpful to developers. You can find it at my site: Android Permissions explained – bi-lingual (English and German). The list includes the "core permission" as well as some selected app-specific ones (mostly those one encounters more frequently: declared by Google apps, or popular apps like Tasker and K-9 Mail). Again, this of course is far from being complete – a "complete list" being as likely as a unicorn (the day published it most likely would be outdated already).


Edit:

As it was asked for in another comment: If you installed a package with a new permission not yet covered by any list, and you want to know the "technical name" of that new permission, you can retrieve that information from your device via ADB:

adb shell dumpsys package com.foo.bar

(of course replace com.foo.bar with the name of the package in question). In the output, skip down to the line grantedPermissions:. Below that come the permissions in "full notation", e.g. android.permission.INTERNET, one per line. To make that easier:

adb shell dumpsys package com.foo.bar |egrep -A99999 "grantedPermissions:"


回答7:

You can get all permissions on a device using the following code:

public static List<PermissionInfo> getAllPermissions(Context context) {
    PackageManager pm = context.getPackageManager();
    List<PermissionInfo> permissions = new ArrayList<>();

    List<PermissionGroupInfo> groupList = pm.getAllPermissionGroups(0);
    groupList.add(null); // ungrouped permissions

    for (PermissionGroupInfo permissionGroup : groupList) {
        String name = permissionGroup == null ? null : permissionGroup.name;
        try {
            permissions.addAll(pm.queryPermissionsByGroup(name, 0));
        } catch (PackageManager.NameNotFoundException ignored) {
        }
    }

    return permissions;
}


回答8:

I know this is a late post, but this is more of a reference for people in the future who have the same question.

Here is a list of every single built-in permission in Android 7.0 (Nougat). However, it is possible to create your own permissions, so that list doesn't contain all of them out there.

Hope that helps :)