通过 adb 列出 Android 应用程序的权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21091022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:57:51  来源:igfitidea点击:

Listing permissions of Android application via adb

androidpermissionsadbandroid-permissionsaapt

提问by Juuso Ohtonen

Using adb, how can I find out the which permissions an Android application requires?

使用 adb,如何找出 Android 应用程序需要哪些权限?

Because I want to display the permissions of multiple applications on different devices, viewing them in Google Playor Settings> Applications managerrequires too much manual work.

因为要在不同设备上显示多个应用的​​权限,在Google PlaySettings>中查看Applications manager需要太多的手动工作。

回答by Denis Kniazhev

I just wanted to combine Jason's and Juuso's answers together and notice that the former lists permissions that were granted, while the latter lists permissions that were requested(including ones that were granted).

我只是想将 Jason 和 Juuso 的答案结合在一起,注意前者列出了已授予的权限,而后者列出了请求的权限(包括已授予的权限)。

To see only permissions that were granted(but omitting ones that were requested but not granted) use

查看已授予的权限(但省略已请求但未授予的权限),请使用

adb shell dumpsys package packagename

and check grantedPermissionssection at the bottom of the output.

并检查grantedPermissions输出底部的部分。

To list all permissions(requested but not granted + requested and granted):

列出所有权限(请求但未授予 + 请求并授予):

  1. Notice the APK of a package. You can run the same command

    adb shell dumpsys package packagename
    

    and get the APK path from codePathelement of its output.

  2. (if there is no aapton your device/emulator) You'll need to pull the apk from device/emulator as Juuso Ohtonen has pointed out in his answer. So execute something like this from your desktop:

    adb pull /data/app/com.your.package.apk
    
  3. List all permissions of the package

    If missing from device/emulator aaptcan be found under build-tools/<version>/in your Android SDK.

    Then execute

    aapt d permissions /path/to/com.your.package.apk
    
  1. 注意包的 APK。您可以运行相同的命令

    adb shell dumpsys package packagename
    

    codePath从其输出的元素中获取 APK 路径。

  2. (如果aapt您的设备/模拟器上没有)您需要从设备/模拟器中提取 apk,正如 Juuso Ohtonen 在他的回答中指出的那样。所以从你的桌面执行这样的事情:

    adb pull /data/app/com.your.package.apk
    
  3. 列出包的所有权限

    如果从设备/模拟器中丢失,aapt可以build-tools/<version>/在您的 Android SDK下找到。

    然后执行

    aapt d permissions /path/to/com.your.package.apk
    

回答by Juuso Ohtonen

  1. List all applications along with their installation paths (use -3flag if you're only interested in 3rd party apps). As an example, let's try to find out YouTube app permissions.
    adb shell pm list packages -f

    Output:

    ...
    package:/data/app/com.google.android.youtube-1.apk=com.google.android.youtube
    ...

  2. Pull the selected apk from the device:
    adb pull /data/app/com.google.android.youtube-1.apk

  3. List the permissions with
    aapt d permissions com.google.android.youtube-1.apk

  1. 列出所有应用程序及其安装路径(-3如果您只对 3rd 方应用程序感兴趣,请使用标志)。例如,让我们尝试找出 YouTube 应用的权限。
    adb shell pm list packages -f

    输出:

    ...
    包:/data/app/com.google.android.youtube-1.apk=com.google.android.youtube
    ...

  2. 从设备中拉出选定的 apk:
    adb pull /data/app/com.google.android.youtube-1.apk

  3. 列出权限
    aapt d permissions com.google.android.youtube-1.apk

Output:

输出:

    uses-permission: android.permission.BROADCAST_STICKY
    uses-permission: android.permission.CALL_PHONE
    uses-permission: android.permission.CALL_PRIVILEGED
    uses-permission: android.permission.WRITE_SETTINGS
    uses-permission: android.permission.WRITE_SECURE_SETTINGS
    uses-permission: android.permission.READ_CONTACTS
    uses-permission: android.permission.READ_CALL_LOG
    uses-permission: android.permission.WRITE_CONTACTS
    uses-permission: android.permission.WRITE_CALL_LOG
    uses-permission: android.permission.SYSTEM_ALERT_WINDOW
    uses-permission: android.permission.INTERNAL_SYSTEM_WINDOW
    uses-permission: android.permission.ADD_SYSTEM_SERVICE
    uses-permission: android.permission.VIBRATE
    uses-permission: android.permission.BLUETOOTH
    uses-permission: android.permission.BLUETOOTH_ADMIN
    uses-permission: android.permission.REORDER_TASKS
    uses-permission: android.permission.CHANGE_CONFIGURATION
    ...

...

...

回答by jason

The fast way: adb shell dumpsys package packagename | grep permission

快捷方式: adb shell dumpsys package packagename | grep权限