Android中Permission权限机制的具体使用

 更新时间:2015年04月07日 10:24:41   投稿:junjie  
这篇文章主要介绍了Android中Permission权限机制的具体使用,本文讲解了权限级别 protection level、ICC(inter-component communication)权限保护等内容,需要的朋友可以参考下

由上篇Android Permission权限机制引子,我们知道Android 通过在每台设备上实施了基于权限的安全策略来处理安全问题,采用权限来限制安装应用程序的能力。本篇文章继续来探讨和Android权限相关的话题,主要集中在权限级别、ICC(inter- component communication)权限保护两个方面。

权限级别 protection level

每一个Permission权限都设有了权限级别(protection level),分别如下:

复制代码 代码如下:

“normal”
The default value. A lower-risk permission that gives requesting applications access to isolated application-level features, with minimal risk to other applications, the system, or the user. The system automatically grants this type of permission to a requesting application at installation, without asking for the user's explicit approval (though the user always has the option to review these permissions before installing).

normal级别是一些比较低风险的权限,我们在安装一个新app到手机时,一般会被折叠起来的权限就是normal级别的。
复制代码 代码如下:

“dangerous”
A higher-risk permission that would give a requesting application access to private user data or control over the device that can negatively impact the user. Because this type of permission introduces potential risk, the system may not automatically grant it to the requesting application. For example, any dangerous permissions requested by an application may be displayed to the user and require confirmation before proceeding, or some other approach may be taken to avoid the user automatically allowing the use of such facilities.

dangerous则是那些比较高风险的权限,在安装时会明显提示用户该app具有这些权限,并且需要用户同意确认才能正确安装app的权限。
复制代码 代码如下:

“signature”
A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval.

signature则在我们用户自定义权限custom时,会用得到的,具体做法我会在另一篇博文:Android 自定义权限中具体研究的,这里简述之:

用户在某一个app(先称permisson app)中自定义了permission时,并且指定了某些组件需要该自定义权限才能打开,这是前提,然后用户又开发了另外一个app(称为permission client),这个permission client如果想访问permisson app中指定了自定义权限的组件,那么这两个app必须具备相同的signature,这就是signature级别的意思。

复制代码 代码如下:

“signatureOrSystem”
A permission that the system grants only to applications that are in the Android system image or that are signed with the same certificates as those in the system image. Please avoid using this option, as the signature protection level should be sufficient for most needs and works regardless of exactly where applications are installed. The “signatureOrSystem” permission is used for certain special situations where multiple vendors have applications built into a system image and need to share specific features explicitly because they are being built together.

这个同上,但多了一个Or,or是指除了相同的signature之外还可以指定为相同的Android img也可以访问,这个img其实就是系统级别的定制了,一般用的很少。

ICC(inter-component communication)权限保护

<application>元素和组件元素都有android:permission的属性,在这里我们称这个属性分别为应用程序和组件的权限标签。应用程序内的组件可以继承应用程序元素设置的权限标签,当某一组件启动 ICC 时,相关的访问控制器就会查看组件和组件所在应用程序的权限标签集合,如目标组件的访问权限标签在以上的集合内,允许 ICC 的建立继续进行,否则将会被拒绝,即使这两个组件在同一应用程序内。

改图描述了该逻辑的进程:组件A是否可以访问组件B和C,取决于比较B和C内的访问权限标签与应用程序1内的标签集合的结果。B和应用程序1内都有i1标签,所以组件A可以访问组件B,相反应用程序1内没有标签i2,组件A 不可以访问组件B。

相关文章

  • android中圆角图像生成方法

    android中圆角图像生成方法

    这篇文章主要介绍了android中圆角图像生成方法,涉及Android处理圆角图像的技巧,需要的朋友可以参考下
    2015-04-04
  • Android TabLayout实现京东详情效果

    Android TabLayout实现京东详情效果

    这篇文章主要为大家详细介绍了android TabLayout实现京东详情效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-09-09
  • Android开发之绘制平面上的多边形功能分析

    Android开发之绘制平面上的多边形功能分析

    这篇文章主要介绍了Android开发之绘制平面上的多边形功能,结合实例形式分析了Android多边形图形绘制的原理、步骤、相关操作技巧与注意事项,需要的朋友可以参考下
    2017-09-09
  • Jetpack Compose实现对话框和进度条实例解析

    Jetpack Compose实现对话框和进度条实例解析

    对话框和进度条其实并无多大联系,放在一起写是因为两者的内容都不多,所以凑到一起,对话框是我们平时开发使用得比较多的组件,进度条的使用频率也很高,比如下载文件,上传文件,处理任务时都可以使用进度条
    2023-04-04
  • Android Handler移除Message详解及实例代码

    Android Handler移除Message详解及实例代码

    这篇文章主要介绍了Android Handler移除Message详解及实例代码的相关资料,需要的朋友可以参考下
    2017-02-02
  • 详解Android全局异常的捕获处理

    详解Android全局异常的捕获处理

    这篇文章主要为大家介绍了Android全局异常的捕获处理,为什么要进行捕获处理,如何进行捕获处理,想要了解的朋友可以参考一下
    2016-01-01
  • Android 第三方库lottie、mmkv的使用详解

    Android 第三方库lottie、mmkv的使用详解

    lottie是Airbnb开源的一个面向 iOS、Android、React Native 的动画库,能实现精美、复杂的动画效果,本文通过实例代码给大家介绍Android 第三方库lottie、mmkv的使用,感兴趣的的朋友一起看看吧
    2021-04-04
  • Android开发之自动朗读TTS用法分析

    Android开发之自动朗读TTS用法分析

    这篇文章主要介绍了Android开发之自动朗读TTS用法,较为详细的分析了TTS的概念、功能、使用方法与相关注意事项,需要的朋友可以参考下
    2016-06-06
  • Android RadioGroup 设置某一个选中或者不可选中的方法

    Android RadioGroup 设置某一个选中或者不可选中的方法

    下面小编就为大家带来一篇Android RadioGroup 设置某一个选中或者不可选中的方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-04-04
  • Kotlin Flow封装类SharedFlow StateFlow LiveData使用对比

    Kotlin Flow封装类SharedFlow StateFlow LiveData使用

    这篇文章主要为大家介绍了Kotlin Flow封装类SharedFlow StateFlow LiveData使用对比,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2022-08-08

最新评论