Android 权限:如何了解哪些权限是危险的,哪些是正常的?

发布于 2024-12-03 13:59:41 字数 530 浏览 1 评论 0原文

Android 定义了一组第三方应用程序可以请求的权限。 权限按敏感度分类;大多数权限要么是“正常”,要么是“危险”。普通权限自动授予,不提示用户;安装应用程序时会向用户提供危险权限,并要求用户同意授予这些权限。

问题:对于我想到的任何特定 Android 权限,我如何判断它是正常权限还是危险权限?是否有危险权限列表和正常权限列表?

(我知道第三方应用程序可以声明自己的权限。我只是询问标准权限。我知道可能无法获得 100% 完整的列表。我只是在寻找尽力而为的;某些东西总比没有好。)

有关相关但不同的问题,另请参阅在哪里可以获得 Android 权限列表(但是,那就是另一个问题;它没有正常与危险的区别,而且我不一定需要完整的列表)。

Android defines a set of permissions that third-party apps can request. Permissions are categorized by sensitivity; most permissions are either "normal" or "dangerous". Normal permissions are granted automatically, without prompting the user; dangerous permissions are presented to the user when the app is installed and the user is asked to consent to granting them.

Question: For any particular Android permission I have in mind, how can I tell whether it is a normal permission or a dangerous permission? Is there a list of dangerous permissions and a list of normal permissions?

(I know that third-party apps can declare their own permissions. I'm only asking about standard permissions. I know it may not be possible to get a 100%-complete list. I'm only looking for best-effort; something is better than nothing.)

For a related but different question, see also Where can I get a list of Android permissions (however, that's a different question; it doesn't at the normal vs dangerous distinction, and I don't necessarily need a complete list).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

触ぅ动初心 2024-12-10 13:59:42

普通权限会自动授予,而不提示用户

AFAIK,这里的文档是错误的。

安装应用程序时会向用户提供危险权限,并要求用户同意授予这些权限

权限,据我所知,所有权限都有此行为。

这可能会演变为始终显示危险权限,而如果有足够的危险权限,则正常权限可能会“低于首屏”。

对于我想到的任何特定 Android 权限,我如何判断它是正常权限还是危险权限?是否有危险权限列表和正常权限列表?

您可以查看源代码

Normal permissions are granted automatically, without prompting the user

AFAIK, the documentation is wrong here.

dangerous permissions are presented to the user when the app is installed and the user is asked to consent to granting them

AFAIK, all permissions have this behavior.

What this may have morphed into is that dangerous permissions are always displayed and normal permissions are ones that might be "below the fold" if there are enough dangerous ones.

For any particular Android permission I have in mind, how can I tell whether it is a normal permission or a dangerous permission? Is there a list of dangerous permissions and a list of normal permissions?

You can look at the source code.

我发现这篇博文按保护级别列出了“默认”权限。我想,这就是您正在寻找的列表。

不过,该列表可能在此期间发生了变化,因为该帖子已经发布了 10 个月。它提供了示例代码供您自行重新编译列表。

I found this blogpost listing the "default" permissions by protection level. I think, this is the kind of list you were looking for.

The list might have changed in the meantime though, as the post is 10 months old. It provides sample code to recompile the list by yourself.

酷到爆炸 2024-12-10 13:59:42

从 android M 开始,权限将在运行时授予。正常权限不需要用户同意,但危险权限需要用户向应用程序授予权限。

普通权限: https://developer.android.com/guide/topics/ security/normal-permissions.html

危险权限:危险权限涵盖应用程序需要涉及用户隐私信息的数据或资源的区域https://developer.android.com/guide/topics/security/permissions .html#正常危险

From android M permissions will be granted at runtime. User consent is not required for Normal permissions but for Dangerous permissions user is required to grant the permission to application.

Normal permissions: https://developer.android.com/guide/topics/security/normal-permissions.html

Dangerous permissions: Dangerous permissions cover areas where the app wants data or resources that involve the user's private information https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous

别挽留 2024-12-10 13:59:42

这里是一篇很好的文章,它描述了有关运行时权限、

正常权限

android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_NOTIFICATION_POLICY
android.permission.ACCESS_WIFI_STATE
android.permission.ACCESS_WIMAX_STATE
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN
android.permission.BROADCAST_STICKY
android.permission.CHANGE_NETWORK_STATE
android.permission.CHANGE_WIFI_MULTICAST_STATE
android.permission.CHANGE_WIFI_STATE
android.permission.CHANGE_WIMAX_STATE
android.permission.DISABLE_KEYGUARD
android.permission.EXPAND_STATUS_BAR
android.permission.FLASHLIGHT
android.permission.GET_ACCOUNTS
android.permission.GET_PACKAGE_SIZE
android.permission.INTERNET
android.permission.KILL_BACKGROUND_PROCESSES
android.permission.MODIFY_AUDIO_SETTINGS
android.permission.NFC
android.permission.READ_SYNC_SETTINGS
android.permission.READ_SYNC_STATS
android.permission.RECEIVE_BOOT_COMPLETED
android.permission.REORDER_TASKS
android.permission.REQUEST_INSTALL_PACKAGES
android.permission.SET_TIME_ZONE
android.permission.SET_WALLPAPER
android.permission.SET_WALLPAPER_HINTS
android.permission.SUBSCRIBED_FEEDS_READ
android.permission.TRANSMIT_IR
android.permission.USE_FINGERPRINT
android.permission.VIBRATE
android.permission.WAKE_LOCK
android.permission.WRITE_SYNC_SETTINGS
com.android.alarm.permission.SET_ALARM
com.android.launcher.permission.INSTALL_SHORTCUT
com.android.launcher.permission.UNINSTALL_SHORTCUT

、危险权限 的所有内容
输入图片此处描述

Here is a good article which describes every thing about run time permissions ,

Normal permissions

android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_NOTIFICATION_POLICY
android.permission.ACCESS_WIFI_STATE
android.permission.ACCESS_WIMAX_STATE
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN
android.permission.BROADCAST_STICKY
android.permission.CHANGE_NETWORK_STATE
android.permission.CHANGE_WIFI_MULTICAST_STATE
android.permission.CHANGE_WIFI_STATE
android.permission.CHANGE_WIMAX_STATE
android.permission.DISABLE_KEYGUARD
android.permission.EXPAND_STATUS_BAR
android.permission.FLASHLIGHT
android.permission.GET_ACCOUNTS
android.permission.GET_PACKAGE_SIZE
android.permission.INTERNET
android.permission.KILL_BACKGROUND_PROCESSES
android.permission.MODIFY_AUDIO_SETTINGS
android.permission.NFC
android.permission.READ_SYNC_SETTINGS
android.permission.READ_SYNC_STATS
android.permission.RECEIVE_BOOT_COMPLETED
android.permission.REORDER_TASKS
android.permission.REQUEST_INSTALL_PACKAGES
android.permission.SET_TIME_ZONE
android.permission.SET_WALLPAPER
android.permission.SET_WALLPAPER_HINTS
android.permission.SUBSCRIBED_FEEDS_READ
android.permission.TRANSMIT_IR
android.permission.USE_FINGERPRINT
android.permission.VIBRATE
android.permission.WAKE_LOCK
android.permission.WRITE_SYNC_SETTINGS
com.android.alarm.permission.SET_ALARM
com.android.launcher.permission.INSTALL_SHORTCUT
com.android.launcher.permission.UNINSTALL_SHORTCUT

Dangerous permissions
enter image description here

天涯离梦残月幽梦 2024-12-10 13:59:42

在 Android Studio 中,您可以打开 AndroidManifest.xml 并对您使用的每个权限按 F1,然后您可以查看文档可能显示的是否存在危险。

in Android Studio,you can open your AndroidManifest.xml and press F1 on every permission you used then you can see if it is dangerous which the doc may shows.

橘亓 2024-12-10 13:59:42

新的权限会随着新的 Android 版本的发布而添加,因此代码中包含的任何列表都将过时。

如果您需要一种面向未来的方法,则可以在运行时确定权限是否危险。

fun Context.isDangerousPermission(permissionName: String): Boolean {
    val permissionInfo: PermissionInfo = try {
        packageManager.getPermissionInfo(permissionName, 0);
    } catch (ex: PackageManager.NameNotFoundException) {
        return false
    }
    return if (Build.VERSION.SDK_INT >= 28) {
        permissionInfo.protection == PermissionInfo.PROTECTION_DANGEROUS
    } else {
        permissionInfo.protectionLevel and PermissionInfo.PROTECTION_DANGEROUS != 0
    }
}

如果权限存在危险,此扩展函数将返回 true

例如:

activity.isDangerousPermission("android.permission.CAMERA") // true
activity.isDangerousPermission("android.permission.INTERNET") // false

New permissions are added as new Android versions are released, so any list included in your code will go out of date.

If you need a future-proof approach, it's possible to determine at runtime whether a permission is dangerous.

fun Context.isDangerousPermission(permissionName: String): Boolean {
    val permissionInfo: PermissionInfo = try {
        packageManager.getPermissionInfo(permissionName, 0);
    } catch (ex: PackageManager.NameNotFoundException) {
        return false
    }
    return if (Build.VERSION.SDK_INT >= 28) {
        permissionInfo.protection == PermissionInfo.PROTECTION_DANGEROUS
    } else {
        permissionInfo.protectionLevel and PermissionInfo.PROTECTION_DANGEROUS != 0
    }
}

This extension function returns true if a permission is dangerous.

For example:

activity.isDangerousPermission("android.permission.CAMERA") // true
activity.isDangerousPermission("android.permission.INTERNET") // false
你在看孤独的风景 2024-12-10 13:59:41

,下面是取自官方文档的普通权限列表:

为了更简单起见 级别 23,以下权限被分类为 PROTECTION_NORMAL:

ACCESS_LOCATION_EXTRA_COMMANDS
ACCESS_NETWORK_STATE
ACCESS_NOTIFICATION_POLICY
ACCESS_WIFI_STATE
BLUETOOTH
BLUETOOTH_ADMIN
BROADCAST_STICKY
CHANGE_NETWORK_STATE
CHANGE_WIFI_MULTICAST_STATE
CHANGE_WIFI_STATE
DISABLE_KEYGUARD
EXPAND_STATUS_BAR
FLASHLIGHT
GET_PACKAGE_SIZE
INTERNET
KILL_BACKGROUND_PROCESSES
MODIFY_AUDIO_SETTINGS
NFC
READ_SYNC_SETTINGS
READ_SYNC_STATS
RECEIVE_BOOT_COMPLETED
REORDER_TASKS
REQUEST_INSTALL_PACKAGES
SET_TIME_ZONE
SET_WALLPAPER
SET_WALLPAPER_HINTS
TRANSMIT_IR
USE_FINGERPRINT
VIBRATE
WAKE_LOCK
WRITE_SYNC_SETTINGS
SET_ALARM
INSTALL_SHORTCUT
UNINSTALL_SHORTCUT

这里是危险权限和权限的列表组

CALENDAR : READ_CALENDAR, WRITE_CALENDAR
CAMERA : CAMERA
CONTACTS : READ_CONTACTS, WRITE_CONTACTS, GET_ACCOUNTS
LOCATION : ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION
MICROPHONE : RECORD_AUDIO
PHONE : READ_PHONE_STATE, CALL_PHONE, READ_CALL_LOG, WRITE_CALL_LOG, ADD_VOICEMAIL, USE_SIP, PROCESS_OUTGOING_CALLS
SENSORS : BODY_SENSORS    
SMS     : SEND_SMS, RECEIVE_SMS, READ_SMS, RECEIVE_WAP_PUSH, RECEIVE_MMS
STORAGE : READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE

For more simplicity, below are list of Normal permissions taken from official docs:

As of API level 23, the following permissions are classified as PROTECTION_NORMAL:

ACCESS_LOCATION_EXTRA_COMMANDS
ACCESS_NETWORK_STATE
ACCESS_NOTIFICATION_POLICY
ACCESS_WIFI_STATE
BLUETOOTH
BLUETOOTH_ADMIN
BROADCAST_STICKY
CHANGE_NETWORK_STATE
CHANGE_WIFI_MULTICAST_STATE
CHANGE_WIFI_STATE
DISABLE_KEYGUARD
EXPAND_STATUS_BAR
FLASHLIGHT
GET_PACKAGE_SIZE
INTERNET
KILL_BACKGROUND_PROCESSES
MODIFY_AUDIO_SETTINGS
NFC
READ_SYNC_SETTINGS
READ_SYNC_STATS
RECEIVE_BOOT_COMPLETED
REORDER_TASKS
REQUEST_INSTALL_PACKAGES
SET_TIME_ZONE
SET_WALLPAPER
SET_WALLPAPER_HINTS
TRANSMIT_IR
USE_FINGERPRINT
VIBRATE
WAKE_LOCK
WRITE_SYNC_SETTINGS
SET_ALARM
INSTALL_SHORTCUT
UNINSTALL_SHORTCUT

And here is list of Dangerous permissions and permission groups:

CALENDAR : READ_CALENDAR, WRITE_CALENDAR
CAMERA : CAMERA
CONTACTS : READ_CONTACTS, WRITE_CONTACTS, GET_ACCOUNTS
LOCATION : ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION
MICROPHONE : RECORD_AUDIO
PHONE : READ_PHONE_STATE, CALL_PHONE, READ_CALL_LOG, WRITE_CALL_LOG, ADD_VOICEMAIL, USE_SIP, PROCESS_OUTGOING_CALLS
SENSORS : BODY_SENSORS    
SMS     : SEND_SMS, RECEIVE_SMS, READ_SMS, RECEIVE_WAP_PUSH, RECEIVE_MMS
STORAGE : READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文