1# Application Privilege Configuration Guide 2 3Application privileges are high-level capabilities of an application, for example, restricting an application from being uninstalled or restricting application data from being deleted. 4 5OpenHarmony provides both general and device-specific application privileges. The latter can be configured by device vendors for applications on different devices. 6 7> **NOTE** 8> - To avoid user dissatisfaction or even infringement, do not abuse application privileges. 9> - The method of changing the application's APL in its profile applies only to the applications or services in debug mode. For a commercial application, apply for a release certificate and profile in the corresponding application market. 10 11## General Application Privileges 12 13### Introduction 14 15General application privileges are privileges available to applications on all types of devices. The general application privileges include the following: 16 17| Privilege| Description | 18| ---------------- | ------------------------------------------------------------ | 19| AllowAppDataNotCleared | Allows application data not to be deleted.| 20| AllowAppMultiProcess | Allows an application to run on multiple processes.| 21| AllowAppDesktopIconHide | Allows the application icon to be hidden from the home screen.| 22| AllowAbilityPriorityQueried | Allows an ability to configure and query the priority. | 23| AllowAbilityExcludeFromMissions | Allows an ability to be hidden in the mission stack.| 24| AllowAppUsePrivilegeExtension | Allows an application to use ServiceExtensionAbilities and DataExtensionAbilities.| 25| AllowFormVisibleNotify | Allows a widget to be visible on the home screen.| 26 27### How to Configure 28 291. Add the **app-privilege-capabilities** field to the [**HarmonyAppProvision** file](../../application-dev/security/app-provision-structure.md) to configure general privilege capabilities as required. 302. Use the hapsigner tool to sign the **HarmonyAppProvision** file and generate a .p7b file. 313. Use the .p7b file to sign the HAP. 32 33Reference: [hapsigner](https://gitee.com/openharmony/developtools_hapsigner#README.md) 34 35### Example 36 37``` 38{ 39 "version-name": "1.0.0", 40 ... 41 "bundle-info": { 42 "developer-id": "OpenHarmony", 43 ... 44 }, 45 "issuer": "pki_internal", 46 "app-privilege-capabilities": ["AllowAppDataNotCleared", "AllowAppDesktopIconHide"] // The application data cannot be deleted, and the application icon can be hidden on the home screen. 47} 48``` 49 50 51 52## Device-specific Application Privileges 53 54### Introduction 55 56In addition to general application privileges, device vendors can define device-specific privileges for an application. The table below describes the device-specific privileges. 57 58| Privilege | Type | Default Value| Description | 59| --------------------- | -------- | ------ | ------------------------------------------------- | 60| removable | bool | true | Allows an application to be uninstalled. This privilege takes effect only for preset applications. | 61| keepAlive | bool | false | Allows an application to keep running in the background. | 62| singleton | bool | false | Allows an application to be installed for a single user (User 0). | 63| allowCommonEvent | string[] | - | Allows an application to be started by a static broadcast. | 64| associatedWakeUp | bool | false | Allows an application in the FA model to be woken up by an associated application. | 65| runningResourcesApply | bool | false | Allows an application to request running resources, such as the CPU, event notifications, and Bluetooth.| 66 67### How to Configure 68 69Configure the required privileges in the [configuration file](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568/preinstall-config). 70 71### Example 72 73#### Configuration in install_list_capability.json 74 75``` 76{ 77 "install_list": [ 78 { 79 "bundleName": "com.example.kikakeyboard", 80 "singleton": true, // The application is installed for a single user. 81 "keepAlive": true, // The application is running in the background. 82 "runningResourcesApply": true, // The application can apply for running resources such as the CPU, event notifications, and Bluetooth. 83 "associatedWakeUp": true, // The application in the FA model can be woken up by an associated application. 84 "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC"], // The setting takes effect only when the configured certificate fingerprint is the same as the HAP certificate fingerprint. 85 "allowCommonEvent": ["usual.event.SCREEN_ON", "usual.event.THERMAL_LEVEL_CHANGED"] 86 }, 87} 88``` 89 90**Obtaining the Certificate Fingerprint** 91 921. Create the **profile.cer** file, and copy the certificate content under the **distribution-certificate** field of the **HarmonyAppProvision** file to the **profile.cer** file. 93 94 Example: 95 96``` 97{ 98 ... 99 "bundle-info": { 100 "distribution-certificate": "-----BEGIN CERTIFICATE----\nMIICMzCCAbegAwIBAgIEaOC/zDAMBggqhkjOPQQDAwUAMk..." / Certificate content. 101 ... 102 } 103 ... 104} 105``` 106 1072. Apply line breaks in the **profile.cer** content and remove the newline characters. 108 109 Example: 110 111``` 112-----BEGIN CERTIFICATE----- 113MIICMzCCAbegAwIBAgIEaOC/zDAMBggqhkjOPQQDAwUAMGMxCzAJBgNVBAYTAkNO 114MRQwEgYDVQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVh 115bTEjMCEGA1UEAxMaT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gQ0EwHhcNMjEwMjAy 116MTIxOTMxWhcNNDkxMjMxMTIxOTMxWjBoMQswCQYDVQQGEwJDTjEUMBIGA1UEChML 117T3Blbkhhcm1vbnkxGTAXBgNVBAsTEE9wZW5IYXJtb255IFRlYW0xKDAmBgNVBAMT 118H09wZW5IYXJtb255IEFwcGxpY2F0aW9uIFJlbGVhc2UwWTATBgcqhkjOPQIBBggq 119hkjOPQMBBwNCAATbYOCQQpW5fdkYHN45v0X3AHax12jPBdEDosFRIZ1eXmxOYzSG 120JwMfsHhUU90E8lI0TXYZnNmgM1sovubeQqATo1IwUDAfBgNVHSMEGDAWgBTbhrci 121FtULoUu33SV7ufEFfaItRzAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFPtxruhl 122cRBQsJdwcZqLu9oNUVgaMAwGCCqGSM49BAMDBQADaAAwZQIxAJta0PQ2p4DIu/ps 123LMdLCDgQ5UH1l0B4PGhBlMgdi2zf8nk9spazEQI/0XNwpft8QAIwHSuA2WelVi/o 124zAlF08DnbJrOOtOnQq5wHOPlDYB4OtUzOYJk9scotrEnJxJzGsh/ 125-----END CERTIFICATE----- 126``` 127 1283. Use keytool to obtain the certificate fingerprint. 129 130 Example: 131 132``` 133keytool -printcert -file profile.cer 134result: 135Issued To: CN=OpenHarmony Application Release, OU=OpenHarmony Team, O=OpenHarmony, C=CN 136Issued By: CN=OpenHarmony Application CA, OU=OpenHarmony Team, O=OpenHarmony, C=CN 137SN: 68e0bfcc 138Valid From: Tue Feb 02 20:19:31 CST 2021, **Valid To**: Fri Dec 31 20:19:31 CST 2049 139Fingerprints: 140 SHA1 fingerprint: E3:E8:7C:65:B8:1D:02:52:24:6A:06:A4:3C:4A:02:39:19:92:D1:F5 141 SHA256 fingerprint: 8E:93:86:3F:C3:2E:E2:38:06:0B:F6:9A:9B:37:E2:60:8F:FF:B2:1F:93:C8:62:DD:51:1C:BA:C9:F3:00:24:B5 // After the colons are removed, the fingerprint is 8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5. 142... 143``` 144 145 146 147#### Configuration in install_list.json 148 149``` 150{ 151 "install_list" : [ 152 { 153 "app_dir" : "/system/app/com.ohos.launcher", 154 "removable": true // The application can be uninstalled. 155 } 156 ] 157} 158``` 159