Declarations and permissions

Posted by enygma on Thu, 04 Jul 2019 23:04:56 +0200

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>  
<manifest xmlns:android="http://schemas.android.com/apk/res/android"  
      package="com.scott.phone"  
      android:versionCode="1"  
      android:versionName="1.0">  
      
    <!-- Declare a privilege  -->  
    <permission android:protectionLevel="normal"   
                android:name="scott.permission.MY_CALL_PHONE"/>  
                  
    <application android:icon="@drawable/icon" android:label="@string/app_name">  
        <activity android:name=".MainActivity"  
                  android:label="@string/app_name">  
            <intent-filter>  
                <action android:name="android.intent.action.MAIN" />  
                <category android:name="android.intent.category.LAUNCHER" />  
            </intent-filter>  
        </activity>  
        <!-- by Activity Apply defined permissions -->  
        <activity android:name=".PhoneActivity"   
                  android:permission="scott.permission.MY_CALL_PHONE">  
            <intent-filter>  
                <!-- Notice this. action This can be used in other applications. action Visit here Activity -->  
                <action android:name="scott.intent.action.MY_CALL"/>  
                <category android:name="android.intent.category.DEFAULT" />  
            </intent-filter>  
        </activity>  
    </application>  
    <!-- Access in the same application PhoneActivity You also need to add permissions. -->  
    <uses-permission android:name="scott.permission.MY_CALL_PHONE"/>  
    <uses-sdk android:minSdkVersion="8" />  
</manifest>  

It is important to note that an android:protectionLevel attribute is required to declare permissions, which represents the "risk level". It must be one of the following values:

normal,dangerous,signature,signatureOrSystem.
Noral means that permissions are low-risk and do not harm the system, users or other applications.
Riskous means that permission is high-risk, and the system may require users to enter relevant information before granting this permission.
Signature tells Android that permissions can only be granted to an application if the digital signature used by the application is the same as all digital signatures of the application declaring this permission.
signatureOrSystem tells Android to grant privileges to applications or Android package classes that have the same digital signature. This level applies to very special situations, such as when multiple vendors need to share system images.
The other is the android:permissionGroup attribute, which represents a permission group. Permissions can be placed in a group, but for custom permissions, you should avoid setting this property. If you really want to set this property, you can use the following attributes instead: android.permission-group.SYSTEM_TOOLS.   

It is important to note that an android:protectionLevel attribute is required to declare permissions, which represents the "risk level". It must be one of the following values:

 

normal,dangerous,signature,signatureOrSystem.

Noral means that permissions are low-risk and do not harm the system, users or other applications.

Riskous means that permission is high-risk, and the system may require users to enter relevant information before granting this permission.

Signature tells Android that permissions can only be granted to an application if the digital signature used by the application is the same as all digital signatures of the application declaring this permission.

signatureOrSystem tells Android to grant privileges to applications or Android package classes that have the same digital signature. This level applies to very special situations, such as when multiple vendors need to share system images.

The other is the android:permissionGroup attribute, which represents a permission group. Permissions can be placed in a group, but for custom permissions, you should avoid setting this property. If you really want to set this property, you can use the following attributes instead: android.permission-group.SYSTEM_TOOLS.

Topics: Android Attribute xml encoding