openharmony 鸿蒙 app-provision-structure

2023-02-03 浏览 (771)

HarmonyAppProvision Configuration File

The HarmonyAppProvision configuration file (also called profile) is a file where you declare permission and signature information for your application.

Configuration File Structure

The HarmonyAppProvision file consists of several parts, which are described in the table below.

NameDescriptionData TypeMandatoryInitial Value Allowed
version-codeVersion number of the HarmonyAppProvision file format. The value is a positive integer containing 32 or less digits.NumberYesNo
version-nameDescription of the version number. It is recommended that the value consist of three segments, for example, A.B.C.StringYesNo
uuidUnique ID of the HarmonyAppProvision file.StringYesNo
typeType of the HarmonyAppProvision file. The value can be debug (for application debugging) or release (for application release). The recommended value is debug.StringYesNo
app-distribution-typeDistribution type of the application. The value can be any of the following:
- app_gallery: application distributed by AppGallery.
- enterprise: enterprise application that can be installed on personal devices.
- enterprise_mdm: enterprise mobile device management (MDM) application, which can be installed only on enterprise devices. The applications of this type must have device management privileges, such as remote locking devices and installing common enterprise applications on devices.
- enterprise_normal: common enterprise application, which can be installed on enterprise devices only through an enterprise MDM application. The applications of this type do not require device management privileges.
- os_integration: preset application in the system.
- crowdtesting: crowdtesting application.
- none: other applications.
StringYesNo
issuerIssuer of the HarmonyAppProvision file.StringYesNo
validityValidity period of the HarmonyAppProvision file. For details, see validity.ObjectYesNo
bundle-infoInformation about the application bundle and developer. For details, see bundle-info.ObjectYesNo
aclsInformation about the permissions requested via Access Control List (ACL). For details, see acls.ObjectNoYes
permissionsPermissions required for your application. For details, see permissions.ObjectNoYes
debug-infoAdditional information for application debugging. For details, see debug-info.ObjectNoYes
app-privilege-capabilitiesPrivilege information required by the application bundle. For details, see the Application Privilege Configuration Guide.String arrayNoYes

An example of the HarmonyAppProvision file is as follows:

{
    "version-code": 1,
    "version-name": "1.0.0",
	"uuid": "string",
	"type": "debug",
	"app-distribution-type": "os_integration",
	"validity": {
		"not-before": 1586422743,
		"not-after": 1617958743
	},
	"bundle-info" : {
		"developer-id": "OpenHarmony",
		"development-certificate": "Base64 string",
		"distribution-certificate": "Base64 string",
		"bundle-name": "com.OpenHarmony.app.test",
		"apl": "normal",
		"app-feature": "hos_normal_app",
		"data-group-ids": [
			"testGroupId1",
			"testGroupId2"
		]
	},
	"acls": {
		"allowed-acls": ["string"]
    },
	"permissions": {
		"restricted-permissions": ["string"]
    },
    "debug-info" : {
	    "device-id-type": "udid",
	    "device-ids": ["string"]
    },
    "app-privilege-capabilities":["AllowAppUsePrivilegeExtension"],
    "issuer": "OpenHarmony"
}

validity

NameDescriptionData TypeMandatoryInitial Value Allowed
not-beforeStart time of the file validity period. The value is a Unix timestamp, which is a non-negative integer.NumberYesNo
not-afterEnd time of the file validity period. The value is a Unix timestamp, which is a non-negative integer.NumberYesNo

bundle-info

NOTE
The value of bundle-name in the bundle-info object in the HarmonyAppProvision file must be the same as the value of bundleName (in config.json or module.json5) of the signed application. To prevent a HarmonyAppProvision file from being used for signatures of different applications, the system checks whether the value of bundleName in the HAP signature is the same as that in the HAP configuration file during application installation. If they are different, the HAP cannot be installed.

NameDescriptionData TypeMandatoryInitial Value Allowed
developer-idUnique ID of the developer.StringYesNo
development-certificateInformation about the debug certificate.NumberYes if type is set to debug and no otherwiseNo
distribution-certificateInformation about the release certificate.NumberYes if type is set to release and no otherwiseNo
bundle-nameBundle name of the application.StringYesNo
aplAbility Privilege Level (APL) of the application. The predefined APLs includes normal, system_basic, and system_core.StringYesNo
app-featureType of your application. The value can be hos_system_app (system application) or hos_normal_app (normal application). Only system applications are allowed to call system APIs. If a normal application calls a system API, the call cannot be successful or the application may run abnormally.StringYesNo
data-group-idsIDs of application data groups. When an application is installed, a directory is generated for each data group ID. If two applications or an ExtensionAbility and its application have the same data group ID in data-group-ids, they can share the data in the directory corresponding to the data group ID. An ExtensionAbility declares the data group IDs in the dataGroupIds field in the module.json5 file.String arrayNoYes (initial value: left empty)
app-identifierUnique ID of the application, which is allocated by the cloud. This ID does not change along the application lifecycle, including version updates, certificate changes, public and private key changes, and application transfers.String arrayNoYes (initial value: left empty)

acls

The acls object contains the permissions authorized via the ACL. It should be noted that you still need to add the ACL information to the requestPermissions attribute in the application configuration file.

NameDescriptionData TypeMandatoryInitial Value Allowed
allowed-aclsPermissions authorized via the ACL.String arrayNoNo

permissions

The permissions object contains restricted permissions required for your application. Different from the ACLs set in the acls object, these permissions need user authorization during the running of your application. It should be noted that you still need to add the ACL information to the requestPermissions attribute in the application configuration file.

NameDescriptionData TypeMandatoryInitial Value Allowed
restricted-permissionsRestricted sensitive permissions allowed. For details, see Restricted Permissions.String arrayNoNo

debug-info

The debug-info object contains debugging information of your application, mainly device management and control information.

NameDescriptionData TypeMandatoryInitial Value Allowed
device-id-typeType of the device ID. Currently, only the udid type is supported.StringNoNo
device-idsIDs of devices on which your application can be debugged.String arrayNoNo

Modifying the HarmonyAppProvision Configuration File

When a development project is created, the default application type is hos_normal_app and the default APL level is normal.

To enable the application to use system APIs, you need to change the app-feature field to hos_system_app (system application). To request high-level permissions, you need to modify fields such as apl and acl. For details, see Access Control Overview.

To modify the HarmonyAppProvision configuration file, perform the following steps:

  1. Open the directory where the OpenHarmony SDK is located. (You can choose File > Settings > OpenHarmony SDK on the menu bar of DevEco Studio to query the directory.)
  2. In the SDK directory, go to the Toolchains > {Version} > lib directory and open the UnsignedReleasedProfileTemplate.json file.
  3. Modify the related fields as required.

After modifying the configuration file, sign the application.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Security

harmony 鸿蒙hapsigner Guide

harmony 鸿蒙hapsigner Overview

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/84aa093bbba44d61a5d226e2aee05f68