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 Play
or Settings
> Applications manager
requires too much manual work.
因为我想在不同的设备上显示多个应用程序的权限,所以在谷歌Play或Settings >应用程序管理器中查看它们需要太多的手工工作。
3 个解决方案
#1
47
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 grantedPermissions
section at the bottom of the output.
并在输出的底部检查grantedPermissions部分。
To list all permissions (requested but not granted + requested and granted):
列出所有权限(请求但不授予+请求和授予):
-
Notice the APK of a package. You can run the same command
注意一个包的APK。您可以运行相同的命令。
adb shell dumpsys package packagename
and get the APK path from
codePath
element of its output.并从其输出的codePath元素获取APK路径。
-
(if there is no
aapt
on 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:如果你的设备/模拟器上没有aapt,你就需要把apk从设备/仿真器中拉出来,就像Juuso Ohtonen在他的回答中指出的那样。所以从你的桌面执行这样的操作:
adb pull /data/app/com.your.package.apk
-
List all permissions of the package
列出包的所有权限。
If missing from device/emulator
aapt
can be found underbuild-tools/<version>/
in your Android SDK.如果在构建工具/ <版本> /在您的Android SDK中,可以找到设备/仿真器aapt的缺失。
Then execute
然后执行
aapt d permissions /path/to/com.your.package.apk
#2
13
-
List all applications along with their installation paths (use
-3
flag 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:列出所有应用程序及其安装路径(如果您只对第三方应用程序感兴趣,请使用-3标志)。举个例子,我们来看看YouTube的应用权限。adb shell pm清单包-f输出:
...
package:/data/app/com.google.android.youtube-1.apk=com.google.android.youtube
...…包:/数据/应用/ com.google.android.youtube - 1. - apk = com.google.android。youtube……
-
Pull the selected apk from the device:
adb pull /data/app/com.google.android.youtube-1.apk
从设备中取出所选的apk: adb Pull /data/app/com.google.android.youtube-1.apk。
-
List the permissions with
aapt d permissions com.google.android.youtube-1.apk
使用aapt权限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
...
...
…
#3
9
The fast way: adb shell dumpsys package packagename | grep permission
快速方式:adb shell dumpsys软件包packagename | grep权限。
#1
47
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 grantedPermissions
section at the bottom of the output.
并在输出的底部检查grantedPermissions部分。
To list all permissions (requested but not granted + requested and granted):
列出所有权限(请求但不授予+请求和授予):
-
Notice the APK of a package. You can run the same command
注意一个包的APK。您可以运行相同的命令。
adb shell dumpsys package packagename
and get the APK path from
codePath
element of its output.并从其输出的codePath元素获取APK路径。
-
(if there is no
aapt
on 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:如果你的设备/模拟器上没有aapt,你就需要把apk从设备/仿真器中拉出来,就像Juuso Ohtonen在他的回答中指出的那样。所以从你的桌面执行这样的操作:
adb pull /data/app/com.your.package.apk
-
List all permissions of the package
列出包的所有权限。
If missing from device/emulator
aapt
can be found underbuild-tools/<version>/
in your Android SDK.如果在构建工具/ <版本> /在您的Android SDK中,可以找到设备/仿真器aapt的缺失。
Then execute
然后执行
aapt d permissions /path/to/com.your.package.apk
#2
13
-
List all applications along with their installation paths (use
-3
flag 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:列出所有应用程序及其安装路径(如果您只对第三方应用程序感兴趣,请使用-3标志)。举个例子,我们来看看YouTube的应用权限。adb shell pm清单包-f输出:
...
package:/data/app/com.google.android.youtube-1.apk=com.google.android.youtube
...…包:/数据/应用/ com.google.android.youtube - 1. - apk = com.google.android。youtube……
-
Pull the selected apk from the device:
adb pull /data/app/com.google.android.youtube-1.apk
从设备中取出所选的apk: adb Pull /data/app/com.google.android.youtube-1.apk。
-
List the permissions with
aapt d permissions com.google.android.youtube-1.apk
使用aapt权限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
...
...
…
#3
9
The fast way: adb shell dumpsys package packagename | grep permission
快速方式:adb shell dumpsys软件包packagename | grep权限。