提交 89fd2d98 编写于 作者: X xsz233 提交者: ShiZhe Xu

modify bundle api reference

Signed-off-by: Nxsz233 <xushizhe@huawei.com>
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/api_doc.iml" filepath="$PROJECT_DIR$/.idea/api_doc.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
# FA Widget Development # FA Widget Development
## Widget Overview ## Widget Overview
A widget is a set of UI components used to display important information or operations for an application. It provides users with direct access to a desired application service, without requiring them to open the application. A widget is a set of UI components that display important information or operations specific to an application. It provides users with direct access to a desired application service, without the need to open the application first.
A widget displays brief information about an application on the UI of another application (host application, currently system applications only) and provides basic interactive functions such as opening a UI page or sending a message. A widget usually appears as a part of the UI of another application (which currently can only be a system application) and provides basic interactive features such as opening a UI page or sending a message.
Basic concepts: Before you get started, it would be helpful if you have a basic understanding of the following concepts:
- Widget provider: an atomic service that controls what and how content is displayed in a widget and interacts with users. - Widget provider: an atomic service that provides the widget content to display and controls how widget components are laid out and how they interact with users.
- Widget host: an application that displays the widget content and controls the position where the widget is displayed in the host application. - Widget host: an application that displays the widget content and controls the widget location.
- Widget Manager: a resident agent that manages widgets added to the system and provides functions such as periodic widget update. - Widget Manager: a resident agent that provides widget management features such as periodic widget updates.
> **NOTE** > **NOTE**
> >
> The widget host and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated. > The widget host and provider do not need to be running all the time. The Widget Manager will start the widget provider to obtain widget information when a widget is added, deleted, or updated.
You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget host and Widget Manager. You only need to develop the widget provider. The system automatically handles the work of the widget host and Widget Manager.
The widget provider controls the widget content to display, component layout, and click events bound to components. The widget provider controls the widget content to display, the layout of components used in the widget, and click events bound to the components.
## Development Overview ## Development Overview
In FA widget development, you need to carry out the following operations as a widget provider based on the [Feature Ability (FA) model](fa-brief.md). Carry out the following operations to develop the widget provider based on the [FA model](fa-brief.md):
- Develop the lifecycle callbacks in **LifecycleForm**. 1. Implement lifecycle callbacks by using the **LifecycleForm** APIs.
- Create a **FormBindingData** instance. 2. Create a **FormBindingData** instance.
- Update a widget through **FormProvider**. 3. Update a widget by using the **FormProvider** APIs.
- Develop the widget UI pages. 4. Develop the widget UI pages.
## Available APIs ## Available APIs
The table below describes the lifecycle callbacks provided in **LifecycleForm**. The table below describes the **LifecycleForm** APIs, which represent the lifecycle callbacks of a widget (known as a **Form** instance).
**Table 1** LifecycleForm APIs **Table 1** LifecycleForm APIs
| API | Description | | API | Description |
| :----------------------------------------------------------- | :------------------------------------------- | | :----------------------------------------------------------- | :------------------------------------------- |
| onCreate(want: Want): formBindingData.FormBindingData | Called to notify the widget provider that a **Form** instance (widget) has been created. | | onCreate(want: Want): formBindingData.FormBindingData | Called to notify the widget provider that a widget has been created. |
| onCastToNormal(formId: string): void | Called to notify the widget provider that a temporary widget has been converted to a normal one.| | onCastToNormal(formId: string): void | Called to notify the widget provider that a temporary widget has been converted to a normal one.|
| onUpdate(formId: string): void | Called to notify the widget provider that a widget has been updated. | | onUpdate(formId: string): void | Called to notify the widget provider that a widget has been updated. |
| onVisibilityChange(newStatus: { [key: string]: number }): void | Called to notify the widget provider of the change in widget visibility. | | onVisibilityChange(newStatus: { [key: string]: number }): void | Called to notify the widget provider of the change in widget visibility. |
| onEvent(formId: string, message: string): void | Called to instruct the widget provider to receive and process a widget event. | | onEvent(formId: string, message: string): void | Called to instruct the widget provider to receive and process a widget event. |
| onDestroy(formId: string): void | Called to notify the widget provider that a **Form** instance (widget) has been destroyed. | | onDestroy(formId: string): void | Called to notify the widget provider that a widget has been destroyed. |
| onAcquireFormState?(want: Want): formInfo.FormState | Called when the widget provider receives the status query result of a widget. | | onAcquireFormState?(want: Want): formInfo.FormState | Called to instruct the widget provider to receive the status query result of a widget. |
For details about the **FormProvider** APIs, see [FormProvider](../reference/apis/js-apis-formprovider.md). The table below describes the **FormProvider** APIs. For details, see [FormProvider](../reference/apis/js-apis-formprovider.md).
**Table 2** FormProvider APIs **Table 2** FormProvider APIs
...@@ -56,9 +56,9 @@ For details about the **FormProvider** APIs, see [FormProvider](../reference/api ...@@ -56,9 +56,9 @@ For details about the **FormProvider** APIs, see [FormProvider](../reference/api
## How to Develop ## How to Develop
### Creating LifecycleForm ### Implementing Lifecycle Callbacks
To create a widget in the FA model, you need to implement the lifecycles of **LifecycleForm**. The sample code is as follows: To create an FA widget, you need to implement lifecycle callbacks using the **LifecycleForm** APIs. The sample code is as follows:
1. Import the required modules. 1. Import the required modules.
...@@ -68,7 +68,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li ...@@ -68,7 +68,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li
import formProvider from '@ohos.application.formProvider' import formProvider from '@ohos.application.formProvider'
``` ```
2. Implement the lifecycle callbacks of **LifecycleForm**. 2. Implement lifecycle callbacks for the widget.
```javascript ```javascript
export default { export default {
...@@ -87,7 +87,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li ...@@ -87,7 +87,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li
console.log('FormAbility onCastToNormal'); console.log('FormAbility onCastToNormal');
}, },
onUpdate(formId) { onUpdate(formId) {
// To support scheduled update, periodic update, or update requested by the widget host, override this method for widget data update. // Override this method to support scheduled updates, periodic updates, or updates requested by the widget host.
console.log('FormAbility onUpdate'); console.log('FormAbility onUpdate');
let obj = { let obj = {
"title": "titleOnUpdate", "title": "titleOnUpdate",
...@@ -119,19 +119,19 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li ...@@ -119,19 +119,19 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li
### Configuring the Widget Configuration File ### Configuring the Widget Configuration File
Configure the **config.json** file for the widget. The widget configuration file is named **config.json**. Find the **config.json** file for the widget and edit the file depending on your need.
- The **js** module in the **config.json** file provides the JavaScript resources of the widget. The internal structure is described as follows: - The **js** module in the **config.json** file provides JavaScript resources of the widget. The internal structure is described as follows:
| Field| Description | Data Type| Default | | Field| Description | Data Type| Default |
| -------- | ------------------------------------------------------------ | -------- | ------------------------ | | -------- | ------------------------------------------------------------ | -------- | ------------------------ |
| name | Name of a JavaScript component. The default value is **default**. | String | No | | name | Name of a JavaScript component. The default value is **default**. | String | No |
| pages | Route information about all pages in the JavaScript component, including the page path and page name. The value is an array, in which each element represents a page. The first element in the array represents the home page of the JavaScript FA.| Array | No | | pages | Route information about all pages in the JavaScript component, including the page path and page name. The value is an array, in which each element represents a page. The first element in the array represents the home page of the JavaScript FA.| Array | No |
| window | Window-related configurations. | Object | Yes | | window | Window-related configurations. | Object | Yes |
| type | Type of the JavaScript component. Available values are as follows:<br>**normal**: indicates that the JavaScript component is an application instance.<br>**form**: indicates that the JavaScript component is a widget instance.| String | Yes (initial value: **normal**)| | type | Type of the JavaScript component. <br>**normal**: indicates an application instance.<br>**form**: indicates a widget instance.| String | Yes (initial value: **normal**)|
| mode | Development mode of the JavaScript component. | Object | Yes (initial value: left empty) | | mode | Development mode of the JavaScript component. | Object | Yes (initial value: left empty) |
A configuration example is as follows: Example configuration:
```json ```json
"js": [{ "js": [{
...@@ -145,27 +145,27 @@ Configure the **config.json** file for the widget. ...@@ -145,27 +145,27 @@ Configure the **config.json** file for the widget.
}] }]
``` ```
- The **abilities** module in the **config.json** file corresponds to the **LifecycleForm** of the widget. The internal structure is described as follows: - The **abilities** module in the **config.json** file corresponds to **LifecycleForm** of the widget. The internal structure is described as follows:
| Field | Description | Data Type | Default | | Field | Description | Data Type | Default |
| ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ | | ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ |
| name | Class name of the widget. The value is a string with a maximum of 127 bytes. | String | No | | name | Class name of the widget. The value is a string with a maximum of 127 bytes. | String | No |
| description | Description of the widget. The value can be a string or a resource index to descriptions in multiple languages. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) | | description | Description of the widget. The value can be a string or a resource index to descriptions in multiple languages. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) |
| isDefault | Whether the widget is a default one. Each ability has only one default widget.<br>**true**: The widget is the default one.<br>**false**: The widget is not the default one.| Boolean | No | | isDefault | Whether the widget is a default one. Each ability has only one default widget.<br>**true**: The widget is the default one.<br>**false**: The widget is not the default one.| Boolean | No |
| type | Type of the widget. Available values are as follows:<br>**JS**: indicates a JavaScript-programmed widget. | String | No | | type | Type of the widget. <br>**JS**: indicates a JavaScript-programmed widget. | String | No |
| colorMode | Color mode of the widget. Available values are as follows:<br>**auto**: The widget adopts the auto-adaptive color mode.<br>**dark**: The widget adopts the dark color mode.<br>**light**: The widget adopts the light color mode.| String | Yes (initial value: **auto**)| | colorMode | Color mode of the widget.<br>**auto**: The widget adopts the auto-adaptive color mode.<br>**dark**: The widget adopts the dark color mode.<br>**light**: The widget adopts the light color mode.| String | Yes (initial value: **auto**)|
| supportDimensions | Grid styles supported by the widget. Available values are as follows:<br>**1 * 2**: indicates a grid with one row and two columns.<br>**2 * 2**: indicates a grid with two rows and two columns.<br>**2 * 4**: indicates a grid with two rows and four columns.<br>**4 * 4**: indicates a grid with four rows and four columns.| String array| No | | supportDimensions | Grid styles supported by the widget.<br>**1 * 2**: indicates a grid with one row and two columns.<br>**2 * 2**: indicates a grid with two rows and two columns.<br>**2 * 4**: indicates a grid with two rows and four columns.<br>**4 * 4**: indicates a grid with four rows and four columns.| String array| No |
| defaultDimension | Default grid style of the widget. The value must be available in the **supportDimensions** array of the widget.| String | No | | defaultDimension | Default grid style of the widget. The value must be available in the **supportDimensions** array of the widget.| String | No |
| updateEnabled | Whether the widget can be updated periodically. Available values are as follows:<br>**true**: The widget can be updated periodically, depending on the update way you select, either at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** is preferentially recommended.<br>**false**: The widget cannot be updated periodically.| Boolean | No | | updateEnabled | Whether the widget can be updated periodically.<br>**true**: The widget can be updated at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** takes precedence over **scheduledUpdateTime**.<br>**false**: The widget cannot be updated periodically.| Boolean | No |
| scheduledUpdateTime | Scheduled time to update the widget. The value is in 24-hour format and accurate to minute.<br>This parameter has a lower priority than **updateDuration**. If both are specified, the value specified by **updateDuration** is used.| String | Yes (initial value: **0:0**) | | scheduledUpdateTime | Scheduled time to update the widget. The value is in 24-hour format and accurate to minute.<br>**updateDuration** takes precedence over **scheduledUpdateTime**. If both are specified, the value specified by **updateDuration** is used.| String | Yes (initial value: **0:0**) |
| updateDuration | Interval to update the widget. The value is a natural number, in the unit of 30 minutes.<br>If the value is **0**, this field does not take effect.<br>If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.<br>This parameter has a higher priority than **scheduledUpdateTime**. If both are specified, the value specified by **updateDuration** is used.| Number | Yes (initial value: **0**) | | updateDuration | Interval to update the widget. The value is a natural number, in the unit of 30 minutes.<br>If the value is **0**, this field does not take effect.<br>If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.<br>**updateDuration** takes precedence over **scheduledUpdateTime**. If both are specified, the value specified by **updateDuration** is used.| Number | Yes (initial value: **0**) |
| formConfigAbility | Link to a specific page of the application. The value is a URI. | String | Yes (initial value: left empty) | | formConfigAbility | Link to a specific page of the application. The value is a URI. | String | Yes (initial value: left empty) |
| formVisibleNotify | Whether the widget is allowed to use the widget visibility notification. | String | Yes (initial value: left empty) | | formVisibleNotify | Whether the widget is allowed to use the widget visibility notification. | String | Yes (initial value: left empty) |
| jsComponentName | Component name of the widget. The value is a string with a maximum of 127 bytes. | String | No | | jsComponentName | Component name of the widget. The value is a string with a maximum of 127 bytes. | String | No |
| metaData | Metadata of the widget. This field contains the array of the **customizeData** field. | Object | Yes (initial value: left empty) | | metaData | Metadata of the widget. This field contains the array of the **customizeData** field. | Object | Yes (initial value: left empty) |
| customizeData | Custom information about the widget. | Object array | Yes (initial value: left empty) | | customizeData | Custom information about the widget. | Object array | Yes (initial value: left empty) |
A configuration example is as follows: Example configuration:
```json ```json
"abilities": [{ "abilities": [{
...@@ -197,7 +197,7 @@ Configure the **config.json** file for the widget. ...@@ -197,7 +197,7 @@ Configure the **config.json** file for the widget.
### Persistently Storing Widget Data ### Persistently Storing Widget Data
Mostly, the widget provider is started only when it needs to obtain information about a widget. The Widget Manager supports multi-instance management and uses the widget ID to identify an instance. If the widget provider supports widget data modification, it must persistently store the data based on the widget ID, so that it can access the data of the target widget when obtaining, updating, or starting a widget. A widget provider is usually started when it is needed to provide information about a widget. The Widget Manager supports multi-instance management and uses the widget ID to identify an instance. If the widget provider supports widget data modification, it must persistently store the data based on the widget ID, so that it can access the data of the target widget when obtaining, updating, or starting a widget.
```javascript ```javascript
onCreate(want) { onCreate(want) {
...@@ -219,35 +219,35 @@ Mostly, the widget provider is started only when it needs to obtain information ...@@ -219,35 +219,35 @@ Mostly, the widget provider is started only when it needs to obtain information
} }
``` ```
You should override **onDestroy** to delete widget data. You should override **onDestroy** to implement widget data deletion.
```javascript ```javascript
onDestroy(formId) { onDestroy(formId) {
console.log('FormAbility onDestroy'); console.log('FormAbility onDestroy');
// You need to implement the code for deleting the persistent widget instance. // You need to implement the code for deleting the persistent widget data.
// The deleteFormInfo API is not implemented here. // The deleteFormInfo API is not implemented here.
deleteFormInfo(formId); deleteFormInfo(formId);
} }
``` ```
For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md). For details about how to implement persistence data storage, see [Lightweight Data Store Development](../database/database-preference-guidelines.md).
Note that the **Want** passed by the widget host to the widget provider contains a flag that indicates whether the requested widget is a temporary one. The **Want** passed by the widget host to the widget provider contains a flag that specifies whether the requested widget is normal or temporary.
- Normal widget: a widget that will be persistently used by the widget host - Normal widget: a widget persistently used by the widget host
- Temporary widget: a widget that is temporarily used by the widget host - Temporary widget: a widget temporarily used by the widget host
Data of a temporary widget is not persistently stored. If the widget framework is killed and restarted, data of a temporary widget will be deleted. However, the widget provider is not notified of which widget is deleted, and still keeps the data. Therefore, the widget provider should implement data clearing. In addition, the widget host may convert a temporary widget into a normal one. If the conversion is successful, the widget provider should process the widget ID and store the data persistently. This prevents the widget provider from deleting persistent data when clearing temporary widgets. Data of a temporary widget will be deleted on the Widget Manager if the widget framework is killed and restarted. The widget provider, however, is not notified of the deletion and still keeps the data. Therefore, the widget provider needs to clear the data of temporary widgets proactively if the data has been kept for a long period of time. If the widget host has converted a temporary widget into a normal one, the widget provider should change the widget data from temporary storage to persistent storage. Otherwise, the widget data may be deleted by mistake.
### Updating Widget Data ### Updating Widget Data
When a widget application initiates a data update upon a scheduled or periodic update, the application obtains the latest data and calls **updateForm** to update the widget. The code snippet is as follows: When an application initiates a scheduled or periodic update, the application obtains the latest data and calls **updateForm** to update the widget. The code snippet is as follows:
```javascript ```javascript
onUpdate(formId) { onUpdate(formId) {
// To support scheduled update, periodic update, or update requested by the widget host, override this method for widget data update. // Override this method to support scheduled updates, periodic updates, or updates requested by the widget host.
console.log('FormAbility onUpdate'); console.log('FormAbility onUpdate');
let obj = { let obj = {
"title": "titleOnUpdate", "title": "titleOnUpdate",
...@@ -267,9 +267,9 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme ...@@ -267,9 +267,9 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme
> **NOTE** > **NOTE**
> >
> Currently, only the JavaScript-based web-like development paradigm can be used to develop the widget UI. > Only the JavaScript-based web-like development paradigm is supported when developing the widget UI.
- In the HML file: - HML file:
```html ```html
<div class="container"> <div class="container">
<stack> <stack>
...@@ -284,7 +284,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme ...@@ -284,7 +284,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme
</div> </div>
``` ```
- In the CSS file: - CSS file:
```css ```css
.container { .container {
...@@ -325,7 +325,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme ...@@ -325,7 +325,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme
} }
``` ```
- In the JSON file: - JSON file:
```json ```json
{ {
"data": { "data": {
...@@ -352,18 +352,18 @@ Now you've got a widget shown below. ...@@ -352,18 +352,18 @@ Now you've got a widget shown below.
You can set router and message events for components on a widget. The router event applies to ability redirection, and the message event applies to custom click events. The key steps are as follows: You can set router and message events for components on a widget. The router event applies to ability redirection, and the message event applies to custom click events. The key steps are as follows:
1. Set **onclick** in the HML file to **routerEvent** or **messageEvent**, depending on the **actions** settings in the JSON file. 1. Set the **onclick** field in the HML file to **routerEvent** or **messageEvent**, depending on the **actions** settings in the JSON file.
2. For the router event, set the following attributes: 2. For the router event, set the following attributes:
- **action**: **"router"**. - **action**: **router**, which indicates a router event.
- **abilityName**: target ability name, for example, **com.example.entry.MainAbility**, which is the default main ability name in DevEco Studio for the FA model. - **abilityName**: target ability name, for example, **com.example.entry.MainAbility**, which is the default main ability name in DevEco Studio for the FA model.
- **params**: custom parameters of the target ability. Set them as required. The value can be obtained from **parameters** in **want** used for starting the target ability. For example, in the lifecycle function **onCreate** of the main ability in the FA model, **featureAbility.getWant()** can be used to obtain **want** and its **parameters** field. - **params**: custom parameters of the target ability. Set them as required. The value can be obtained from **parameters** in **want** used for starting the target ability. For example, in the lifecycle function **onCreate** of the main ability in the FA model, **featureAbility.getWant()** can be used to obtain **want** and its **parameters** field.
3. For the message event, set the following attributes: 3. For the message event, set the following attributes:
- **action**: **"message"**. - **action**: **message**, which indicates a message event.
- **params**: custom parameters of the message event. Set them as required. The value can be obtained from **message** in the widget lifecycle function **onEvent**. - **params**: custom parameters of the message event. Set them as required. The value can be obtained from **message** in the widget lifecycle function **onEvent**.
The code snippet is as follows: The code snippet is as follows:
- In the HML file: - HML file:
```html ```html
<div class="container"> <div class="container">
<stack> <stack>
...@@ -378,7 +378,7 @@ The code snippet is as follows: ...@@ -378,7 +378,7 @@ The code snippet is as follows:
</div> </div>
``` ```
- In the JSON file: - JSON file:
```json ```json
{ {
"data": { "data": {
......
...@@ -8,19 +8,19 @@ During the compilation, select a build form factor based on the site requirement ...@@ -8,19 +8,19 @@ During the compilation, select a build form factor based on the site requirement
| Build Form Factor | Development Board| Main Chip| Kernel| System Type| | Build Form Factor | Development Board| Main Chip| Kernel| System Type|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| [neptune100](https://gitee.com/openharmony/vendor_hihope/blob/master/neptune_iotlink_demo/config.json) | neptune100 | WinnerMicro | LiteOS-M | Mini | | [neptune100](https://gitee.com/openharmony/vendor_hihope/blob/master/neptune_iotlink_demo/config.json) | neptune100 | WinnerMicro | LiteOS-M | Mini |
| [rk3568](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/config.json) | rk3568 | Rockchip | Linux | standard | | [rk3568](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/config.json) | rk3568 | Rockchip | Linux | Standard |
| [rk3568_Mini_system](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568_Mini_system/config.json) | rk3568 | Rockchip | Linux | Standard | | [rk3568_mini_system](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568_mini_system/config.json) | rk3568 | Rockchip | Linux | Standard |
| [bearpi_hm_micro](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_micro/config.json) | bearpi_hm_micro | STM32MP1xx | LiteOS-A | small | | [bearpi_hm_micro](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_micro/config.json) | bearpi_hm_micro | STM32MP1xx | LiteOS-A | small |
| [bearpi_hm_nano](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_nano/config.json) | bearpi_hm_nano | Hi3861V100 | LiteOS-M | Mini | | [bearpi_hm_nano](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_nano/config.json) | bearpi_hm_nano | Hi3861V100 | LiteOS-M | Mini |
| [wifiiot_hispark_pegasus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus/config.json) | hispark_pegasus | Hi3861V100 | LiteOS-M | Mini | | [wifiiot_hispark_pegasus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus/config.json) | hispark_pegasus | Hi3861V100 | LiteOS-M | Mini |
| [ipcamera_hispark_aries](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_aries/config.json) | hispark_aries | Hi3518EV300 | LiteOS-A | Small | | [ipcamera_hispark_aries](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_aries/config.json) | hispark_aries | Hi3518EV300 | LiteOS-A | Small |
| [ipcamera_hispark_taurus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus/config.json) | hispark_taurus | Hi3516DV300 | LiteOS-A | Small | | [ipcamera_hispark_taurus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus/config.json) | hispark_taurus | Hi3516DV300 | LiteOS-A | Small |
| [ipcamera_hispark_taurus_Linux](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_Linux/config.json) | hispark_taurus | Hi3516DV300 | Linux | Small | | [ipcamera_hispark_taurus_linux](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_linux/config.json) | hispark_taurus | Hi3516DV300 | Linux | Small |
| [hispark_taurus_Standard](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_Standard/config.json) | hispark_taurus | Hi3516DV300 | Linux | Standard | | [hispark_taurus_standard](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_standard/config.json) | hispark_taurus | Hi3516DV300 | Linux | Standard |
| [watchos](https://gitee.com/openharmony/vendor_hisilicon/blob/master/watchos/config.json) | hispark_taurus | Hi3516DV300 | Linux | Standard | | [watchos](https://gitee.com/openharmony/vendor_hisilicon/blob/master/watchos/config.json) | hispark_taurus | Hi3516DV300 | Linux | Standard |
| [hispark_phoenix](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_phoenix/config.json) | hispark_phoenix | Hi3751V350 | Linux | Standard | | [hispark_phoenix](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_phoenix/config.json) | hispark_phoenix | Hi3751V350 | Linux | Standard |
| [hispark_taurus_Mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_Mini_system/config.json) | hispark_taurus | Hi3516DV300 | LiteOS-A | Mini | | [hispark_taurus_mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_mini_system/config.json) | hispark_taurus | Hi3516DV300 | LiteOS-A | Mini |
| [hispark_pegasus_Mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus_Mini_system/config.json) | hispark_pegasus | Hi3861V100 | LiteOS-M | Mini | | [hispark_pegasus_mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus_mini_system/config.json) | hispark_pegasus | Hi3861V100 | LiteOS-M | Mini |
| [gr5515_sk_iotlink_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_iotlink_demo/config.json) | gr5515_sk | GR551x | LiteOS-M | Mini | | [gr5515_sk_iotlink_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_iotlink_demo/config.json) | gr5515_sk | GR551x | LiteOS-M | Mini |
| [gr5515_sk_xts_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_xts_demo/config.json) | gr5515_sk | GR551x | LiteOS-M | Mini | | [gr5515_sk_xts_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_xts_demo/config.json) | gr5515_sk | GR551x | LiteOS-M | Mini |
| [wifi_demo](https://gitee.com/openharmony/vendor_asrmicro/blob/master/wifi_demo/config.json) | dev_wifi_a | ASR582X | LiteOS-M | Mini | | [wifi_demo](https://gitee.com/openharmony/vendor_asrmicro/blob/master/wifi_demo/config.json) | dev_wifi_a | ASR582X | LiteOS-M | Mini |
...@@ -28,17 +28,17 @@ During the compilation, select a build form factor based on the site requirement ...@@ -28,17 +28,17 @@ During the compilation, select a build form factor based on the site requirement
| [display_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/display_demo/config.json) | v200zr | BES2600 | LiteOS-M | Mini | | [display_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/display_demo/config.json) | v200zr | BES2600 | LiteOS-M | Mini |
| [xts_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/xts_demo/config.json) | v200zr | BES2600 | LiteOS-M | Mini | | [xts_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/xts_demo/config.json) | v200zr | BES2600 | LiteOS-M | Mini |
| [iotlink_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/iotlink_demo/config.json) | v200zr | BES2600 | LiteOS-M | Mini | | [iotlink_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/iotlink_demo/config.json) | v200zr | BES2600 | LiteOS-M | Mini |
| [Mini_distributed_music_player](https://gitee.com/openharmony/vendor_bestechnic/blob/master/Mini_distributed_music_player/config.json) | v200zr | BES2600 | LiteOS-M | Mini | | [mini_distributed_music_player](https://gitee.com/openharmony/vendor_bestechnic/blob/master/mini_distributed_music_player/config.json) | v200zr | BES2600 | LiteOS-M | Mini |
| [niobe407](https://gitee.com/openharmony/vendor_talkweb/blob/master/niobe407/config.json) | niobe407 | STM32F4xx | LiteOS-M | Mini | | [niobe407](https://gitee.com/openharmony/vendor_talkweb/blob/master/niobe407/config.json) | niobe407 | STM32F4xx | LiteOS-M | Mini |
| [QEMU_Mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/QEMU_Mini_system_demo/config.json) | arm_mps2_an386 | QEMU | LiteOS-M | Mini | | [qemu_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_mini_system_demo/config.json) | arm_mps2_an386 | QEMU | LiteOS-M | Mini |
| [QEMU_csky_Mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/QEMU_csky_Mini_system_demo/config.json) | SmartL_E802 | QEMU | LiteOS-M | Mini | | [qemu_csky_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_csky_mini_system_demo/config.json) | SmartL_E802 | QEMU | LiteOS-M | Mini |
| [QEMU_cm55_Mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/QEMU_cm55_Mini_system_demo/config.json) | arm_mps3_an547 | QEMU | LiteOS-M | Mini | | [qemu_cm55_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_cm55_mini_system_demo/config.json) | arm_mps3_an547 | QEMU | LiteOS-M | Mini |
| [QEMU_xtensa_Mini_system_demo](https://gitee.com/Rockchip/vendor_ohemu/blob/master/QEMU_xtensa_Mini_system_demo/config.json) | esp32 | QEMU | LiteOS-M | Mini | | [qemu_xtensa_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_xtensa_mini_system_demo/config.json) | esp32 | QEMU | LiteOS-M | Mini |
| [QEMU_riscv_Mini_system_demo](https://gitee.com/Rockchip/vendor_ohemu/blob/master/QEMU_riscv32_Mini_system_demo/config.json) | ricsv32_virt | QEMU | LiteOS-M | Mini | | [qemu_riscv_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_riscv32_mini_system_demo/config.json) | ricsv32_virt | QEMU | LiteOS-M | Mini |
| [QEMU_ca7_Mini_system_demo](https://gitee.com/Rockchip/vendor_ohemu/blob/master/QEMU_ca7_Mini_system_demo/config.json) | arm_virt | QEMU | LiteOS-A | Small | | [qemu_ca7_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_ca7_mini_system_demo/config.json) | arm_virt | QEMU | LiteOS-A | Small |
| [QEMU_Small_system_demo](https://gitee.com/Rockchip/vendor_ohemu/blob/master/QEMU_Small_system_demo/config.json) | arm_virt | QEMU | LiteOS-A | Small | | [qemu_small_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_small_system_demo/config.json) | arm_virt | QEMU | LiteOS-A | Small |
| [QEMU_arm_Linux_min](https://gitee.com/Rockchip/vendor_ohemu/blob/master/QEMU_arm_Linux_min/config.json) | QEMU-arm-Linux | QEMU | Linux | Standard | | [qemu_arm_inux_min](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_min/config.json) | qemu-arm-linux | QEMU | Linux | Standard |
| [QEMU_arm_Linux_headless](https://gitee.com/Rockchip/vendor_ohemu/blob/master/QEMU_arm_Linux_headless/config.json) | QEMU-arm-Linux | QEMU | Linux | Standard | | [qemu_arm_linux_headless](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_headless/config.json) | qemu-arm-linux | QEMU | Linux | Standard |
| [iotlink_demo](https://gitee.com/Rockchip/vendor_Chipsea/blob/master/iotlink_demo/config.json) | cst85_wblink | Chipsea | LiteOS-M | Mini | | [iotlink_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/iotlink_demo/config.json) | cst85_wblink | Chipsea | LiteOS-M | Mini |
| [dsoftbus_demo](https://gitee.com/Rockchip/vendor_Chipsea/blob/master/dsoftbus_demo/config.json) | cst85_wblink | Chipsea | LiteOS-M | Mini | | [dsoftbus_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/dsoftbus_demo/config.json) | cst85_wblink | Chipsea | LiteOS-M | Mini |
| [xts_demo](https://gitee.com/Rockchip/vendor_Chipsea/blob/master/xts_demo/config.json) | cst85_wblink | Chipsea | LiteOS-M | Mini | | [xts_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/xts_demo/config.json) | cst85_wblink | Chipsea | LiteOS-M | Mini |
...@@ -115,6 +115,6 @@ Next ...@@ -115,6 +115,6 @@ Next
Congratulations! You have finished all steps! Proceed to develop samples to better familiarize yourself with OpenHarmony development: Congratulations! You have finished all steps! Proceed to develop samples to better familiarize yourself with OpenHarmony development:
- [LED Peripheral Control](guide/device-wlan-led-control.md) - [LED Peripheral Control](../guide/device-wlan-led-control.md)
- [Third-Party SDK Integration](guide/device-wlan-sdk.md) - [Third-Party SDK Integration](../guide/device-wlan-sdk.md)
...@@ -249,6 +249,7 @@ ...@@ -249,6 +249,7 @@
- [@ohos.runningLock (Runninglock锁)](js-apis-runninglock.md) - [@ohos.runningLock (Runninglock锁)](js-apis-runninglock.md)
- [@ohos.sensor (传感器)](js-apis-sensor.md) - [@ohos.sensor (传感器)](js-apis-sensor.md)
- [@ohos.settings (设置数据项名称)](js-apis-settings.md) - [@ohos.settings (设置数据项名称)](js-apis-settings.md)
- [@ohos.systemCapability (系统能力)](js-apis-system-capability.md)
- [@ohos.systemParameterV9 (系统属性)](js-apis-system-parameterV9.md) - [@ohos.systemParameterV9 (系统属性)](js-apis-system-parameterV9.md)
- [@ohos.thermal (热管理)](js-apis-thermal.md) - [@ohos.thermal (热管理)](js-apis-thermal.md)
- [@ohos.update (升级)](js-apis-update.md) - [@ohos.update (升级)](js-apis-update.md)
......
...@@ -46,7 +46,7 @@ SystemCapability.BundleManager.DistributedBundleFramework ...@@ -46,7 +46,7 @@ SystemCapability.BundleManager.DistributedBundleFramework
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 获得的ElementName信息。 | | elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 获得的ElementName信息。 |
| callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | 是 | 程序启动作为入参的回调函数,返回远程基本能力信息。 | | callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | 是 | 程序启动作为入参的回调函数,返回远程基本能力信息。 |
...@@ -75,7 +75,7 @@ SystemCapability.BundleManager.DistributedBundleFramework ...@@ -75,7 +75,7 @@ SystemCapability.BundleManager.DistributedBundleFramework
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | -------------------------------------------- | ---- | ----------------------- | | ----------- | -------------------------------------------- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 获得的ElementName信息。 | | elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 获得的ElementName信息。 |
...@@ -107,7 +107,7 @@ SystemCapability.BundleManager.DistributedBundleFramework ...@@ -107,7 +107,7 @@ SystemCapability.BundleManager.DistributedBundleFramework
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | 是 | ElementName信息,最大数组长度为10。 | | elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | 是 | ElementName信息,最大数组长度为10。 |
| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回远程基本能力信息。 | | callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回远程基本能力信息。 |
...@@ -136,7 +136,7 @@ SystemCapability.BundleManager.DistributedBundleFramework ...@@ -136,7 +136,7 @@ SystemCapability.BundleManager.DistributedBundleFramework
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | --------------------------------------------------- | ---- | ----------------------- | | ------------ | --------------------------------------------------- | ---- | ----------------------- |
| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | 是 | ElementName信息,最大数组长度为10。 | | elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | 是 | ElementName信息,最大数组长度为10。 |
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```js ```ts
import bundle from '@ohos.bundle'; import bundle from '@ohos.bundle';
``` ```
## 权限列表 ## 权限列表
| 权限 | 权限等级 | 描述 | | 权限 | 权限等级 | 描述 |
| ------------------------------------------ | ------------ | ------------------ | |--------------------------------------------|--------------|---------------|
| ohos.permission.GET_BUNDLE_INFO | normal | 查询指定应用信息 | | ohos.permission.GET_BUNDLE_INFO | normal | 查询指定应用信息 |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 | | ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 |
| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 | | ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 |
...@@ -55,7 +55,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -55,7 +55,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let bundleFlags = 0; let bundleFlags = 0;
let userId = 100; let userId = 100;
...@@ -95,7 +95,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -95,7 +95,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let bundleFlags = 0; let bundleFlags = 0;
let userId = 100; let userId = 100;
...@@ -135,7 +135,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -135,7 +135,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let bundleFlags = 0; let bundleFlags = 0;
bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => { bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
...@@ -179,7 +179,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -179,7 +179,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleFlag = 0; let bundleFlag = 0;
let userId = 100; let userId = 100;
bundle.getAllBundleInfo(bundleFlag, userId) bundle.getAllBundleInfo(bundleFlag, userId)
...@@ -211,12 +211,12 @@ SystemCapability.BundleManager.BundleFramework ...@@ -211,12 +211,12 @@ SystemCapability.BundleManager.BundleFramework
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| bundleFlag | BundleFlag | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 | | bundleFlag | BundleFlag | 是 | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 |
| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回所有可用的BundleInfo。 | | callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回所有可用的BundleInfo。 |
**示例:** **示例:**
```js ```ts
let bundleFlag = 0; let bundleFlag = 0;
bundle.getAllBundleInfo(bundleFlag, (err, data) => { bundle.getAllBundleInfo(bundleFlag, (err, data) => {
if (err) { if (err) {
...@@ -247,15 +247,15 @@ SystemCapability.BundleManager.BundleFramework ...@@ -247,15 +247,15 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | |------------|-------------------------------------------------------------------|-----|---------------------------------------------------------------------|
| bundleFlag | BundleFlag | 是 | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 | | bundleFlag | BundleFlag | 是 | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回指定用户下所有包的BundleInfo | callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundle-BundleInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回指定用户下所有包的BundleInfo。 |
| |
**示例:** **示例:**
```js ```ts
let bundleFlag = 0; let bundleFlag = 0;
let userId = 100; let userId = 100;
bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => { bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => {
...@@ -288,8 +288,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -288,8 +288,8 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------- | ---- | --------------------------------------- | | ----------- | ------------- | ---- |---------------------------------------------------------------------|
| bundleName | string | 是 | 要查询的应用程序包名 | | bundleName | string | 是 | 要查询的应用程序包名 |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 |
| options | [BundleOptions](#bundleoptions) | 否 | 包含userid的查询选项。 | | options | [BundleOptions](#bundleoptions) | 否 | 包含userid的查询选项。 |
...@@ -301,7 +301,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -301,7 +301,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let bundleFlags = 1; let bundleFlags = 1;
let options = { let options = {
...@@ -335,14 +335,14 @@ SystemCapability.BundleManager.BundleFramework ...@@ -335,14 +335,14 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | | ----------- | ---------------------------------------------------------- | ---- |---------------------------------------------------------------------|
| bundleName | string | 是 | 需要查询的应用程序包名 | | bundleName | string | 是 | 需要查询的应用程序包名称。 |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 |
| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 是 | 程序启动作为入参的回调函数,返回包信息。 | | callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 是 | 程序启动作为入参的回调函数,返回包信息。 |
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let bundleFlags = 1; let bundleFlags = 1;
bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => { bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => {
...@@ -377,13 +377,13 @@ SystemCapability.BundleManager.BundleFramework ...@@ -377,13 +377,13 @@ SystemCapability.BundleManager.BundleFramework
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | | ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 包名 | | bundleName | string | 是 | 包名 |
| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag |
| options | [BundleOptions](#bundleoptions) | 是 | 包含userid。 | | options | [BundleOptions](#bundleoptions) | 是 | 包含userid。 |
| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 是 | 程序启动作为入参的回调函数,返回包信息。 | | callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 是 | 程序启动作为入参的回调函数,返回包信息。 |
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let bundleFlags = 1; let bundleFlags = 1;
let options = { let options = {
...@@ -473,7 +473,7 @@ bundle.getBundleInstaller((err, data) => { ...@@ -473,7 +473,7 @@ bundle.getBundleInstaller((err, data) => {
} }
}); });
``` ```
## bundle.cleanBundleCacheFiles<sup>deprecated<sup> ## bundle.cleanBundleCacheFiles<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles)替代。
...@@ -514,7 +514,7 @@ bundle.cleanBundleCacheFiles(bundleName, err => { ...@@ -514,7 +514,7 @@ bundle.cleanBundleCacheFiles(bundleName, err => {
}); });
``` ```
## bundle.cleanBundleCacheFiles<sup>deprecated<sup> ## bundle.cleanBundleCacheFiles<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles)替代。
...@@ -558,7 +558,7 @@ bundle.cleanBundleCacheFiles(bundleName).then(()=> { ...@@ -558,7 +558,7 @@ bundle.cleanBundleCacheFiles(bundleName).then(()=> {
}); });
``` ```
## bundle.setApplicationEnabled<sup>deprecated<sup> ## bundle.setApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled)替代。
...@@ -581,8 +581,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -581,8 +581,8 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------- | ---- | ----------------------------------------------- | | ---------- | ------------------- | ---- |--------------------------------|
| bundleName | string | 是 | 应用程序包名称。 | | bundleName | string | 是 | 指示需要启用或禁用的应用程序包名称。 |
| isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false表示禁用。 | | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false表示禁用。 |
| callback | AsyncCallback\<void> | 是 | 回调函数。 | | callback | AsyncCallback\<void> | 是 | 回调函数。 |
...@@ -600,7 +600,7 @@ bundle.setApplicationEnabled(bundleName, false, err => { ...@@ -600,7 +600,7 @@ bundle.setApplicationEnabled(bundleName, false, err => {
}); });
``` ```
## bundle.setApplicationEnabled<sup>deprecated<sup> ## bundle.setApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled)替代。
...@@ -623,8 +623,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -623,8 +623,8 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------- | ---- | ----------------------------------------------- | | ---------- | ------- | ---- |------------------------------|
| bundleName | string | 是 | 应用程序包名称。 | | bundleName | string | 是 | 指示需要启用或禁用的应用程序包名称。 |
| isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 | | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 |
**返回值:** **返回值:**
...@@ -645,7 +645,7 @@ bundleManager.setApplicationEnabled(bundleName, false).then(()=> { ...@@ -645,7 +645,7 @@ bundleManager.setApplicationEnabled(bundleName, false).then(()=> {
}); });
``` ```
## bundle.setAbilityEnabled<sup>deprecated<sup> ## bundle.setAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled)替代。
...@@ -673,7 +673,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -673,7 +673,7 @@ SystemCapability.BundleManager.BundleFramework
| isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 | | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 |
| callback | AsyncCallback\<void> | 是 | 为返回操作结果而调用的回调。 | | callback | AsyncCallback\<void> | 是 | 为返回操作结果而调用的回调。 |
## bundle.setAbilityEnabled<sup>deprecated<sup> ## bundle.setAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled)替代。
...@@ -728,7 +728,7 @@ bundle.getAbilityInfo(want, flag, userId).then((abilityInfo) => { ...@@ -728,7 +728,7 @@ bundle.getAbilityInfo(want, flag, userId).then((abilityInfo) => {
console.error('getAbilityInfo failed. Cause: ' + JSON.stringify(error)); console.error('getAbilityInfo failed. Cause: ' + JSON.stringify(error));
}); });
``` ```
## bundle.getPermissionDef<sup>deprecated<sup> ## bundle.getPermissionDef<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef)替代。
...@@ -768,7 +768,7 @@ bundleManager.getPermissionDef(permission, (err, data) => { ...@@ -768,7 +768,7 @@ bundleManager.getPermissionDef(permission, (err, data) => {
}); });
``` ```
## bundle.getPermissionDef<sup>deprecated<sup> ## bundle.getPermissionDef<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef)替代。
...@@ -842,7 +842,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -842,7 +842,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleFlags = 8; let bundleFlags = 8;
let userId = 100; let userId = 100;
bundle.getAllApplicationInfo(bundleFlags, userId) bundle.getAllApplicationInfo(bundleFlags, userId)
...@@ -879,7 +879,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -879,7 +879,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleFlags = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION; let bundleFlags = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
let userId = 100; let userId = 100;
bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
...@@ -917,7 +917,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -917,7 +917,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleFlags = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION; let bundleFlags = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
bundle.getAllApplicationInfo(bundleFlags, (err, data) => { bundle.getAllApplicationInfo(bundleFlags, (err, data) => {
if (err) { if (err) {
...@@ -944,7 +944,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -944,7 +944,7 @@ SystemCapability.BundleManager.BundleFramework
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------ | | ---------- | ------ | ---- | ------------ |
| hapFilePath | string | 是 | HAP存放路径。路径应指向当前应用程序的数据目录的相对目录。 | | hapFilePath | string | 是 | HAP存放路径。支持当前应用程序的绝对路径和数据目录沙箱路径。 |
| bundleFlags | number | 是 | 用于指定要返回的BundleInfo对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 | | bundleFlags | number | 是 | 用于指定要返回的BundleInfo对象中包含信息的标记。取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 |
**返回值:** **返回值:**
...@@ -954,7 +954,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -954,7 +954,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let hapFilePath = "/data/storage/el2/base/test.hap"; let hapFilePath = "/data/storage/el2/base/test.hap";
let bundleFlags = 0; let bundleFlags = 0;
bundle.getBundleArchiveInfo(hapFilePath, bundleFlags) bundle.getBundleArchiveInfo(hapFilePath, bundleFlags)
...@@ -987,7 +987,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -987,7 +987,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let hapFilePath = "/data/storage/el2/base/test.hap"; let hapFilePath = "/data/storage/el2/base/test.hap";
let bundleFlags = 0; let bundleFlags = 0;
bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => { bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
...@@ -1020,8 +1020,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1020,8 +1020,8 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ---------------- | | ----------- | ------ | ---- |------------|
| bundleName | string | 是 | 应用程序包名 | | bundleName | string | 是 | 应用程序包名称。 |
| abilityName | string | 是 | Ability组件名称。 | | abilityName | string | 是 | Ability组件名称。 |
**返回值:** **返回值:**
...@@ -1032,7 +1032,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1032,7 +1032,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility"; let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName) bundle.getAbilityInfo(bundleName, abilityName)
...@@ -1049,7 +1049,7 @@ bundle.getAbilityInfo(bundleName, abilityName) ...@@ -1049,7 +1049,7 @@ bundle.getAbilityInfo(bundleName, abilityName)
getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void; getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void;
通过包名称和ability名称获取Ability信息,使用callback形式返回结果。 通过包名称和组件名获取Ability组件信息,使用callback形式返回结果。
**需要权限:** **需要权限:**
...@@ -1063,14 +1063,14 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1063,14 +1063,14 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------ | ---- | ---------------- | | ----------- | ------------ | ---- |----------------------------|
| bundleName | string | 是 | 应用程序包名 | | bundleName | string | 是 | 应用程序包名称。 |
| abilityName | string | 是 | Ability名称。 | | abilityName | string | 是 | Ability名称。 |
| callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | 是 | 程序启动作为入参的回调函数,返回Ability信息。 | | callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | 是 | 程序启动作为入参的回调函数,返回Ability信息。 |
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility"; let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName, (err, data) => { bundle.getAbilityInfo(bundleName, abilityName, (err, data) => {
...@@ -1082,7 +1082,7 @@ bundle.getAbilityInfo(bundleName, abilityName, (err, data) => { ...@@ -1082,7 +1082,7 @@ bundle.getAbilityInfo(bundleName, abilityName, (err, data) => {
}) })
``` ```
## bundle.getAbilityLabel<sup>deprecated<sup> ## bundle.getAbilityLabel<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel)替代。
...@@ -1102,8 +1102,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1102,8 +1102,8 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ---------------- | |-------------|--------|-----|------------|
| bundleName | string | 是 | 应用程序包名。 | | bundleName | string | 是 | 应用程序包名称。 |
| abilityName | string | 是 | Ability名称。 | | abilityName | string | 是 | Ability名称。 |
**返回值:** **返回值:**
...@@ -1114,7 +1114,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1114,7 +1114,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility"; let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityLabel(bundleName, abilityName) bundle.getAbilityLabel(bundleName, abilityName)
...@@ -1125,13 +1125,13 @@ bundle.getAbilityLabel(bundleName, abilityName) ...@@ -1125,13 +1125,13 @@ bundle.getAbilityLabel(bundleName, abilityName)
}) })
``` ```
## bundle.getAbilityLabel<sup>deprecated<sup> ## bundle.getAbilityLabel<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel)替代。
getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\<string>): void getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\<string>): void
通过包名称和abilityName获取应用名称,使用callback形式返回结果。 通过包名称和Ability组件名获取应用名称,使用callback形式返回结果。
**需要权限:** **需要权限:**
...@@ -1145,14 +1145,14 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1145,14 +1145,14 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ---------------------- | ---- | ---------------- | |-------------|------------------------|-----|-------------------------|
| bundleName | string | 是 | 应用程序包名。 | | bundleName | string | 是 | 应用程序包名称。 |
| abilityName | string | 是 | Ability名称。 | | abilityName | string | 是 | Ability名称。 |
| callback | AsyncCallback\<string> | 是 | 程序启动作为入参的回调函数,返回应用名称信息。 | | callback | AsyncCallback\<string> | 是 | 程序启动作为入参的回调函数,返回应用名称信息。 |
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility"; let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityLabel(bundleName, abilityName, (err, data) => { bundle.getAbilityLabel(bundleName, abilityName, (err, data) => {
...@@ -1164,7 +1164,7 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => { ...@@ -1164,7 +1164,7 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => {
}) })
``` ```
## bundle.isAbilityEnabled<sup>deprecated<sup> ## bundle.isAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled)替代。
...@@ -1190,7 +1190,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1190,7 +1190,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility"; let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
...@@ -1202,7 +1202,7 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{ ...@@ -1202,7 +1202,7 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
}) })
``` ```
## bundle.isAbilityEnabled<sup>deprecated<sup> ## bundle.isAbilityEnabled<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled)替代。
...@@ -1223,7 +1223,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1223,7 +1223,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility"; let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
...@@ -1237,7 +1237,7 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{ ...@@ -1237,7 +1237,7 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
}) })
``` ```
## bundle.isApplicationEnabled<sup>deprecated<sup> ## bundle.isApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled)替代。
...@@ -1263,7 +1263,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1263,7 +1263,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
bundle.isApplicationEnabled(bundleName) bundle.isApplicationEnabled(bundleName)
.then((data) => { .then((data) => {
...@@ -1273,7 +1273,7 @@ bundle.isApplicationEnabled(bundleName) ...@@ -1273,7 +1273,7 @@ bundle.isApplicationEnabled(bundleName)
}) })
``` ```
## bundle.isApplicationEnabled<sup>deprecated<sup> ## bundle.isApplicationEnabled<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled)替代。
...@@ -1294,7 +1294,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1294,7 +1294,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
bundle.isApplicationEnabled(bundleName, (err, data) => { bundle.isApplicationEnabled(bundleName, (err, data) => {
if (err) { if (err) {
...@@ -1338,7 +1338,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1338,7 +1338,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleFlags = 0; let bundleFlags = 0;
let userId = 100; let userId = 100;
let want = { let want = {
...@@ -1375,15 +1375,15 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1375,15 +1375,15 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | |-------------|---------------------------------------------------------------------|-----|-------------------------------------------------------------------------|
| want | [Want](js-apis-application-Want.md) | 是 | 指示包含要查询的应用程序包名称的意图。 | | want | [Want](js-apis-application-Want.md) | 是 | 指示包含要查询的应用程序包名称的意图。 |
| bundleFlags | number | 是 | 用于指定返回abilityInfo信息。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中Ability信息相关flag。 | | bundleFlags | number | 是 | 用于指定返回abilityInfo信息。取值范围:参考[BundleFlag说明](#bundleflag)中Ability信息相关flag。 |
| userId | number | 是 | 用户ID。取值范围:大于等于0。 | | userId | number | 是 | 用户ID。取值范围:大于等于0。 |
| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回Ability信息。 | | callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回Ability信息。 |
**示例:** **示例:**
```js ```ts
let bundleFlags = 0; let bundleFlags = 0;
let userId = 100; let userId = 100;
let want = { let want = {
...@@ -1419,14 +1419,14 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1419,14 +1419,14 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | |-------------|---------------------------------------------------------------------|-----|-------------------------------------------------------------------------|
| want | [Want](js-apis-application-Want.md) | 是 | 指示包含要查询的应用程序包名称的意图。 | | want | [Want](js-apis-application-Want.md) | 是 | 指示包含要查询的应用程序包名称的意图。 |
| bundleFlags | number | 是 | 用于指定返回abilityInfo信息。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中Ability信息相关flag。 | | bundleFlags | number | 是 | 用于指定返回abilityInfo信息。取值范围:参考[BundleFlag说明](#bundleflag)中Ability信息相关flag。 |
| callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回Ability信息。 | | callback | AsyncCallback<Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回Ability信息。 |
**示例:** **示例:**
```js ```ts
let bundleFlags = 0; let bundleFlags = 0;
let want = { let want = {
bundleName : "com.example.myapplication", bundleName : "com.example.myapplication",
...@@ -1472,7 +1472,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1472,7 +1472,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
bundle.getLaunchWantForBundle(bundleName) bundle.getLaunchWantForBundle(bundleName)
.then((data) => { .then((data) => {
...@@ -1507,7 +1507,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1507,7 +1507,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
bundle.getLaunchWantForBundle(bundleName, (err, data) => { bundle.getLaunchWantForBundle(bundleName, (err, data) => {
if (err) { if (err) {
...@@ -1519,7 +1519,7 @@ bundle.getLaunchWantForBundle(bundleName, (err, data) => { ...@@ -1519,7 +1519,7 @@ bundle.getLaunchWantForBundle(bundleName, (err, data) => {
``` ```
## bundle.getNameForUid<sup>deprecated<sup> ## bundle.getNameForUid<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid)替代。
...@@ -1540,11 +1540,11 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1540,11 +1540,11 @@ SystemCapability.BundleManager.BundleFramework
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------- | --------------------------------- | | ---------------- | --------------------------------- |
| Promise\<string> | 返回值为Promise对象,Promise中包含指定uid的包名。 | | Promise\<string> | 返回值为Promise对象,Promise中包含指定uid的包名。 |
**示例:** **示例:**
```js ```ts
let uid = 20010005; let uid = 20010005;
bundle.getNameForUid(uid) bundle.getNameForUid(uid)
.then((data) => { .then((data) => {
...@@ -1554,7 +1554,7 @@ bundle.getNameForUid(uid) ...@@ -1554,7 +1554,7 @@ bundle.getNameForUid(uid)
}) })
``` ```
## bundle.getNameForUid<sup>deprecated<sup> ## bundle.getNameForUid<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid)替代。
...@@ -1569,13 +1569,13 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1569,13 +1569,13 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ----------------------------------------------- | |----------|------------------------|-----|----------------------------|
| uid | number | 是 | 要查询的uid。 | | uid | number | 是 | 要查询的uid。 |
| callback | AsyncCallback\<string> | 是 | 程序启动作为入参的回调函数,返回指定uid的包名。 | | callback | AsyncCallback\<string> | 是 | 程序启动作为入参的回调函数,返回指定uid的包名。 |
**示例:** **示例:**
```js ```ts
let uid = 20010005; let uid = 20010005;
bundle.getNameForUid(uid, (err, data) => { bundle.getNameForUid(uid, (err, data) => {
if (err) { if (err) {
...@@ -1587,7 +1587,7 @@ bundle.getNameForUid(uid, (err, data) => { ...@@ -1587,7 +1587,7 @@ bundle.getNameForUid(uid, (err, data) => {
``` ```
## bundle.getAbilityIcon<sup>deprecated<sup> ## bundle.getAbilityIcon<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon)替代。
...@@ -1607,9 +1607,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1607,9 +1607,9 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | --------------------- | | ----------- | ------ | ---- |-----------------|
| bundleName | string | 是 | 要查询的bundleName。 | | bundleName | string | 是 | 要查询的应用包名。 |
| abilityName | string | 是 | 要查询的abilityName。 | | abilityName | string | 是 | 要查询的Ability组件名。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
...@@ -1618,7 +1618,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1618,7 +1618,7 @@ SystemCapability.BundleManager.BundleFramework
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility"; let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityIcon(bundleName, abilityName) bundle.getAbilityIcon(bundleName, abilityName)
...@@ -1629,7 +1629,7 @@ bundle.getAbilityIcon(bundleName, abilityName) ...@@ -1629,7 +1629,7 @@ bundle.getAbilityIcon(bundleName, abilityName)
}) })
``` ```
## bundle.getAbilityIcon<sup>deprecated<sup> ## bundle.getAbilityIcon<sup>8+</sup> <sup>deprecated<sup>
> 从API version 9开始不再维护,建议使用[bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon)替代。 > 从API version 9开始不再维护,建议使用[bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon)替代。
...@@ -1650,14 +1650,14 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1650,14 +1650,14 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | ---------------------------------------- | | ----------- | ---------------------------------------- | ---- |-------------------------------------------------|
| bundleName | string | 是 | 要查询的应用包名 | | bundleName | string | 是 | 要查询的应用包名称。 |
| abilityName | string | 是 | 要查询的Ability组件名。 | | abilityName | string | 是 | 要查询的Ability组件名。 |
| callback | AsyncCallback\<image.PixelMap> | 是 | 程序启动作为入参的回调函数,返回指定[PixelMap](js-apis-image.md)。 | | callback | AsyncCallback\<image.PixelMap> | 是 | 程序启动作为入参的回调函数,返回指定[PixelMap](js-apis-image.md)。 |
**示例:** **示例:**
```js ```ts
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility"; let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { bundle.getAbilityIcon(bundleName, abilityName, (err, data) => {
...@@ -1731,7 +1731,7 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { ...@@ -1731,7 +1731,7 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => {
**系统能力:** SystemCapability.BundleManager.BundleFramework **系统能力:** SystemCapability.BundleManager.BundleFramework
| 参数名 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ---- | ---- | ----------------------------------------------------- | | ------ | ------ | ---- | ---- | ----------------------------------------------------- |
| userId | number | 是 | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | | userId | number | 是 | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
...@@ -1743,7 +1743,7 @@ Ability组件类型。 ...@@ -1743,7 +1743,7 @@ Ability组件类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 参数名 | 类型 | 说明 | | 名称 | 值 | 说明 |
| ------- | ---- | --------------------------- | | ------- | ---- | --------------------------- |
| UNKNOWN | 无 | 未知Ability类型 | | UNKNOWN | 无 | 未知Ability类型 |
| PAGE | 无 | 表示基于Page模板开发的FA,用于提供与用户交互的能力 | | PAGE | 无 | 表示基于Page模板开发的FA,用于提供与用户交互的能力 |
...@@ -1758,7 +1758,7 @@ Ability组件类型。 ...@@ -1758,7 +1758,7 @@ Ability组件类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 参数名 | 类型 | 说明 | | 名称 | 值 | 说明 |
| ------------- | ---- | ------------------------ | | ------------- | ---- | ------------------------ |
| UNSPECIFIED | 无 | 屏幕方向--不指定 | | UNSPECIFIED | 无 | 屏幕方向--不指定 |
| LANDSCAPE | 无 | 屏幕方向--横屏 | | LANDSCAPE | 无 | 屏幕方向--横屏 |
...@@ -1772,7 +1772,7 @@ Ability组件的启动模式。 ...@@ -1772,7 +1772,7 @@ Ability组件的启动模式。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 参数名 | 类型 | 说明 | | 名称 | 值 | 说明 |
| --------- | ---- | ------------------- | | --------- | ---- | ------------------- |
| SINGLETON | 0 | Ability只有一个实例 | | SINGLETON | 0 | Ability只有一个实例 |
| STANDARD | 1 | Ability有多个实例 | | STANDARD | 1 | Ability有多个实例 |
...@@ -1784,7 +1784,7 @@ Ability组件的子类型。 ...@@ -1784,7 +1784,7 @@ Ability组件的子类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 参数名 | 类型 | 说明 | | 名称 | 值 | 说明 |
| ----------- | ---- | ----------------------------- | | ----------- | ---- | ----------------------------- |
| UNSPECIFIED | 0 | 未定义Ability子类型 | | UNSPECIFIED | 0 | 未定义Ability子类型 |
| CA | 1 | Ability子类型是带有 UI 的服务 | | CA | 1 | Ability子类型是带有 UI 的服务 |
...@@ -1796,7 +1796,7 @@ Ability组件的子类型。 ...@@ -1796,7 +1796,7 @@ Ability组件的子类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 参数名 | 类型 | 说明 | | 名称 | 值 | 说明 |
| ---------- | ---- | -------- | | ---------- | ---- | -------- |
| AUTO_MODE | -1 | 自动模式 | | AUTO_MODE | -1 | 自动模式 |
| DARK_MODE | 0 | 黑色模式 | | DARK_MODE | 0 | 黑色模式 |
...@@ -1811,7 +1811,7 @@ Ability组件的子类型。 ...@@ -1811,7 +1811,7 @@ Ability组件的子类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
| 参数名 | 类型 | 说明 | | 名称 | 值 | 说明 |
| ------------------ | ---- | ------------ | | ------------------ | ---- | ------------ |
| PERMISSION_DENIED | -1 | 拒绝授予权限 | | PERMISSION_DENIED | -1 | 拒绝授予权限 |
| PERMISSION_GRANTED | 0 | 授予权限 | | PERMISSION_GRANTED | 0 | 授予权限 |
...@@ -39,7 +39,7 @@ setDisposedStatus(appId: string, disposedWant: Want): Promise\<void> ...@@ -39,7 +39,7 @@ setDisposedStatus(appId: string, disposedWant: Want): Promise\<void>
| ------------------------- | ------------------ | | ------------------------- | ------------------ |
| Promise\<void> | Promise对象。无返回结果的Promise对象。 | | Promise\<void> | Promise对象。无返回结果的Promise对象。 |
**错误码** **错误码**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md) 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
...@@ -85,7 +85,7 @@ setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\<vo ...@@ -85,7 +85,7 @@ setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\<vo
| disposedWant | Want | 是 | 对应用的处置意图。 | | disposedWant | Want | 是 | 对应用的处置意图。 |
| callback | AsyncCallback\<void> | 是 | 回调函数,当设置处置状态成功,err为undefined,否则为错误对象。 | | callback | AsyncCallback\<void> | 是 | 回调函数,当设置处置状态成功,err为undefined,否则为错误对象。 |
**错误码** **错误码**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md) 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
...@@ -136,7 +136,7 @@ getDisposedStatus(appId: string): Promise\<Want>; ...@@ -136,7 +136,7 @@ getDisposedStatus(appId: string): Promise\<Want>;
| ------------------------- | ------------------ | | ------------------------- | ------------------ |
| Promise\<Want> | Promise对象,返回应用的处置状态。 | | Promise\<Want> | Promise对象,返回应用的处置状态。 |
**错误码** **错误码**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md) 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
...@@ -180,7 +180,7 @@ getDisposedStatus(appId: string, callback: AsyncCallback\<Want>): void; ...@@ -180,7 +180,7 @@ getDisposedStatus(appId: string, callback: AsyncCallback\<Want>): void;
| appId | string | 是 | 要查询的应用的appId<br> appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 | | appId | string | 是 | 要查询的应用的appId<br> appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 |
| callback | AsyncCallback\<Want> | 是 | 回调函数。当获取应用的处置状态成功时,err为undefined,data为获取到的处置状态;否则为错误对象。 | | callback | AsyncCallback\<Want> | 是 | 回调函数。当获取应用的处置状态成功时,err为undefined,data为获取到的处置状态;否则为错误对象。 |
**错误码** **错误码**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md) 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
...@@ -230,7 +230,7 @@ deleteDisposedStatus(appId: string): Promise\<void> ...@@ -230,7 +230,7 @@ deleteDisposedStatus(appId: string): Promise\<void>
| ------------------------- | ------------------ | | ------------------------- | ------------------ |
| Promise\<void> | Promise对象,无返回结果的Promise对象 | | Promise\<void> | Promise对象,无返回结果的Promise对象 |
**错误码** **错误码**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md) 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
...@@ -274,7 +274,7 @@ deleteDisposedStatus(appId: string, callback: AsyncCallback\<void>) : void ...@@ -274,7 +274,7 @@ deleteDisposedStatus(appId: string, callback: AsyncCallback\<void>) : void
| appId | string | 是 | 要查询的应用的appId。<br> appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 | | appId | string | 是 | 要查询的应用的appId。<br> appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 |
| callback | AsyncCallback\<void> | 是 | 回调函数,当设置处置状态成功时,err返回undefined。否则回调函数返回具体错误对象。 | | callback | AsyncCallback\<void> | 是 | 回调函数,当设置处置状态成功时,err返回undefined。否则回调函数返回具体错误对象。 |
**错误码** **错误码**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md) 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
......
...@@ -13,6 +13,26 @@ Buffer对象用于表示固定长度的字节序列,是专门存放二进制数 ...@@ -13,6 +13,26 @@ Buffer对象用于表示固定长度的字节序列,是专门存放二进制数
import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer';
``` ```
## BufferEncoding
表示支持的编码格式字符串。
**系统能力:** SystemCapability.Utils.Lang
| 编码格式 | 说明 |
| ------- | -------------------- |
| ascii | 表示ascii格式。 |
| utf8 | 表示utf8格式。 |
| utf-8 | 表示utf8格式。 |
| utf16le | 表示utf16小端序格式。 |
| ucs2 | 表示utf16小端序格式。 |
| ucs-2 | 表示utf16小端序格式。 |
| base64 | 表示base64格式。 |
| base64url | 表示base64格式。 |
| latin1 | 表示ascii格式。 |
| binary | 表示二进制格式。 |
| hex | 表示十六进制格式。 |
## Buffer ## Buffer
### 属性 ### 属性
...@@ -73,7 +93,7 @@ alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): ...@@ -73,7 +93,7 @@ alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding):
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| size | number | 是 | 指定的Buffer实例长度,单位:字节。 | | size | number | 是 | 指定的Buffer实例长度,单位:字节。 |
| fill | string&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;number | 否 | 预填充的值,默认值: 0 | | fill | string&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;number | 否 | 预填充的值,默认值: 0 |
| encoding | BufferEncoding | 否 | 编码方式(当`fill`为string时,才有意义)。 默认值: 'utf-8' | | encoding | [BufferEncoding](#bufferencoding) | 否 | 编码方式(当`fill`为string时,才有意义)。 默认值: 'utf-8' |
**返回值:** **返回值:**
...@@ -181,7 +201,7 @@ byteLength(string: string | Buffer | TypedArray | DataView | ArrayBuffer | Share ...@@ -181,7 +201,7 @@ byteLength(string: string | Buffer | TypedArray | DataView | ArrayBuffer | Share
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| string | string&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;TypedArray&nbsp;\|&nbsp;DataView&nbsp;\|&nbsp;ArrayBuffer&nbsp;\|&nbsp;SharedArrayBuffer | 是 | 指定字符串。 | | string | string&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;TypedArray&nbsp;\|&nbsp;DataView&nbsp;\|&nbsp;ArrayBuffer&nbsp;\|&nbsp;SharedArrayBuffer | 是 | 指定字符串。 |
| encoding | BufferEncoding | 否 | 编码方式。 默认值: 'utf-8' | | encoding | [BufferEncoding](#bufferencoding) | 否 | 编码方式。 默认值: 'utf-8' |
**返回值:** **返回值:**
...@@ -469,7 +489,7 @@ from(string: String, encoding?: BufferEncoding): Buffer ...@@ -469,7 +489,7 @@ from(string: String, encoding?: BufferEncoding): Buffer
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| string | String | 是 | 字符串 | | string | String | 是 | 字符串 |
| encoding | BufferEncoding | 否 | 编码格式。 默认值: 'utf-8'。 | | encoding | [BufferEncoding](#bufferencoding) | 否 | 编码格式。 默认值: 'utf-8'。 |
**返回值:** **返回值:**
...@@ -739,7 +759,7 @@ fill(value: string | Buffer | Uint8Array | number, offset?: number, end?: number ...@@ -739,7 +759,7 @@ fill(value: string | Buffer | Uint8Array | number, offset?: number, end?: number
| value | string&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;Uint8Array&nbsp;\|&nbsp;number | 是 | 用于填充的值。 | | value | string&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;Uint8Array&nbsp;\|&nbsp;number | 是 | 用于填充的值。 |
| offset | number | 否 | 起始偏移量。 默认值: 0。 | | offset | number | 否 | 起始偏移量。 默认值: 0。 |
| end | number | 否 | 结束偏移量(不包括在内)。 默认值: buf.length。 | | end | number | 否 | 结束偏移量(不包括在内)。 默认值: buf.length。 |
| encoding | BufferEncoding | 否 | 字符编码格式(`value`为string才有意义)。 默认值: 'utf-8'。 | | encoding | [BufferEncoding](#bufferencoding) | 否 | 字符编码格式(`value`为string才有意义)。 默认值: 'utf-8'。 |
**返回值:** **返回值:**
...@@ -785,7 +805,7 @@ includes(value: string | number | Buffer | Uint8Array, byteOffset?: number, enco ...@@ -785,7 +805,7 @@ includes(value: string | number | Buffer | Uint8Array, byteOffset?: number, enco
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 要搜索的内容。 | | value | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 要搜索的内容。 |
| byteOffset | number | 否 | 字节偏移量。 如果为负数,则从末尾开始计算偏移量。 默认值: 0。 | | byteOffset | number | 否 | 字节偏移量。 如果为负数,则从末尾开始计算偏移量。 默认值: 0。 |
| encoding | BufferEncoding | 否 | 字符编码格式。 默认值: 'utf-8'。 | | encoding | [BufferEncoding](#bufferencoding) | 否 | 字符编码格式。 默认值: 'utf-8'。 |
**返回值:** **返回值:**
...@@ -824,7 +844,7 @@ indexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encod ...@@ -824,7 +844,7 @@ indexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encod
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 要搜索的内容。 | | value | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 要搜索的内容。 |
| byteOffset | number | 否 | 字节偏移量。 如果为负数,则从末尾开始计算偏移量。 默认值: 0。 | | byteOffset | number | 否 | 字节偏移量。 如果为负数,则从末尾开始计算偏移量。 默认值: 0。 |
| encoding | BufferEncoding | 否 | 字符编码格式。 默认值: 'utf-8'。 | | encoding | [BufferEncoding](#bufferencoding) | 否 | 字符编码格式。 默认值: 'utf-8'。 |
**返回值:** **返回值:**
...@@ -894,7 +914,7 @@ lastIndexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, e ...@@ -894,7 +914,7 @@ lastIndexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, e
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 要搜索的内容。 | | value | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;Buffer&nbsp;\|&nbsp;Uint8Array | 是 | 要搜索的内容。 |
| byteOffset | number | 否 | 字节偏移量。 如果为负数,则从末尾开始计算偏移量。 默认值: 0。 | | byteOffset | number | 否 | 字节偏移量。 如果为负数,则从末尾开始计算偏移量。 默认值: 0。 |
| encoding | BufferEncoding | 否 | 字符编码格式。 默认值: 'utf-8'。 | | encoding | [BufferEncoding](#bufferencoding) | 否 | 字符编码格式。 默认值: 'utf-8'。 |
**返回值:** **返回值:**
...@@ -2196,7 +2216,7 @@ for (let value of buf1.values()) { ...@@ -2196,7 +2216,7 @@ for (let value of buf1.values()) {
### write ### write
write(str: string, offset?: number, length?: number, encoding?: BufferEncoding): number write(str: string, offset?: number, length?: number, encoding?: string): number
从buf的offset偏移写入指定编码的字符串str,写入的字节长度为length 从buf的offset偏移写入指定编码的字符串str,写入的字节长度为length
...@@ -2209,7 +2229,7 @@ write(str: string, offset?: number, length?: number, encoding?: BufferEncoding): ...@@ -2209,7 +2229,7 @@ write(str: string, offset?: number, length?: number, encoding?: BufferEncoding):
| str | string | 是 | 要写入Buffer的字符串。 | | str | string | 是 | 要写入Buffer的字符串。 |
| offset | number | 否 | 偏移量。 默认值: 0。 | | offset | number | 否 | 偏移量。 默认值: 0。 |
| length | number | 否 | 最大字节长度。 默认值: (buf.length - offset)。| | length | number | 否 | 最大字节长度。 默认值: (buf.length - offset)。|
| encoding | BufferEncoding | 否 | 字符编码。 默认值: 'utf-8'。 | | encoding | string | 否 | 字符编码。 默认值: 'utf-8'。 |
**返回值:** **返回值:**
......
...@@ -25,7 +25,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -25,7 +25,7 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | | --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| bundleFilePaths | Array&lt;string&gt; | 是 | 指示存储hap包的沙箱路径。沙箱路径的获取方法参见[获取应用的沙箱路径](#获取应用的沙箱路径)| | bundleFilePaths | Array&lt;string&gt; | 是 | 指示存储hap包的沙箱路径。沙箱路径的获取方法参见[获取应用的沙箱路径](#获取应用的沙箱路径)|
| param | [InstallParam](#installparamdeprecated) | 是 | 指定安装所需的其他参数。 | | param | [InstallParam](#installparamdeprecated) | 是 | 指定安装所需的其他参数。 |
...@@ -75,7 +75,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -75,7 +75,7 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| bundleName | string | 是 | 包名 | | bundleName | string | 是 | 包名 |
| param | [InstallParam](#installparamdeprecated) | 是 | 指定卸载所需的其他参数。 | | param | [InstallParam](#installparamdeprecated) | 是 | 指定卸载所需的其他参数。 |
...@@ -124,7 +124,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -124,7 +124,7 @@ SystemCapability.BundleManager.BundleFramework
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| bundleName | string | 是 | 应用包名。 | | bundleName | string | 是 | 应用包名。 |
| param | [InstallParam](#installparamdeprecated) | 是 | 指定应用恢复所需的其他参数。 | | param | [InstallParam](#installparamdeprecated) | 是 | 指定应用恢复所需的其他参数。 |
......
...@@ -206,10 +206,6 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo]( ...@@ -206,10 +206,6 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](
| ----------------------------------------------------------- | ------------------------------------- | | ----------------------------------------------------------- | ------------------------------------- |
| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回当前应用的BundleInfo。| | Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回当前应用的BundleInfo。|
**错误码:**
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
**示例:** **示例:**
```ts ```ts
...@@ -241,10 +237,6 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback ...@@ -241,10 +237,6 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback
| bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息。 | | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息。 |
| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的当前应用的BundleInfo;否则为错误对象。 | | callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的当前应用的BundleInfo;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
**示例:** **示例:**
```ts ```ts
...@@ -292,7 +284,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: ...@@ -292,7 +284,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback:
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -364,6 +356,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< ...@@ -364,6 +356,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -419,7 +412,7 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n ...@@ -419,7 +412,7 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | --------------------------------------| | -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -487,7 +480,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use ...@@ -487,7 +480,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | --------------------------------------| | -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -538,6 +531,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal ...@@ -538,6 +531,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | --------------------------------------| | -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -593,7 +587,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use ...@@ -593,7 +587,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -641,7 +635,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A ...@@ -641,7 +635,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | --------------------------------- | | -------- | --------------------------------- |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found. |
**示例:** **示例:**
...@@ -686,6 +680,10 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Arr ...@@ -686,6 +680,10 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback<Arr
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md) 错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------- |
| 17700004 | The specified user ID is not found. |
**示例:** **示例:**
```ts ```ts
...@@ -736,7 +734,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<A ...@@ -736,7 +734,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise<A
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ---------------------------------- | | -------- | ---------------------------------- |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found. |
**示例:** **示例:**
...@@ -781,7 +779,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, call ...@@ -781,7 +779,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, call
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ---------------------------------- | | -------- | ---------------------------------- |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found. |
**示例:** **示例:**
...@@ -826,6 +824,10 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallb ...@@ -826,6 +824,10 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallb
错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md) 错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------- |
| 17700004 | The specified user ID is not found. |
**示例:** **示例:**
```ts ```ts
...@@ -876,7 +878,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr ...@@ -876,7 +878,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ---------------------------------- | | -------- | ---------------------------------- |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found. |
**示例:** **示例:**
...@@ -981,6 +983,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy ...@@ -981,6 +983,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700003 | The specified ability is not found. | | 17700003 | The specified ability is not found. |
| 17700004 | The specified userId is invalid. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
| 17700029 | The specified ability is disabled. | | 17700029 | The specified ability is disabled. |
...@@ -1040,7 +1043,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb ...@@ -1040,7 +1043,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700003 | The specified ability is not found. | | 17700003 | The specified extensionAbility is not found. |
| 17700004 | The specified userId is invalid. | | 17700004 | The specified userId is invalid. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
| 17700029 | The specified ability is disabled. | | 17700029 | The specified ability is disabled. |
...@@ -1170,9 +1173,10 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp ...@@ -1170,9 +1173,10 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md) 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------------------- | | -------- | -------------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700003 | The specified extensionAbility is not found. | | 17700003 | The specified extensionAbility is not found. |
| 17700004 | The specified userId is invalid. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -1499,7 +1503,7 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void; ...@@ -1499,7 +1503,7 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\<void>): void;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700030 | The specified bundleName does not support cleaning cache files. | | 17700030 | The specified bundle does not support clearing of cache files. |
**示例:** **示例:**
...@@ -2029,7 +2033,7 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba ...@@ -2029,7 +2033,7 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | --------------------------------------| | -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -2078,6 +2082,7 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void ...@@ -2078,6 +2082,7 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | --------------------------------------| | -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified user ID is not found |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -2131,7 +2136,7 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>; ...@@ -2131,7 +2136,7 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\<Want>;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | --------------------------------------| | -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -2177,7 +2182,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin ...@@ -2177,7 +2182,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin
| -------- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName is not existed. | | 17700002 | The specified moduleName is not existed. |
| 17700003 | The specified abilityName is not existed. | | 17700003 | The specified abilityName is not existed. |
| 17700024 | The specified metadataName is not existed or the profile is not json-format. | | 17700024 | Failed to get the profile because there is no profile in the HAP. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
| 17700029 | The specified ability is disabled. | | 17700029 | The specified ability is disabled. |
...@@ -2232,7 +2237,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri ...@@ -2232,7 +2237,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri
| -------- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName is not existed. | | 17700002 | The specified moduleName is not existed. |
| 17700003 | The specified abilityName is not existed. | | 17700003 | The specified abilityName is not existed. |
| 17700024 | The specified metadataName is not existed or the profile is not json-format. | | 17700024 | Failed to get the profile because there is no profile in the HAP. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
| 17700029 | The specified ability is disabled. | | 17700029 | The specified ability is disabled. |
...@@ -2280,7 +2285,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m ...@@ -2280,7 +2285,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ | | -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ |
| moduleName | string | 是 | 表示应用程序的moduleName。 | | moduleName | string | 是 | 表示应用程序的moduleName。 |
| extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName。 | | extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName。 |
...@@ -2295,7 +2300,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m ...@@ -2295,7 +2300,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
| -------- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName is not existed. | | 17700002 | The specified moduleName is not existed. |
| 17700003 | The specified extensionAbilityName is not existed. | | 17700003 | The specified extensionAbilityName is not existed. |
| 17700024 | The specified metadataName is not existed or the profile is not json-format. | | 17700024 | Failed to get the profile because there is no profile in the HAP. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -2329,7 +2334,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m ...@@ -2329,7 +2334,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------ | ---- | ---------------------------------- | | -------------------- | ------ | ---- | ---------------------------------- |
| moduleName | string | 是 | 表示应用程序的moduleName。 | | moduleName | string | 是 | 表示应用程序的moduleName。 |
| extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName。 | | extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName。 |
...@@ -2349,7 +2354,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m ...@@ -2349,7 +2354,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m
| -------- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName is not existed. | | 17700002 | The specified moduleName is not existed. |
| 17700003 | The specified extensionAbilityName is not existed. | | 17700003 | The specified extensionAbilityName is not existed. |
| 17700024 | The specified metadataName is not existed or the profile is not json-format. | | 17700024 | Failed to get the profile because there is no profile in the HAP. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -2395,7 +2400,7 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef ...@@ -2395,7 +2400,7 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| permissionName | string | 是 | 表示权限名称。 | | permissionName | string | 是 | 表示权限名称。 |
| callback | AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<PermissionDef>;否则为错误对象。 | | callback | AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\<PermissionDef>;否则为错误对象。 |
...@@ -2440,7 +2445,7 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl ...@@ -2440,7 +2445,7 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------ | ---- | -------------- | | -------------- | ------ | ---- | -------------- |
| permissionName | string | 是 | 表示权限参数名。 | | permissionName | string | 是 | 表示权限参数名。 |
...@@ -2830,7 +2835,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId ...@@ -2830,7 +2835,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified userId is not found. | | 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
...@@ -2881,6 +2886,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [Bund ...@@ -2881,6 +2886,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [Bund
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**示例:** **示例:**
......
...@@ -138,7 +138,7 @@ getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo> ...@@ -138,7 +138,7 @@ getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo>
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 17700004 | The specified user id is not found. | | 17700004 | The specified user ID is not found. |
| 17700023 | The specified default app does not exist. | | 17700023 | The specified default app does not exist. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
...@@ -189,7 +189,7 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<Bun ...@@ -189,7 +189,7 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<Bun
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 17700004 | The specified user id is not found. | | 17700004 | The specified user ID is not found. |
| 17700023 | The specified default app does not exist. | | 17700023 | The specified default app does not exist. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
...@@ -240,7 +240,7 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void ...@@ -240,7 +240,7 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 17700004 | The specified user id is not found. | | 17700004 | The specified user ID is not found. |
| 17700023 | The specified default app does not exist. | | 17700023 | The specified default app does not exist. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
...@@ -304,9 +304,9 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number): ...@@ -304,9 +304,9 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number):
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ---------------------------------------------- | | -------- | ---------------------------------------------- |
| 17700004 | The specified user id is not found. | | 17700004 | The specified user ID is not found. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
| 17700028 | The specified ability and type does not match. | | 17700028 | The specified ability does not match the type. |
**示例:** **示例:**
...@@ -371,9 +371,9 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca ...@@ -371,9 +371,9 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ---------------------------------------------- | | -------- | ---------------------------------------------- |
| 17700004 | The specified user id is not found. | | 17700004 | The specified user ID is not found. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
| 17700028 | The specified ability and type does not match. | | 17700028 | The specified ability does not match the type. |
**示例:** **示例:**
...@@ -431,9 +431,9 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal ...@@ -431,9 +431,9 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ---------------------------------------------- | | -------- | ---------------------------------------------- |
| 17700004 | The specified user id is not found. | | 17700004 | The specified user ID is not found. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
| 17700028 | The specified ability and type does not match. | | 17700028 | The specified ability does not match the type. |
**示例:** **示例:**
...@@ -489,7 +489,7 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void> ...@@ -489,7 +489,7 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void>
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 17700004 | The specified user id is not found. | | 17700004 | The specified user ID is not found. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
**示例:** **示例:**
...@@ -540,7 +540,7 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v ...@@ -540,7 +540,7 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 17700004 | The specified user id is not found. | | 17700004 | The specified user ID is not found. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
**示例:** **示例:**
...@@ -590,7 +590,7 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void; ...@@ -590,7 +590,7 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 17700004 | The specified user id is not found. | | 17700004 | The specified user ID is not found. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
**示例:** **示例:**
......
...@@ -74,7 +74,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -74,7 +74,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 类型 | 必填 | 描述 | | 名称 | 类型 | 必填 | 说明 |
| ---------------------- | ------------------------- | ---- | -------- | | ---------------------- | ------------------------- | ---- | -------- |
| deviceId | string | 是 | 设备的唯一标识。 | | deviceId | string | 是 | 设备的唯一标识。 |
| deviceName | string | 是 | 设备名称。 | | deviceName | string | 是 | 设备名称。 |
...@@ -88,7 +88,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -88,7 +88,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 默认值 | 说明 | | 名称 | 值 | 说明 |
| ------------ | ---- | ---- | | ------------ | ---- | ---- |
| SPEAKER | 0x0A | 智能音箱 | | SPEAKER | 0x0A | 智能音箱 |
| PHONE | 0x0E | 手机 | | PHONE | 0x0E | 手机 |
...@@ -105,7 +105,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -105,7 +105,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 默认值 | 说明 | | 名称 | 值 | 说明 |
| ------- | ---- | --------------- | | ------- | ---- | --------------- |
| ONLINE | 0 | 设备物理上线状态。 | | ONLINE | 0 | 设备物理上线状态。 |
| READY | 1 | 设备可用状态,表示设备间信息已在分布式数据中同步完成, 可以运行分布式业务。 | | READY | 1 | 设备可用状态,表示设备间信息已在分布式数据中同步完成, 可以运行分布式业务。 |
...@@ -118,7 +118,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -118,7 +118,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 类型 | 必填 | 描述 | | 名称 | 类型 | 必填 | 说明 |
| ------------- | --------------------------------- | ---- | ----------------- | | ------------- | --------------------------------- | ---- | ----------------- |
| subscribeId | number | 是 | 发现标识,用于标识不同的发现周期。 | | subscribeId | number | 是 | 发现标识,用于标识不同的发现周期。 |
| mode | [DiscoverMode ](#discovermode) | 否 | 发现模式。 | | mode | [DiscoverMode ](#discovermode) | 否 | 发现模式。 |
...@@ -135,7 +135,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -135,7 +135,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 默认值 | 说明 | | 名称 | 值 | 说明 |
| --------------------- | ---- | ----- | | --------------------- | ---- | ----- |
| DISCOVER_MODE_PASSIVE | 0x55 | 被动模式。 | | DISCOVER_MODE_PASSIVE | 0x55 | 被动模式。 |
| DISCOVER_MODE_ACTIVE | 0xAA | 主动模式。 | | DISCOVER_MODE_ACTIVE | 0xAA | 主动模式。 |
...@@ -147,7 +147,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -147,7 +147,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 默认值 | 说明 | | 名称 | 值 | 说明 |
| ---- | ---- | --------- | | ---- | ---- | --------- |
| AUTO | 0 | 自动发现类型。 | | AUTO | 0 | 自动发现类型。 |
| BLE | 1 | 蓝牙发现类型。 | | BLE | 1 | 蓝牙发现类型。 |
...@@ -160,7 +160,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -160,7 +160,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 默认值 | 说明 | | 名称 | 值 | 说明 |
| ---------- | ---- | ----- | | ---------- | ---- | ----- |
| LOW | 0 | 低频率。 | | LOW | 0 | 低频率。 |
| MID | 1 | 中频率。 | | MID | 1 | 中频率。 |
...@@ -174,7 +174,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -174,7 +174,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 默认值 | 说明 | | 名称 | 值 | 说明 |
| ------------------------- | ---- | -------------- | | ------------------------- | ---- | -------------- |
| SUBSCRIBE_CAPABILITY_DDMP | 0 | DDMP能力,后续会被废弃。 | | SUBSCRIBE_CAPABILITY_DDMP | 0 | DDMP能力,后续会被废弃。 |
| SUBSCRIBE_CAPABILITY_OSD | 1 | OSD能力。 | | SUBSCRIBE_CAPABILITY_OSD | 1 | OSD能力。 |
...@@ -186,10 +186,10 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -186,10 +186,10 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 类型 | 必填 | 描述 | | 名称 | 类型 | 必填 | 说明 |
| --------- | -------------------- | ---- | ---------- | | --------- | -------------------- | ---- | ---------- |
| authType | number | 是 | 认证类型。 | | authType | number | 是 | 认证类型。 |
| extraInfo | {[key:string] : any} | 否 | 认证参数可扩展字段。 | | extraInfo | {[key:string]&nbsp;:&nbsp;any} | 否 | 认证参数可扩展字段。 |
## AuthInfo ## AuthInfo
...@@ -197,19 +197,19 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -197,19 +197,19 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 类型 | 必填 | 描述 | | 名称 | 类型 | 必填 | 说明 |
| --------- | -------------------- | ---- | ---------- | | --------- | -------------------- | ---- | ---------- |
| authType | number | 是 | 认证类型。 | | authType | number | 是 | 认证类型。 |
| token | number | 是 | 认证Token。 | | token | number | 是 | 认证Token。 |
| extraInfo | {[key:string] : any} | 否 | 认证信息可扩展字段。 | | extraInfo | {[key:string]&nbsp;:&nbsp;any} | 否 | 认证信息可扩展字段。 |
## PublishInfo9+</sup> ## PublishInfo<sup>9+</sup>
发布设备参数 发布设备参数
**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager
| 名称 | 类型 | 必填 | 描述 | | 名称 | 类型 | 必填 | 说明 |
| ------------- | --------------------------------- | ---- | ----------------- | | ------------- | --------------------------------- | ---- | ----------------- |
| publishId | number | 是 | 发布设备标识,用于标识不同的发布周期。 | | publishId | number | 是 | 发布设备标识,用于标识不同的发布周期。 |
| mode | [DiscoverMode ](#discovermode) | 是 | 发现模式。 | | mode | [DiscoverMode ](#discovermode) | 是 | 发现模式。 |
...@@ -288,7 +288,7 @@ getTrustedDeviceList(callback:AsyncCallback&lt;Array&lt;DeviceInfo&gt;&gt;): voi ...@@ -288,7 +288,7 @@ getTrustedDeviceList(callback:AsyncCallback&lt;Array&lt;DeviceInfo&gt;&gt;): voi
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | --------------------- | | -------- | ---------------------------------------- | ---- | --------------------- |
| callback | AsyncCallback&lt;Array&lt;[DeviceInfo](#deviceinfo)&gt;&gt; | 是 | 获取所有可信设备列表的回调,返回设备信息。 | | callback | AsyncCallback&lt;Array&lt;[DeviceInfo](#deviceinfo)&gt;&gt; | 是 | 获取所有可信设备列表的回调,返回设备信息。 |
...@@ -390,7 +390,7 @@ getLocalDeviceInfo(callback:AsyncCallback&lt;DeviceInfo&gt;): void ...@@ -390,7 +390,7 @@ getLocalDeviceInfo(callback:AsyncCallback&lt;DeviceInfo&gt;): void
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | --------- | | -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback&lt;[DeviceInfo](#deviceinfo)&gt; | 是 | 获取本地设备信息。 | | callback | AsyncCallback&lt;[DeviceInfo](#deviceinfo)&gt; | 是 | 获取本地设备信息。 |
...@@ -450,7 +450,7 @@ getLocalDeviceInfo(): Promise&lt;DeviceInfo&gt; ...@@ -450,7 +450,7 @@ getLocalDeviceInfo(): Promise&lt;DeviceInfo&gt;
}); });
``` ```
### startDeviceDiscovery8+</sup> ### startDeviceDiscovery<sup>8+</sup>
startDeviceDiscovery(subscribeInfo: SubscribeInfo): void startDeviceDiscovery(subscribeInfo: SubscribeInfo): void
...@@ -460,7 +460,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void ...@@ -460,7 +460,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ----- | | ------------- | ------------------------------- | ---- | ----- |
| subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | 发现信息。| | subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | 发现信息。|
...@@ -494,7 +494,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void ...@@ -494,7 +494,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void
} }
``` ```
### startDeviceDiscovery9+</sup> ### startDeviceDiscovery<sup>9+</sup>
startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void
...@@ -504,7 +504,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void ...@@ -504,7 +504,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ----- | | ------------- | ------------------------------- | ---- | ----- |
| subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | 发现信息。 | | subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | 发现信息。 |
| filterOptions | string | 否 | 发现设备过滤信息。| | filterOptions | string | 否 | 发现设备过滤信息。|
...@@ -558,7 +558,7 @@ stopDeviceDiscovery(subscribeId: number): void ...@@ -558,7 +558,7 @@ stopDeviceDiscovery(subscribeId: number): void
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ----- | | ----------- | ------ | ---- | ----- |
| subscribeId | number | 是 | 发现标识。 | | subscribeId | number | 是 | 发现标识。 |
...@@ -581,7 +581,7 @@ stopDeviceDiscovery(subscribeId: number): void ...@@ -581,7 +581,7 @@ stopDeviceDiscovery(subscribeId: number): void
} }
``` ```
### publishDeviceDiscovery9+</sup> ### publishDeviceDiscovery<sup>9+</sup>
publishDeviceDiscovery(publishInfo: PublishInfo): void publishDeviceDiscovery(publishInfo: PublishInfo): void
...@@ -591,7 +591,7 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void ...@@ -591,7 +591,7 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ----- | | ------------- | ------------------------------- | ---- | ----- |
| publishInfo | [PublishInfo](#publishinfo) | 是 | 发布设备发现信息。 | | publishInfo | [PublishInfo](#publishinfo) | 是 | 发布设备发现信息。 |
...@@ -622,7 +622,7 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void ...@@ -622,7 +622,7 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void
} }
``` ```
### unPublishDeviceDiscovery9+</sup> ### unPublishDeviceDiscovery<sup>9+</sup>
unPublishDeviceDiscovery(publishId: number): void unPublishDeviceDiscovery(publishId: number): void
...@@ -632,7 +632,7 @@ unPublishDeviceDiscovery(publishId: number): void ...@@ -632,7 +632,7 @@ unPublishDeviceDiscovery(publishId: number): void
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | -------- | ---- | ----- | | ----------- | -------- | ---- | ----- |
| publishId | number | 是 | 发布标识。 | | publishId | number | 是 | 发布标识。 |
...@@ -657,7 +657,7 @@ unPublishDeviceDiscovery(publishId: number): void ...@@ -657,7 +657,7 @@ unPublishDeviceDiscovery(publishId: number): void
### authenticateDevice ### authenticateDevice
authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback<{deviceId: string, pinToken ?: number}>): void authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback&lt;{deviceId: string, pinToken ?: number}&gt;): void
认证设备。 认证设备。
...@@ -665,11 +665,11 @@ authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: Async ...@@ -665,11 +665,11 @@ authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: Async
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------- | ---- | ------- | | ---------- | ---------------------------------------- | ---- | ------- |
| deviceInfo | [DeviceInfo](#deviceinfo) | 是 | 设备信息。 | | deviceInfo | [DeviceInfo](#deviceinfo) | 是 | 设备信息。 |
| authParam | [AuthParam](#authparam) | 是 | 认证参数。 | | authParam | [AuthParam](#authparam) | 是 | 认证参数。 |
| callback | AsyncCallback<{ deviceId: string, pinToken ?: number }> | 是 | 认证结果回调。 | | callback | AsyncCallback&lt;{deviceId:&nbsp;string,&nbsp;pinToken&nbsp;?:&nbsp;number}&gt; | 是 | 认证结果回调。 |
**错误码:** **错误码:**
...@@ -717,7 +717,7 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void ...@@ -717,7 +717,7 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ----- | | ---------- | ------------------------- | ---- | ----- |
| deviceInfo | [DeviceInfo](#deviceinfo) | 是 | 设备信息。 | | deviceInfo | [DeviceInfo](#deviceinfo) | 是 | 设备信息。 |
...@@ -741,7 +741,7 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void ...@@ -741,7 +741,7 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void
### verifyAuthInfo ### verifyAuthInfo
verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, level: number}>): void verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback&lt;{deviceId: string, level: number}&gt;): void
验证认证信息。 验证认证信息。
...@@ -749,10 +749,10 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, le ...@@ -749,10 +749,10 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, le
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------- | | -------- | ---------------------------------------- | ---- | ------- |
| authInfo | [AuthInfo](#authinfo) | 是 | 认证信息。 | | authInfo | [AuthInfo](#authinfo) | 是 | 认证信息。 |
| callback | AsyncCallback<{ deviceId: string, level: number }> | 是 | 验证结果回调。 | | callback | AsyncCallback&lt;{deviceId:&nbsp;string,&nbsp;level:&nbsp;number}&gt; | 是 | 验证结果回调。 |
**错误码:** **错误码:**
...@@ -783,7 +783,7 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, le ...@@ -783,7 +783,7 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, le
} }
``` ```
### setUserOperation9+</sup> ### setUserOperation<sup>9+</sup>
setUserOperation(operateAction: number, params: string): void; setUserOperation(operateAction: number, params: string): void;
...@@ -793,7 +793,7 @@ setUserOperation(operateAction: number, params: string): void; ...@@ -793,7 +793,7 @@ setUserOperation(operateAction: number, params: string): void;
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | --------------- | ---- | ------------------- | | ------------- | --------------- | ---- | ------------------- |
| operateAction | number | 是 | 用户操作动作。 | | operateAction | number | 是 | 用户操作动作。 |
| params | string | 是 | 表示用户的输入参数。 | | params | string | 是 | 表示用户的输入参数。 |
...@@ -817,9 +817,9 @@ setUserOperation(operateAction: number, params: string): void; ...@@ -817,9 +817,9 @@ setUserOperation(operateAction: number, params: string): void;
} }
``` ```
### on('uiStateChange')9+</sup> ### on('uiStateChange')<sup>9+</sup>
on(type: 'uiStateChange', callback: Callback<{ param: string}>): void; on(type: 'uiStateChange', callback: Callback&lt;{ param: string}&gt;): void;
ui状态变更回调。 ui状态变更回调。
...@@ -827,10 +827,10 @@ ui状态变更回调。 ...@@ -827,10 +827,10 @@ ui状态变更回调。
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------ |
| type | string | 是 | 注册的设备管理器 ui 状态回调,以便在状态改变时通知应用。 | | type | string | 是 | 注册的设备管理器 ui 状态回调,以便在状态改变时通知应用。 |
| callback | Callback&lt;{&nbsp;param: string}&gt; | 是 | 指示要注册的设备管理器 ui 状态回调,返回ui状态。 | | callback | Callback&lt;{&nbsp;param:&nbsp;string}&gt; | 是 | 指示要注册的设备管理器 ui 状态回调,返回ui状态。 |
**示例:** **示例:**
...@@ -850,9 +850,9 @@ ui状态变更回调。 ...@@ -850,9 +850,9 @@ ui状态变更回调。
} }
``` ```
### off('uiStateChange')9+</sup> ### off('uiStateChange')<sup>9+</sup>
off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void; off(type: 'uiStateChange', callback?: Callback&lt;{ param: string}&gt;): void;
取消ui状态变更回调 取消ui状态变更回调
...@@ -860,10 +860,10 @@ off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void; ...@@ -860,10 +860,10 @@ off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void;
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | ------------------------------ | | -------- | ------------------------------------- | ---- | ------------------------------ |
| type | string | 是 | 取消注册的设备管理器 ui 状态回调。 | | type | string | 是 | 取消注册的设备管理器 ui 状态回调。 |
| callback | Callback&lt;{&nbsp;param: string}&gt; | 是 | 指示要取消注册的设备管理器 ui 状态,返回UI状态。 | | callback | Callback&lt;{&nbsp;param:&nbsp;string}&gt; | 否 | 指示要取消注册的设备管理器 ui 状态,返回UI状态。 |
**示例:** **示例:**
...@@ -885,7 +885,7 @@ on(type: 'deviceStateChange', callback: Callback&lt;{ action: DeviceStateChange ...@@ -885,7 +885,7 @@ on(type: 'deviceStateChange', callback: Callback&lt;{ action: DeviceStateChange
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------ | | -------- | ---------------------------------------- | ---- | ------------------------------ |
| type | string | 是 | 注册设备状态回调,固定为deviceStateChange。 | | type | string | 是 | 注册设备状态回调,固定为deviceStateChange。 |
| callback | Callback&lt;{&nbsp;action:&nbsp;[DeviceStateChangeAction](#devicestatechangeaction),&nbsp;device:&nbsp;[DeviceInfo](#deviceinfo)&nbsp;}&gt; | 是 | 指示要注册的设备状态回调,返回设备状态和设备信息。 | | callback | Callback&lt;{&nbsp;action:&nbsp;[DeviceStateChangeAction](#devicestatechangeaction),&nbsp;device:&nbsp;[DeviceInfo](#deviceinfo)&nbsp;}&gt; | 是 | 指示要注册的设备状态回调,返回设备状态和设备信息。 |
...@@ -912,10 +912,10 @@ off(type: 'deviceStateChange', callback?: Callback&lt;{ action: DeviceStateChang ...@@ -912,10 +912,10 @@ off(type: 'deviceStateChange', callback?: Callback&lt;{ action: DeviceStateChang
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | --------------------------- | | -------- | ---------------------------------------- | ---- | --------------------------- |
| type | string | 是 | 根据应用程序的包名取消注册设备状态回调。 | | type | string | 是 | 根据应用程序的包名取消注册设备状态回调。 |
| callback | Callback&lt;{&nbsp;action:&nbsp;[DeviceStateChangeAction](#devicestatechangeaction),&nbsp;device:&nbsp;[DeviceInfo](#deviceinfo)&nbsp;&nbsp;}&gt; | 是 | 指示要取消注册的设备状态回调,返回设备状态和设备信息。 | | callback | Callback&lt;{&nbsp;action:&nbsp;[DeviceStateChangeAction](#devicestatechangeaction),&nbsp;device:&nbsp;[DeviceInfo](#deviceinfo)&nbsp;}&gt; | 否 | 指示要取消注册的设备状态回调,返回设备状态和设备信息。 |
**示例:** **示例:**
...@@ -939,10 +939,10 @@ on(type: 'deviceFound', callback: Callback&lt;{ subscribeId: number, device: Dev ...@@ -939,10 +939,10 @@ on(type: 'deviceFound', callback: Callback&lt;{ subscribeId: number, device: Dev
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------------- | | -------- | ---------------------------------------- | ---- | -------------------------- |
| type | string | 是 | 注册设备发现回调,以便在发现周边设备时通知应用程序。 | | type | string | 是 | 注册设备发现回调,以便在发现周边设备时通知应用程序。 |
| callback | Callback&lt;{&nbsp;subscribeId: number, device: DeviceInfo&nbsp;}&gt; | 是 | 注册设备发现的回调方法。 | | callback | Callback&lt;{&nbsp;subscribeId:&nbsp;number,&nbsp;device:&nbsp;[DeviceInfo](#deviceinfo)&nbsp;}&gt; | 是 | 注册设备发现的回调方法。 |
**示例:** **示例:**
...@@ -966,10 +966,10 @@ off(type: 'deviceFound', callback?: Callback&lt;{ subscribeId: number, device: D ...@@ -966,10 +966,10 @@ off(type: 'deviceFound', callback?: Callback&lt;{ subscribeId: number, device: D
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | --------------------------- | | -------- | ---------------------------------------- | ---- | --------------------------- |
| type | string | 是 | 取消注册设备发现回调。 | | type | string | 是 | 取消注册设备发现回调。 |
| callback | Callback&lt;{&nbsp;subscribeId: number, device: [DeviceInfo](#deviceinfo)&nbsp;}&gt; | 是 | 指示要取消注册的设备发现回调,返回设备状态和设备信息。 | | callback | Callback&lt;{&nbsp;subscribeId:&nbsp;number,&nbsp;device:&nbsp;[DeviceInfo](#deviceinfo)&nbsp;}&gt; | 否 | 指示要取消注册的设备发现回调,返回设备状态和设备信息。 |
**示例:** **示例:**
...@@ -993,10 +993,10 @@ on(type: 'discoverFail', callback: Callback&lt;{ subscribeId: number, reason: nu ...@@ -993,10 +993,10 @@ on(type: 'discoverFail', callback: Callback&lt;{ subscribeId: number, reason: nu
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------ | | -------- | ---------------------------------------- | ---- | ------------------------------ |
| type | string | 是 | 注册设备发现失败回调,以便在发现周边设备失败时通知应用程序。 | | type | string | 是 | 注册设备发现失败回调,以便在发现周边设备失败时通知应用程序。 |
| callback | Callback&lt;{&nbsp;subscribeId: number, reason: number&nbsp;}&gt; | 是 | 注册设备发现失败的回调方法。 | | callback | Callback&lt;{&nbsp;subscribeId:&nbsp;number,&nbsp;reason:&nbsp;number&nbsp;}&gt; | 是 | 注册设备发现失败的回调方法。 |
**示例:** **示例:**
...@@ -1020,10 +1020,10 @@ off(type: 'discoverFail', callback?: Callback&lt;{ subscribeId: number, reason: ...@@ -1020,10 +1020,10 @@ off(type: 'discoverFail', callback?: Callback&lt;{ subscribeId: number, reason:
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ----------------- | | -------- | ---------------------------------------- | ---- | ----------------- |
| type | string | 是 | 取消注册设备发现失败回调。 | | type | string | 是 | 取消注册设备发现失败回调。 |
| callback | Callback&lt;{&nbsp;subscribeId: number, reason: number&nbsp;}&gt; | 是 | 指示要取消注册的设备发现失败回调。 | | callback | Callback&lt;{&nbsp;subscribeId:&nbsp;number,&nbsp;reason:&nbsp;number&nbsp;}&gt; | 否 | 指示要取消注册的设备发现失败回调。 |
**示例:** **示例:**
...@@ -1037,7 +1037,7 @@ off(type: 'discoverFail', callback?: Callback&lt;{ subscribeId: number, reason: ...@@ -1037,7 +1037,7 @@ off(type: 'discoverFail', callback?: Callback&lt;{ subscribeId: number, reason:
} }
``` ```
### on('publishSuccess')9+</sup> ### on('publishSuccess')<sup>9+</sup>
on(type: 'publishSuccess', callback: Callback&lt;{ publishId: number }&gt;): void on(type: 'publishSuccess', callback: Callback&lt;{ publishId: number }&gt;): void
...@@ -1047,10 +1047,10 @@ on(type: 'publishSuccess', callback: Callback&lt;{ publishId: number }&gt;): voi ...@@ -1047,10 +1047,10 @@ on(type: 'publishSuccess', callback: Callback&lt;{ publishId: number }&gt;): voi
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------------- | | -------- | ---------------------------------------- | ---- | -------------------------- |
| type | string | 是 | 注册发布设备成功回调,以便将发布成功时通知应用程序。 | | type | string | 是 | 注册发布设备成功回调,以便将发布成功时通知应用程序。 |
| callback | Callback&lt;{ publishId: number }&gt; | 是 | 注册设备发布成功的回调方法。 | | callback | Callback&lt;{&nbsp;publishId:&nbsp;number&nbsp;}&gt; | 是 | 注册设备发布成功的回调方法。 |
**示例:** **示例:**
...@@ -1065,7 +1065,7 @@ on(type: 'publishSuccess', callback: Callback&lt;{ publishId: number }&gt;): voi ...@@ -1065,7 +1065,7 @@ on(type: 'publishSuccess', callback: Callback&lt;{ publishId: number }&gt;): voi
} }
``` ```
### off('publishSuccess')9+</sup> ### off('publishSuccess')<sup>9+</sup>
off(type: 'publishSuccess', callback?: Callback&lt;{ publishId: number }&gt;): void off(type: 'publishSuccess', callback?: Callback&lt;{ publishId: number }&gt;): void
...@@ -1075,10 +1075,10 @@ off(type: 'publishSuccess', callback?: Callback&lt;{ publishId: number }&gt;): v ...@@ -1075,10 +1075,10 @@ off(type: 'publishSuccess', callback?: Callback&lt;{ publishId: number }&gt;): v
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | --------------------------- | | -------- | ---------------------------------------- | ---- | --------------------------- |
| type | string | 是 | 取消注册设备发布成功回调。 | | type | string | 是 | 取消注册设备发布成功回调。 |
| callback | Callback&lt;{ publishId: number }&gt; | 是 | 指示要取消注册的设备发布成功回调。 | | callback | Callback&lt;{&nbsp;publishId:&nbsp;number&nbsp;}&gt; | 否 | 指示要取消注册的设备发布成功回调。 |
**示例:** **示例:**
...@@ -1092,7 +1092,7 @@ off(type: 'publishSuccess', callback?: Callback&lt;{ publishId: number }&gt;): v ...@@ -1092,7 +1092,7 @@ off(type: 'publishSuccess', callback?: Callback&lt;{ publishId: number }&gt;): v
} }
``` ```
### on('publishFail')9+</sup> ### on('publishFail')<sup>9+</sup>
on(type: 'publishFail', callback: Callback&lt;{ publishId: number, reason: number }&gt;): void on(type: 'publishFail', callback: Callback&lt;{ publishId: number, reason: number }&gt;): void
...@@ -1102,10 +1102,10 @@ on(type: 'publishFail', callback: Callback&lt;{ publishId: number, reason: numbe ...@@ -1102,10 +1102,10 @@ on(type: 'publishFail', callback: Callback&lt;{ publishId: number, reason: numbe
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------- | ---- | ------------------------------ | | -------- | ----------------------------------------------------- | ---- | ------------------------------ |
| type | string | 是 | 注册设备发布失败回调,以便在发布设备失败时通知应用程序。 | | type | string | 是 | 注册设备发布失败回调,以便在发布设备失败时通知应用程序。 |
| callback | Callback&lt;{ publishId: number, reason: number }&gt; | 是 | 注册设备发布失败的回调方法。 | | callback | Callback&lt;{&nbsp;publishId:&nbsp;number,&nbsp;reason:&nbsp;number&nbsp;}&gt; | 是 | 注册设备发布失败的回调方法。 |
**示例:** **示例:**
...@@ -1119,7 +1119,7 @@ on(type: 'publishFail', callback: Callback&lt;{ publishId: number, reason: numbe ...@@ -1119,7 +1119,7 @@ on(type: 'publishFail', callback: Callback&lt;{ publishId: number, reason: numbe
} }
``` ```
### off('publishFail')9+</sup> ### off('publishFail')<sup>9+</sup>
off(type: 'publishFail', callback?: Callback&lt;{ publishId: number, reason: number }&gt;): void off(type: 'publishFail', callback?: Callback&lt;{ publishId: number, reason: number }&gt;): void
...@@ -1129,10 +1129,10 @@ off(type: 'publishFail', callback?: Callback&lt;{ publishId: number, reason: num ...@@ -1129,10 +1129,10 @@ off(type: 'publishFail', callback?: Callback&lt;{ publishId: number, reason: num
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------- | ---- | ----------------- | | -------- | ----------------------------------------------------- | ---- | ----------------- |
| type | string | 是 | 取消注册设备发布失败回调。 | | type | string | 是 | 取消注册设备发布失败回调。 |
| callback | Callback&lt;{ publishId: number, reason: number }&gt; | 是 | 指示要取消注册设备发布失败回调。 | | callback | Callback&lt;{&nbsp;publishId:&nbsp;number,&nbsp;reason:&nbsp;number&nbsp;}&gt; | 否 | 指示要取消注册设备发布失败回调。 |
**示例:** **示例:**
...@@ -1156,7 +1156,7 @@ on(type: 'serviceDie', callback: () =&gt; void): void ...@@ -1156,7 +1156,7 @@ on(type: 'serviceDie', callback: () =&gt; void): void
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ---------------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------------- |
| type | string | 是 | 注册serviceDie回调,以便在devicemanager服务异常终止时通知应用程序。 | | type | string | 是 | 注册serviceDie回调,以便在devicemanager服务异常终止时通知应用程序。 |
| callback | ()&nbsp;=&gt;&nbsp;void | 是 | 注册serviceDie的回调方法。 | | callback | ()&nbsp;=&gt;&nbsp;void | 是 | 注册serviceDie的回调方法。 |
...@@ -1183,7 +1183,7 @@ off(type: 'serviceDie', callback?: () =&gt; void): void ...@@ -1183,7 +1183,7 @@ off(type: 'serviceDie', callback?: () =&gt; void): void
**参数:** **参数:**
| 名称 | 参数类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ---------------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------------- |
| type | string | 是 | 取消注册serviceDie回调,以便在devicemanager服务异常终止时通知应用程序。 | | type | string | 是 | 取消注册serviceDie回调,以便在devicemanager服务异常终止时通知应用程序。 |
| callback | ()&nbsp;=&gt;&nbsp;void | 否 | 取消注册serviceDie的回调方法。 | | callback | ()&nbsp;=&gt;&nbsp;void | 否 | 取消注册serviceDie的回调方法。 |
......
# DispatchInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
调度信息类
## DispatchInfo
**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.FreeInstall
**系统API:**此接口为系统接口,三方应用不支持调用
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------ | ------ | ---- | ---- | ------------------------ |
| version | string | 是 | 否 | 包含dispatchInfo版本信息 |
| dispatchAPIVersion | string | 是 | 否 | 包含免安装接口版本号 |
...@@ -53,7 +53,7 @@ getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback\<RemoteAb ...@@ -53,7 +53,7 @@ getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback\<RemoteAb
|----------|--------------------------------------| |----------|--------------------------------------|
| 17700001 | The specified bundle name is not found. | | 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. | | 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. | | 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. | | 17700027 | The distributed service is not running. |
**示例:** **示例:**
...@@ -109,7 +109,7 @@ getRemoteAbilityInfo(elementName: ElementName): Promise\<RemoteAbilityInfo>; ...@@ -109,7 +109,7 @@ getRemoteAbilityInfo(elementName: ElementName): Promise\<RemoteAbilityInfo>;
|----------|-------------------------| |----------|-------------------------|
| 17700001 | The specified bundle name is not found. | | 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. | | 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. | | 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. | | 17700027 | The distributed service is not running. |
**示例:** **示例:**
...@@ -158,7 +158,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, callback: AsyncCallback\ ...@@ -158,7 +158,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, callback: AsyncCallback\
|----------|-------------------------| |----------|-------------------------|
| 17700001 | The specified bundle name is not found. | | 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. | | 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. | | 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. | | 17700027 | The distributed service is not running. |
**示例:** **示例:**
...@@ -221,7 +221,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>): Promise\<Array\<RemoteA ...@@ -221,7 +221,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>): Promise\<Array\<RemoteA
|----------|-------------------------| |----------|-------------------------|
| 17700001 | The specified bundle name is not found. | | 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. | | 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. | | 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. | | 17700027 | The distributed service is not running. |
**示例:** **示例:**
...@@ -278,7 +278,7 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCa ...@@ -278,7 +278,7 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCa
|----------|-------------------------| |----------|-------------------------|
| 17700001 | The specified bundle name is not found. | | 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. | | 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. | | 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. | | 17700027 | The distributed service is not running. |
**示例:** **示例:**
...@@ -335,7 +335,7 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise\<RemoteA ...@@ -335,7 +335,7 @@ getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise\<RemoteA
|----------|-------------------------| |----------|-------------------------|
| 17700001 | The specified bundle name is not found. | | 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. | | 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. | | 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. | | 17700027 | The distributed service is not running. |
**示例:** **示例:**
...@@ -385,7 +385,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string, callback ...@@ -385,7 +385,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string, callback
|---------------|-------------------------| |---------------|-------------------------|
| 17700001 | The specified bundle name is not found. | | 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. | | 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. | | 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. | | 17700027 | The distributed service is not running. |
**示例:** **示例:**
...@@ -449,7 +449,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string): Promise ...@@ -449,7 +449,7 @@ getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string): Promise
|----------|-------------------------| |----------|-------------------------|
| 17700001 | The specified bundle name is not found. | | 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. | | 17700003 | The specified ability name is not found. |
| 17700007 | The specified device id is not found. | | 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. | | 17700027 | The distributed service is not running. |
**示例:** **示例:**
......
...@@ -116,14 +116,14 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback: ...@@ -116,14 +116,14 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback:
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md) 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------ | | -------- | ------------------------------------------------------------ |
| 17700004 | The specified userId is not existed. | | 17700004 | The specified user ID is not found. |
| 17700010 | To parse file of config.json or module.json failed. | | 17700010 | Failed to install the HAP because the HAP fails to be parsed. |
| 17700011 | To verify signature failed. | | 17700011 | Failed to install the HAP because the HAP signature fails to be verified. |
| 17700012 | Invalid hap file path or too large file size. | | 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. |
| 17700015 | Multiple haps have inconsistent configured information. | | 17700015 | Failed to install the HAPs because they have different configuration information. |
| 17700016 | No disk space left for installation. | | 17700016 | Failed to install the HAP because of insufficient system disk space. |
| 17700017 | Downgrade installation is prohibited. | | 17700017 | Failed to install the HAP since the version of the HAP to install is too early. |
| 17700101 | The system service is excepted. | | 17700101 | The system service is excepted. |
| 17700103 | I/O operation is failed. | | 17700103 | I/O operation is failed. |
...@@ -181,7 +181,7 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac ...@@ -181,7 +181,7 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ |
| 17700004 | The specified userId is not existed. | | 17700004 | The specified user ID is not found. |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | | 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700101 | The system service is excepted. | | 17700101 | The system service is excepted. |
...@@ -239,7 +239,7 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback& ...@@ -239,7 +239,7 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback&
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 17700004 | The specified userId is not existed. | | 17700004 | The specified user ID is not found. |
**示例:** **示例:**
......
...@@ -27,7 +27,7 @@ getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallba ...@@ -27,7 +27,7 @@ getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallba
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | -------------- | | ---------- | ------ | ---- | -------------- |
| bundleName | string | 是 | 应用程序包名称。 | | bundleName | string | 是 | 应用程序包名称。 |
| userId | number | 是 | 被查询的用户id。| | userId | number | 是 | 被查询的用户id。|
...@@ -78,7 +78,7 @@ getLauncherAbilityInfo(bundleName: string, userId: number) : Promise<Array\<[Lau ...@@ -78,7 +78,7 @@ getLauncherAbilityInfo(bundleName: string, userId: number) : Promise<Array\<[Lau
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | -------------- | | ---------- | ------ | ---- | -------------- |
| bundleName | string | 是 | 应用程序包名称。| | bundleName | string | 是 | 应用程序包名称。|
| userId | number | 是 | 被查询的用户id。 | | userId | number | 是 | 被查询的用户id。 |
...@@ -128,7 +128,7 @@ getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array\<[Launch ...@@ -128,7 +128,7 @@ getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array\<[Launch
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------- | | ------ | ------ | ---- | -------------- |
| userId | number | 是 | 被查询的用户id。 | | userId | number | 是 | 被查询的用户id。 |
...@@ -176,7 +176,7 @@ getAllLauncherAbilityInfo(userId: number) : Promise<Array\<[LauncherAbilityInfo] ...@@ -176,7 +176,7 @@ getAllLauncherAbilityInfo(userId: number) : Promise<Array\<[LauncherAbilityInfo]
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------- | | ------ | ------ | ---- | -------------- |
| userId | number | 是 | 被查询的用户id。 | | userId | number | 是 | 被查询的用户id。 |
...@@ -222,7 +222,7 @@ getShortcutInfo(bundleName :string, callback: AsyncCallback<Array\<[ShortcutInfo ...@@ -222,7 +222,7 @@ getShortcutInfo(bundleName :string, callback: AsyncCallback<Array\<[ShortcutInfo
**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher **系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher
| 参数名 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | -------------- | | ---------- | ------ | ---- | -------------- |
| bundleName | string | 是 | 应用程序包名称。 | | bundleName | string | 是 | 应用程序包名称。 |
...@@ -269,7 +269,7 @@ getShortcutInfo(bundleName : string) : Promise<Array\<[ShortcutInfo](js-apis-bun ...@@ -269,7 +269,7 @@ getShortcutInfo(bundleName : string) : Promise<Array\<[ShortcutInfo](js-apis-bun
**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher **系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher
| 参数名 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | -------------- | | ---------- | ------ | ---- | -------------- |
| bundleName | string | 是 | 应用程序包名称。 | | bundleName | string | 是 | 应用程序包名称。 |
......
...@@ -150,7 +150,7 @@ getFirst(): T ...@@ -150,7 +150,7 @@ getFirst(): T
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
**参数:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
......
# 系统能力
系统能力(SystemCapability,简称SysCap),指操作系统中每一个相对独立的特性。不同的设备对应不同的系统能力集,每个系统能力对应多个接口。开发者可根据系统能力来判断是否可以使用某接口。本模块提供接口可查询系统能力的集合。
> **说明:**
> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口为系统接口。
## 导入模块
```ts
import systemcapability from '@ohos.systemCapability'
```
## systemcapability.querySystemCapabilities
querySystemCapabilities(callback: AsyncCallback<string>): void;
获取系统能力集合的字符串,并调用回调函数。
**系统能力:** SystemCapability.Developtools.Syscap
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<string> | 是 | 回调函数 |
**示例:**
```ts
try {
systemcapability.querySystemCapabilities(function (err, data) {
if (err == undefined) {
console.log("get system capabilities:" + data)
} else {
console.log(" get system capabilities err:" + err.code)
}});
}catch(e){
console.log("get unexpected error: " + e);
}
```
## systemcapability.querySystemCapabilities
querySystemCapabilities(): Promise&lt;string&gt;
获取系统能力的集合。
**系统能力:** SystemCapability.Startup.SystemInfo
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;string&gt; | Promise示例,用于异步获取结果。 |
**示例:**
```ts
try {
var p = systemcapability.querySystemCapabilities();
p.then(function (value) {
console.log("get system capabilities: " + value);
}).catch(function (err) {
console.log("get system capabilities error: " + err.code);
});
}catch(e){
console.log("get unexpected error: " + e);
}
```
> **说明:**
> - 以上接口所返回的system capability集合形式均为编码后的数字字符串形式。
...@@ -30,21 +30,21 @@ constructor() ...@@ -30,21 +30,21 @@ constructor()
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------- | -------------------- | | ---------------------- | -------------------- |
| [FaceAuthManager](#faceauthmanager) | 人脸认证管理器对象 | | [FaceAuthManager](#faceauthmanager) | 人脸认证管理器对象 |
**示例:** **示例:**
```js ```js
import userIAM_faceAuth from '@ohos.userIAM.faceAuth'; import userIAM_faceAuth from '@ohos.userIAM.faceAuth';
let faceAuthManager = new userIAM_faceAuth.FaceAuthManager(); let faceAuthManager = new userIAM_faceAuth.FaceAuthManager();
``` ```
### setSurfaceId ### setSurfaceId
setSurfaceId(surfaceId: string): void; setSurfaceId(surfaceId: string): void;
设置录入流程中人脸预览界面 [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID 该接口仅用于在录入人脸时,设置人脸预览界面 [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID,需要配合[人脸录入接口](./js-apis-osAccount.md#addcredential8)来使用
**系统能力:** SystemCapability.UserIAM.UserAuth.FaceAuth **系统能力:** SystemCapability.UserIAM.UserAuth.FaceAuth
...@@ -56,17 +56,28 @@ setSurfaceId(surfaceId: string): void; ...@@ -56,17 +56,28 @@ setSurfaceId(surfaceId: string): void;
| -------------- | ---------------------------------- | ---- | -------------------------- | | -------------- | ---------------------------------- | ---- | -------------------------- |
| surfaceId | string | 是 | [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID。 | | surfaceId | string | 是 | [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID。 |
以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 12700001 | The operation is failed. |
**示例:** **示例:**
```js ```js
import faceAuth from '@ohos.userIAM.faceAuth'; import userIAM_faceAuth from '@ohos.userIAM.faceAuth';
let surfaceId = "123456"; // 该surfaceId应该从XComponent控件获取,此处仅用作示例。
let manager = new faceAuth.FaceAuthManager(); let surfaceId = "123456";
try { let manager = new userIAM_faceAuth.FaceAuthManager();
try {
manager.setSurfaceId(surfaceId); manager.setSurfaceId(surfaceId);
console.info("set surface id success"); console.info("set surface id success");
} catch (e) { } catch (e) {
console.error("set surface id failed, error = " + e); console.error("set surface id failed, error = " + e);
} }
``` ```
...@@ -12,219 +12,78 @@ ...@@ -12,219 +12,78 @@
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
``` ```
## 完整示例 ## AuthResultInfo<sup>9+</sup>
```js
// API version 9
import userIAM_userAuth from '@ohos.userIAM.userAuth';
export default {
getVersion() {
try {
let version = userIAM_userAuth.getVersion();
console.info("auth version = " + version);
} catch (error) {
console.info("get version failed, error = " + error);
}
},
start() {
console.info("start auth");
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let authType = userIAM_userAuth.UserAuthType.FACE;
let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
try {
let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
auth.on("result", {
callback: (result: userIAM_userAuth.AuthResultInfo) => {
console.log("authV9 result " + result.result);
console.log("authV9 token " + result.token);
console.log("authV9 remainAttempts " + result.remainAttempts);
console.log("authV9 lockoutDuration " + result.lockoutDuration);
}
});
// if need tip
auth.on("tip", {
callback : (result : userIAM_userAuth.TipInfo) => {
switch (result.tip) {
case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT:
// do something;
case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK:
// do something;
// ...
default:
// do others
}
}
});
auth.start();
console.log("authV9 start success");
} catch (error) {
console.log("authV9 error = " + error);
// do error
}
},
getAvailableStatus() {
console.info("start check auth support");
try {
userIAM_userAuth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1);
console.info("current auth trust level is supported");
} catch (error) {
console.info("current auth trust level is not supported, error = " + error);
}
},
cancel() {
console.info("start cancel auth");
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let authType = userIAM_userAuth.UserAuthType.FACE;
let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
try { 表示认证结果信息。
let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
auth.start();
auth.cancel();
console.info("cancel auth success");
} catch (error) {
console.info("cancel auth failed, error = " + error);
}
}
}
```
```js **系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core。
// API version 8
import userIAM_userAuth from '@ohos.userIAM.userAuth';
let auth = new userIAM_userAuth.UserAuth();
export default { | 名称 | 类型 | 必填 | 说明 |
getVersion() { | ------------ | ---------- | ---- | -------------------- |
console.info("start get version"); | result | number | 是 | 认证结果。 |
let version = auth.getVersion(); | token | Uint8Array | 否 | 用户身份认证通过的凭证。 |
console.info("auth version = " + version); | remainAttempts | number | 否 | 剩余的认证操作次数。 |
}, | lockoutDuration | number | 否 | 认证操作的冻结时间。 |
startAuth() { ## TipInfo<sup>9+</sup>
console.info("start auth");
auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => {
try {
console.info("auth onResult result = " + result);
console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo));
if (result == userIAM_userAuth.ResultCode.SUCCESS) {
// 此处添加认证成功逻辑
} else {
// 此处添加认证失败逻辑
}
} catch (e) {
console.info("auth onResult error = " + e);
}
},
onAcquireInfo: (module, acquire, extraInfo) => { 表示认证过程中的提示信息。
try {
console.info("auth onAcquireInfo module = " + module);
console.info("auth onAcquireInfo acquire = " + acquire);
console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo));
} catch (e) {
console.info("auth onAcquireInfo error = " + e);
}
}
});
},
checkAuthSupport() { **系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core。
console.info("start check auth support");
let checkCode = this.auth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1);
if (checkCode == userIAM_userAuth.ResultCode.SUCCESS) {
console.info("check auth support success");
// 此处添加支持指定类型认证的逻辑
} else {
console.error("check auth support fail, code = " + checkCode);
// 此处添加不支持指定类型认证的逻辑
}
},
cancelAuth() { | 名称 | 类型 | 必填 | 说明 |
console.info("start cancel auth"); | ------------ | ---------- | ---- | -------------------- |
// contextId通过auth接口获取 | module | number | 是 | 发送提示信息的模块标识。 |
let contextId = auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { | tip | number | 是 | 认证过程提示信息。 |
onResult: (result, extraInfo) => {
console.info("auth onResult result = " + result);
},
onAcquireInfo: (module, acquire, extraInfo) => { ## EventInfo<sup>9+</sup>
console.info("auth onAcquireInfo module = " + module);
}
});
let cancelCode = this.auth.cancel(contextId);
if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) {
console.info("cancel auth success");
} else {
console.error("cancel auth fail");
}
}
}
```
```js 表示认证过程中事件信息的类型。
// API version 6
import userIAM_userAuth from '@ohos.userIAM.userAuth';
export default { **系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core。
startAuth() {
console.info("start auth");
let auth = userIAM_userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2").then((code)=>{
console.info("auth success");
// 此处添加认证成功逻辑
}).catch((code)=>{
console.error("auth fail, code = " + code);
// 此处添加认证失败逻辑
});
}
}
```
## EventInfo<sup>9+</sup> | 取值类型 | 说明 |
| --------- | ----------------------- |
| [AuthResultInfo](#authresultinfo9) | 获取到的认证结果信息。 |
| [TipInfo](#tipinfo9) | 认证过程中的提示信息。 |
类型别名,用于表示认证事件信息的类型,取值可以为下表中的类型。 ## AuthEventKey<sup>9+</sup>
**系统能力**:SystemCapability.UserIAM.UserAuth.Core 表示认证事件类型的关键字,作为[on](#on9)接口的的参数。
| 类型 | 说明 | | 取值类型 | 说明 |
| --------- | ----------------------- | | ---------- | ----------------------- |
| [AuthResultInfo](#authresultinfo9) | 认证结果信息 | | "result" | [on](#on9)接口第一个参数为"result"时,[callback](#callback9)回调返回认证的结果信息。 |
| [TipInfo](#tipinfo9) | 认证过程中的提示信息 | | "tip" | [on](#on9)接口第一个参数为"tip"时,[callback](#callback9)回调返回认证操作中的提示信息。 |
## AuthEvent<sup>9+</sup> ## AuthEvent<sup>9+</sup>
认证事件回调的对象。 认证接口的异步回调对象。
### callback<sup>9+</sup> ### callback<sup>9+</sup>
callback: (result : EventInfo) => void callback(result : EventInfo) : void
表示在认证结束后返回结果信息或者在认证操作中返回提示信息。 通过该回调获取认证结果信息或认证过程中的提示信息。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------------- | ---- | -------------------------------------------------------- | | --------- | -------------------------- | ---- | ------------------------------ |
| result | [EventInfo](#eventinfo9) | 是 | 返回的认证结果信息或提示信息。 | | result | [EventInfo](#eventinfo9) | 是 | 返回的认证结果信息或提示信息。 |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let authType = userIAM_userAuth.UserAuthType.FACE; let authType = userIAM_userAuth.UserAuthType.FACE;
let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
try { // 通过callback获取认证结果
try {
let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
auth.on("result", { auth.on("result", {
callback: (result: userIAM_userAuth.AuthResultInfo) => { callback: (result: userIAM_userAuth.AuthResultInfo) => {
...@@ -236,44 +95,32 @@ callback: (result : EventInfo) => void ...@@ -236,44 +95,32 @@ callback: (result : EventInfo) => void
}); });
auth.start(); auth.start();
console.log("authV9 start success"); console.log("authV9 start success");
} catch (error) { } catch (error) {
console.log("authV9 error = " + error); console.log("authV9 error = " + error);
// do error // do error
}
// 通过callback获取认证过程中的提示信息
try {
let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
auth.on("tip", {
callback : (result : userIAM_userAuth.TipInfo) => {
switch (result.tip) {
case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT:
// do something;
case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK:
// do something;
default:
// do others
} }
``` }
});
## AuthResultInfo<sup>9+</sup> auth.start();
console.log("authV9 start success");
表示认证结果信息的对象。 } catch (error) {
console.log("authV9 error = " + error);
**系统能力**:SystemCapability.UserIAM.UserAuth.Core // do error
}
| 名称 | 参数类型 | 必填 | 说明 | ```
| ------------ | ---------- | ---- | -------------------- |
| result | number | 是 | 认证结果。 |
| token | Uint8Array | 否 | 用户身份认证通过的凭证。 |
| remainAttempts | number | 否 | 剩余的认证操作次数。 |
| lockoutDuration | number | 否 | 认证操作的冻结时间。 |
## TipInfo<sup>9+</sup>
表示认证过程中提示信息的对象。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 参数类型 | 必填 | 说明 |
| ------------ | ---------- | ---- | -------------------- |
| module | number | 否 | 认证模块。 |
| tip | number | 否 | 认证过程提示信息。 |
## AuthEventKey<sup>9+</sup>
类型别名,表示认证事件的关键字,取值为表格内字符串。
| 取值 | 说明 |
| ---------- | ----------------------- |
| "result" | 取值为result时,事件回调返回认证的结果信息。 |
| "tip" | 取值为tip时,事件回调返回认证操作中的提示信息。 |
## AuthInstance<sup>9+</sup> ## AuthInstance<sup>9+</sup>
...@@ -281,9 +128,12 @@ callback: (result : EventInfo) => void ...@@ -281,9 +128,12 @@ callback: (result : EventInfo) => void
### on<sup>9+</sup> ### on<sup>9+</sup>
on(name : AuthEventKey, callback : AuthEvent) : void on : (name : AuthEventKey, callback : AuthEvent) => void
订阅指定类型的用户认证事件。
表示开启对认证事件的监听。 > **说明:**
> 使用获取到的[AuthInstance](#authinstance9)对象调用该接口进行订阅。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
...@@ -291,19 +141,29 @@ on(name : AuthEventKey, callback : AuthEvent) : void ...@@ -291,19 +141,29 @@ on(name : AuthEventKey, callback : AuthEvent) : void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------------- | ---- | ------------------------- | | --------- | -------------------------- | ---- | ------------------------- |
| name | AuthEventKey | 是 | 认证事件的关键字 | | name | [AuthEventKey](#autheventkey9) | 是 | 表示认证事件类型,取值为"result"时,回调函数返回认证结果;取值为"tip"时,回调函数返回认证过程中的提示信息。 |
| callback | AuthEvent | 是 | 认证事件的回调函数 | | callback | [AuthEvent](#authevent9) | 是 | 认证接口的回调函数,用于返回认证结果或认证过程中的提示信息。 |
以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ------- |
| 401 | Incorrect parameters. |
| 12500002 | General operation error. |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let authType = userIAM_userAuth.UserAuthType.FACE; let authType = userIAM_userAuth.UserAuthType.FACE;
let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
try { try {
let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
// 订阅认证结果
auth.on("result", { auth.on("result", {
callback: (result: userIAM_userAuth.AuthResultInfo) => { callback: (result: userIAM_userAuth.AuthResultInfo) => {
console.log("authV9 result " + result.result); console.log("authV9 result " + result.result);
...@@ -312,7 +172,7 @@ on(name : AuthEventKey, callback : AuthEvent) : void ...@@ -312,7 +172,7 @@ on(name : AuthEventKey, callback : AuthEvent) : void
console.log("authV9 lockoutDuration " + result.lockoutDuration); console.log("authV9 lockoutDuration " + result.lockoutDuration);
} }
}); });
// if need tip // 订阅认证过程中的提示信息
auth.on("tip", { auth.on("tip", {
callback : (result : userIAM_userAuth.TipInfo) => { callback : (result : userIAM_userAuth.TipInfo) => {
switch (result.tip) { switch (result.tip) {
...@@ -320,7 +180,6 @@ on(name : AuthEventKey, callback : AuthEvent) : void ...@@ -320,7 +180,6 @@ on(name : AuthEventKey, callback : AuthEvent) : void
// do something; // do something;
case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK: case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK:
// do something; // do something;
// ...
default: default:
// do others // do others
} }
...@@ -328,35 +187,54 @@ on(name : AuthEventKey, callback : AuthEvent) : void ...@@ -328,35 +187,54 @@ on(name : AuthEventKey, callback : AuthEvent) : void
}); });
auth.start(); auth.start();
console.log("authV9 start success"); console.log("authV9 start success");
} catch (error) { } catch (error) {
console.log("authV9 error = " + error); console.log("authV9 error = " + error);
// do error // do error
} }
``` ```
### off<sup>9+</sup> ### off<sup>9+</sup>
off(name : AuthEventKey) : void off : (name : AuthEventKey) => void
取消订阅特定类型的认证事件。
表示关闭对认证事件的监听。 > **说明:**
> 需要使用已经成功订阅事件的[AuthInstance](#authinstance9)对象调用该接口进行取消订阅。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
| 参数名 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| --------- | -------------------------- | ---- | ------------------------- | | --------- | -------------------------- | ---- | ------------------------- |
| name | AuthEventKey | 是 | 认证事件的关键字 | | name | [AuthEventKey](#autheventkey9) | 是 | 表示认证事件类型,取值为"result"时,取消订阅认证结果;取值为"tip"时,取消订阅认证过程中的提示信息。 |
以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ------- |
| 401 | Incorrect parameters. |
| 12500002 | General operation error. |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let authType = userIAM_userAuth.UserAuthType.FACE; let authType = userIAM_userAuth.UserAuthType.FACE;
let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
let auth;
try {
auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
console.log("get auth instance success");
} catch (error) {
console.log("get auth instance failed" + error);
}
try { try {
let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); // 订阅认证结果
auth.on("result", { auth.on("result", {
callback: (result: userIAM_userAuth.AuthResultInfo) => { callback: (result: userIAM_userAuth.AuthResultInfo) => {
console.log("authV9 result " + result.result); console.log("authV9 result " + result.result);
...@@ -365,77 +243,103 @@ off(name : AuthEventKey) : void ...@@ -365,77 +243,103 @@ off(name : AuthEventKey) : void
console.log("authV9 lockoutDuration " + result.lockoutDuration); console.log("authV9 lockoutDuration " + result.lockoutDuration);
} }
}); });
console.log("turn on authentication event listening success"); console.log("subscribe authentication event success");
} catch (error) { } catch (error) {
console.log("turn off authentication event listening failed " + error); console.log("subscribe authentication event failed " + error);
// do error }
} // 取消订阅认证结果
try {
try {
let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
auth.off("result"); auth.off("result");
console.info("turn off authentication event listening success"); console.info("cancel subscribe authentication event success");
} catch (error) { } catch (error) {
console.info("turn off authentication event listening failed, error = " + error); console.info("cancel subscribe authentication event failed, error = " + error);
} }
``` ```
### start<sup>9+</sup> ### start<sup>9+</sup>
start() : void start : () => void
表示开始认证。 开始认证。
> **说明:**
> 使用获取到的[AuthInstance](#authinstance9)对象调用该接口进行认证。
**需要权限**:ohos.permission.ACCESS_BIOMETRIC **需要权限**:ohos.permission.ACCESS_BIOMETRIC
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ------- |
| 201 | Permission verification failed. |
| 401 | Incorrect parameters. |
| 12500002 | General operation error. |
| 12500005 | The authentication type is not supported. |
| 12500006 | The authentication trust level is not supported. |
| 12500010 | The type of credential has not been enrolled. |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let authType = userIAM_userAuth.UserAuthType.FACE; let authType = userIAM_userAuth.UserAuthType.FACE;
let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
try { try {
let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
auth.start(); auth.start();
console.info("authV9 start auth success"); console.info("authV9 start auth success");
} catch (error) { } catch (error) {
console.info("authV9 start auth failed, error = " + error); console.info("authV9 start auth failed, error = " + error);
} }
``` ```
### cancel<sup>9+</sup> ### cancel<sup>9+</sup>
cancel(): void cancel : () => void
表示取消认证。 取消认证。
> **说明:**
> 使用获取到的[AuthInstance](#authinstance9)对象调用该接口进行取消认证,此[AuthInstance](#authinstance9)需要是正在进行认证的对象。
**需要权限**:ohos.permission.ACCESS_BIOMETRIC **需要权限**:ohos.permission.ACCESS_BIOMETRIC
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ------- |
| 201 | Permission verification failed. |
| 401 | Incorrect parameters. |
| 12500002 | General operation error. |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let authType = userIAM_userAuth.UserAuthType.FACE; let authType = userIAM_userAuth.UserAuthType.FACE;
let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
try { try {
let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
auth.start();
auth.cancel(); auth.cancel();
console.info("cancel auth success"); console.info("cancel auth success");
} catch (error) { } catch (error) {
console.info("cancel auth failed, error = " + error); console.info("cancel auth failed, error = " + error);
} }
``` ```
## userIAM_userAuth.getAuthInstance<sup>9+</sup> ## userIAM_userAuth.getAuthInstance<sup>9+</sup>
...@@ -444,7 +348,7 @@ getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel ...@@ -444,7 +348,7 @@ getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel
获取AuthInstance对象,用于执行用户身份认证。 获取AuthInstance对象,用于执行用户身份认证。
> **说明:** > **说明:**
> 每个AuthInstance只能用于发起一次认证,若需要再次发起认证需重新获取AuthInstance。 > 每个AuthInstance只能进行一次认证,若需要再次进行认证则需重新获取AuthInstance。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
...@@ -462,21 +366,33 @@ getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel ...@@ -462,21 +366,33 @@ getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel
| ----------------------------------------- | ------------ | | ----------------------------------------- | ------------ |
| [AuthInstance](#authinstance9) | 认证器对象。 | | [AuthInstance](#authinstance9) | 认证器对象。 |
以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ------- |
| 401 | Incorrect parameters. |
| 12500002 | General operation error. |
| 12500005 | The authentication type is not supported. |
| 12500006 | The authentication trust level is not supported. |
**示例:** **示例:**
```js
import userIAM_userAuth from '@ohos.userIAM.userAuth';
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); ```js
let authType = userIAM_userAuth.UserAuthType.FACE; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
try { let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let authType = userIAM_userAuth.UserAuthType.FACE;
let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
try {
let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
console.info("get auth instance success"); console.info("get auth instance success");
} catch (error) { } catch (error) {
console.info("get auth instance success failed, error = " + error); console.info("get auth instance success failed, error = " + error);
} }
``` ```
## userIAM_userAuth.getVersion<sup>9+</sup> ## userIAM_userAuth.getVersion<sup>9+</sup>
...@@ -492,26 +408,35 @@ getVersion(): number ...@@ -492,26 +408,35 @@ getVersion(): number
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ---------------------- | | ------ | ---------------------- |
| number | 获取的认证器版本信息。 | | number | 认证器版本信息。 |
以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ------- |
| 201 | Permission verification failed. |
| 12500002 | General operation error. |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
try { try {
let version = userIAM_userAuth.getVersion(); let version = userIAM_userAuth.getVersion();
console.info("auth version = " + version); console.info("auth version = " + version);
} catch (error) { } catch (error) {
console.info("get version failed, error = " + error); console.info("get version failed, error = " + error);
} }
``` ```
## userIAM_userAuth.getAvailableStatus<sup>9+</sup> ## userIAM_userAuth.getAvailableStatus<sup>9+</sup>
getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void
表示检查指定的认证等级的认证能力是否可用 查询指定类型和等级的认证能力是否支持
**需要权限**:ohos.permission.ACCESS_BIOMETRIC **需要权限**:ohos.permission.ACCESS_BIOMETRIC
...@@ -522,28 +447,41 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): vo ...@@ -522,28 +447,41 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): vo
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------- | ---- | -------------------------- | | -------------- | ---------------------------------- | ---- | -------------------------- |
| authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前只支持FACE。 | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前只支持FACE。 |
| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证结果的信任等级。 | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 |
以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ------- |
| 201 | Permission verification failed. |
| 401 | Incorrect parameters. |
| 12500002 | General operation error. |
| 12500005 | The authentication type is not supported. |
| 12500006 | The authentication trust level is not supported. |
| 12500010 | The type of credential has not been enrolled. |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
try { try {
userIAM_userAuth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1); userIAM_userAuth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1);
console.info("current auth trust level is supported"); console.info("current auth trust level is supported");
} catch (error) { } catch (error) {
console.info("current auth trust level is not supported, error = " + error); console.info("current auth trust level is not supported, error = " + error);
} }
``` ```
## ResultCodeV9<sup>9+</sup> ## ResultCodeV9<sup>9+</sup>
表示执行结果的枚举。 表示返回码的枚举。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 默认值 | 描述 | | 名称 | 值 | 说明 |
| ----------------------- | ------ | -------------------- | | ----------------------- | ------ | -------------------- |
| SUCCESS | 12500000 | 执行成功。 | | SUCCESS | 12500000 | 执行成功。 |
| FAIL | 12500001 | 执行失败。 | | FAIL | 12500001 | 执行失败。 |
...@@ -553,50 +491,49 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): vo ...@@ -553,50 +491,49 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): vo
| TYPE_NOT_SUPPORT | 12500005 | 不支持的认证类型。 | | TYPE_NOT_SUPPORT | 12500005 | 不支持的认证类型。 |
| TRUST_LEVEL_NOT_SUPPORT | 12500006 | 不支持的认证等级。 | | TRUST_LEVEL_NOT_SUPPORT | 12500006 | 不支持的认证等级。 |
| BUSY | 12500007 | 忙碌状态。 | | BUSY | 12500007 | 忙碌状态。 |
| INVALID_PARAMETERS | 12500008 | 无效参数。 |
| LOCKED | 12500009 | 认证器已锁定。 | | LOCKED | 12500009 | 认证器已锁定。 |
| NOT_ENROLLED | 12500010 | 用户未录入认证信息。 | | NOT_ENROLLED | 12500010 | 用户未录入认证信息。 |
## UserAuth<sup>8+</sup> ## UserAuth<sup>8+</sup>
认证器对象。 认证器对象。
### constructor<sup>(deprecated)</sup> ### constructor<sup>(deprecated)</sup>
constructor() constructor()
创建认证器对象。
> **说明:** > **说明:**
> 从 API version 9 开始废弃,请使用[getAuthInstance](#useriam_userauthgetauthinstance9)替代。 > 从 API version 9 开始废弃,请使用[getAuthInstance](#useriam_userauthgetauthinstance9)替代。
<br/>从 API version 8 开始支持。 <br/>从 API version 8 开始支持。
表示获取的认证器对象。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------- | -------------------- | | ---------------------- | -------------------- |
| [UserAuth](#userauth8) | UserAuth认证器对象。 | | [UserAuth](#userauth8) | 认证器对象。 |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let auth = new userIAM_userAuth.UserAuth(); let auth = new userIAM_userAuth.UserAuth();
``` ```
### getVersion<sup>(deprecated)</sup> ### getVersion<sup>(deprecated)</sup>
getVersion() : number getVersion() : number
获取认证器的版本信息。
> **说明:** > **说明:**
> 从 API version 9 开始废弃,请使用[getVersion](#useriam_userauthgetversion9)替代。 > 从 API version 9 开始废弃,请使用[getVersion](#useriam_userauthgetversion9)替代。
<br/>从 API version 8 开始支持。 <br/>从 API version 8 开始支持。
表示获取的认证器版本信息。
**需要权限**:ohos.permission.ACCESS_BIOMETRIC **需要权限**:ohos.permission.ACCESS_BIOMETRIC
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
...@@ -605,28 +542,28 @@ getVersion() : number ...@@ -605,28 +542,28 @@ getVersion() : number
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ---------------------- | | ------ | ---------------------- |
| number | 获取的认证器版本信息。 | | number | 认证器版本信息。 |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let auth = new userIAM_userAuth.UserAuth(); let auth = new userIAM_userAuth.UserAuth();
let version = auth.getVersion(); let version = auth.getVersion();
console.info("auth version = " + version); console.info("auth version = " + version);
``` ```
### getAvailableStatus<sup>(deprecated)</sup> ### getAvailableStatus<sup>(deprecated)</sup>
getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number
查询指定类型和等级的认证能力是否支持。
> **说明:** > **说明:**
> 从 API version 9 开始废弃,请使用开始废弃,请使用[getAvailableStatus](#useriam_userauthgetavailablestatus9)替代。 > 从 API version 9 开始废弃,请使用[getAvailableStatus](#useriam_userauthgetavailablestatus9)替代。
<br/>从 API version 8 开始支持。 <br/>从 API version 8 开始支持。
表示检查指定的认证等级的认证能力是否可用。
**需要权限**:ohos.permission.ACCESS_BIOMETRIC **需要权限**:ohos.permission.ACCESS_BIOMETRIC
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
...@@ -636,40 +573,38 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : n ...@@ -636,40 +573,38 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : n
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------- | ---- | -------------------------- | | -------------- | ---------------------------------- | ---- | -------------------------- |
| authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前只支持FACE。 | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前只支持FACE。 |
| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证结果的信任等级。 | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ------------------------------------------------------------ | | ------ | ------------------------------------------------------------ |
| number | 获取指定的认证等级的认证能力是否可用的检查结果,返回值参见[ResultCode](#resultcodedeprecated)。 | | number | 查询结果,结果为SUCCESS时表示支持,其他返回值参见[ResultCode](#resultcodedeprecated)。 |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let auth = new userIAM_userAuth.UserAuth(); let auth = new userIAM_userAuth.UserAuth();
let checkCode = auth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1); let checkCode = auth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1);
if (checkCode == userIAM_userAuth.ResultCode.SUCCESS) { if (checkCode == userIAM_userAuth.ResultCode.SUCCESS) {
console.info("check auth support success"); console.info("check auth support success");
// 此处添加支持指定类型认证的逻辑 } else {
} else {
console.error("check auth support fail, code = " + checkCode); console.error("check auth support fail, code = " + checkCode);
// 此处添加不支持指定类型认证的逻辑 }
} ```
```
### auth<sup>(deprecated)</sup> ### auth<sup>(deprecated)</sup>
auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array
执行用户认证,使用回调函数返回结果。
> **说明:** > **说明:**
> 从 API version 9 开始废弃,建议使用[start](#start9)代替。 > 从 API version 9 开始废弃,建议使用[start](#start9)代替。
<br/>从 API version 8 开始支持。 <br/>从 API version 8 开始支持。
表示执行用户认证,使用callback方式作为异步方法。
**需要权限**:ohos.permission.ACCESS_BIOMETRIC **需要权限**:ohos.permission.ACCESS_BIOMETRIC
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
...@@ -680,7 +615,7 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev ...@@ -680,7 +615,7 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev
| -------------- | ---------------------------------------- | ---- | ------------------------ | | -------------- | ---------------------------------------- | ---- | ------------------------ |
| challenge | Uint8Array | 是 | 挑战值,可以填null。 | | challenge | Uint8Array | 是 | 挑战值,可以填null。 |
| authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前支持FACE。 | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前支持FACE。 |
| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 信任等级。 | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 |
| callback | [IUserAuthCallback](#iuserauthcallbackdeprecated) | 是 | 回调函数。 | | callback | [IUserAuthCallback](#iuserauthcallbackdeprecated) | 是 | 回调函数。 |
**返回值:** **返回值:**
...@@ -691,11 +626,11 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev ...@@ -691,11 +626,11 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let auth = new userIAM_userAuth.UserAuth(); let auth = new userIAM_userAuth.UserAuth();
auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => { onResult: (result, extraInfo) => {
try { try {
console.info("auth onResult result = " + result); console.info("auth onResult result = " + result);
...@@ -709,19 +644,19 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev ...@@ -709,19 +644,19 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev
console.info("auth onResult error = " + e); console.info("auth onResult error = " + e);
} }
} }
}); });
``` ```
### cancelAuth<sup>(deprecated)</sup> ### cancelAuth<sup>(deprecated)</sup>
cancelAuth(contextID : Uint8Array) : number cancelAuth(contextID : Uint8Array) : number
表示通过contextID取消本次认证操作。
> **说明:** > **说明:**
> 从 API version 9 开始废弃,建议使用[cancel](#cancel9)代替。 > 从 API version 9 开始废弃,建议使用[cancel](#cancel9)代替。
<br/>从 API version 8 开始支持。 <br/>从 API version 8 开始支持。
表示通过contextID取消本次认证操作。
**需要权限**:ohos.permission.ACCESS_BIOMETRIC **需要权限**:ohos.permission.ACCESS_BIOMETRIC
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
...@@ -730,65 +665,64 @@ cancelAuth(contextID : Uint8Array) : number ...@@ -730,65 +665,64 @@ cancelAuth(contextID : Uint8Array) : number
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ---------- | ---- | ------------------------------------------ | | --------- | ---------- | ---- | ------------------------------------------ |
| contextID | Uint8Array | 是 | 上下文ID信息,通过[auth](#authdeprecated)接口获得。 | | contextID | Uint8Array | 是 | 上下文的标识,通过[auth](#authdeprecated)接口获取。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ------------------------ | | ------ | ------------------------ |
| number | 取消本次认证操作的结果。 | | number | 取消认证的结果,结果为SUCCESS时表示取消成功,其他返回值参见[ResultCode](#resultcodedeprecated)。 |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
// contextId可通过auth接口获取,此处直接定义 // contextId可通过auth接口获取,此处直接定义
let contextId = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7]); let contextId = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7]);
let auth = new userIAM_userAuth.UserAuth(); let auth = new userIAM_userAuth.UserAuth();
let cancelCode = auth.cancelAuth(contextId); let cancelCode = auth.cancelAuth(contextId);
if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) {
console.info("cancel auth success"); console.info("cancel auth success");
} else { } else {
console.error("cancel auth fail"); console.error("cancel auth fail");
} }
``` ```
## IUserAuthCallback<sup>(deprecated)</sup> ## IUserAuthCallback<sup>(deprecated)</sup>
返回认证结果的回调对象。
> **说明:** > **说明:**
> 从 API version 9 开始废弃,建议使用[AuthEvent](#authevent9)代替。 > 从 API version 9 开始废弃,建议使用[AuthEvent](#authevent9)代替。
<br/>从 API version 8 开始支持。 <br/>从 API version 8 开始支持。
认证过程中回调结果的对象。
### onResult<sup>(deprecated)</sup> ### onResult<sup>(deprecated)</sup>
onResult: (result : number, extraInfo : AuthResult) => void onResult: (result : number, extraInfo : AuthResult) => void
回调函数,返回认证结果。
> **说明:** > **说明:**
> 从 API version 9 开始废弃,建议使用[callback](#callback9)代替。 > 从 API version 9 开始废弃,建议使用[callback](#callback9)代替。
<br/>从 API version 8 开始支持。 <br/>从 API version 8 开始支持。
表示在认证操作中,获取认证结果。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------------- | ---- | ------------------------------------------------------------ | | --------- | -------------------------- | ---- | ------------------------------------------------ |
| result | number | 是 | 认证结果,参见[ResultCode](#resultcodedeprecated)。 | | result | number | 是 | 认证结果,参见[ResultCode](#resultcodedeprecated)。 |
| extraInfo | [AuthResult](#authresultdeprecated) | 是 | 扩展信息,不同情况下的具体信息,<br/>如果身份验证通过,则在extrainfo中返回用户认证令牌,<br/>如果身份验证失败,则在extrainfo中返回剩余的用户认证次数,<br/>如果身份验证执行器被锁定,则在extrainfo中返回冻结时间。 | | extraInfo | [AuthResult](#authresultdeprecated) | 是 | 扩展信息,不同情况下的具体信息,<br/>如果身份验证通过,则在extraInfo中返回用户认证令牌,<br/>如果身份验证失败,则在extraInfo中返回剩余的用户认证次数,<br/>如果身份验证执行器被锁定,则在extraInfo中返回冻结时间。 |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let auth = new userIAM_userAuth.UserAuth(); let auth = new userIAM_userAuth.UserAuth();
auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => { onResult: (result, extraInfo) => {
try { try {
console.info("auth onResult result = " + result); console.info("auth onResult result = " + result);
...@@ -801,61 +735,37 @@ onResult: (result : number, extraInfo : AuthResult) => void ...@@ -801,61 +735,37 @@ onResult: (result : number, extraInfo : AuthResult) => void
} catch (e) { } catch (e) {
console.info("auth onResult error = " + e); console.info("auth onResult error = " + e);
} }
},
onAcquireInfo: (module, acquire, extraInfo) => {
try {
console.info("auth onAcquireInfo module = " + module);
console.info("auth onAcquireInfo acquire = " + acquire);
console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo));
} catch (e) {
console.info("auth onAcquireInfo error = " + e);
} }
} });
}); ```
```
### onAcquireInfo<sup>(deprecated)</sup> ### onAcquireInfo<sup>(deprecated)</sup>
onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
回调函数,返回认证过程中的提示信息,非必须实现。
> **说明:** > **说明:**
> 从 API version 9 开始废弃,建议使用[callback](#callback9)代替。 > 从 API version 9 开始废弃,建议使用[callback](#callback9)代替。
<br/>从 API version 8 开始支持。 <br/>从 API version 8 开始支持。
表示在认证过程中,获取提示码信息,非必须实现。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ------------------------------ | | --------- | ------ | ---- | ------------------------------ |
| module | number | 是 | 认证执行器的类型。 | | module | number | 是 | 发送提示信息的模块标识。 |
| acquire | number | 是 | 认证执行器认证过程的交互信息。 | | acquire | number | 是 | 认证执过程中的提示信息。 |
| extraInfo | any | 是 | 预留字段。 | | extraInfo | any | 是 | 预留字段。 |
**示例:** **示例:**
```js ```js
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let auth = new userIAM_userAuth.UserAuth();
auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => {
try {
console.info("auth onResult result = " + result);
console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo));
if (result == userIAM_userAuth.ResultCode.SUCCESS) {
// 此处添加认证成功逻辑
} else {
// 此处添加认证失败逻辑
}
} catch (e) {
console.info("auth onResult error = " + e);
}
},
let auth = new userIAM_userAuth.UserAuth();
auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
onAcquireInfo: (module, acquire, extraInfo) => { onAcquireInfo: (module, acquire, extraInfo) => {
try { try {
console.info("auth onAcquireInfo module = " + module); console.info("auth onAcquireInfo module = " + module);
...@@ -865,35 +775,35 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void ...@@ -865,35 +775,35 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
console.info("auth onAcquireInfo error = " + e); console.info("auth onAcquireInfo error = " + e);
} }
} }
}); });
``` ```
## AuthResult<sup>(deprecated)</sup> ## AuthResult<sup>(deprecated)</sup>
表示认证结果的对象。
> **说明:** > **说明:**
> 从 API version 9 开始废弃,建议使用[AuthResultInfo](#authresultinfo9)代替。 > 从 API version 9 开始废弃,建议使用[AuthResultInfo](#authresultinfo9)代替。
<br/>从 API version 8 开始支持。 <br/>从 API version 8 开始支持。
表示认证结果的对象。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 参数类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------------ | ---------- | ---- | -------------------- | | ------------ | ---------- | ---- | -------------------|
| token | Uint8Array | 否 | 身份认证令牌。 | | token | Uint8Array | 否 | 认证通过的令牌信息。 |
| remainTimes | number | 否 | 剩余的认证操作次数。 | | remainTimes | number | 否 | 剩余的认证操作次数。 |
| freezingTime | number | 否 | 认证操作的冻结时间。 | | freezingTime | number | 否 | 认证操作的冻结时间。 |
## ResultCode<sup>(deprecated)</sup> ## ResultCode<sup>(deprecated)</sup>
表示返回码的枚举。
> **说明:** > **说明:**
> 从 API version 9 开始废弃,建议使用[ResultCodeV9](#resultcodev99)代替。 > 从 API version 9 开始废弃,建议使用[ResultCodeV9](#resultcodev99)代替。
表示执行结果的枚举。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 默认值 | 描述 | | 名称 | 值 | 说明 |
| ----------------------- | ------ | -------------------- | | ----------------------- | ------ | -------------------- |
| SUCCESS | 0 | 执行成功。 | | SUCCESS | 0 | 执行成功。 |
| FAIL | 1 | 执行失败。 | | FAIL | 1 | 执行失败。 |
...@@ -906,14 +816,13 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void ...@@ -906,14 +816,13 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
| LOCKED | 9 | 认证器已锁定。 | | LOCKED | 9 | 认证器已锁定。 |
| NOT_ENROLLED | 10 | 用户未录入认证信息。 | | NOT_ENROLLED | 10 | 用户未录入认证信息。 |
## FaceTips<sup>8+</sup> ## FaceTips<sup>8+</sup>
表示人脸认证过程中提示码的枚举。 表示人脸认证过程中提示码的枚举。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 默认值 | 描述 | | 名称 | 值 | 说明 |
| ----------------------------- | ------ | ------------------------------------ | | ----------------------------- | ------ | ------------------------------------ |
| FACE_AUTH_TIP_TOO_BRIGHT | 1 | 光线太强,获取的图像太亮。 | | FACE_AUTH_TIP_TOO_BRIGHT | 1 | 光线太强,获取的图像太亮。 |
| FACE_AUTH_TIP_TOO_DARK | 2 | 光线太暗,获取的图像太暗。 | | FACE_AUTH_TIP_TOO_DARK | 2 | 光线太暗,获取的图像太暗。 |
...@@ -934,7 +843,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void ...@@ -934,7 +843,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 默认值 | 描述 | | 名称 | 值 | 说明 |
| --------------------------------- | ------ | -------------------------------------------------- | | --------------------------------- | ------ | -------------------------------------------------- |
| FINGERPRINT_AUTH_TIP_GOOD | 0 | 获取的指纹图像良好。 | | FINGERPRINT_AUTH_TIP_GOOD | 0 | 获取的指纹图像良好。 |
| FINGERPRINT_AUTH_TIP_DIRTY | 1 | 由于传感器上可疑或检测到的污垢,指纹图像噪音过大。 | | FINGERPRINT_AUTH_TIP_DIRTY | 1 | 由于传感器上可疑或检测到的污垢,指纹图像噪音过大。 |
...@@ -950,7 +859,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void ...@@ -950,7 +859,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 默认值 | 描述 | | 名称 | 值 | 说明 |
| ----------- | ------ | ---------- | | ----------- | ------ | ---------- |
| FACE | 2 | 人脸认证。 | | FACE | 2 | 人脸认证。 |
| FINGERPRINT | 4 | 指纹认证。 | | FINGERPRINT | 4 | 指纹认证。 |
...@@ -961,7 +870,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void ...@@ -961,7 +870,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 默认值 | 描述 | | 名称 | 值 | 说明 |
| ---- | ------ | ------------------------- | | ---- | ------ | ------------------------- |
| ATL1 | 10000 | 认证结果的信任等级级别1。 | | ATL1 | 10000 | 认证结果的信任等级级别1。 |
| ATL2 | 20000 | 认证结果的信任等级级别2。 | | ATL2 | 20000 | 认证结果的信任等级级别2。 |
...@@ -972,11 +881,11 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void ...@@ -972,11 +881,11 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void
getAuthenticator(): Authenticator getAuthenticator(): Authenticator
获取Authenticator对象,用于执行用户身份认证。
> **说明:** > **说明:**
> 从 API version 8 开始废弃,建议使用[constructor](#constructordeprecated)替代。 > 从 API version 8 开始废弃,建议使用[constructor](#constructordeprecated)替代。
获取Authenticator对象,用于执行用户身份认证。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
**返回值:** **返回值:**
...@@ -992,21 +901,20 @@ getAuthenticator(): Authenticator ...@@ -992,21 +901,20 @@ getAuthenticator(): Authenticator
## Authenticator<sup>(deprecated)</sup> ## Authenticator<sup>(deprecated)</sup>
> **说明:**
> 从 API version 8 开始废弃,建议使用[UserAuth](#userauth8)替代。
认证器对象。 认证器对象。
> **说明:**
> 从 API version 8 开始废弃,建议使用[UserAuth](#userauth8)替代。
### execute<sup>(deprecated)</sup> ### execute<sup>(deprecated)</sup>
execute(type: AuthType, level: SecureLevel, callback: AsyncCallback&lt;number&gt;): void execute(type: AuthType, level: SecureLevel, callback: AsyncCallback&lt;number&gt;): void
执行用户认证,使用callback方式作为异步方法。
> **说明:** > **说明:**
> 从 API version 8 开始废弃,建议使用[auth](#authdeprecated)替代。 > 从 API version 8 开始废弃,建议使用[auth](#authdeprecated)替代。
执行用户认证,使用callback方式作为异步方法。
**需要权限**:ohos.permission.ACCESS_BIOMETRIC **需要权限**:ohos.permission.ACCESS_BIOMETRIC
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
...@@ -1014,39 +922,40 @@ execute(type: AuthType, level: SecureLevel, callback: AsyncCallback&lt;number&gt ...@@ -1014,39 +922,40 @@ execute(type: AuthType, level: SecureLevel, callback: AsyncCallback&lt;number&gt
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------- | ---- | -------------------------- |
| type | AuthType | 是 | 认证类型,当前只支持"FACE_ONLY"。<br/>ALL为预留参数,当前版本暂不支持ALL类型的认证。 | | type | AuthType | 是 | 认证类型,当前只支持"FACE_ONLY"。<br/>ALL为预留参数,当前版本暂不支持ALL类型的认证。 |
| level | SecureLevel | 是 | 安全级别,对应认证的安全级别,有效值为"S1"(最低)、"S2"、"S3"、"S4"(最高)。<br/>具备3D人脸识别能力的设备支持"S3"及以下安全级别的认证。<br/>具备2D人脸识别能力的设备支持"S2"及以下安全级别的认证。 | | level | SecureLevel | 是 | 安全级别,对应认证的安全级别,有效值为"S1"(最低)、"S2"、"S3"、"S4"(最高)。<br/>具备3D人脸识别能力的设备支持"S3"及以下安全级别的认证。<br/>具备2D人脸识别能力的设备支持"S2"及以下安全级别的认证。 |
| callback | AsyncCallback&lt;number&gt; | 否 | 回调函数。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数。 |
callback返回值: callback返回值:
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ------------------------------------------------------------ | | ------ | ------------------------------------------------------------ |
| number | 表示认证结果,参见[AuthenticationResult](#authenticationresultdeprecated)。 | | number | 表示认证结果,参见[AuthenticationResult](#authenticationresultdeprecated)。 |
**示例:** **示例:**
```js
let authenticator = userIAM_userAuth.getAuthenticator(); ```js
authenticator.execute("FACE_ONLY", "S2", (error, code)=>{ let authenticator = userIAM_userAuth.getAuthenticator();
authenticator.execute("FACE_ONLY", "S2", (error, code)=>{
if (code === userIAM_userAuth.ResultCode.SUCCESS) { if (code === userIAM_userAuth.ResultCode.SUCCESS) {
console.info("auth success"); console.info("auth success");
return; return;
} }
console.error("auth fail, code = " + code); console.error("auth fail, code = " + code);
}); });
``` ```
### execute<sup>(deprecated)</sup> ### execute<sup>(deprecated)</sup>
execute(type:AuthType, level:SecureLevel): Promise&lt;number&gt; execute(type : AuthType, level : SecureLevel): Promise&lt;number&gt;
执行用户认证,使用promise方式作为异步方法。
> **说明:** > **说明:**
> 从 API version 8 开始废弃,建议使用[auth](#authdeprecated)替代。 > 从 API version 8 开始废弃,建议使用[auth](#authdeprecated)替代。
执行用户认证,使用promise方式作为异步方法。
**需要权限**:ohos.permission.ACCESS_BIOMETRIC **需要权限**:ohos.permission.ACCESS_BIOMETRIC
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
...@@ -1066,25 +975,25 @@ execute(type:AuthType, level:SecureLevel): Promise&lt;number&gt; ...@@ -1066,25 +975,25 @@ execute(type:AuthType, level:SecureLevel): Promise&lt;number&gt;
**示例:** **示例:**
```js ```js
let authenticator = userIAM_userAuth.getAuthenticator(); let authenticator = userIAM_userAuth.getAuthenticator();
authenticator.execute("FACE_ONLY", "S2").then((code)=>{ authenticator.execute("FACE_ONLY", "S2").then((code)=>{
console.info("auth success"); console.info("auth success");
}).catch((error)=>{ }).catch((error)=>{
console.error("auth fail, code = " + error); console.error("auth fail, code = " + error);
}); });
``` ```
## AuthenticationResult<sup>(deprecated)</sup> ## AuthenticationResult<sup>(deprecated)</sup>
表示认证结果的枚举。
> **说明:** > **说明:**
> 从 API version 8 开始废弃,建议使用[ResultCode](#resultcodedeprecated)替代。 > 从 API version 8 开始废弃,建议使用[ResultCode](#resultcodedeprecated)替代。
表示认证结果的枚举。
**系统能力**:SystemCapability.UserIAM.UserAuth.Core **系统能力**:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 默认值 | 描述 | | 名称 | 值 | 说明 |
| ------------------ | ------ | -------------------------- | | ------------------ | ------ | -------------------------- |
| NO_SUPPORT | -1 | 设备不支持当前的认证方式。 | | NO_SUPPORT | -1 | 设备不支持当前的认证方式。 |
| SUCCESS | 0 | 认证成功。 | | SUCCESS | 0 | 认证成功。 |
......
...@@ -30,7 +30,9 @@ Worker构造函数的选项信息,用于为Worker添加其他信息。 ...@@ -30,7 +30,9 @@ Worker构造函数的选项信息,用于为Worker添加其他信息。
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ---- | -------- | ---- | ---- | -------------- | | ---- | -------- | ---- | ---- | -------------- |
| type | classic \| module | 是 | 是 | Worker执行脚本的模式类型,默认为classic类型,暂不支持module类型。 |
| name | string | 是 | 是 | Worker的名称。 | | name | string | 是 | 是 | Worker的名称。 |
| shared | boolean | 是 | 是 | 暂不支持共享Worker功能。 |
## ThreadWorker<sup>9+</sup> ## ThreadWorker<sup>9+</sup>
......
...@@ -27,7 +27,7 @@ zipFile(inFile: string, outFile: string, options: Options): Promise&lt;void&gt; ...@@ -27,7 +27,7 @@ zipFile(inFile: string, outFile: string, options: Options): Promise&lt;void&gt;
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[Stage模型](js-apis-application-context.md)。 | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[Stage模型](js-apis-application-context.md)。 |
| outFile | string | 是 | 指定压缩结果的文件路径(文件的扩展名zip)。 | | outFile | string | 是 | 指定压缩结果的文件路径(文件的扩展名zip)。 |
| options | [Options](#options) | 否 | 压缩的可选参数。 | | options | [Options](#options) | 是 | 压缩的可选参数。 |
**返回值:** **返回值:**
...@@ -91,7 +91,7 @@ unzipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt; ...@@ -91,7 +91,7 @@ unzipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt;
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md)。 | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md)[stage模型](js-apis-application-context.md)。 |
| outFile | string | 是 | 指定的解压文件路径。 | | outFile | string | 是 | 指定的解压文件路径。 |
| options | [Options](#options) | 否 | 解压的可选参数。 | | options | [Options](#options) | 是 | 解压的可选参数。 |
**返回值:** **返回值:**
...@@ -318,11 +318,11 @@ try { ...@@ -318,11 +318,11 @@ try {
**系统能力:** SystemCapability.BundleManager.Zlib **系统能力:** SystemCapability.BundleManager.Zlib
| 参数名 | 类型 | 必填 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | ---------------- | ---- | --------------------------------------------------------- | | -------- | ---------------- | ---- | ---- | ---------------------------------------------------------- |
| level | CompressLeve | 否 | 参考[zip.CompressLevel枚举定义](#zipcompresslevel)。 | | level | CompressLeve | 是 | 否 | 参考[zip.CompressLevel枚举定义](#zipcompresslevel)。 |
| memLevel | MemLevel | 否 | 参考[zip.MemLevel枚举定义](#zipmemlevel)。 | | memLevel | MemLevel | 是 | 否 | 参考[zip.MemLevel枚举定义](#zipmemlevel)。 |
| strategy | CompressStrategy | 否 | 参考[zip.CompressStrategy枚举定义](#zipcompressstrategy)。 | | strategy | CompressStrategy | 是 | 否 | 参考[zip.CompressStrategy枚举定义](#zipcompressstrategy)。 |
## zip.CompressLevel ## zip.CompressLevel
......
# 用户认证错误码
## 201 权限验证失败
具体参见[通用错误码](./errorcode-universal.md)
## 202 调用方不是一个系统应用
具体参见[通用错误码](./errorcode-universal.md)
## 401 参数不正确
具体参见[通用错误码](./errorcode-universal.md)
## 12500002 一般的操作错误
**错误信息**
General operation error.
**可能原因**
1. NAPI层解析参数出错。
2. 用户认证服务的进程没有启动。
3. IPC通信的proxy客户端写数据出错。
4. IPC通信的stub服务端解析数据出错。
5. 获取driver服务出错。
**处理步骤**
重启设备,重新调用接口。
## 12500005 认证类型不支持
**错误信息**
The authentication type is not supported.
**可能原因**
1. 传入的认证类型参数不支持,例如调用userAuth模块的getAvailableStatus接口时传入的参数不是FACE或FINGERPRINT类型,则会返回12500005错误码。
2. 传入的认证类型参数在本设备上不支持,例如在没有部署指纹传感器的设备上发起指纹认证,则会返回12500005错误码。
**处理步骤**
请检查传入的认证类型参数,重新调用接口。
## 12500006 认证信任等级不支持
**错误信息**
The authentication trust level is not supported.
**可能原因**
1. 调用userAuth模块的getAvailableStatus或getAuthInstance接口时,传入的authTrustLevel参数不在[ATL1, ATL2, ATL3, ATL4]范围内。
2. 当前的设备不支持该认证信任等级,例如在只部署了2D摄像头的设备上发起支付级别的人脸认证,则会返回12500006错误码。
**处理步骤**
检查传入的authTrustLevel是否在合理范围,如果在合理范围,则是当前的设备不支持该认证信任等级。
## 12500010 该类型的凭据没有录入
**错误信息**
The type of credential has not been enrolled.
**可能原因**
例如调用userAuth模块的getAvailableStatus接口,传入的authType参数为FACE,但是当前的设备没有录入人脸凭据,则会返回12500010错误码。
调用start接口发起人脸认证,但是目前的设备没有录入人脸凭据,则会返回12500010错误码。
**处理步骤**
检查是否录入该类型的凭据,如果没有录入,则需要成功录入该类型凭据后再调用相关接口。
## 12700001 人脸录入过程中的操作失败
**错误信息**
The operation is failed.
**可能原因**
1. 例如调用faceAuth模块的setSurfaceId接口时,人脸认证服务未启动,则会返回12700001错误码。
2. IPC通信的proxy客户端写数据出错。
3. IPC通信的stub服务端解析数据出错。
4. 人脸driver层调用出错。
**处理步骤**
主要检查人脸认证服务的进程是否启动。
# 用户认证开发指导 # 用户认证开发指导
> **说明:** > **说明:**
> 该开发指导需匹配API Version 8或以上版本的SDK使用。 > 该开发指导需配合API version 9版本的SDK使用。
## 场景介绍 ## 场景介绍
当前用户认证支持2D人脸识别、3D人脸识别,可应用于设备解锁、应用登录、支付等身份认证场景。 当前用户认证支持人脸识别和指纹识别,可应用于设备解锁、应用登录、支付等身份认证场景。
## 接口说明 ## 接口说明
userIAM_userAuth模块提供了用户认证的相关方法,包括检测认证能力、认证和取消认证等,用户可以使用人脸等生物特征信息进行认证操作。具体接口说明可以查阅[API参考](../reference/apis/js-apis-useriam-userauth.md) userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证能力、发起认证和取消认证等,用户可以使用人脸、指纹等生物特征信息进行认证操作。具体接口说明可以查阅[API参考文档](../reference/apis/js-apis-useriam-userauth.md)
在执行认证前,需要检查设备是否支持该认证能力,具体指认证类型、认证等级。如果不支持,需要考虑使用其他认证能力。 在执行认证前,需要指定[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),查询设备是否支持该认证能力。
**表1** 用户认证开放能力列表 **表1** 用户认证开放能力列表
| 接口名 | 功能描述 | | 接口名称 | 功能描述 |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ---------- | ----------------------- |
| getVersion() : number | 获取认证对象的版本信息。 | | getVersion() : number | 获取认证对象的版本信息。 |
| getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 | | getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 |
| auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array | 执行用户认证,使用callback方式作为异步方法。 | | getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel : AuthTrustLevel): AuthInstance | 获取AuthInstance对象,用于执行用户身份认证。 |
| cancelAuth(contextID : Uint8Array) : number | 通过contextID取消本次认证操作。 | | on(name : AuthEventKey, callback : AuthEvent) : void | 订阅指定类型的用户认证事件。 |
| off(name : AuthEventKey) : void | 取消订阅特定类型的认证事件。 |
| start: void | 执行用户认证。 |
| cancel: void | 取消本次认证操作。 |
## 开发步骤 ## 获取认证对象的版本信息
开发前请完成以下准备工作: ### 开发步骤
1. 在应用配置权限文件中,增加ohos.permission.ACCESS_BIOMETRIC的权限声明。 1. 申请权限。调用[getVersion](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetversion9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)
2. 在使用用户认证能力的代码文件中增加import userIAM_userAuth from '@ohos.userIAM.userAuth'。
开发过程: 2. 调用[getVersion](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetversion9)接口获取版本信息。
1. 获取Authenticator的单例对象,代码示例如下:
```js ```js
let auth = new userIAM_userAuth.UserAuth(); import userIAM_userAuth from '@ohos.userIAM.userAuth';
// 获取版本信息
try {
let version = userIAM_userAuth.getVersion();
console.info("auth version = " + version);
} catch (error) {
console.info("get version failed, error = " + error);
}
``` ```
2. (可选)获取认证对象的版本信息,代码示例如下: ## 查询当前设备是否支持相应的认证能力
### 开发步骤
1. 申请权限。调用[getAvailableStatus](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetavailablestatus9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)
2. 指定[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),调用[getAvailableStatus](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetavailablestatus9)接口查询当前的设备是否支持相应的认证能力。
```js ```js
let auth = new userIAM_userAuth.UserAuth(); import userIAM_userAuth from '@ohos.userIAM.userAuth';
let version = auth.getVersion();
console.info("auth version = " + version); // 查询认证能力是否支持
try {
userIAM_userAuth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1);
console.info("current auth trust level is supported");
} catch (error) {
console.info("current auth trust level is not supported, error = " + error);
}
``` ```
3. 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力,代码示例如下: ## 执行认证操作并请阅认证结果
### 开发步骤
1. 申请权限。调用[start](../reference/apis/js-apis-useriam-userauth.md#start9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)
2. 指定challenge、[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),获取认证对象。
3. 调用[on](../reference/apis/js-apis-useriam-userauth.md#on9)接口订阅认证结果。
4. 调用[start](../reference/apis/js-apis-useriam-userauth.md#start9)接口发起认证,通过[callback](../reference/apis/js-apis-useriam-userauth.md#callback9)回调返回认证结果。
5. 调用[off](../reference/apis/js-apis-useriam-userauth.md#off9)接口取消订阅认证结果。
```js ```js
let auth = new userIAM_userAuth.UserAuth(); import userIAM_userAuth from '@ohos.userIAM.userAuth';
let checkCode = auth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1);
if (checkCode == userIAM_userAuth.ResultCode.SUCCESS) { let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
console.info("check auth support success"); let authType = userIAM_userAuth.UserAuthType.FACE;
// 此处添加支持指定类型认证的逻辑 let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
} else {
console.error("check auth support fail, code = " + checkCode); // 获取认证对象
// 此处添加不支持指定类型认证的逻辑 let auth;
try {
auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
console.log("get auth instance success");
} catch (error) {
console.log("get auth instance failed" + error);
}
// 订阅认证结果
try {
auth.on("result", {
callback: (result: userIAM_userAuth.AuthResultInfo) => {
console.log("authV9 result " + result.result);
console.log("authV9 token " + result.token);
console.log("authV9 remainAttempts " + result.remainAttempts);
console.log("authV9 lockoutDuration " + result.lockoutDuration);
}
});
console.log("subscribe authentication event success");
} catch (error) {
console.log("subscribe authentication event failed " + error);
}
// 开始认证
try {
auth.start();
console.info("authV9 start auth success");
} catch (error) {
console.info("authV9 start auth failed, error = " + error);
}
// 取消订阅认证结果
try {
auth.off("result");
console.info("cancel subscribe authentication event success");
} catch (error) {
console.info("cancel subscribe authentication event failed, error = " + error);
} }
``` ```
4. 执行认证操作,代码示例如下: ## 执行认证操作并订阅认证过程中的提示信息
### 开发步骤
1. 申请权限。调用[start](../reference/apis/js-apis-useriam-userauth.md#start9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)
2. 指定challenge、[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),获取认证对象。
3. 调用[on](../reference/apis/js-apis-useriam-userauth.md#on9)接口订阅认证过程中的提示信息。
4. 调用[start](../reference/apis/js-apis-useriam-userauth.md#start9)接口发起认证,通过[callback](../reference/apis/js-apis-useriam-userauth.md#callback9)回调返回认证过程中的提示信息。
5. 调用[off](../reference/apis/js-apis-useriam-userauth.md#off9)接口取消订阅认证过程中的提示信息。
```js ```js
let auth = new userIAM_userAuth.UserAuth(); import userIAM_userAuth from '@ohos.userIAM.userAuth';
auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => { let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let authType = userIAM_userAuth.UserAuthType.FACE;
let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
// 获取认证对象
let auth;
try { try {
console.info("auth onResult result = " + result); auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo)); console.log("get auth instance success");
if (result == userIAM_userAuth.ResultCode.SUCCESS) { } catch (error) {
// 此处添加认证成功逻辑 console.log("get auth instance failed" + error);
} else {
// 此处添加认证失败逻辑
}
} catch (e) {
console.info("auth onResult error = " + e);
} }
},
onAcquireInfo: (module, acquire, extraInfo) => { // 订阅认证过程中的提示信息
try { try {
console.info("auth onAcquireInfo module = " + module); auth.on("tip", {
console.info("auth onAcquireInfo acquire = " + acquire); callback : (result : userIAM_userAuth.TipInfo) => {
console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo)); switch (result.tip) {
} catch (e) { case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT:
console.info("auth onAcquireInfo error = " + e); // do something;
case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK:
// do something;
default:
// do others
} }
} }
}); });
console.log("subscribe authentication event success");
} catch (error) {
console.log("subscribe authentication event failed " + error);
}
// 开始认证
try {
auth.start();
console.info("authV9 start auth success");
} catch (error) {
console.info("authV9 start auth failed, error = " + error);
}
// 取消订阅认证过程中的提示信息
try {
auth.off("tip");
console.info("cancel subscribe tip information success");
} catch (error) {
console.info("cancel subscribe tip information failed, error = " + error);
}
``` ```
5. 认证过程中取消认证,代码示例如下: ## 认证过程中取消认证
### 开发步骤
1. 申请权限。调用[cancel](../reference/apis/js-apis-useriam-userauth.md#cancel9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)
2. 指定challenge、[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),获取认证对象。
3. 调用[start](../reference/apis/js-apis-useriam-userauth.md#start9)接口发起认证。
4. 通过调用[cancel](../reference/apis/js-apis-useriam-userauth.md#cancel9)接口取消本次认证。
```js ```js
let auth = new userIAM_userAuth.UserAuth(); import userIAM_userAuth from '@ohos.userIAM.userAuth';
// contextId通过auth接口获取
let contextId = auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
onResult: (result, extraInfo) => { let authType = userIAM_userAuth.UserAuthType.FACE;
console.info("auth onResult result = " + result); let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
},
onAcquireInfo: (module, acquire, extraInfo) => { // 获取认证对象
console.info("auth onAcquireInfo module = " + module); let auth;
try {
auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
console.log("get auth instance success");
} catch (error) {
console.log("get auth instance failed" + error);
} }
});
let cancelCode = auth.cancel(contextId); // 开始认证
if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { try {
auth.start();
console.info("authV9 start auth success");
} catch (error) {
console.info("authV9 start auth failed, error = " + error);
}
// 取消认证
try {
auth.cancel();
console.info("cancel auth success"); console.info("cancel auth success");
} else { } catch (error) {
console.error("cancel auth fail"); console.info("cancel auth failed, error = " + error);
} }
``` ```
# 用户认证开发概述 # 用户认证开发概述
提供用户认证能力,可应用于设备解锁、支付、应用登录等身份认证场景。 ## 用户认证模块的定义
当前用户认证能力提供2D人脸识别、3D人脸识别两种人脸识别能力,设备具备哪种识别能力,取决于设备的硬件能力和技术实现 用户认证模块提供用户认证能力,对应用开发者而言,可使用该模块进行用户身份认证,用于设备解锁、支付、应用登录等身份认证场景
3D人脸识别技术识别率、防伪能力都优于2D人脸识别技术,但具有3D人脸能力(比如3D结构光、3D TOF等)的设备才可以使用3D人脸识别技术 当前用户认证提供人脸识别和指纹识别能力,设备具备哪种识别能力,取决于当前设备的硬件能力和技术实现
## 基本概念 ## 基本概念
人脸识别:基于人的脸部特征信息进行身份识别的一种生物特征识别技术,用摄像机或摄像头采集含有人脸的图像或视频流,并自动在图像中检测和跟踪人脸,进而对检测到的人脸进行脸部识别,通常也叫做人像识别、面部识别、人脸认证。 - 人脸识别:基于人的脸部特征信息进行身份识别的一种生物特征识别技术,用摄像机或摄像头采集含有人脸的图像或视频流,并自动在图像中检测和跟踪人脸,进而对检测到的人脸进行脸部识别,通常也叫做人像识别、面部识别、人脸认证。
- 指纹识别:基于人的指尖皮肤纹路进行身份识别的一种生物特征识别技术。当用户触摸指纹采集器件时,器件感知并获取到用户的指纹图像,然后传输到指纹识别模块进行一定的处理后与用户预先注册的指纹信息进行比对,从而识别出用户身份。
## 运作机制 ## 运作机制
人脸识别会在摄像头和TEE(Trusted Execution Environment)之间建立安全通道,人脸图像信息通过安全通道传递到TEE中,由于人脸图像信息从REE(Rich Execution Environment)侧无法获取,从而避免了恶意软件从REE侧进行攻击。对人脸图像采集、特征提取、活体检测、特征比对等处理完全在TEE中,基于TrustZone进行安全隔离,外部的人脸框架只负责人脸的认证发起和处理认证结果等数据,不涉及人脸数据本身。 人脸或指纹识别过程中,特征采集器件和TEE(Trusted Execution Environment)之间会建立安全通道,将采集的生物特征信息直接通过安全通道传递到TEE中,从而避免了恶意软件从REE(Rich Execution Environment)侧进行攻击。传输到TEE中的生物特征数据从活体检测、特征提取、特征存储、特征比对到特征销毁等处理都完全在TEE中完成,基于TrustZone进行安全隔离,提供API的服务框架只负责管理认证请求和处理认证结果等数据,不涉及生物特征数据本身。
人脸特征数据通过TEE的安全存储区进行存储,采用高强度的密码算法对人脸特征数据进行加密和完整性保护,外部无法获取到加密人脸特征数据的密钥,保证用户的人脸特征数据不会泄露。本能力采集和存储的人脸特征数据不会在用户未授权的情况下被传出TEE,这意味着,用户未授权时,无论是系统应用还是三方应用都无法获得人脸特征数据,也无法将人脸特征数据传送或备份到任何外部存储介质。 用户注册的生物特征数据在TEE的安全存储区进行存储,采用高强度的密码算法进行加密和完整性保护,外部无法获取到加密生物特征数据的密钥,保证了用户生物特征数据的安全性。本能力采集和存储的生物特征数据不会在用户未授权的情况下被传出TEE。这意味着,用户未授权时,无论是系统应用还是三方应用都无法获得人脸和指纹等特征数据,也无法将这些特征数据传送或备份到任何外部存储介质。
## 约束与限制 ## 约束与限制
- 当前版本提供的用户认证能力只包含人脸识别,且只支持本地认证,不提供认证界面。 - 当前版本提供的用户认证能力包含人脸识别和指纹识别,且只支持本地认证,不提供认证界面。
- 要求设备上具备摄像器件,且人脸图像像素大于100*100。 - 要求设备上具备相应的生物特征采集器,且对于人脸识别要求人脸图像分辨率大于100*100。
- 要求设备上具有TEE安全环境,人脸特征信息高强度加密保存在TEE中。 - 要求设备上具有TEE安全环境,人脸和指纹等生物特征信息高强度加密保存在TEE中。
- 对于面部特征相似的人、面部特征不断发育的儿童,人脸特征匹配率有所不同。如果对此担忧,可考虑其他认证方式。 - 对于面部特征相似的人、面部特征不断发育的儿童,人脸特征匹配率有所不同。如果对此担忧,可考虑其他认证方式。
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
人脸识别功能是端侧设备不可或缺的一部分,为设备提供一种用户认证能力,可应用于设备解锁、支付、应用登录等身份认证场景。它是基于人的脸部特征信息进行身份识别的一种生物特征识别技术,用摄像机或摄像头采集含有人脸的图像或视频流,并自动在图像中检测和跟踪人脸,进而对检测到的人脸进行脸部识别,通常也叫做人像识别、面部识别、人脸认证。人脸识别功能整体框架如图1。 人脸识别功能是端侧设备不可或缺的一部分,为设备提供一种用户认证能力,可应用于设备解锁、支付、应用登录等身份认证场景。它是基于人的脸部特征信息进行身份识别的一种生物特征识别技术,用摄像机或摄像头采集含有人脸的图像或视频流,并自动在图像中检测和跟踪人脸,进而对检测到的人脸进行脸部识别,通常也叫做人像识别、面部识别、人脸认证。人脸识别功能整体框架如图1。
基于HDF(Hardware Driver Foundation)驱动框架开发的Face_auth驱动,能够屏蔽硬件器件差异,为上层用户认证框架和Face_auth服务提供稳定的人脸识别基础能力接口,包括人脸识别执行器列表查询、执行器信息查询、指定人脸模板ID查询模板信息、用户认证框架和执行器间的人脸模板信息对账、人脸的录入,删除,认证和识别等。 基于HDF(Hardware Driver Foundation)驱动框架开发的Face_auth驱动,能够屏蔽硬件器件差异,为上层用户认证框架和Face_auth服务提供稳定的人脸识别基础能力接口,包括人脸识别执行器列表查询、执行器信息查询、指定人脸模板ID查询模板信息、用户认证框架和执行器间的人脸模板信息对账、人脸录入、删除、认证和识别等。
**图1** 人脸识别功能整体框架 **图1** 人脸识别功能整体框架
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- 执行器安全等级 - 执行器安全等级
执行器提供能力时运行环境所达到的安全级别。 执行器提供能力时所在运行环境达到的安全级别。
- 执行器角色 - 执行器角色
...@@ -51,6 +51,22 @@ ...@@ -51,6 +51,22 @@
用户认证框架统一管理用户身份和凭据ID的映射关系,执行器对接到用户认证框架时,会读取用户身份认证框架内保存的该执行器的模板ID列表,执行器需要与自己维护的模板ID列表进行比对,并删除冗余信息。 用户认证框架统一管理用户身份和凭据ID的映射关系,执行器对接到用户认证框架时,会读取用户身份认证框架内保存的该执行器的模板ID列表,执行器需要与自己维护的模板ID列表进行比对,并删除冗余信息。
- HAPs
HAPs(OpenHarmony Ability Packages),广义上指可以安装在OpenHarmony上的应用包,本章节中仅代表Face_auth驱动的上层应用。
- IDL接口
接口定义语言(Interface Definition Language)通过IDL编译器编译后,能够生成与编程语言相关的文件:客户端桩文件,服务器框架文件。本文主要是通过IDL接口生成的客户端和服务端来实现Face_auth服务和驱动的通信,详细使用方法可参考[IDL简介](https://gitee.com/openharmony/ability_idl_tool/blob/master/README.md)
- IPC通信
IPC(Inter Process Communication),进程间通信是指两个进程的数据之间产生交互,详细原理可参考[IPC通信简介](https://gitee.com/openharmony/communication_ipc/blob/master/README_zh.md)
- HDI
HDI(Hardware Device Interface),硬件设备接口,位于基础系统服务层和设备驱动层之间,是提供给硬件系统服务开发者使用的、统一的硬件设备功能抽象接口,其目的是为系统服务屏蔽底层硬件设备差异,具体可参考[HDI规范](../../design/hdi-design-specifications.md)
### 运作机制 ### 运作机制
Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务提供稳定的人脸识别基础能力,保证设备上人脸识别功能可以正常运行。 Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务提供稳定的人脸识别基础能力,保证设备上人脸识别功能可以正常运行。
...@@ -74,10 +90,14 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务 ...@@ -74,10 +90,14 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
### 接口说明 ### 接口说明
注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/face_auth/v1_0/)。
在本文中,人脸凭据的录入、认证、识别和删除相关的HDI接口如表1所示,表2中的回调函数分别用于人脸执行器返回操作结果给框架和返回操作过程中的提示信息给上层应用。
**表1** 接口功能介绍 **表1** 接口功能介绍
| 接口名 | 功能介绍 | | 接口名称 | 功能介绍 |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ----------------------------------- | ---------------------------------- |
| GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | 获取执行器列表。 | | GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | 获取执行器列表。 |
| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 | | GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定人脸模板ID的模板信息。 | | GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定人脸模板ID的模板信息。 |
...@@ -91,7 +111,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务 ...@@ -91,7 +111,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
**表2** 回调函数介绍 **表2** 回调函数介绍
| 接口名 | 功能介绍 | | 接口名 | 功能介绍 |
| ------------------------------------------------------------ | ------------------------ | | ------------------------------------------------------------ | ------------------------ |
| IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | 返回操作的最终结果。 | | IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | 返回操作的最终结果。 |
| IExecutorCallback::OnTip(int32_t code, const std::vector<uint8_t>& extraInfo) | 返回操作的过程交互信息。 | | IExecutorCallback::OnTip(int32_t code, const std::vector<uint8_t>& extraInfo) | 返回操作的过程交互信息。 |
...@@ -107,7 +127,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务 ...@@ -107,7 +127,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
└── hdi_service # Face_auth驱动实现 └── hdi_service # Face_auth驱动实现
├── BUILD.gn # 编译脚本 ├── BUILD.gn # 编译脚本
├── include # 头文件 ├── include # 头文件
└── src └── src # 源文件
├── executor_impl.cpp # 认证、录入等功能接口实现 ├── executor_impl.cpp # 认证、录入等功能接口实现
├── face_auth_interface_driver.cpp # Face_auth驱动入口 ├── face_auth_interface_driver.cpp # Face_auth驱动入口
└── face_auth_interface_service.cpp # 获取执行器列表接口实现 └── face_auth_interface_service.cpp # 获取执行器列表接口实现
...@@ -423,66 +443,59 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务 ...@@ -423,66 +443,59 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
驱动开发完成后,通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,基于Hi3516DV300平台验证。认证和取消功能验证的JS测试代码如下: 驱动开发完成后,通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,基于Hi3516DV300平台验证。认证和取消功能验证的JS测试代码如下:
```js ```js
// API version 8 // API version 9
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let auth = new userIAM_userAuth.UserAuth();
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
export default { let authType = userIAM_userAuth.UserAuthType.FACE;
getVersion() { let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
console.info("start get version");
let version = this.auth.getVersion(); // 获取认证对象
console.info("auth version = " + version); let auth;
},
startAuth() {
console.info("start auth");
this.auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => {
try { try {
console.info("auth onResult result = " + result); auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo)); console.log("get auth instance success");
if (result == userIAM_userAuth.ResultCode.SUCCESS) { } catch (error) {
// 此处添加认证成功逻辑 console.log("get auth instance failed" + error);
} else {
// 此处添加认证失败逻辑
}
} catch (e) {
console.info("auth onResult error = " + e);
} }
},
onAcquireInfo: (module, acquire, extraInfo) => { // 订阅认证结果
try { try {
console.info("auth onAcquireInfo module = " + module); auth.on("result", {
console.info("auth onAcquireInfo acquire = " + acquire); callback: (result: userIAM_userAuth.AuthResultInfo) => {
console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo)); console.log("authV9 result " + result.result);
} catch (e) { console.log("authV9 token " + result.token);
console.info("auth onAcquireInfo error = " + e); console.log("authV9 remainAttempts " + result.remainAttempts);
} console.log("authV9 lockoutDuration " + result.lockoutDuration);
} }
}); });
}, console.log("subscribe authentication event success");
} catch (error) {
cancelAuth() { console.log("subscribe authentication event failed " + error);
console.info("start cancel auth"); }
// contextId通过auth接口获取
let contextId = auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => {
console.info("auth onResult result = " + result);
},
onAcquireInfo: (module, acquire, extraInfo) => { // 开始认证
console.info("auth onAcquireInfo module = " + module); try {
auth.start();
console.info("authV9 start auth success");
} catch (error) {
console.info("authV9 start auth failed, error = " + error);
} }
});
let cancelCode = this.auth.cancel(contextId); // 取消认证
if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { try {
auth.cancel();
console.info("cancel auth success"); console.info("cancel auth success");
} else { } catch (error) {
console.error("cancel auth fail"); console.info("cancel auth failed, error = " + error);
}
} }
}
```
// 取消订阅认证结果
try {
auth.off("result");
console.info("cancel subscribe authentication event success");
} catch (error) {
console.info("cancel subscribe authentication event failed, error = " + error);
}
```
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- 执行器安全等级 - 执行器安全等级
执行器提供能力时运行环境所达到的安全级别。 执行器提供能力时所在运行环境达到的安全级别。
- 执行器角色 - 执行器角色
...@@ -53,15 +53,19 @@ ...@@ -53,15 +53,19 @@
- HAPs - HAPs
HAPs(OpenHarmony Ability Packages),本章节中仅代表Fingerprint_auth驱动的上层应用。 HAPs(OpenHarmony Ability Packages),广义上指可以安装在OpenHarmony上的应用包,本章节中仅代表Fingerprint_auth驱动的上层应用。
- IDL接口 - IDL接口
接口定义语言(Interface Definition Language)通过IDL编译器编译后,能够生成与编程语言相关的文件:客户端桩文件,服务器框架文件。本文主要是通过IDL接口实现Fingerprint_auth服务和驱动的通信 接口定义语言(Interface Definition Language)通过IDL编译器编译后,能够生成与编程语言相关的文件:客户端桩文件,服务器框架文件。本文主要是通过IDL接口生成的客户端和服务端来实现Fingerprint_auth服务和驱动的通信,详细使用方法可参考[IDL简介](https://gitee.com/openharmony/ability_idl_tool/blob/master/README.md)
- IPC通信 - IPC通信
IPC(Inter Process Communication),进程间通信是指两个进程的数据之间产生交互。 IPC(Inter Process Communication),进程间通信是指两个进程的数据之间产生交互,详细原理可参考[IPC通信简介](https://gitee.com/openharmony/communication_ipc/blob/master/README_zh.md)
- HDI
HDI(Hardware Device Interface),硬件设备接口,位于基础系统服务层和设备驱动层之间,是提供给硬件系统服务开发者使用的、统一的硬件设备功能抽象接口,其目的是为系统服务屏蔽底层硬件设备差异,具体可参考[HDI规范](../../design/hdi-design-specifications.md)
### 运作机制 ### 运作机制
...@@ -84,10 +88,13 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin ...@@ -84,10 +88,13 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
### 接口说明 ### 接口说明
注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/fingerprint_auth/v1_0/)。
在本文中,指纹凭据的录入、认证、识别和删除相关的HDI接口如表1所示,表2中的回调函数分别用于指纹执行器返回操作结果给框架和返回操作过程中的提示信息给上层应用。
**表1** 接口功能介绍 **表1** 接口功能介绍
| 接口名 | 功能介绍 | | 接口名称 | 功能介绍 |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | -------------------------------- | ----------------------------------- |
| GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | 获取执行器列表。 | | GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | 获取执行器列表。 |
| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 | | GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定模板ID的模板信息。 | | GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定模板ID的模板信息。 |
...@@ -101,7 +108,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin ...@@ -101,7 +108,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
**表2** 回调函数介绍 **表2** 回调函数介绍
| 接口名 | 功能介绍 | | 接口名 | 功能介绍 |
| ------------------------------------------------------------ | ------------------------ | | ------------------------------------------------------------ | ------------------------ |
| IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | 返回操作的最终结果。 | | IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | 返回操作的最终结果。 |
| IExecutorCallback::OnTip(int32_t code, const std::vector<uint8_t>& extraInfo) | 返回操作的过程交互信息。 | | IExecutorCallback::OnTip(int32_t code, const std::vector<uint8_t>& extraInfo) | 返回操作的过程交互信息。 |
...@@ -117,7 +124,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin ...@@ -117,7 +124,7 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
└── hdi_service # Fingerprint_auth驱动实现 └── hdi_service # Fingerprint_auth驱动实现
├── BUILD.gn # 编译脚本 ├── BUILD.gn # 编译脚本
├── include # 头文件 ├── include # 头文件
└── src └── src # 源文件
├── executor_impl.cpp # 认证、录入等功能接口实现 ├── executor_impl.cpp # 认证、录入等功能接口实现
├── fingerprint_auth_interface_driver.cpp # Fingerprint_auth驱动入口 ├── fingerprint_auth_interface_driver.cpp # Fingerprint_auth驱动入口
└── fingerprint_auth_interface_service.cpp # 获取执行器列表接口实现 └── fingerprint_auth_interface_service.cpp # 获取执行器列表接口实现
...@@ -433,47 +440,59 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin ...@@ -433,47 +440,59 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin
驱动开发完成后,开发者可以通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,JS应用通过Fingerprint_auth服务调用Fingerprint_auth驱动,从而验证驱动开发是否符合预期。基于Hi3516DV300平台验证,认证功能验证的JS测试代码如下: 驱动开发完成后,开发者可以通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,JS应用通过Fingerprint_auth服务调用Fingerprint_auth驱动,从而验证驱动开发是否符合预期。基于Hi3516DV300平台验证,认证功能验证的JS测试代码如下:
```js ```js
// API version 8 // API version 9
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let auth = new userIAM_userAuth.UserAuth();
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
export default { let authType = userIAM_userAuth.UserAuthType.FINGERPRINT;
getVersion() { let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
console.info("start get version");
let version = this.auth.getVersion(); // 获取认证对象
console.info("auth version = " + version); let auth;
},
startAuth() {
console.info("start auth");
// auth是开发者可以调用的API接口,开发者可以指定认证类型为FINGERPRINT,从而验证驱动是否向框架注册成功以及认证接口实现是否符合预期,result即为认证结果。
this.auth.auth(null, userIAM_userAuth.UserAuthType.FINGERPRINT, userIAM_userAuth.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => {
try { try {
console.info("auth onResult result = " + result); auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo)); console.log("get auth instance success");
if (result == userIAM_userAuth.ResultCode.SUCCESS) { } catch (error) {
// 此处添加认证成功逻辑 console.log("get auth instance failed" + error);
} else {
// 此处添加认证失败逻辑
} }
} catch (e) {
console.info("auth onResult error = " + e);
}
},
onAcquireInfo: (module, acquire, extraInfo) => { // 订阅认证结果
try { try {
console.info("auth onAcquireInfo module = " + module); auth.on("result", {
console.info("auth onAcquireInfo acquire = " + acquire); callback: (result: userIAM_userAuth.AuthResultInfo) => {
console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo)); console.log("authV9 result " + result.result);
} catch (e) { console.log("authV9 token " + result.token);
console.info("auth onAcquireInfo error = " + e); console.log("authV9 remainAttempts " + result.remainAttempts);
} console.log("authV9 lockoutDuration " + result.lockoutDuration);
} }
}); });
console.log("subscribe authentication event success");
} catch (error) {
console.log("subscribe authentication event failed " + error);
} }
}
```
// 开始认证
try {
auth.start();
console.info("authV9 start auth success");
} catch (error) {
console.info("authV9 start auth failed, error = " + error);
}
// 取消认证
try {
auth.cancel();
console.info("cancel auth success");
} catch (error) {
console.info("cancel auth failed, error = " + error);
}
// 取消订阅认证结果
try {
auth.off("result");
console.info("cancel subscribe authentication event success");
} catch (error) {
console.info("cancel subscribe authentication event failed, error = " + error);
}
```
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- 执行器安全等级 - 执行器安全等级
执行器提供能力时运行环境所达到的安全级别。 执行器提供能力时所在运行环境达到的安全级别。
- 执行器角色 - 执行器角色
...@@ -52,6 +52,18 @@ ...@@ -52,6 +52,18 @@
用户认证框架统一管理用户身份和凭据ID的映射关系,执行器对接到用户认证框架时,会读取用户身份认证框架内保存的该执行器的模板ID列表,执行器需要与自己维护的模板ID列表进行比对,并删除冗余信息。 用户认证框架统一管理用户身份和凭据ID的映射关系,执行器对接到用户认证框架时,会读取用户身份认证框架内保存的该执行器的模板ID列表,执行器需要与自己维护的模板ID列表进行比对,并删除冗余信息。
- IDL接口
接口定义语言(Interface Definition Language)通过IDL编译器编译后,能够生成与编程语言相关的文件:客户端桩文件,服务器框架文件。本文主要是通过IDL接口生成的客户端和服务端来实现Pin_auth服务和驱动的通信,详细使用方法可参考[IDL简介](https://gitee.com/openharmony/ability_idl_tool/blob/master/README.md)
- IPC通信
IPC(Inter Process Communication),进程间通信是指两个进程的数据之间产生交互,详细原理可参考[IPC通信简介](https://gitee.com/openharmony/communication_ipc/blob/master/README_zh.md)
- HDI
HDI(Hardware Device Interface),硬件设备接口,位于基础系统服务层和设备驱动层之间,是提供给硬件系统服务开发者使用的、统一的硬件设备功能抽象接口,其目的是为系统服务屏蔽底层硬件设备差异,具体可参考[HDI规范](../../design/hdi-design-specifications.md)
### 运作机制 ### 运作机制
Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提供稳定的口令认证的基础能力,保证口令认证的功能可以正常运行。开发者可基于HDF框架对不同芯片进行各自驱动的开发以及HDI层接口的调用。 Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提供稳定的口令认证的基础能力,保证口令认证的功能可以正常运行。开发者可基于HDF框架对不同芯片进行各自驱动的开发以及HDI层接口的调用。
...@@ -61,7 +73,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提 ...@@ -61,7 +73,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
![image](figures/pin_auth服务与驱动交互.png "pin_auth服务与驱动交互") ![image](figures/pin_auth服务与驱动交互.png "pin_auth服务与驱动交互")
### 约束与限制 ### 约束与限制
口令认证的实现需要在TEE安全环境中实现,口令凭据等数据的密信息需要在安全环境中存储。 口令认证的实现需要在TEE安全环境中实现,口令凭据等数据的密信息需要在安全环境中存储。
## 开发指导 ## 开发指导
### 场景介绍 ### 场景介绍
...@@ -69,15 +81,18 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提 ...@@ -69,15 +81,18 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
### 接口说明 ### 接口说明
注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/pin_auth/v1_0/)。
在本文中,口令凭据的录入、认证和删除相关的HDI接口如表1所示,表2中的回调函数分别用于口令执行器返回操作结果给框架和获取用户输入的口令信息。
**表1** 接口功能介绍 **表1** 接口功能介绍
| 接口名 | 功能介绍 | | 接口名称 | 功能介绍 |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------- | ------------------------------------------- |
| GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | 获取执行器列表。 | | GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | 获取执行器列表。 |
| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息。 | | GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息。 |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定templateId的模板信息。 | | GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定templateId的模板信息。 |
| OnRegisterFinish(const std::vector<uint64_t>& templateIdList,<br/>const std::vector<uint8_t>& frameworkPublicKey,<br/>const std::vector<uint8_t>& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的template 列表用于对账。 | | OnRegisterFinish(const std::vector<uint64_t>& templateIdList,<br/>const std::vector<uint8_t>& frameworkPublicKey,<br/>const std::vector<uint8_t>& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的template 列表用于对账。 |
| OnSetData(uint64_t scheduleId, uint64_t authSubType, <br/>const std::vector<uint8_t> &data) | 用于回调传pin码认证的子类型和脱敏数据。 | | OnSetData(uint64_t scheduleId, uint64_t authSubType, <br/>const std::vector<uint8_t> &data) | 回调函数,返回用户录入的口令子类型和录入的口令脱敏数据。 |
| Enroll(uint64_t scheduleId, const std::vector<uint8_t>& extraInfo,<br/>const sptr<IExecutorCallback>& callbackObj) | 录入pin码。 | | Enroll(uint64_t scheduleId, const std::vector<uint8_t>& extraInfo,<br/>const sptr<IExecutorCallback>& callbackObj) | 录入pin码。 |
| Authenticate(uint64_t scheduleId, uint64_t templateId, const std::vector<uint8_t>& extraInfo, const sptr<IExecutorCallback>& callbackObj) | pin码认证。 | | Authenticate(uint64_t scheduleId, uint64_t templateId, const std::vector<uint8_t>& extraInfo, const sptr<IExecutorCallback>& callbackObj) | pin码认证。 |
| Delete(uint64_t templateId) | 删除pin码模板。 | | Delete(uint64_t templateId) | 删除pin码模板。 |
...@@ -86,7 +101,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提 ...@@ -86,7 +101,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
**表2** 回调函数介绍 **表2** 回调函数介绍
| 接口名 | 功能介绍 | | 接口名 | 功能介绍 |
| ------------------------------------------------------------ | -------------------- | | ------------------------------------------------------------ | -------------------- |
| IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | 返回操作的最终结果。 | | IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | 返回操作的最终结果。 |
| IExecutorCallback::OnGetData(uint64_t scheduleId, const std::vector<uint8_t>& salt,<br/> uint64_t authSubType)| 返回获取pin码数据信息。 | | IExecutorCallback::OnGetData(uint64_t scheduleId, const std::vector<uint8_t>& salt,<br/> uint64_t authSubType)| 返回获取pin码数据信息。 |
...@@ -108,7 +123,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提 ...@@ -108,7 +123,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提
├── main # 口令相关功能实现入口 ├── main # 口令相关功能实现入口
└── service # Pin_auth驱动实现入口 └── service # Pin_auth驱动实现入口
├── inc # 头文件 ├── inc # 头文件
└── src └── src # 源文件
├── executor_impl.cpp # 认证、录入等功能接口实现 ├── executor_impl.cpp # 认证、录入等功能接口实现
├── pin_auth_interface_driver.cpp # Pin_auth驱动入口 ├── pin_auth_interface_driver.cpp # Pin_auth驱动入口
└── pin_auth_interface_service.cpp # 获取执行器列表接口实现 └── pin_auth_interface_service.cpp # 获取执行器列表接口实现
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- 认证凭据模板 - 认证凭据模板
认证凭据模板在用户设置认证凭据时由认证服务产生并存储。每个模板有一个ID,用于索引模板信息文件。在认证时,读取模板信息并和当次认证过程中产生的认证数据做对比,完成身份认证。 认证凭据模板在用户设置认证凭据时由认证服务产生并存储。每个模板有一个ID,用于索引模板信息文件。在认证时,读取模板信息并和当次认证过程中产生的认证数据做对比,完成身份认证。
- 执行器 - 执行器
...@@ -41,11 +41,11 @@ ...@@ -41,11 +41,11 @@
- 执行器安全等级 - 执行器安全等级
执行器提供能力时运行环境所达到的安全级别,如操作运行在无访问控制安全等级低于操作运行硬件可信执行环境的安全等级 执行器提供能力时所在运行环境达到的安全级别
- 用户认证框架公钥 & 执行器公钥 - 用户认证框架公钥 & 执行器公钥
用户身份认证处理需要保证用户数据安全以及认证结果的准确性,用户认证框架与基础认证服务间的关键交互信息需要做数据完整性保护,各基础认证服务将提供的执行器能力对接到用户认证框架时,需要交各自的公钥,其中: 用户身份认证处理需要保证用户数据安全以及认证结果的准确性,用户认证框架与基础认证服务间的关键交互信息需要做数据完整性保护,各基础认证服务将提供的执行器能力对接到用户认证框架时,需要交各自的公钥,其中:
- 执行器通过用户认证框架公钥校验调度指令的准确性,如锁定一个人脸模板,这种情况导致无法使用人脸功能,属于敏感操作,需要确保指令准确,才可处理。 - 执行器通过用户认证框架公钥校验调度指令的准确性,如锁定一个人脸模板,这种情况导致无法使用人脸功能,属于敏感操作,需要确保指令准确,才可处理。
...@@ -76,6 +76,18 @@ ...@@ -76,6 +76,18 @@
OpenHarmony系统向系统应用提供的应用编程接口。 OpenHarmony系统向系统应用提供的应用编程接口。
- IDL接口
接口定义语言(Interface Definition Language),通过IDL编译器编译后,能够生成与编程语言相关的文件:客户端桩文件,服务器框架文件。本文主要是通过IDL接口生成的客户端和服务端来实现User_auth服务和驱动的通信,详细使用方法可参考[IDL简介](https://gitee.com/openharmony/ability_idl_tool/blob/master/README.md)
- IPC通信
IPC(Inter Process Communication),进程间通信是指两个进程的数据之间产生交互,详细原理可参考[IPC通信简介](https://gitee.com/openharmony/communication_ipc/blob/master/README_zh.md)
- HDI
HDI(Hardware Device Interface),硬件设备接口,位于基础系统服务层和设备驱动层之间,是提供给硬件系统服务开发者使用的、统一的硬件设备功能抽象接口,其目的是为系统服务屏蔽底层硬件设备差异,具体可参考[HDI规范](../../design/hdi-design-specifications.md)
### 运作机制 ### 运作机制
User_auth驱动主要工作是屏蔽不同安全器件和安全环境的差异,通过统一的认证能力注册、录入、认证接口,向User_auth服务提供认证执行器管理、认证凭据管理和认证方案生成管理等能力。 User_auth驱动主要工作是屏蔽不同安全器件和安全环境的差异,通过统一的认证能力注册、录入、认证接口,向User_auth服务提供认证执行器管理、认证凭据管理和认证方案生成管理等能力。
...@@ -97,10 +109,13 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -97,10 +109,13 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
### 接口说明 ### 接口说明
注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/user_auth/v1_0/)。
在本文中,执行器注册、凭据录入、凭据删除、用户认证和用户识别相关的HDI接口如表1所示。
**表1** 接口功能介绍 **表1** 接口功能介绍
| 接口名 | 功能介绍 | | 接口名称 | 功能介绍 |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | --------------------------- | --------------------------- |
| Init() | 初始化缓存信息。 | | Init() | 初始化缓存信息。 |
| AddExecutor(const ExecutorRegisterInfo& info, uint64_t& index, std::vector<uint8_t>& publicKey,<br/> std::vector<uint64_t>& templateIds) | 添加认证执行器,获得此认证能力。 | | AddExecutor(const ExecutorRegisterInfo& info, uint64_t& index, std::vector<uint8_t>& publicKey,<br/> std::vector<uint64_t>& templateIds) | 添加认证执行器,获得此认证能力。 |
| DeleteExecutor(uint64_t index) | 根据索引值index删除认证执行器。 | | DeleteExecutor(uint64_t index) | 根据索引值index删除认证执行器。 |
...@@ -121,7 +136,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -121,7 +136,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
| UpdateIdentificationResult(uint64_t contextId, const std::vector<uint8_t>& scheduleResult,<br/> IdentifyResultInfo& info) | 更新识别结果,进行此次识别方案结果的评估。 | | UpdateIdentificationResult(uint64_t contextId, const std::vector<uint8_t>& scheduleResult,<br/> IdentifyResultInfo& info) | 更新识别结果,进行此次识别方案结果的评估。 |
| CancelIdentification(uint64_t contextId) | 取消此次识别。 | | CancelIdentification(uint64_t contextId) | 取消此次识别。 |
| GetAuthTrustLevel(int32_t userId, AuthType authType, uint32_t& authTrustLevel) | 获取此用户当前认证类型的认证可信等级。 | | GetAuthTrustLevel(int32_t userId, AuthType authType, uint32_t& authTrustLevel) | 获取此用户当前认证类型的认证可信等级。 |
| GetValidSolution(int32_t userId, const std::vector<AuthType>& authTypes, uint32_t authTrustLevel,<br/> std::vector<AuthType>& validTypes) | 筛选此用户当前认证可信等级下可用认证方式。 | | GetValidSolution(int32_t userId, const std::vector<AuthType>& authTypes, uint32_t authTrustLevel,<br/> std::vector<AuthType>& validTypes) | 筛选此用户当前认证可信等级下可用认证方式。 |
### 开发步骤 ### 开发步骤
...@@ -494,66 +509,59 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -494,66 +509,59 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
驱动开发完成后,通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,基于Hi3516DV300平台验证。认证和取消功能验证的JS测试代码如下: 驱动开发完成后,通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,基于Hi3516DV300平台验证。认证和取消功能验证的JS测试代码如下:
```js ```js
// API version 8 // API version 9
import userIAM_userAuth from '@ohos.userIAM.userAuth'; import userIAM_userAuth from '@ohos.userIAM.userAuth';
let auth = new userIAM_userAuth.UserAuth();
let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
export default { let authType = userIAM_userAuth.UserAuthType.FACE;
getVersion() { let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1;
console.info("start get version");
let version = this.auth.getVersion(); // 获取认证对象
console.info("auth version = " + version); let auth;
},
startAuth() {
console.info("start auth");
this.auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => {
try { try {
console.info("auth onResult result = " + result); auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel);
console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo)); console.log("get auth instance success");
if (result == 'SUCCESS') { } catch (error) {
// 此处添加认证成功逻辑 console.log("get auth instance failed" + error);
} else {
// 此处添加认证失败逻辑
} }
} catch (e) {
console.info("auth onResult error = " + e);
}
},
onAcquireInfo: (module, acquire, extraInfo) => { // 订阅认证结果
try { try {
console.info("auth onAcquireInfo module = " + module); auth.on("result", {
console.info("auth onAcquireInfo acquire = " + acquire); callback: (result: userIAM_userAuth.AuthResultInfo) => {
console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo)); console.log("authV9 result " + result.result);
} catch (e) { console.log("authV9 token " + result.token);
console.info("auth onAcquireInfo error = " + e); console.log("authV9 remainAttempts " + result.remainAttempts);
} console.log("authV9 lockoutDuration " + result.lockoutDuration);
} }
}); });
}, console.log("subscribe authentication event success");
} catch (error) {
cancelAuth() { console.log("subscribe authentication event failed " + error);
console.info("start cancel auth"); }
// contextId通过auth接口获取
let contextId = auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => {
console.info("auth onResult result = " + result);
},
onAcquireInfo: (module, acquire, extraInfo) => { // 开始认证
console.info("auth onAcquireInfo module = " + module); try {
auth.start();
console.info("authV9 start auth success");
} catch (error) {
console.info("authV9 start auth failed, error = " + error);
} }
});
let cancelCode = this.auth.cancel(contextId); // 取消认证
if (cancelCode == userIAM_userAuth.Result.SUCCESS) { try {
auth.cancel();
console.info("cancel auth success"); console.info("cancel auth success");
} else { } catch (error) {
console.error("cancel auth fail"); console.info("cancel auth failed, error = " + error);
}
} }
}
```
// 取消订阅认证结果
try {
auth.off("result");
console.info("cancel subscribe authentication event success");
} catch (error) {
console.info("cancel subscribe authentication event failed, error = " + error);
}
```
...@@ -28,7 +28,7 @@ New IP载荷传输效率,相比IPv4提高最少1%,相比IPv6提高最少2.33 ...@@ -28,7 +28,7 @@ New IP载荷传输效率,相比IPv4提高最少1%,相比IPv6提高最少2.33
## 可变长报头格式 ## 可变长报头格式
New IP WiFi灵活极简报文头如下图所示,通过LLC Header中的EtherType = 0xEADD标识New IP报文。Bitmap是一组由0和1组成的二进制序列,每个二进制位的数值用于表示特定目标字段的存在性 New IP WiFi灵活极简报文头如下图所示,通过LLC Header中的EtherType = 0xEADD标识New IP报文。Bitmap是一组由0和1组成的二进制序列,每个二进制位的数值用于表示New IP报头中是否携带某个字段,即New IP报文头可以由用户根据业务场景自行定制报头中携带哪些字段
![zh-cn_image-20220915140627223](figures/zh-cn_image-20220915140627223.png) ![zh-cn_image-20220915140627223](figures/zh-cn_image-20220915140627223.png)
...@@ -89,23 +89,31 @@ New IP支持可变长地址(IPv4/IPv6地址长度固定),支持自解析 ...@@ -89,23 +89,31 @@ New IP支持可变长地址(IPv4/IPv6地址长度固定),支持自解析
## New IP配置指导 ## New IP配置指导
启用New IP,需要通过编译内核时打开相应的配置项及依赖,New IP相关CONFIG如下: ### New IP使能
```c 目前只有rk3568开发板Linux 5.10内核上支持New IP内核协议栈,在rk3568开发板内核模块配置文件中搜索NEWIP,将其修改成“CONFIG_XXX=y”即可,New IP相关CONFIG如下。
```
# kernel/linux/config/linux-5.10/arch/arm64/configs/rk3568_standard_defconfig
CONFIG_NEWIP=y // 使能New IP内核协议栈 CONFIG_NEWIP=y // 使能New IP内核协议栈
CONFIG_NEWIP_HOOKS=y // 使能New IP内核侵入式修改插桩函数注册,使能New IP的同时必须使用New IP HOOKS功能 CONFIG_NEWIP_HOOKS=y // 使能New IP内核侵入式修改插桩函数注册,使能New IP的同时必须使用New IP HOOKS功能
VENDOR_HOOKS=y // 使能内核插桩基础框架(New IP依赖此配置项,rk3568开发板已默认开启)
``` ```
另有部分CONFIG被依赖: 代码编译完成后,通过下面命令可以确认New IP协议栈代码是否使能成功。
```c ```
VENDOR_HOOKS=y // 使能内核插桩基础框架 find out/ -name *nip*.o
...
out/kernel/OBJ/linux-5.10/net/newip/nip_addrconf_core.o
out/kernel/OBJ/linux-5.10/net/newip/nip_hdr_decap.o
out/kernel/OBJ/linux-5.10/net/newip/nip_addr.o
out/kernel/OBJ/linux-5.10/net/newip/nip_checksum.o
out/kernel/OBJ/linux-5.10/net/newip/tcp_nip_output.o
...
``` ```
备注: 备注:OpenHarmony linux内核要求所有原生内核代码侵入式修改,都要修改成插桩方式。例如下面IPv4,IPv6协议栈公共流程中增加New IP处理时,不能直接调用New IP函数,需要在公共流程中增加插桩点,New IP使能后在模块初始化时将xx功能函数注册到对应的函数指针上,下面公共流程就可以通过函数指针的形式调用到New IP的函数。
1. 只在Linux 5.10内核上支持New IP内核协议栈。
2. OpenHarmony linux内核要求所有原生内核代码侵入式修改,都要修改成插桩方式。
```c ```c
/* 将New IP ehash函数注册到内核 */ /* 将New IP ehash函数注册到内核 */
...@@ -142,24 +150,12 @@ static u32 sk_ehashfn(const struct sock *sk) ...@@ -142,24 +150,12 @@ static u32 sk_ehashfn(const struct sock *sk)
} }
``` ```
### New IP禁用
在rk3568开发板内核模块配置文件中搜索NEWIP,将其“CONFIG_NEWIP=y”和“CONFIG_NEWIP_HOOKS=y”删除或使用#注释掉即可。
代码编译完成后,通过下面命令可以确认New IP协议栈代码是否使能成功。
```c
find out/ -name *nip*.o
out/rk3568/obj/third_party/glib/glib/glib_source/guniprop.o
out/kernel/OBJ/linux-5.10/net/newip/nip_addrconf_core.o
out/kernel/OBJ/linux-5.10/net/newip/nip_hdr_decap.o
out/kernel/OBJ/linux-5.10/net/newip/nip_addr.o
out/kernel/OBJ/linux-5.10/net/newip/nip_checksum.o
out/kernel/OBJ/linux-5.10/net/newip/tcp_nip_output.o
...
``` ```
# kernel/linux/config/linux-5.10/arch/arm64/configs/rk3568_standard_defconfig
禁用New IP内核协议栈,删除CONFIG_NEWIP使能开关,删除out/kernel目录后重新编译。
```c
# CONFIG_NEWIP is not set # CONFIG_NEWIP is not set
# CONFIG_NEWIP_HOOKS is not set # CONFIG_NEWIP_HOOKS is not set
``` ```
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
## 简介 ## 简介
用户身份和访问管理子系统,下称用户IAM(Identity and Access Management),旨在为OpenHarmony提供统一用户身份凭据信息管理和用户身份认证框架能力,支持多用户分别设置认证凭据信息,并根据用户设置的认证凭据信息提供用户身份认证功能,支撑锁屏等安全场景。同时,用户IAM子系统也提供API,支持三方开发者调用系统提供的身份认证能力来实现业务对用户的访问控制要求。 用户身份和访问管理子系统,下称用户IAM(Identity and Access Management),旨在为OpenHarmony提供统一用户身份凭据管理和身份认证的能力,支持多用户分别设置凭据信息,并根据用户设置的凭据信息提供用户身份认证功能,支撑锁屏和支付等安全场景。同时,用户IAM子系统也提供对外的接口供三方应用调用,实现业务对用户的访问控制要求。
**图1** 子系统架构图 **图1** 子系统架构图
...@@ -14,15 +14,14 @@ ...@@ -14,15 +14,14 @@
- **用户身份凭据管理:** 向上提供系统内统一的用户身份凭据信息管理接口,向下通过认证执行器管理模块,调用系统内的认证资源,完成用户身份凭据的生命周期管理和安全存储。 - **用户身份凭据管理:** 向上提供系统内统一的用户身份凭据信息管理接口,向下通过认证执行器管理模块,调用系统内的认证资源,完成用户身份凭据的生命周期管理和安全存储。
- **认证执行器管理:** 提供认证资源管理和认证会话管理功能,支持系统内身份认证相关**执行器**<sup></sup>统一管理和协同调度,支持不同类型的身份认证执行器灵活对接。 - **认证执行器管理:** 提供认证资源管理和认证会话管理功能,支持系统内身份认证相关**执行器**<sup></sup>统一管理和协同调度,支持不同类型的身份认证执行器灵活对接。
基于统一用户认证框架,系统可以扩展支持多种认证能力。OpenHarmony框架当前已经支持的**认证执行器**包含口令认证和人脸认证,开发者如果想实现新的认证执行器,只需要在新的部件内实现认证相关功能,并且按照执行器管理模块定义的接口与统一用户认证框架对接即可。 基于统一用户认证框架,系统可以扩展支持多种认证能力。OpenHarmony框架当前已经支持的**认证执行器**包含口令执行器和人脸执行器,开发者如果想实现新的认证执行器,只需要在新的部件内实现认证相关功能,并且按照执行器管理模块定义的接口与统一用户认证框架对接即可。
*注:在用户IAM子系统内,将一个用户身份认证操作的最小执行单元称为**执行器**,如一个口令认证模块,处理口令采集、口令处理和比对、口令安全存储的全过程,因此可以抽象为一个口令认证的全功能执行器。* *注:在用户IAM子系统内,将一个用户身份认证操作的最小执行单元称为**执行器**,如一个口令认证模块,包含口令采集、处理、安全存储和口令比对的全过程,因此可以抽象为一个口令认证的全功能执行器。*
## 目录 ## 目录
```undefined ```undefined
//base/user_iam //base/useriam
├── user_auth_framework # 用户认证框架,包括用户认证、凭据管理和执行器管理 ├── user_auth_framework # 用户认证框架,包括用户认证、凭据管理和执行器管理
├── face_auth # 人脸认证部件,与认证执行器管理对接,支持人脸录入、删除和人脸认证功能 ├── face_auth # 人脸认证部件,与认证执行器管理对接,支持人脸录入、删除和人脸认证功能
├── pin_auth # 口令认证部件,与认证执行器管理对接,支持口令录入、删除和口令认证功能 ├── pin_auth # 口令认证部件,与认证执行器管理对接,支持口令录入、删除和口令认证功能
...@@ -31,7 +30,7 @@ ...@@ -31,7 +30,7 @@
## 约束 ## 约束
1. 用户身份凭据信息管理类操作,是系统内的关键操作,相关接口只支持系统基础应用调用。 1. 用户身份凭据信息管理类操作,是系统内的关键操作,相关接口只支持系统基础应用调用。
2. 执行器内部真正完成用户凭据信息的处理,因此只支持系统服务实现执行器的功能,与认证执行器管理模块对接。 2. 执行器内部真正完成用户凭据信息的处理,因此只支持系统服务实现执行器的功能,与认证执行器管理模块对接。
## 说明 ## 说明
...@@ -39,7 +38,7 @@ ...@@ -39,7 +38,7 @@
### 使用说明 ### 使用说明
1. 统一用户认证框架必须配合一个认证执行器才可以使用。 1. 统一用户认证框架必须配合一个认证执行器才可以使用。
2. 系统内默认存在的第一个认证执行器应该是口令执行器。 2. 系统内默认存在的第一个认证执行器是口令执行器。
## 相关仓 ## 相关仓
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册