android 权限系统在阅读清单后如何在内部工作

How android permission system works internally after reading manifest

如何Android 跟踪从清单文件读取后授予应用程序的权限?是否根据 applicationId/package name/signing key/some 其他方式跟踪应用程序权限?

如果它在某些存储上存储权限,那么 android 将如何检索权限 array/data 以匹配。它会用什么?类似于 SHA、应用程序 ID 或程序包名称?

Note : Marshmallow 6.0 is the Target Environment

android os 将读取应用程序的清单文件。

在每个 android 应用程序中,都有一个名为 AndroidManifest.xml 的文件,它使用名为 uses-permission 的标签定义应用程序的权限。例如

<uses-permission android:name="android.permission.INTERNET" /> 

定义互联网使用权限。

应用程序使用很多权限,例如使用互联网、访问您的 phone 书籍、访问 SD 卡等。Android 显示应用程序在每次安装应用程序之前需要的权限。用户知道应用程序在安装之前使用的权限。

并且 Android 通过查看名为 Androidmenifest.xml 的 Androidmenifest 文件知道了这一点。此文件包含在每个 Android 应用程序的根目录中。所有的权限都在那里控制。

清单文件的结构:

<uses-permission />
<permission />
<permission-tree />
<permission-group />
<instrumentation />
<uses-sdk />
<uses-configuration />  
<uses-feature />  
<supports-screens />  
<compatible-screens />  
<supports-gl-texture />  

<application>

    <activity>
        <intent-filter>
            <action />
            <category />
            <data />
        </intent-filter>
        <meta-data />
    </activity>

    <activity-alias>
        <intent-filter> . . . </intent-filter>
        <meta-data />
    </activity-alias>

    <service>
        <intent-filter> . . . </intent-filter>
        <meta-data/>
    </service>

    <receiver>
        <intent-filter> . . . </intent-filter>
        <meta-data />
    </receiver>

    <provider>
        <grant-uri-permission />
        <meta-data />
        <path-permission />
    </provider>

    <uses-library />

</application>

每个权限都由一个唯一的标签标识,该标签表示受限的操作。 Android定义的一些权限示例:

android.permission.INTERNET
android.permission.READ_OWNER_DATA
android.permission.SET_WALLPAPER
android.permission.DEVICE_POWER

如果应用程序需要上述权限,它必须在 menifest 文件中使用 <used-permission> 元素进行声明,如下所示。

<uses-permission android:name="android.permission.INTERNET" />

请查看以下链接 -

1) http://trendblog.net/android-app-permissions/

2) https://www.se.jku.at/wp-content/uploads/2012/09/2012.permission-tracking.pdf

If Signature is specified, access is granted if a requesting application is signed with the same certificate as the application that declared the permission. The level SignatureOrSystem grants access to applications that are in the Android system image or that are signed with the same certificates as those in the system image.

所以这里 Signing Certificate 是帮助 android 系统识别 permitted applications 特定权限的关键要素。

可能对你有帮助!