博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Runtime Permissions
阅读量:6033 次
发布时间:2019-06-20

本文共 7216 字,大约阅读时间需要 24 分钟。

Runtime Permissions

The Android 6.0 application permission model is designed to make permissions more understandable, useful, and secure for users. The model moves Android applications that require dangerous permissions (see ) from an install time permission model to runtime permission model:

  • Install Time Permissions (Android 5.1 and earlier). Users grant dangerous permissions to an app when installing or updating the app. OEMs/carriers can pre-install apps with pre-granted permissions without notifying the user.
  • Runtime Permissions (Android 6.0 and later). Users grant dangerous permissions to an app when the app is running. Applications decide when to request permissions (such as when the app launches or the user accesses a specific feature), but must allow the user to grant/deny application access to specific permission groups. OEMs/carriers can pre-install apps but cannot pre-grant permissions (see ).

Runtime permissions provide users additional context and visibility into the permissions applications are seeking or have been granted. The runtime model also encourages developers to help users understand why applications require the requested permissions and to provide greater transparency about the benefits and hazards of granting or denying permissions.

Users can revoke application permissions using the Apps menu in Settings.

Affected permissions


Android 6.0 requires only dangerous permissions to use a runtime permissions model. Dangerous permissions are higher-risk permissions (such as READ_CALENDAR) that grant requesting applications access to private user data or control over the device that can negatively impact the user. To view a list of dangerous permissions, run the command:

adb shell pm list permissions -g -d

Android 6.0 does not change the behavior of normal permissions (all non-dangerous permissions including normal, system, and signature permissions). Normal permissions are lower-risk permissions (such as SET_WALLPAPER) that grant requesting applications access to isolated application-level features with minimal risk to other applications, the system, or the user. As in Android 5.1 and earlier releases, the system automatically grants normal permissions to a requesting application at installation and does not prompt the user for approval. For details on permissions, refer to .

Requirements


The runtime permission model applies to all applications, including pre-installed apps and apps delivered to the device as part of the setup process. Application software requirements include:

  • Runtime permission model must be consistent across all devices running Android 6.0. Enforced by Android Compatibility Test Suite (CTS) tests.
  • Apps must prompt users to grant application permissions at runtime. For details, see . Limited exceptions may be granted to default applications and handlers that provide basic device functionality fundamental to the expected operation of the device (i.e. the device's default Dialer app for handling ACTION_CALL may have Phone permission access). For details, see .
  • Pre-loaded apps with "dangerous permission" must target API level 23 and maintain the runtime permission model (i.e. the UI flow during app installation should not deviate from the AOSP implementation of PackageInstaller, users can revoke dangerous permissions of pre-installed apps, etc.).
  • Headless applications must use an activity to request permissions or share a UID with another application that has the necessary permissions. For details, see .

Permissions migration


Permissions granted to applications on Android 5.x remain granted after updating to Android 6.0, but users can revoke those permissions at any time.

Integration


When integrating the Android 6.0 application runtime permissions model, you must update pre-installed applications to work with the new model. You can also define exceptions for apps that are the default handlers/providers for core functionality, define custom permissions, and customize the theme used in the PackageInstaller.

Updating applications

Applications on the system image and pre-installed applications are not automatically pre-granted permissions. We encourage you to work with pre-installed app developers (OEM, Carrier, and third party) to make the required app modifications using . Specifically, you must ensure that pre-installed applications are modified to avoid crashes and other issues when users revoke permissions.

Pre-loaded applications

Pre-loaded apps that use dangerous permissions must target API level 23 and maintain the Android 6.0 AOSP permission model (i.e. the UI flow during an app installation should not deviate from the AOSP implementation of PackageInstaller, users can even revoke the dangerous permissions of pre-installed apps, etc.).

Headless applications

Only activities can request permissions; services cannot directly request permissions.

  • In Android 5.1 and earlier releases, headless applications can request permissions when installed or pre-installed without the use of an activity.
  • In Android 6.0, headless applications must use one of the following methods to request permissions:
    • Add an activity to request permissions (preferred method).
    • Share a UID with another application that has the necessary permissions. Use this method only when you need the platform to handle multiple APKs as a single application.

The goal is to avoid confusing users with permission requests that appear out of context.

Customizing PackageInstaller

If desired, you can customize the Permissions UI theme by updating the default device themes (Theme.DeviceDefault.Settings and Theme.DeviceDefault.Light.Dialog.NoActionBar) used by PackageInstaller. However, because consistency is critical for app developers, you cannot customize the placement, position, and rules of when the Permissions UI appears.

To include strings for additional languages, contribute the strings to AOSP.

Creating exceptions

You can pre-grant permissions to applications that are default handlers or providers for core OS functionality using the DefaultPermissionGrantPolicy.java in PackageManager. Examples:

ACTION_CALL (Dialer) Default

  • Phone, Contacts, SMS, Microphone

SMS_DELIVER_ACTION (SMS/MMS) Default

  • Phone, Contacts, SMS

Defining custom permissions

You can define custom permissions and groups as normal or dangerous and add OEM/Carrier-specific permissions to existing permissions groups, just as you could in Android 5.x and earlier releases.

In Android 6.0, if you add a new dangerous permission, it must be handled in the same way as other dangerous permissions (requested during app runtime and revocable by users). Specifically:

  • You can add new permissions to a current group, but you cannot modify the AOSP mapping of dangerous permissions and dangerous permissions group (e.g. you cannot remove a permission from a group and assign to other group).
  • You can add new permission groups in applications installed on the device, but you cannot add new permissions groups in the platform manifest.

Testing permissions


Android 6.0 includes Compatibility Test Suite (CTS) tests that verify individual permissions are mapped to the correct Groups. Passing these tests is a requirement for Android 6.0 CTS compatibility.

转载地址:http://updhx.baihongyu.com/

你可能感兴趣的文章
Sublime text3中配置Github
查看>>
Getting Started with iOS Development Part10:Customizing your Mobile target's Splash screen
查看>>
asp.net C# MVC 提交表单后清空表单
查看>>
备份软件 FreeFileSync 怎么用
查看>>
Asp.net,C# 加密解密字符串
查看>>
网页视频播放器插件源码
查看>>
CentOS7 睡眠 休眠 关机 电源
查看>>
SqlServer里DateTime转字符串
查看>>
2019-4-23 plan
查看>>
固定弹层叉掉
查看>>
[编解码] 关于base64编码的原理及实现
查看>>
2015/6/1站立会议(补发)
查看>>
WinDbg配置和使用基础
查看>>
Realm数据库使用
查看>>
JDK7,JDK8 - 下载地址
查看>>
Mybatis使用接口开发
查看>>
《批量下载音乐文件》 requests 网页请求模块
查看>>
转:Object-Runtime的基本数据类型
查看>>
JMJS系统总结系列----Jquery分页扩展库(五)
查看>>
学习笔记5
查看>>