1e41f4b71Sopenharmony_ci# module.json5配置文件 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## 配置文件示例 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci先通过一个示例,整体认识一下module.json5配置文件。 6e41f4b71Sopenharmony_ci<!--RP1--> 7e41f4b71Sopenharmony_ci```json 8e41f4b71Sopenharmony_ci{ 9e41f4b71Sopenharmony_ci "module": { 10e41f4b71Sopenharmony_ci "name": "entry", 11e41f4b71Sopenharmony_ci "type": "entry", 12e41f4b71Sopenharmony_ci "description": "$string:module_desc", 13e41f4b71Sopenharmony_ci "mainElement": "EntryAbility", 14e41f4b71Sopenharmony_ci "deviceTypes": [ 15e41f4b71Sopenharmony_ci "default", 16e41f4b71Sopenharmony_ci "tablet" 17e41f4b71Sopenharmony_ci ], 18e41f4b71Sopenharmony_ci "deliveryWithInstall": true, 19e41f4b71Sopenharmony_ci "installationFree": false, 20e41f4b71Sopenharmony_ci "pages": "$profile:main_pages", 21e41f4b71Sopenharmony_ci "virtualMachine": "ark", 22e41f4b71Sopenharmony_ci "appStartup": "$profile:app_startup_config", 23e41f4b71Sopenharmony_ci "metadata": [ 24e41f4b71Sopenharmony_ci { 25e41f4b71Sopenharmony_ci "name": "string", 26e41f4b71Sopenharmony_ci "value": "string", 27e41f4b71Sopenharmony_ci "resource": "$profile:distributionFilter_config" 28e41f4b71Sopenharmony_ci } 29e41f4b71Sopenharmony_ci ], 30e41f4b71Sopenharmony_ci "abilities": [ 31e41f4b71Sopenharmony_ci { 32e41f4b71Sopenharmony_ci "name": "EntryAbility", 33e41f4b71Sopenharmony_ci "srcEntry": "./ets/entryability/EntryAbility.ets", 34e41f4b71Sopenharmony_ci "description": "$string:EntryAbility_desc", 35e41f4b71Sopenharmony_ci "icon": "$media:layered_image", 36e41f4b71Sopenharmony_ci "label": "$string:EntryAbility_label", 37e41f4b71Sopenharmony_ci "startWindowIcon": "$media:icon", 38e41f4b71Sopenharmony_ci "startWindowBackground": "$color:start_window_background", 39e41f4b71Sopenharmony_ci "exported": true, 40e41f4b71Sopenharmony_ci "skills": [ 41e41f4b71Sopenharmony_ci { 42e41f4b71Sopenharmony_ci "entities": [ 43e41f4b71Sopenharmony_ci "entity.system.home" 44e41f4b71Sopenharmony_ci ], 45e41f4b71Sopenharmony_ci "actions": [ 46e41f4b71Sopenharmony_ci "ohos.want.action.home" 47e41f4b71Sopenharmony_ci ] 48e41f4b71Sopenharmony_ci } 49e41f4b71Sopenharmony_ci ], 50e41f4b71Sopenharmony_ci "continueType": [ 51e41f4b71Sopenharmony_ci "continueType1" 52e41f4b71Sopenharmony_ci ], 53e41f4b71Sopenharmony_ci "continueBundleName": [ 54e41f4b71Sopenharmony_ci "com.example.myapplication1", 55e41f4b71Sopenharmony_ci "com.example.myapplication2" 56e41f4b71Sopenharmony_ci ] 57e41f4b71Sopenharmony_ci } 58e41f4b71Sopenharmony_ci ], 59e41f4b71Sopenharmony_ci "definePermissions": [ 60e41f4b71Sopenharmony_ci { 61e41f4b71Sopenharmony_ci "name": "ohos.abilitydemo.permission.PROVIDER", 62e41f4b71Sopenharmony_ci "grantMode": "system_grant", 63e41f4b71Sopenharmony_ci "availableLevel": "system_core", 64e41f4b71Sopenharmony_ci "provisionEnable": true, 65e41f4b71Sopenharmony_ci "distributedSceneEnable": false, 66e41f4b71Sopenharmony_ci "label": "$string:EntryAbility_label" 67e41f4b71Sopenharmony_ci } 68e41f4b71Sopenharmony_ci ], 69e41f4b71Sopenharmony_ci "requestPermissions": [ 70e41f4b71Sopenharmony_ci { 71e41f4b71Sopenharmony_ci "name": "ohos.abilitydemo.permission.PROVIDER", 72e41f4b71Sopenharmony_ci "reason": "$string:reason", 73e41f4b71Sopenharmony_ci "usedScene": { 74e41f4b71Sopenharmony_ci "abilities": [ 75e41f4b71Sopenharmony_ci "FormAbility" 76e41f4b71Sopenharmony_ci ], 77e41f4b71Sopenharmony_ci "when": "inuse" 78e41f4b71Sopenharmony_ci } 79e41f4b71Sopenharmony_ci } 80e41f4b71Sopenharmony_ci ], 81e41f4b71Sopenharmony_ci "targetModuleName": "feature", 82e41f4b71Sopenharmony_ci "targetPriority": 50, 83e41f4b71Sopenharmony_ci "querySchemes": [ 84e41f4b71Sopenharmony_ci "app1Scheme", 85e41f4b71Sopenharmony_ci "app2Scheme" 86e41f4b71Sopenharmony_ci ], 87e41f4b71Sopenharmony_ci "routerMap": "$profile:router_map", 88e41f4b71Sopenharmony_ci "appEnvironments": [ 89e41f4b71Sopenharmony_ci { 90e41f4b71Sopenharmony_ci "name": "name1", 91e41f4b71Sopenharmony_ci "value": "value1" 92e41f4b71Sopenharmony_ci } 93e41f4b71Sopenharmony_ci ], 94e41f4b71Sopenharmony_ci "hnpPackages": [ 95e41f4b71Sopenharmony_ci { 96e41f4b71Sopenharmony_ci "package": "hnpsample.hnp", 97e41f4b71Sopenharmony_ci "type": "public" 98e41f4b71Sopenharmony_ci } 99e41f4b71Sopenharmony_ci ], 100e41f4b71Sopenharmony_ci "fileContextMenu": "$profile:menu" 101e41f4b71Sopenharmony_ci } 102e41f4b71Sopenharmony_ci} 103e41f4b71Sopenharmony_ci``` 104e41f4b71Sopenharmony_ci<!--RP1End--> 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci## 配置文件标签 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_cimodule.json5配置文件包含以下标签。 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ci **表1** module.json5配置文件标签说明 112e41f4b71Sopenharmony_ci 113e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 114e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 115e41f4b71Sopenharmony_ci| name | 标识当前Module的名称,确保该名称在整个应用中唯一。命名规则如下 :<br/>- 由字母、数字和下划线组成,且必须以字母开头。<br/>- 最大长度31字节。<br/>应用升级时允许修改该名称,但需要应用适配Module相关数据目录的迁移,详见[文件管理接口](../reference/apis-core-file-kit/js-apis-file-fs.md#fscopydir10)。 | 字符串 | 该标签不可缺省。 | 116e41f4b71Sopenharmony_ci| type | 标识当前Module的类型。支持的取值如下:<br/>- entry:应用的主模块。<br/>- feature:应用的动态特性模块。<br/>- har:静态共享包模块。<br/>- shared:动态共享包模块。 | 字符串 | 该标签不可缺省。 | 117e41f4b71Sopenharmony_ci| srcEntry | 标识当前Module所对应的代码路径,取值为长度不超过127字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 118e41f4b71Sopenharmony_ci| description | 标识当前Module的描述信息,取值为长度不超过255字节的字符串,可以采用字符串资源索引格式。 | 字符串 | 该标签可缺省,缺省值为空。 | 119e41f4b71Sopenharmony_ci| process | 标识当前Module的进程名,取值为长度不超过31字节的字符串。如果在HAP标签下配置了process,则该应用的所有UIAbility、DataShareExtensionAbility、ServiceExtensionAbility都运行在该进程中。<br/>**说明:**<br/>仅支持系统应用配置,三方应用配置不生效。 | 字符串 | 该标签可缺省,缺省为app.json5文件下app标签下的bundleName。 | 120e41f4b71Sopenharmony_ci| mainElement | 标识当前Module的入口UIAbility名称或者ExtensionAbility名称,取值为长度不超过255字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 121e41f4b71Sopenharmony_ci| [deviceTypes](#devicetypes标签) | 标识当前Module可以运行在哪类设备上。 | 字符串数组 | 该标签不可缺省。 | 122e41f4b71Sopenharmony_ci| deliveryWithInstall | 标识当前Module是否在用户主动安装的时候安装,即该Module对应的HAP是否跟随应用一起安装。<br/>- true:主动安装时安装。<br/>- false:主动安装时不安装。 | 布尔值 | 该标签不可缺省。 | 123e41f4b71Sopenharmony_ci| installationFree | 标识当前Module是否支持免安装特性。<br/>- true:表示支持免安装特性,且符合免安装约束。<br/>- false:表示不支持免安装特性。<br/>**说明:**<br/>当[bundleType](./app-configuration-file.md#配置文件标签)为原子化服务时,该字段需要配置为true。反之,该字段需要配置为false。 | 布尔值 | 该标签不可缺省。 | 124e41f4b71Sopenharmony_ci| virtualMachine | 标识当前Module运行的目标虚拟机类型,供云端分发使用,如应用市场和分发中心。如果目标虚拟机类型为ArkTS引擎,则其值为“ark+版本号”。 | 字符串 | 该标签由IDE构建HAP的时候自动插入。 | 125e41f4b71Sopenharmony_ci| [pages](#pages标签) | 标识当前Module的profile资源,用于列举每个页面信息,取值为长度不超过255字节的字符串。 | 字符串 | 在有UIAbility的场景下,该标签不可缺省。 | 126e41f4b71Sopenharmony_ci| [metadata](#metadata标签) | 标识当前Module的自定义元信息,可通过资源引用的方式配置[distributionFilter](#distributionfilter标签)、[shortcuts](#shortcuts标签)等信息。只对当前Module、UIAbility、ExtensionAbility生效。 | 对象数组 | 该标签可缺省,缺省值为空。 | 127e41f4b71Sopenharmony_ci| [abilities](#abilities标签) | 标识当前Module中UIAbility的配置信息,只对当前UIAbility生效。 | 对象数组 | 该标签可缺省,缺省值为空。 | 128e41f4b71Sopenharmony_ci| [extensionAbilities](#extensionabilities标签) | 标识当前Module中ExtensionAbility的配置信息,只对当前ExtensionAbility生效。 | 对象数组 | 该标签可缺省,缺省值为空。 | 129e41f4b71Sopenharmony_ci| [definePermissions](#definepermissions标签) | 标识系统资源hap定义的权限,不支持应用自定义权限。 | 对象数组 | 该标签可缺省,缺省值为空。 | 130e41f4b71Sopenharmony_ci| [requestPermissions](../security/AccessToken/declare-permissions.md#在配置文件中声明权限)| 标识当前应用运行时需向系统申请的权限集合。 | 对象数组 | 该标签可缺省,缺省值为空。 | 131e41f4b71Sopenharmony_ci| [testRunner](#testrunner标签) | 标识用于测试当前Module的测试框架的配置。 | 对象 | 该标签可缺省,缺省值为空。 | 132e41f4b71Sopenharmony_ci| [atomicService](#atomicservice标签)| 标识当前应用是原子化服务时,有关原子化服务的相关配置。| 对象 | 该标签可缺省,缺省值为空。 | 133e41f4b71Sopenharmony_ci| [dependencies](#dependencies标签)| 标识当前模块运行时依赖的共享库列表。| 对象数组 | 该标签可缺省,缺省值为空。 | 134e41f4b71Sopenharmony_ci| targetModuleName | 标识当前包所指定的目标module,确保该名称在整个应用中唯一。取值为长度不超过31字节的字符串,不支持中文。配置该字段的Module具有overlay特性。仅在动态共享包(HSP)中适用。 |字符串|该标签可缺省,缺省值为空。| 135e41f4b71Sopenharmony_ci| targetPriority | 标识当前Module的优先级,取值范围为1~100。配置targetModuleName字段之后,才需要配置该字段。仅在动态共享包(HSP)中适用。 |整型数值|该标签可缺省,缺省值为1。| 136e41f4b71Sopenharmony_ci| [proxyData](#proxydata标签) | 标识当前Module提供的数据代理列表。| 对象数组 | 该标签可缺省,缺省值为空。| 137e41f4b71Sopenharmony_ci| isolationMode | 标识当前Module的多进程配置项。支持的取值如下:<br/>- nonisolationFirst:优先在非独立进程中运行。<br/>- isolationFirst:优先在独立进程中运行。<br/>- isolationOnly:只在独立进程中运行。<br/>- nonisolationOnly:只在非独立进程中运行。 |字符串|该标签可缺省,缺省值为nonisolationFirst。| 138e41f4b71Sopenharmony_ci| generateBuildHash |标识当前HAP/HSP是否由打包工具生成哈希值。当配置为true时,如果系统OTA升级时应用versionCode保持不变,可根据哈希值判断应用是否需要升级。<br/>该字段仅在[app.json5文件](./app-configuration-file.md)中的generateBuildHash字段为false时使能。<br/>**说明:**<br/>该字段仅对预置应用生效。|布尔值|该标签可缺省,缺省值为false。| 139e41f4b71Sopenharmony_ci| compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP。<br/>- true:libs库以压缩方式存储。<br/>- false:libs库以不压缩方式存储。 | 布尔值 | 该标签可缺省,缺省值为false。 | 140e41f4b71Sopenharmony_ci| libIsolation | 用于区分同应用不同HAP下的.so文件,以防止.so冲突。<br/>- true:当前HAP的.so文件会储存在libs目录中以Module名命名的路径下。<br/>- false:当前HAP的.so文件会直接储存在libs目录中。 | 布尔值 | 该标签可缺省,缺省值为false。 | 141e41f4b71Sopenharmony_ci| fileContextMenu | 标识当前HAP的右键菜单配置项。取值为长度不超过255字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 142e41f4b71Sopenharmony_ci| querySchemes | 标识允许当前应用进行跳转查询的URL schemes,只允许entry类型模块配置,最多50个,每个字符串取值不超过128字节。 | 字符串数组 | 该标签可缺省,缺省值为空。 | 143e41f4b71Sopenharmony_ci| [routerMap](#routermap标签) | 标识当前模块配置的路由表路径。取值为长度不超过255字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 144e41f4b71Sopenharmony_ci| [appEnvironments](#appenvironments标签) | 标识当前模块配置的应用环境变量,只允许entry和feature模块配置。 | 对象数组 | 该标签可缺省,缺省值为空。 | 145e41f4b71Sopenharmony_ci| appStartup | 标识当前Module启动框架配置路径,仅在Entry中生效。 | 字符串 | 该标签可缺省,缺省值为空。 | 146e41f4b71Sopenharmony_ci| [hnpPackages](#hnppackages标签) | 标识当前应用包含的Native软件包信息。只允许entry类型模块配置。 | 对象数组 | 该标签可缺省,缺省值为空。 | 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci## deviceTypes标签 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci **表2** deviceTypes标签说明 151e41f4b71Sopenharmony_ci<!--RP2--> 152e41f4b71Sopenharmony_ci| 设备类型 | 枚举值 | 说明 | 153e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 154e41f4b71Sopenharmony_ci| 平板 | tablet | - | 155e41f4b71Sopenharmony_ci| 智慧屏 | tv | - | 156e41f4b71Sopenharmony_ci| 智能手表 | wearable | 系统能力较丰富的手表,具备电话功能。 | 157e41f4b71Sopenharmony_ci| 车机 | car | - | 158e41f4b71Sopenharmony_ci| 2in1 | 2in1 | 融合了屏幕触控和键鼠操作的二合一设备。 | 159e41f4b71Sopenharmony_ci| 默认设备 | default | 能够使用全部系统能力的设备。 | 160e41f4b71Sopenharmony_ci<!--RP2End--> 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_cideviceTypes示例: 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ci 165e41f4b71Sopenharmony_ci```json 166e41f4b71Sopenharmony_ci{ 167e41f4b71Sopenharmony_ci "module": { 168e41f4b71Sopenharmony_ci "name": "myHapName", 169e41f4b71Sopenharmony_ci "type": "feature", 170e41f4b71Sopenharmony_ci "deviceTypes" : [ 171e41f4b71Sopenharmony_ci "tablet" 172e41f4b71Sopenharmony_ci ] 173e41f4b71Sopenharmony_ci } 174e41f4b71Sopenharmony_ci} 175e41f4b71Sopenharmony_ci``` 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci## pages标签 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci该标签是一个profile文件资源,用于指定描述页面信息的配置文件。 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci 183e41f4b71Sopenharmony_ci```json 184e41f4b71Sopenharmony_ci{ 185e41f4b71Sopenharmony_ci "module": { 186e41f4b71Sopenharmony_ci // ... 187e41f4b71Sopenharmony_ci "pages": "$profile:main_pages", // 通过profile下的资源文件配置 188e41f4b71Sopenharmony_ci } 189e41f4b71Sopenharmony_ci} 190e41f4b71Sopenharmony_ci``` 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci在开发视图的resources/base/profile下面定义配置文件main_pages.json,其中文件名"main_pages"可自定义,需要和pages标签指定的信息对应。配置文件中列举了当前应用组件中的页面信息,包含页面的路由信息和显示窗口相关的配置。 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci **表3** pages标签说明 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 197e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 198e41f4b71Sopenharmony_ci| src | 标识当前Module中所有页面的路由信息,包括页面路径和页面名称。其中,页面路径是以当前Module的src/main/ets为基准。该标签取值为一个字符串数组,其中每个元素表示一个页面。 | 字符串数组 | 该标签不可缺省。 | 199e41f4b71Sopenharmony_ci| window | 标识用于定义与显示窗口相关的配置。 | 对象 | 该标签可缺省,缺省值为空。 | 200e41f4b71Sopenharmony_ci 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci **表4** window标签说明 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 205e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 206e41f4b71Sopenharmony_ci| designWidth | 标识页面设计基准宽度。以此为基准,根据实际设备宽度来缩放元素大小。 | 数值 | 可缺省,缺省值为720px。 | 207e41f4b71Sopenharmony_ci| autoDesignWidth | 标识页面设计基准宽度是否自动计算。当配置为true时,designWidth将会被忽略,设计基准宽度由设备宽度与屏幕密度计算得出。 | 布尔值 | 可缺省,缺省值为false。 | 208e41f4b71Sopenharmony_ci 209e41f4b71Sopenharmony_ci```json 210e41f4b71Sopenharmony_ci{ 211e41f4b71Sopenharmony_ci "src": [ 212e41f4b71Sopenharmony_ci "pages/index/mainPage", 213e41f4b71Sopenharmony_ci "pages/second/payment", 214e41f4b71Sopenharmony_ci "pages/third/shopping_cart", 215e41f4b71Sopenharmony_ci "pages/four/owner" 216e41f4b71Sopenharmony_ci ], 217e41f4b71Sopenharmony_ci "window": { 218e41f4b71Sopenharmony_ci "designWidth": 720, 219e41f4b71Sopenharmony_ci "autoDesignWidth": false 220e41f4b71Sopenharmony_ci } 221e41f4b71Sopenharmony_ci} 222e41f4b71Sopenharmony_ci``` 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci## metadata标签 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci该标签标识HAP的自定义元信息,标签值为数组类型,包含name、value、resource三个子标签。 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci**表5** metadata标签说明 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 232e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 233e41f4b71Sopenharmony_ci| name | 标识数据项的名称,取值为长度不超过255字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 234e41f4b71Sopenharmony_ci| value | 标识数据项的值,取值为长度不超过255字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 235e41f4b71Sopenharmony_ci| resource | 标识定义用户自定义数据格式,取值为长度不超过255字节的字符串,内容为标识该数据的资源索引。| 字符串 | 该标签可缺省,缺省值为空。 | 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ciresource属性值使用“$profile:文件名”的方式指定文件所在位置,$profile表示资源的路径为工程中的/resources/base/profile目录下。例如$profile:shortcuts_config指定了/resources/base/profile/shortcuts_config.json文件。metadata标签可配置启动页默认大小,name为ohos.ability.window.height表示启动页默认高度,name为ohos.ability.window.width表示启动页默认宽度。 238e41f4b71Sopenharmony_ci 239e41f4b71Sopenharmony_ci```json 240e41f4b71Sopenharmony_ci{ 241e41f4b71Sopenharmony_ci "module": { 242e41f4b71Sopenharmony_ci "metadata": [{ 243e41f4b71Sopenharmony_ci "name": "module_metadata", 244e41f4b71Sopenharmony_ci "value": "a test demo for module metadata", 245e41f4b71Sopenharmony_ci "resource": "$profile:shortcuts_config" 246e41f4b71Sopenharmony_ci }], 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci "abilities": [{ 249e41f4b71Sopenharmony_ci "metadata": [{ 250e41f4b71Sopenharmony_ci "name": "ability_metadata", 251e41f4b71Sopenharmony_ci "value": "a test demo for ability", 252e41f4b71Sopenharmony_ci "resource": "$profile:config_file" 253e41f4b71Sopenharmony_ci }, 254e41f4b71Sopenharmony_ci { 255e41f4b71Sopenharmony_ci "name": "ability_metadata_2", 256e41f4b71Sopenharmony_ci "value": "a string test", 257e41f4b71Sopenharmony_ci "resource": "$profile:config_file" 258e41f4b71Sopenharmony_ci }, 259e41f4b71Sopenharmony_ci { 260e41f4b71Sopenharmony_ci "name": "ohos.ability.window.height", 261e41f4b71Sopenharmony_ci "value": "987" 262e41f4b71Sopenharmony_ci }, 263e41f4b71Sopenharmony_ci { 264e41f4b71Sopenharmony_ci "name": "ohos.ability.window.width", 265e41f4b71Sopenharmony_ci "value": "1300" 266e41f4b71Sopenharmony_ci }], 267e41f4b71Sopenharmony_ci }], 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ci "extensionAbilities": [{ 270e41f4b71Sopenharmony_ci "metadata": [{ 271e41f4b71Sopenharmony_ci "name": "extensionAbility_metadata", 272e41f4b71Sopenharmony_ci "value": "a test for extensionAbility", 273e41f4b71Sopenharmony_ci "resource": "$profile:config_file" 274e41f4b71Sopenharmony_ci }, 275e41f4b71Sopenharmony_ci { 276e41f4b71Sopenharmony_ci "name": "extensionAbility_metadata_2", 277e41f4b71Sopenharmony_ci "value": "a string test", 278e41f4b71Sopenharmony_ci "resource": "$profile:config_file" 279e41f4b71Sopenharmony_ci }], 280e41f4b71Sopenharmony_ci }] 281e41f4b71Sopenharmony_ci } 282e41f4b71Sopenharmony_ci} 283e41f4b71Sopenharmony_ci``` 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ci 286e41f4b71Sopenharmony_ci## abilities标签 287e41f4b71Sopenharmony_ci 288e41f4b71Sopenharmony_ciabilities标签描述UIAbility组件的配置信息,标签值为数组类型,该标签下的配置只对当前UIAbility生效。 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ci **表6** abilities标签说明 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 293e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 294e41f4b71Sopenharmony_ci| name | 标识当前UIAbility组件的名称,确保该名称在整个应用中唯一。取值为长度不超过127字节的字符串,不支持中文。 | 字符串 | 该标签不可缺省。 | 295e41f4b71Sopenharmony_ci| srcEntry | 标识入口UIAbility的代码路径,取值为长度不超过127字节的字符串。 | 字符串 | 该标签不可缺省。 | 296e41f4b71Sopenharmony_ci| [launchType](../application-models/uiability-launch-type.md) | 标识当前UIAbility组件的启动模式,支持的取值如下:<br/>- multiton:多实例模式,每次启动创建一个新实例。<br/>- singleton:单实例模式,仅第一次启动创建新实例。<br/>- specified:指定实例模式,运行时由开发者决定是否创建新实例。<br/>- standard:multiton的曾用名,效果与多实例模式一致。 | 字符串 | 该标签可缺省,该标签缺省为“singleton”。 | 297e41f4b71Sopenharmony_ci| description | 标识当前UIAbility组件的描述信息,取值为长度不超过255字节的字符串。要求采用描述信息的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | 298e41f4b71Sopenharmony_ci| icon | 标识当前UIAbility组件的图标,取值为图标资源文件的索引。 | 字符串 | 该标签可缺省,缺省值为空。<br/>如果UIAbility被配置为MainElement,该标签必须配置。 | 299e41f4b71Sopenharmony_ci| label | 标识当前UIAbility组件对用户显示的名称,要求采用该名称的资源索引,以支持多语言。取值为长度不超过255字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。<br/>如果UIAbility被配置为MainElement,该标签必须配置。 | 300e41f4b71Sopenharmony_ci| permissions | 标识当前UIAbility组件自定义的权限信息。当其他应用访问该UIAbility时,需要申请相应的权限信息。<br/>一个数组元素为一个权限名称。通常采用反向域名格式(不超过255字节),取值为系统预定义的权限。 | 字符串数组 | 该标签可缺省,缺省值为空。 | 301e41f4b71Sopenharmony_ci| [metadata](#metadata标签) | 标识当前UIAbility组件的元信息。 | 对象数组 | 该标签可缺省,缺省值为空。 | 302e41f4b71Sopenharmony_ci| exported | 标识当前UIAbility组件是否可以被其他应用调用。<br/>- true:表示可以被其他应用调用。<br/>- false:表示不可以被其他应用调用,包括无法被aa工具命令拉起应用。 | 布尔值 | 该标签可缺省,缺省值为false。 | 303e41f4b71Sopenharmony_ci| continuable | 标识当前UIAbility组件是否支持跨端迁移。<br/>- true:表示支持迁移。<br/>- false:表示不支持迁移。 | 布尔值 | 该标签可缺省,缺省值为false。 | 304e41f4b71Sopenharmony_ci| [skills](#skills标签) | 标识当前UIAbility组件或ExtensionAbility组件能够接收的[Want](../application-models/want-overview.md)特征集,为数组格式。<br/>配置规则:<br/>- 对于Entry类型的HAP,应用可以配置多个具有入口能力的skills标签(即配置了ohos.want.action.home和entity.system.home)。<br/>- 对于Feature类型的HAP,只有应用可以配置具有入口能力的skills标签,服务不允许配置。 | 对象数组 | 该标签可缺省,缺省值为空。 | 305e41f4b71Sopenharmony_ci| backgroundModes | 标识当前UIAbility组件的长时任务集合,指定用于满足特定类型的长时任务。<br/>长时任务类型有如下:<br/>- dataTransfer:通过网络/对端设备进行数据下载、备份、分享、传输等。<br/>- audioPlayback:音频播放。<br/>- audioRecording:录音。<br/>- location:定位、导航。<br/>- bluetoothInteraction:蓝牙扫描、连接、传输(穿戴)。<br/>- multiDeviceConnection:多设备互联。<br/>- taskKeeping:计算。 | 字符串数组 | 该标签可缺省,缺省值为空。 | 306e41f4b71Sopenharmony_ci| startWindowIcon | 标识当前UIAbility组件启动页面图标资源文件的索引,取值为长度不超过255字节的字符串。 | 字符串 | 该标签不可缺省。 | 307e41f4b71Sopenharmony_ci| startWindowBackground | 标识当前UIAbility组件启动页面背景颜色资源文件的索引,取值为长度不超过255字节的字符串。<br/>取值示例:$color:red。| 字符串 | 该标签不可缺省。 | 308e41f4b71Sopenharmony_ci| removeMissionAfterTerminate | 标识当前UIAbility组件销毁后,是否从任务列表中移除任务。<br/>- true表示销毁后移除任务。<br/>- false表示销毁后不移除任务。 | 布尔值 | 该标签可缺省,缺省值为false。 | 309e41f4b71Sopenharmony_ci| orientation | 标识当前UIAbility组件启动时的方向。支持的取值如下:<br/>- unspecified:未指定方向,由系统自动判断显示方向。<br/>- landscape:横屏。<br/>- portrait:竖屏。<br/>- follow_recent:跟随背景窗口的旋转模式。<br/>- landscape_inverted:反向横屏。<br/>- portrait_inverted:反向竖屏。<br/>- auto_rotation:随传感器旋转。<br/>- auto_rotation_landscape:传感器横屏旋转,包括横屏和反向横屏。<br/>- auto_rotation_portrait:传感器竖屏旋转,包括竖屏和反向竖屏。<br/>- auto_rotation_restricted:传感器开关打开,方向可随传感器旋转。<br/>- auto_rotation_landscape_restricted:传感器开关打开,方向可随传感器旋转为横屏, 包括横屏和反向横屏。<br/>- auto_rotation_portrait_restricted:传感器开关打开,方向随可传感器旋转为竖屏, 包括竖屏和反向竖屏。<br/>- locked:传感器开关关闭,方向锁定。<br/>- auto_rotation_unspecified:受开关控制和由系统判定的自动旋转模式。<br/>- follow_desktop:跟随桌面的旋转模式。 | 字符串 | 该标签可缺省,缺省值为unspecified。 | 310e41f4b71Sopenharmony_ci| supportWindowMode | 标识当前UIAbility组件所支持的窗口模式。支持的取值如下:<br/>- fullscreen:全屏模式。<br/>- split:分屏模式。<br/>- floating:悬浮窗模式。 | 字符串数组 | 该标签可缺省,缺省值为<br/>["fullscreen", "split", "floating"]。 | 311e41f4b71Sopenharmony_ci| priority | 标识当前UIAbility组件的优先级。[隐式查询](../application-models/explicit-implicit-want-mappings.md)时,优先级越高,UIAbility在返回列表越靠前。取值范围0~10,数值越大,优先级越高。<br/>**说明:**<br/>仅支持系统应用配置,三方应用配置不生效。 | 整型数值 | 该标签可缺省,缺省值为0。 | 312e41f4b71Sopenharmony_ci| maxWindowRatio | 标识当前UIAbility组件支持的最大的宽高比。该标签最小取值为0。 | 数值 | 该标签可缺省,缺省值为平台支持的最大的宽高比。 | 313e41f4b71Sopenharmony_ci| minWindowRatio | 标识当前UIAbility组件支持的最小的宽高比。该标签最小取值为0。 | 数值 | 该标签可缺省,缺省值为平台支持的最小的宽高比。 | 314e41f4b71Sopenharmony_ci| maxWindowWidth | 标识当前UIAbility组件支持的最大的窗口宽度,宽度单位为vp。<br/>最小取值为minWindowWidth,最大取值为平台支持的最大窗口宽度。窗口尺寸可以参考[窗口大小限制](../windowmanager/window-overview.md#约束与限制)。 | 数值 | 该标签可缺省,缺省值为平台支持的最大的窗口宽度。 | 315e41f4b71Sopenharmony_ci| minWindowWidth | 标识当前UIAbility组件支持的最小的窗口宽度, 宽度单位为vp。<br/>最小取值为平台支持的最小窗口宽度,最大取值为maxWindowWidth。窗口尺寸可以参考[窗口大小限制](../windowmanager/window-overview.md#约束与限制)。 | 数值 | 该标签可缺省,缺省值为平台支持的最小的窗口宽度。 | 316e41f4b71Sopenharmony_ci| maxWindowHeight | 标识当前UIAbility组件支持的最大的窗口高度, 高度单位为vp。<br/>最小取值为minWindowHeight,最大取值为平台支持的最大窗口高度。 窗口尺寸可以参考[窗口大小限制](../windowmanager/window-overview.md#约束与限制)。| 数值 | 该标签可缺省,缺省值为平台支持的最大的窗口高度。 | 317e41f4b71Sopenharmony_ci| minWindowHeight | 标识当前UIAbility组件支持的最小的窗口高度, 高度单位为vp。<br/>最小取值为平台支持的最小窗口高度,最大取值为maxWindowHeight。窗口尺寸可以参考[窗口大小限制](../windowmanager/window-overview.md#约束与限制)。| 数值 | 该标签可缺省,缺省值为平台支持的最小的窗口高度。 | 318e41f4b71Sopenharmony_ci| excludeFromMissions | 标识当前UIAbility组件是否在最近任务列表中显示。<br/>- true:表示不在任务列表中显示。<br/>- false:表示在任务列表中显示。<br/>**说明:**<br/>仅支持系统应用配置,且需申请应用特权AllowAbilityExcludeFromMissions,三方应用配置不生效<!--Del-->,详见[应用特权配置指导](../../device-dev/subsystems/subsys-app-privilege-config-guide.md)<!--DelEnd-->。| 布尔值 | 该标签可缺省,缺省值为false。 | 319e41f4b71Sopenharmony_ci| recoverable | 标识当前UIAbility组件是否支持在检测到应用故障后,恢复到应用原界面。<br/>- true:支持检测到出现故障后,恢复到原界面。<br/>- false:不支持检测到出现故障后,恢复到原界面。 | 布尔值 | 该标签可缺省,缺省值为false。 | 320e41f4b71Sopenharmony_ci| unclearableMission | 标识当前UIAbility组件是否支持从最近任务列表中移除。<br/>- true:表示在任务列表中不可移除。<br/>- false:表示在任务列表中可以移除。<br/>**说明:**<br/>单独配置该字段不可生效,需要申请对应的<!--Del-->[<!--DelEnd-->AllowMissionNotCleared<!--Del-->](../../device-dev/subsystems/subsys-app-privilege-config-guide.md)<!--DelEnd-->特权之后,该字段才能生效。 | 布尔值 | 该标签可缺省,缺省值为false。 | 321e41f4b71Sopenharmony_ci| isolationProcess | 标识组件能否运行在独立的进程中。<br/>- true:表示能运行在独立的进程中。<br/>- false:表示不能运行在独立的进程中。 | 布尔值 | 该标签可缺省,缺省值为false。 | 322e41f4b71Sopenharmony_ci| excludeFromDock | 标识当前UIAbility组件是否支持从dock区域隐藏图标。<br/>- true:表示在dock区域隐藏。<br/>- false:表示不能在dock区域隐藏。 | 布尔值 | 该标签可缺省,缺省值为false。 | 323e41f4b71Sopenharmony_ci| preferMultiWindowOrientation | 标识当前UIAbility组件多窗布局方向:<br/>- default:缺省值,参数不配置默认值,建议其他应用类配置。<br/>- portrait:多窗布局方向为竖向,建议竖向游戏类应用配置。<br/>- landscape:多窗布局方向为横向,配置后支持横屏悬浮窗和上下分屏,建议横向游戏类应用配置。<br/>- landscape_auto:多窗布局动态可变为横向,需要配合API enableLandScapeMultiWindow/disableLandScapeMultiWindow使用,建议视频类应用配置。 | 字符串 | 该标签可缺省,缺省值为default。 | 324e41f4b71Sopenharmony_ci| continueType | 标识当前UIAbility组件的跨端迁移类型。 | 字符串数组 | 该标签可缺省,缺省值为当前组件的名称。 | 325e41f4b71Sopenharmony_ci| continueBundleName | 标识当前应用支持跨端迁移的其它应用名称列表。<br/>**说明:**<br/>不能配置为本应用包名,仅为了做异包名迁移使用。 | 字符串数组 | 该标签可缺省,缺省值为空。 | 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ciabilities示例: 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_ci```json 331e41f4b71Sopenharmony_ci{ 332e41f4b71Sopenharmony_ci "abilities": [{ 333e41f4b71Sopenharmony_ci "name": "EntryAbility", 334e41f4b71Sopenharmony_ci "srcEntry": "./ets/entryability/EntryAbility.ets", 335e41f4b71Sopenharmony_ci "launchType":"singleton", 336e41f4b71Sopenharmony_ci "description": "$string:description_main_ability", 337e41f4b71Sopenharmony_ci "icon": "$media:layered_image", 338e41f4b71Sopenharmony_ci "label": "Login", 339e41f4b71Sopenharmony_ci "permissions": [], 340e41f4b71Sopenharmony_ci "metadata": [], 341e41f4b71Sopenharmony_ci "exported": true, 342e41f4b71Sopenharmony_ci "continuable": true, 343e41f4b71Sopenharmony_ci "skills": [{ 344e41f4b71Sopenharmony_ci "actions": ["ohos.want.action.home"], 345e41f4b71Sopenharmony_ci "entities": ["entity.system.home"], 346e41f4b71Sopenharmony_ci "uris": [] 347e41f4b71Sopenharmony_ci }], 348e41f4b71Sopenharmony_ci "backgroundModes": [ 349e41f4b71Sopenharmony_ci "dataTransfer", 350e41f4b71Sopenharmony_ci "audioPlayback", 351e41f4b71Sopenharmony_ci "audioRecording", 352e41f4b71Sopenharmony_ci "location", 353e41f4b71Sopenharmony_ci "bluetoothInteraction", 354e41f4b71Sopenharmony_ci "multiDeviceConnection", 355e41f4b71Sopenharmony_ci "wifiInteraction", 356e41f4b71Sopenharmony_ci "voip", 357e41f4b71Sopenharmony_ci "taskKeeping" 358e41f4b71Sopenharmony_ci ], 359e41f4b71Sopenharmony_ci "startWindowIcon": "$media:icon", 360e41f4b71Sopenharmony_ci "startWindowBackground": "$color:red", 361e41f4b71Sopenharmony_ci "removeMissionAfterTerminate": true, 362e41f4b71Sopenharmony_ci "orientation": " ", 363e41f4b71Sopenharmony_ci "supportWindowMode": ["fullscreen", "split", "floating"], 364e41f4b71Sopenharmony_ci "maxWindowRatio": 3.5, 365e41f4b71Sopenharmony_ci "minWindowRatio": 0.5, 366e41f4b71Sopenharmony_ci "maxWindowWidth": 2560, 367e41f4b71Sopenharmony_ci "minWindowWidth": 1400, 368e41f4b71Sopenharmony_ci "maxWindowHeight": 300, 369e41f4b71Sopenharmony_ci "minWindowHeight": 200, 370e41f4b71Sopenharmony_ci "excludeFromMissions": false, 371e41f4b71Sopenharmony_ci "unclearableMission": false, 372e41f4b71Sopenharmony_ci "excludeFromDock": false, 373e41f4b71Sopenharmony_ci "preferMultiWindowOrientation": "default", 374e41f4b71Sopenharmony_ci "isolationProcess": false, 375e41f4b71Sopenharmony_ci "continueType": [ 376e41f4b71Sopenharmony_ci "continueType1", 377e41f4b71Sopenharmony_ci "continueType2" 378e41f4b71Sopenharmony_ci ], 379e41f4b71Sopenharmony_ci "continueBundleName": [ 380e41f4b71Sopenharmony_ci "com.example.myapplication1", 381e41f4b71Sopenharmony_ci "com.example.myapplication2" 382e41f4b71Sopenharmony_ci ] 383e41f4b71Sopenharmony_ci }] 384e41f4b71Sopenharmony_ci} 385e41f4b71Sopenharmony_ci``` 386e41f4b71Sopenharmony_ci 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci## skills标签 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ci该标签标识UIAbility组件或者ExtensionAbility组件能够接收的[Want](../application-models/want-overview.md)的特征。 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci **表7** skills标签说明 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 395e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 396e41f4b71Sopenharmony_ci| actions | 标识能够接收的Action值集合,取值通常为系统预定义的action值,也允许自定义。<br>一个skill中不建议配置多个action,否则可能导致无法匹配预期场景。 | 字符串数组 | 该标签可缺省,缺省值为空。 | 397e41f4b71Sopenharmony_ci| entities | 标识能够接收的Entity值的集合。<br>一个skill中不建议配置多个entity,否则可能导致无法匹配预期场景。 | 字符串数组 | 该标签可缺省,缺省值为空。 | 398e41f4b71Sopenharmony_ci| uris | 标识与Want中URI(Uniform Resource Identifier)相匹配的集合。数组允许的最大数量为512。 | 对象数组 | 该标签可缺省,缺省值为空。 | 399e41f4b71Sopenharmony_ci| permissions | 标识当前UIAbility组件自定义的权限信息。当其他应用访问该UIAbility时,需要申请相应的权限信息。<br/>一个数组元素为一个权限名称。通常采用反向域名格式(不超过255字节),取值为系统预定义的权限。 | 字符串数组 | 该标签可缺省,缺省值为空。 | 400e41f4b71Sopenharmony_ci| domainVerify | 标识是否开启域名校验。 | 布尔值 | 该标签可缺省,缺省值为false。 | 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ci **表8** uris标签说明 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 406e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 407e41f4b71Sopenharmony_ci| scheme | 标识URI的协议名部分,常见的有http、https、file、ftp等。 | 字符串 | uris中仅配置type时可以缺省,缺省值为空,否则不可缺省。 | 408e41f4b71Sopenharmony_ci| host | 标识URI的主机地址部分,该字段在scheme存在时才有意义。常见的方式:<br/>- 域名方式,如example.com。<br/>- IP地址方式,如10.10.10.1。 | 字符串 | 该标签可缺省,缺省值为空。 | 409e41f4b71Sopenharmony_ci| port | 标识URI的端口部分。如http默认端口为80,https默认端口是443,ftp默认端口是21。该字段在scheme和host都存在时才有意义。 | 字符串 | 该标签可缺省,缺省值为空。 | 410e41f4b71Sopenharmony_ci| path \| pathStartWith \| pathRegex | 标识URI的路径部分,path、pathStartWith和pathRegex配置时三选一。path标识URI与want中的路径部分全匹配,pathStartWith标识URI与want中的路径部分允许前缀匹配,pathRegex标识URI与want中的路径部分允许正则匹配。该字段在scheme和host都存在时才有意义。 | 字符串 | 该标签可缺省,缺省值为空。 | 411e41f4b71Sopenharmony_ci| type | 标识与Want相匹配的数据类型,使用MIME(Multipurpose Internet Mail Extensions)类型规范和[UniformDataType](../reference/apis-arkdata/js-apis-data-uniformTypeDescriptor.md)类型规范。可与scheme同时配置,也可以单独配置。 | 字符串 | 该标签可缺省,缺省值为空。 | 412e41f4b71Sopenharmony_ci| utd | 标识与Want相匹配的[标准化数据类型](../reference/apis-arkdata/js-apis-data-uniformTypeDescriptor.md),适用于分享等场景。 | 字符串 | 该标签可缺省,缺省值为空。 | 413e41f4b71Sopenharmony_ci| maxFileSupported | 对于指定类型的文件,标识一次能接收或打开的最大数量,适用于分享等场景,需要与utd配合使用。| 整数 | 该标签可缺省,缺省值为0。| 414e41f4b71Sopenharmony_ci| linkFeature | 标识URI提供的功能类型(如文件打开、分享、导航等),用于实现应用间跳转。取值为长度不超过127字节的字符串,不支持中文。详情见[linkFeature标签说明](../application-models/app-uri-config.md#linkfeature标签说明)。 | 字符串 | 该标签可缺省,缺省值为空。| 415e41f4b71Sopenharmony_ci 416e41f4b71Sopenharmony_ciskills示例: 417e41f4b71Sopenharmony_ci 418e41f4b71Sopenharmony_ci 419e41f4b71Sopenharmony_ci```json 420e41f4b71Sopenharmony_ci{ 421e41f4b71Sopenharmony_ci "abilities": [ 422e41f4b71Sopenharmony_ci { 423e41f4b71Sopenharmony_ci "skills": [ 424e41f4b71Sopenharmony_ci { 425e41f4b71Sopenharmony_ci "actions": [ 426e41f4b71Sopenharmony_ci "ohos.want.action.home" 427e41f4b71Sopenharmony_ci ], 428e41f4b71Sopenharmony_ci "entities": [ 429e41f4b71Sopenharmony_ci "entity.system.home" 430e41f4b71Sopenharmony_ci ], 431e41f4b71Sopenharmony_ci "uris": [ 432e41f4b71Sopenharmony_ci { 433e41f4b71Sopenharmony_ci "scheme":"http", 434e41f4b71Sopenharmony_ci "host":"example.com", 435e41f4b71Sopenharmony_ci "port":"80", 436e41f4b71Sopenharmony_ci "path":"path", 437e41f4b71Sopenharmony_ci "type": "text/*", 438e41f4b71Sopenharmony_ci "linkFeature": "Login" 439e41f4b71Sopenharmony_ci } 440e41f4b71Sopenharmony_ci ], 441e41f4b71Sopenharmony_ci "permissions": [], 442e41f4b71Sopenharmony_ci "domainVerify": false 443e41f4b71Sopenharmony_ci } 444e41f4b71Sopenharmony_ci ] 445e41f4b71Sopenharmony_ci } 446e41f4b71Sopenharmony_ci ] 447e41f4b71Sopenharmony_ci} 448e41f4b71Sopenharmony_ci``` 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci## extensionAbilities标签 451e41f4b71Sopenharmony_ci 452e41f4b71Sopenharmony_ci描述extensionAbilities的配置信息,标签值为数组类型,该标签下的配置只对当前extensionAbilities生效。 453e41f4b71Sopenharmony_ci 454e41f4b71Sopenharmony_ci **表9** extensionAbilities标签说明 455e41f4b71Sopenharmony_ci 456e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 457e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 458e41f4b71Sopenharmony_ci| name | 标识当前ExtensionAbility组件的名称,确保该名称在整个应用中唯一,取值为长度不超过127字节的字符串。 | 字符串 | 该标签不可缺省。 | 459e41f4b71Sopenharmony_ci| srcEntry | 标识当前ExtensionAbility组件所对应的代码路径,取值为长度不超过127字节的字符串。 | 字符串 | 该标签不可缺省。 | 460e41f4b71Sopenharmony_ci| description | 标识当前ExtensionAbility组件的描述,取值为长度不超过255字节的字符串,可以是对描述内容的资源索引,用于支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | 461e41f4b71Sopenharmony_ci| icon | 标识当前ExtensionAbility组件的图标,取值为资源文件的索引。如果ExtensionAbility组件被配置为MainElement,该标签必须配置。 | 字符串 | 该标签可缺省,缺省值为空。 | 462e41f4b71Sopenharmony_ci| label | 标识当前ExtensionAbility组件对用户显示的名称,取值为该名称的资源索引,以支持多语言,字符串长度不超过255字节。如果ExtensionAbility被配置当前Module的mainElement时,该标签必须配置,且要确保应用内唯一。 | 字符串 | 该标签可缺省,缺省值为空。 | 463e41f4b71Sopenharmony_ci| type | 标识当前ExtensionAbility组件的类型,支持的取值如下:<br/>- form:卡片的ExtensionAbility。<br/>- workScheduler:延时任务的ExtensionAbility。<br/>- inputMethod:输入法的ExtensionAbility。<br/>- service:后台运行的service组件。<br/>- accessibility:辅助能力的ExtensionAbility。<br/>- fileAccess:公共数据访问的ExtensionAbility,允许应用程序提供文件和文件夹给文件管理类应用展示。<br/>- dataShare:数据共享的ExtensionAbility。<br/>- staticSubscriber:静态广播的ExtensionAbility。<br/>- wallpaper:壁纸的ExtensionAbility。<br/>- backup:数据备份的ExtensionAbility。<br/>- window:该ExtensionAbility会在启动过程中创建一个window,为开发者提供界面开发。开发者开发出来的界面将通过UIExtensionComponent控件组合到其他应用的窗口中。<br/>- thumbnail:获取文件缩略图的ExtensionAbility,开发者可以对自定义文件类型的文件提供缩略。<br/>- preview:该ExtensionAbility会将文件解析后在一个窗口中显示,开发者可以通过将此窗口组合到其他应用窗口中。<br/>- print:打印框架的ExtensionAbility。<br/>- push:推送的ExtensionAbility。<br/>- driver:驱动框架的ExtensionAbility。<br/>- remoteNotification:远程通知的ExtensionAbility。<br/>- remoteLocation:远程定位的ExtensionAbility。<br/>- voip:网络音视频通话的ExtensionAbility。<br/>- action:自定义操作业务模板的ExtensionAbility,为开发者提供基于UIExtension的自定义操作业务模板<br/>- adsService:广告业务的ExtensionAbility,提供广告业务框架。<br/>- embeddedUI:嵌入式UI扩展能力,提供跨进程界面嵌入的能力。<br/>- insightIntentUI:为开发者提供能被小艺意图调用,以窗口形态呈现内容的扩展能力。<br/>- ads:广告业务的ExtensionAbility,与AdComponent控件组合使用,将广告页面展示到其他应用中。仅支持设备厂商使用。<br/>- photoEditor:图片编辑业务的ExtensionAbility,为开发者提供基于UIExtension的图片编辑业务模版。<br/>- appAccountAuthorization:应用账号授权扩展能力的ExtensionAbility,用于处理账号授权请求,比如账号登录授权。<br/>- autoFill/password:用于账号和密码自动填充业务的ExtensionAbility,支持数据的保存、填充能力。<br/>- hms/account:应用账号管理能力的ExtensionAbility。<br/>- sysDialog/atomicServicePanel:提供构建原子化服务服务面板的基础能力的ExtensionAbility,使用时基于UIExtensionAbility实现。<br/>- sysDialog/userAuth:本地用户鉴权的ExtensionAbility。<br/>- sysDialog/common:通用弹窗的ExtensionAbility。<br/>- sysDialog/power:关机重启弹窗的ExtensionAbility。<br/>- sysDialog/print:打印模态弹窗的ExtensionAbility。<br/>- sysDialog/meetimeCall:畅连通话的ExtensionAbility。<br/>- sysDialog/meetimeContact:畅连联系人的ExtensionAbility。<br/>- sysPicker/meetimeMessage:畅连消息的ExtensionAbility。<br/>- sysPicker/meetimeContact:畅连联系人列表的ExtensionAbility。<br/>- sysPicker/meetimeCallLog:畅连通话记录列表的ExtensionAbility。<br/>- sysPicker/share:系统分享的ExtensionAbility。<br/>- sysPicker/mediaControl:投播组件的ExtensionAbility。<br/>- sysPicker/photoPicker:三方应用通过对应的UIExtensionType拉起图库picker界面。<br/>- sysPicker/filePicker:文件下载弹窗的ExtensionAbility。<br/>- sysPicker/audioPicker:音频管理弹窗的ExtensionAbility。<br/>- sysPicker/photoEditor:图片编辑弹窗的ExtensionAbility。<br/>- sys/commonUI:非通用的ExtensionAbility,提供业务属性强相关的嵌入式显示或弹框。<br/>- autoFill/smart:用于情景化场景自动填充业务的ExtensionAbility,支持数据的保存、填充能力。<br/>- uiService:弹窗服务组件,在启动过程中会创建window,并支持双向通信。<br/>- statusBarView:一步直达的ExtensionAbility。<br/>- recentPhoto:最近照片推荐的ExtensionAbility。<br/>**说明:**<br/>其中service、adsService、sys/commonUI、fileAccess、sysDialog类型、sysPicker类型、dataShare类型和uiService类型,仅支持系统应用配置,三方应用配置不生效。 | 字符串 | 该标签不可缺省。 | 464e41f4b71Sopenharmony_ci| permissions | 标识当前ExtensionAbility组件自定义的权限信息。当其他应用访问该ExtensionAbility时,需要申请相应的权限信息。<br/>一个数组元素为一个权限名称。通常采用反向域名格式(最大255字节),取值为[系统预定义的权限](../security/AccessToken/permissions-for-all.md)。 | 字符串数组 | 该标签可缺省,缺省值为空。 | 465e41f4b71Sopenharmony_ci| readPermission | 标识读取当前ExtensionAbility组件数据所需的权限,取值为长度不超过255字节的字符串。仅当ExtensionAbility组件的type为dataShare时支持配置该标签。 | 字符串 | 该标签可缺省,缺省值为空。 | 466e41f4b71Sopenharmony_ci| writePermission | 标识向当前ExtensionAbility组件写数据所需的权限,取值为长度不超过255字节的字符串。仅当ExtensionAbility组件的type为dataShare时支持配置该标签。 | 字符串 | 该标签可缺省,缺省值为空。 | 467e41f4b71Sopenharmony_ci| uri | 标识当前ExtensionAbility组件提供的数据URI,取值为长度不超过255字节的字符数组,用反向域名的格式表示。<br/>**说明:**<br/>该标签在type为dataShare类型的ExtensionAbility时,不可缺省。 | 字符串 | 该标签可缺省,缺省值为空。 | 468e41f4b71Sopenharmony_ci|skills | 标识当前ExtensionAbility组件能够接收的[Want](../application-models/want-overview.md)的特征集。<br/>配置规则:entry包可以配置多个具有入口能力的skills标签(配置了ohos.want.action.home和entity.system.home)的ExtensionAbility,其中第一个配置了skills标签的ExtensionAbility中的label和icon作为服务或应用的label和icon。<br/>**说明:**<br/>服务的Feature包不能配置具有入口能力的skills标签。<br/>应用的Feature包可以配置具有入口能力的skills标签。 | 数组 | 该标签可缺省,缺省值为空。 | 469e41f4b71Sopenharmony_ci| [metadata](#metadata标签) | 标识当前ExtensionAbility组件的元信息。<br/>**说明:**<br/>该标签在type为form时,不可缺省,且必须存在一个name为ohos.extension.form的对象值,其对应的resource值不能缺省,为卡片的二级资源引用。 | 对象 | 该标签可缺省,缺省值为空。 | 470e41f4b71Sopenharmony_ci| exported | 标识当前ExtensionAbility组件是否可以被其他应用调用。<br/>- true:表示可以被其他应用调用。<br/>- false:表示不可以被其他应用调用,包括无法被aa工具命令拉起应用。 | 布尔值 | 该标签可缺省,缺省值为false。 | 471e41f4b71Sopenharmony_ci| extensionProcessMode | 标识当前ExtensionAbility组件的多进程实例模型,当前只对UIExtensionAbility以及从UIExtensionAbility扩展的ExtensionAbility生效。<br/>- instance:表示该ExtensionAbility每个实例一个进程。<br/>- type:表示该ExtensionAbility实例都运行在同一个进程里,与其他ExtensionAbility分离进程。<br/>- bundle:表示该ExtensionAbility实例都运行在应用统一进程里,与其他配置了bundle模型的ExtensionAbility共进程。<br>- runWithMainProcess:表示该ExtensionAbility和应用主进程共进程,只有一步直达的ExtensionAbility可以配置runWithMainProcess。 | 字符串 | 该标签可缺省,缺省值为空。 | 472e41f4b71Sopenharmony_ci| dataGroupIds | 标识当前ExtensionAbility组件的dataGroupId集合,暂不支持。如果当前ExtensionAbility组件所在的应用在应用市场申请的证书里groupIds也申请了某个dataGroupId,那么当前ExtensionAbility组件可以和应用共享这一个dataGroupId生成的目录,所以ExtensionAbility组件的dataGroupId需要是应用的证书中groupIds字段里配置的才能生效。 且该字段仅在当前ExtensionAbility组件存在独立的沙箱目录时生效。 | 字符串数组 | 该标签可缺省,缺省值为空。 | 473e41f4b71Sopenharmony_ci 474e41f4b71Sopenharmony_ciextensionAbilities示例: 475e41f4b71Sopenharmony_ci 476e41f4b71Sopenharmony_ci 477e41f4b71Sopenharmony_ci```json 478e41f4b71Sopenharmony_ci{ 479e41f4b71Sopenharmony_ci "extensionAbilities": [ 480e41f4b71Sopenharmony_ci { 481e41f4b71Sopenharmony_ci "name": "FormName", 482e41f4b71Sopenharmony_ci "srcEntry": "./form/MyForm.ts", 483e41f4b71Sopenharmony_ci "icon": "$media:icon", 484e41f4b71Sopenharmony_ci "label" : "$string:extension_name", 485e41f4b71Sopenharmony_ci "description": "$string:form_description", 486e41f4b71Sopenharmony_ci "type": "form", 487e41f4b71Sopenharmony_ci "permissions": ["ohos.abilitydemo.permission.PROVIDER"], 488e41f4b71Sopenharmony_ci "readPermission": "", 489e41f4b71Sopenharmony_ci "writePermission": "", 490e41f4b71Sopenharmony_ci "exported": true, 491e41f4b71Sopenharmony_ci "uri":"scheme://authority/path/query", 492e41f4b71Sopenharmony_ci "skills": [{ 493e41f4b71Sopenharmony_ci "actions": [], 494e41f4b71Sopenharmony_ci "entities": [], 495e41f4b71Sopenharmony_ci "uris": [], 496e41f4b71Sopenharmony_ci "permissions": [] 497e41f4b71Sopenharmony_ci }], 498e41f4b71Sopenharmony_ci "metadata": [ 499e41f4b71Sopenharmony_ci { 500e41f4b71Sopenharmony_ci "name": "ohos.extension.form", 501e41f4b71Sopenharmony_ci "resource": "$profile:form_config", 502e41f4b71Sopenharmony_ci } 503e41f4b71Sopenharmony_ci ], 504e41f4b71Sopenharmony_ci "extensionProcessMode": "instance", 505e41f4b71Sopenharmony_ci "dataGroupIds": [ 506e41f4b71Sopenharmony_ci "testGroupId1" 507e41f4b71Sopenharmony_ci ] 508e41f4b71Sopenharmony_ci } 509e41f4b71Sopenharmony_ci ] 510e41f4b71Sopenharmony_ci} 511e41f4b71Sopenharmony_ci``` 512e41f4b71Sopenharmony_ci 513e41f4b71Sopenharmony_ci## shortcuts标签 514e41f4b71Sopenharmony_ci 515e41f4b71Sopenharmony_cishortcuts标识应用的快捷方式信息。标签值为数组,包含四个子标签shortcutId、label、icon、wants。 516e41f4b71Sopenharmony_ci 517e41f4b71Sopenharmony_cimetadata中指定shortcut信息,其中: 518e41f4b71Sopenharmony_ci 519e41f4b71Sopenharmony_ci- name:指定shortcuts的名称,使用ohos.ability.shortcuts作为shortcuts信息的标识。 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ci- resource:指定shortcuts信息的资源位置。 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_ci**表11** shortcuts标签说明 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 类型 | 是否可缺省 | 526e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 527e41f4b71Sopenharmony_ci| shortcutId | 标识快捷方式的ID,取值为长度不超过63字节的字符串。 | 字符串 | 该标签不可缺省。 | 528e41f4b71Sopenharmony_ci| label | 标识快捷方式的标签信息,即快捷方式对外显示的文字描述信息。取值为长度不超过255字节的字符串,可以是描述性内容,也可以是标识label的资源索引。 | 字符串 | 该标签可缺省,缺省值为空。 | 529e41f4b71Sopenharmony_ci| icon | 标识快捷方式的图标,取值为资源文件的索引。 | 字符串 | 该标签可缺省,缺省值为空。 | 530e41f4b71Sopenharmony_ci| [wants](#wants标签) | 标识快捷方式内定义的目标wants信息集合,在调用launcherBundleManager的startShortcut接口时,会拉起wants标签里的第一个目标组件,推荐只配置一个wants元素。 | 对象 | 该标签可缺省,缺省为空。 | 531e41f4b71Sopenharmony_ci 532e41f4b71Sopenharmony_ci 533e41f4b71Sopenharmony_ci1. 在/resources/base/profile/目录下配置shortcuts_config.json配置文件。 534e41f4b71Sopenharmony_ci 535e41f4b71Sopenharmony_ci ```json 536e41f4b71Sopenharmony_ci { 537e41f4b71Sopenharmony_ci "shortcuts": [ 538e41f4b71Sopenharmony_ci { 539e41f4b71Sopenharmony_ci "shortcutId": "id_test1", 540e41f4b71Sopenharmony_ci "label": "$string:shortcut", 541e41f4b71Sopenharmony_ci "icon": "$media:aa_icon", 542e41f4b71Sopenharmony_ci "wants": [ 543e41f4b71Sopenharmony_ci { 544e41f4b71Sopenharmony_ci "bundleName": "com.ohos.hello", 545e41f4b71Sopenharmony_ci "moduleName": "entry", 546e41f4b71Sopenharmony_ci "abilityName": "EntryAbility", 547e41f4b71Sopenharmony_ci "parameters": { 548e41f4b71Sopenharmony_ci "testKey": "testValue" 549e41f4b71Sopenharmony_ci } 550e41f4b71Sopenharmony_ci } 551e41f4b71Sopenharmony_ci ] 552e41f4b71Sopenharmony_ci } 553e41f4b71Sopenharmony_ci ] 554e41f4b71Sopenharmony_ci } 555e41f4b71Sopenharmony_ci ``` 556e41f4b71Sopenharmony_ci 557e41f4b71Sopenharmony_ci2. 在module.json5配置文件的abilities标签中,针对需要添加快捷方式的UIAbility进行配置metadata标签,使shortcut配置文件对该UIAbility生效。 558e41f4b71Sopenharmony_ci 559e41f4b71Sopenharmony_ci ```json 560e41f4b71Sopenharmony_ci { 561e41f4b71Sopenharmony_ci "module": { 562e41f4b71Sopenharmony_ci // ... 563e41f4b71Sopenharmony_ci "abilities": [ 564e41f4b71Sopenharmony_ci { 565e41f4b71Sopenharmony_ci "name": "EntryAbility", 566e41f4b71Sopenharmony_ci "srcEntry": "./ets/entryability/EntryAbility.ets", 567e41f4b71Sopenharmony_ci // ... 568e41f4b71Sopenharmony_ci "skills": [ 569e41f4b71Sopenharmony_ci { 570e41f4b71Sopenharmony_ci "entities": [ 571e41f4b71Sopenharmony_ci "entity.system.home" 572e41f4b71Sopenharmony_ci ], 573e41f4b71Sopenharmony_ci "actions": [ 574e41f4b71Sopenharmony_ci "ohos.want.action.home" 575e41f4b71Sopenharmony_ci ] 576e41f4b71Sopenharmony_ci } 577e41f4b71Sopenharmony_ci ], 578e41f4b71Sopenharmony_ci "metadata": [ 579e41f4b71Sopenharmony_ci { 580e41f4b71Sopenharmony_ci "name": "ohos.ability.shortcuts", 581e41f4b71Sopenharmony_ci "resource": "$profile:shortcuts_config" 582e41f4b71Sopenharmony_ci } 583e41f4b71Sopenharmony_ci ] 584e41f4b71Sopenharmony_ci } 585e41f4b71Sopenharmony_ci ] 586e41f4b71Sopenharmony_ci } 587e41f4b71Sopenharmony_ci } 588e41f4b71Sopenharmony_ci ``` 589e41f4b71Sopenharmony_ci### wants标签 590e41f4b71Sopenharmony_ci 591e41f4b71Sopenharmony_ci此标签用于标识快捷方式内定义的目标wants信息集合。 592e41f4b71Sopenharmony_ci 593e41f4b71Sopenharmony_ci**表11-1** wants标签说明 594e41f4b71Sopenharmony_ci 595e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 类型 | 是否可缺省 | 596e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 597e41f4b71Sopenharmony_ci| bundleName | 表示快捷方式的目标包名。 | 字符串 | 该标签不可缺省。 | 598e41f4b71Sopenharmony_ci| moduleName | 表示快捷方式的目标模块名。 | 字符串 | 该标签可缺省。 | 599e41f4b71Sopenharmony_ci| abilityName| 表示快捷方式的目标组件名。 | 字符串 | 该标签不可缺省。 | 600e41f4b71Sopenharmony_ci| parameters | 表示拉起快捷方式时的自定义数据,仅支持配置字符串类型的数据。其中键值均最大支持1024长度的字符串。 | 对象 | 该标签可缺省。 | 601e41f4b71Sopenharmony_ci 602e41f4b71Sopenharmony_cidata标签示例: 603e41f4b71Sopenharmony_ci 604e41f4b71Sopenharmony_ci```json 605e41f4b71Sopenharmony_ci{ 606e41f4b71Sopenharmony_ci "wants": [ 607e41f4b71Sopenharmony_ci { 608e41f4b71Sopenharmony_ci "bundleName": "com.ohos.hello", 609e41f4b71Sopenharmony_ci "moduleName": "entry", 610e41f4b71Sopenharmony_ci "abilityName": "EntryAbility", 611e41f4b71Sopenharmony_ci "parameters": { 612e41f4b71Sopenharmony_ci "testKey": "testValue" 613e41f4b71Sopenharmony_ci } 614e41f4b71Sopenharmony_ci } 615e41f4b71Sopenharmony_ci ] 616e41f4b71Sopenharmony_ci} 617e41f4b71Sopenharmony_ci``` 618e41f4b71Sopenharmony_ci 619e41f4b71Sopenharmony_ci## distributionFilter标签 620e41f4b71Sopenharmony_ci 621e41f4b71Sopenharmony_ci该标签用于定义HAP对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。 622e41f4b71Sopenharmony_ci 623e41f4b71Sopenharmony_ci> **说明:** 624e41f4b71Sopenharmony_ci> 该标签从API10及以后版本开始生效,API9及以前版本使用distroFilter标签。 625e41f4b71Sopenharmony_ci 626e41f4b71Sopenharmony_ci- **适用场景:** 当一个工程中存在多个Entry,且多个Entry配置的deviceTypes存在交集时,则需要通过该标签进行区分。比如下面的两个Entry都支持tablet类型,就需要通过该标签进行区分。 627e41f4b71Sopenharmony_ci ```json 628e41f4b71Sopenharmony_ci // entry1支持的设备类型 629e41f4b71Sopenharmony_ci { 630e41f4b71Sopenharmony_ci "module": { 631e41f4b71Sopenharmony_ci "name": "entry1", 632e41f4b71Sopenharmony_ci "type": "entry", 633e41f4b71Sopenharmony_ci "deviceTypes" : [ 634e41f4b71Sopenharmony_ci "tv", 635e41f4b71Sopenharmony_ci "tablet" 636e41f4b71Sopenharmony_ci ] 637e41f4b71Sopenharmony_ci } 638e41f4b71Sopenharmony_ci } 639e41f4b71Sopenharmony_ci ``` 640e41f4b71Sopenharmony_ci ```json 641e41f4b71Sopenharmony_ci // entry2支持的设备类型 642e41f4b71Sopenharmony_ci { 643e41f4b71Sopenharmony_ci "module": { 644e41f4b71Sopenharmony_ci "name": "entry2", 645e41f4b71Sopenharmony_ci "type": "entry", 646e41f4b71Sopenharmony_ci "deviceTypes" : [ 647e41f4b71Sopenharmony_ci "car", 648e41f4b71Sopenharmony_ci "tablet" 649e41f4b71Sopenharmony_ci ] 650e41f4b71Sopenharmony_ci } 651e41f4b71Sopenharmony_ci } 652e41f4b71Sopenharmony_ci ``` 653e41f4b71Sopenharmony_ci 654e41f4b71Sopenharmony_ci- **配置规则:** 该标签支持配置四个属性,包括屏幕形状([screenShape](#screenshape标签))、窗口分辨率([screenWindow](#screenwindow标签))、屏幕像素密度([screenDensity](#screendensity标签) )、设备所在国家与地区([countryCode](#countrycode标签)),详见下表。 655e41f4b71Sopenharmony_ci 656e41f4b71Sopenharmony_ci 在分发应用包时,通过deviceTypes与这四个属性的匹配关系,唯一确定一个用于分发到设备的HAP。 657e41f4b71Sopenharmony_ci 658e41f4b71Sopenharmony_ci * 如果需要配置该标签,则至少包含一个属性。 659e41f4b71Sopenharmony_ci * 如果一个Entry中配置了任意一个或多个属性,则其他Entry也必须包含相同的属性。 660e41f4b71Sopenharmony_ci * screenShape和screenWindow属性仅用于轻量级智能穿戴设备。 661e41f4b71Sopenharmony_ci 662e41f4b71Sopenharmony_ci- **配置方式:** 该标签需要配置在/resources/base/profile资源目录下,并在metadata的resource字段中引用。 663e41f4b71Sopenharmony_ci 664e41f4b71Sopenharmony_ci 665e41f4b71Sopenharmony_ci**表12** distributionFilter标签配置说明 666e41f4b71Sopenharmony_ci 667e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 668e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 669e41f4b71Sopenharmony_ci| [screenShape](#screenshape标签) | 标识屏幕形状的支持策略。 | 对象数组 | 该标签可缺省,缺省值为空。 | 670e41f4b71Sopenharmony_ci| [screenWindow](#screenwindow标签) | 标识应用运行时的窗口分辨率的支持策略。| 对象数组 | 该标签可缺省,缺省值为空。 | 671e41f4b71Sopenharmony_ci| [screenDensity](#screendensity标签) | 标识屏幕的像素密度(dpi:Dot Per Inch)的支持策略。 | 对象数组 | 该标签可缺省,缺省值为空。 | 672e41f4b71Sopenharmony_ci| [countryCode](#countrycode标签) | 标识国家与地区的支持策略,取值参考ISO-3166-1标准。支持多个国家和地区枚举定义。 | 对象数组 | 该标签可缺省,缺省值为空。 | 673e41f4b71Sopenharmony_ci 674e41f4b71Sopenharmony_ci### screenShape标签 675e41f4b71Sopenharmony_ci 676e41f4b71Sopenharmony_ci**表13** screenShape标签说明 677e41f4b71Sopenharmony_ci 678e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 679e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 680e41f4b71Sopenharmony_ci| policy | 标识条件属性的过滤规则。<br/>- exclude:表示需要排除的value属性。<br/>- include:表示需要包含的value属性。 | 字符串 | 该标签不可缺省。 | 681e41f4b71Sopenharmony_ci| value | 支持的取值为circle(圆形)、rect(矩形)。例如,针对智能穿戴设备,可为圆形表盘和矩形表盘分别提供不同的HAP。 | 字符串数组 | 该标签不可缺省。 | 682e41f4b71Sopenharmony_ci 683e41f4b71Sopenharmony_ci### screenWindow标签 684e41f4b71Sopenharmony_ci 685e41f4b71Sopenharmony_ci**表14** screenWindow标签说明 686e41f4b71Sopenharmony_ci 687e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 688e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 689e41f4b71Sopenharmony_ci| policy | 标识条件属性的过滤规则。当前取值仅支持“include”。<br/>- include:表示需要包含的value属性。 | 字符串 | 该标签不可缺省。 | 690e41f4b71Sopenharmony_ci| value | 单个字符串的取值格式为“宽 \* 高”,取值为整数像素值,例如“454 \* 454”。 | 字符串数组 | 该标签不可缺省。 | 691e41f4b71Sopenharmony_ci 692e41f4b71Sopenharmony_ci### screenDensity标签 693e41f4b71Sopenharmony_ci 694e41f4b71Sopenharmony_ci**表15** screenDensity标签说明 695e41f4b71Sopenharmony_ci 696e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 697e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 698e41f4b71Sopenharmony_ci| policy | 标识条件属性的过滤规则。<br/>- exclude:表示需要排除的value属性。<br/>- include:表示需要包含的value属性。 | 字符串 | 该标签不可缺省。 | 699e41f4b71Sopenharmony_ci| value | 标识屏幕的像素密度(dpi :Dot Per Inch)。支持的取值如下:<br/>- sdpi:表示小规模的屏幕密度(Small-scale Dots per Inch),适用于dpi取值为(0,120]的设备。<br/>- mdpi:表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120,160]的设备。<br/>- ldpi:表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160,240]的设备。<br/>- xldpi:表示大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240,320]的设备。<br/>- xxldpi:表示大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320,480]的设备。<br/>- xxxldpi:表示大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480, 640]的设备。 | 字符串数组 | 该标签不可缺省。 | 700e41f4b71Sopenharmony_ci 701e41f4b71Sopenharmony_ci### countryCode标签 702e41f4b71Sopenharmony_ci 703e41f4b71Sopenharmony_ci**表16** countryCode标签说明 704e41f4b71Sopenharmony_ci 705e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 706e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 707e41f4b71Sopenharmony_ci| policy | 标识条件属性的过滤规则。<br/>- exclude:表示需要排除的value属性。<br/>- include:表示需要包含的value属性。 | 字符串 | 该标签不可缺省。 | 708e41f4b71Sopenharmony_ci| value | 标识应用需要分发的国家地区码。 | 字符串数组 | 该标签不可缺省。 | 709e41f4b71Sopenharmony_ci 710e41f4b71Sopenharmony_ci 711e41f4b71Sopenharmony_ci示例如下: 712e41f4b71Sopenharmony_ci 713e41f4b71Sopenharmony_ci1. 在开发视图的resources/base/profile下面定义配置文件distributionFilter_config.json,文件名可以自定义。 714e41f4b71Sopenharmony_ci ```json 715e41f4b71Sopenharmony_ci { 716e41f4b71Sopenharmony_ci "distributionFilter": { 717e41f4b71Sopenharmony_ci "screenShape": { 718e41f4b71Sopenharmony_ci "policy": "include", 719e41f4b71Sopenharmony_ci "value": [ 720e41f4b71Sopenharmony_ci "circle", 721e41f4b71Sopenharmony_ci "rect" 722e41f4b71Sopenharmony_ci ] 723e41f4b71Sopenharmony_ci }, 724e41f4b71Sopenharmony_ci "screenWindow": { 725e41f4b71Sopenharmony_ci "policy": "include", 726e41f4b71Sopenharmony_ci "value": [ 727e41f4b71Sopenharmony_ci "454*454", 728e41f4b71Sopenharmony_ci "466*466" 729e41f4b71Sopenharmony_ci ] 730e41f4b71Sopenharmony_ci }, 731e41f4b71Sopenharmony_ci "screenDensity": { 732e41f4b71Sopenharmony_ci "policy": "exclude", 733e41f4b71Sopenharmony_ci "value": [ 734e41f4b71Sopenharmony_ci "ldpi", 735e41f4b71Sopenharmony_ci "xldpi" 736e41f4b71Sopenharmony_ci ] 737e41f4b71Sopenharmony_ci }, 738e41f4b71Sopenharmony_ci "countryCode": { // 支持在中国分发 739e41f4b71Sopenharmony_ci "policy": "include", 740e41f4b71Sopenharmony_ci "value": [ 741e41f4b71Sopenharmony_ci "CN" 742e41f4b71Sopenharmony_ci ] 743e41f4b71Sopenharmony_ci } 744e41f4b71Sopenharmony_ci } 745e41f4b71Sopenharmony_ci } 746e41f4b71Sopenharmony_ci ``` 747e41f4b71Sopenharmony_ci 748e41f4b71Sopenharmony_ci 749e41f4b71Sopenharmony_ci2. 在module.json5配置文件的module标签中定义metadata信息。 750e41f4b71Sopenharmony_ci 751e41f4b71Sopenharmony_ci 752e41f4b71Sopenharmony_ci ```json 753e41f4b71Sopenharmony_ci { 754e41f4b71Sopenharmony_ci "module": { 755e41f4b71Sopenharmony_ci // ... 756e41f4b71Sopenharmony_ci "metadata": [ 757e41f4b71Sopenharmony_ci { 758e41f4b71Sopenharmony_ci "name": "ohos.module.distribution", 759e41f4b71Sopenharmony_ci "resource": "$profile:distributionFilter_config", 760e41f4b71Sopenharmony_ci } 761e41f4b71Sopenharmony_ci ] 762e41f4b71Sopenharmony_ci } 763e41f4b71Sopenharmony_ci } 764e41f4b71Sopenharmony_ci ``` 765e41f4b71Sopenharmony_ci 766e41f4b71Sopenharmony_ci 767e41f4b71Sopenharmony_ci## testRunner标签 768e41f4b71Sopenharmony_ci 769e41f4b71Sopenharmony_ci此标签用于支持对测试框架的配置。 770e41f4b71Sopenharmony_ci 771e41f4b71Sopenharmony_ci**表17** testRunner标签说明 772e41f4b71Sopenharmony_ci 773e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 774e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 775e41f4b71Sopenharmony_ci| name | 标识测试框架对象名称,取值为长度不超过255字节的字符串。 | 字符串 | 不可缺省。 | 776e41f4b71Sopenharmony_ci| srcPath | 标识测试框架代码路径,取值为长度不超过255字节的字符串。 | 字符串 | 不可缺省。 | 777e41f4b71Sopenharmony_ci 778e41f4b71Sopenharmony_citestRunner标签示例: 779e41f4b71Sopenharmony_ci 780e41f4b71Sopenharmony_ci 781e41f4b71Sopenharmony_ci```json 782e41f4b71Sopenharmony_ci{ 783e41f4b71Sopenharmony_ci "module": { 784e41f4b71Sopenharmony_ci // ... 785e41f4b71Sopenharmony_ci "testRunner": { 786e41f4b71Sopenharmony_ci "name": "myTestRunnerName", 787e41f4b71Sopenharmony_ci "srcPath": "etc/test/TestRunner.ts" 788e41f4b71Sopenharmony_ci } 789e41f4b71Sopenharmony_ci } 790e41f4b71Sopenharmony_ci} 791e41f4b71Sopenharmony_ci``` 792e41f4b71Sopenharmony_ci 793e41f4b71Sopenharmony_ci## atomicService标签 794e41f4b71Sopenharmony_ci 795e41f4b71Sopenharmony_ci此标签用于支持对原子化服务的配置。此标签仅在app.json中bundleType指定为atomicService时使能。 796e41f4b71Sopenharmony_ci 797e41f4b71Sopenharmony_ci**表18** atomicService标签说明 798e41f4b71Sopenharmony_ci 799e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 800e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 801e41f4b71Sopenharmony_ci| preloads | 标识原子化服务中预加载列表。 | 对象数组 | 该标签可缺省,缺省值为空。 | 802e41f4b71Sopenharmony_ci 803e41f4b71Sopenharmony_ci 804e41f4b71Sopenharmony_ci**表19** preloads标签说明 805e41f4b71Sopenharmony_ci 806e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 807e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 808e41f4b71Sopenharmony_ci| moduleName | 标识原子化服务中当前模块被加载时,需预加载的模块名。不能配置自身modulename,且必须有对应的模块,取值为长度不超过31字节的字符串。 | 字符串 | 该标签不可缺省。 | 809e41f4b71Sopenharmony_ci 810e41f4b71Sopenharmony_ci 811e41f4b71Sopenharmony_ciatomicService标签示例: 812e41f4b71Sopenharmony_ci 813e41f4b71Sopenharmony_ci```json 814e41f4b71Sopenharmony_ci{ 815e41f4b71Sopenharmony_ci "module": { 816e41f4b71Sopenharmony_ci "atomicService": { 817e41f4b71Sopenharmony_ci "preloads":[ 818e41f4b71Sopenharmony_ci { 819e41f4b71Sopenharmony_ci "moduleName":"feature" 820e41f4b71Sopenharmony_ci } 821e41f4b71Sopenharmony_ci ] 822e41f4b71Sopenharmony_ci } 823e41f4b71Sopenharmony_ci } 824e41f4b71Sopenharmony_ci} 825e41f4b71Sopenharmony_ci``` 826e41f4b71Sopenharmony_ci 827e41f4b71Sopenharmony_ci## dependencies标签 828e41f4b71Sopenharmony_ci 829e41f4b71Sopenharmony_ci此标签标识模块运行时依赖的共享库列表。 830e41f4b71Sopenharmony_ci 831e41f4b71Sopenharmony_ci**表20** dependencies标签说明 832e41f4b71Sopenharmony_ci 833e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 834e41f4b71Sopenharmony_ci| ----------- | ------------------------------ | -------- | ---------- | 835e41f4b71Sopenharmony_ci| bundleName | 标识当前模块依赖的共享包包名。取值为长度7~128字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 836e41f4b71Sopenharmony_ci| moduleName | 标识当前模块依赖的共享包模块名。取值为长度不超过31字节的字符串。 | 字符串 | 该标签不可缺省。 | 837e41f4b71Sopenharmony_ci| versionCode | 标识当前共享包的版本号。取值范围为0~2147483647。 | 数值 | 该标签可缺省,缺省值为空。 | 838e41f4b71Sopenharmony_ci 839e41f4b71Sopenharmony_cidependencies标签示例: 840e41f4b71Sopenharmony_ci 841e41f4b71Sopenharmony_ci```json 842e41f4b71Sopenharmony_ci{ 843e41f4b71Sopenharmony_ci "module": { 844e41f4b71Sopenharmony_ci "dependencies": [ 845e41f4b71Sopenharmony_ci { 846e41f4b71Sopenharmony_ci "bundleName":"com.share.library", 847e41f4b71Sopenharmony_ci "moduleName": "library", 848e41f4b71Sopenharmony_ci "versionCode": 10001 849e41f4b71Sopenharmony_ci } 850e41f4b71Sopenharmony_ci ] 851e41f4b71Sopenharmony_ci } 852e41f4b71Sopenharmony_ci} 853e41f4b71Sopenharmony_ci``` 854e41f4b71Sopenharmony_ci 855e41f4b71Sopenharmony_ci## proxyData标签 856e41f4b71Sopenharmony_ci 857e41f4b71Sopenharmony_ci此标签标识模块提供的数据代理列表,仅限entry和feature配置。 858e41f4b71Sopenharmony_ci 859e41f4b71Sopenharmony_ci**表21** proxyData标签说明 860e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 861e41f4b71Sopenharmony_ci| ----------- | ------------------------------ | -------- | ---------- | 862e41f4b71Sopenharmony_ci| uri | 标识用于访问该数据代理的URI,不同的数据代理配置的URI不可重复,且需要满足`datashareproxy://当前应用包名/xxx`的格式。取值为长度不超过255字节的字符串。 | 字符串 | 该标签不可缺省。 | 863e41f4b71Sopenharmony_ci| requiredReadPermission | 标识从该数据代理中读取数据所需要的权限,若不配置,则其他应用无法使用该代理。非系统应用配置的权限的等级需为system_basic或system_core,系统应用配置的权限的等级没有限制。权限等级可以参考[权限列表](../security/AccessToken/permissions-for-all.md)。取值为长度不超过255字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 864e41f4b71Sopenharmony_ci| requiredWritePermission | 标识向该数据代理中写入数据所需要的权限,若不配置,则其他应用无法使用该代理。非系统应用配置的权限的等级需为system_basic或system_core,系统应用配置的权限的等级没有限制。权限等级可以参考[权限列表](../security/AccessToken/permissions-for-all.md)。取值为长度不超过255字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 865e41f4b71Sopenharmony_ci| [metadata](#metadata标签) | 标识该数据代理的元信息,只支持配置name和resource字段。 | 对象 | 该标签可缺省,缺省值为空。 | 866e41f4b71Sopenharmony_ci 867e41f4b71Sopenharmony_ciproxyData标签示例: 868e41f4b71Sopenharmony_ci 869e41f4b71Sopenharmony_ci```json 870e41f4b71Sopenharmony_ci{ 871e41f4b71Sopenharmony_ci "module": { 872e41f4b71Sopenharmony_ci "proxyData": [ 873e41f4b71Sopenharmony_ci { 874e41f4b71Sopenharmony_ci "uri":"datashareproxy://com.ohos.datashare/event/Meeting", 875e41f4b71Sopenharmony_ci "requiredReadPermission": "ohos.permission.GET_BUNDLE_INFO", 876e41f4b71Sopenharmony_ci "requiredWritePermission": "ohos.permission.GET_BUNDLE_INFO", 877e41f4b71Sopenharmony_ci "metadata": { 878e41f4b71Sopenharmony_ci "name": "datashare_metadata", 879e41f4b71Sopenharmony_ci "resource": "$profile:datashare" 880e41f4b71Sopenharmony_ci } 881e41f4b71Sopenharmony_ci } 882e41f4b71Sopenharmony_ci ] 883e41f4b71Sopenharmony_ci } 884e41f4b71Sopenharmony_ci} 885e41f4b71Sopenharmony_ci``` 886e41f4b71Sopenharmony_ci 887e41f4b71Sopenharmony_ci## routerMap标签 888e41f4b71Sopenharmony_ci 889e41f4b71Sopenharmony_ci此标签标识模块配置的路由表的路径。 890e41f4b71Sopenharmony_ci 891e41f4b71Sopenharmony_cirouterMap配置文件描述模块的路由表信息,routerMap标签值为数组类型。 892e41f4b71Sopenharmony_ci 893e41f4b71Sopenharmony_ci**表22** routerMap标签说明 894e41f4b71Sopenharmony_ci 895e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 896e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 897e41f4b71Sopenharmony_ci| name | 标识跳转页面的名称。取值为长度不超过1023字节的字符串。 | 字符串 | 该标签不可缺省。 | 898e41f4b71Sopenharmony_ci| pageSourceFile| 标识页面在模块内的路径。取值为长度不超过255字节的字符串。 | 字符串 | 该标签不可缺省。 | 899e41f4b71Sopenharmony_ci| buildFunction | 标识被@Builder修饰的函数,该函数描述页面的UI。取值为长度不超过1023字节的字符串。 | 字符串 | 该标签不可缺省。 | 900e41f4b71Sopenharmony_ci| [data](#data标签) | 标识字符串类型的自定义数据。 每个自定义数据字符串取值不超过128字节。 | 对象 | 该标签可缺省,缺省值为空。 | 901e41f4b71Sopenharmony_ci| [customData](#customdata标签) | 标识任意类型的自定义数据,总长度不超过4096。 | 对象 | 该标签可缺省,缺省值为空。 | 902e41f4b71Sopenharmony_ci 903e41f4b71Sopenharmony_ci示例如下: 904e41f4b71Sopenharmony_ci 905e41f4b71Sopenharmony_ci1. 在开发视图的resources/base/profile下面定义配置文件,文件名可以自定义,例如:router_map.json。 906e41f4b71Sopenharmony_ci 907e41f4b71Sopenharmony_ci ```json 908e41f4b71Sopenharmony_ci { 909e41f4b71Sopenharmony_ci "routerMap": [ 910e41f4b71Sopenharmony_ci { 911e41f4b71Sopenharmony_ci "name": "DynamicPage1", 912e41f4b71Sopenharmony_ci "pageSourceFile": "src/main/ets/pages/pageOne.ets", 913e41f4b71Sopenharmony_ci "buildFunction": "myFunction", 914e41f4b71Sopenharmony_ci "customData": { 915e41f4b71Sopenharmony_ci "stringKey": "data1", 916e41f4b71Sopenharmony_ci "numberKey": 123, 917e41f4b71Sopenharmony_ci "booleanKey": true, 918e41f4b71Sopenharmony_ci "objectKey": { 919e41f4b71Sopenharmony_ci "name": "test" 920e41f4b71Sopenharmony_ci }, 921e41f4b71Sopenharmony_ci "arrayKey": [ 922e41f4b71Sopenharmony_ci { 923e41f4b71Sopenharmony_ci "id": 123 924e41f4b71Sopenharmony_ci } 925e41f4b71Sopenharmony_ci ] 926e41f4b71Sopenharmony_ci } 927e41f4b71Sopenharmony_ci }, 928e41f4b71Sopenharmony_ci { 929e41f4b71Sopenharmony_ci "name": "DynamicPage2", 930e41f4b71Sopenharmony_ci "pageSourceFile": "src/main/ets/pages/pageTwo.ets", 931e41f4b71Sopenharmony_ci "buildFunction": "myBuilder", 932e41f4b71Sopenharmony_ci "data": { 933e41f4b71Sopenharmony_ci "key1": "data1", 934e41f4b71Sopenharmony_ci "key2": "data2" 935e41f4b71Sopenharmony_ci } 936e41f4b71Sopenharmony_ci } 937e41f4b71Sopenharmony_ci ] 938e41f4b71Sopenharmony_ci } 939e41f4b71Sopenharmony_ci ``` 940e41f4b71Sopenharmony_ci 941e41f4b71Sopenharmony_ci2. 在module.json5配置文件的module标签中定义`routerMap`字段,指向定义的路由表配置文件,例如:`"routerMap": "$profile:router_map"`。 942e41f4b71Sopenharmony_ci 943e41f4b71Sopenharmony_ci### data标签 944e41f4b71Sopenharmony_ci 945e41f4b71Sopenharmony_ci此标签用于支持在路由表中配置自定义的字符串数据。 946e41f4b71Sopenharmony_ci 947e41f4b71Sopenharmony_cidata标签示例: 948e41f4b71Sopenharmony_ci 949e41f4b71Sopenharmony_ci```json 950e41f4b71Sopenharmony_ci{ 951e41f4b71Sopenharmony_ci "routerMap": [ 952e41f4b71Sopenharmony_ci { 953e41f4b71Sopenharmony_ci "name": "DynamicPage", 954e41f4b71Sopenharmony_ci "pageSourceFile": "src/main/ets/pages/pageOne.ets", 955e41f4b71Sopenharmony_ci "buildFunction": "myBuilder", 956e41f4b71Sopenharmony_ci "data": { 957e41f4b71Sopenharmony_ci "key1": "data1", 958e41f4b71Sopenharmony_ci "key2": "data2" 959e41f4b71Sopenharmony_ci } 960e41f4b71Sopenharmony_ci } 961e41f4b71Sopenharmony_ci ] 962e41f4b71Sopenharmony_ci} 963e41f4b71Sopenharmony_ci``` 964e41f4b71Sopenharmony_ci 965e41f4b71Sopenharmony_ci### customData标签 966e41f4b71Sopenharmony_ci 967e41f4b71Sopenharmony_ci此标签用于支持在路由表中配置自定义数据。 968e41f4b71Sopenharmony_cicustomData对象内部,可以填入任意类型的自定义数据。 969e41f4b71Sopenharmony_ci 970e41f4b71Sopenharmony_cicustomData标签示例: 971e41f4b71Sopenharmony_ci 972e41f4b71Sopenharmony_ci```json 973e41f4b71Sopenharmony_ci{ 974e41f4b71Sopenharmony_ci "routerMap": [ 975e41f4b71Sopenharmony_ci { 976e41f4b71Sopenharmony_ci "name": "DynamicPage", 977e41f4b71Sopenharmony_ci "pageSourceFile": "src/main/ets/pages/pageOne.ets", 978e41f4b71Sopenharmony_ci "buildFunction": "myBuilder", 979e41f4b71Sopenharmony_ci "customData": { 980e41f4b71Sopenharmony_ci "stringKey": "data1", 981e41f4b71Sopenharmony_ci "numberKey": 123, 982e41f4b71Sopenharmony_ci "booleanKey": true, 983e41f4b71Sopenharmony_ci "objectKey": { 984e41f4b71Sopenharmony_ci "name": "test" 985e41f4b71Sopenharmony_ci }, 986e41f4b71Sopenharmony_ci "arrayKey": [ 987e41f4b71Sopenharmony_ci { 988e41f4b71Sopenharmony_ci "id": 123 989e41f4b71Sopenharmony_ci } 990e41f4b71Sopenharmony_ci ] 991e41f4b71Sopenharmony_ci } 992e41f4b71Sopenharmony_ci } 993e41f4b71Sopenharmony_ci ] 994e41f4b71Sopenharmony_ci} 995e41f4b71Sopenharmony_ci``` 996e41f4b71Sopenharmony_ci 997e41f4b71Sopenharmony_ci## appEnvironments标签 998e41f4b71Sopenharmony_ci 999e41f4b71Sopenharmony_ci此标签标识模块配置的应用环境变量。 1000e41f4b71Sopenharmony_ci 1001e41f4b71Sopenharmony_ci**表23** appEnvironments标签说明 1002e41f4b71Sopenharmony_ci 1003e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 1004e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 1005e41f4b71Sopenharmony_ci| name | 标识环境变量的变量名称。取值为长度不超过4096字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 1006e41f4b71Sopenharmony_ci| value | 标识环境变量的值。取值为长度不超过4096字节的字符串。 | 字符串 | 该标签可缺省,缺省值为空。 | 1007e41f4b71Sopenharmony_ci 1008e41f4b71Sopenharmony_ciappEnvironments标签示例: 1009e41f4b71Sopenharmony_ci 1010e41f4b71Sopenharmony_ci```json 1011e41f4b71Sopenharmony_ci{ 1012e41f4b71Sopenharmony_ci "module": { 1013e41f4b71Sopenharmony_ci "appEnvironments": [ 1014e41f4b71Sopenharmony_ci { 1015e41f4b71Sopenharmony_ci "name":"name1", 1016e41f4b71Sopenharmony_ci "value": "value1" 1017e41f4b71Sopenharmony_ci } 1018e41f4b71Sopenharmony_ci ] 1019e41f4b71Sopenharmony_ci } 1020e41f4b71Sopenharmony_ci} 1021e41f4b71Sopenharmony_ci``` 1022e41f4b71Sopenharmony_ci 1023e41f4b71Sopenharmony_ci## definePermissions标签 1024e41f4b71Sopenharmony_ci 1025e41f4b71Sopenharmony_ci该标签仅支持系统资源hap定义权限,不支持应用自定义权限。权限定义方式参见[系统资源权限定义](https://gitee.com/openharmony/utils_system_resources/blob/master/systemres/main/config.json)。 1026e41f4b71Sopenharmony_ci 1027e41f4b71Sopenharmony_ci**表24** definePermissions标签说明 1028e41f4b71Sopenharmony_ci 1029e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 1030e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 1031e41f4b71Sopenharmony_ci| name | 标识权限的名称,该标签最大长度为255字节。 | 字符串 | 不可缺省。 | 1032e41f4b71Sopenharmony_ci| grantMode | 标识权限的授予方式,支持如下两种授予模式如下:<br/>- system_grant:安装后系统自动授予该权限。<br/>- user_grant:使用时动态申请,用户授权后才可使用。 | 字符串 | 可缺省,缺省值为system_grant。 | 1033e41f4b71Sopenharmony_ci| availableLevel | 标识权限限制类别,可选值如下:<br/>- system_core:系统核心权限。<br/>- system_basic:系统基础权限。<br/>- normal:普通权限。所有应用允许申请的权限。 | 字符串 | 可缺省,缺省值为normal。 | 1034e41f4b71Sopenharmony_ci| provisionEnable | 标识权限是否支持证书方式申请权限,包括高级别的权限。配置为true标识开发者可以通过provision方式申请权限。 | 布尔值 | 可缺省,缺省值为true。 | 1035e41f4b71Sopenharmony_ci| distributedSceneEnabled | 标识权限是否支持分布式场景下使用该权限。 | 布尔值 | 可缺省,缺省值为false。 | 1036e41f4b71Sopenharmony_ci| label | 标识权限的简短描述,配置为对描述内容的资源索引。 | 字符串 | 可缺省,缺省值为空。 | 1037e41f4b71Sopenharmony_ci| description | 标识权限的详细描述,可以是字符串,或者是对描述内容的资源索引。 | 字符串 | 可缺省,缺省值为空。 | 1038e41f4b71Sopenharmony_ci 1039e41f4b71Sopenharmony_cidefinePermissions标签示例: 1040e41f4b71Sopenharmony_ci 1041e41f4b71Sopenharmony_ci```json 1042e41f4b71Sopenharmony_ci{ 1043e41f4b71Sopenharmony_ci "module" : { 1044e41f4b71Sopenharmony_ci "definePermissions": [ 1045e41f4b71Sopenharmony_ci { 1046e41f4b71Sopenharmony_ci "name": "ohos.abilitydemo.permission.PROVIDER", 1047e41f4b71Sopenharmony_ci "grantMode": "system_grant", 1048e41f4b71Sopenharmony_ci "availableLevel": "system_core", 1049e41f4b71Sopenharmony_ci "provisionEnable": true, 1050e41f4b71Sopenharmony_ci "distributedSceneEnable": false, 1051e41f4b71Sopenharmony_ci "label": "$string:EntryAbility_label" 1052e41f4b71Sopenharmony_ci } 1053e41f4b71Sopenharmony_ci ] 1054e41f4b71Sopenharmony_ci } 1055e41f4b71Sopenharmony_ci} 1056e41f4b71Sopenharmony_ci``` 1057e41f4b71Sopenharmony_ci 1058e41f4b71Sopenharmony_ci## hnpPackages标签 1059e41f4b71Sopenharmony_ci 1060e41f4b71Sopenharmony_ci该标签标识应用包含的Native软件包信息。 1061e41f4b71Sopenharmony_ci 1062e41f4b71Sopenharmony_ci**表25** hnpPackages标签说明 1063e41f4b71Sopenharmony_ci 1064e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 1065e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 1066e41f4b71Sopenharmony_ci| package | 标识Native软件包名称。 | 字符串 | 该标签不可缺省。 | 1067e41f4b71Sopenharmony_ci| type | 标识Native软件包类型。支持的取值如下:<br/>- public:公有类型。<br/>- private:私有类型。 | 字符串 | 该标签不可缺省。 | 1068e41f4b71Sopenharmony_ci 1069e41f4b71Sopenharmony_cihnpPackages示例: 1070e41f4b71Sopenharmony_ci 1071e41f4b71Sopenharmony_ci 1072e41f4b71Sopenharmony_ci```json 1073e41f4b71Sopenharmony_ci{ 1074e41f4b71Sopenharmony_ci "module" : { 1075e41f4b71Sopenharmony_ci "hnpPackages": [ 1076e41f4b71Sopenharmony_ci { 1077e41f4b71Sopenharmony_ci "package": "hnpsample.hnp", 1078e41f4b71Sopenharmony_ci "type": "public" 1079e41f4b71Sopenharmony_ci } 1080e41f4b71Sopenharmony_ci ] 1081e41f4b71Sopenharmony_ci } 1082e41f4b71Sopenharmony_ci} 1083e41f4b71Sopenharmony_ci``` 1084e41f4b71Sopenharmony_ci 1085e41f4b71Sopenharmony_ci## fileContextMenu标签 1086e41f4b71Sopenharmony_ci 1087e41f4b71Sopenharmony_ci该标签用来标识当前HAP的右键菜单配置项,是一个profile文件资源,用于指定描述应用注册右键菜单配置文件。 1088e41f4b71Sopenharmony_ci 1089e41f4b71Sopenharmony_cifileContextMenu标签示例 1090e41f4b71Sopenharmony_ci 1091e41f4b71Sopenharmony_ci```json 1092e41f4b71Sopenharmony_ci{ 1093e41f4b71Sopenharmony_ci "module": { 1094e41f4b71Sopenharmony_ci // ... 1095e41f4b71Sopenharmony_ci "fileContextMenu": "$profile:menu" // 通过profile下的资源文件配置 1096e41f4b71Sopenharmony_ci } 1097e41f4b71Sopenharmony_ci} 1098e41f4b71Sopenharmony_ci``` 1099e41f4b71Sopenharmony_ci 1100e41f4b71Sopenharmony_ci在开发视图的resources/base/profile下面定义配置文件menu.json,其中文件名“menu.json”可自定义,需要和fileContextMenu标签指定的信息对应。配置文件中描述了当前应用注册的右键菜单的项目和响应行为。 1101e41f4b71Sopenharmony_ci配置文件根节点名称为fileContextMenu,为对象数组,标识当前module注册右键菜单的数量。(单模块和单应用注册数量不能超过5个,配置超过数量当前只解析随机5个) 1102e41f4b71Sopenharmony_ci 1103e41f4b71Sopenharmony_ci**表26** fileContextMenu标签配置说明 1104e41f4b71Sopenharmony_ci 1105e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 1106e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 1107e41f4b71Sopenharmony_ci| abilityName | 表示当前右键菜单对应的需要拉起的ability名称。 | 字符串 | 不可缺省 | 1108e41f4b71Sopenharmony_ci| menuItem | 右键菜单显示的信息。 | 资源id | 不可缺省 | 1109e41f4b71Sopenharmony_ci| menuHandler | 一个ability可以创建多个右键菜单, 用该字段来区分用户拉起的不同右键菜单项。该字段在用户点击右键菜单执行时,会作为参数传递给右键菜单应用。 | 字符串 | 不可缺省 | 1110e41f4b71Sopenharmony_ci| menuContext | 定义展示该菜单项需要的上下文,可以支持多种情况,类型为数组。 | 对象数组 | 不可缺省 | 1111e41f4b71Sopenharmony_ci 1112e41f4b71Sopenharmony_ci**表27** menuContext标签配置说明 1113e41f4b71Sopenharmony_ci 1114e41f4b71Sopenharmony_ci| 属性名称 | 含义 | 数据类型 | 是否可缺省 | 1115e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 1116e41f4b71Sopenharmony_ci| menuKind | 表示什么情况下触发该右键菜单:0:空白处 1:文件 2: 文件夹 3:文件和文件夹。 | 数值 | 不可缺省 | 1117e41f4b71Sopenharmony_ci| menuRule | 用来表示是单选/多选下选择单个文件/文件夹,或者两种情况都显示。单选:single, 多选:multi 单选+多选:both(全小写)。 | 字符串 | 不可缺省,当menuKind为1或2读取 | 1118e41f4b71Sopenharmony_ci| fileSupportType | 当选中的文件列表里包含这些文件类型时,显示该右键菜单。 | 字符串数组 | 不可缺省,仅menuKind为1时候读取,为*才读取fileNotSupportType字段,如果为具体值,不读取fileNotSupportType字段,如果为空,这条策略废弃 | 1119e41f4b71Sopenharmony_ci| fileNotSupportType | 当选中的文件列表里包含这些文件类型时,不显示该右键菜单。 | 字符串数组 | 仅menuKind为1,且fileSupportType为*才读取该字段 | 1120e41f4b71Sopenharmony_ci 1121e41f4b71Sopenharmony_cifileContextMenu配置文件示例 1122e41f4b71Sopenharmony_ci```json 1123e41f4b71Sopenharmony_ci{ 1124e41f4b71Sopenharmony_ci "fileContextMenu": [ 1125e41f4b71Sopenharmony_ci { 1126e41f4b71Sopenharmony_ci "abilityName": "EntryAbility", 1127e41f4b71Sopenharmony_ci "menuItem": "$string:module_desc", 1128e41f4b71Sopenharmony_ci "menuHandler": "openCompress", 1129e41f4b71Sopenharmony_ci "menuContext": [ 1130e41f4b71Sopenharmony_ci { 1131e41f4b71Sopenharmony_ci "menuKind": 0 1132e41f4b71Sopenharmony_ci }, 1133e41f4b71Sopenharmony_ci { 1134e41f4b71Sopenharmony_ci "menuKind": 1, 1135e41f4b71Sopenharmony_ci "menuRule": "both", 1136e41f4b71Sopenharmony_ci "fileSupportType": [ 1137e41f4b71Sopenharmony_ci ".rar", 1138e41f4b71Sopenharmony_ci ".zip" 1139e41f4b71Sopenharmony_ci ], 1140e41f4b71Sopenharmony_ci "fileNotSupportType": [ 1141e41f4b71Sopenharmony_ci "" 1142e41f4b71Sopenharmony_ci ] 1143e41f4b71Sopenharmony_ci }, 1144e41f4b71Sopenharmony_ci { 1145e41f4b71Sopenharmony_ci "menuKind": 2, 1146e41f4b71Sopenharmony_ci "menuRule": "single" 1147e41f4b71Sopenharmony_ci }, 1148e41f4b71Sopenharmony_ci { 1149e41f4b71Sopenharmony_ci "menuKind": 3 1150e41f4b71Sopenharmony_ci } 1151e41f4b71Sopenharmony_ci ] 1152e41f4b71Sopenharmony_ci } 1153e41f4b71Sopenharmony_ci ] 1154e41f4b71Sopenharmony_ci} 1155e41f4b71Sopenharmony_ci``` 1156e41f4b71Sopenharmony_ci 1157e41f4b71Sopenharmony_ci**响应行为** 1158e41f4b71Sopenharmony_ci 1159e41f4b71Sopenharmony_ci应用进行右键扩展菜单注册后,在文件管理器通过右键操作拉起菜单,该菜单中会有“更多”选项。点击“更多”选项后,会出现注册后的menuItem列表,点击任意一个选项后,文件管理器默认通过startAbility的方式拉起三方应用,除了指定三方应用的包名和ability名之外,want中的parameter中,也会传入如下字段: 1160e41f4b71Sopenharmony_ci 1161e41f4b71Sopenharmony_ci**表28** want中parameter字段说明 1162e41f4b71Sopenharmony_ci 1163e41f4b71Sopenharmony_ci| 参数名 | 值 | 类型 | 1164e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 1165e41f4b71Sopenharmony_ci| menuHandler | 对应注册配置文件中menuHandler的值。 | 字符串 | 1166e41f4b71Sopenharmony_ci| uriList | 用户在具体文件上触发右键的uri值,如果空白处响应,此值为空,单个文件响应,数组长度1,多个文件响应则传入对应所有文件的uri值。 | 字符串数组 |