提交 65904bd9 编写于 作者: E ester.zhou

Update docs (20589)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 41810fc3
......@@ -21,7 +21,8 @@ In the following example, two copies of the weather widget are added to the home
},
"colorMode": "auto",
"isDefault": true,
"updateEnabled": true,"scheduledUpdateTime": "07:00",
"updateEnabled": true,
"scheduledUpdateTime": "07:00",
"updateDuration": 0,
"defaultDimension": "2*2",
"supportDimensions": ["2*2"]
......@@ -103,10 +104,15 @@ In the following example, two copies of the weather widget are added to the home
let isTempCard: boolean = want.parameters[formInfo.FormParam.TEMPORARY_KEY];
if (isTempCard === false) {// If the widget is a normal one, the widget information is persisted.
console.info('Not temp card, init db for:' + formId);
let storeDB = dataPreferences.getPreferences(this.context, 'mystore')
storeDB.put('A' + formId, 'false');
storeDB.put('B' + formId, 'false');
storeDB.flush();
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB) => {
console.info("Succeeded to get preferences.");
await storeDB.put('A' + formId, 'false');
await storeDB.put('B' + formId, 'false');
await storeDB.flush();
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
let formData = {};
return formBindingData.createFormBindingData(formData);
......@@ -114,54 +120,71 @@ In the following example, two copies of the weather widget are added to the home
onRemoveForm(formId) {
console.info('onRemoveForm, formId:' + formId);
let storeDB = dataPreferences.getPreferences(this.context, 'mystore')
storeDB.delete('A' + formId);
storeDB.delete('B' + formId);
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB) => {
console.info("Succeeded to get preferences.");
await storeDB.delete('A' + formId);
await storeDB.delete('B' + formId);
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
// If the widget is a temporary one, it is recommended that the widget information be persisted when the widget is converted to a normal one.
onCastToNormalForm(formId) {
console.info('onCastToNormalForm, formId:' + formId);
let storeDB = dataPreferences.getPreferences(this.context, 'myStore')
storeDB.put('A' + formId, 'false');
storeDB.put('B' + formId, 'false');
storeDB.flush();
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB) => {
console.info("Succeeded to get preferences.");
await storeDB.put('A' + formId, 'false');
await storeDB.put('B' + formId, 'false');
await storeDB.flush();
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
onUpdateForm(formId) {
let storeDB = dataPreferences.getPreferences(this.context, 'myStore')
let stateA = storeDB.get('A' + formId, 'false').toString()
let stateB = storeDB.get('B' + formId, 'false').toString()
// Update textA in state A.
if (stateA === 'true') {
let formInfo = formBindingData.createFormBindingData({
'textA': 'AAA'
})
formProvider.updateForm(formId, formInfo)
}
// Update textB in state B.
if (stateB === 'true') {
let formInfo = formBindingData.createFormBindingData({
'textB': 'BBB'
})
formProvider.updateForm(formId, formInfo)
}
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB) => {
console.info("Succeeded to get preferences.");
let stateA = await storeDB.get('A' + formId, 'false');
let stateB = await storeDB.get('B' + formId, 'false');
// Update textA in state A.
if (stateA === 'true') {
let formInfo = formBindingData.createFormBindingData({'textA': 'AAA'});
await formProvider.updateForm(formId, formInfo);
}
// Update textB in state B.
if (stateB === 'true') {
let formInfo = formBindingData.createFormBindingData({'textB': 'BBB'});
await formProvider.updateForm(formId, formInfo);
}
console.info(`Update form success stateA:${stateA} stateB:${stateB}.`);
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
onFormEvent(formId, message) {
// Store the widget state.
console.info('onFormEvent formId:' + formId + 'msg:' + message);
let storeDB = dataPreferences.getPreferences(this.context, 'myStore')
let msg = JSON.parse(message)
if (msg.selectA != undefined) {
console.info('onFormEvent selectA info:' + msg.selectA);
storeDB.put('A' + formId, msg.selectA);
}
if (msg.selectB != undefined) {
console.info('onFormEvent selectB info:' + msg.selectB);
storeDB.put('B' + formId, msg.selectB);
}
storeDB.flush();
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB) => {
console.info("Succeeded to get preferences.");
let msg = JSON.parse(message);
if (msg.selectA != undefined) {
console.info('onFormEvent selectA info:' + msg.selectA);
await storeDB.put('A' + formId, msg.selectA);
}
if (msg.selectB != undefined) {
console.info('onFormEvent selectB info:' + msg.selectB);
await storeDB.put('B' + formId, msg.selectB);
}
await storeDB.flush();
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
};
```
......
# app.json5 Configuration File
This topic gives an overview of the **app.json5** configuration file. To start with, let's go through an example of what this file contains.
This document gives an overview of the **app.json5** configuration file. To start with, let's go through an example of what this file contains.
```json
{
......@@ -35,7 +35,7 @@ As shown above, the **app.json5** file contains several tags.
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| bundleName | Bundle name, which uniquely identifies an application. The value must comply with the following rules:<br>- Consists of letters, digits, underscores (_), and periods (.).<br>- Starts with a letter.<br>- Contains 7 to 127 bytes.<br>You are advised to use the reverse domain name notation, for example, *com.example.demo*, where the first part is the domain suffix **com**, the second part is the vendor/individual name, and the third part is the application name, which can be of multiple levels.<br>If an application is built with the system source code, you are advised to name it in *com.ohos.demo* notation, where **ohos** signifies that the application is an OpenHarmony system application.| String| No|
| bundleType| Bundle type, which is used to distinguish applications and atomic services.<br>- **app**: The bundle is a common application.<br>- **atomicService**: The bundle is an atomic service.<br>- **shared**: The bundle is a shared object application.| String| Yes (initial value: **"app"**)|
| bundleType| Bundle type, which is used to distinguish applications and atomic services. <br>- **app**: The bundle is a common application.<br>- **atomicService**: The bundle is an atomic service.<br>- **shared**: The bundle is a shared object application.| String| Yes (initial value: **"app"**)|
| debug | Whether the application can be debugged. This tag is generated during compilation and building in DevEco Studio.<br>- **true**: The application can be debugged.<br>- **false**: The application cannot be debugged.| Boolean| Yes (initial value: **false**)|
| icon | [Icon of the application](../application-models/application-component-configuration-stage.md). The value is an icon resource index.| String| No|
| label | [Name of the application](../application-models/application-component-configuration-stage.md). The value is a string resource index.| String| No|
......@@ -47,7 +47,7 @@ As shown above, the **app.json5** file contains several tags.
| minAPIVersion | Minimum API version required for running the application.| Number| Yes (initial value: value of **compatibleSdkVersion** in **build-profile.json5**)|
| targetAPIVersion | Target API version required for running the application.| Number| Yes (initial value: value of **compileSdkVersion** in **build-profile.json5**)|
| apiReleaseType | Type of the target API version required for running the application. The value can be **"CanaryN"**, **"BetaN"**, or **"Release"**, where **N** represents a positive integer.<br>- **Canary**: indicates a restricted release.<br>- **Beta**: indicates a publicly released beta version.<br>- **Release**: indicates a publicly released official version.<br>The value is set by DevEco Studio reading the stage of the SDK in use.| String| Yes (initial value: set by DevEco Studio)|
| multiProjects | Whether the application supports joint development of multiple projects.<br>- **true**: The application supports joint development of multiple projects.<br>- **false**: The application does not support joint development of multiple projects. For details about multi-project development, see [Multi-Project Build](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-building-overview-0000001263360495-V3#section71471033104216).| Boolean| Yes (initial value: **false**)|
| multiProjects | Whether the application supports joint development of multiple projects.<br>- **true**: The application supports joint development of multiple projects.<br>- **false**: The application does not support joint development of multiple projects. | Boolean| Yes (initial value: **false**)|
| asanEnabled | Whether to enable AddressSanitizer (ASan) to detect memory corruption issues such as buffer overflows.<br>- **true**: ASan is enabled.<br>- **false**: ASan is disabled. Note that ASan is not available in the Release version.| Boolean| Yes (initial value: **false**)|
| tablet | Tablet-specific configuration, which includes the **minAPIVersion** attribute.<br>When running on tablets, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)|
| tv | TV-specific configuration, which includes the **minAPIVersion** attribute.<br>When running on TVs, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)|
......@@ -56,4 +56,4 @@ As shown above, the **app.json5** file contains several tags.
| default | Default device–specific configuration, which includes the **minAPIVersion** attribute.<br>When running on default devices, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)|
|targetBundleName|Target application name of the bundle. The value rule and range are the same as those of **bundleName**.|String|Yes (if the initial value is used, the target application is not an application with the overlay feature)|
|targetPriority|Priority of the application. When **targetBundleName** is set, the application is an application with the overlay feature. The value ranges from 1 to 100.|Number|Yes (initial value: **1**)|
|generateBuildHash |Whether the hash values of all HAP and HSP files of the application are generated by the packaging tool. The hash values (if any) are used to determine whether the application needs to be updated when the system is updated in OTA mode but the **versionCode** value of the application remains unchanged.<br>If this tag is set to **true**, the packaging tool generates hash values for all HAP and HSP files of the application.<br>**NOTE**<br>This tag applies only to system applications.|Boolean|Yes (initial value: **false**)|
|generateBuildHash |Whether the hash values of all HAP and HSP files of the application are generated by the packaging tool. The hash values (if any) are used to determine whether the application needs to be updated when the system is updated in OTA mode but the **versionCode** value of the application remains unchanged.<br>If this tag is set to **true**, the packaging tool generates hash values for all HAP and HSP files of the application.<br>**NOTE**<br>**This tag applies only to system applications.**|Boolean|Yes (initial value: **false**)|
......@@ -27,7 +27,7 @@ Table 2 describes the internal structure of the **deviceConfig** attributes.
| process | Name of the process running the application or ability. If the **process** attribute is configured in the **deviceConfig** tag, all abilities of the application run in this process. You can set the **process** attribute for a specific ability in the **abilities** attribute, so that the ability can run in the particular process. The value can contain a maximum of 31 characters.| String| Yes (initial value: left empty)|
| keepAlive | Whether the application is always running. This attribute applies only to system applications and does not take effect for third-party applications. The value **true** means that the application will start during the OS startup and keep alive. If the application process exits, the OS will restart it.| Boolean| Yes (initial value: **false**)|
| supportBackup | Whether the application supports backup and restoration. The value **false** means that the application does not support backup or restoration.| Boolean| Yes (initial value: **false**)|
| compressNativeLibs | Whether the **libs** libraries are packaged in the HAP file after being compressed. The value **false** means that the **libs** libraries are stored without being compressed and will be directly loaded during the installation of the HAP file.| Boolean| Yes (initial value: **false**)|
| compressNativeLibs | Whether the **libs** libraries are packaged in the HAP file after being compressed. The value **false** means that the **libs** libraries are stored without being compressed and will be directly loaded during the installation of the HAP file.| Boolean| Yes (initial value: **true**)|
| network | Network security configuration. You can customize the network security settings of the application in the security statement of the configuration file without modifying the application code.| Object| Yes (initial value: left empty)|
## Internal Structure of the network Attribute
......
......@@ -380,7 +380,7 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie
| type | Type of the ExtensionAbility component. The options are as follows:<br>- **form**: ExtensionAbility of a widget.<br>- **workScheduler**: ExtensionAbility of a Work Scheduler task.<br>- **inputMethod**: ExtensionAbility of an input method.<br>- **service**: service component running in the background.<br>- **accessibility**: ExtensionAbility of an accessibility feature.<br>- **dataShare**: ExtensionAbility for data sharing.<br>- **fileShare**: ExtensionAbility for file sharing.<br>- **staticSubscriber**: ExtensionAbility for static broadcast.<br>- **wallpaper**: ExtensionAbility of the wallpaper.<br>- **backup**: ExtensionAbility for data backup.<br>- **window**: ExtensionAbility of a window. This type of ExtensionAbility creates a window during startup for which you can develop the GUI. The window is then combined with other application windows through **abilityComponent**.<br>- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.<br>- **preview**: ExtensionAbility for preview. This type of ExtensionAbility can parse the file and display it in a window. You can combine the window with other application windows.<br>- **print**: ExtensionAbility for the print framework.<br>- **push**: ExtensionAbility to be pushed.<br>- **driver**: ExtensionAbility for the driver framework.<br>**NOTE**<br>The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications.| String| No|
| permissions | Permissions required for another application to access the ExtensionAbility component.<br>The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of permission names predefined by the system or customized. The name of a customized permission must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty)|
| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.<br>**NOTE**<br>This attribute is mandatory when the type of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)|
|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.<br>Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application,<br>but not for an OpenHarmony service.| Array| Yes (initial value: left empty)|
|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.<br>Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application, but not for an OpenHarmony service.| Array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)|
| exported | Whether the ExtensionAbility component can be called by other applications. <br>- **true**: The ExtensionAbility component can be called by other applications.<br>- **false**: The ExtensionAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
......
......@@ -7,24 +7,24 @@ The **module** tag contains the HAP configuration.
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| mainAbility | Ability whose icon is displayed in the Service Center. When the resident process is started, the **mainAbility** is started.| String| Yes (initial value: left empty)|
| package | Package name of the HAP file, which must be unique in the application. The value is a string with a maximum of 127 bytes, in the reverse domain name notation. It is recommended that the value be the same as the project directory of the HAP file. | String| No|
| name | Class name of the HAP file. The value is a string with a maximum of 255 bytes, in the reverse domain name notation. The prefix must be the same as the **package** value specified for this module. Alternatively, the value can start with a period (.) followed by the class name.| String| Yes (initial value: left empty)|
| description | Description of the HAP file. The value is a string with a maximum of 255 bytes. If the value exceeds the limit or needs to support multiple languages, you can use a resource index to the description.| String| Yes (initial value: left empty)|
| supportedModes | Modes supported by the application. Currently, only the **drive** mode is defined. This attribute applies only to head units.| String array| Yes (initial value: left empty)|
|deviceType | Type of device on which the ability can run. The device types predefined in the system include **tablet**, **tv**, **car**, and **wearable**.| String array| No|
|distro | Distribution description of the HAP file.| Object| No|
|metaData | Metadata of the HAP file.| Object| Yes (initial value: left empty)|
| abilities | All abilities in the current module. The value is an array of objects, each of which represents an ability.| Object array| Yes (initial value: left empty)|
| js | A set of JS modules developed using ArkUI. The value is an array of objects, each of which represents a JS module.| Object array| Yes (initial value: left empty)|
| shortcuts | Shortcuts of the application. The value is an array of objects, each of which represents a shortcut object.| Object array| Yes (initial value: left empty)|
| reqPermissions | Permissions that the application requests from the system when it is running.| Object array| Yes (initial value: left empty)|
| colorMode | Color mode of the application. The options are as follows:<br>- **dark**: Resources applicable for the dark mode are used.<br>- **light**: Resources applicable for the light mode are used.<br>- **auto**: Resources are used based on the color mode of the system.| String| Yes (initial value: **auto**)|
| distributionFilter | Distribution rules of the application. This attribute defines the rules for distributing HAP files based on different device specifications, so that precise matching can be performed when the application market distributes applications. Distribution rules cover three factors: API version, screen shape, and screen resolution. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these three factors.| Object| Yes (initial value: left empty) Set this attribute when an application has multiple entry modules.|
|commonEvents | Information about the common event static subscriber, which must contain the subscriber name, required permissions, and list of the common events subscribed to. When a subscribed event is sent, the static subscriber is started. Unlike the dynamic subscriber, the static subscriber does not need to proactively call the common event subscription API in the service code, and may not be running when the common event is published.| Object array| Yes (initial value: left empty)|
| entryTheme | Keyword of an OpenHarmony internal theme. Set it to the resource index of the name.| String| Yes (initial value: left empty)|
|testRunner | Test runner configuration.| Object| Yes (initial value: left empty)|
|generateBuildHash | Whether the hash value of the HAP or HSP file is generated by the packaging tool. The hash value (if any) is used to determine whether the application needs to be updated when the system is updated in OTA mode but the value of [code](#internal-structure-of-the-apiversion-attribute) in **version** of the application remains unchanged.<br>**NOTE**<br>This tag applies only to system applications.|Boolean|Yes (initial value: **false**)|
| mainAbility | Ability whose icon is displayed in the Service Center. When the resident process is started, the **mainAbility** is started.| String| Yes (initial value: left empty)|
| package | Package name of the HAP file, which must be unique in the application. The value is a string with a maximum of 127 bytes, in the reverse domain name notation. It is recommended that the value be the same as the project directory of the HAP file. | String| No|
| name | Class name of the HAP file. The value is a string with a maximum of 255 bytes, in the reverse domain name notation. The prefix must be the same as the **package** value specified for this module. Alternatively, the value can start with a period (.) followed by the class name.| String| Yes (initial value: left empty)|
| description | Description of the HAP file. The value is a string with a maximum of 255 bytes. If the value exceeds the limit or needs to support multiple languages, you can use a resource index to the description.| String| Yes (initial value: left empty)|
| supportedModes | Modes supported by the application. Currently, only the **drive** mode is defined. This attribute applies only to head units.| String array| Yes (initial value: left empty)|
|deviceType | Type of device on which the ability can run. The device types predefined in the system include **tablet**, **tv**, **car**, and **wearable**.| String array| No|
|distro | Distribution description of the HAP file.| Object| No|
|metaData | Metadata of the HAP file.| Object| Yes (initial value: left empty)|
| abilities | All abilities in the current module. The value is an array of objects, each of which represents an ability.| Object array| Yes (initial value: left empty)|
| js | A set of JS modules developed using ArkUI. The value is an array of objects, each of which represents a JS module.| Object array| Yes (initial value: left empty)|
| shortcuts | Shortcuts of the application. The value is an array of objects, each of which represents a shortcut object.| Object array| Yes (initial value: left empty)|
| reqPermissions | Permissions that the application requests from the system when it is running.| Object array| Yes (initial value: left empty)|
| colorMode | Color mode of the application. The options are as follows:<br>- **dark**: Resources applicable for the dark mode are used.<br>- **light**: Resources applicable for the light mode are used.<br>- **auto**: Resources are used based on the color mode of the system.| String| Yes (initial value: **auto**)|
| distributionFilter | Rules for distributing HAP files based on different device specifications, so that precise matching can be performed when the application market distributes applications. All sub-attributes under this attribute are optional. This attribute must be configured in the **/resource/profile** directory. During distribution, a unique HAP is determined based on the mapping between **deviceType** and attributes listed in the table below.| Object| Yes (initial value: left empty) Set this attribute when an application has multiple entry modules.|
|commonEvents | Information about the common event static subscriber, which must contain the subscriber name, required permissions, and list of the common events subscribed to. When a subscribed event is sent, the static subscriber is started. Unlike the dynamic subscriber, the static subscriber does not need to proactively call the common event subscription API in the service code, and may not be running when the common event is published.| Object array| Yes (initial value: left empty)|
| entryTheme | Keyword of an OpenHarmony internal theme. Set it to the resource index of the name.| String| Yes (initial value: left empty)|
|testRunner | Test runner configuration.| Object| Yes (initial value: left empty)|
|generateBuildHash |Whether the hash value of the HAP or HSP file is generated by the packaging tool. The hash value (if any) is used to determine whether the application needs to be updated when the system is updated in OTA mode but the value of [code](#internal-structure-of-the-apiversion-attribute) in **version** of the application remains unchanged.<br>**NOTE**<br>**This tag applies only to system applications.**|Boolean|Yes (initial value: **false**)|
Example of the **module** tag structure:
......@@ -96,7 +96,7 @@ Example of the **module** tag structure:
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| moduleName | Name of the HAP file. The maximum length is 31 bytes.| String| No|
| moduleName | Name of the HAP file. The maximum length is 31 bytes. During application upgrade, this name can be changed. If it is changed, migration of module-related directories is required for the application. You can use the [file operation API](../reference/apis/js-apis-file-fs.md#fscopydir10) for migration.| String| No|
| moduleType | Type of the HAP file, which can **entry**, **feature**, or **har**.| String| No|
| installationFree | Whether the HAP file supports the installation-free feature. **true**: The HAP file supports the installation-free feature and meets installation-free constraints. **false**: The HAP file does not support the installation-free feature. If this tag is set to **true** for an entry-type HAP file (**entry.hap**), it must also be set to **true** for feature-type HAP files (**feature.hap**) of the same application. If this tag is set to **false** for an entry-type HAP file, it can be set to **true** or **false** for feature-type modules of the same application based on service requirements.| Boolean| No|
| deliveryWithInstall | Whether the HAP file will be installed when the user installs the application. **true**: The HAP file will be installed when the user installs the application. **false**: The HAP file will not be installed when the user installs the application.| Boolean| No|
......@@ -196,10 +196,10 @@ Example of the metadata attribute:
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| process | Name of the process running the application or ability. If the **process** attribute is configured in the **deviceConfig** tag, all abilities of the application run in this process. You can set the **process** attribute for a specific ability in the **abilities** attribute, so that the ability can run in the particular process. If this attribute is set to the name of the process running other applications, all these applications can run in the same process, provided they have the same unified user ID and the same signature. The value can contain a maximum of 31 bytes.| String| Yes (initial value: left empty)|
| name | Ability name. The value can be a reverse domain name, in the format of "*bundleName*.*className*", for example, **"com.example.myapplication.EntryAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".EntryAbility"**.<br>The ability name must be unique in an application.<br/>**NOTE**<br/>If you use DevEco Studio to create the project, an ability named **EntryAbility** will be created by default, and its configuration will be saved to the **config.json** file. If you use other IDEs, the value of this attribute can be customized. The value can contain a maximum of 127 bytes. | String| No|
| name | Ability name. The value can be a reverse domain name, in the format of "*bundleName*.*className*", for example, **"com.example.myapplication.EntryAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".EntryAbility"**.<br>The ability name must be unique in an application.<br>**NOTE**<br>If you use DevEco Studio to create the project, an ability named **EntryAbility** will be created by default, and its configuration will be saved to the **config.json** file. If you use other IDEs, the value of this attribute can be customized. The value can contain a maximum of 127 bytes.| String| No|
| description | Description of the ability. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 bytes.| String| Yes (initial value: left empty)|
| icon | Index to the ability icon file. Example value: **$media:ability_icon**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the icon of the ability is also used as the icon of the application. If multiple abilities address this condition, the icon of the first candidate ability is used as the application icon.<br>**NOTE**<br>The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels. | String| Yes (initial value: left empty)|
| label | Ability name displayed to users. The value can be a name string or a resource index to names in multiple languages, for example, **$string:ability_label**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the label of the ability is also used as the label of the application. If multiple abilities address this condition, the label of the first candidate ability is used as the application label.<br>**NOTE**<br/>The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels. The value can be a reference to a string defined in a resource file or a string enclosed in brackets ({}). The value can contain a maximum of 255 bytes. | String| Yes (initial value: left empty)|
| icon | Index to the ability icon file. Example value: **$media:ability_icon**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the icon of the ability is also used as the icon of the application. If multiple abilities address this condition, the icon of the first candidate ability is used as the application icon.<br>**NOTE**<br>The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels.| String| Yes (initial value: left empty)|
| label | Ability name displayed to users. The value can be a name string or a resource index to names in multiple languages, for example, **$string:ability_label**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the label of the ability is also used as the label of the application. If multiple abilities address this condition, the label of the first candidate ability is used as the application label.<br>**NOTE**<br>The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels. The value can be a reference to a string defined in a resource file or a string enclosed in brackets ({}). The value can contain a maximum of 255 bytes.| String| Yes (initial value: left empty)|
| uri | Uniform Resource Identifier (URI) of the ability. The value can contain a maximum of 255 bytes.| String| Yes (No for abilities using the Data template)|
| launchType | Launch type of the ability. The value can be **standard** or **singleton**.<br>**standard**: Multiple **Ability** instances can be created during startup. Most abilities can use this type.<br>**singleton**: Only a single **Ability** instance can be created across all task stacks during startup. For example, a globally unique incoming call screen uses the singleton launch type. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String| Yes (initial value: **"singleton"**)|
| visible | Whether the ability can be called by other applications.<br>**true**: The ability can be called by other applications.<br>**false**: The ability cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
......
......@@ -125,8 +125,8 @@ Defines subscription information.
| mode | [DiscoverMode ](#discovermode) | Yes | Device discovery mode. |
| medium | [ExchangeMedium](#exchangemedium) | Yes | Medium used for device discovery. |
| freq | [ExchangeFreq](#exchangefreq) | Yes | Frequency of device discovery. |
| isSameAccount | boolean | Yes | Whether the same account is used on the discovered device. |
| isWakeRemote | boolean | Yes | Whether to wake up the discovered device. |
| isSameAccount | boolean | No | Whether the same account is used on the discovered device. |
| isWakeRemote | boolean | No | Whether to wake up the discovered device. |
| capability | [SubscribeCap](#subscribecap) | Yes | Discovery capability. |
......@@ -227,6 +227,8 @@ release(): void
Releases this **DeviceManager** instance when it is no longer used.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Error codes**
......@@ -253,6 +255,8 @@ getTrustedDeviceListSync(): Array&lt;DeviceInfo&gt;
Obtains all trusted devices synchronously.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Return value**
......@@ -279,12 +283,54 @@ For details about the error codes, see [Device Management Error Codes](../errorc
}
```
### getTrustedDeviceListSync<sup>10+</sup>
getTrustedDeviceListSync(isRefresh: boolean): Array&lt;DeviceInfo&gt;
Enables the DSoftBus heartbeat mode to quickly bring offline trusted devices online and updates the list of online trusted devices.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
| Name | Type | Mandatory| Description |
| ------------- | --------------------------------- | ---- | ---------------------------------- |
| isRefresh | boolean | Yes | Whether to enable the heartbeat mode and update the list of online trusted devices. |
**Return value**
| Name | Description |
| -------------------------------------- | ---------------- |
| Array&lt;[DeviceInfo](#deviceinfo)&gt; | List of trusted devices obtained.|
**Error codes**
For details about the error codes, see [Device Management Error Codes](../errorcodes/errorcode-device-manager.md).
| ID| Error Message |
| -------- | --------------------------------------------------------------- |
| 11600101 | Failed to execute the function. |
**Example**
```js
try {
var deviceInfoList = dmInstance.getTrustedDeviceListSync(true);
} catch (err) {
console.error("getTrustedDeviceListSync errCode:" + err.code + ",errMessage:" + err.message);
}
```
### getTrustedDeviceList<sup>8+</sup>
getTrustedDeviceList(callback:AsyncCallback&lt;Array&lt;DeviceInfo&gt;&gt;): void
Obtains all trusted devices. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -315,6 +361,8 @@ getTrustedDeviceList(): Promise&lt;Array&lt;DeviceInfo&gt;&gt;
Obtains all trusted devices. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Return value**
......@@ -323,14 +371,6 @@ Obtains all trusted devices. This API uses a promise to return the result.
| ---------------------------------------- | --------------------- |
| Promise&lt;Array&lt;[DeviceInfo](#deviceinfo)&gt;&gt; | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Device Management Error Codes](../errorcodes/errorcode-device-manager.md).
| ID| Error Message |
| -------- | --------------------------------------------------------------- |
| 11600101 | Failed to execute the function. |
**Example**
```js
......@@ -347,6 +387,8 @@ getLocalDeviceInfoSync(): [DeviceInfo](#deviceinfo)
Obtains local device information synchronously.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Return value**
......@@ -379,6 +421,8 @@ getLocalDeviceInfo(callback:AsyncCallback&lt;DeviceInfo&gt;): void
Obtains local device information. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -409,6 +453,8 @@ getLocalDeviceInfo(): Promise&lt;DeviceInfo&gt;
Obtains local device information. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Return value**
......@@ -417,14 +463,6 @@ Obtains local device information. This API uses a promise to return the result.
| ---------------------------------------- | --------------------- |
| Promise&lt;[DeviceInfo](#deviceinfo)&gt; | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Device Management Error Codes](../errorcodes/errorcode-device-manager.md).
| ID| Error Message |
| ------- | --------------------------------------------------------------- |
| 11600101| Failed to execute the function. |
**Example**
```js
......@@ -441,6 +479,8 @@ getDeviceInfo(networkId: string, callback:AsyncCallback&lt;DeviceInfo&gt;): void
Obtains the information about a specific device based on the network ID. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -474,6 +514,8 @@ getDeviceInfo(networkId: string): Promise&lt;DeviceInfo&gt;
Obtains the information about a specific device based on the network ID. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -506,6 +548,8 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void
Starts to discover peripheral devices. The discovery process automatically stops when 2 minutes have elapsed. A maximum of 99 devices can be discovered.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -550,6 +594,8 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void
Starts to discover peripheral devices and filters discovered devices. The discovery process automatically stops when 2 minutes have elapsed. A maximum of 99 devices can be discovered.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -604,6 +650,8 @@ stopDeviceDiscovery(subscribeId: number): void
Stops device discovery.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -638,6 +686,8 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void
Publishes device information for discovery purposes. The publish process automatically stops when 2 minutes have elapsed.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -679,6 +729,8 @@ unPublishDeviceDiscovery(publishId: number): void
Stops publishing device information.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -713,6 +765,8 @@ authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: Async
Authenticates a device.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -764,6 +818,8 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void
Deauthenticates a device.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -803,6 +859,8 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback&lt;{deviceId: string,
Verifies authentication information.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -839,6 +897,8 @@ setUserOperation(operateAction: number, params: string): void;
Sets a user operation.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -873,6 +933,8 @@ requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback<{regi
Obtains the registration information of the credential.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -908,6 +970,8 @@ importCredential(credentialInfo: string, callback: AsyncCallback<{resultInfo: st
Imports credential information.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -959,6 +1023,8 @@ deleteCredential(queryInfo: string, callback: AsyncCallback<{resultInfo: string}
Deletes credential information.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -995,6 +1061,8 @@ on(type: 'uiStateChange', callback: Callback&lt;{ param: string}&gt;): void;
Subscribes to UI status changes.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1025,6 +1093,8 @@ off(type: 'uiStateChange', callback?: Callback&lt;{ param: string}&gt;): void;
Unsubscribes from UI status changes.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1050,6 +1120,8 @@ on(type: 'deviceStateChange', callback: Callback&lt;{ action: DeviceStateChange
Subscribes to changes in the device state.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1077,6 +1149,8 @@ off(type: 'deviceStateChange', callback?: Callback&lt;{ action: DeviceStateChang
Unsubscribes from changes in the device state.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1104,6 +1178,8 @@ on(type: 'deviceFound', callback: Callback&lt;{ subscribeId: number, device: Dev
Subscribes to device discovery events.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1131,6 +1207,8 @@ off(type: 'deviceFound', callback?: Callback&lt;{ subscribeId: number, device: D
Unsubscribes from device discovery events.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1158,6 +1236,8 @@ on(type: 'discoverFail', callback: Callback&lt;{ subscribeId: number, reason: nu
Subscribes to device discovery failures.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1185,6 +1265,8 @@ off(type: 'discoverFail', callback?: Callback&lt;{ subscribeId: number, reason:
Unsubscribes from device discovery failures.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1212,6 +1294,8 @@ on(type: 'publishSuccess', callback: Callback&lt;{ publishId: number }&gt;): voi
Subscribes to device information publication success events.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1240,6 +1324,8 @@ off(type: 'publishSuccess', callback?: Callback&lt;{ publishId: number }&gt;): v
Unsubscribes from device information publication success events.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1267,6 +1353,8 @@ on(type: 'publishFail', callback: Callback&lt;{ publishId: number, reason: numbe
Subscribes to device information publication failures.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1294,6 +1382,8 @@ off(type: 'publishFail', callback?: Callback&lt;{ publishId: number, reason: num
Unsubscribes from device information publication failures.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1321,6 +1411,8 @@ on(type: 'serviceDie', callback: () =&gt; void): void
Subscribes to dead events of the **DeviceManager** service.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......@@ -1348,6 +1440,8 @@ off(type: 'serviceDie', callback?: () =&gt; void): void
Unsubscribes from dead events of the **DeviceManager** service.
**Required permissions**: ohos.permission.ACCESS_SERVICE_DM
**System capability**: SystemCapability.DistributedHardware.DeviceManager
**Parameters**
......
# Device Management Changelog
## cl.device_manager.1 API Permission Change
Added permission verification for some APIs.
**Change Impact**
Applications developed in versions later than OpenHarmony 4.0.8.2 must have the specific permission to call the APIs.
**Key API/Component Changes**
| Module | Class | Method/Attribute/Enum/Constant | New Permission|
| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** release(): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** getTrustedDeviceListSync(): Array&lt;DeviceInfo&gt; | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** getTrustedDeviceListSync(isRefresh: boolean): Array&lt;DeviceInfo&gt;; | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** getTrustedDeviceList(callback:AsyncCallback&lt;Array&lt;DeviceInfo&gt;&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** getTrustedDeviceList(): Promise&lt;Array&lt;DeviceInfo&gt;&gt; | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** getLocalDeviceInfoSync(): DeviceInfo | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** getLocalDeviceInfo(callback:AsyncCallback&lt;DeviceInfo&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** getLocalDeviceInfo(): Promise&lt;DeviceInfo&gt; | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** getDeviceInfo(networkId: string, callback:AsyncCallback&lt;DeviceInfo&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** getDeviceInfo(networkId: string): Promise&lt;DeviceInfo&gt; | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** startDeviceDiscovery(subscribeInfo: SubscribeInfo): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** stopDeviceDiscovery(subscribeId: number): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** publishDeviceDiscovery(publishInfo: PublishInfo): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** unPublishDeviceDiscovery(publishId: number): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback&lt;{deviceId: string, pinToken ?: number}&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** unAuthenticateDevice(deviceInfo: DeviceInfo): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback&lt;{deviceId: string, level: number}&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** setUserOperation(operateAction: number, params: string): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback&lt;{registerInfo: string}&gt;): void; | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** importCredential(credentialInfo: string, callback: AsyncCallback&lt;{resultInfo: string}&gt;): void; | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** deleteCredential(queryInfo: string, callback: AsyncCallback&lt;{resultInfo: string}&gt;): void; | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** on(type: 'uiStateChange', callback: Callback&lt;{ param: string}&gt;): void; | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** off(type: 'uiStateChange', callback?: Callback&lt;{ param: string}&gt;): void; | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** on(type: 'deviceStateChange', callback: Callback&lt;{ action: DeviceStateChangeAction, device: DeviceInfo }&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** off(type: 'deviceStateChange', callback?: Callback&lt;{ action: DeviceStateChangeAction, device: DeviceInfo }&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** on(type: 'deviceFound', callback: Callback&lt;{ subscribeId: number, device: DeviceInfo }&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** off(type: 'deviceFound', callback?: Callback&lt;{ subscribeId: number, device: DeviceInfo }&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** on(type: 'discoverFail', callback: Callback&lt;{ subscribeId: number, reason: number }&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** off(type: 'discoverFail', callback?: Callback&lt;{ subscribeId: number, reason: number }&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** on(type: 'publishSuccess', callback: Callback&lt;{ publishId: number }&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** off(type: 'publishSuccess', callback?: Callback&lt;{ publishId: number }&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** on(type: 'publishFail', callback: Callback&lt;{ publishId: number, reason: number }&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** off(type: 'publishFail', callback?: Callback&lt;{ publishId: number, reason: number }&gt;): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** on(type: 'serviceDie', callback: () =&gt; void): void | ohos.permission.ACCESS_SERVICE_DM |
| @ohos.distributedHardware.deviceManager | deviceManager | **function** off(type: 'serviceDie', callback?: () =&gt; void): void | ohos.permission.ACCESS_SERVICE_DM |
**Adaptation Guide**
Apply for the corresponding permission to call these APIs.
## cl.device_manager.2 Permission Verification for All System APIs
Added permission verification for all system APIs.
**Change Impact**
Non-system applications and applications without system API permission cannot call system APIs.
**Key API/Component Changes**
System API permission verification is performed on all APIs. The table below describes the APIs.
| API/Enum/Variable| Type| Is System API|
| -------- | -------- | ------- |
| createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager&gt;): void; | interface | Yes|
| release(): void | interface | Yes|
| getTrustedDeviceListSync(): Array&lt;DeviceInfo&gt; | interface | Yes|
| getTrustedDeviceListSync(isRefresh: boolean): Array&lt;DeviceInfo&gt;; | interface | Yes|
| getTrustedDeviceList(callback:AsyncCallback&lt;Array&lt;DeviceInfo&gt;&gt;): void | interface | Yes|
| getTrustedDeviceList(): Promise&lt;Array&lt;DeviceInfo&gt;&gt; | interface | Yes|
| getLocalDeviceInfoSync(): DeviceInfo | interface | Yes|
| getLocalDeviceInfo(callback:AsyncCallback&lt;DeviceInfo&gt;): void | interface | Yes|
| getLocalDeviceInfo(): Promise&lt;DeviceInfo&gt; | interface | Yes|
| getDeviceInfo(networkId: string, callback:AsyncCallback&lt;DeviceInfo&gt;): void | interface | Yes|
| getDeviceInfo(networkId: string): Promise&lt;DeviceInfo&gt; | interface | Yes|
| startDeviceDiscovery(subscribeInfo: SubscribeInfo): void | interface | Yes|
| startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void | interface | Yes|
| stopDeviceDiscovery(subscribeId: number): void | interface | Yes|
| publishDeviceDiscovery(publishInfo: PublishInfo): void | interface | Yes|
| unPublishDeviceDiscovery(publishId: number): void | interface | Yes|
| authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback&lt;{deviceId: string, pinToken ?: number}&gt;): void |interface | Yes|
| unAuthenticateDevice(deviceInfo: DeviceInfo): void | interface | Yes|
| verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback&lt;{deviceId: string, level: number}&gt;): void | interface | Yes|
| setUserOperation(operateAction: number, params: string): void | interface | Yes|
| requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback&lt;{registerInfo: string}&gt;): void; | interface | Yes|
| importCredential(credentialInfo: string, callback: AsyncCallback&lt;{resultInfo: string}&gt;): void; | interface | Yes|
| deleteCredential(queryInfo: string, callback: AsyncCallback&lt;{resultInfo: string}&gt;): void; | interface | Yes|
| on(type: 'uiStateChange', callback: Callback&lt;{ param: string}&gt;): void; | interface | Yes|
| off(type: 'uiStateChange', callback?: Callback&lt;{ param: string}&gt;): void; | interface | Yes|
| on(type: 'deviceStateChange', callback: Callback&lt;{ action: DeviceStateChangeAction, device: DeviceInfo }&gt;): void | interface | Yes|
| off(type: 'deviceStateChange', callback?: Callback&lt;{ action: DeviceStateChangeAction, device: DeviceInfo }&gt;): void | interface | Yes|
| on(type: 'deviceFound', callback: Callback&lt;{ subscribeId: number, device: DeviceInfo }&gt;): void | interface | Yes|
| off(type: 'deviceFound', callback?: Callback&lt;{ subscribeId: number, device: DeviceInfo }&gt;): void | interface | Yes|
| on(type: 'discoverFail', callback: Callback&lt;{ subscribeId: number, reason: number }&gt;): void | interface | Yes|
| off(type: 'discoverFail', callback?: Callback&lt;{ subscribeId: number, reason: number }&gt;): void | interface | Yes|
| on(type: 'publishSuccess', callback: Callback&lt;{ publishId: number }&gt;): void | interface | Yes|
| off(type: 'publishSuccess', callback?: Callback&lt;{ publishId: number }&gt;): void | interface | Yes|
| on(type: 'publishFail', callback: Callback&lt;{ publishId: number, reason: number }&gt;): void | interface | Yes|
| off(type: 'publishFail', callback?: Callback&lt;{ publishId: number, reason: number }&gt;): void | interface | Yes|
| on(type: 'serviceDie', callback: () =&gt; void): void | interface | Yes|
| off(type: 'serviceDie', callback?: () =&gt; void): void | interface | Yes|
**Adaptation Guide**
Make sure the caller of the preceding APIs is a system application or an application that has the system API permission.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册