diff --git a/CODEOWNERS b/CODEOWNERS index 734621c462063c03350bc7671614f6d34c23f418..b5776edf2a9eb6f1ca0441e380ef32dfc8757117 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -460,62 +460,64 @@ zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md @RaySh zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-wantAgent.md @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen -zh-cn/application-dev/reference/errorcodes/errcode-ability.md @RayShih -zh-cn/application-dev/reference/errorcodes/errcode-access-token.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-accessibility.md @RayShih -zh-cn/application-dev/reference/errorcodes/errcode-account.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-animator.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-app-account.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-audio.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-avsession.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-backgroundTaskMgr.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-batteryStatistics.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-brightness.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-buffer.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-bundle.md @RayShih -zh-cn/application-dev/reference/errorcodes/errcode-colorspace-manager.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-CommonEventService.md @RayShih -zh-cn/application-dev/reference/errorcodes/errcode-containers.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-data-rdb.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-datashare.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-device-manager.md @qinxiaowang -zh-cn/application-dev/reference/errorcodes/errcode-DeviceUsageStatistics.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-display.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-distributed-dataObject.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-distributedKVStore.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-DistributedNotificationService.md @RayShih -zh-cn/application-dev/reference/errorcodes/errcode-DistributedSchedule.md @RayShih -zh-cn/application-dev/reference/errorcodes/errcode-enterpriseDeviceManager.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-faultlogger.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-filemanagement.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-geoLocationManager.md @RayShih -zh-cn/application-dev/reference/errorcodes/errcode-hiappevent.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-hisysevent.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-hiviewdfx-hidebug.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-huks.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-i18n.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-inputmethod-framework.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-multimodalinput.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-nfc.md @RayShih -zh-cn/application-dev/reference/errorcodes/errcode-pasteboard.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-power.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-preferences.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-promptAction.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-reminderAgentManager.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-request.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-resource-manager.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-router.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-rpc.md @qinxiaowang -zh-cn/application-dev/reference/errorcodes/errcode-runninglock.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-sensor.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-system-parameterV9.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-thermal.md @zengyawen -zh-cn/application-dev/reference/errorcodes/errcode-uitest.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-universal.md @RayShih -zh-cn/application-dev/reference/errorcodes/errcode-update.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-usb.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-vibrator.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-webview.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-window.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-workScheduler.md @HelloCrease -zh-cn/application-dev/reference/errorcodes/errcode-zlib.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-ability.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-accessibility.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-account.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-animator.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-app-account.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-audio.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-avsession.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-batteryStatistics.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-brightness.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-buffer.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-colorspace-manager.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-CommonEventService.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-containers.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-data-rdb.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-datashare.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-device-manager.md @qinxiaowang +zh-cn/application-dev/reference/errorcodes/errorcode-DeviceUsageStatistics.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-display.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-distributed-dataObject.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-DistributedNotificationService.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-DistributedSchedule.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-enterpriseDeviceManager.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-geoLocationManager.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-hiappevent.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-hisysevent.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-hiviewdfx-hidebug.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-huks.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-i18n.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-multimodalinput.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-power.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-preferences.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-request.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-router.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md @qinxiaowang +zh-cn/application-dev/reference/errorcodes/errorcode-runninglock.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-sensor.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-system-parameterV9.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-thermal.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-uitest.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-universal.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-update.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-usb.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-vibrator.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-webview.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-window.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md @RayShih +zh-cn/release-notes/changelogs @majiajun518 \ No newline at end of file diff --git a/en/application-dev/ability/fa-formability.md b/en/application-dev/ability/fa-formability.md index c1cadebe652dbd9f195e96ed1dec221df0eff849..377d5e4b8faeda387f4eda5a6506d103c3d76395 100644 --- a/en/application-dev/ability/fa-formability.md +++ b/en/application-dev/ability/fa-formability.md @@ -1,49 +1,49 @@ # FA Widget Development ## 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: -- Widget provider: an atomic service that controls what and how content is displayed in a widget and interacts 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 Manager: a resident agent that manages widgets added to the system and provides functions such as periodic widget update. +Before you get started, it would be helpful if you have a basic understanding of the following concepts: +- 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 widget location. +- Widget Manager: a resident agent that provides widget management features such as periodic widget updates. > **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 -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**. -- Create a **FormBindingData** instance. -- Update a widget through **FormProvider**. -- Develop the widget UI pages. +1. Implement lifecycle callbacks by using the **LifecycleForm** APIs. +2. Create a **FormBindingData** instance. +3. Update a widget by using the **FormProvider** APIs. +4. Develop the widget UI pages. ## 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 | 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.| | 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. | | 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. | -| onAcquireFormState?(want: Want): formInfo.FormState | Called when the widget provider receives the status query result of a widget. | +| onDestroy(formId: string): void | Called to notify the widget provider that a widget has been destroyed. | +| 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 @@ -56,9 +56,9 @@ For details about the **FormProvider** APIs, see [FormProvider](../reference/api ## 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. @@ -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' ``` -2. Implement the lifecycle callbacks of **LifecycleForm**. +2. Implement lifecycle callbacks for the widget. ```javascript export default { @@ -87,7 +87,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li console.log('FormAbility onCastToNormal'); }, 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'); let obj = { "title": "titleOnUpdate", @@ -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 -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 | | -------- | ------------------------------------------------------------ | -------- | ------------------------ | | 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 | | window | Window-related configurations. | Object | Yes | - | type | Type of the JavaScript component. Available values are as follows:
**normal**: indicates that the JavaScript component is an application instance.
**form**: indicates that the JavaScript component is a widget instance.| String | Yes (initial value: **normal**)| + | type | Type of the JavaScript component.
**normal**: indicates an application instance.
**form**: indicates a widget instance.| String | Yes (initial value: **normal**)| | mode | Development mode of the JavaScript component. | Object | Yes (initial value: left empty) | - A configuration example is as follows: + Example configuration: ```json "js": [{ @@ -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 | | ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ | | 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) | | isDefault | Whether the widget is a default one. Each ability has only one default widget.
**true**: The widget is the default one.
**false**: The widget is not the default one.| Boolean | No | - | type | Type of the widget. Available values are as follows:
**JS**: indicates a JavaScript-programmed widget. | String | No | - | colorMode | Color mode of the widget. Available values are as follows:
**auto**: The widget adopts the auto-adaptive color mode.
**dark**: The widget adopts the dark color mode.
**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:
**1 * 2**: indicates a grid with one row and two columns.
**2 * 2**: indicates a grid with two rows and two columns.
**2 * 4**: indicates a grid with two rows and four columns.
**4 * 4**: indicates a grid with four rows and four columns.| String array| No | + | type | Type of the widget.
**JS**: indicates a JavaScript-programmed widget. | String | No | + | colorMode | Color mode of the widget.
**auto**: The widget adopts the auto-adaptive color mode.
**dark**: The widget adopts the dark color mode.
**light**: The widget adopts the light color mode.| String | Yes (initial value: **auto**)| + | supportDimensions | Grid styles supported by the widget.
**1 * 2**: indicates a grid with one row and two columns.
**2 * 2**: indicates a grid with two rows and two columns.
**2 * 4**: indicates a grid with two rows and four columns.
**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 | - | updateEnabled | Whether the widget can be updated periodically. Available values are as follows:
**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.
**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.
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**) | - | updateDuration | Interval to update the widget. The value is a natural number, in the unit of 30 minutes.
If the value is **0**, this field does not take effect.
If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.
This parameter has a higher priority than **scheduledUpdateTime**. If both are specified, the value specified by **updateDuration** is used.| Number | Yes (initial value: **0**) | + | updateEnabled | Whether the widget can be updated periodically.
**true**: The widget can be updated at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** takes precedence over **scheduledUpdateTime**.
**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.
**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.
If the value is **0**, this field does not take effect.
If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.
**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) | | 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 | | 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) | - A configuration example is as follows: + Example configuration: ```json "abilities": [{ @@ -197,7 +197,7 @@ Configure the **config.json** file for the widget. ### 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 onCreate(want) { @@ -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 onDestroy(formId) { 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. 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 -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 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'); let obj = { "title": "titleOnUpdate", @@ -267,9 +267,9 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme > **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
@@ -284,7 +284,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme
``` - - In the CSS file: + - CSS file: ```css .container { @@ -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 { "data": { @@ -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: -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: - - **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. - **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: - - **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**. The code snippet is as follows: - - In the HML file: + - HML file: ```html
@@ -378,7 +378,7 @@ The code snippet is as follows:
``` - - In the JSON file: + - JSON file: ```json { "data": { diff --git a/en/application-dev/ability/stage-ability.md b/en/application-dev/ability/stage-ability.md index 3457aa29249a7c569053a09b6374cf03ce0d8868..d09585b25531556cfbee2ab5cbd45c72191aa8a4 100644 --- a/en/application-dev/ability/stage-ability.md +++ b/en/application-dev/ability/stage-ability.md @@ -1,6 +1,6 @@ # Ability Development ## When to Use -Ability development in the [stage model](stage-brief.md) is significantly different from that in the FA model. The stage model requires you to declare the application package structure in the `module.json5` and `app.json5` files during application development. For details about the configuration file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). To develop an ability based on the stage model, implement the following logic: +Ability development in the [stage model](stage-brief.md) is significantly different from that in the FA model. The stage model requires you to declare the application package structure in the **module.json5** and **app.json5** files during application development. For details about the configuration file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). To develop an ability based on the stage model, implement the following logic: - Create an ability that supports screen viewing and human-machine interaction. You must implement the following scenarios: ability lifecycle callbacks, obtaining ability configuration, requesting permissions, and notifying environment changes. - Start an ability. You need to implement ability startup on the same device, on a remote device, or with a specified UI page. - Call abilities. For details, see [Call Development](stage-call.md). @@ -8,15 +8,15 @@ Ability development in the [stage model](stage-brief.md) is significantly differ - Continue the ability on another device. For details, see [Ability Continuation Development](stage-ability-continuation.md). ### Launch Type -An ability can be launched in the **standard**, **singleton**, or **specified** mode, as configured by `launchType` in the `module.json5` file. Depending on the launch type, the action performed when the ability is started differs, as described below. +An ability can be launched in the **standard**, **singleton**, or **specified** mode, as configured by **launchType** in the **module.json5** file. Depending on the launch type, the action performed when the ability is started differs, as described below. | Launch Type | Description |Action | | ----------- | ------- |---------------- | -| standard | Standard mode. | A new instance is started each time an ability starts.| -| singleton | Singleton mode. | The ability has only one instance in the system. If an instance already exists when an ability is started, that instance is reused.| +| standard | Standard mode | A new instance is started each time an ability starts.| +| singleton | Singleton mode | The ability has only one instance in the system. If an instance already exists when an ability is started, that instance is reused.| | specified | Instance-specific| The internal service of an ability determines whether to create multiple instances during running.| -By default, the singleton mode is used. The following is an example of the `module.json5` file: +By default, the singleton mode is used. The following is an example of the **module.json5** file: ```json { "module": { @@ -30,7 +30,7 @@ By default, the singleton mode is used. The following is an example of the `modu ``` ## Creating an Ability ### Available APIs -The table below describes the APIs provided by the `AbilityStage` class, which has the `context` attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md). +The table below describes the APIs provided by the **AbilityStage** class, which has the **context** attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md). **Table 1** AbilityStage APIs |API|Description| @@ -39,7 +39,7 @@ The table below describes the APIs provided by the `AbilityStage` class, which h |onAcceptWant(want: Want): string|Called when a specified ability is started.| |onConfigurationUpdated(config: Configuration): void|Called when the global configuration is updated.| -The table below describes the APIs provided by the `Ability` class. For details about the APIs, see [Ability](../reference/apis/js-apis-application-ability.md). +The table below describes the APIs provided by the **Ability** class. For details about the APIs, see [Ability](../reference/apis/js-apis-application-ability.md). **Table 2** Ability APIs @@ -47,19 +47,19 @@ The table below describes the APIs provided by the `Ability` class. For details |:------|:------| |onCreate(want: Want, param: AbilityConstant.LaunchParam): void|Called when an ability is created.| |onDestroy(): void|Called when the ability is destroyed.| -|onWindowStageCreate(windowStage: window.WindowStage): void|Called when a `WindowStage` is created for the ability. You can use the `window.WindowStage` APIs to implement operations such as page loading.| -|onWindowStageDestroy(): void|Called when the `WindowStage` is destroyed for the ability.| +|onWindowStageCreate(windowStage: window.WindowStage): void|Called when a **WindowStage** is created for the ability. You can use the **window.WindowStage** APIs to implement operations such as page loading.| +|onWindowStageDestroy(): void|Called when the **WindowStage** is destroyed for the ability.| |onForeground(): void|Called when the ability is switched to the foreground.| |onBackground(): void|Called when the ability is switched to the background.| -|onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void|Called when the ability launch type is set to `singleton`.| +|onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void|Called when the ability launch type is set to **singleton**.| |onConfigurationUpdated(config: Configuration): void|Called when the configuration of the environment where the ability is running is updated.| ### Implementing AbilityStage and Ability Lifecycle Callbacks -To create Page abilities for an application in the stage model, you must implement the `AbilityStage` class and ability lifecycle callbacks, and use the `Window` APIs to set the pages. The sample code is as follows: -1. Import the `AbilityStage` module. +To create Page abilities for an application in the stage model, you must implement the **AbilityStage** class and ability lifecycle callbacks, and use the **Window** class to set the pages. The sample code is as follows: +1. Import the **AbilityStage** module. ``` import AbilityStage from "@ohos.application.AbilityStage" ``` -2. Implement the `AbilityStage` class. The default relative path generated by the APIs is **entry\src\main\ets\Application\AbilityStage.ts**. +2. Implement the **AbilityStage** class. The default relative path generated by the APIs is **entry\src\main\ets\Application\AbilityStage.ts**. ```ts export default class MyAbilityStage extends AbilityStage { onCreate() { @@ -67,13 +67,13 @@ To create Page abilities for an application in the stage model, you must impleme } } ``` -3. Import the `Ability` module. +3. Import the **Ability** module. ```js import Ability from '@ohos.application.Ability' ``` -4. Implement the lifecycle callbacks of the `Ability` class. The default relative path generated by the APIs is **entry\src\main\ets\MainAbility\MainAbility.ts**. +4. Implement the lifecycle callbacks of the **Ability** class. The default relative path generated by the APIs is **entry\src\main\ets\MainAbility\MainAbility.ts**. - In the `onWindowStageCreate(windowStage)` API, use `loadContent` to set the application page to be loaded. For details about how to use the `Window` APIs, see [Window Development](../windowmanager/application-window-stage.md). + In the **onWindowStageCreate(windowStage)** API, use **loadContent** to set the application page to be loaded. For details about how to use the **Window** APIs, see [Window Development](../windowmanager/application-window-stage.md). ```ts export default class MainAbility extends Ability { onCreate(want, launchParam) { @@ -108,9 +108,9 @@ To create Page abilities for an application in the stage model, you must impleme } ``` ### Obtaining AbilityStage and Ability Configurations -Both the `AbilityStage` and `Ability` classes have the `context` attribute. An application can obtain the context of an `Ability` instance through `this.context` to obtain the configuration details. +Both the **AbilityStage** and **Ability** classes have the **context** attribute. An application can obtain the context of an **Ability** instance through **this.context** to obtain the configuration details. -The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `AbilityStage` class. The sample code is as follows: +The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the **context** attribute in the **AbilityStage** class. The sample code is as follows: ```ts import AbilityStage from "@ohos.application.AbilityStage" @@ -130,7 +130,7 @@ export default class MyAbilityStage extends AbilityStage { } ``` -The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `Ability` class. The sample code is as follows: +The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the **context** attribute in the **Ability** class. The sample code is as follows: ```ts import Ability from '@ohos.application.Ability' export default class MainAbility extends Ability { @@ -149,9 +149,9 @@ export default class MainAbility extends Ability { } ``` ### Requesting Permissions -If an application needs to obtain user privacy information or use system capabilities, for example, obtaining location information or using the camera to take photos or record videos, it must request the respective permission from consumers. During application development, you need to specify the involved sensitive permissions, declare the required permissions in `module.json5`, and use the `requestPermissionsFromUser` API to request the permission from consumers in the form of a dialog box. The following uses the permission for calendar access as an example. +If an application needs to obtain user privacy information or use system capabilities, for example, obtaining location information or using the camera to take photos or record videos, it must request the respective permission from consumers. During application development, you need to specify the involved sensitive permissions, declare the required permissions in **module.json5**, and use the **requestPermissionsFromUser** API to request the permission from consumers in the form of a dialog box. The following uses the permission for calendar access as an example. -Declare the required permission in the `module.json5` file. +Declare the required permission in the **module.json5** file. ```json "requestPermissions": [ { @@ -170,13 +170,13 @@ context.requestPermissionsFromUser(permissions).then((data) => { }) ``` ### Notifying of Environment Changes -Environment changes include changes of global configurations and ability configurations. Currently, the global configurations include the system language and color mode. The change of global configurations is generally triggered by configuration items in **Settings** or icons in **Control Panel**. The ability configuration is specific to a single `Ability` instance, including the display ID, screen resolution, and screen orientation. The configuration is related to the display where the ability is located, and the change is generally triggered by the window. For details on the configuration, see [Configuration](../reference/apis/js-apis-configuration.md). +Environment changes include changes of global configurations and ability configurations. Currently, the global configurations include the system language and color mode. The change of global configurations is generally triggered by configuration items in **Settings** or icons in **Control Panel**. The ability configuration is specific to a single **Ability** instance, including the display ID, screen resolution, and screen orientation. The configuration is related to the display where the ability is located, and the change is generally triggered by the window. For details on the configuration, see [Configuration](../reference/apis/js-apis-configuration.md). -For an application in the stage model, when the configuration changes, its abilities are not restarted, but the `onConfigurationUpdated(config: Configuration)` callback is triggered. If the application needs to perform processing based on the change, you can overwrite `onConfigurationUpdated`. Note that the `Configuration` object in the callback contains all the configurations of the current ability, not only the changed configurations. +For an application in the stage model, when the configuration changes, its abilities are not restarted, but the **onConfigurationUpdated(config: Configuration)** callback is triggered. If the application needs to perform processing based on the change, you can overwrite **onConfigurationUpdated**. Note that the **Configuration** object in the callback contains all the configurations of the current ability, not only the changed configurations. -The following example shows the implementation of the `onConfigurationUpdated` callback in the `AbilityStage` class. The callback is triggered when the system language and color mode are changed. +The following example shows the implementation of the **onConfigurationUpdated** callback in the **AbilityStage** class. The callback is triggered when the system language and color mode are changed. ```ts -import Ability from '@ohos.application.Ability' +import AbilityStage from '@ohos.application.AbilityStage' import ConfigurationConstant from '@ohos.application.ConfigurationConstant' export default class MyAbilityStage extends AbilityStage { @@ -188,7 +188,7 @@ export default class MyAbilityStage extends AbilityStage { } ``` -The following example shows the implementation of the `onConfigurationUpdated` callback in the `Ability` class. The callback is triggered when the system language, color mode, or display parameters (such as the direction and density) change. +The following example shows the implementation of the **onConfigurationUpdated** callback in the **Ability** class. The callback is triggered when the system language, color mode, or display parameters (such as the direction and density) change. ```ts import Ability from '@ohos.application.Ability' import ConfigurationConstant from '@ohos.application.ConfigurationConstant' @@ -209,7 +209,7 @@ export default class MainAbility extends Ability { ``` ## Starting an Ability ### Available APIs -The `Ability` class has the `context` attribute, which belongs to the `AbilityContext` class. The `AbilityContext` class has the `abilityInfo`, `currentHapModuleInfo`, and other attributes as well as the APIs used for starting abilities. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md). +The **Ability** class has the **context** attribute, which belongs to the **AbilityContext** class. The **AbilityContext** class has the **abilityInfo**, **currentHapModuleInfo**, and other attributes as well as the APIs used for starting abilities. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md). **Table 3** AbilityContext APIs |API|Description| @@ -223,7 +223,7 @@ The `Ability` class has the `context` attribute, which belongs to the `AbilityCo |startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void|Starts an ability with the execution result and account ID.| |startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\|Starts an ability with the execution result and account ID.| ### Starting an Ability on the Same Device -An application can obtain the context of an `Ability` instance through `this.context` and then use the `startAbility` API in the `AbilityContext` class to start the ability. The ability can be started by specifying `Want`, `StartOptions`, and `accountId`, and the operation result can be returned using a callback or `Promise` instance. The sample code is as follows: +An application can obtain the context of an **Ability** instance through **this.context** and then use the **startAbility** API in the **AbilityContext** class to start the ability. The ability can be started by specifying **Want**, **StartOptions**, and **accountId**, and the operation result can be returned using a callback or **Promise** instance. The sample code is as follows: ```ts let context = this.context var want = { @@ -239,7 +239,7 @@ context.startAbility(want).then(() => { ``` ### Starting an Ability on a Remote Device ->This feature applies only to system applications, since the `getTrustedDeviceListSync` API of the `DeviceManager` class is open only to system applications. +>This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. In the cross-device scenario, you must specify the ID of the remote device. The sample code is as follows: ```ts let context = this.context @@ -254,7 +254,7 @@ context.startAbility(want).then(() => { console.error("Failed to start remote ability with error: " + JSON.stringify(error)) }) ``` -Obtain the ID of a specified device from `DeviceManager`. The sample code is as follows: +Obtain the ID of a specified device from **DeviceManager**. The sample code is as follows: ```ts import deviceManager from '@ohos.distributedHardware.deviceManager'; function getRemoteDeviceId() { @@ -271,11 +271,11 @@ function getRemoteDeviceId() { } } ``` -Request the permission `ohos.permission.DISTRIBUTED_DATASYNC` from consumers. This permission is used for data synchronization. For details about the sample code for requesting the permission, see [Requesting Permissions](##requesting-permissions). +Request the permission **ohos.permission.DISTRIBUTED_DATASYNC** from consumers. This permission is used for data synchronization. For details about the sample code for requesting the permission, see [Requesting Permissions](#requesting-permissions). ### Starting an Ability with the Specified Page -If the launch type of an ability is set to `singleton` and the ability has been started, the `onNewWant` callback is triggered when the ability is started again. You can pass start options through the `want`. For example, to start an ability with the specified page, use the `uri` or `parameters` parameter in the `want` to pass the page information. Currently, the ability in the stage model cannot directly use the `router` capability. You must pass the start options to the custom component and invoke the `router` method to display the specified page during the custom component lifecycle management. The sample code is as follows: +If the launch type of an ability is set to **singleton** and the ability has been started, the **onNewWant** callback is triggered when the ability is started again. You can pass start options through the **want**. For example, to start an ability with the specified page, use the **uri** or **parameters** parameter in the **want** to pass the page information. Currently, the ability in the stage model cannot directly use the **router** capability. You must pass the start options to the custom component and invoke the **router** method to display the specified page during the custom component lifecycle management. The sample code is as follows: -When using `startAbility` to start an ability again, use the `uri` parameter in the `want` to pass the page information. +When using **startAbility** to start an ability again, use the **uri** parameter in the **want** to pass the page information. ```ts async function reStartAbility() { try { @@ -291,7 +291,7 @@ async function reStartAbility() { } ``` -Obtain the `want` parameter that contains the page information from the `onNewWant` callback of the ability. +Obtain the **want** parameter that contains the page information from the **onNewWant** callback of the ability. ```ts import Ability from '@ohos.application.Ability' @@ -302,7 +302,7 @@ export default class MainAbility extends Ability { } ``` -Obtain the `want` parameter that contains the page information from the custom component and process the route based on the URI. +Obtain the **want** parameter that contains the page information from the custom component and process the route based on the URI. ```ts import router from '@ohos.router' @@ -315,7 +315,7 @@ struct Index { console.info('Index onPageShow') let newWant = globalThis.newWant if (newWant.hasOwnProperty("uri")) { - router.push({ uri: newWant.uri }); + router.push({ url: newWant.uri }); globalThis.newWant = undefined } } diff --git a/en/application-dev/reference/apis/js-apis-colorSpaceManager.md b/en/application-dev/reference/apis/js-apis-colorSpaceManager.md index ca879b489145b7d741cdf990e36656b78cd3033b..044fab3c6456d47e9a342b78770f10dc8f58c87d 100644 --- a/en/application-dev/reference/apis/js-apis-colorSpaceManager.md +++ b/en/application-dev/reference/apis/js-apis-colorSpaceManager.md @@ -64,6 +64,14 @@ Creates a standard color space object. | ------------------ | ------------------------ | | [ColorSpaceManager](#colorspacemanager) | Color space object created. | +**Error codes** + +For details about the error codes, see [colorSpaceManager Error Codes](../errorcodes/errorcode-colorspace-manager.md). + +| ID| Error Message| +| ------- | ----------------------- | +| 18600001 | Parameter value is abnormal. | + **Example** ```js @@ -96,6 +104,14 @@ Creates a custom color space object. | ------------------ | ------------------------ | | [ColorSpaceManager](#colorspacemanager) | Color space object created.
The color space type is **CUSTOM** of [ColorSpace](#colorspace).| +**Error codes** + +For details about the error codes, see [colorSpaceManager Error Codes](../errorcodes/errorcode-colorspace-manager.md). + +| ID| Error Message| +| ------- | ----------------------- | +| 18600001 | Parameter value is abnormal. | + **Example** ```js @@ -138,11 +154,19 @@ Obtains the color space type. | ------------------ | ------------------------ | | [ColorSpace](#colorspace) | Color space type.| +**Error codes** + +For details about the error codes, see [colorSpaceManager Error Codes](../errorcodes/errorcode-colorspace-manager.md). + +| ID| Error Message| +| ------- | ----------------------- | +| 18600001 | Parameter value is abnormal. | + **Example** ```js try { - let csType = colorSpace.getColorSpaceName(); + colorSpace.getColorSpaceName(); } catch (err) { console.log(`Fail to get colorSpace's name. Cause: ` + JSON.stringify(err)); } @@ -162,11 +186,19 @@ Obtains the coordinates of the white point of the color space. | ------------------ | ------------------------ | | Array\ | Coordinates [x, y] of the white point.| +**Error codes** + +For details about the error codes, see [colorSpaceManager Error Codes](../errorcodes/errorcode-colorspace-manager.md). + +| ID| Error Message| +| ------- | ----------------------- | +| 18600001 | Parameter value is abnormal. | + **Example** ```js try { - let wp = colorSpace.getWhitePoint(); + colorSpace.getWhitePoint(); } catch (err) { console.log(`Failed to get white point. Cause: ` + JSON.stringify(err)); } @@ -186,11 +218,19 @@ Obtains the gamma of the color space. | ------------------ | ------------------------ | | number | Gamma of the color space.| +**Error codes** + +For details about the error codes, see [colorSpaceManager Error Codes](../errorcodes/errorcode-colorspace-manager.md). + +| ID| Error Message| +| ------- | ----------------------- | +| 18600001 | Parameter value is abnormal. | + **Example** ```js try { - let gamma = colorSpace.getGamma(); + colorSpace.getGamma(); } catch (err) { console.log(`Failed to get gamma. Cause: ` + JSON.stringify(err)); } diff --git a/en/application-dev/reference/apis/js-apis-configuration.md b/en/application-dev/reference/apis/js-apis-configuration.md index 14abee7e2d9cca63278e11b16486643d89e56bd0..25c57c7d5f0a6b7a1e8073fc9313bb92562b8576 100644 --- a/en/application-dev/reference/apis/js-apis-configuration.md +++ b/en/application-dev/reference/apis/js-apis-configuration.md @@ -3,7 +3,7 @@ The **Configuration** module provides environment configuration information. > **NOTE** -> +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -16,11 +16,11 @@ import Configuration from '@ohos.application.Configuration'; **System capability**: SystemCapability.Ability.AbilityBase - | Name| Type| Readable| Writable| Description| + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| language | string | Yes| Yes| Language of the application.| -| colorMode | [ColorMode](js-apis-configurationconstant.md) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.| -| direction9+ | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.| -| screenDensity9+ | ScreenDensity | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).| -| displayId9+ | number | Yes| No| ID of the display where the application is located.| -| hasPointerDevice9+ | boolean | Yes| No| Whether the pointer device is connected.| +| language | string | Yes| Yes| Language of the application.| +| colorMode | [ColorMode](js-apis-configurationconstant.md) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.| +| direction9+ | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.| +| screenDensity9+ | ScreenDensity | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).| +| displayId9+ | number | Yes| No| ID of the display where the application is located.| +| hasPointerDevice9+ | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.| diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md index 153397a41d715c1814a143a4ff051e6964ba29eb..cad744cb266c3c5712de9d441fe0a56a1fc4ccbc 100644 --- a/en/application-dev/reference/apis/js-apis-data-preferences.md +++ b/en/application-dev/reference/apis/js-apis-data-preferences.md @@ -22,8 +22,8 @@ import data_preferences from '@ohos.data.preferences'; | Name | Type| Readable| Writable| Description | | ---------------- | -------- | ---- | ---- | --------------------------------------- | -| MAX_KEY_LENGTH | string | Yes | No | Maximum length of a key. The key must be less than 80 bytes. | -| MAX_VALUE_LENGTH | string | Yes | No | Maximum length of a value. The value must be less than 8192 bytes.| +| MAX_KEY_LENGTH | number | Yes | No | Maximum length of a key. The key must be less than 80 bytes. | +| MAX_VALUE_LENGTH | number | Yes | No | Maximum length of a value. The value must be less than 8192 bytes.| ## data_preferences.getPreferences @@ -50,16 +50,19 @@ FA model: // Obtain the context. import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); - let preferences = null; -data_preferences.getPreferences(context, 'mystore', function (err, object) { - if (err) { - console.info("Failed to get the preferences. Cause: " + err); - return; - } - preferences = object; - console.info("Got the preferences successfully."); -}) + +try { + data_preferences.getPreferences(context, 'mystore', function (err, val) { + if (err) { + console.info("Failed to get the preferences. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Got the preferences successfully."); + }) +} catch (err) { + console.info("Failed to get the preferences. code =" + err.code + ", message =" + err.message); +} ``` Stage model: @@ -75,14 +78,17 @@ class MainAbility extends Ability{ } let preferences = null; -data_preferences.getPreferences(context, 'mystore', function (err, object) { - if (err) { - console.info("Failed to get the preferences. Cause: " + err); - return; - } - preferences = object; - console.info("Got the preferences successfully."); -}) +try { + data_preferences.getPreferences(context, 'mystore', function (err, val) { + if (err) { + console.info("Failed to get the preferences. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Got the preferences successfully."); + }) +} catch (err) { + console.info("Failed to get the preferences. code =" + err.code + ", message =" + err.message); +} ``` ## data_preferences.getPreferences @@ -116,13 +122,17 @@ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); let preferences = null; -let promise = data_preferences.getPreferences(context, 'mystore'); -promise.then((object) => { - preferences = object; - console.info("Got the preferences successfully."); -}).catch((err) => { - console.info("Failed to get the preferences. Cause: " + err); -}) +try { + let promise = data_preferences.getPreferences(context, 'mystore'); + promise.then((object) => { + preferences = object; + console.info("Got the preferences successfully."); + }).catch((err) => { + console.log("Failed to get the preferences. code =" + err.code + ", message =" + err.message); + }) +} catch(err) { + console.log("Failed to get the preferences. code =" + err.code + ", message =" + err.message); +} ``` Stage model: @@ -138,13 +148,17 @@ class MainAbility extends Ability{ } let preferences = null; -let promise = data_preferences.getPreferences(context, 'mystore'); -promise.then((object) => { - preferences = object; - console.info("Got the preferences successfully."); -}).catch((err) => { - console.info("Failed to get the preferences. Cause: " + err); -}) +try { + let promise = data_preferences.getPreferences(context, 'mystore'); + promise.then((object) => { + preferences = object; + console.info("Got the preferences successfully."); + }).catch((err) => { + console.log("Failed to get the preferences. code =" + err.code + ", message =" + err.message); + }) +} catch(err) { + console.log("Failed to get the preferences. code =" + err.code + ", message =" + err.message); +} ``` ## data_preferences.deletePreferences @@ -167,6 +181,14 @@ The deleted **Preferences** instance cannot be used for data operations. Otherwi | name | string | Yes | Name of the **Preferences** instance to delete. | | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.| +**Error codes** + +For details about the following error codes, see [Preference Error Codes](../errorcodes/errorcode-preferences.md). + +| ID| Error Message | +| -------- | ------------------------------| +| 15500010 | Failed to delete the preferences. | + **Example** FA model: @@ -176,13 +198,17 @@ FA model: import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); -data_preferences.deletePreferences(context, 'mystore', function (err) { - if (err) { - console.info("Failed to delete the preferences. Cause: " + err); - return; - } - console.info("Deleted the preferences successfully." ); -}) +try { + data_preferences.deletePreferences(context, 'mystore', function (err, val) { + if (err) { + console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Deleted the preferences successfully." ); + }) +} catch (err) { + console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); +} ``` Stage model: @@ -197,13 +223,17 @@ class MainAbility extends Ability{ } } -data_preferences.deletePreferences(context, 'mystore', function (err) { - if (err) { - console.info("Failed to delete the preferences. Cause: " + err); - return; - } - console.info("Deleted the preferences successfully." ); -}) +try { + data_preferences.deletePreferences(context, 'mystore', function (err, val) { + if (err) { + console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Deleted the preferences successfully." ); + }) +} catch (err) { + console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); +} ``` ## data_preferences.deletePreferences @@ -231,6 +261,14 @@ The deleted **Preferences** instance cannot be used for data operations. Otherwi | ------------------- | ------------------------- | | Promise<void> | Promise that returns no value.| +**Error codes** + +For details about the following error codes, see [Preference Error Codes](../errorcodes/errorcode-preferences.md). + +| ID| Error Message | +| -------- | ------------------------------| +| 15500010 | Failed to delete the preferences. | + **Example** FA model: @@ -240,12 +278,16 @@ FA model: import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); -let promise = data_preferences.deletePreferences(context, 'mystore'); -promise.then(() => { - console.info("Deleted the preferences successfully."); -}).catch((err) => { - console.info("Failed to delete the preferences. Cause: " + err); -}) +try { + let promise = data_preferences.deletePreferences(context, 'mystore'); + promise.then(() => { + console.info("Deleted the preferences successfully."); + }).catch((err) => { + console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); + }) +} catch(err) { + console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); +} ``` Stage model: @@ -260,12 +302,16 @@ class MainAbility extends Ability{ } } -let promise = data_preferences.deletePreferences(context, 'mystore'); -promise.then(() => { - console.info("Deleted the preferences successfully."); -}).catch((err) => { - console.info("Failed to delete the preferences. Cause: " + err); -}) +try{ + let promise = data_preferences.deletePreferences(context, 'mystore'); + promise.then(() => { + console.info("Deleted the preferences successfully."); + }).catch((err) => { + console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); + }) +} catch(err) { + console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); +} ``` ## data_preferences.removePreferencesFromCache @@ -295,13 +341,17 @@ FA model: import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); -data_preferences.removePreferencesFromCache(context, 'mystore', function (err) { - if (err) { - console.info("Failed to remove the preferences. Cause: " + err); - return; - } - console.info("Removed the preferences successfully."); -}) +try { + data_preferences.removePreferencesFromCache(context, 'mystore', function (err, val) { + if (err) { + console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Removed the preferences successfully."); + }) +} catch (err) { + console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); +} ``` Stage model: @@ -316,13 +366,18 @@ class MainAbility extends Ability{ } } -data_preferences.removePreferencesFromCache(context, 'mystore', function (err) { - if (err) { - console.info("Failed to remove the preferences. Cause: " + err); - return; - } - console.info("Removed the preferences successfully."); -}) +try { + data_preferences.removePreferencesFromCache(context, 'mystore', function (err, val) { + if (err) { + console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Removed the preferences successfully."); + }) +} catch (err) { + console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); +} + ``` ## data_preferences.removePreferencesFromCache @@ -357,12 +412,16 @@ FA model: import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); -let promise = data_preferences.removePreferencesFromCache(context, 'mystore'); -promise.then(() => { - console.info("Removed the preferences successfully."); -}).catch((err) => { - console.info("Failed to remove the preferences. Cause: " + err); -}) +try { + let promise = data_preferences.removePreferencesFromCache(context, 'mystore'); + promise.then(() => { + console.info("Removed the preferences successfully."); + }).catch((err) => { + console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); + }) +} catch(err) { + console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); +} ``` Stage model: @@ -377,12 +436,16 @@ class MainAbility extends Ability{ } } -let promise = data_preferences.removePreferencesFromCache(context, 'mystore'); -promise.then(() => { - console.info("Removed the preferences successfully."); -}).catch((err) => { - console.info("Failed to remove the preferences. Cause: " + err); -}) +try { + let promise = data_preferences.removePreferencesFromCache(context, 'mystore'); + promise.then(() => { + console.info("Removed the preferences successfully."); + }).catch((err) => { + console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); + }) +} catch(err) { + console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); +} ``` ## Preferences @@ -411,13 +474,17 @@ Obtains the value of a key. This API uses an asynchronous callback to return the **Example** ```js -preferences.get('startup', 'default', function(err, data) { - if (err) { - console.info("Failed to get the value of 'startup'. Cause: " + err); - return; - } - console.info("Got the value of 'startup'. Data: " + data); -}) +try { + preferences.get('startup', 'default', function (err, val) { + if (err) { + console.info("Failed to get the value of 'startup'. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Obtained the value of 'startup' successfully. val: " + val); + }) +} catch (err) { + console.info("Failed to get the value of 'startup'. code =" + err.code + ", message =" + err.message); +} ``` @@ -445,12 +512,16 @@ Obtains the value of a key. This API uses a promise to return the result. If the **Example** ```js -let promise = preferences.get('startup', 'default'); -promise.then((data) => { - console.info("Got the value of 'startup'. Data: " + data); -}).catch((err) => { - console.info("Failed to get the value of 'startup'. Cause: " + err); -}) +try { + let promise = preferences.get('startup', 'default'); + promise.then((data) => { + console.info("Got the value of 'startup'. Data: " + data); + }).catch((err) => { + console.info("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message); + }) +} catch(err) { + console.info("Failed to get the value of 'startup'. code =" + err.code + ", message =" + err.message); +} ``` ### getAll @@ -470,15 +541,19 @@ Obtains an **Object** instance that contains all KV pairs. This API uses an asyn **Example** ```js -preferences.getAll(function (err, value) { - if (err) { - console.info("Failed to get all KV pairs. Cause: " + err); - return; - } +try { + preferences.getAll(function (err, value) { + if (err) { + console.info("Failed to get all KV pairs. code =" + err.code + ", message =" + err.message); + return; + } let allKeys = Object.keys(value); console.info("getAll keys = " + allKeys); console.info("getAll object = " + JSON.stringify(value)); -}); + }) +} catch (err) { + console.info("Failed to get all KV pairs. code =" + err.code + ", message =" + err.message); +} ``` @@ -499,14 +574,18 @@ Obtains an **Object** instance that contains all KV pairs. This API uses a promi **Example** ```js -let promise = preferences.getAll(); -promise.then((value) => { - let allKeys = Object.keys(value); - console.info('getAll keys = ' + allKeys); - console.info("getAll object = " + JSON.stringify(value)); -}).catch((err) => { - console.info("Failed to get all KV pairs. Cause: " + err); -}) +try { + let promise = preferences.getAll(); + promise.then((value) => { + let allKeys = Object.keys(value); + console.info('getAll keys = ' + allKeys); + console.info("getAll object = " + JSON.stringify(value)); + }).catch((err) => { + console.info("Failed to get all KV pairs. code =" + err.code + ", message =" + err.message); + }) +} catch (err) { + console.info("Failed to get all KV pairs. code =" + err.code + ", message =" + err.message); +} ``` ### put @@ -528,13 +607,17 @@ Writes data to this **Preferences** instance. This API uses an asynchronous call **Example** ```js -preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Failed to put the value of 'startup'. Cause: " + err); - return; - } - console.info("Put the value of 'startup' successfully."); -}) +try { + preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Failed to put the value of 'startup'. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Put the value of 'startup' successfully."); + }) +} catch (err) { + console.info("Failed to put the value of 'startup'. code =" + err.code + ", message =" + err.message); +} ``` @@ -562,12 +645,16 @@ Writes data to this **Preferences** instance. This API uses a promise to return **Example** ```js -let promise = preferences.put('startup', 'auto'); -promise.then(() => { - console.info("Put the value of 'startup' successfully."); -}).catch((err) => { - console.info("Failed to put the value of 'startup'. Cause: " + err); -}) +try { + let promise = preferences.put('startup', 'auto'); + promise.then(() => { + console.info("Put the value of 'startup' successfully."); + }).catch((err) => { + console.info("Failed to put the value of 'startup'. code =" + err.code +", message =" + err.message); + }) +} catch(err) { + console.info("Failed to put the value of 'startup'. code =" + err.code +", message =" + err.message); +} ``` @@ -589,17 +676,21 @@ Checks whether this **Preferences** instance contains a KV pair with the given k **Example** ```js -preferences.has('startup', function (err, isExist) { - if (err) { - console.info("Failed to check the key 'startup'. Cause: " + err); - return; - } - if (isExist) { - console.info("The key 'startup' is contained."); - } else { - console.info("The key 'startup' is not contained."); - } -}) +try { + preferences.has('startup', function (err, val) { + if (err) { + console.info("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message); + return; + } + if (val) { + console.info("The key 'startup' is contained."); + } else { + console.info("The key 'startup' is not contained."); + } + }) +} catch (err) { + console.info("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message); +} ``` @@ -626,16 +717,20 @@ Checks whether this **Preferences** instance contains a KV pair with the given k **Example** ```js -let promise = preferences.has('startup'); -promise.then((isExist) => { - if (isExist) { - console.info("The key 'startup' is contained."); - } else { - console.info("The key 'startup' is not contained."); - } -}).catch((err) => { - console.info("Failed to check the key 'startup'. Cause: " + err); -}) +try { + let promise = preferences.has('startup'); + promise.then((val) => { + if (val) { + console.info("The key 'startup' is contained."); + } else { + console.info("The key 'startup' is not contained."); + } + }).catch((err) => { + console.info("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message); + }) +} catch(err) { + console.info("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message); +} ``` @@ -643,7 +738,7 @@ promise.then((isExist) => { delete(key: string, callback: AsyncCallback<void>): void -Deletes a KV pair from this **Preferences** instance. This API uses an asynchronous callback to return the result. +Deletes a KV pair from this **Preferences** instance based on the specified key. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -657,13 +752,17 @@ Deletes a KV pair from this **Preferences** instance. This API uses an asynchron **Example** ```js -preferences.delete('startup', function (err) { - if (err) { - console.info("Failed to delete the key 'startup'. Cause: " + err); - return; - } - console.info("Deleted the key 'startup'."); -}) +try { + preferences.delete('startup', function (err) { + if (err) { + console.info("Failed to delete the key 'startup'. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Deleted the key 'startup'."); + }) +} catch (err) { + console.info("Failed to delete the key 'startup'. code =" + err.code + ", message =" + err.message); +} ``` @@ -690,12 +789,16 @@ Deletes a KV pair from this **Preferences** instance. This API uses a promise to **Example** ```js -let promise = preferences.delete('startup'); -promise.then(() => { - console.info("Deleted the key 'startup'."); -}).catch((err) => { - console.info("Failed to delete the key 'startup'. Cause: " + err); -}) +try { + let promise = preferences.delete('startup'); + promise.then(() => { + console.info("Deleted the key 'startup'."); + }).catch((err) => { + console.log("Failed to delete the key 'startup'. code =" + err.code +", message =" + err.message); + }) +} catch(err) { + console.log("Failed to delete the key 'startup'. code =" + err.code +", message =" + err.message); +} ``` @@ -716,13 +819,17 @@ Saves the data of this **Preferences** instance to a file asynchronously. This A **Example** ```js -preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data. Cause: " + err); - return; - } - console.info("Flushed data successfully."); -}) +try { + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Flushed data successfully."); + }) +} catch (err) { + console.info("Failed to flush data. code =" + err.code + ", message =" + err.message); +} ``` @@ -743,12 +850,16 @@ Saves the data of this **Preferences** instance to a file asynchronously. This A **Example** ```js -let promise = preferences.flush(); -promise.then(() => { - console.info("Flushed data to file successfully.") -}).catch((err) => { - console.info("Failed to flush data. Cause: " + err); -}) +try { + let promise = preferences.flush(); + promise.then(() => { + console.info("Flushed data successfully."); + }).catch((err) => { + console.info("Failed to flush data. code =" + err.code + ", message =" + err.message); + }) +} catch (err) { + console.info("Failed to flush data. code =" + err.code + ", message =" + err.message); +} ``` @@ -769,13 +880,17 @@ Clears this **Preferences** instance. This API uses an asynchronous callback to **Example** ```js -preferences.clear(function (err) { - if (err) { - console.info("Failed to clear data. Cause: " + err); - return; - } - console.info("Cleared data successfully."); -}) +try { + preferences.clear(function (err) { + if (err) { + console.info("Failed to clear data. code =" + err.code + ", message =" + err.message); + return; + } + console.info("Cleared data successfully."); + }) +} catch (err) { + console.info("Failed to clear data. code =" + err.code + ", message =" + err.message); +} ``` @@ -796,12 +911,16 @@ Clears this **Preferences** instance. This API uses a promise to return the resu **Example** ```js -let promise = preferences.clear() -promise.then(() => { - console.info("Cleared data successfully."); -}).catch((err) => { - console.info("Failed to clear data. Cause: " + err); -}) +try { + let promise = preferences.clear(); + promise.then(() => { + console.info("Cleared data successfully."); + }).catch((err) => { + console.info("Failed to clear data. code =" + err.code + ", message =" + err.message); + }) +} catch(err) { + console.info("Failed to clear data. code =" + err.code + ", message =" + err.message); +} ``` @@ -823,31 +942,35 @@ Subscribes to data changes. A callback will be triggered to return the new value **Example** ```js -data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences."); - return; - } - let observer = function (key) { - console.info("The key " + key + " changed."); - } - preferences.on('change', observer); - preferences.put('startup', 'manual', function (err) { - if (err) { - console.info("Failed to put the value of 'startup'. Cause: " + err); - return; - } - console.info("Put the value of 'startup' successfully."); - - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data. Cause: " + err); - return; - } - console.info("Flushed data successfully."); // The observer will be called. - }) - }) -}) +try { + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { + console.info("Failed to get the preferences."); + return; + } + let observer = function (key) { + console.info("The key " + key + " changed."); + } + preferences.on('change', observer); + preferences.put('startup', 'manual', function (err) { + if (err) { + console.info("Failed to put the value of 'startup'. Cause: " + err); + return; + } + console.info("Put the value of 'startup' successfully."); + + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data. Cause: " + err); + return; + } + console.info("Flushed data successfully."); + }) + }) + }) +} catch (err) { + console.info("Failed to flush data. code =" + err.code + ", message =" + err.message); +} ``` @@ -869,32 +992,36 @@ Unsubscribes from data changes. **Example** ```js -data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences."); - return; - } - let observer = function (key) { - console.info("The key " + key + " changed."); - } - preferences.on('change', observer); - preferences.put('startup', 'auto', function (err) { +try { + data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { if (err) { - console.info("Failed to put the value of 'startup'. Cause: " + err); + console.info("Failed to get the preferences."); return; } - console.info("Put the value of 'startup' successfully."); - - preferences.flush(function (err) { + let observer = function (key) { + console.info("The key " + key + " changed."); + } + preferences.on('change', observer); + preferences.put('startup', 'auto', function (err) { if (err) { - console.info("Failed to flush data. Cause: " + err); + console.info("Failed to put the value of 'startup'. Cause: " + err); return; } - console.info("Flushed data successfully."); // The observer will be called. + console.info("Put the value of 'startup' successfully."); + + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data. Cause: " + err); + return; + } + console.info("Flushed data successfully."); + }) + preferences.off('change', observer); }) - preferences.off('change', observer); }) -}) +} catch (err) { + console.info("Failed to flush data. code =" + err.code + ", message =" + err.message); +} ``` ## ValueType diff --git a/en/application-dev/reference/apis/js-apis-data-resultset.md b/en/application-dev/reference/apis/js-apis-data-resultset.md index 28cde770498760d5eac09dc79c5b495f91d05c4a..798ac7bba0926f47e1bc16eb6b672403bc082fa7 100644 --- a/en/application-dev/reference/apis/js-apis-data-resultset.md +++ b/en/application-dev/reference/apis/js-apis-data-resultset.md @@ -2,13 +2,551 @@ A result set is a set of results returned after the relational database (RDB) query APIs are called. You can use the **resultset** APIs to obtain required data. -> **NOTE**
+> **NOTE** > > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Usage +## ResultSetV99+ -You need to use [RdbStore.query()](js-apis-data-rdb.md#query) to obtain a **resultSet** object. +Provides methods to access the result set, which is obtained by querying the RDB store. + +### Usage + +You need to obtain the **resultSetV9** instance by using [RdbStoreV9.query()](js-apis-data-rdb.md#query). + +```js +import dataRdb from '@ohos.data.rdb'; +let predicatesV9 = new dataRdb.RdbPredicatesV9("EMPLOYEE"); +predicatesV9.equalTo("AGE", 18); +let promise = rdbStoreV9.query(predicatesV9, ["ID", "NAME", "AGE", "SALARY", "CODES"]); +promise.then((resultSetV9) => { + console.log(TAG + "resultSet columnNames:" + resultSetV9.columnNames); + console.log(TAG + "resultSet columnCount:" + resultSetV9.columnCount); +}); +``` + +### Attributes9+ + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +| Name | Type | Mandatory| Description | +| ------------ | ------------------- | ---- | -------------------------------- | +| columnNames | Array<string> | Yes | Names of all columns in the result set. | +| columnCount | number | Yes | Number of columns in the result set. | +| rowCount | number | Yes | Number of rows in the result set. | +| rowIndex | number | Yes | Index of the current row in the result set. | +| isAtFirstRow | boolean | Yes | Whether the cursor is in the first row of the result set. | +| isAtLastRow | boolean | Yes | Whether the cursor is in the last row of the result set. | +| isEnded | boolean | Yes | Whether the cursor is after the last row of the result set.| +| isStarted | boolean | Yes | Whether the cursor has been moved. | +| isClosed | boolean | Yes | Whether the result set is closed. | + +### getColumnIndex9+ + +getColumnIndex(columnName: string): number + +Obtains the column index based on the column name. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------------------------- | +| columnName | string | Yes | Column name specified.| + +**Return value** + +| Type | Description | +| ------ | ------------------ | +| number | Index of the column obtained.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800013 | The column value is null or the column type is incompatible. | + +**Example** + + ```js +resultSetV9.goToFirstRow(); +const id = resultSetV9.getLong(resultSetV9.getColumnIndex("ID")); +const name = resultSetV9.getString(resultSetV9.getColumnIndex("NAME")); +const age = resultSetV9.getLong(resultSetV9.getColumnIndex("AGE")); +const salary = resultSetV9.getDouble(resultSetV9.getColumnIndex("SALARY")); + ``` + +### getColumnName9+ + +getColumnName(columnIndex: number): string + +Obtains the column name based on the column index. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | -------------------------- | +| columnIndex | number | Yes | Column index specified.| + +**Return value** + +| Type | Description | +| ------ | ------------------ | +| string | Column name obtained.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800013 | The column value is null or the column type is incompatible. | + +**Example** + + ```js +const id = resultSetV9.getColumnName(0); +const name = resultSetV9.getColumnName(1); +const age = resultSetV9.getColumnName(2); + ``` + +### goTo9+ + +goTo(offset:number): boolean + +Moves the cursor to the row based on the specified offset. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------------- | +| offset | number | Yes | Offset relative to the current position.| + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800012 | The result set is empty or the specified location is invalid. | + +**Example** + + ```js +let predicatesV9goto = new dataRdb.RdbPredicatesV9("EMPLOYEE"); +let promisequerygoto = rdbStoreV9.query(predicatesV9goto, ["ID", "NAME", "AGE", "SALARY", "CODES"]); +promisequerygoto.then((resultSetV9) => { + resultSetV9.goTo(1); + resultSetV9.close(); +}).catch((err) => { + console.log('query failed'); +}); + ``` + +### goToRow9+ + +goToRow(position: number): boolean + +Moves the cursor to the specified row in the result set. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------ | +| position | number | Yes | Position to which the cursor is to be moved.| + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800012 | The result set is empty or the specified location is invalid. | + +**Example** + + ```js +let predicatesV9gotorow = new dataRdb.RdbPredicatesV9("EMPLOYEE"); +let promisequerygotorow = rdbStoreV9.query(predicatesV9gotorow, ["ID", "NAME", "AGE", "SALARY", "CODES"]); +promisequerygotorow.then((resultSetV9) => { + resultSetV9.goToRow(5); + resultSetV9.close(); +}).catch((err) => { + console.log('query failed'); +}); + ``` + +### goToFirstRow9+ + +goToFirstRow(): boolean + + +Moves the cursor to the first row of the result set. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800012 | The result set is empty or the specified location is invalid. | + +**Example** + + ```js +let predicatesV9goFirst = new dataRdb.RdbPredicatesV9("EMPLOYEE"); +let promisequerygoFirst = rdbStoreV9.query(predicatesV9goFirst, ["ID", "NAME", "AGE", "SALARY", "CODES"]); +promisequerygoFirst.then((resultSetV9) => { + resultSetV9.goToFirstRow(); + resultSetV9.close(); +}).catch((err) => { + console.log('query failed'); +}); + ``` + +### goToLastRow9+ + +goToLastRow(): boolean + +Moves the cursor to the last row of the result set. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800012 | The result set is empty or the specified location is invalid. | + +**Example** + + ```js +let predicatesV9goLast = new dataRdb.RdbPredicatesV9("EMPLOYEE"); +let promisequerygoLast = rdbStoreV9.query(predicatesV9goLast, ["ID", "NAME", "AGE", "SALARY", "CODES"]); +promisequerygoLast.then((resultSetV9) => { + resultSetV9.goToLastRow(); + resultSetV9.close(); +}).catch((err) => { + console.log('query failed'); +}); + ``` + +### goToNextRow9+ + +goToNextRow(): boolean + +Moves the cursor to the next row in the result set. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800012 | The result set is empty or the specified location is invalid. | + +**Example** + + ```js +let predicatesV9goNext = new dataRdb.RdbPredicatesV9("EMPLOYEE"); +let promisequerygoNext = rdbStoreV9.query(predicatesV9goNext, ["ID", "NAME", "AGE", "SALARY", "CODES"]); +promisequerygoNext.then((resultSetV9) => { + resultSetV9.goToNextRow(); + resultSetV9.close(); +}).catch((err) => { + console.log('query failed'); +}); + ``` + +### goToPreviousRow9+ + +goToPreviousRow(): boolean + +Moves the cursor to the previous row in the result set. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800012 | The result set is empty or the specified location is invalid. | + +**Example** + + ```js +let predicatesV9goPrev = new dataRdb.RdbPredicatesV9("EMPLOYEE"); +let promisequerygoPrev = rdbStoreV9.query(predicatesV9goPrev, ["ID", "NAME", "AGE", "SALARY", "CODES"]); +promisequerygoPrev.then((resultSetV9) => { + resultSetV9.goToPreviousRow(); + resultSetV9.close(); +}).catch((err) => { + console.log('query failed'); +}); + ``` + +### getBlob9+ + +getBlob(columnIndex: number): Uint8Array + +Obtains the value in the specified column in the current row as a byte array. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ----------------------- | +| columnIndex | number | Yes | Index of the specified column, starting from 0.| + +**Return value** + +| Type | Description | +| ---------- | -------------------------------- | +| Uint8Array | Value in the specified column as a byte array.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800013 | The column value is null or the column type is incompatible. | + +**Example** + + ```js +const codes = resultSetV9.getBlob(resultSetV9.getColumnIndex("CODES")); + ``` + +### getString9+ + +getString(columnIndex: number): string + +Obtains the value in the specified column in the current row as a string. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ----------------------- | +| columnIndex | number | Yes | Index of the specified column, starting from 0.| + +**Return value** + +| Type | Description | +| ------ | ---------------------------- | +| string | Value in the specified column as a string.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800013 | The column value is null or the column type is incompatible. | + +**Example** + + ```js +const name = resultSetV9.getString(resultSetV9.getColumnIndex("NAME")); + ``` + +### getLong9+ + +getLong(columnIndex: number): number + +Obtains the value in the specified column in the current row as a Long. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ----------------------- | +| columnIndex | number | Yes | Index of the specified column, starting from 0.| + +**Return value** + +| Type | Description | +| ------ | -------------------------- | +| number | Value in the specified column as a Long.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800013 | The column value is null or the column type is incompatible. | + +**Example** + + ```js +const age = resultSetV9.getLong(resultSetV9.getColumnIndex("AGE")); + ``` + +### getDouble9+ + +getDouble(columnIndex: number): number + +Obtains the value in the specified column in the current row as a double. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ----------------------- | +| columnIndex | number | Yes | Index of the specified column, starting from 0.| + +**Return value** + +| Type | Description | +| ------ | ---------------------------- | +| number | Value in the specified column as a double.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800013 | The column value is null or the column type is incompatible. | + +**Example** + + ```js +const salary = resultSetV9.getDouble(resultSetV9.getColumnIndex("SALARY")); + ``` + +### isColumnNull9+ + +isColumnNull(columnIndex: number): boolean + +Checks whether the value in the specified column of the current row is null. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ----------------------- | +| columnIndex | number | Yes | Index of the specified column, starting from 0.| + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------------------- | +| boolean | Returns **true** if the value is null; returns **false** otherwise.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800013 | The column value is null or the column type is incompatible. | + +**Example** + + ```js +const isColumnNull = resultSetV9.isColumnNull(resultSetV9.getColumnIndex("CODES")); + ``` + +### close9+ + +close(): void + +Closes this result set. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Example** + + ```js +let predicatesV9Close = new dataRdb.RdbPredicatesV9("EMPLOYEE"); +let promiseClose = rdbStoreV9.query(predicatesV9Close, ["ID", "NAME", "AGE", "SALARY", "CODES"]); +promiseClose.then((resultSetV9) => { + resultSetV9.close(); +}).catch((err) => { + console.log('Failed to close the resultset'); +}); + ``` + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| ID| **Error Message** | +| ------------ | ------------------------------------------------------------ | +| 14800012 | The result set is empty or the specified location is invalid. | + +## ResultSet(deprecated) + +Provides methods to access the result set, which is obtained by querying the RDB store. + +> **NOTE** +> +> This object is supported since API version 7 and deprecated since API version 9. You are advised to use [ResultSetV9](#resultsetv99). + +### Usage + +You need to obtain a **resultSet** object by using [RdbStore.query()](js-apis-data-rdb.md#query). ```js import dataRdb from '@ohos.data.rdb'; @@ -21,11 +559,11 @@ promise.then((resultSet) => { }); ``` -## ResultSet +### Attributes(deprecated) -Provides methods to access the result set, which is obtained by querying the RDB store. - -### Attributes +> **NOTE** +> +> This parameter is supported since API version 7 and is deprecated since API version 9. You are advised to use [Attributes](#attributes9). **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -41,25 +579,29 @@ Provides methods to access the result set, which is obtained by querying the RDB | isStarted | boolean | Yes| Whether the cursor has been moved.| | isClosed | boolean | Yes| Whether the result set is closed.| -### getColumnIndex +### getColumnIndex(deprecated) getColumnIndex(columnName: string): number Obtains the column index based on the column name. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getColumnIndex](#getcolumnindex9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | columnName | string | Yes| Column name specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| columnName | string | Yes| Column name specified.| **Return value** - | Type| Description| - | -------- | -------- | - | number | Index of the column obtained.| +| Type| Description| +| -------- | -------- | +| number | Index of the column obtained.| **Example** @@ -71,25 +613,29 @@ Obtains the column index based on the column name. const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); ``` -### getColumnName +### getColumnName(deprecated) getColumnName(columnIndex: number): string Obtains the column name based on the column index. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getColumnName](#getcolumnname9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | columnIndex | number | Yes| Column index specified.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| columnIndex | number | Yes| Column index specified.| **Return value** - | Type| Description| - | -------- | -------- | - | string | Column name obtained.| +| Type| Description| +| -------- | -------- | +| string | Column name obtained.| **Example** @@ -99,32 +645,36 @@ Obtains the column name based on the column index. const age = resultSet.getColumnName(2); ``` -### goTo +### goTo(deprecated) goTo(offset:number): boolean Moves the cursor to the row based on the specified offset. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goTo](#goto9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | offset | number | Yes| Offset relative to the current position.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| offset | number | Yes| Offset relative to the current position.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** ```js let predicatesgoto = new dataRdb.RdbPredicates("EMPLOYEE"); let promisequerygoto = rdbStore.query(predicatesgoto, ["ID", "NAME", "AGE", "SALARY", "CODES"]); - promisequerygoto.then((resultSet) { + promisequerygoto.then((resultSet) => { resultSet.goTo(1); resultSet.close(); }).catch((err) => { @@ -132,32 +682,36 @@ Moves the cursor to the row based on the specified offset. }); ``` -### goToRow +### goToRow(deprecated) goToRow(position: number): boolean Moves the cursor to the specified row in the result set. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goToRow](#gotorow9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | position | number | Yes| Position to which the cursor is to be moved.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| position | number | Yes| Position to which the cursor is to be moved.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** ```js let predicatesgotorow = new dataRdb.RdbPredicates("EMPLOYEE"); let promisequerygotorow = rdbStore.query(predicatesgotorow, ["ID", "NAME", "AGE", "SALARY", "CODES"]); - promisequerygotorow.then((resultSet) { + promisequerygotorow.then((resultSet) => { resultSet.goToRow(5); resultSet.close(); }).catch((err) => { @@ -165,27 +719,30 @@ Moves the cursor to the specified row in the result set. }); ``` -### goToFirstRow +### goToFirstRow(deprecated) goToFirstRow(): boolean - Moves the cursor to the first row of the result set. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goToFirstRow](#gotofirstrow9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** ```js let predicatesgoFirst = new dataRdb.RdbPredicates("EMPLOYEE"); let promisequerygoFirst = rdbStore.query(predicatesgoFirst, ["ID", "NAME", "AGE", "SALARY", "CODES"]); - promisequerygoFirst.then((resultSet) { + promisequerygoFirst.then((resultSet) => { resultSet.goToFirstRow(); resultSet.close(); }).catch((err) => { @@ -193,26 +750,30 @@ Moves the cursor to the first row of the result set. }); ``` -### goToLastRow +### goToLastRow(deprecated) goToLastRow(): boolean Moves the cursor to the last row of the result set. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goToLastRow](#gotolastrow9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** ```js let predicatesgoLast = new dataRdb.RdbPredicates("EMPLOYEE"); let promisequerygoLast = rdbStore.query(predicatesgoLast, ["ID", "NAME", "AGE", "SALARY", "CODES"]); - promisequerygoLast.then((resultSet) { + promisequerygoLast.then((resultSet) => { resultSet.goToLastRow(); resultSet.close(); }).catch((err) => { @@ -220,26 +781,30 @@ Moves the cursor to the last row of the result set. }); ``` -### goToNextRow +### goToNextRow(deprecated) goToNextRow(): boolean Moves the cursor to the next row in the result set. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goToNextRow](#gotonextrow9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** ```js let predicatesgoNext = new dataRdb.RdbPredicates("EMPLOYEE"); let promisequerygoNext = rdbStore.query(predicatesgoNext, ["ID", "NAME", "AGE", "SALARY", "CODES"]); - promisequerygoNext.then((resultSet) { + promisequerygoNext.then((resultSet) => { resultSet.goToNextRow(); resultSet.close(); }).catch((err) => { @@ -247,26 +812,30 @@ Moves the cursor to the next row in the result set. }); ``` -### goToPreviousRow +### goToPreviousRow(deprecated) goToPreviousRow(): boolean Moves the cursor to the previous row in the result set. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goToPreviousRow](#gotopreviousrow9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** ```js let predicatesgoPrev = new dataRdb.RdbPredicates("EMPLOYEE"); let promisequerygoPrev = rdbStore.query(predicatesgoPrev, ["ID", "NAME", "AGE", "SALARY", "CODES"]); - promisequerygoPrev.then((resultSet) { + promisequerygoPrev.then((resultSet) => { resultSet.goToPreviousRow(); resultSet.close(); }).catch((err) => { @@ -274,25 +843,29 @@ Moves the cursor to the previous row in the result set. }); ``` -### getBlob +### getBlob(deprecated) getBlob(columnIndex: number): Uint8Array Obtains the value in the specified column in the current row as a byte array. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getBlob](#getblob9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | columnIndex | number | Yes| Index of the specified column, starting from 0.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| columnIndex | number | Yes| Index of the specified column, starting from 0.| **Return value** - | Type| Description| - | -------- | -------- | - | Uint8Array | Value in the specified column as a byte array.| +| Type| Description| +| -------- | -------- | +| Uint8Array | Value in the specified column as a byte array.| **Example** @@ -300,25 +873,29 @@ Obtains the value in the specified column in the current row as a byte array. const codes = resultSet.getBlob(resultSet.getColumnIndex("CODES")); ``` -### getString +### getString(deprecated) getString(columnIndex: number): string Obtains the value in the specified column in the current row as a string. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getString](#getstring9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | columnIndex | number | Yes| Index of the specified column, starting from 0.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| columnIndex | number | Yes| Index of the specified column, starting from 0.| **Return value** - | Type| Description| - | -------- | -------- | - | string | Value in the specified column as a string.| +| Type| Description| +| -------- | -------- | +| string | Value in the specified column as a string.| **Example** @@ -326,25 +903,29 @@ Obtains the value in the specified column in the current row as a string. const name = resultSet.getString(resultSet.getColumnIndex("NAME")); ``` -### getLong +### getLong(deprecated) getLong(columnIndex: number): number Obtains the value in the specified column in the current row as a Long. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getLong](#getlong9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | columnIndex | number | Yes| Index of the specified column, starting from 0.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| columnIndex | number | Yes| Index of the specified column, starting from 0.| **Return value** - | Type| Description| - | -------- | -------- | - | number | Value in the specified column as a Long.| +| Type| Description| +| -------- | -------- | +| number | Value in the specified column as a Long.| **Example** @@ -352,25 +933,29 @@ Obtains the value in the specified column in the current row as a Long. const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); ``` -### getDouble +### getDouble(deprecated) getDouble(columnIndex: number): number Obtains the value in the specified column in the current row as a double. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDouble](#getdouble9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | columnIndex | number | Yes| Index of the specified column, starting from 0.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| columnIndex | number | Yes| Index of the specified column, starting from 0.| **Return value** - | Type| Description| - | -------- | -------- | - | number | Value in the specified column as a double.| +| Type| Description| +| -------- | -------- | +| number | Value in the specified column as a double.| **Example** @@ -378,25 +963,29 @@ Obtains the value in the specified column in the current row as a double. const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); ``` -### isColumnNull +### isColumnNull(deprecated) isColumnNull(columnIndex: number): boolean Checks whether the value in the specified column of the current row is null. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isColumnNull](#iscolumnnull9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | columnIndex | number | Yes| Index of the specified column, starting from 0.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| columnIndex | number | Yes| Index of the specified column, starting from 0.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the value is null; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the value is null; returns **false** otherwise.| **Example** @@ -404,12 +993,16 @@ Checks whether the value in the specified column of the current row is null. const isColumnNull = resultSet.isColumnNull(resultSet.getColumnIndex("CODES")); ``` -### close +### close(deprecated) close(): void Closes this result set. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [close](#close9). + **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **Example** @@ -417,9 +1010,9 @@ Closes this result set. ```js let predicatesClose = new dataRdb.RdbPredicates("EMPLOYEE"); let promiseClose = rdbStore.query(predicatesClose, ["ID", "NAME", "AGE", "SALARY", "CODES"]); - promiseClose.then((resultSet) { + promiseClose.then((resultSet) => { resultSet.close(); }).catch((err) => { - console.log('Failed to close resultset'); + console.log('Failed to close the resultset'); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-data-storage.md b/en/application-dev/reference/apis/js-apis-data-storage.md index f01e1a3ab8db3d7fb42d8362a35e29455066b15e..b724dfabc1fed1e99d98ad5bba715d81d91677b8 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -22,10 +22,10 @@ import data_storage from '@ohos.data.storage'; **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -| Name | Type | Readable | Writable | Description | -| ---------------- | ------ | -------- | -------- | ----------------------------------------------------------- | -| MAX_KEY_LENGTH | string | Yes | No | Maximum length of a key. It must be less than 80 bytes. | -| MAX_VALUE_LENGTH | string | Yes | No | Maximum length of a value. It must be less than 8192 bytes. | +| Name | Type| Readable| Writable| Description | +| ---------------- | -------- | ---- | ---- | ------------------------------------- | +| MAX_KEY_LENGTH | number | Yes | No | Maximum length of a key. It must be less than 80 bytes. | +| MAX_VALUE_LENGTH | number | Yes | No | Maximum length of a value. It must be less than 8192 bytes.| ## data_storage.getStorageSync @@ -53,8 +53,8 @@ Reads the specified file and loads its data to the **Storage** instance for data ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -86,8 +86,8 @@ Reads the specified file and loads its data to the **Storage** instance for data ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -129,8 +129,8 @@ Reads the specified file and loads its data to the **Storage** instance for data ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -165,8 +165,8 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -195,8 +195,8 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -237,8 +237,8 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -271,8 +271,8 @@ Removes the singleton **Storage** instance of a file from the cache. The removed ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -302,8 +302,8 @@ Removes the singleton **Storage** instance of a file from the cache. The removed ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -344,8 +344,8 @@ Removes the singleton **Storage** instance of a file from the cache. The removed ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -864,15 +864,15 @@ Subscribes to data changes. The **StorageObserver** needs to be implemented. Whe **Parameters** -| Name | Type | Description | -| -------- | --------------------------------------------------- | ---------------------------------------- | -| type | string | Event type. The value **change** indicates data change events.| -| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ------ |---------------------------------------- | +| type | string |Yes| Event type. The value **change** indicates data change events.| +| callback | Callback<[StorageObserver](#storageobserver)> | Yes|Callback used to return data changes. | **Example** ```js -var observer = function (key) { +let observer = function (key) { console.info("The key of " + key + " changed."); } storage.on('change', observer); @@ -891,15 +891,15 @@ Unsubscribes from data changes. **Parameters** -| Name | Type | Description | -| -------- | --------------------------------------------------- | ---------------------------------------- | -| type | string | Event type. The value **change** indicates data change events.| -| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ------ |---------------------------------------- | +| type | string |Yes| Event type. The value **change** indicates data change events.| +| callback | Callback<[StorageObserver](#storageobserver)> | Yes|Callback used to return data changes. | **Example** ```js -var observer = function (key) { +let observer = function (key) { console.info("The key of " + key + " changed."); } storage.off('change', observer); diff --git a/en/application-dev/reference/apis/js-apis-huks.md b/en/application-dev/reference/apis/js-apis-huks.md index a886b6c643be1295bd49f0bf166d1e244d82f9af..f5eaa37329b675708a0f3068ba2d1d8d25202d20 100644 --- a/en/application-dev/reference/apis/js-apis-huks.md +++ b/en/application-dev/reference/apis/js-apis-huks.md @@ -1,12 +1,12 @@ # HUKS +The **HUKS** module provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations. +The keys managed by OpenHarmony Universal KeyStore (HUKS) can be imported by applications or generated by calling the HUKS APIs. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -The **HUKS** module provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations. -The keys managed by OpenHarmony Universal KeyStore (HUKS) can be imported by applications or generated by calling the HUKS APIs. - ## Modules to Import ```js @@ -75,7 +75,7 @@ Generates a key. This API uses an asynchronous callback to return the result. | -------- | --------------------------- | ---- | --------------------------------------------- | | keyAlias | string | Yes | Alias of the key. | | options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, no **err** value is returned; otherwise, an error code is returned.| +| callback | AsyncCallback\ | Yes | Callback that returns no value.| **Example** @@ -186,7 +186,7 @@ Deletes a key. This API uses an asynchronous callback to return the result. | -------- | --------------------------- | ---- | --------------------------------------------- | | keyAlias | string | Yes | Key alias passed in when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, no **err** value is returned; otherwise, an error code is returned.| +| callback | AsyncCallback\ | Yes | Callback that returns no value.| **Example** @@ -289,7 +289,7 @@ Imports a key in plaintext. This API uses an asynchronous callback to return the | -------- | --------------------------- | ---- | --------------------------------------------- | | keyAlias | string | Yes | Alias of the key. | | options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key to import. | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, no **err** value is returned; otherwise, an error code is returned.| +| callback | AsyncCallback\ | Yes | Callback that returns no value.| **Example** @@ -553,7 +553,7 @@ Obtains the certificate used to verify a key. This API uses a promise to return | Type | Description | | ---------------------------------------------- | --------------------------------------------- | -| Promise<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result. If **err** is not returned, the operation is successful. Otherwise, an error occurs.| +| Promise<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result. If the operation is successful, no **err** value is returned; otherwise, an error code is returned.| **Example** @@ -676,7 +676,7 @@ Imports a wrapped key. This API uses an asynchronous callback to return the resu | keyAlias | string | Yes | Alias of the wrapped key to import. | | wrappingKeyAlias | string | Yes | Alias of the data used to unwrap the key imported. | | options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and the wrapped key to import.| -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, no **err** value is returned; otherwise, an error code is returned.| +| callback | AsyncCallback\ | Yes | Callback that returns no value.| **Example** @@ -926,7 +926,7 @@ Exports a key. This API uses an asynchronous callback to return the result. | -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result. If **HUKS_SUCCESS** is returned, the operation is successful. Otherwise, an error occurs. **outData** contains the public key exported.| +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned and **outData** contains the public key exported. If the operation fails, an error code is returned. | **Example** @@ -968,7 +968,7 @@ Exports a key. This API uses a promise to return the result. | Type | Description | | ---------------------------------------------- | ------------------------------------------------------------ | -| Promise<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result. If **err** is not returned, the operation is successful. Otherwise, an error occurs. **outData** contains the public key exported.| +| Promise<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result. If the operation is successful, no **err** value is returned and **outData** contains the public key exported. If the operation fails, an error code is returned. | **Example** @@ -1005,7 +1005,7 @@ Obtains key properties. This API uses an asynchronous callback to return the res | -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result. If **errorCode** is **HUKS_SUCCESS**, the operation is successful. Otherwise, an error occurs.| +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result. If the operation is successful, **errorCode** is **HUKS_SUCCESS**; otherwise, an error code is returned.| **Example** @@ -1047,7 +1047,7 @@ Obtains key properties. This API uses a promise to return the result. | Type | Description | | ----------------------------------------------- | ------------------------------------------------------------ | -| Promise\<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result. If **err** is not returned, the operation is successful. Otherwise, an error occurs. **properties** returns the parameters required for generating the key.| +| Promise\<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result. If the operation is successful, no **err** value is returned and **properties** contains the parameters required for generating the key. If the operation fails, an error code is returned. | **Example** @@ -1084,7 +1084,7 @@ Checks whether a key exists. This API uses an asynchronous callback to return th | -------- | --------------------------- | ---- | --------------------------------------- | | keyAlias | string | Yes | Alias of the key to check. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. The value **TRUE** means that the key exists, and **FALSE** means the opposite.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. **TRUE** means that the key exists; **FALSE** means the opposite.| **Example** @@ -1126,7 +1126,7 @@ Checks whether a key exists. This API uses a promise to return the result. | Type | Description | | ----------------- | --------------------------------------- | -| Promise\ | Promise used to return the result. The value **TRUE** means that the key exists, and **FALSE** means the opposite.| +| Promise\ | Promise used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite.| **Example** @@ -1315,7 +1315,7 @@ Aborts the use of the key. This API uses an asynchronous callback to return the | -------- | --------------------------- | ---- | ------------------------------------------- | | handle | number | Yes | Handle of the **Abort** operation. | | options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Abort** operation. | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| +| callback | AsyncCallback\ | Yes | Callback that returns no value.| **Example** @@ -1465,7 +1465,7 @@ Aborts the use of the key. This API uses a promise to return the result. | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise that returns no value.| **Example** @@ -1993,7 +1993,7 @@ Generates a key. This API uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Alias of the key. | | options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If **HUKS_SUCCESS** is returned, the operation is successful. For details about other results, see HuksResult.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code defined in **HuksResult** is returned.| **Example** @@ -2050,7 +2050,7 @@ Generates a key. This API uses a promise to return the result. | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If **HUKS_SUCCESS** is returned, the operation is successful. Otherwise, an error occurs.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| **Example** @@ -2099,7 +2099,7 @@ Deletes a key. This API uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | -------------------------------------------------- | | keyAlias | string | Yes | Key alias passed in when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If **HUKS_SUCCESS** is returned, the operation is successful. Otherwise, an error occurs.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| **Example** @@ -2133,7 +2133,7 @@ Deletes a key. This API uses a promise to return the result. | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If **HUKS_SUCCESS** is returned, the operation is successful. Otherwise, an error occurs.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| **Example** @@ -2163,7 +2163,7 @@ Imports a key in plaintext. This API uses an asynchronous callback to return the | -------- | ------------------------ | ---- | ------------------------------------------------- | | keyAlias | string | Yes | Alias of the key.| | options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key to import.| -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If **HUKS_SUCCESS** is returned, the operation is successful. Otherwise, an error occurs.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| **Example** @@ -2228,7 +2228,7 @@ Imports a key in plaintext. This API uses a promise to return the result. | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If **HUKS_SUCCESS** is returned, the operation is successful. Otherwise, an error occurs.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| **Example** @@ -2291,7 +2291,7 @@ Exports a key. This API uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If **HUKS_SUCCESS** is returned, the operation is successful. Otherwise, an error occurs. **outData** contains the public key exported.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned and **outData** contains the public key exported. If the operation fails, an error code is returned.| **Example** @@ -2325,7 +2325,7 @@ Exports a key. This API uses a promise to return the result. | Type | Description | | ----------------------------------- | ------------------------------------------------------------ | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If **HUKS_SUCCESS** is returned, the operation is successful. Otherwise, an error occurs. **outData** contains the public key exported.| +| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned and **outData** contains the public key exported. If the operation fails, an error code is returned. | **Example** @@ -2355,7 +2355,7 @@ Obtains key properties. This API uses an asynchronous callback to return the res | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If **errorCode** is **HUKS_SUCCESS**, the operation is successful. Otherwise, an error occurs.| +| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If the operation is successful, **errorCode** is **HUKS_SUCCESS**; otherwise, an error code is returned.| **Example** @@ -2389,7 +2389,7 @@ Obtains key properties. This API uses a promise to return the result. | Type | Description | | ------------------ | ------------------------------------------------------------ | -| Promise\<[HuksResult](#huksoptions)> | Promise used to return the result. If **HUKS_SUCCESS** is returned, the operation is successful. Otherwise, an error occurs. **properties** returns the parameters required for generating the key.| +| Promise\<[HuksResult](#huksoptions)> | Promise used to return the result. If the operation is successful, **errorCode** is **HUKS_SUCCESS** and **properties** contains the parameters required for generating the key. If the operation fails, an error code is returned. | **Example** @@ -2419,7 +2419,7 @@ Checks whether a key exists. This API uses an asynchronous callback to return th | -------- | ---------------------- | ---- | ------------------------------------- | | keyAlias | string | Yes | Alias of the key to check.| | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).| -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. The value **TRUE** means that the key exists, and **FALSE** means the opposite.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result. **TRUE** means that the key exists; **FALSE** means the opposite.| **Example** @@ -2453,7 +2453,7 @@ Checks whether a key exists. This API uses a promise to return the result. | Type | Description | | ----------------- | --------------------------------------- | -| Promise\ | Promise used to return the result. The value **TRUE** means that the key exists, and **FALSE** means the opposite.| +| Promise\ | Promise used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite.| **Example** diff --git a/en/application-dev/reference/errorcodes/errorcode-colorspace-manager.md b/en/application-dev/reference/errorcodes/errorcode-colorspace-manager.md new file mode 100644 index 0000000000000000000000000000000000000000..c2afdd192f26f11593f0a8c6a72f4586c523071e --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-colorspace-manager.md @@ -0,0 +1,18 @@ +# colorSpaceManager Error Codes + +## 18600001 Abnormal Parameter Value +**Error Message** + +Parameter value is abnormal. + +**Description** + +This error code is reported when a parameter value passed in the API does not meet the requirements. + +**Possible Causes** + +The parameter value exceeds the valid range. For example, an enumerated value exceeds the defined range. + +**Solution** + +Pass parameter values that meet the requirements in the API. diff --git a/en/application-dev/reference/errorcodes/errorcode-data-rdb.md b/en/application-dev/reference/errorcodes/errorcode-data-rdb.md new file mode 100644 index 0000000000000000000000000000000000000000..d7e89e178783267e178ef45da2174ce8cffd28ba --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-data-rdb.md @@ -0,0 +1,79 @@ +# RDB Error Codes + +## 14800010 Invalid RDB Name + +**Error Message** + +Invalid database name. + +**Description** + +The RDB store name is invalid. + +**Possible Causes** + +The RDB store name is empty or exceeds 1024 bytes. + +**Solution** + +Check that the RDB store name is not empty and does not exceed 1024 bytes. + +## 14800011 Database File Corrupted + +**Error Message** + +Database corrupted. + +**Description** + +The RDB store is corrupted when an API for adding, deleting, querying, or synchronizing data is invoked. + +**Possible Causes** + +The RDB store file has been corrupted. + +**Solution** + +1. Restore the RDB store using the backup file. +2. If no RDB backup file is available, delete the RDB store and create it again. + +## 14800012 Empty Result Set or Invalid Position + +**Error Message** + +The result set is empty or the specified location is invalid. + +**Description** + +The result set is empty or the specified location is invalid. + +**Possible Causes** + +The result set is empty, or the specified row number in the result set is out of range [0, m - 1]. **m** is **resultsetV9.rowCount**. + +**Solution** + +Check whether the result set is empty or whether the specified row number is out of range. + +## 14800013 Null Column Value or Column Data Type Incompatible With the API Called + +**Error Message** + +The column value is null or the column type is incompatible. + +**Description** + +The column value is null, or the column data type is incompatible with the API called. + +**Possible Causes** + +1. The result set is empty. +2. The current row number in the result set is out of range [0, m - 1]. **m** is **resultsetV9.rowCount**. +3. The column number is out of the range [0, n - 1]. **n** is **resultsetV9.columnCount**. +4. The API called does not support the type of the column data. + +**Solution** + +1. Check whether the result set is empty. +2. Check whether the row number and column number of the result set are out of range. +3. Check whether the column data type is supported. diff --git a/en/application-dev/reference/errorcodes/errorcode-preferences.md b/en/application-dev/reference/errorcodes/errorcode-preferences.md new file mode 100644 index 0000000000000000000000000000000000000000..8abc1aaf4839704add8351d336b0f1bef8e154b9 --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-preferences.md @@ -0,0 +1,21 @@ +# Preferences Error Codes + +## 15500010 Failed to Delete Preferences +**Error Message** + +Failed to delete preferences. + +**Description** + +Failed to delete the preference. + +**Possible Causes** + +The possible causes are as follows: +1. The file name is incorrect. +2. The file path is incorrect. + +**Solution** + +1. Check that the file name is correct. +2. Check that the file path is correct. diff --git a/en/application-dev/webgl/webgl-overview.md b/en/application-dev/webgl/webgl-overview.md index 2431360e9c750802e2a9ec27437255933a120a6c..19f4432209700f82a6d217bdc2c0f48e6866374b 100644 --- a/en/application-dev/webgl/webgl-overview.md +++ b/en/application-dev/webgl/webgl-overview.md @@ -1,6 +1,6 @@ # WebGL Overview -Web Graphic Library (WebGL) is used for rendering interactive 2D and 3D graphics. WebGL used in OpenHarmony is based on OpenGL for Embedded Systems (OpenGL ES). It can be used in the **<canvas>** object of HTML5 without using plug-ins and supports cross-platform. WebGL is programmed by JavaScript code. Its APIs can implement graphics rendering and acceleration by using GPU hardware provided by the user equipment. +Web Graphic Library (WebGL) is used for rendering interactive 2D and 3D graphics. WebGL used in OpenHarmony is based on OpenGL for Embedded Systems (OpenGL ES). It can be used in the **\** object of HTML5 without using plug-ins and supports cross-platform. WebGL is programmed by JavaScript code. Its APIs can implement graphics rendering and acceleration by using GPU hardware provided by the user equipment. For more information, see [WebGL™](https://www.khronos.org/registry/webgl/specs/latest/1.0/). ## Basic Concepts @@ -31,7 +31,7 @@ The WebGLProgram is a JavaScript object responsible for associating the shader w ## Working Principles - **Figure 1** WebGL working principles +**Figure 1** WebGL working principles ![en-us_image_0000001238544451](figures/en-us_image_0000001238544451.png) @@ -40,7 +40,7 @@ The WebGLProgram is a JavaScript object responsible for associating the shader w - Native APIs complete the interaction between JavaScript and C++ code. -- JavaScript engine is a graphics framework that provides the **Surface** object for the WebGL module. +- JavaScript engine is the graphics framework that provides the **Surface** object for the WebGL module. - The WebGL module exposes the GPU drawing APIs of OpenGL ES. diff --git a/en/device-dev/kernel/Readme-EN.md b/en/device-dev/kernel/Readme-EN.md index 9a9ccfbd298bb5ca1aecee69dbc3a05d233260a1..0dcbb0d34e34cff4ae76fc54d0abead443f3be54 100644 --- a/en/device-dev/kernel/Readme-EN.md +++ b/en/device-dev/kernel/Readme-EN.md @@ -1,11 +1,10 @@ # Kernel - Kernel - - Mini-System Kernel - [Kernel Overview](kernel-overview.md) - Mini-System Kernel (LiteOS-M) - [LiteOS-M Overview](kernel-mini-overview.md) - - Basic Kernel + - Base Kernel - [Interrupt Management](kernel-mini-basic-interrupt.md) - [Task Management](kernel-mini-basic-task.md) - [Memory Management](kernel-mini-basic-memory.md) @@ -16,6 +15,7 @@ - [Semaphore](kernel-mini-basic-ipc-sem.md) - [Time Management](kernel-basic-mini-time.md) - [Software Timer](kernel-mini-basic-soft.md) + - [Doubly Linked List](kernel-mini-basic-list.md) - Extended Components - [C++ Support](kernel-mini-extend-support.md) - [CPUP](kernel-mini-extend-cpup.md) @@ -28,7 +28,6 @@ - [LMS](kernel-mini-memory-lms.md) - Appendix - [Kernel Coding Specification](kernel-mini-appx-code.md) - - [Doubly Linked List](kernel-mini-appx-data-list.md) - [Standard Libraries](kernel-mini-appx-lib.md) - Small-System Kernel (LiteOS-A) - [Kernel Overview](kernel-small-overview.md) @@ -158,6 +157,7 @@ - [Compiling and Building the Linux Kernel](kernel-standard-build.md) - Enhanced Kernel Features - [Enhanced Swap](kernel-standard-mm-eswap.md) + - [NewIP Kernel Protocol Stack](kernel-standard-newip.md) - Task Scheduling - [Related Thread Group](kernel-standard-sched-rtg.md) - [Lightweight CPU Isolation](kernel-standard-sched-cpuisolation.md) \ No newline at end of file diff --git a/en/device-dev/kernel/figures/Liteos-a-architecture.png b/en/device-dev/kernel/figures/Liteos-a-architecture.png index b1494cb3173ae82efc779c7e5a8aba4f6be8eb76..9a028a05f5f470ab6f9c751b8a28f7a75e60d16c 100644 Binary files a/en/device-dev/kernel/figures/Liteos-a-architecture.png and b/en/device-dev/kernel/figures/Liteos-a-architecture.png differ diff --git a/en/device-dev/kernel/figures/Liteos-m-architecture.png b/en/device-dev/kernel/figures/Liteos-m-architecture.png index dfe167e24812c8146866ee20cd22c4deb9f71d29..9a7769e2408cda7c2bddd028dcd2d249c2c5295b 100644 Binary files a/en/device-dev/kernel/figures/Liteos-m-architecture.png and b/en/device-dev/kernel/figures/Liteos-m-architecture.png differ diff --git a/en/device-dev/kernel/figures/newip-ND-request-parsed.png b/en/device-dev/kernel/figures/newip-ND-request-parsed.png new file mode 100644 index 0000000000000000000000000000000000000000..814ed3eb64440da9ace8078af96dc482414277db Binary files /dev/null and b/en/device-dev/kernel/figures/newip-ND-request-parsed.png differ diff --git a/en/device-dev/kernel/figures/newip-ND-request.png b/en/device-dev/kernel/figures/newip-ND-request.png new file mode 100644 index 0000000000000000000000000000000000000000..fbbae65979e1c28eb1e1012a82d3c96dd5bbf71b Binary files /dev/null and b/en/device-dev/kernel/figures/newip-ND-request.png differ diff --git a/en/device-dev/kernel/figures/newip-ND-response-parsed.png b/en/device-dev/kernel/figures/newip-ND-response-parsed.png new file mode 100644 index 0000000000000000000000000000000000000000..d1d9f869ca11b3392e3decea6a088d5c1c30562c Binary files /dev/null and b/en/device-dev/kernel/figures/newip-ND-response-parsed.png differ diff --git a/en/device-dev/kernel/figures/newip-ND-response.png b/en/device-dev/kernel/figures/newip-ND-response.png new file mode 100644 index 0000000000000000000000000000000000000000..0a6a1ce6afbc279a0d44c823bd09c9077b89ca67 Binary files /dev/null and b/en/device-dev/kernel/figures/newip-ND-response.png differ diff --git a/en/device-dev/kernel/figures/newip-TCP-handshake-parsed.png b/en/device-dev/kernel/figures/newip-TCP-handshake-parsed.png new file mode 100644 index 0000000000000000000000000000000000000000..12f145f1bc435ce223f22ab3670c0d7e6b556aa3 Binary files /dev/null and b/en/device-dev/kernel/figures/newip-TCP-handshake-parsed.png differ diff --git a/en/device-dev/kernel/figures/newip-TCP-handshake.png b/en/device-dev/kernel/figures/newip-TCP-handshake.png new file mode 100644 index 0000000000000000000000000000000000000000..77f4dda8d44cca18e80964081b0c0d2bb08d9d1d Binary files /dev/null and b/en/device-dev/kernel/figures/newip-TCP-handshake.png differ diff --git a/en/device-dev/kernel/figures/newip-TCP-packet-parsed.png b/en/device-dev/kernel/figures/newip-TCP-packet-parsed.png new file mode 100644 index 0000000000000000000000000000000000000000..19f4ef10ba4b468b1595322a5753fa08faf77ff8 Binary files /dev/null and b/en/device-dev/kernel/figures/newip-TCP-packet-parsed.png differ diff --git a/en/device-dev/kernel/figures/newip-TCP-packet.png b/en/device-dev/kernel/figures/newip-TCP-packet.png new file mode 100644 index 0000000000000000000000000000000000000000..0665e4fd8d8dc3730f48766ae5a3481450d1e4fd Binary files /dev/null and b/en/device-dev/kernel/figures/newip-TCP-packet.png differ diff --git a/en/device-dev/kernel/figures/newip-WireShark-template.png b/en/device-dev/kernel/figures/newip-WireShark-template.png new file mode 100644 index 0000000000000000000000000000000000000000..b7c4dbbd84b81444797f996a339f6686c7470443 Binary files /dev/null and b/en/device-dev/kernel/figures/newip-WireShark-template.png differ diff --git a/en/device-dev/kernel/figures/newip-connections.png b/en/device-dev/kernel/figures/newip-connections.png new file mode 100644 index 0000000000000000000000000000000000000000..c4edde138f8cd92cfe8828a4467c49d0b3e5bf65 Binary files /dev/null and b/en/device-dev/kernel/figures/newip-connections.png differ diff --git a/en/device-dev/kernel/figures/newip-development.png b/en/device-dev/kernel/figures/newip-development.png new file mode 100644 index 0000000000000000000000000000000000000000..e5e2b90263058fc847a711b3acffe627e94081f4 Binary files /dev/null and b/en/device-dev/kernel/figures/newip-development.png differ diff --git a/en/device-dev/kernel/figures/newip-header.png b/en/device-dev/kernel/figures/newip-header.png new file mode 100644 index 0000000000000000000000000000000000000000..9190bb298de56b73f98ffd142af014ded382c07b Binary files /dev/null and b/en/device-dev/kernel/figures/newip-header.png differ diff --git a/en/device-dev/kernel/figures/newip-wifi-packet.png b/en/device-dev/kernel/figures/newip-wifi-packet.png new file mode 100644 index 0000000000000000000000000000000000000000..d8f21510cc2e92a5811a11197483b99fafd441c3 Binary files /dev/null and b/en/device-dev/kernel/figures/newip-wifi-packet.png differ diff --git a/en/device-dev/kernel/kernel-mini-appx-data-list.md b/en/device-dev/kernel/kernel-mini-basic-list.md similarity index 100% rename from en/device-dev/kernel/kernel-mini-appx-data-list.md rename to en/device-dev/kernel/kernel-mini-basic-list.md diff --git a/en/device-dev/kernel/kernel-standard-newip.md b/en/device-dev/kernel/kernel-standard-newip.md new file mode 100644 index 0000000000000000000000000000000000000000..6ad095d8e80a657d69fea1cfdaf4ebb69841a7e4 --- /dev/null +++ b/en/device-dev/kernel/kernel-standard-newip.md @@ -0,0 +1,434 @@ +# New IP Kernel Protocol Stack + + +## Basic Concepts + +On basis of the traditional IP, New IP employs lightweight packet headers and variable-length, multi-semantic addresses and integrates Layer 2 and Layer 3 protocols to simplify protocols, reduce redundant bytes, and improve the energy efficiency ratio (EER), net throughput, and communication efficiency. New IP strives to implement end-to-end interconnection between heterogeneous networks to support ultimate experience of Super Device via efficient communication between devices. + +The WiFi protocol packets cause low transmission efficiency due to high overheads in Layer 3 packet headers and addressing. + +![](figures/newip-wifi-packet.png) + +``` +An IPv4 address has a fixed length of 4 bytes, and an IPv6 address has a fixed length of 16 bytes. +The network layer header ranges from 20 to 60 bytes for an IPv4 packet and is 40 bytes for an IPv6 packet. +``` + +New IP supports variable-length multi-semantic addresses (min. 1 byte) and customized header encapsulation (min. 5 bytes). Simplified packet headers reduce overheads and improve transmission efficiency. + +New IP provides 25.9% less packet header overheads than IPv4 and 44.9% less than IPv6. + +New IP provides at least 1% higher payload transmission efficiency than IPv4 and 2.33% than IPv6. + +| Scenario | Header Overhead (Bytes) | Payload Transmission Efficiency
(WiFi MTU = 1500 Bytes, BT MTU = 255 Bytes)| +| -------------- | ------------ | ------------------------------------------- | +| IPv4 for WiFi | 30 + 8 + 20 = 58 | (1500 - 58)/1500 = 96.13% | +| IPv6 for WiFi | 30 + 8 + 40 = 78 | (1500 - 78)/1500 = 94.8% | +| NewIP for WiFi | 30 + 8 + 5 = 43 | (1500 - 43)/1500 = 97.13% | + +## Variable-Length Header Format + +The figure below shows a New IP WiFi packet header. "EtherType = 0xEADD" in the LLC header identifies the packet. **Bitmap** is a binary sequence. The value of each binary bit indicates the existence of a feature. + +![](figures/newip-header.png) + +- **Dispatch** indicates the encapsulation type. The value **0b0** indicates the New IP encapsulation child class, which is 1 bit long (**0b** indicates that the following values are binary). +- **Bitmap** is of variable length. By default, it is seven bits following the **Dispatch** valid bit. The length of **Bitmap** can be extended contiguously. The last bit **0** of **Bitmap** indicates the end of **Bitmap**. The last bit **1** means to extend the **Bitmap** one byte until the last bit **0**. +- **Value** indicates the field value. The length is an integer multiple of 1 byte. The value type and length are determined by the semantic table of the header field. + +The **Bitmap** field is defined as follows: + +| Bitmap Identifier | Bitops | Field Length (Byte) | Setting | Remarks | +| -------------------------- | ------ | ---------------- | -------------- | --------------------------------------- | +| Bitmap 1st Byte: | - | - | - | - | +| Dispatch flag | 0 | It does not indicate a specific field. | Set to **0**. | The value **0** indicates a New IP packet; **1** indicates a non-New-IP packet. | +| TTL | 1 | 1 | Set to **1**. | Indicates the number of remaining hops. | +| Total Length | 2 | 2 | Set to **0** for UDP and **1** for TCP.| Total length of a New IP packet (including the header length). | +| Next Header | 3 | 1 | Set to **1**. | Protocol type. | +| Reserve | 4 | Reserved | Set to **0**. | Reserved. | +| Dest Address | 5 | Variable length (1 to 8 bytes)| Set to **1**. | Destination address. | +| Source Address | 6 | Variable length (1 to 8 bytes)| Determined by the protocol.| Source address. | +| Flag bit, indicating whether there is the second byte| 7 | It does not indicate a specific field. | - | The value **0** indicates the end of this bitmap. The value **1** indicates another 8-bit bitmap.| +| Bitmap 2nd Byte: | - | - | - | - | +| Header Length | 0 | 1 | - | Length of the New IP packet header. | +| Reserve | 1 | Reserved | Set to **0**. | - | +| Reserve | 2 | Reserved | Set to **0**. | - | +| Reserve | 3 | Reserved | Set to **0**. | - | +| Reserve | 4 | Reserved | Set to **0**. | - | +| Reserve | 5 | Reserved | Set to **0**. | - | +| Reserve | 6 | Reserved | Set to **0**. | - | +| Flag bit, indicating whether there is the third byte| 7 | It does not indicate a specific field. | Set to **0**. | The value **0** indicates the end of this bitmap. The value **1** indicates another 8-bit bitmap.| + +The bitmap fields in New IP are processed as follows: + +Only the bitmap fields defined in New IP are parsed. All the bitmap fields with unknown semantics are skipped. The start position of the packet is located for parsing based on the header length. If the packet header contains bitmap fields with unknown semantics and does not contain the header length, the packet will be discarded. + +## Variable-Length Address Format + +New IP uses variable-length addresses. The address itself indicates the length of the address. The address encoding format is as follows: + +| First Byte | Semantics | Valid Range of Address | +| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| 0x00 | Address is 0 | [1 byte] 0 to 220 (0x00 to 0xDC) | +| 0x01 | Address is 1 | - | +| 0x02 | Address is 2 | - | +| ... | ... | - | +| 0xDC | Address is 220 | - | +| 0xDD | An 16-bit address, which is 0 + 256 * (0xDD - 0xDD) + the last byte value | [2 bytes] 221 to 255 (0x**DD**DD to 0x**DD**FF) | +| 0xDE | An 16-bit address, which is 0 + 256 * (0xDE - 0xDD) + the last byte value | [2 bytes] 256 to 511 (0x**DE**00 to 0x**DE**FF) | +| 0xDF | An 16-bit address, which is 0 + 256 * (0xDF - 0xDD) + the last byte value | [2 bytes] 512 to 767 (0x**DF**00 to 0x**DF**FF) | +| ... | ... | - | +| 0xF0 | An 16-bit address, which is 0 + 256 * (0xF0 - 0xDD) + the last byte value | [2 bytes] 4864 to 5119 (0x**F0**00 to 0x**F0**FF) | +| 0xF1 | An 16-bit address is followed | [3 bytes] 5120 to 65535 (0x**F1** 1400 to 0x**F1** FFFF) | +| 0xF2 | An 32-bit address is followed | [5 bytes] 65536 to 4,294,967,295 (0x**F2** 0001 0000 to 0x**F2** FFFF FFFF)| +| 0xF3 | An 48-bit address is followed | [7 bytes] 4,294,967,296 to 281,474,976,710,655 (0x**F3** 0001 0000 0000 to 0x**F3** FFFF FFFF FFFF)| +| 0xFE | An 56-bit address is followed | [8 bytes] 0 to 72,057,594,037,927,935 (0x**FE**00 0000 0000 0000 to 0x**FE**FF FFFF FFFF FFFF)| + + + +## New IP Configuration + +Configure related settings and dependencies during kernel compilation to enable New IP. The New IP configuration is as follows: + +```c +CONFIG_NEWIP=y // Enable the New IP kernel protocol stack. +CONFIG_NEWIP_HOOKS=y // Enable New IP processing with hooks. +``` + +Set the following dependency: + +```c +VENDOR_HOOKS=y // Enable the kernel function hooking framework. +``` + +**NOTE** + +- Only the Linux 5.10 kernel supports the New IP kernel protocol stack. +- All native kernel code must be intrusively modified by hooks. + +```c +/* Register the New IP ehash function with the kernel. */ +register_trace_ninet_ehashfn_hook(&ninet_ehashfn_hook, NULL); + + +/* The following is the general entry function of IPv4 and IPv6 protocol stacks. Add the processing related to the New IP protocol stack to the general entry function. */ +static u32 sk_ehashfn(const struct sock *sk) +{ + /* IPv6 */ +#if IS_ENABLED(CONFIG_IPV6) + if (sk->sk_family == AF_INET6 && + !ipv6_addr_v4mapped(&sk->sk_v6_daddr)) + return inet6_ehashfn(sock_net(sk), + &sk->sk_v6_rcv_saddr, sk->sk_num, + &sk->sk_v6_daddr, sk->sk_dport); +#endif + +#if IS_ENABLED(CONFIG_NEWIP_HOOKS) + if (sk->sk_family == AF_NINET) { + u32 ret = 0; + + /* ehash function registered by New IP */ + trace_ninet_ehashfn_hook(sock_net(sk), &sk->sk_nip_rcv_saddr, sk->sk_num, + &sk->sk_nip_daddr, sk->sk_dport, &ret); + return ret; + } +#endif + + /* IPv4 */ + return inet_ehashfn(sock_net(sk), + sk->sk_rcv_saddr, sk->sk_num, + sk->sk_daddr, sk->sk_dport); +} +``` + + + +Run the following command to check whether the New IP protocol stack code is successfully enabled: + +```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 +... +``` + +Disable the New IP kernel protocol stack, delete **CONFIG_NEWIP** and the **out/kernel** directory, and start the build again. + +```c +# CONFIG_NEWIP is not set +# CONFIG_NEWIP_HOOKS is not set +``` + +## New IP APIs + +The user-mode application calls the socket API to create a New IP socket and uses the New IP frame header encapsulation to receive and transmit packets. The following table lists the New IP socket functions. + +| Function | Input | Output | Return Value | Function Description | +| -------- | ------------------------------------------------------------ | ---------------------------------------------- | ---------------- | ------------------------------------------------------------ | +| socket | int **domain**, int type, int **protocol** | NA | Socket handle **sockfd**.| Creates a **socket** instance for New IP.
**domain** must be **AF_NINET**, which indicates a New IP socket.
**protocol** can be **IPPROTO_TCP** or **IPPROTO_UDP**.
This function returns the handle of the **socket** instance created.| +| bind | int sockfd, const **struct sockaddr_nin** *myaddr, socklen_t addrlen | NA | Error code. The value is an integer. | Binds the **socket** instance to the specified IP address and port.
**myaddr->sin_family** must be **AF_NINET**.| +| listen | int socket, int backlog | NA | Error code. The value is an integer. | Listens for the New IP address and port from the server. | +| connect | int sockfd, const **struct sockaddr_nin** *addr, aocklen_t addrlen | NA | Error code. The value is an integer. | Sets up a connection between the client and the server. | +| accept | int sockfd, **struct sockaddr_nin** *address, socklen_t *address_len | NA | **sockfd**. | Accepts the connection request from the client. | +| send | int sockfd, const void *msg, int len, unsigned int flags, const **struct sockaddr_nin** *dst_addr, int addrlen | NA | Error code. The value is an integer. | Sends New IP TCP packets from the socket. | +| recv | int sockfd, size_t len, int flags, **struct sockaddr_nin** *src_addr, | void **buf, int* *fromlen | Error code. The value is an integer. | Receives New IP TCP packets from the socket. | +| close | int sockfd | NA | Error code. The value is an integer. | Closes the socket to release resources. | +| ioctl | int sockfd, unsigned long cmd, ... | NA | Error code. The value is an integer. | Queries or modifies the information about the New IP protocol stack. | +| sendto | int sockfd, const void *msg, int len, unsigned int flags, const **struct sockaddr** *dst_addr, int addrlen | NA | Error code. The value is an integer. | Sends New IP UDP packets from the socket. | +| recvfrom | int sockfd, size_t len, int flags, | void *buf, struct sockaddr *from, int *fromlen | Error code. The value is an integer. | Receives New IP UDP packets from the socket. | + +Structure of New IP short addresses: + +```c +enum nip_8bit_addr_index { + NIP_8BIT_ADDR_INDEX_0 = 0, + NIP_8BIT_ADDR_INDEX_1 = 1, + NIP_8BIT_ADDR_INDEX_2 = 2, + NIP_8BIT_ADDR_INDEX_3 = 3, + NIP_8BIT_ADDR_INDEX_4 = 4, + NIP_8BIT_ADDR_INDEX_5 = 5, + NIP_8BIT_ADDR_INDEX_6 = 6, + NIP_8BIT_ADDR_INDEX_7 = 7, + NIP_8BIT_ADDR_INDEX_MAX, +}; + +enum nip_16bit_addr_index { + NIP_16BIT_ADDR_INDEX_0 = 0, + NIP_16BIT_ADDR_INDEX_1 = 1, + NIP_16BIT_ADDR_INDEX_2 = 2, + NIP_16BIT_ADDR_INDEX_3 = 3, + NIP_16BIT_ADDR_INDEX_MAX, +}; + +enum nip_32bit_addr_index { + NIP_32BIT_ADDR_INDEX_0 = 0, + NIP_32BIT_ADDR_INDEX_1 = 1, + NIP_32BIT_ADDR_INDEX_MAX, +}; + +#define nip_addr_field8 v.u.field8 +#define nip_addr_field16 v.u.field16 +#define nip_addr_field32 v.u.field32 + +#pragma pack(1) +struct nip_addr_field { + union { + unsigned char field8[NIP_8BIT_ADDR_INDEX_MAX]; + unsigned short field16[NIP_16BIT_ADDR_INDEX_MAX]; /* big-endian */ + unsigned int field32[NIP_32BIT_ADDR_INDEX_MAX]; /* big-endian */ + } u; +}; + +struct nip_addr { + unsigned char bitlen; /* The address length is in bit (not byte) */ + struct nip_addr_field v; +}; +#pragma pack() + +/* The following structure must be larger than V4. System calls use V4. + * If the definition is smaller than V4, the read process will have memory overruns + * v4: include\linux\socket.h --> sockaddr (16Byte) + */ +#define POD_SOCKADDR_SIZE 3 +struct sockaddr_nin { + unsigned short sin_family; /* [2Byte] AF_NINET */ + unsigned short sin_port; /* [2Byte] Transport layer port, big-endian */ + struct nip_addr sin_addr; /* [9Byte] NIP address */ + + unsigned char sin_zero[POD_SOCKADDR_SIZE]; /* [3Byte] Byte alignment */ +}; +``` + +## New IP Development + +Only the OpenHarmony Linux-5.10 kernel supports New IP kernel protocol stack. You must manually configure IP address and route data for New IP in user mode, and connect the two devices through the router WiFi. To implement automatic switch to the New IP kernel protocol stack for communication after the IP address and route are is configured, see the description in the blue block in the figure below. + +![](figures/newip-development.png) + +For details about the address and route configuration, see [examples](https://gitee.com/openharmony/communication_sfc_newip/tree/master/examples). Modify the CC definition in Makefile based on the CPU you use, compile the CC definition into a binary file, and push the file to the development board. Refer to the figure above to configure the address and route data for New IP. + +| File | Description | +| ------------------ | ------------------------------------------------------ | +| nip_addr.c | Demo code for configuring the variable-length New IP addresses (any valid New IP address can be configured)| +| nip_route.c | Demo code for configuring the New IP route data (any valid New IP route can be configured) | +| check_nip_enable.c | Demo code for obtaining the New IP capabilities of the local device. | + +Check the New IP address and route information on device 1. + +```sh +# cat /proc/net/nip_addr +01 wlan0 +# cat /proc/net/nip_route +02 ff09 1 wlan0 # Route to device 2. +01 01 2149580801 wlan0 # Route for sending packets to itself and receiving the packets. +``` + +Check the New IP address and route information on device 2. + +```sh +# cat /proc/net/nip_addr +02 wlan0 +# cat /proc/net/nip_route +01 ff09 1 wlan0 # Route to device 1. +02 02 2149580801 wlan0 # Route for sending packets to itself and receiving the packets. +``` + +## New IP Sample Code for Receiving and Sending Packets + +The table below lists the demo code files. For details about how to use the user-mode APIs of the New IP protocol stack, see [examples](https://gitee.com/openharmony/communication_sfc_newip/tree/master/examples). Fixed addresses and routes are configured in the demo code. You do not need to manually specify the addresses and routes when executing the binary program. + +| File | Description | +| --------------------- | ----------------------------- | +| nip_addr_cfg_demo.c | Demo code for configuring the New IP variable-length addresses. | +| nip_route_cfg_demo.c | Demo code for New IP route configuration. | +| nip_udp_server_demo.c | Demo code for the server that sends and receives New IP UDP packets.| +| nip_udp_client_demo.c | Demo code for the client that sends and receives New IP UDP packets.| +| nip_tcp_server_demo.c | Demo code for the server that sends and receives New IP TCP packets.| +| nip_tcp_client_demo.c | Demo code for the client that sends and receives New IP TCP packets.| +| nip_lib.c | API demo code, for example, obtaining the interface index.| + +**Basic Procedure** + +![](figures/newip-connections.png) + +1. Copy the demo code to the Linux compiler, and run **make clean** and **make all** to compile the demo code. + +2. Upload the generated binary files to device 1 and device 2. + +3. Run the **ifconfig wlan0 up** command to start the network adapter. + +4. Run the **./nip_addr_cfg_demo server** command on shell of device 1 to configure a variable-length address **0xDE00** (2 bytes) for the server. Run the **./nip_addr_cfg_demo client** command on device 2 to configure a variable-length address **0x50** (1 byte) for the client. Then, run the **cat /proc/net/nip_addr** command to check the kernel address configuration. + +5. Run the **./nip_route_cfg_demo server** command on device 1 to configure the server route data. Run the **./nip_route_cfg_demo client** command on device 2 to configure the client route data. Then, run the **cat /proc/net/nip_route** command to check the kernel route configuration. + +Now, you can send and receive UDP/TCP packets. By default, the addresses and routes configured are used for sending and receiving packets. + + + +**Sending and Receiving UDP Packets** + +Run the **./nip_udp_server_demo** command on the server and then the **./nip_udp_client_demo** command on the client. The client sends 10 New IP packets. After receiving the packets, the server sends them to the client. + +``` +The following information is displayed in the shell window on the server: +Received -- 1661826989 498038 NIP_UDP # 0 -- from 0x50:57605 +Sending -- 1661826989 498038 NIP_UDP # 0 -- to 0x50:57605 +Received -- 1661826990 14641 NIP_UDP # 1 -- from 0x50:57605 +Sending -- 1661826990 14641 NIP_UDP # 1 -- to 0x50:57605 +Received -- 1661826990 518388 NIP_UDP # 2 -- from 0x50:57605 +Sending -- 1661826990 518388 NIP_UDP # 2 -- to 0x50:57605 +... +Received -- 1661827011 590576 NIP_UDP # 9 -- from 0x50:37758 +Sending -- 1661827011 590576 NIP_UDP # 9 -- to 0x50:37758 + +The following information is displayed in the shell window on the client: +Received --1661827007 55221 NIP_UDP # 0 sock 3 success: 1/ 1/no= 0 +Received --1661827007 557926 NIP_UDP # 1 sock 3 success: 2/ 2/no= 1 +Received --1661827008 62653 NIP_UDP # 2 sock 3 success: 3/ 3/no= 2 +... +Received --1661827011 590576 NIP_UDP # 9 sock 3 success: 10/ 10/no= 9 +``` + + + +**Sending and Receiving TCP Packets** + +Run the **./nip_tcp_server_demo** command on the server and then the **./nip_tcp_client_demo** command on the client. The client sends 10 New IP packets. After receiving the packets, the server sends them to the client. + +``` +The following information is displayed in the shell window on the server: +Received -- 1661760202 560605 NIP_TCP # 0 --:1024 +Sending -- 1661760202 560605 NIP_TCP # 0 --:1024 +Received -- 1661760203 69254 NIP_TCP # 1 --:1024 +Sending -- 1661760203 69254 NIP_TCP # 1 --:1024 +Received -- 1661760203 571604 NIP_TCP # 2 --:1024 +Sending -- 1661760203 571604 NIP_TCP # 2 --:1024 +... +Received -- 1661760207 86544 NIP_TCP # 9 --:1024 +Sending -- 1661760207 86544 NIP_TCP # 9 --:1024 + +The following information is displayed in the shell window on the client: +Received --1661760202 560605 NIP_TCP # 0 sock 3 success: 1/ 1/no= 0 +Received --1661760203 69254 NIP_TCP # 1 sock 3 success: 2/ 2/no= 1 +... +Received --1661760207 86544 NIP_TCP # 9 sock 3 success: 10/ 10/no= 9 +``` + +## SELinux Policy + +The SELinux policy must be added for the user-mode process to use New IP sockets. Otherwise, the operation will be intercepted. + +```sh +# base\security\selinux\sepolicy\ohos_policy\xxx\xxx.te +# socket operation +# avc: denied { create } for pid=540 comm="thread_xxx" scontext=u:r:thread_xxx:s0 tcontext=u:r:thread_xxx:s0 tclass=socket permissive=0 +allow thread_xxx thread_xxx:socket { create bind connect listen accept read write shutdown setopt getopt }; + +# ioctl operation +# The operation code is defined in linux-xxx\include\uapi\linux\sockios.h. +# 0x8933 : name -> if_index mapping +# 0x8916 : set PA address +# 0x890B : add routing table entry +allowxperm thread_xxx thread_xxx:socket ioctl { 0x8933 0x8916 0x890B }; +``` + +## WireShark Packet Parsing Template + +The default packet parsing rules of Wireshark cannot parse New IP packets. You can add a New IP packet parsing template to Wireshark to parse New IP packets. For details about the template, see [New IP packet parsing template](https://gitee.com/openharmony/communication_sfc_newip/blob/master/tools/wireshark_cfg_for_newip.lua). + +The procedure is as follows: + +Choose **Help** > **About Wireshark** > **Folders**, open the **Global Configuration** directory, and edit the **init.lua** file. Add **dofile (*DATA_DIR*.."newip.lua")** to the end of the file. *DATA_DIR* is the directory where the **newip.lua** plug-in is located. + +![](figures/newip-WireShark-template.png) + +The following is an example of adding a New IP packet parsing template: + +``` +Path of the New IP packet parsing template: +D:\tools\WireShark\wireshark_cfg_for_newip.lua + +Path of the WireShark configuration file: +C:\Program Files\Wireshark\init.lua + +Add the following to the end of the **init.lua** file (Windows 11, for example): +dofile("D:\\tools\\WireShark\\wireshark_cfg_for_newip.lua") +``` + +### Packet Parsing Example + +#### ND Request + +The figure below shows the format of the New IP Neighbor Discovery (ND) request packet. The header contains a 1-byte bitmap (0x76), which is followed by the TTL, total packet length, upper-layer protocol type, destination address, and source address. The New IP ND request packet contains the packet type, operation code, checksum, and request address. + +![](figures/newip-ND-request.png) + +![](figures/newip-ND-request-parsed.png) + +#### ND Response + +The figure below shows the format of a New IP ND response packet. The header contains two bitmaps (**0x77** and **0x00**). Bitmap 1 is followed by the TTL, total length of the packet, upper-layer protocol type, destination address, and source address. Bitmap2 is used for byte alignment and does not carry any data. (For the rk3568 development board, the data transmitted in the link layer must be of an even number of bytes.) A New IP ND response packet contains the packet type, operation code, checksum, neighbor MAC address length, and neighbor MAC address. + +![](figures/newip-ND-response.png) + +![](figures/newip-ND-response-parsed.png) + +#### TCP Handshake + +The figure below shows the format of a TCP three-way handshake SYN packet. The New IP packet header contains two bitmaps (**0x77** and **0x00**). Bitmap1 is followed by the TTL, total packet length, upper-layer protocol type, destination address, and source address. Bitmap2 is used for byte alignment and does not carry any data. (For the rk3568 development board, the data transmitted in the link layer must be of an even number of bytes.) + +![](figures/newip-TCP-handshake.png) + +![](figures/newip-TCP-handshake-parsed.png) + +#### TCP Data Packet + +The figure below shows the TCP data format. The New IP header contains two bitmaps (**0x77** and **0x00**). Bitmap 1 is followed by the TTL, total packet length, upper-layer protocol type, destination address, and source address. Bitmap2 is used for byte alignment and does not carry any data. (For the rk3568 development board, the data transmitted in the link layer must be of an even number of bytes.) + +![](figures/newip-TCP-packet.png) + +![](figures/newip-TCP-packet-parsed.png) diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001249937195.png b/en/device-dev/quick-start/figures/en-us_image_0000001249937195.png new file mode 100644 index 0000000000000000000000000000000000000000..8f54146ca114dcbd54141b13bd9477629d5b91f3 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001249937195.png differ diff --git a/en/device-dev/quick-start/figures/hi3516-faq-firewall-setting.png b/en/device-dev/quick-start/figures/hi3516-faq-firewall-setting.png new file mode 100644 index 0000000000000000000000000000000000000000..9487849c5f8a860e9680016ff3657404b2c0ad6e Binary files /dev/null and b/en/device-dev/quick-start/figures/hi3516-faq-firewall-setting.png differ diff --git a/en/device-dev/quick-start/figures/quickstart-hi3516-standard-hitool-select.png b/en/device-dev/quick-start/figures/quickstart-hi3516-standard-hitool-select.png new file mode 100644 index 0000000000000000000000000000000000000000..0851abfaab1a272e9e39ee58dc0b46b031ea0161 Binary files /dev/null and b/en/device-dev/quick-start/figures/quickstart-hi3516-standard-hitool-select.png differ diff --git a/en/device-dev/quick-start/figures/quickstart-pkg-prepare-networkdriver.png b/en/device-dev/quick-start/figures/quickstart-pkg-prepare-networkdriver.png new file mode 100644 index 0000000000000000000000000000000000000000..bc805d5a667fd1aa076d2b6e3ddcff89798f5f0b Binary files /dev/null and b/en/device-dev/quick-start/figures/quickstart-pkg-prepare-networkdriver.png differ diff --git a/en/device-dev/quick-start/figures/quickstart-pkg-prepare-setsamba.png b/en/device-dev/quick-start/figures/quickstart-pkg-prepare-setsamba.png new file mode 100644 index 0000000000000000000000000000000000000000..2a2d55620e10cf1e463ec305afd6554378443275 Binary files /dev/null and b/en/device-dev/quick-start/figures/quickstart-pkg-prepare-setsamba.png differ diff --git a/en/device-dev/quick-start/quickstart-appendix-compiledform.md b/en/device-dev/quick-start/quickstart-appendix-compiledform.md index fe1ecde0b39f5de4030235c2782964afaf47b794..9602f5e33b03daf8817384f08254de07f928c41e 100644 --- a/en/device-dev/quick-start/quickstart-appendix-compiledform.md +++ b/en/device-dev/quick-start/quickstart-appendix-compiledform.md @@ -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| | -------- | -------- | -------- | -------- | -------- | | [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_Mini_system](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568_Mini_system/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 | | [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 | | [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_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 | -| [hispark_taurus_Standard](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_Standard/config.json) | hispark_taurus | Hi3516DV300 | Linux | Standard | +| [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 | | [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_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_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 | | [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 | | [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 | [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 | | [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 | -| [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_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_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_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_Small_system_demo](https://gitee.com/Rockchip/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_Linux_headless](https://gitee.com/Rockchip/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 | -| [dsoftbus_demo](https://gitee.com/Rockchip/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 | +| [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_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/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/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/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/openharmony/vendor_ohemu/blob/master/qemu_small_system_demo/config.json) | arm_virt | QEMU | LiteOS-A | Small | +| [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/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_headless/config.json) | qemu-arm-linux | QEMU | Linux | Standard | +| [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/openharmony/vendor_chipsea/blob/master/dsoftbus_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 | diff --git a/en/device-dev/quick-start/quickstart-pkg-3861-running.md b/en/device-dev/quick-start/quickstart-pkg-3861-running.md index 71f94356edf4f1fc7faac18b59e028d10028773f..c132aed7c1b30066e7281aad04d07406a8ba5aea 100644 --- a/en/device-dev/quick-start/quickstart-pkg-3861-running.md +++ b/en/device-dev/quick-start/quickstart-pkg-3861-running.md @@ -115,6 +115,6 @@ Next 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) diff --git a/en/release-notes/OpenHarmony-v3.2-beta3.md b/en/release-notes/OpenHarmony-v3.2-beta3.md index 25bcbf7e919ca3e107301ae9ad26f535b4cce352..932b16e58b23e08e69fe12daf47acc007a6f4926 100644 --- a/en/release-notes/OpenHarmony-v3.2-beta3.md +++ b/en/release-notes/OpenHarmony-v3.2-beta3.md @@ -53,8 +53,8 @@ The distributed database supports cross-device and cross-application sharing. Th | Software/Tool| Version| Remarks| | -------- | -------- | -------- | | OpenHarmony | 3.2 Beta3| NA | -| Public SDK | Ohos_sdk_public 3.2.7.5 (API Version 9 Beta3)| This toolkit is intended for application developers and does not contain system APIs that require system permissions.
It is provided as standard in DevEco Studio.| -| Full SDK | Ohos_sdk_full 3.2.7.5 (API Version 9 Beta3)| This toolkit is intended for original equipment manufacturers (OEMs) and contains system APIs that require system permissions.
To use the full SDK, manually obtain it from the mirror and switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](../application-dev/quick-start/full-sdk-switch-guide.md).| +| Public SDK | Ohos_sdk_public 3.2.7.5 (API Version 9 Beta3)
Ohos_sdk_public 3.2.7.6 (API Version 9 Beta3) | This toolkit is intended for application developers and does not contain system APIs that require system permissions.
It is provided as standard in DevEco Studio.| +| Full SDK | Ohos_sdk_full 3.2.7.5 (API Version 9 Beta3)
Ohos_sdk_full 3.2.7.6 (API Version 9 Beta3) | This toolkit is intended for original equipment manufacturers (OEMs) and contains system APIs that require system permissions.
To use the full SDK, manually obtain it from the mirror and switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](../application-dev/quick-start/full-sdk-switch-guide.md).| | (Optional) HUAWEI DevEco Studio| 3.0 Release| Recommended for developing OpenHarmony applications.| | (Optional) HUAWEI DevEco Device Tool| 3.0 Release| Recommended for developing OpenHarmony devices.| @@ -137,6 +137,10 @@ Use the **repo** tool to download the source code over HTTPS. | Full SDK package for the standard system (Windows/Linux) | 3.2.7.5 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-windows_linux-full.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-windows_linux-full.tar.gz.sha256) | | Public SDK package for the standard system (macOS) | 3.2.7.5 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-mac-public.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-mac-public.tar.gz.sha256) | | Public SDK package for the standard system (Windows/Linux) | 3.2.7.5 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-windows_linux-public.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/ohos-sdk-windows_linux-public.tar.gz.sha256) | +| Full SDK package for the standard system (macOS) | 3.2.7.6 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/sdk-patch/mac-sdk-full.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/sdk-patch/mac-sdk-full.tar.gz.sha256)| +| Full SDK package for the standard system (Windows/Linux) | 3.2.7.6 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/sdk-patch/ohos-sdk-full.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/sdk-patch/ohos-sdk-full.tar.gz.sha256) | +| Public SDK package for the standard system (macOS) | 3.2.7.6 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/sdk-patch/mac-sdk-public.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/sdk-patch/mac-sdk-public.tar.gz.sha256) | +| Public SDK package for the standard system (Windows/Linux) | 3.2.7.6 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/sdk-patch/ohos-sdk-public.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/sdk-patch/ohos-sdk-public.tar.gz.sha256) | @@ -167,10 +171,12 @@ This version has the following updates to OpenHarmony 3.2 Beta2. | Multi-language runtime subsystem| The front-end compilation performance is improved, for example, by using the es2abc component.
Runtime performance is improved through ISA reconstruction, assembly interpreter, and TS Ahead of Time (AOT) compiler.
New functions are added, such as ES2021 in strict mode, modularization, runtime debugging and tuning enhancement, and bytecode hot reload.
The following requirements are involved:
I5MYM9 [New specifications] Merging and adaptation of the abc file for multiple modules
I59TAQ [New specifications] Standard compilation lowering of the TS AOT compiler and pass description optimization
I5OJ8Q [New specifications] Displaying the attribute types defined ES2021 in DevEco Studio
I5ODV4 [New feature] Uninstalling bytecode patch files
I5OXSC [New feature] Installing bytecode patch files
I5HNNZ [New feature] Enabling the namespace of the loader
I5HVQE [New feature] Product-specific stack size setting of the thread, and stack page guard
I5MCUF [Enhanced feature] New CAPIs of libc and support for symbols such as pthread
I5HVNH [New feature] RM.006. Enhanced dynamic library symbol management
I5HVQ0 [New feature] RM.008. Fortify supported by musl
I5KT7X [New feature] RM.002. API detection for API header files
I5TB3Y [New feature] ABI using emutls by default
I5R119 [Enhanced feature] Separated use of memory for loader and libc
Open-source Clang toolchain
I5MYM9 [New specifications] Modular compilation supported by the front-end compiler toolchain
I5IKO1 [New specifications] Compiling Commonjs module with the es2abc component
I5RRAJ [New specifications] Patch file source code identification tool
I5PRFT [New specifications] Patch bytecode compiler
I5RHDH [New specifications] Hot loading of ArkCompiler bytecode
I5RA7C [New specifications] Support for ES2021 in strict mode
I5HRUY [New specifications] Converting from JS code to ArkCompiler bytecode by the es2abc component| NA | | IAM account subsystem and program access control subsystem| User identity authentication is added to the IAM account subsystem. The permission service supports precise positioning and fuzzy positioning, and other capabilities are enhanced. The privacy management service is provided.
The following requirements are involved:
I5N90B [New specifications] Application accounts adaptation to sandbox applications
I5N90O [New specifications] User identity authentication of the IAM account subsystem
I5NOQI [New feature] Precise positioning and fuzzy positioning of the permission service
I5NT1X [New feature] Enhanced permission usage record management
I5NU8U [New feature] Improved UX effect for the permission request dialog box
I5P4IU [New feature] Privacy management
I5P530 [New feature] Location service usage status management| NA | | Globalization subsystem| The pseudo-localization capability is added.
The following requirement is involved:
I4WLSJ [New feature] Pseudo-localization| NA | -| Misc services subsystem| The following basic module features are added: pasteboard, upload and download, screen lock, and input method framework.
The following requirements are involved:
I5JPMG [request] [download] Background task notification
I5NXHK [input_method_fwk] Binding of only the innerkits interface of the input method and the JS interface that independently controls the display and hiding of the soft keyboard
I5NG2X [theme_screenlock] Screen lock requested by specific system applications
I5IU1Z Adding image data to pasteboard data
I5OGA3 Cross-device pasteboard switch at the device level
I5NMKI [pasteboard] Adding binary data to pasteboard data
I5MAMN Limiting the pasteboard data range to within the application
I5OX20 [input_method_fwk] Added the API for obtaining the input method| NA | +| Misc services subsystem| The following basic module features are added: pasteboard, upload and download, screen lock, and input method framework.
The following requirements are involved:
I5JPMG [request] [download] Background task notification
I5NXHK [input_method_fwk] Binding of only the innerkits interface of the input method and the JS interface that independently controls the display and hiding of the soft keyboard
I5NG2X [theme_screenlock] Screen lock requested by specific system applications
I5IU1Z Adding image data to pasteboard data
I5OGA3 Pasteboard plugin loading switch
I5NMKI [pasteboard] Adding binary data to pasteboard data
I5MAMN Limiting the pasteboard data range to within the application
I5OX20 [input_method_fwk] Added the API for obtaining the input method| NA | | ArkUI development framework| The following capabilities are enhanced: ArkUI component, resource and media query, DFX, and toolchain. The memory and performance are optimized.
The following requirements are involved:
I5IZZ7 [ace_engine_standard] Separate **borderRadius** setting for each corner by the **\** component
I5JQ1R [ace_engine_standard] Image copy and paste
I5JQ3F [ace_engine_standard] Enhanced text box capabilities
I5JQ3J [ace_engine_standard] Event topology of the **\** component
I5JQ54 [ace_engine_standard] Specifying a component to get the focus
I5MX7J [ace_engine_standard] Left sliding, right sliding, and rebound effect of the **\** component
I5MWS0 [ace_engine_standard] Height notification of the **\** component
I5IZVY [ace_engine_standard] Component refresh upon the keyboard and mouse connection
I5JQ5Y [ace_engine_standard] Enhanced focus navigation
I5IY7K [New requirement] [ace_engine_standard] Theme capability
I5MWTB [ace_engine_standard] vp query for media
I5IZU9 [ace_engine_standard] Optimization of the resident memory of ui_service
I5JQ26 [ace_engine_standard] Optimized Vsync request mechanism
I5JQ2O [ace_engine] Preloading of public resources
I5JQ2D [ace_engine_standard] Optimized resampling of move events
I5IZXS [toolchain] Display of the plaintext of the developer variable name in the DFX error stack print
I5IZYG [toolchain] Display of the plaintext of the developer variable name in the DFX error stack print
I5IZX0 [toolchain] Adding the **bundleName** and **moduleName** parameters to **$r** during compilation
I5J09I [toolchain] Export of \@Builder| NA | +For details about the API changes, see the following: +[API Differences](api-change/v3.2-beta3/Readme-EN.md) ### Chip and Development Board Adaptation @@ -186,7 +192,7 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op | -------- | -------- | -------- | -------- | | ArkUI development framework| [HealthyDiet](https://gitee.com/openharmony/applications_app_samples/tree/master/ETSUI/HealthyDiet)| This sample app helps you keep food records and view food information. After you add food records, including the food type, weight, and meal time, the app can calculate nutrition data (calories, proteins, fats, and carbon water) for the meals and display the data in a bar chart.| eTS | | ArkUI development framework| [MusicAlbum](https://gitee.com/openharmony/applications_app_samples/tree/master/MultiDeviceAppDev/MusicAlbum)| This sample shows the home page of a music album app. The adaptive layout and responsive layout are used to ensure that the app can be properly displayed on devices irrespective of screen sizes.| eTS | -| Ability framework and file management subsystem| [Share](https://gitee.com/openharmony/applications_app_samples/tree/master/Share/Share)| Using this sample app, you can share texts, links, and images with third-party applications and display them in these applications.| eTS | +| Ability framework and file management subsystem| [Share](https://gitee.com/openharmony/applications_app_samples/tree/master/Share/CustomShare)| Using this sample app, you can share texts, links, and images with third-party applications and display them in these applications.| eTS | | Ability framework| [GalleryForm](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/GalleryForm)| This sample demonstrates the display of **Gallery** images in a widget and periodic update of the widget.| eTS | | ArkUI development framework| [AppMarket](https://gitee.com/openharmony/applications_app_samples/tree/master/MultiDeviceAppDev/AppMarket)| This sample shows the home page of an application market, which contains the tab bar, banner, featured apps, and featured games.| eTS | | ArkUI development framework| [Weather](https://gitee.com/openharmony/applications_app_samples/tree/master/MultiDeviceAppDev/Weather)| This sample demonstrates one-time development for multi-device deployment by showing how to develop a weather app and deploy it across different devices. The demo app includes the following: home page, **Manage City** page, **Add City** page, and **Update Time** page.| eTS | diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index 90378b11ecb5a1b4f9c490cef182bd55c9ce0be7..5da55f3036ae1bf2d9647e69fb566bf969e7cb6e 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -44,6 +44,7 @@ - [设备使用信息统计](device-usage-statistics/Readme-CN.md) - [DFX](dfx/Readme-CN.md) - [国际化](internationalization/Readme-CN.md) + - [应用测试](application-test/Readme-CN.md) - [一次开发,多端部署](key-features/multi-device-app-dev/Readme-CN.md) - [IDL工具规格及使用说明书](IDL/idl-guidelines.md) - [Native API的相关指导](napi/Readme-CN.md) @@ -65,4 +66,3 @@ - [常见问题](faqs/Readme-CN.md) - 贡献 - [参与贡献](../contribute/贡献文档.md) - diff --git a/zh-cn/application-dev/application-dev-guide-for-gitee.md b/zh-cn/application-dev/application-dev-guide-for-gitee.md index 9be881921b4c9d7ccefbc2f6b518972030853f1c..b4b31f05b37d25026458f8adc836f456e5a1b0c4 100644 --- a/zh-cn/application-dev/application-dev-guide-for-gitee.md +++ b/zh-cn/application-dev/application-dev-guide-for-gitee.md @@ -37,6 +37,7 @@ - [设备使用信息统计](device-usage-statistics/Readme-CN.md) - [DFX](dfx/Readme-CN.md) - [国际化](internationalization/Readme-CN.md) +- [应用测试](application-test/Readme-CN.md) - [IDL工具规格及使用说明书](IDL/idl-guidelines.md) - [Native API的相关指导](napi/Readme-CN.md) diff --git a/zh-cn/application-dev/application-dev-guide.md b/zh-cn/application-dev/application-dev-guide.md index 73869033a8be5a1138a21fd56bdd5dbf5c8a3a40..9fd8708ce841409d7f3c5da9880bdcf7520766e1 100644 --- a/zh-cn/application-dev/application-dev-guide.md +++ b/zh-cn/application-dev/application-dev-guide.md @@ -37,6 +37,7 @@ - [设备使用信息统计](device-usage-statistics/device-usage-statistics-overview.md) - [DFX](dfx/hiappevent-overview.md) - [国际化](internationalization/international-overview.md) +- [应用测试](application-test/Readme-CN.md) - [IDL工具规格及使用说明书](IDL/idl-guidelines.md) - [Native API的相关指导](napi/napi-guidelines.md) diff --git a/zh-cn/application-dev/application-test/arkxtest-guidelines.md b/zh-cn/application-dev/application-test/arkxtest-guidelines.md index 410547a5d0ef493f9cee83b670b7a391023fb6e2..3920c6f859534f86cac8e63c98ffce6eb27b83ca 100644 --- a/zh-cn/application-dev/application-test/arkxtest-guidelines.md +++ b/zh-cn/application-dev/application-test/arkxtest-guidelines.md @@ -169,3 +169,105 @@ export default function abilityTest() { 测试执行完毕后可直接在DevEco Studio中查看测试结果,如下图示例所示: ![](figures/TestResult.PNG) + +## 常见问题 + +### 单元测试用例常见问题 + +**1、用例中增加的打印日志在用例结果之后才打印** + +**问题描述** + +用例中增加的日志打印信息,没有在用例执行过程中出现,而是在用例执行结束之后才出现。 + + **可能原因** + +此类情况只会存在于用例中有调用异步接口的情况,原则上用例中所有的日志信息均在用例执行结束之前打印。 + + **解决方法** + +当被调用的异步接口多于一个时,建议将接口调用封装成Promise方式调用。 + +**2、执行用例时报error:fail to start ability** + +**问题描述** + +执行测试用例时候,用例执行失败,控制台返回错误:fail to start ability。 + +**可能原因** + +测试包打包过程中出现问题,未将测试框架依赖文件打包在测试包中。 + +**解决方法** + +检查测试包中是否包含OpenHarmonyTestRunner.abc文件,如没有则重新编译打包后再次执行测试。 + +**3、执行用例时报用例超时错误** + +**问题描述** + +用例执行结束,控制台提示execute time XXms错误,即用例执行超时 + +**可能原因** + +1.用例执行异步接口,但执行过程中没有执行到done函数,导致用例执行一直没有结束,直到超时结束。 + +2.用例调用函数耗时过长,超过用例执行设置的超时时间。 + +**解决方法** + +1.检查用例代码逻辑,确保即使断言失败场景认可走到done函数,保证用例执行结束。 + +2.可在IDE中Run/Debug Configurations中修改用例执行超时配置参数,避免用例执行超时。 + +### UI测试用例常见问题 + +**1、失败日志有“Get windows failed/GetRootByWindow failed”错误信息** + +**问题描述** + +UI测试用例执行失败,查看hilog日志发现日志中有“Get windows failed/GetRootByWindow failed”错误信息。 + +**可能原因** + +系统ArkUI开关未开启,导致被测试界面控件树信息未生成。 + +**解决方法** + +执行如下命令,并重启设备再次执行用例。 + +```shell +hdc shell param set persist.ace.testmode.enabled 1 +``` + +**2、失败日志有“uitest-api dose not allow calling concurrently”错误信息** + +**问题描述** + +UI测试用例执行失败,查看hilog日志发现日志中有“uitest-api dose not allow calling concurrently”错误信息。 + +**可能原因** + +1.用例中UI测试框架提供异步接口没有增加await语法糖调用。 + +2.多进程执行UI测试用例,导致拉起多个UITest进程,框架不支持多进程调用。 + +**解决方法** + +1.检查用例实现,异步接口增加await语法糖调用。 + +2.避免多进程执行UI测试用例。 + +**3、失败日志有“dose not exist on current UI! Check if the UI has changed after you got the widget object”错误信息** + +**问题描述** + +UI测试用例执行失败,查看hilog日志发现日志中有“dose not exist on current UI! Check if the UI has changed after you got the widget object”错误信息。 + +**可能原因** + +在用例中代码查找到目标控件后,设备界面发生了变化,导致查找到的控件丢失,无法进行下一步的模拟操作。 + +**解决方法** + +重新执行UI测试用例。 diff --git a/zh-cn/application-dev/device/Readme-CN.md b/zh-cn/application-dev/device/Readme-CN.md index 9d211b929513eb5638f71e1ff0a98a115c8bb727..3639b281c4a9421c0f62f9b26d912842eaf6b553 100644 --- a/zh-cn/application-dev/device/Readme-CN.md +++ b/zh-cn/application-dev/device/Readme-CN.md @@ -13,7 +13,7 @@ - 振动 - [振动开发概述](vibrator-overview.md) - [振动开发指导](vibrator-guidelines.md) -- 设备管理 +- 多模输入 - [输入设备开发指导](inputdevice-guidelines.md) - [鼠标光标开发指导](pointerstyle-guidelines.md) - 升级服务 diff --git a/zh-cn/application-dev/device/device-location-geocoding.md b/zh-cn/application-dev/device/device-location-geocoding.md index 2a5b0f843aa260a130a458fdca803863e777e024..6a6eaf336b6706dc91692714ef2b62368023b117 100644 --- a/zh-cn/application-dev/device/device-location-geocoding.md +++ b/zh-cn/application-dev/device/device-location-geocoding.md @@ -14,17 +14,18 @@ ## 接口说明 -进行坐标和地理编码信息的相互转化,所使用的接口说明如下,详细信息参见:[位置服务](../reference/apis/js-apis-geoLocationManager.md)。 +进行坐标和地理编码信息的相互转化,所使用的接口说明如下,详细信息参见:[位置服务](../reference/apis/js-apis-geolocation.md)。 **表1** 地理编码转化能力和逆地理编码转化能力的API功能介绍 | 接口名 | 功能描述 | | -------- | -------- | -| isGeocoderAvailable(): boolean; | 判断(逆)地理编码服务状态。 | -| getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void | 调用逆地理编码服务,将坐标转换为地理描述,使用callback回调异步返回结果。 | -| getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<GeoAddress>> | 调用逆地理编码服务,将坐标转换为地理描述,使用Promise方式异步返回结果。 | -| getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void | 调用地理编码服务,将地理描述转换为具体坐标,使用callback回调异步返回结果。 | -| getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAddress>> | 调用地理编码服务,将地理描述转换为具体坐标,使用Promise方式异步返回结果。 | +| isGeoServiceAvailable(callback: AsyncCallback<boolean>) : void | 判断(逆)地理编码服务状态,使用callback回调异步返回结果。 | +| isGeoServiceAvailable() : Promise<boolean> | 判断(逆)地理编码服务状态,使用Promise方式异步返回结果。 | +| getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>) : void | 调用逆地理编码服务,将坐标转换为地理描述,使用callback回调异步返回结果。 | +| getAddressesFromLocation(request: ReverseGeoCodeRequest) : Promise<Array<GeoAddress>> | 调用逆地理编码服务,将坐标转换为地理描述,使用Promise方式异步返回结果。 | +| getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>) : void | 调用地理编码服务,将地理描述转换为具体坐标,使用callback回调异步返回结果。 | +| getAddressesFromLocationName(request: GeoCodeRequest) : Promise<Array<GeoAddress>> | 调用地理编码服务,将地理描述转换为具体坐标,使用Promise方式异步返回结果。 | ## 开发步骤 @@ -32,22 +33,23 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > GeoConvert需要访问后端服务,请确保设备联网,以进行信息获取。 -1. 导入geoLocationManager模块,所有与(逆)地理编码转化能力相关的功能API,都是通过该模块提供的。 +1. 导入geolocation模块,所有与(逆)地理编码转化能力相关的功能API,都是通过该模块提供的。 ```ts - import geoLocationManager from '@ohos.geoLocationManager'; + import geolocation from '@ohos.geolocation'; ``` 2. 查询geoCoder服务是否可用。 - 调用isGeoServiceAvailable查询geoCoder服务是否可用,如果服务可用再继续进行步骤3。 ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - try { - var isAvailable = geoLocationManager.isGeocoderAvailable(); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } + geolocation.isGeoServiceAvailable((err, data) => { + if (err) { + console.log('isGeoServiceAvailable err: ' + JSON.stringify(err)); + } else { + console.log('isGeoServiceAvailable data: ' + JSON.stringify(data)); + } + }); ``` 3. 获取转化结果。 @@ -55,7 +57,7 @@ ```ts var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; - geoLocationManager.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { + geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { if (err) { console.log('getAddressesFromLocation err: ' + JSON.stringify(err)); } else { @@ -64,12 +66,12 @@ }); ``` - 参考接口API说明[位置服务](../reference/apis/js-apis-geoLocationManager.md),应用可以获得与此坐标匹配的GeoAddress列表,应用可以根据实际使用需求,读取相应的参数数据。 + 参考接口API说明[位置服务](../reference/apis/js-apis-geolocation.md),应用可以获得与此坐标匹配的GeoAddress列表,应用可以根据实际使用需求,读取相应的参数数据。 - 调用getAddressesFromLocationName位置描述转化坐标。 ```ts var geocodeRequest = {"description": "上海市浦东新区xx路xx号", "maxItems": 1}; - geoLocationManager.getAddressesFromLocationName(geocodeRequest, (err, data) => { + geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { if (err) { console.log('getAddressesFromLocationName err: ' + JSON.stringify(err)); } else { @@ -78,6 +80,6 @@ }); ``` - 参考接口API说明[位置服务](../reference/apis/js-apis-geoLocationManager.md),应用可以获得与位置描述相匹配的GeoAddress列表,其中包含对应的坐标数据,请参考API使用。 + 参考接口API说明[位置服务](../reference/apis/js-apis-geolocation.md),应用可以获得与位置描述相匹配的GeoAddress列表,其中包含对应的坐标数据,请参考API使用。 如果需要查询的位置描述可能出现多地重名的请求,可以设置GeoCodeRequest,通过设置一个经纬度范围,以高效地获取期望的准确结果。 diff --git a/zh-cn/application-dev/device/device-location-info.md b/zh-cn/application-dev/device/device-location-info.md index 10f006b399671f5c5047299dd3f6e2a72925d20f..6a1954e0b7e5b1cfdd19b88cbdc354e835b5a4e3 100644 --- a/zh-cn/application-dev/device/device-location-info.md +++ b/zh-cn/application-dev/device/device-location-info.md @@ -10,12 +10,12 @@ ## 接口说明 -获取设备的位置信息,所使用的接口说明参见:[位置服务](../reference/apis/js-apis-geoLocationManager.md)。 +获取设备的位置信息,所使用的接口说明参见:[位置服务](../reference/apis/js-apis-geolocation.md)。 ## 开发步骤 -如需要获取设备位置相关接口信息,请参考[位置服务](../reference/apis/js-apis-geoLocationManager.md)。 +如需要获取设备位置相关接口信息,请参考[位置服务](../reference/apis/js-apis-geolocation.md)。 1. 应用在使用系统能力前,需要检查是否已经获取用户授权访问设备位置信息。如未获得授权,可以向用户申请需要的位置权限,申请方式请参考下文。 系统提供的定位权限有: @@ -42,10 +42,10 @@ 开发者可以在应用配置文件中声明所需要的权限,具体可参考[授权申请指导](../security/accesstoken-guidelines.md)。 -2. 导入geoLocationManager模块,所有与基础定位能力相关的功能API,都是通过该模块提供的。 +2. 导入geolocation模块,所有与基础定位能力相关的功能API,都是通过该模块提供的。 - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; + ``` + import geolocation from '@ohos.geolocation'; ``` 3. 实例化LocationRequest对象,用于告知系统该向应用提供何种类型的位置服务,以及位置结果上报的频率。
@@ -78,8 +78,8 @@ 以导航场景为例,实例化方式如下: - ```ts - var requestInfo = {'scenario': geoLocationManager.LocationRequestScenario.NAVIGATION, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; + ``` + var requestInfo = {'scenario': geolocation.LocationRequestScenario.NAVIGATION, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` **方式二:** @@ -108,7 +108,7 @@ 以定位精度优先策略为例,实例化方式如下: ```ts - var requestInfo = {'priority': geoLocationManager.LocationRequestPriority.ACCURACY, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; + var requestInfo = {'priority': geolocation.LocationRequestPriority.ACCURACY, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` 4. 实例化Callback对象,用于向系统提供位置上报的途径。 @@ -123,24 +123,25 @@ 5. 启动定位。 ```ts - geoLocationManager.on('locationChange', requestInfo, locationChange); + geolocation.on('locationChange', requestInfo, locationChange); ``` 6. (可选)结束定位。 ```ts - geoLocationManager.off('locationChange', locationChange); + geolocation.off('locationChange', locationChange); ``` 如果应用使用场景不需要实时的设备位置,可以获取系统缓存的最近一次历史定位结果。 ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - try { - var location = geoLocationManager.getLastLocation(); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } + geolocation.getLastLocation((err, data) => { + if (err) { + console.log('getLastLocation: err: ' + JSON.stringify(err)); + } else { + console.log('getLastLocation: data: ' + JSON.stringify(data)); + } + }); ``` 此接口的使用需要应用向用户申请ohos.permission.LOCATION权限。 \ No newline at end of file diff --git a/zh-cn/application-dev/device/inputdevice-guidelines.md b/zh-cn/application-dev/device/inputdevice-guidelines.md index 166f085cc394b7f20c6773ec9c6f8ec2b80ad5c6..30ec8073cb7e6d552b53afcc43b38f8aa6593f1f 100644 --- a/zh-cn/application-dev/device/inputdevice-guidelines.md +++ b/zh-cn/application-dev/device/inputdevice-guidelines.md @@ -16,10 +16,10 @@ import inputDevice from '@ohos.multimodalInput.inputDevice'; | 实例名 | 接口名 | 说明 | | ----------- | ------------------------------------------------------------ | -------------------------- | -| inputDevice | **function** getDeviceList(callback: AsyncCallback>): **void**; | 获取输入设备列表。 | -| inputDevice | **function** getKeyboardType(deviceId: **number**, callback: AsyncCallback): **void**; | 获取输入设备的键盘类型。 | -| inputDevice | **function** on(**type**: "change", listener: Callback): **void**; | 监听输入设备的热插拔事件。 | -| inputDevice | **function** off(**type**: "change", listener?: Callback): **void**; | 取消监听输入设备的热插拔事件。 | +| inputDevice | function getDeviceList(callback: AsyncCallback\>): void; | 获取输入设备列表。 | +| inputDevice | function getKeyboardType(deviceId: number, callback: AsyncCallback\): void; | 获取输入设备的键盘类型。 | +| inputDevice | function on(type: "change", listener: Callback\): void; | 监听输入设备的热插拔事件。 | +| inputDevice | function off(type: "change", listener?: Callback\): void; | 取消监听输入设备的热插拔事件。 | ## 虚拟键盘弹出检测 diff --git a/zh-cn/application-dev/device/pointerstyle-guidelines.md b/zh-cn/application-dev/device/pointerstyle-guidelines.md index a2bf27e017bab128a56cb2f1af4213490e0e6c63..b15e2b58e42993d0baa5bd0876e2255d22e2f0c0 100644 --- a/zh-cn/application-dev/device/pointerstyle-guidelines.md +++ b/zh-cn/application-dev/device/pointerstyle-guidelines.md @@ -16,10 +16,10 @@ import inputDevice from '@ohos.multimodalInput.pointer'; | 实例名 | 接口名 | 说明 | | ------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| pointer | **function** isPointerVisible(callback: AsyncCallback): **void**; | 获取鼠标指针显示或隐藏状态。 | -| pointer | **function** setPointerVisible(visible: boolean, callback: AsyncCallback<**void**>): **void**; | 设置鼠标指针显示或隐藏状态,改接口会影响全局鼠标光标的显示状态。 | -| pointer | **function** setPointerStyle(windowId: **number**, pointerStyle: PointerStyle, callback: AsyncCallback<**void**>): **void**; | 设置鼠标光标样式,改接口会影响指定窗口鼠标光标样式。 | -| pointer | **function** getPointerStyle(windowId: **number**, callback: AsyncCallback): **void**; | 查询鼠标光标样式。 | +| pointer | function isPointerVisible(callback: AsyncCallback\): void; | 获取鼠标指针显示或隐藏状态。 | +| pointer | function setPointerVisible(visible: boolean, callback: AsyncCallback\): void; | 设置鼠标指针显示或隐藏状态,改接口会影响全局鼠标光标的显示状态。 | +| pointer | function setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback\): void; | 设置鼠标光标样式,改接口会影响指定窗口鼠标光标样式。 | +| pointer | function getPointerStyle(windowId: number, callback: AsyncCallback\): void; | 查询鼠标光标样式。 | ## 设置鼠标光标隐藏 diff --git a/zh-cn/application-dev/faqs/faqs-device-management.md b/zh-cn/application-dev/faqs/faqs-device-management.md index bb4bb7d211450089c05f9bb09d6669b0c6fe5747..c2868918d25e61a5067b191b4ed3c62551201f39 100644 --- a/zh-cn/application-dev/faqs/faqs-device-management.md +++ b/zh-cn/application-dev/faqs/faqs-device-management.md @@ -21,7 +21,7 @@ display.getDefaultDisplay((err, data) => { }); ``` -## 如何获取当前运行设备类型(穿戴、平板等) +## 如何获取当前运行设备类型 适用于:OpenHarmony SDK 3.2.2.5版本,API9 Stage模型 diff --git a/zh-cn/application-dev/media/avsession-guidelines.md b/zh-cn/application-dev/media/avsession-guidelines.md index a395e65ee5afc1df9d1f329b778bf9cfe191efbd..d721d5b8e474a40ac4963e9914333f00feed3b85 100644 --- a/zh-cn/application-dev/media/avsession-guidelines.md +++ b/zh-cn/application-dev/media/avsession-guidelines.md @@ -14,14 +14,14 @@ | 接口名 | 描述 | |----------------------------------------------------------------------------------|-------------| -| createAVSession(context: Context, tag: string, type: AVSessionType, callback: AsyncCallback): void | 创建会话 | -| setAVMetadata(data: AVMetadata, callback: AsyncCallback): void | 设置会话元数据 | -| setAVPlaybackState(state: AVPlaybackState, callback: AsyncCallback): void | 设置会话播放状态信息 | -| setLaunchAbility(ability: WantAgent, callback: AsyncCallback): void | 设置启动ability | -| getController(callback: AsyncCallback): void | 获取当前会话自身控制器 | -| getOutputDevice(callback: AsyncCallback): void | 获取音频输出设备信息 | -| activate(callback: AsyncCallback): void | 激活会话 | -| destroy(callback: AsyncCallback): void | 销毁会话 | +| createAVSession(context: Context, tag: string, type: AVSessionType, callback: AsyncCallback\): void | 创建会话 | +| setAVMetadata(data: AVMetadata, callback: AsyncCallback\): void | 设置会话元数据 | +| setAVPlaybackState(state: AVPlaybackState, callback: AsyncCallback\): void | 设置会话播放状态信息 | +| setLaunchAbility(ability: WantAgent, callback: AsyncCallback\): void | 设置启动ability | +| getController(callback: AsyncCallback\): void | 获取当前会话自身控制器 | +| getOutputDevice(callback: AsyncCallback\): void | 获取音频输出设备信息 | +| activate(callback: AsyncCallback\): void | 激活会话 | +| destroy(callback: AsyncCallback\): void | 销毁会话 | ### 开发步骤 1.导入模块接口 @@ -354,14 +354,14 @@ currentSession.deactivate().then(() => { | 接口名 | 描述 | | ------------------------------------------------------------------------------------------------ | ----------------- | -| getAllSessionDescriptors(callback: AsyncCallback>>): void | 获取所有会话的描述符 | -| createController(sessionId: string, callback: AsyncCallback): void | 创建控制器 | -| sendAVKeyEvent(event: KeyEvent, callback: AsyncCallback): void | 发送按键命令 | -| getLaunchAbility(callback: AsyncCallback): void | 拉起应用 | -| sendControlCommand(command: AVControlCommand, callback: AsyncCallback): void | 发送控制命令 | -| sendSystemAVKeyEvent(event: KeyEvent, callback: AsyncCallback): void | 发送系统按键命令 | -| sendSystemControlCommand(command: AVControlCommand, callback: AsyncCallback): void | 发送系统控制命令 | -| castAudio(session: SessionToken | 'all', audioDevices: Array, callback: AsyncCallback): void | 远端投播 | +| getAllSessionDescriptors(callback: AsyncCallback\>>): void | 获取所有会话的描述符 | +| createController(sessionId: string, callback: AsyncCallback\): void | 创建控制器 | +| sendAVKeyEvent(event: KeyEvent, callback: AsyncCallback\): void | 发送按键命令 | +| getLaunchAbility(callback: AsyncCallback\): void | 拉起应用 | +| sendControlCommand(command: AVControlCommand, callback: AsyncCallback\): void | 发送控制命令 | +| sendSystemAVKeyEvent(event: KeyEvent, callback: AsyncCallback\): void | 发送系统按键命令 | +| sendSystemControlCommand(command: AVControlCommand, callback: AsyncCallback\): void | 发送系统控制命令 | +| castAudio(session: SessionToken | 'all', audioDevices: Array\, callback: AsyncCallback\): void | 远端投播 | ### 开发步骤 1.导入模块接口 diff --git a/zh-cn/application-dev/media/image.md b/zh-cn/application-dev/media/image.md index e36f90f47891eed3165ef79156a622f348ef5814..8c8f86e53d7a3064b4eda0e8acb1af5f2377eb23 100644 --- a/zh-cn/application-dev/media/image.md +++ b/zh-cn/application-dev/media/image.md @@ -21,23 +21,27 @@ let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { // 创建pixelmap对象 const color = new ArrayBuffer(96); let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } } -image.createPixelMap(color, opts, pixelmap => { +image.createPixelMap(color, opts, (err, pixelmap) => { console.log('Succeeded in creating pixelmap.'); }) // 用于读像素 -pixelmap.readPixels(area,(data) => { - if(data !== null) { - var bufferArr = new Uint8Array(area.pixels); - var res = true; - for (var i = 0; i < bufferArr.length; i++) { - console.info(' buffer ' + bufferArr[i]); - if(res) { - if(bufferArr[i] == 0) { - res = false; - console.log('readPixels end.'); - break; - } +const area = { + pixels: new ArrayBuffer(8), + offset: 0, + stride: 8, + region: { size: { height: 1, width: 2 }, x: 0, y: 0 } +} +pixelmap.readPixels(area,() => { + var bufferArr = new Uint8Array(area.pixels); + var res = true; + for (var i = 0; i < bufferArr.length; i++) { + console.info(' buffer ' + bufferArr[i]); + if(res) { + if(bufferArr[i] == 0) { + res = false; + console.log('readPixels end.'); + break; } } } @@ -128,7 +132,7 @@ imageSourceApi.release(() => { const imagePackerApi = image.createImagePacker(); const imageSourceApi = image.createImageSource(0); let packOpts = { format:"image/jpeg", quality:98 }; -imagePackerApi.packing(imageSourceApi, packOpts, data => { +imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => { console.log('Succeeded in packing'); }) @@ -156,7 +160,7 @@ let decodingOptions = { }; // 用于回调方式创建pixelmap -imageSourceApi.createPixelMap(decodingOptions, pixelmap => { +imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => { console.log('Succeeded in creating pixelmap.'); }) diff --git a/zh-cn/application-dev/quick-start/Readme-CN.md b/zh-cn/application-dev/quick-start/Readme-CN.md index 64e10076782a08f6aea0572f55d421b22603c086..aff3717c1a9d367cf54b4e0004d1889ce0a79992 100755 --- a/zh-cn/application-dev/quick-start/Readme-CN.md +++ b/zh-cn/application-dev/quick-start/Readme-CN.md @@ -5,8 +5,8 @@ - [使用ArkTS语言开发(FA模型)](start-with-ets-fa.md) - [使用JS语言开发(FA模型)](start-with-js-fa.md) - 开发基础知识 - - [应用包结构说明(FA模型)](package-structure.md) - - [应用包结构说明(Stage模型)](stage-structure.md) + - [应用包结构配置文件的说明(FA模型)](package-structure.md) + - [应用包结构配置文件的说明(Stage模型)](stage-structure.md) - [SysCap说明](syscap.md) - [资源分类与访问](resource-categories-and-access.md) - 学习ArkTS语言 diff --git a/zh-cn/application-dev/quick-start/package-structure.md b/zh-cn/application-dev/quick-start/package-structure.md index 7305b7d1bb55bbbdf62dea9c6d83268e7858c8f5..60c0c6891bdaaa6015d19b5a0cab0cd738b5e386 100755 --- a/zh-cn/application-dev/quick-start/package-structure.md +++ b/zh-cn/application-dev/quick-start/package-structure.md @@ -1,6 +1,6 @@ -# 应用包结构配置文件的说明 +# 应用包结构配置文件的说明(FA模型) 在FA模型的应用开发的工程中,需要在config.json配置文件中对应用的包结构进行声明。 @@ -10,7 +10,7 @@ 表1 配置文件的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ------------ | ------------------------------------------------------------ | -------- | ---------- | | app | 标识应用的全局配置信息。同一个应用的不同HAP包的app配置必须保持一致。参考[app对象内部结构](#app对象内部结构)。 | 对象 | 不可缺省。 | | deviceConfig | 标识应用在具体设备上的配置信息。参考[deviceConfig对象内部结构](#deviceconfig对象的内部结构)。 | 对象 | 不可缺省。 | @@ -24,25 +24,24 @@ config.json示例: "bundleName": "com.example.myapplication", "vendor": "example", "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5, - "releaseType": "Beta1" + "code": 1000000, + "name": "1.0.0" } }, "deviceConfig": {}, "module": { - "package": "com.example.myapplication.entrymodule", - "name": ".MyApplication", + "package": "com.example.myapplication", + "name": ".entry", + "mainAbility": ".MainAbility", "deviceType": [ - "default" + "default", + "tablet" ], "distro": { + "deliveryWithInstall": true, "moduleName": "entry", - "moduleType": "entry" + "moduleType": "entry", + "installationFree": false }, "abilities": [ { @@ -56,20 +55,33 @@ config.json示例: ] } ], - "name": "com.example.myapplication.entrymodule.MainAbility", + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "ets", + "srcPath": "MainAbility", "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", + "description": "$string:ability_desc", + "label": "$string:ability_label", "type": "page", + "visible": true, "launchType": "standard" } ], "js": [ { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, "pages": [ - "pages/index/index" + "pages/LoginPage", + "pages/MinePage", + "pages/RegistrationSuccessPage", + "pages/PrivacyPage", + "pages/CustomerServicePage" ], - "name": "default", + "name": ".MainAbility", "window": { "designWidth": 720, "autoDesignWidth": false @@ -86,46 +98,48 @@ app对象包含应用全局配置信息,内部结构说明参见表2。 表2 app对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ----------------- | ------------------------------------------------------------ | -------- | --------------------------- | -| bundleName | 标识应用的包名,用于标识应用的唯一性。包名是由字母、数字、下划线(_)和点号(.)组成的字符串,必须以字母开头。支持的字符串长度为7~127字节。包名通常采用反向域名形式表示(例如,"com.example.myapplication")。建议第一级为域名后缀"com",第二级为厂商/个人名,也可以采用多级。 | 字符串 | 不可缺省。 | +| bundleName | 标识应用的包名,用于标识应用的唯一性。包名是由字母、数字、下划线(_)和点号(.)组成的字符串,必须以字母开头。支持的字符串长度为7~127字节。
包名通常采用反向域名形式表示(例如,"com.example.myapplication")。建议第一级为域名后缀"com",第二级为厂商/个人名,也可以采用多级。 | 字符串 | 不可缺省。 | | vendor | 标识对应用开发厂商的描述。字符串长度不超过255字节。 | 字符串 | 可缺省,缺省值为空。 | -| version | 标识应用的版本信息。参考表3。 | 对象 | 否 | +| version | 标识应用的版本信息。参考表3。 | 对象 | 不可缺省。 | | apiVersion | 标识应用程序所依赖的OpenHarmony API版本。参考表4。 | 对象 | 可缺省,缺省值为空。 | | smartWindowSize | 标识应用在模拟器中运行时使用的屏幕尺寸。 | 字符串 | 可缺省,缺省值为空。 | | smartWindowDeviceType | 标识应用在模拟器中运行时可以模拟的设备。 | 字符串数组 | 可缺省,缺省值为空。 | 表3 version内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ------------------------ | ------------------------------------------------------------ | -------- | -------------------------- | | name | 标识应用的版本号,用于向应用的终端用户呈现。取值可以自定义,长度不超过127字节。自定义规则如下:
API5及更早的版本:推荐使用三段数字版本号(也兼容两段式版本号),如A.B.C(也兼容A.B),其中A、B、C取值为0-999范围内的整数。除此之外不支持其他格式。
A段,一般表示主版本号(Major)。
B段,一般表示次版本号(Minor)。
C段,一般表示修订版本号(Patch)。
API6版本起:推荐采用四段式数字版本号,如A.B.C.D,其中A、B、C取值为0-99范围内的整数,D的取值为0-999范围内的整数。
A段,一般表示主版本号(Major)。
B段,一般表示次版本号(Minor)。
C段,一般表示特性版本号(Feature)。
D段,一般表示修订版本号(Patch)。 | 数值 | 不可缺省。 | -| code | 标识应用的版本号,仅用于OpenHarmony管理该应用,不对应用的终端用户呈现。取值规则如下:
API5及更早版本:二进制32位以内的非负整数,需要从version.name的值转换得到。转换规则为:
code值=A * 1,000,000 + B * 1,000 + C 例如,version.name字段取值为2.2.1,则code值为2002001。
API6版本起:code的取值不与version.name字段的取值关联,开发者可自定义code取值,取值范围为2^31以内的非负整数,但是每次应用版本的更新,均需要更新code字段的值,新版本code取值必须大于旧版本code的值。 | 数值 | 不可缺省。 | +| code | 标识应用的版本号,仅用于OpenHarmony管理该应用,不对应用的终端用户呈现。取值规则如下:
API5及更早版本:二进制32位以内的非负整数,需要从version.name的值转换得到。转换规则为:
code值=A * 1,000,000 + B * 1,000 + C 例如,version.name字段取值为2.2.1,则code值为2002001。
API6版本起:code的取值不与version.name字段的取值关联,开发者可自定义code取值,取值范围为2^31以内的非负整数,
但是每次应用版本的更新,均需要更新code字段的值,新版本code取值必须大于旧版本code的值。 | 数值 | 不可缺省。 | | minCompatibleVersionCode | 标识应用可兼容的最低版本号,用于跨设备场景下,判断其他设备上该应用的版本是否兼容。
格式与version.code字段的格式要求相同。 | 数值 | 可缺省,缺省值为code标签值。 | 表4 apiVersion内部结构 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ----------- | ----------------------------------------------------------- | -------- | ---------- | | compatible | 运行应用所需要的最低API版本,取值范围为0~2147483647。 | 数值 | 配置在build.profile中,打包时由IDE填充到config.json中。 | | target | 用于标识应用运行所需的目标API版本,取值范围为0~2147483647。 | 数值 | 配置在build.profile中,打包时由IDE填充到config.json中。 | -| releaseType | 用于标识应用运行所需的目标API版本的类型。 | 字符串 | 配置在build.profile中,打包时由IDE填充到config.json中。 | +| releaseType | 用于标识应用运行时SDK的状态。
canary:面向特定开发者早期预览版本,不承诺质量,不承诺API稳定。
beta:公开发布的Beta版本,早期Beta版本不承诺API稳定,经历若干次发布后,通过Release Notes对开发者声明该Beta版本为API稳定里程碑,后续版本的API冻结。
release:正式发布版本,承诺质量,API不可变更。当版本处于此状态时版本号中不呈现Stage字段。 | 字符串 | 配置在build.profile中,打包时由IDE填充到config.json中。 | app实例: ```json -"app": { +{ + "app": { "bundleName": "com.example.myapplication", "vendor": "example", "version": { - "code": 8, - "name": "8.0.1" + "code": 1000000, + "name": "1.0.0" }, "apiVersion": { - "compatible": 8, - "target": 9, - "releaseType": "Beta1" + "compatible": 9, + "target": 9, + "releaseType": "Beta1" } + } } ``` @@ -147,12 +161,12 @@ default、tablet、tv、car、wearable等对象的内部结构说明如下: 表6 deviceConfig设备对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ------------------ | ------------------------------------------------------------ | -------- | ----------------------- | -| process | 标识应用或者Ability的进程名。如果在deviceConfig标签下配置了process标签,则该应用的所有Ability都运行在这个进程中。如果在abilities标签下也为某个Ability配置了process标签,则该Ability就运行在这个进程中。该标签仅适用于默认设备、平板、智慧屏、车机、智慧穿戴。该标签最大长度为31。 | 字符串 | 可缺省,缺省值为空。 | -| keepAlive | 标识应用是否始终保持运行状态,仅支持系统应用配置,三方应用配置不生效。该标签为布尔类型,可缺省,缺省值为false,如果配置为true,应用将始终保持为运行状态,并在系统启动的时候被系统驱动起来,应用进程退出后,系统也会重新启动应用进程。 | 布尔值 | 可缺省,缺省值为false。 | -| supportBackup | 标识应用是否支持备份和恢复。如果配置为"false",则不支持为该应用执行备份或恢复操作。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为false。 | -| compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP包。如果配置为"false",则libs库以不压缩的方式存储,HAP包在安装时无需解压libs,运行时会直接从HAP内加载libs库。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为false。 | +| process | 标识应用或者Ability的进程名。如果在deviceConfig标签下配置了process标签,则该应用的所有Ability都运行在这个进程中。如果在abilities标签下也为某个Ability配置了process标签,
则该Ability就运行在这个进程中。该标签最大长度为31。 | 字符串 | 可缺省,缺省值为空。 | +| keepAlive | 标识应用是否始终保持运行状态,仅支持系统应用配置,三方应用配置不生效。该标签为布尔类型,可缺省,缺省值为false,如果配置为true,应用将始终保持为运行状态,
并在系统启动的时候被系统驱动起来,应用进程退出后,系统也会重新启动应用进程。 | 布尔值 | 可缺省,缺省值为false。 | +| supportBackup | 标识应用是否支持备份和恢复。如果配置为false,则不支持为该应用执行备份或恢复操作。 | 布尔值 | 可缺省,缺省值为false。 | +| compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP包。如果配置为false,则libs库以不压缩的方式存储,HAP包在安装时无需解压libs,运行时会直接从HAP内加载libs库。 | 布尔值 | 可缺省,缺省值为false。 | | network | 标识网络安全性配置。该标签允许应用通过配置文件的安全声明来自定义其网络安全,无需修改应用代码。参考表7。 | 对象 | 可缺省,缺省值为空。 | 表7 network对象的内部结构说明 @@ -164,34 +178,36 @@ default、tablet、tv、car、wearable等对象的内部结构说明如下: 表8 securityConfig对象的内部结构说明 -| 属性名称 | 子属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 子属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------------- | ------------------ | ------------------------------------------------------------ | -------- | ---------------- | | domainSettings | - | 标识自定义的网域范围的安全配置,支持多层嵌套,即一个domainSettings对象中允许嵌套更小网域范围的domainSettings对象。 | 对象 | 可缺省,缺省值为空。 | | | cleartextPermitted | 标识自定义的网域范围内是否允许明文流量传输。当cleartextTraffic和security同时存在时,自定义网域是否允许明文流量传输以cleartextPermitted的取值为准。
true:允许明文流量传输。
false:拒绝明文流量传输。 | 布尔值 | 可缺省,缺省值为空。 | -| | domains | 标识域名配置信息,包含两个参数:subdomains和name。
subdomains(布尔类型):表示是否包含子域名。如果为"true",此网域规则将与相应网域及所有子网域(包括子网域的子网域)匹配。否则,该规则仅适用于精确匹配项。
name(字符串):表示域名名称。 | 对象数组 | 可缺省,缺省值为空。 | +| | domains | 标识域名配置信息,包含两个参数:subdomains和name。
subdomains(布尔类型):表示是否包含子域名。如果为true,此网域规则将与相应网域及所有子网域(包括子网域的子网域)匹配。
否则,该规则仅适用于精确匹配项。name(字符串):表示域名名称。 | 对象数组 | 可缺省,缺省值为空。 | deviceConfig示例: ```json -"deviceConfig": { +{ + "deviceConfig": { "default": { - "process": "com.example.test.example", - "supportBackup": false, - "network": { - "cleartextTraffic": true, - "securityConfig": { - "domainSettings": { - "cleartextPermitted": true, - "domains": [ - { - "subdomains": true, - "name": "example.ohos.com" - } - ] - } - } + "process": "com.example.myapplication", + "supportBackup": false, + "network": { + "cleartextTraffic": true, + "securityConfig": { + "domainSettings": { + "cleartextPermitted": true, + "domains": [ + { + "subdomains": true, + "name": "example.ohos.com" + } + ] + } } + } } + } } ``` @@ -201,63 +217,96 @@ module对象包含HAP包的配置信息,内部结构说明参见表9。 表9 module对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ----------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | | mainAbility | 服务中心图标露出的ability,常驻进程拉起时会启动mainAbility。 | 字符串 | 可缺省,缺省值为空。 | -| package | 标识HAP的包结构名称,在应用内保证唯一性。采用反向域名格式(建议与HAP的工程目录保持一致)。字符串长度为1-127个字节。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 不可缺省。 | -| name | 标识HAP的类名。采用反向域名方式标识,前缀要与同级的package标签指定的包名一致,也可采用"."开头的命名方式。字符串长度不超过255字节。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。 | -| description | 标识HAP的描述信息。字符串长度不超过255字节。如果字符串超出长度或者需要支持多语言,可以采用资源索引的方式添加描述内容。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。 | +| package | 标识HAP的包结构名称,在应用内保证唯一性。采用反向域名格式(建议与HAP的工程目录保持一致)。字符串长度为1-127个字节。 | 字符串 | 不可缺省。 | +| name | 标识HAP的类名。采用反向域名方式标识,前缀要与同级的package标签指定的包名一致,也可采用"."开头的命名方式。字符串长度不超过255字节。 | 字符串 | 可缺省,缺省值为空。 | +| description | 标识HAP的描述信息。字符串长度不超过255字节。如果字符串超出长度或者需要支持多语言,可以采用资源索引的方式添加描述内容。 | 字符串 | 可缺省,缺省值为空。 | | supportedModes | 标识应用支持的运行模式,当前只定义了驾驶模式(drive)。该标签只适用于车机。 | 字符串数组 | 可缺省,缺省值为空。 | | deviceType | 标识允许Ability运行的设备类型。系统预定义的设备类型包括:tablet(平板)、tv(智慧屏)、car(车机)、wearable(智能穿戴)等。 | 字符串数组 | 不可缺省。 | -| distro | 标识HAP发布的具体描述。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。参考表10。 | 对象 | 不可缺省。 | +| distro | 标识HAP发布的具体描述。参考表10。 | 对象 | 不可缺省。 | | metaData | 标识HAP的元信息。参考表11。 | 对象 | 可缺省,缺省值为空。 | | abilities | 标识当前模块内的所有Ability。采用对象数据格式。参考表15。 | 对象数组 | 可缺省,缺省值为空。 | | js | 标识基于ArkUI框架开发的JS模块集合,其中的每个元素代表一个JS模块的信息。参考表21。 | 对象数组 | 可缺省,缺省值为空。 | | shortcuts | 标识应用的快捷方式信息。采用对象数组格式,其中的每个元素表示一个快捷方式对象。参考表24。 | 对象数组 | 可缺省,缺省值为空。 | | reqPermissions | 标识应用运行时向系统申请的权限。参考表19。 | 对象数组 | 可缺省,缺省值为空。 | -| colorMode | 标识应用自身的颜色模式。
dark:表示按照深色模式选取资源。
light:表示按照浅色模式选取资源。
auto:表示跟随系统的颜色模式值选取资源。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"auto"。 | -| distroFilter | 标识应用的分发规则。
该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括API Version、屏幕形状、屏幕分辨率。在进行分发时,通过deviceType与这三个属性的匹配关系,唯一确定一个用于分发到设备的HAP。参考表28。 | 对象 | 可缺省,缺省值为空。但当应用中包含多个entry模块时,必须配置该标签。 | -| commonEvents | 定义了公共事件静态订阅者的信息,该字段中需要声明静态订阅者的名称、权限要求及订阅事件列表信息,当订阅的公共事件发送时,该公共事件静态订阅者将被拉起。这里的静态订阅者区分于常用的动态订阅者,前者无需在业务代码中主动调用订阅事件的接口,在公共事件发布时可能未被拉起,而动态订阅者则在业务代码中主动调用公共事件订阅的相关API,因此需要应用处于活动状态。参考表34。 | 对象数组 | 可缺省,缺省值为空。 | +| colorMode | 标识应用自身的颜色模式。
dark:表示按照深色模式选取资源。
light:表示按照浅色模式选取资源。
auto:表示跟随系统的颜色模式值选取资源。 | 字符串 | 可缺省,缺省值为"auto"。 | +| distroFilter | 标识应用的分发规则。
该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括:
API Version、屏幕形状、屏幕尺寸、屏幕分辨率、国家和地区码。
在进行分发时,通过deviceType与这五个属性的匹配关系,唯一确定一个用于分发到设备的HAP。参考表27。 | 对象 | 可缺省,缺省值为空。但当应用中包含多个entry模块时,必须配置该标签。 | +| commonEvents | 定义了公共事件静态订阅者的信息,该字段中需要声明静态订阅者的名称、权限要求及订阅事件列表信息,当订阅的公共事件发送时,
该公共事件静态订阅者将被拉起。这里的静态订阅者区分于常用的动态订阅者,前者无需在业务代码中主动调用订阅事件的接口,
在公共事件发布时可能未被拉起,而动态订阅者则在业务代码中主动调用公共事件订阅的相关API,因此需要应用处于活动状态。参考表33。 | 对象数组 | 可缺省,缺省值为空。 | | entryTheme | 此标签标识OpenHarmony内部主题的关键字。将标记值设置为名称的资源索引。 | 字符串 | 可缺省,缺省值为空。 | -| testRunner | 此标签用于支持对测试框架的配置,参考表35。 | 对象 | 可缺省,缺省值为空。 | +| testRunner | 此标签用于支持对测试框架的配置,参考表34。 | 对象 | 可缺省,缺省值为空。 | module示例: ```json -"module": { - "mainAbility": "MainAbility", - "package": "com.example.myapplication.entry", - "name": ".MyOHOSAbilityPackage", - "description": "$string:description_application", - "supportModes": [ - "drive" - ], +{ + "module": { + "package": "com.example.myapplication", + "name": ".entry", + "mainAbility": ".MainAbility", "deviceType": [ - "car" + "default", + "tablet" ], "distro": { - "moduleName": "ohos_entry", - "moduleType": "entry" + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false }, "abilities": [ - ... - ], - "shortcuts": [ - ... + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "ets", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:ability_desc", + "label": "$string:ability_label", + "type": "page", + "visible": true, + "launchType": "standard" + } ], "js": [ - ... - ], - "reqPermissions": [ - ... - ], - "colorMode": "light" + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/LoginPage", + "pages/MinePage", + "pages/RegistrationSuccessPage", + "pages/PrivacyPage", + "pages/CustomerServicePage" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } } ``` 表10 distro对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ---------------- | ------------------------------------------------------------ | -------- | ---------- | | moduleName | 标识当前HAP的名称,最大长度为31个字节。 | 字符串 | 不可缺省。 | | moduleType | 标识当前HAP的类型,包括三种类型:entry、feature和har。 | 字符串 | 不可缺省。 | @@ -267,17 +316,21 @@ module示例: distro示例: ```json -"distro": { - "moduleName": "ohos_entry", - "moduleType": "entry", - "installationFree": true, - "deliveryWithInstall": true +{ + "module": { + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + } + } } ``` 表11 metaData对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ------------- | ------------------------------------------------------------ | -------- | -------------------- | | parameters | 标识调用Ability时所有调用参数的元信息。每个调用参数的元信息由以下三个标签组成:description、name、type。参考表12。 | 对象数组 | 可缺省,缺省值为空。 | | results | 标识Ability返回值的元信息。每个返回值的元信息由以下三个标签组成:description、name、type。参考表13。 | 对象数组 | 可缺省,缺省值为空。 | @@ -285,7 +338,7 @@ distro示例: 表12 parameters对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ----------- | ------------------------------------------------------------ | -------- | ------------------ | | description | 标识对调用参数的描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | | name | 标识调用参数的名称。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | @@ -293,7 +346,7 @@ distro示例: 表13 results对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ----------- | ------------------------------------------------------------ | -------- | -------------------- | | description | 标识对返回值的描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | | name | 标识返回值的名字。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | @@ -310,53 +363,63 @@ distro示例: metaData示例: ```json -"metaData": { - "parameters" : [{ - "name" : "string", - "type" : "Float", - "description" : "$string:parameters_description" - }], - "results" : [{ - "name" : "string", - "type" : "Float", - "description" : "$string:results_description" - }], - "customizeData" : [{ - "name" : "string", - "value" : "string", - "extra" : "$string:customizeData_description" - }] +{ + "module": { + "metaData": { + "parameters": [ + { + "name": "string", + "type": "Float", + "description": "$string:parameters_desc" + } + ], + "results": [ + { + "name": "string", + "type": "Float", + "description": "$string:results_desc" + } + ], + "customizeData": [ + { + "name": "string", + "value": "string", + "extra": "$string:customizeData_desc" + } + ] + } + } } ``` 表15 abilities对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ---------------- | ------------------------------------------------------------ | ---------- | -------------------------------------------------------- | | process | 运行应用程序或Ability的进程名称。如果在deviceConfig标记中配置了进程,则应用程序的所有能力都在此进程中运行。您还可以为特定能力设置流程属性,以便该能力可以在此流程中运行。如果此属性设置为与其他应用程序相同的进程名称,则所有这些应用程序可以在同一进程中运行,前提是他们具有相同的联合用户ID和相同的签名。运行OHOS的设备不支持此属性。该标签最大字节数为31个字节。 | 字符串 | 可缺省,缺省值为空。 | -| name | 标识Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如“com.example.myapplication.MainAbility”;也可采用“.”开头的类名方式表示,如“.MainAbility”。
Ability的名称,需在一个应用的范围内保证唯一。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。
说明:在使用DevEco Studio新建项目时,默认生成首个Ability的配置,即“config.json”中“MainAbility”的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127。 | 字符串 | 不可缺省。 | +| name | 标识Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如“com.example.myapplication.MainAbility”;也可采用“.”开头的类名方式表示,如“.MainAbility”。
Ability的名称,需在一个应用的范围内保证唯一。
说明:在使用DevEco Studio新建项目时,默认生成首个Ability的配置,即“config.json”中“MainAbility”的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127。 | 字符串 | 不可缺省。 | | description | 标识对Ability的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | | icon | 标识Ability图标资源文件的索引。取值示例:$media:ability_icon。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的icon将同时作为应用的icon。如果存在多个符合条件的Ability,则取位置靠前的Ability的icon作为应用的icon。
说明:应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。 | 字符串 | 可缺省,缺省值为空。 | | label | 标识Ability对用户显示的名称。取值可以是Ability名称,也可以是对该名称的资源索引,以支持多语言。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。
说明: 应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。该标签为资源文件中定义的字符串的引用,或以"{}"包括的字符串。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | | uri | 标识Ability的统一资源标识符。该标签最大长度为255。 | 字符串 | 可缺省,对于data类型的Ability不可缺省。 | -| launchType | 标识Ability的启动模式,支持“standard”和“singleton”两种模式:
standard:表示该Ability可以有多实例。该模式适用于大多数应用场景。
singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用“singleton”模式。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为“singleton”。 | -| visible | 标识Ability是否可以被其他应用调用。
true:可以被其他应用调用。
false:不能被其他应用调用。 | 布尔值 | 可缺省,缺省值为“false”。 | +| launchType | 标识Ability的启动模式,支持“standard”和“singleton”两种模式:
standard:表示该Ability可以有多实例。该模式适用于大多数应用场景。
singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用“singleton”模式。 | 字符串 | 可缺省,缺省值为“singleton”。 | +| visible | 标识Ability是否可以被其他应用调用。
true:可以被其他应用调用。
false:不能被其他应用调用。 | 布尔值 | 可缺省,缺省值为false。 | | permissions | 标识其他应用的Ability调用此Ability时需要申请的权限集合,一个数组元素为一个权限名称。通常采用反向域名格式(最大255字节),取值为系统预定义的权限。 | 字符串数组 | 可缺省,缺省值为空。 | -| skills | 标识Ability能够接收的want的特征。 | 对象数组 | 可缺省,缺省值为空。 | +| skills | 标识Ability能够接收的want的特征。参考表17。 | 对象数组 | 可缺省,缺省值为空。 | | deviceCapability | 标识Ability运行时要求设备具有的能力,采用字符串数组的格式表示。该标签为数组,支持最多配置512个元素,单个元素最大字节长度为64。 | 字符串数组 | 可缺省,缺省值为空。 | | metaData | 元数据,参考表11。 | 对象 | 可缺省,缺省值为空。 | | type | 标识Ability的类型。取值范围如下:
page:表示基于Page模板开发的FA,用于提供与用户交互的能力。
service:表示基于Service模板开发的PA,用于提供后台运行任务的能力。
data:表示基于Data模板开发的PA,用于对外部提供统一的数据访问抽象。
CA:表示支持其他应用以窗口方式调起该Ability。 | 字符串 | 不可缺省。 | | orientation | 标识该Ability的显示模式。该标签仅适用于page类型的Ability。取值范围如下:
unspecified:由系统自动判断显示方向。
landscape:横屏模式。
portrait:竖屏模式。
followRecent:跟随栈中最近的应用。 | 字符串 | 可缺省,缺省值为“unspecified”。 | | backgroundModes | 标识后台服务的类型,可以为一个服务配置多个后台服务类型。该标签仅适用于service类型的Ability。取值范围如下:
dataTransfer:通过网络/对端设备进行数据下载、备份、分享、传输等业务。
audioPlayback:音频输出业务。
audioRecording:音频输入业务。
pictureInPicture:画中画、小窗口播放视频业务。
voip:音视频电话、VOIP业务。
location:定位、导航业务。
bluetoothInteraction:蓝牙扫描、连接、传输业务。
wifiInteraction:WLAN扫描、连接、传输业务。
screenFetch:录屏、截屏业务。
multiDeviceConnection:多设备互联业务 | 字符串数组 | 可缺省,缺省值为空。 | | grantPermission | 指定是否可以向Ability内任何数据授予权限。 | 布尔值 | 可缺省,缺省值为空。 | -| readPermission | 标识读取Ability的数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。 | -| writePermission | 标识向Ability写数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。 | +| readPermission | 标识读取Ability的数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。 | 字符串 | 可缺省,缺省值为空。 | +| writePermission | 标识向Ability写数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。 | 字符串 | 可缺省,缺省值为空。 | | configChanges | 标识Ability关注的系统配置集合。当已关注的配置发生变更后,Ability会收到onConfigurationUpdated回调。取值范围:
mcc:表示IMSI移动设备国家/地区代码(MCC)发生变更。典型场景:检测到SIM并更新MCC。
mnc:IMSI移动设备网络代码(MNC)发生变更。典型场景:检测到SIM并更新MNC。
locale:表示语言区域发生变更。典型场景:用户已为设备文本的文本显示选择新的语言类型。
layout:表示屏幕布局发生变更。典型场景:当前有不同的显示形态都处于活跃状态。
fontSize:表示字号发生变更。典型场景:用户已设置新的全局字号。
orientation:表示屏幕方向发生变更。典型场景:用户旋转设备。
density:表示显示密度发生变更。典型场景:用户可能指定不同的显示比例,或当前有不同的显示形态同时处于活跃状态。
size:显示窗口大小发生变更。
smallestSize:显示窗口较短边的边长发生变更。
colorMode:颜色模式发生变更。 | 字符串数组 | 可缺省,缺省值为空。 | -| mission | 标识Ability指定的任务栈。该标签仅适用于page类型的Ability。默认情况下应用中所有Ability同属一个任务栈。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为应用的包名。 | -| targetAbility | 标识当前Ability重用的目标Ability。该标签仅适用于page类型的Ability。如果配置了targetAbility属性,则当前Ability(即别名Ability)的属性中仅name、icon、label、visible、permissions、skills生效,其它属性均沿用targetAbility中的属性值。目标Ability必须与别名Ability在同一应用中,且在配置文件中目标Ability必须在别名之前进行声明。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。表示当前Ability不是一个别名Ability。 | -| formsEnabled | 标识Ability是否支持卡片(forms)功能。该标签仅适用于page类型的Ability。
true:支持卡片能力。
false:不支持卡片能力。 | 布尔值 | 可缺省,缺省值为“false”。 | -| forms | 标识服务卡片的属性。该标签仅当formsEnabled为“true”时,才能生效。参考表26。 | 对象数组 | 可缺省,缺省值为空。 | -| srcLanguage | Ability开发语言的类型,开发者创建工程时由开发者手动选择开发语言。 | 字符串 | 可缺省,取值为js或ets | +| mission | 标识Ability指定的任务栈。该标签仅适用于page类型的Ability。默认情况下应用中所有Ability同属一个任务栈。 | 字符串 | 可缺省,缺省为应用的包名。 | +| targetAbility | 标识当前Ability重用的目标Ability。该标签仅适用于page类型的Ability。如果配置了targetAbility属性,则当前Ability(即别名Ability)的属性中仅name、icon、label、visible、permissions、skills生效,其它属性均沿用targetAbility中的属性值。目标Ability必须与别名Ability在同一应用中,且在配置文件中目标Ability必须在别名之前进行声明。 | 字符串 | 可缺省,缺省值为空。表示当前Ability不是一个别名Ability。 | +| formsEnabled | 标识Ability是否支持卡片(forms)功能。该标签仅适用于page类型的Ability。
true表示支持卡片能力,false表示不支持卡片能力。 | 布尔值 | 可缺省,缺省值为false。 | +| forms | 标识服务卡片的属性。该标签仅当formsEnabled为true时,才能生效。参考表26。 | 对象数组 | 可缺省,缺省值为空。 | +| srcLanguage | Ability开发语言的类型,开发者创建工程时由开发者手动选择开发语言。 | 字符串 | 可缺省,取值为"js"或"ets" | | srcPath | 该标签标识Ability对应的JS组件代码路径,该标签最大长度为127字节。 | 字符串 | 可缺省,缺省值为空。 | | uriPermission | 标识该Ability有权访问的应用程序数据。此属性由模式和路径子属性组成。此属性仅对类型提供者的能力有效。运行OHOS的设备不支持此属性。参考表16。 | 对象 | 可缺省,缺省值为空。 | | startWindowIcon | 标识该Ability启动页面图标资源文件的索引。该标签仅适用于page类型的ability。取值示例:$media:icon。 | 字符串 | 可缺省,缺省值为空。| @@ -368,82 +431,49 @@ metaData示例: | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ----------------------- | -------- | ------------------------- | | path | uriPermission标识的路径,该标签最大字节长度为255个字节。 | 字符串 | 不可缺省。 | -| mode | uriPermission的匹配模式 | 字符串 | 可缺省,缺省值为default。 | +| mode | uriPermission的匹配模式 | 字符串 | 可缺省,缺省值为"default"。 | abilities示例: ```json -"abilities": [ - { - "name": ".MainAbility", - "description": "test main ability", - "icon": "$media:ic_launcher", - "label": "$media:example", - "launchType": "standard", - "orientation": "unspecified", - "permissions": [], - "visible": true, +{ + "module": { + "abilities": [ + { "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } ], - "configChanges": [ - "locale", - "layout", - "fontSize", - "orientation" - ], - "type": "page", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:red", - "removeMissionAfterTerminate": true - }, - { - "name": ".PlayService", - "description": "example play ability", - "icon": "$media:ic_launcher", - "label": "$media:example", - "launchType": "standard", "orientation": "unspecified", - "visible": false, - "skills": [ - { - "actions": [ - "action.play.music", - "action.stop.music" - ], - "entities": [ - "entity.audio" - ] - } - ], - "type": "service", - "backgroundModes": [ - "audioPlayback" - ] - }, - { - "name": ".UserADataAbility", - "type": "data", - "uri": "dataability://com.example.world.test.UserADataAbility", - "visible": true - } -] + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "ets", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:ability_desc", + "label": "$string:ability_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ] + } +} ``` 表17 skills对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------- | ------------------------------------------------------------ | ---------- | -------------------- | | actions | 标识能够接收的want的action值,可以包含一个或多个action。取值通常为系统预定义的action值。 | 字符串数组 | 可缺省,缺省值为空。 | | entities | 标识能够接收的want的Ability的类别(如视频、桌面应用等),可以包含一个或多个entity。 | 字符串数组 | 可缺省,缺省值为空。 | -| uris | 该标签标识向want过滤器添加数据规范集合。该规范可以是只有数据类型(mimeType属性),可以是只有URI,也可以是既有数据类型又有URI。URI由其各个部分的单独属性指定:\://\:\/[\\|\\|\]。其中,scheme字段配置为uri时必配;当只设置数据类型(mimeType)时,则scheme字段为非必配项。参考表18。 | 对象数组 | 可缺省,缺省值为空。 | +| uris | 该标签标识向want过滤器添加数据规范集合。该规范可以是只有数据类型(mimeType属性),可以是只有URI,也可以是既有数据类型又有URI。
URI由其各个部分的单独属性指定:\://\:\/[\\|\\|\]。其中,scheme字段配置为uri时必配;当只设置数据类型(mimeType)时,则scheme字段为非必配项。参考表18。 | 对象数组 | 可缺省,缺省值为空。 | 表18 uris对象的内部结构说明 @@ -460,30 +490,38 @@ abilities示例: skills示例: ```json -"skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ], - "uris": [ - { +{ + "module": { + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ], + "uris": [ + { "scheme": "http", "host": "www.example.com", "port": "8080", "path": "query/student/name", "type": "text/*" - } + } + ] + } ] - } -] + } + ] + } +} ``` 表19 reqPermissions权限申请字段说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ---------- | ------------------------------------------------------------ | -------- | ------------------ | | name | 需要使用的权限名称。 | 字符串 | 不可缺省。 | | reason | 描述申请权限的原因。需要做多语种适配。 | 字符串 | 分情况:当申请的权限为user_grant时,必须填写此字段,否则不允许在应用市场上架;其它权限可缺省,缺省值为空。 | @@ -492,57 +530,67 @@ skills示例: 表20 usedScene对象内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ------- | --------------------| -------- | ------ | | ability | 标识哪些Ability需要此权限,里面配置Ability的名称。| 字符串数组 | 可缺省,缺省表示所有Ability都需要此权限。 | | when | 标识使用此权限的使用时间:
inuse:使用时需要此权限。
always:所有时间都需要此权限。 | 枚举值 | 可缺省,缺省值为空。 | 表21 js对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | ------------------------ | | name | 标识JS Component的名字。该标签不可缺省,默认值为default。 | 字符串 | 不可缺省。 | | pages | 标识JS Component的页面用于列举JS Component中每个页面的路由信息[页面路径+页面名称]。该标签不可缺省,取值为数组,数组第一个元素代表JS FA首页。 | 字符串数组 | 不可缺省。 | -| window | 用于定义与显示窗口相关的配置。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。参考表22。 | 对象 | 可缺省。 | +| window | 用于定义与显示窗口相关的配置。参考表22。 | 对象 | 可缺省,缺省值参考表22。 | | type | 标识JS应用的类型。取值范围如下:
normal:标识该JS Component为应用实例。
form:标识该JS Component为卡片实例。 | 字符串 | 可缺省,缺省值为“normal” | | mode | 定义JS组件的开发模式。参考表23。 | 对象 | 可缺省,缺省值为空。 | 表22 window对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | --------------- | ------------------------------------------------------------ | -------- | ----------------------- | | designWidth | 标识页面设计基准宽度。以此为基准,根据实际设备宽度来缩放元素大小。 | 数值 | 可缺省,缺省值为720px。 | -| autoDesignWidth | 标识页面设计基准宽度是否自动计算。当配置为true时,designWidth将会被忽略,设计基准宽度由设备宽度与屏幕密度计算得出。 | 布尔值 | 可缺省,缺省值为“false”。 | +| autoDesignWidth | 标识页面设计基准宽度是否自动计算。当配置为true时,designWidth将会被忽略,设计基准宽度由设备宽度与屏幕密度计算得出。 | 布尔值 | 可缺省,缺省值为false。 | 表23 mode对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | -------------------- | ----------------------------------- | --------------------------- | -| type | 定义JS组件的功能类型 | 字符串,取值为"pageAbility"、"form" | 可缺省,缺省值为pageAbility。 | +| type | 定义JS组件的功能类型 | 字符串,取值为"pageAbility"、"form" | 可缺省,缺省值为"pageAbility"。 | | syntax | 定义JS组件的语法类型 | 字符串,取值为"hml","ets" | 可缺省,缺省值为"hml"。 | js示例: ```json -"js": [ - { - "name": "default", - "pages": [ - "pages/index/index", - "pages/detail/detail" - ], - "window": { - "designWidth": 720, - "autoDesignWidth": false +{ + "module": { + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" }, - "type": "form" - } -] + "pages": [ + "pages/LoginPage", + "pages/MinePage", + "pages/RegistrationSuccessPage", + "pages/PrivacyPage", + "pages/CustomerServicePage" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} ``` 表24 shortcuts对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ---------- | ------------------------------------------------------------ | -------- | ------------------ | | shortcutId | 标识快捷方式的ID。字符串的最大长度为63字节。 | 字符串 | 不可缺省。 | | label | 标识快捷方式的标签信息,即快捷方式对外显示的文字描述信息。取值可以是描述性内容,也可以是标识label的资源索引。字符串最大长度为63字节。 | 字符串 | 可缺省,缺省值为空。 | @@ -559,23 +607,27 @@ js示例: shortcuts示例: ```json -"shortcuts": [ - { +{ + "module": { + "shortcuts": [ + { "shortcutId": "id", "label": "$string:shortcut", "intents": [ - { - "targetBundle": "com.example.world.test", - "targetClass": "com.example.world.test.entry.MainAbility" - } + { + "targetBundle": "com.example.myapplication", + "targetClass": "com.example.myapplication.MainAbility" + } ] - } -] + } + ] + } +} ``` 表26 forms对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ | | name | 标识卡片的类名。字符串最大长度为127字节。 | 字符串 | 不可缺省。 | | description | 标识卡片的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省值为空。 | @@ -586,115 +638,115 @@ shortcuts示例: | defaultDimension | 标识卡片的默认外观规格,取值必须在该卡片supportDimensions配置的列表中。 | 字符串 | 不可缺省。 | | updateEnabled | 标识卡片是否支持周期性刷新,取值范围:
true:表示支持周期性刷新,可以在定时刷新(updateDuration)和定点刷新(scheduledUpdateTime)两种方式任选其一,优先选择定时刷新。
false:表示不支持周期性刷新。 | 布尔值 | 不可缺省。 | | scheduledUpdateTime | 标识卡片的定点刷新的时刻,采用24小时制,精确到分钟。 | 字符串 | 可缺省,缺省值为“0:0”。 | -| updateDuration | 标识卡片定时刷新的更新周期,单位为30分钟,取值为自然数。
当取值为0时,表示该参数不生效。
当取值为正整数N时,表示刷新周期为30*N分钟。 | 数值 | 可缺省,缺省值为“0”。 | +| updateDuration | 标识卡片定时刷新的更新周期,单位为30分钟,取值为自然数。
当取值为0时,表示该参数不生效。
当取值为正整数N时,表示刷新周期为30*N分钟。 | 数值 | 可缺省,缺省值为0。 | | formConfigAbility | 标识用于调整卡片的设施或活动的名称。 | 字符串 | 可缺省,缺省值为空。 | | formVisibleNotify | 标识是否允许卡片使用卡片可见性通知 | 字符串 | 可缺省,缺省值为空。 | | jsComponentName | 标识JS卡片的Component名称。字符串最大长度为127字节。仅当卡片类型为JS卡片时,需要配置该标签。 | 字符串 | 不可缺省。 | | metaData | 标识卡片的自定义信息,包含customizeData数组标签。参考表11。 | 对象 | 可缺省,缺省值为空。 | -| customizeData | 标识自定义的卡片信息。参考表27。 | 对象数组 | 可缺省,缺省值为空。 | +| customizeData | 标识自定义的卡片信息。参考表14。 | 对象数组 | 可缺省,缺省值为空。 | -表27 customizeData对象内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | --------------------------------------------------- | -------- | -------------------- | -| name | 标识数据项的键名称。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省值为空。 | -| value | 标识数据项的值。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省值为空。 | -| extra | 标识当前custom数据的格式,取值为表示extra的资源值。 | 字符串 | 可缺省,缺省值为空。 | forms示例: ```json -"forms": [ - { - "name": "Form_Js", - "description": "It's Js Form", - "type": "JS", - "jsComponentName": "card", - "colorMode": "auto", - "isDefault": true, - "updateEnabled": true, - "scheduledUpdateTime": "11:00", - "updateDuration": 1, - "defaultDimension": "2*2", - "supportDimensions": [ - "2*2", - "2*4", - "4*4" - ] - }, - { - "name": "Form_Js", - "description": "It's JS Form", - "type": "Js", - "colorMode": "auto", - "isDefault": false, - "updateEnabled": true, - "scheduledUpdateTime": "21:05", - "updateDuration": 1, - "defaultDimension": "1*2", - "supportDimensions": [ - "1*2" - ], - "landscapeLayouts": [ - "$layout:ability_form" - ], - "portraitLayouts": [ - "$layout:ability_form" - ], - "formConfigAbility": "ability://com.example.myapplication.fa/.MainAbility", - "metaData": { - "customizeData": [ +{ + "module": { + "abilities": [ + { + "forms": [ + { + "name": "Form_Js", + "description": "It's Js Form", + "type": "JS", + "jsComponentName": "card", + "colorMode": "auto", + "isDefault": true, + "updateEnabled": true, + "scheduledUpdateTime": "11:00", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2", + "2*4", + "4*4" + ] + }, + { + "name": "Form_Js", + "description": "It's JS Form", + "type": "Js", + "colorMode": "auto", + "isDefault": false, + "updateEnabled": true, + "scheduledUpdateTime": "21:05", + "updateDuration": 1, + "defaultDimension": "1*2", + "supportDimensions": [ + "1*2" + ], + "landscapeLayouts": [ + "$layout:ability_form" + ], + "portraitLayouts": [ + "$layout:ability_form" + ], + "formConfigAbility": "ability://com.example.myapplication.fa/.MainAbility", + "metaData": { + "customizeData": [ { - "name": "originWidgetName", - "value": "com.example.weather.testWidget" + "name": "originWidgetName", + "value": "com.example.myapplication.testWidget" } - ] - } - } -] + ] + } + } + ] + } + } +} ``` -表28 distroFilter对象的内部结构说明 +表27 distroFilter对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ------------- | ------------------------------------------------------------ | -------- | -------------------- | -| apiVersion | 标识支持的apiVersion范围。参考表29。 | 对象 | 可缺省,缺省值为空。 | -| screenShape | 标识屏幕形状的支持策略。参考表30。 | 对象数组 | 可缺省,缺省值为空。 | -| screenWindow | 标识应用运行时窗口的分辨率支持策略。该字段仅支持对轻量级智能穿戴设备进行配置。参考表31。 | 对象数组 | 可缺省,缺省值为空。 | -| screenDensity | 标识屏幕的像素密度(dpi:Dots Per Inch)。参考表32。 | 对象数组 | 可缺省,缺省值为空。 | -| countryCode | 标识分发应用时的国家码。具体值参考ISO-3166-1的标准,支持多个国家和地区的枚举定义。参考表33。 | 对象数组 | 可缺省,缺省值为空。 | +| apiVersion | 标识支持的apiVersion范围。参考表28。 | 对象 | 可缺省,缺省值为空。 | +| screenShape | 标识屏幕形状的支持策略。参考表29。 | 对象数组 | 可缺省,缺省值为空。 | +| screenWindow | 标识应用运行时窗口的分辨率支持策略。该字段仅支持对轻量级智能穿戴设备进行配置。参考表30。 | 对象数组 | 可缺省,缺省值为空。 | +| screenDensity | 标识屏幕的像素密度(dpi:Dots Per Inch)。参考表31。 | 对象数组 | 可缺省,缺省值为空。 | +| countryCode | 标识分发应用时的国家码。具体值参考ISO-3166-1的标准,支持多个国家和地区的枚举定义。参考表32。 | 对象数组 | 可缺省,缺省值为空。 | -表29 apiVersion对象的内部结构说明 +表28 apiVersion对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | -------------------- | | policy | 标识该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 支持的取值为API Version存在的整数值,例如4、5、6。场景示例:某应用,针对相同设备型号,同时在网的为使用API 5和API 6开发的两个软件版本,则允许上架2个entry类型的安装包,分别支持到对应设备侧软件版本的分发。 | 数组 | 可缺省,缺省值为空。 | +| value | 支持的取值为API Version存在的整数值,例如4、5、6。场景示例:某应用,针对相同设备型号,
同时在网的为使用API 5和API 6开发的两个软件版本,则允许上架2个entry类型的安装包,分别支持到对应设备侧软件版本的分发。 | 数组 | 可缺省,缺省值为空。 | -表30 screenShape对象的内部结构说明 +表29 screenShape对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | -------------------- | | policy | 标识该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | | value | 支持的取值为circle(圆形)、rect(矩形)。场景示例:针对智能穿戴设备,可为圆形表盘和矩形表盘分别提供不同的HAP。 | 数组 | 可缺省,缺省值为空。 | -表31 screenWindow对象的内部结构说明 +表30 screenWindow对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | -------------------- | | policy | 标识该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | | value | 单个字符串的取值格式为:“宽 * 高”,取值为整数像素值,例如“454 * 454”。 | 数组 | 可缺省,缺省值为空。 | -表32 screenDensity对象的内部结构说明 +表31 screenDensity对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | -------------------- | | policy | 标识该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | | value | 取值范围如下:
sdpi:表示小规模的屏幕密度(Small-scale Dots Per Inch),适用于dpi取值为(0,120]的设备。
mdpi:表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120,160]的设备。
ldpi:表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160,240]的设备。
xldpi:表示特大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240,320]的设备。
xxldpi:表示超大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320,480]的设备。
xxxldpi:表示超特大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480,640]的设备。 | 数组 | 可缺省,缺省值为空。 | -表33 countryCode对象的内部结构说明 +表32 countryCode对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------- | ------------------------------------------------------------ | ---------- | -------------------- | | policy | 标识该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | | value | 该标签标识应用需要分发的国家码,标签为字符串数组,子串表示支持的国家或地区,由两个大写字母表示。 | 字符串数组 | 可缺省,缺省值为空。 | @@ -702,31 +754,50 @@ forms示例: distroFilter示例: ```json -"distroFilter": { - "apiVersion": { +{ + "module": { + "distroFilter": { + "apiVersion": { "policy": "include", - "value": [4,5] - }, - "screenShape": { + "value": [ + 4, + 5 + ] + }, + "screenShape": { "policy": "include", - "value": ["circle","rect"] - }, - "screenWindow": { + "value": [ + "circle", + "rect" + ] + }, + "screenWindow": { "policy": "include", - "value": ["454*454","466*466"] - }, - "screenDensity":{ - "policy": "exclude", - "value": ["ldpi","xldpi"] - }, - "countryCode": { - "policy":"include", - "value":["CN","HK"] + "value": [ + "454*454", + "466*466" + ] + }, + "screenDensity": { + "policy": "exclude", + "value": [ + "ldpi", + "xldpi" + ] + }, + "countryCode": { + "policy": "include", + "value": [ + "CN", + "HK" + ] + } } + } } ``` -表34 commonEvents对象的内部结构说明 +表33 commonEvents对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------- | ------------------------------------------------------------ | ---------- | ------------------ | @@ -739,23 +810,27 @@ distroFilter示例: commonEvents示例: ```json -"commonEvents": [ - { - "name":"MainAbility", +{ + "module": { + "commonEvents": [ + { + "name": "MainAbility", "permission": "string", - "data":[ - "string", - "string" + "data": [ + "string", + "string" ], "events": [ - "string", - "string" + "string", + "string" ] - } -] + } + ] + } +} ``` -表35 testRunner对象的内部结构说明 +表34 testRunner对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | -------------------- | -------- | ---------- | @@ -763,21 +838,25 @@ commonEvents示例: | srcPath | 标识测试框架代码路径,该标签最大长度为255字节。 | 字符串 | 不可缺省。 | ```json -"testRunner": { - "name": "myTestRunnerName", - "srcPath": "etc/test/TestRunner.ts" +{ + "module": { + "testRunner": { + "name": "myTestRunnerName", + "srcPath": "etc/test/TestRunner.ts" + } + } } ``` -表36 definePermissions对象内部结构说明 +表35 definePermissions对象内部结构说明 definePermission仅支持系统应用配置,三方应用配置不生效。 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ----------------------- | ------------------------------------------------------------ | -------- | ---------- | | name | 标识权限的名称,该标签最大长度为255字节。 | 字符串 | 不可缺省。 | -| grantMode | 标识权限的授予方式,支持如下两种授予模式:
system_grant:安装后系统自动授予该权限。
user_grant:使用时动态申请,用户授权后才可使用。 | 字符串 | 可缺省,缺省值为system_grant。 | -| availableLevel | 标识权限限制类别。可选值如下:
system_core:系统核心权限。
system_basic:系统基础权限。
normal:普通权限。所有应用允许申请的权限。 | 字符串 | 可缺省,缺省值为normal。 | +| grantMode | 标识权限的授予方式,支持如下两种授予模式:
system_grant:安装后系统自动授予该权限。
user_grant:使用时动态申请,用户授权后才可使用。 | 字符串 | 可缺省,缺省值为"system_grant"。 | +| availableLevel | 标识权限限制类别。可选值如下:
system_core:系统核心权限。
system_basic:系统基础权限。
normal:普通权限。所有应用允许申请的权限。 | 字符串 | 可缺省,缺省值为"normal"。 | | provisionEnable | 标识权限是否支持证书方式申请权限,包括高级别的权限。配置为true标识需要开发者可以通过provision方式申请权限。 | 布尔值 | 可缺省,缺省值为true。 | | distributedSceneEnabled | 标识权限是否支持分布式场景下使用该权限。 | 布尔值 | 可缺省,缺省值为false。 | | label | 标识权限的简短描述,配置为对描述内容的资源索引。 | 字符串 | 可缺省,缺省值为空。 | diff --git a/zh-cn/application-dev/quick-start/stage-structure.md b/zh-cn/application-dev/quick-start/stage-structure.md index fe72991043a1e313e677f968c8240d6b96bec2fa..d2909681f7df0cfa82ceadcbf1dc023b8aa30ac2 100755 --- a/zh-cn/application-dev/quick-start/stage-structure.md +++ b/zh-cn/application-dev/quick-start/stage-structure.md @@ -1,12 +1,12 @@ -# 应用包结构配置文件的说明 +# 应用包结构配置文件的说明(Stage模型) 在开发stage模型的应用程序时,需要在app.json5和module.json5配置文件中对应用的包结构进行声明。 ## 配置文件内部结构 -配置文件由app和module这两个部分组成,缺一不可。配置文件的内部结构参见表1。 +配置文件由app.json5和module.json5两部分组成。配置文件的内部结构参见表1。 表1 配置文件的内部结构说明 @@ -21,7 +21,7 @@ 表2 app对象的内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ------------------------------ | ------------------------------------------------------------ | -------- | ------------------------------------------- | | bundleName | 该标签标识应用的包名,用于标识应用的唯一性。标签的值命名规则 :
1)字符串以字母、数字、下划线和符号”.”组成;
2)以字母开头;
3)最小长度7字节,最大长度127个字节。
推荐采用反域名形式命名(如 :com.example.xxx,建议第一级为域名后缀com,第二级为厂商/个人名,第三级为应用名,也可以多级)。 | 字符串 | 不可缺省。 | | debug | 该标签标识应用是否可调试。该标签由IDE编译构建时产生。 | 布尔值 | 可缺省,缺省值为false。 | @@ -29,14 +29,14 @@ | label | 该标签标识应用的名称,标签值为字符串资源的索引。 | 字符串 | 不可缺省。 | | description | 该标签标识App的描述信息,标签值是是字符串类型或对描述内容的字符串资源索引。 | 字符串 | 可缺省,缺省值为空。 | | vendor | 该标签是对应用开发厂商的描述。最大长度255字节。 | 字符串 | 可缺省,缺省值为空。 | -| versionCode | 该标签标识应用的版本号,该标签值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。开发者可以将该值设置为任何正整数,但是必须确保应用的新版本都使用比旧版本更大的值。versionCode 值应小于2的31次方。 | 数值 | 不可缺省。 | +| versionCode | 该标签标识应用的版本号,该标签值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。
开发者可以将该值设置为任何正整数,但是必须确保应用的新版本都使用比旧版本更大的值。versionCode 值应小于2的31次方。 | 数值 | 不可缺省。 | | versionName | 该标签标识版本号的文字描述,用于向用户展示。
该标签仅由数字和点构成,推荐采用“A.B.C.D”四段式的形式。四段式推荐的含义如下所示。
第一段 :主版本号/Major,范围0-99,重大修改的版本,如实现新的大功能或重大变化。
第二段 :次版本号/Minor,范围0-99,表示实现较突出的特点,如新功能添加和大问题修复。
第三段 :特性版本号/Feature,范围0-99,标识规划的新版本特性。
第四段 :修订版本号/Patch,范围0-999,表示维护版本,修复bug。 | 字符串 | 不可缺省。 | | minCompatibleVersionCode | 该标签标识该app能够兼容的最低历史版本号,用于跨设备兼容性判断。 | 数值 | 可缺省。缺省值等于versionCode标签值。| | minAPIVersion | 该标签标识应用运行需要的SDK的API最小版本。 | 数值 | 可缺省,缺省值为bundle-profile.json5中的compatibleSdkVersion。| | targetAPIVersion | 该标签标识应用运行需要的API目标版本。 | 数值 | 可缺省,缺省值为bundle-profile.json5中的compileSdkVersion。| | apiReleaseType | 该标签标识应用运行需要的API目标版本的类型,采用字符串类型表示。取值为“CanaryN”、“BetaN”或者“Release”,其中,N代表大于零的整数。
Canary :受限发布的版本。
Beta :公开发布的Beta版本。
Release :公开发布的正式版本。
该字段由IDE读取当前使用的SDK的stage来生成。 | 字符串 | 可缺省,由IDE生成并覆盖。 | | distributedNotificationEnabled | 该标签标记该应用是否开启分布式通知。 | 布尔值 | 可缺省,缺省值为true。 | -| entityType | 该标签标记该应用的类别,具体有 :游戏类(game),影音类(media)、社交通信类(communication)、新闻类(news)、出行类(travel)、工具类(utility)、购物类(shopping)、教育类(education)、少儿类(kids)、商务类(business)、拍摄类(photography)。 | 字符串 | 可缺省,缺省值为"unspecified"。 | +| entityType | 该标签标记该应用的类别,具体有 :游戏类(game),影音类(media)、社交通信类(communication)、新闻类(news)、
出行类(travel)、工具类(utility)、购物类(shopping)、教育类(education)、少儿类(kids)、商务类(business)、拍摄类(photography)、未指定(unspecified)。 | 字符串 | 可缺省,缺省值为"unspecified"。 | | multiProjects | 标识当前工程是否支持多工程。 | 布尔值 | 可缺省,缺省值为false。 | | 设备类型 | 该标签可以配置多个,表示具体设备上的特殊配置信息,具体的设备类型有:"tablet"、"tv"、"wearable"、"car"、"default",可包含的字段有:minAPIVersion、distributedNotificationEnabled。 | 对象 | 可缺省,缺省值使用app下面相关的字段。 | @@ -44,26 +44,27 @@ app.json示例 : ```json { - "app": { - "bundleName": "bundleName", - "vendor": "vendorName", - "versionCode": 1, - "versionName": "1.0", - "minCompatibleVersionCode": 1, - "minAPIVersion": 7, - "targetAPIVersion": 8, - "apiReleaseType": "Release", - "debug": false, - "icon": "$media:app_icon", - "label": "$string:app_label", - "description": "$string:app_description", - "distributedNotificationEnabled": true, - "entityType": "game", - "car": { - "minAPIVersion": 8 - } + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "minCompatibleVersionCode": 9, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "apiReleaseType": "Canary1", + "debug": false, + "description": "$string:app_description", + "entityType": "game", + "car": { + "minAPIVersion": 9 } + } } + ``` ### module对象内部结构 @@ -72,7 +73,7 @@ HAP包的配置信息,该标签下的配置只对当前HAP包生效。 表3 module对象内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | | name | 该标签标识当前module的名字。module打包成HAP后,表示HAP的名称,标签值采用字符串表示(最大长度31字节),该名称在整个应用要唯一。 | 字符串 | 不可缺省。 | | type | 该标签标识当前module的类型。类型有两种,分别是entry、feature。 | 字符串 | 不可缺省。 | @@ -84,8 +85,8 @@ HAP包的配置信息,该标签下的配置只对当前HAP包生效。 | deliveryWithInstall | 该标签标识当前HAP是否在用户主动安装的时候安装,true表示主动安装时安装,false表示主动安装时不安装。 | 布尔值 | 不可缺省。 | | installationFree | 标识当前HAP是否支持免安装特性。所有Hap包都需要配置不可缺省。
true :表示支持免安装特性,且符合免安装约束。
false :表示不支持免安装特性。

当entry.hap该字段配置为true时,与该entry.hap相关的所有feature.hap该字段也需要配置为true。
当entry.hap该字段配置为false时,与该entry.hap相关的各feature.hap该字段可按业务需求配置true或false。 | 布尔值 | 不可缺省。 | | virtualMachine | 该标签用于标识当前HAP运行的目标虚拟机类型,供云端分发使用,如应用市场和分发中心。
该标签值为字符串。如果目标虚拟机类型为方舟虚拟机,则其值为"ark + 版本号"。 该标签由IDE构建HAP的时候自动插入。 | 字符串 | 该标签由IDE构建HAP的时候自动插入。 | -| uiSyntax(deprecated) | syntax定义该JS Component的语法类型。
hml标识该JS Component使用hml/css/js进行开发;
ets标识该JS Component使用ets声明式语法进行开发。 | 字符串 | 可缺省,缺省值为hml,该字段从API9开始废弃。 | -| pages | 该标签是一个profile资源,用于列举JS Component中每个页面信息。可以配置window标签定义与显示窗口相关的配置。window参考[window对象内部结构](#window对象内部结构)。 | 字符串 | 在有ability的场景下,不可缺省。 | +| uiSyntax(deprecated) | syntax定义该JS Component的语法类型。
hml标识该JS Component使用hml/css/js进行开发;
ets标识该JS Component使用ets声明式语法进行开发。 | 字符串 | 可缺省,缺省值为"hml",该字段从API9开始废弃。 | +| pages | 标识当前Module的profile资源,用于列举JS Component中每个页面信息。该标签最大长度为255个字节。 | 字符串 | 在有ability的场景下,不可缺省。 | | metadata | 该标签标识Hap的自定义元信息。参考[metadata对象内部结构](#metadata对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | | abilities | 描述元能力的配置信息,该标签下的配置只对当前ability生效。参考[abilities对象内部结构](#abilities对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | | extensionAbilities | 描述extensionAbilities的配置信息,该标签下的配置只对当前extensionAbility生效。参考[extensionAbilities对象内部结构](#extensionabilities对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | @@ -98,109 +99,107 @@ module.json5示例: ```json { - "module": { - "name": "moduleName", - "type": "entry", - "srcEntrance" : "./abilityStage.js", - "description" : "$string:description_application", - "mainElement": "MainAbility", - "pages": "$profile:pages_config", - "deviceTypes": [ - "tablet", - "tv", - "wearable", - "car" + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "metadata": [ + { + "name": "name1", + "value": "value1", + "resource": "$profile:config_file1" + }, + { + "name": "name2", + "value": "value2", + "resource": "$profile:config_file2" + } + ], + "abilities": [ + { + "name": "EntryAbility", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "description": "$string:ability_desc", + "icon": "$media:icon", + "label": "$string:ability_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "backgroundModes": [ + "dataTransfer", + "audioPlayback", + "audioRecording", + "location", + "bluetoothInteraction", + "multiDeviceConnection", + "wifiInteraction", + "voip", + "taskKeeping" ], - "deliveryWithInstall": true, - "installationFree": false, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "permissionName", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "EntryFormAbility" + ], + "when": "inuse" + } + } + ], + "extensionAbilities": [ + { + "name": "EntryFormAbility", + "srcEntrance": "./ets/entryformability/EntryFormAbility.ts", + "label": "$string:EntryFormAbility_label", + "description": "$string:EntryFormAbility_desc", + "type": "form", "metadata": [ - { - "name": "name1", - "value": "value1", - "resource": "$profile:config_file1" - }, - { - "name": "name2", - "value": "value2", - "resource": "$profile:config_file2" - } - ], - "abilities": [ - { - "name": "MainAbility", - "srcEntrance" : "./login/MyMainAbility.ts", - "description": "$string:description_main_ability", - "icon": "$media:icon", - "label": "$string:label", - "visible": true, - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ], - "uris": [] - } - ], - "backgroundModes": [ - "dataTransfer", - "audioPlayback", - "audioRecording", - "location", - "bluetoothInteraction", - "multiDeviceConnection", - "wifiInteraction", - "voip", - "taskKeeping" - ], - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:red" - }, - { - "name": "sampleAbility", - "srcEntrance" : "./login/sampleAbility.ts", - "description": "$string:description_sample_ability", - "icon": "$media:icon", - "label": "$string:label", - "visible": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:red" - } - ], - "requestPermissions": [ - { - "name": "permissionName", - "reason": "$string:reason", - "usedScene": { - "abilities": [ - "FormAbility" - ], - "when": "inuse" - } - } + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } ] - } + } + ] + } } ``` pages示例 : -1.在开发视图的resources/base/profile下面定义配置文件pages_config.json(文件名称可由开发者定义): +1.在开发视图的resources/base/profile下面定义配置文件main_pages.json(文件名称可由开发者定义): ```json { - "src": [ - "pages/index/index", - "pages/second/second", - "pages/third/third", - "pages/four/four" - ], - "window": { - "designWidth": 720, - "autoDesignWidth": false - } + "src": [ + "pages/LoginPage", + "pages/MinePage", + "pages/RegistrationSuccessPage", + "pages/PrivacyPage", + "pages/CustomerServicePage" + ] } ``` @@ -208,9 +207,9 @@ pages示例 : ```json { - "module": { - "pages": "$profile:pages_config" - } + "module": { + "pages": "$profile:main_pages" + } } ``` @@ -228,68 +227,159 @@ deviceTypes示例 : ```json { - "module": { - "deviceTypes" : [ - "wearable" - ] - } + "module": { + "deviceTypes": [ + "default", + "tablet" + ] + } } ``` -#### window对象内部结构 +#### metadata对象内部结构 -定义与显示窗口相关的配置。 +描述的module、ability、extensionAbility配置信息,标签值为数组类型,该标签下的配置只对当前module、或者ability、或者extensionAbility生效。 -表5 window对象内部结构说明 +表5 metadata对象内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | -------------------------- | -| designWidth | 定义页面设计基准宽度,根据实际设备宽度来缩放元素大小。 | 数值 | 可缺省,缺省值为750。 | -| autoDesignWidth | 定义页面设计基准宽度是否自动计算,当设置为true时,designWidth将被忽略,设计基准宽度由设备宽度与屏幕密度计算得出。 | 布尔值 | 可缺省,缺省值为false。 | +| name | 该标签标识数据项的键名称,最大长度255字节。 | 字符串 | 可缺省,缺省值为空。 | +| value | 该标签标识数据项的值,最大长度255字节。 | 字符串 | 可缺省,缺省值为空。 | +| resource | 该标签标识定义用户自定义数据格式,标签值为标识该数据的资源的索引值。 | 字符串 | 可缺省,缺省值为空。 | -window示例 : +metadata示例: ```json { - "window": { - "designWidth": 720, - "autoDesignWidth": false - } + "module": { + "metadata": [ + { + "name": "name1", + "value": "value1", + "resource": "$profile:config_file1" + }, + { + "name": "name2", + "value": "value2", + "resource": "$profile:config_file2" + } + ] + } } ``` +#### distroFilter对象内部结构 +标识应用的分发规则。 -#### metadata对象内部结构 +该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括API Version、屏幕形状、窗口分辨率、屏幕分辨率、国家码。在进行分发时,通过deviceType与这五个属性的匹配关系,唯一确定一个用于分发到设备的HAP。
+配置方式如下:
+module标签配置metadata信息。name :"ohos.module.distro"。resource :指定distroFilter信息的资源位置。 -描述的module、ability、extensionAbility配置信息,标签值为数组类型,该标签下的配置只对当前module、或者ability、或者extensionAbility生效。 +表6 distroFilter对象内部结构 -表6 metadata对象内部结构说明 +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ------------- | ------------------------------------------------------------ | -------- | -------------------------- | +| apiVersion | 标识支持的apiVersion。 | 对象 | 可缺省,缺省值为空。 | +| screenShape | 标识屏幕形状的支持策略。仅支持liteWearable设备配置。 | 对象 | 可缺省,缺省值为空。 | +| screenWindow | 标识应用运行时窗口的分辨率支持策略。仅支持liteWearable设备配置。 | 对象 | 可缺省,缺省值为空。 | +| screenDensity | 标识屏幕的像素密度(dpi : Dot Per Inch)。 | 对象 | 可缺省,缺省值为空。 | +| countryCode | 标识应用需要分发的国家地区码。具体值以ISO-3166-1标准为准。 | 对象 | 可缺省,缺省值为空。 | -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------------- | -| name | 该标签标识数据项的键名称,最大长度255字节。 | 字符串 | 可缺省,缺省值为空。 | -| value | 该标签标识数据项的值,最大长度255字节。 | 字符串 | 可缺省,缺省值为空。 | -| resource | 该标签标识定义用户自定义数据格式,标签值为标识该数据的资源的索引值。 | 字符串 | 可缺省,缺省值为空。 | +表7 apiVersion对象内部结构 + +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 标识该子属性取值的黑白名单规则。配置为"exclude"或"include"。"include"表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 支持的取值为API Version存在的整数值,例如4、5、6,最小取值为3。场景示例 :某应用,针对相同设备型号,同时在网的为使用API 5和API 6开发的两个软件版本,
则允许上架2个entry类型的安装包,分别支持到对应设备侧软件版本的分发。 | 数值数组 | 可缺省,缺省值为空。 | + +表8 screenShape对象内部结构 + +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 标识该子属性取值的黑白名单规则。配置为"exclude"或"include"。"include"表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 支持的取值为circle(圆形屏幕)、rect(矩形屏幕)。场景示例:针对智能穿戴设备,可为圆形表盘和矩形表盘分别提供不同的HAP。 | 字符串数组 | 可缺省,缺省值为空。 | + +表9 screenWindow对象内部结构 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 标识该子属性取值的黑白名单规则。配置为"include"。"include"表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 单个字符串的取值格式为 :“宽 * 高”,取值为整数像素值,例如“454 * 454”。 | 字符串数组 | 可缺省,缺省值为空。 | + +表10 screenDensity对象内部结构 -metadata示例 : +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 标识该子属性取值的黑白名单规则。配置为"exclude"或"include"。"include"表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 字符串范围如下:
sdpi :表示小规模的屏幕密度(Small-scale Dots per Inch),适用于dpi取值为(0,120]的设备。
mdpi :表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120,160]的设备。
ldpi :表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160,240]的设备。
xldpi :表示大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240,320]的设备。
xxldpi :表示大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320,480]的设备。
xxxldpi :表示大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480, 640]的设备。 | 字符串数组 | 可缺省,缺省值为空。 | + +表11 countryCode对象内部结构 + +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 标识该子属性取值的黑白名单规则。配置为"exclude"或"include"。"include"表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 支持多个国家和地区枚举定义。字符串表示所支持的国家或地区,由两个大写字母组成。 | 字符串数组 | 可缺省,缺省值为空。 | + +distroFilter示例 : + +1.在开发视图的resources/base/profile下面定义配置文件distro_filter_config.json(文件名称可由开发者定义): ```json { - "module": { - "metadata": [ - { - "name": "name1", - "value": "value1", - "resource": "$profile:config_file1" - }, - { - "name": "name2", - "value": "value2", - "resource": "$profile:config_file2" - } - ], + "distroFilter": { + "apiVersion": { + "policy": "include", + "value": [ + 4, + 5 + ] + }, + "screenShape": { + "policy": "include", + "value": [ + "circle", + "rect" + ] + }, + "screenWindow": { + "policy": "include", + "value": [ + "454*454", + "466*466" + ] + }, + "screenDensity": { + "policy": "exclude", + "value": [ + "ldpi", + "xldpi" + ] + }, + "countryCode": { + "policy": "include", + "value": [ + "CN", + "HK" + ] } + } +} +``` + +2.在module.json5的module标签下配置metadata信息: + +```json +{ + "module": { + "metadata": [ + { + "name": "ohos.module.distro", + "resource": "$profile:distro_filter_config" + } + ] + } } ``` @@ -297,80 +387,80 @@ metadata示例 : 该标签标识ability或者extension能够接收的意图的特征。 -表7 skill对象内部结构说明 +表12 skill对象内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------- | ------------------------------------------------------------ | ---------- | -------------------- | | actions | 该标签标识能够接收的意图的action值的集合,取值通常为系统预定义的action值,也允许自定义。 | 字符串数组 | 可缺省,缺省值为空。 | | entities | 该标签标识能够接收Want的元能力的类别集合,取值通常为系统预定义的类别,也允许自定义。 | 字符串数组 | 可缺省,缺省值为空。 | -| uris | 该标签标识与意图中URI(Uniform Resource Identifier)相匹配的集合。uris内部结构参考表8。 | 对象数组 | 可缺省,缺省值为空。 | +| uris | 该标签标识与意图中URI(Uniform Resource Identifier)相匹配的集合。uris内部结构参考表13。 | 对象数组 | 可缺省,缺省值为空。 | -表8 uris对象内部结构说明 +表13 uris对象内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | -------- | ------------------- | -------- | -------------------- | | scheme | 标识URI的协议名部分,常见的有http、https、file、ftp等。 | 字符串 | 当配置type时可缺省,缺省值为空。没有配置type时不可缺省。 | | host | 标识URI的主机地址部分,常见的有域名的方式,如example.com,ip地址的方式,如192.0.0.1。该字段要在scheme存在时才有意义。 | 字符串 | 可缺省,缺省值为空。 | | port | 标识URI的端口部分。如http默认端口为80,https默认端口是443,ftp默认端口是21。该字段要在scheme和host都存在时才有意义。| 字符串 | 可缺省,缺省值为空。 | -| path \| pathStartWith \| pathRegex | 标识URI的路径部分,path、pathStartWith和pathRegex配置时三选一。path标识URI与want中的路径部分全匹配,pathStartWith标识URI与want中的路径部分允许前缀匹配,pathRegex标识URI与want中的路径部分允许正则匹配。该字段要在scheme和host都存在时才有意义。| 字符串 | 可缺省,缺省值为空。 | +| path \| pathStartWith \|
pathRegex | 标识URI的路径部分,path、pathStartWith和pathRegex配置时三选一。path标识URI与want中的路径部分全匹配,
pathStartWith标识URI与want中的路径部分允许前缀匹配,pathRegex标识URI与want中的路径部分允许正则匹配。
该字段要在scheme和host都存在时才有意义。| 字符串 | 可缺省,缺省值为空。 | | type | 标识数据类型,使用MIME(Multipurpose Internet Mail Extensions)类型规范。可与scheme同时配置,也可以单独配置。| 字符串 | 可缺省,缺省值为空。 | skills示例 : ```json { - "module": { - "abilities": [ - { - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ], - "uris": [ - { - "scheme":"https", - "host":"www.example.com", - "port":"8080", - "path":"query/student/name", - "pathStartWith":"query/student", - "pathRegex":"query/.*/name", - "type": "text/*" - } - ] - } - ] - } - ], - "extensionAbilities": [ - { - "skills": [ - { - "actions": [ - "actionName" - ], - "entities": [ - "entityName" - ], - "uris": [ - { - "scheme":"https", - "host":"www.example.com", - "port":"8080", - "path":"query/student/name", - "pathStartWith":"query/student", - "pathRegex":"query/.*/name", - "type": "text/*" - } - ] - } - ] - } + "module": { + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ], + "uris": [ + { + "scheme": "https", + "host": "www.example.com", + "port": "8080", + "path": "query/student/name", + "pathStartWith": "query/student", + "pathRegex": "query/.*/name", + "type": "text/*" + } + ] + } ] - } + } + ], + "extensionAbilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ], + "uris": [ + { + "scheme": "https", + "host": "www.example.com", + "port": "8080", + "path": "query/student/name", + "pathStartWith": "query/student", + "pathRegex": "query/.*/name", + "type": "text/*" + } + ] + } + ] + } + ] + } } ``` @@ -378,21 +468,21 @@ skills示例 : abilities描述Ability组件的配置信息,标签值为数组类型。 -表9 ability对象内部结构说明 +表14 ability对象内部结构说明 -| 属性 | 含义 | 数据类型 | 是否可缺省 | +| 属性 | 含义 | 数据类型
| 是否可缺省 | | --------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | | name | 该标签标识当前Ability组件的逻辑名,该名称在整个应用要唯一,标签值采用字符串表示(最大长度127字节)。 | 字符串 | 不可缺省。 | | srcEntrance | 该标签标识Ability组件所对应的js代码路径,标签值为字符串(最大长度127字节)。 | 字符串 | 不可缺省。 | -| launchType | 该标签标识Ability组件的启动模式,可选标签值:
"standard":多实例,每次启动创建一个新的实例。
"singleton":单实例,仅第一次启动创建新实例。
"specified":运行时由开发者决定是否创建新实例。 | 字符串 | 可缺省,缺省值为"singleton" | +| launchType | 该标签标识Ability组件的启动模式,可选标签值:
"standard":多实例,每次启动创建一个新的实例。
"singleton":单实例,仅第一次启动创建新实例。
"specified":运行时由开发者决定是否创建新实例。 | 字符串 | 可缺省,缺省值为"singleton"。 | | description | 该标签标识Ability组件的描述信息,标签值是是字符串类型或对描述内容的资源索引,要求采用资源索引方式,以支持多语言。 | 字符串 | 可缺省,缺省值为空。 | | icon | 该标签标识Ability组件的图标,标签值为图标资源文件的索引。 | 字符串 | 可缺省,缺省值为空。
如果Ability组件被配置为MainElement,该标签必须配置。 | -| permissions | 该标签标识被其它应用的Ability组件调用时需要申请的权限的集合,一个数组元素为一个权限名称。通常采用反向域名格式(最大长度255字节),取值为系统预定义的权限。 | 字符串数组 | 可缺省,缺省值为空。 | +| permissions | 该标签标识被其它应用的Ability组件调用时需要申请的权限的集合,一个数组元素为一个权限名称。通常采用反向域名格式(最大长度255字节),
取值为系统预定义的权限。 | 字符串数组 | 可缺省,缺省值为空。 | | metadata | 该标签标识Ability组件的元信息。参考[metadata对象内部结构](#metadata对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | | visible | 该标签标识Ability组件是否可以被其它应用调用,true表示可以被其它应用调用, false表示不可以被其它应用调用。 | 布尔值 | 可缺省,缺省值为false。 | | continuable | 该标签标识Ability组件是否可以迁移,true表示可以被迁移, false表示不可以被迁移。 | 布尔值 | 可缺省,缺省值为false。 | -| skills | 该标签标识Ability组件能够接收的意图的特征集。
配置规则 : entry包可以配置多个具有入口能力的skills标签(配置了action.system.home和entity.system.home)的Ability组件,其中第一个配置了skills标签的Ability组件中的label和icon作为OpenHarmony服务或应用的label和icon。
OpenHarmony服务的Feature包不能配置具有入口能力的skills标签。
OpenHarmony应用的Feature包可以配置具有入口能力的skills标签。
参考[skills对象内部结构](#skills对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | -| backgroundModes | 该标签标识Ability组件的长时任务集合。指定用于满足特定类型的长时任务。
长时任务类型有如下 :
dataTransfer :通过网络/对端设备进行数据下载、备份、分享、传输等业务。
audioPlayback :音频输出业务。
audioRecording :音频输入业务。
location :定位、导航业务。
bluetoothInteraction :蓝牙扫描、连接、传输业务(穿戴)。
multiDeviceConnection :多设备互联业务。
wifiInteraction :Wifi扫描、连接、传输业务(克隆 多屏)。
voip :音视频电话,VOIP业务。
taskKeeping :计算业务。
| 字符串 | 可缺省,缺省值为空。 | +| skills | 该标签标识Ability组件能够接收的意图的特征集。
配置规则 : entry包可以配置多个具有入口能力的skills标签(配置了action.system.home和entity.system.home)的Ability组件,
其中第一个配置了skills标签的Ability组件中的label和icon作为OpenHarmony服务或应用的label和icon。
OpenHarmony服务的Feature包不能配置具有入口能力的skills标签。
OpenHarmony应用的Feature包可以配置具有入口能力的skills标签。
参考[skills对象内部结构](#skills对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | +| backgroundModes | 该标签标识Ability组件的长时任务集合。指定用于满足特定类型的长时任务。
长时任务类型有如下 :
dataTransfer :通过网络/对端设备进行数据下载、备份、分享、传输等业务。
audioPlayback :音频输出业务。
audioRecording :音频输入业务。
location :定位、导航业务。
bluetoothInteraction :蓝牙扫描、连接、传输业务(穿戴)。
multiDeviceConnection :多设备互联业务。
wifiInteraction :Wifi扫描、连接、传输业务(克隆 多屏)。
voip :音视频电话,VOIP业务。
taskKeeping :计算业务。
| 字符串数组 | 可缺省,缺省值为空。 | | startWindowIcon | 标识该Ability组件启动页面图标资源文件的索引。取值示例:$media:icon。 | 字符串 | 不可缺省。| | startWindowBackground | 标识该Ability组件启动页面背景颜色资源文件的索引。取值示例:$color:red。 | 字符串 | 不可缺省。| | removeMissionAfterTerminate | 该标签标识Ability组件销毁后是否从任务列表中移除任务。true表示销毁后移除任务, false表示销毁后不移除任务。 | 布尔值 | 可缺省,缺省值为false。| @@ -409,217 +499,177 @@ abilities示例 : ```json { - "module": { - "abilities": [ - { - "name": "MainAbility", - "srcEntrance": "./ets/login/LoginAbility.ts", - "launchType":"standard", - "description": "$string:description", - "icon": "$media:icon", - "label": "$string:label", - "permissions": [], - "metadata": [], - "visible": true, - "continuable": true, - "skills": [ - { - "actions": ["action.system.home"], - "entities": ["entity.system.home"], - "uris": [] - } - ], - "backgroundModes": [ - "dataTransfer", - "audioPlayback", - "audioRecording", - "location", - "bluetoothInteraction", - "multiDeviceConnection", - "wifiInteraction", - "voip", - "taskKeeping" - ], - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:red", - "removeMissionAfterTerminate": true, - "orientation": "landscape", - "supportWindowMode": ["fullscreen", "split", "floating"], - "maxWindowRatio": 3.5, - "minWindowRatio": 0.5, - "maxWindowWidth": 2560, - "minWindowWidth": 1400, - "maxWindowHeight": 300, - "minWindowHeight": 200 - } - ] - } + "module": { + "abilities": [ + { + "name": "EntryAbility", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "description": "$string:ability_desc", + "icon": "$media:icon", + "label": "$string:ability_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "backgroundModes": [ + "dataTransfer", + "audioPlayback", + "audioRecording", + "location", + "bluetoothInteraction", + "multiDeviceConnection", + "wifiInteraction", + "voip", + "taskKeeping" + ], + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "landscape", + "supportWindowMode": [ + "fullscreen", + "split", + "floating" + ], + "maxWindowRatio": 3.5, + "minWindowRatio": 0.5, + "maxWindowWidth": 2560, + "minWindowWidth": 1400, + "maxWindowHeight": 300, + "minWindowHeight": 200 + } + ] + } } ``` +#### shortcuts对象内部结构 -#### extensionAbilities对象内部结构 +标识应用的快捷方式信息。最多可以配置四个快捷方式。
+配置方式如下:
+ability标签配置metadata信息。name :"ohos.ability.shortcuts"。resource :指定shortcuts信息的资源位置。 -extensionAbilities描述extensionAbility的配置信息,标签值为数组类型。 +表15 shortcut对象内部结构说明 -表10 extensionAbility对象内部结构说明 +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | +| ---------- | ------------------------------------------------------------ | -------- | -------------------------- | +| shortcutId | 标识快捷方式的ID。最大长度为63字节。 | 字符串 | 不可缺省。 | +| label | 标识快捷方式的标签信息,即快捷方式对外显示的文字描述信息。取值可以是描述性内容,也可以是标识label的资源索引。字符串最大长度为63字节。 | 字符串 | 可缺省,缺省值为空。 | +| icon | 该标签标识shortcut的图标,标签值为资源文件的索引。 | 字符串 | 可缺省,缺省值为空。 | +| wants | 该标签标识快捷方式内定义的目标wants信息集合,每个want可配置两个子标签,bundleName,abilityName。
bundleName :快捷方式目标包名,字符串类型。
abilityName :快捷方式的目标组件名,字符串类型。 | 对象数组 | 可缺省,缺省值为空。 | -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ----------- | ------------------------------------------------------------ | ---------- | ----------------------------- | -| name | 该标签标识当前ExtensionAbility组件的逻辑名,标签值采用字符串表示(最大长度127字节),该名称在整个应用要唯一。 | 字符串 | 不可缺省。 | -| srcEntrance | 该标签标识ExtensionAbility组件所对应的js代码路径,标签值为字符串(最大长度127字节)。 | 字符串 | 不可缺省。 | -| description | 该标签标识ExtensionAbility组件的描述,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 可缺省,缺省值为空。 | -| icon | 该标签标识ExtensionAbility组件图标,标签值为资源文件的索引。 | 字符串 | 可缺省,缺省值为空。如果ExtensionAbility组件被配置为MainElement,不可缺省。 | -| label | 该标签标识ExtensionAbility组件对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。 | 字符串 | 可缺省,缺省值为空。如果ExtensionAbility组件被配置为MainElement,该标签必须配置,且应用内唯一。 | -| type | 该标签标识ExtensionAbility组件的类型,取值为form、workScheduler、inputMethod、service、accessibility、dataShare、fileShare、staticSubscriber、wallpaper、backup、window、enterpriseAdmin、thumbnail、preview其中之一。 | 字符串 | 不可缺省。 | -| permissions | 该标签标识被其它应用的ability调用时需要申请的权限的集合,字符串数组类型,每个数组元素为一个权限名称,通常采用反向域名方式表示(最大长度255字节),取值为系统预定义权限或者应用自定义权限,如果是后者,需与defPermissions标签中定义的某个权限的name标签值一致。 | 字符串数组 | 可缺省,缺省值为空。 | -| uri | 该标签标识ability提供的数据URI,为字符数组类型(最大长度255字节),用反向域名的格式表示。 | 字符串 | 可缺省,缺省值为空。该标签在type为dataShare类型的ExtensionAbility组件时,不可缺省。 | -| skills | 该标签标识ability能够接收的意图的特征集,为数组格式。
配置规则 : entry包可以配置多个具有入口能力的skills标签(配置了action.system.home和entity.system.home)的ability,其中第一个配置了skills标签的ability中的label和icon作为OpenHarmony服务或应用的label和icon。
OpenHarmony服务的Feature包不能配置具有入口能力的skills标签。
OpenHarmony应用的Feature包可以配置具有入口能力的skills标签。
参考[skills对象内部结构](#skills对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | -| metadata | 该标签标识ExtensionAbility组件的元信息。参考[metadata对象内部结构](#metadata对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | -| visible | 该标签标识ExtensionAbility组件是否可以被其它应用调用。true表示可以被其它应用调用, false表示不可以被其它应用调用。 | 布尔值 | 可缺省,缺省值为false。 | -| readPermission | 该标签标识读取ExtensionAbility组件的数据所需的权限。最大长度255字节。type为dataShare类型的ExtensionAbility组件支持该配置。该标签只对系统应用生效。 | 字符串 | 可缺省,缺省值为空。 | -| writePermission | 该标签标识向ExtensionAbility组件写数据所需的权限。最大长度255字节。type为dataShare类型的ExtensionAbility组件支持该配置。该标签只对系统应用生效。 | 字符串 | 可缺省,缺省值为空。 | +shortcuts示例 : -extensionAbilities示例 : +1.在开发视图的resources/base/profile下面定义配置文件shortcuts_config.json(文件名称可由开发者定义): ```json { - "module": { - "extensionAbilities": [ - { - "name": "extensionName", - "srcEntrance": "./extension/FormExtension.ts", - "icon": "$media:icon", - "label" : "$string:label", - "description": "$string:description", - "type": "form", - "permissions": ["permissionName"], - "readPermission": "", - "writePermission": "", - "visible": true, - "uri":"scheme://authority/path/query" - "skills": [ - { - "actions": [], - "entities": [], - "uris": [] - } - ], - "metadata": [ - { - "name": "ohos.extability.form", - "resource": "$profile:form_config", - } - ] - } - ] + "shortcuts": [ + { + "shortcutId": "shortcut_id", + "label": "$string:label", + "icon": "$media:icon", + "wants": [ + { + "bundleName": "com.example.myapplication", + "abilityName": "abilityName" + } + ] } + ] } - ``` -#### definePermissions对象内部结构 - -该标签标识HAP定义的权限。该标签只支持系统应用配置。 - -表11 definePermission对象内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ---------------------- | ------------------------------------------------------------ | -------- | ------------------------------ | -| name | 标识权限的名称。 | 字符串 | 不可缺省。 | -| grantMode | 标识权限的授予方式,授予模式如下:
system_grant:安装后系统自动授予该权限。
user_grant:应用动态申请,用户授权后才可使用 | 字符串 | 可缺省,缺省值为"system_grant"。 | -| availableLevel | 标识权限限制门限,可选值为system_core、system_basic、normal。
system_core:系统核心权限。
system_basic:系统基础权限。
normal:普通权限。所有应用允许申请的权限。 | 字符串 | 可缺省,缺省值为"normal"。 | -| provisionEnable | 标识权限是否支持证书方式申请权限,包括高级别的权限,true标识需要开发者可以通过provision证书acls方式申请权限。 | 布尔值 | 可缺省,缺省值为true。 | -| distributedSceneEnable | 标识权限是否支持分布式场景下使用该权限。 | 布尔值 | 可缺省,缺省值为false。 | -| label | 标识权限的简短描述,配置为对描述内容的资源索引。 | 字符串 | 可缺省,缺省值为空。 | -| description | 标识权限的详细描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引。 | 字符串 | 可缺省,缺省值为空。 | - -definePermissions示例 : +2.在module.json5的abilities标签下配置metadata信息: ```json { - "module": { - "definePermissions": [ - { - "name": "permissionName", - "grantMode": "user_grant", - "availableLevel": "system_basic", - "provisionEnable": false, - "distributedSceneEnable": true, - "label" : "$string:label", - "description": "$string:description" - } - ] - } -} - -``` - -#### requestPermissions对象内部结构 - -该标签标识应用运行时需向系统申请的权限集合。 - -表12 requestPermission对象内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------| ------| -------- | ------------------------------ | -| name | 需要申请的权限名称。| 字符串 | 不可缺省。 | -| reason | 申请权限的原因。配置为描述内容的资源索引,以支持多语言。 | 字符串 | 可缺省,缺省值为空。当申请权限的grantMode为user_grant时不可缺省。 | -| usedScene | 权限使用的场景和时机。参考[usedScene对象内部结构](#usedscene对象内部结构)。| 对象 | 可缺省,缺省值为空。当申请权限的grantMode为user_grant时不可缺省。 | - -requestPermissions示例 : - -```json -{ - "module": { - "requestPermissions": [ - { - "name": "permissionName", - "reason": "$string:reason", - "usedScene": { - "abilities": [ - "AudioAbility", - "VideoAbility" - ], - "when": "inuse" - } - } + "module": { + "abilities": [ + { + "name": "EntryAbility", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "metadata": [ + { + "name": "ohos.ability.shortcuts", + "resource": "$profile:shortcuts_config" + } ] - } + } + ] + } } ``` -权限访问的更多说明,可参考[访问控制开发指导](../security/accesstoken-guidelines.md) - -#### usedScene对象内部结构 +#### extensionAbilities对象内部结构 -该标签标识权限使用的场景和时机。 +extensionAbilities描述extensionAbility的配置信息,标签值为数组类型。 -表13 usedScene对象内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------- | --------------------| -------- | ------ | -| abilities | 标识需要使用到该权限的ability。| 字符串数组 | 不可缺省。 | -| when | 标识使用该权限的时机,可选值为inuse和always。inuse表示仅前台使用,always表示前后台都可使用 | 字符串 | 可缺省,缺省值为空。 | +表16 extensionAbility对象内部结构说明 +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | +| ----------- | ------------------------------------------------------------ | ---------- | ----------------------------- | +| name | 该标签标识当前ExtensionAbility组件的逻辑名,标签值采用字符串表示(最大长度127字节),该名称在整个应用要唯一。 | 字符串 | 不可缺省。 | +| srcEntrance | 该标签标识ExtensionAbility组件所对应的js代码路径,标签值为字符串(最大长度127字节)。 | 字符串 | 不可缺省。 | +| description | 该标签标识ExtensionAbility组件的描述,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 可缺省,缺省值为空。 | +| icon | 该标签标识ExtensionAbility组件图标,标签值为资源文件的索引。 | 字符串 | 可缺省,缺省值为空。如果ExtensionAbility组件被配置为MainElement,不可缺省。 | +| label | 该标签标识ExtensionAbility组件对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。 | 字符串 | 可缺省,缺省值为空。如果ExtensionAbility组件被配置为MainElement,该标签必须配置,且应用内唯一。 | +| type | 该标签标识ExtensionAbility组件的类型,取值为form、workScheduler、inputMethod、service、accessibility、dataShare、fileShare、staticSubscriber、wallpaper、backup、window、enterpriseAdmin、thumbnail、preview其中之一。 | 字符串 | 不可缺省。 | +| permissions | 该标签标识被其它应用的ability调用时需要申请的权限的集合,字符串数组类型,每个数组元素为一个权限名称,通常采用反向域名方式表示(最大长度255字节),取值为系统预定义权限或者应用自定义权限,如果是后者,需与defPermissions标签中定义的某个权限的name标签值一致。 | 字符串数组 | 可缺省,缺省值为空。 | +| uri | 该标签标识ability提供的数据URI,为字符数组类型(最大长度255字节),用反向域名的格式表示。 | 字符串 | 可缺省,缺省值为空。该标签在type为dataShare类型的ExtensionAbility组件时,不可缺省。 | +| skills | 该标签标识ability能够接收的意图的特征集,为数组格式。
配置规则 : entry包可以配置多个具有入口能力的skills标签(配置了action.system.home和entity.system.home)的ability,其中第一个配置了skills标签的ability中的label和icon作为OpenHarmony服务或应用的label和icon。
OpenHarmony服务的Feature包不能配置具有入口能力的skills标签。
OpenHarmony应用的Feature包可以配置具有入口能力的skills标签。
参考[skills对象内部结构](#skills对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | +| metadata | 该标签标识ExtensionAbility组件的元信息。参考[metadata对象内部结构](#metadata对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | +| visible | 该标签标识ExtensionAbility组件是否可以被其它应用调用。true表示可以被其它应用调用, false表示不可以被其它应用调用。 | 布尔值 | 可缺省,缺省值为false。 | +| readPermission | 该标签标识读取ExtensionAbility组件的数据所需的权限。最大长度255字节。type为dataShare类型的ExtensionAbility组件支持该配置。该标签只对系统应用生效。 | 字符串 | 可缺省,缺省值为空。 | +| writePermission | 该标签标识向ExtensionAbility组件写数据所需的权限。最大长度255字节。type为dataShare类型的ExtensionAbility组件支持该配置。该标签只对系统应用生效。 | 字符串 | 可缺省,缺省值为空。 | -usedScene示例 : +extensionAbilities示例 : ```json { - "module": { - "requestPermissions": [ - { - "usedScene": { - "abilities": [ - "AudioAbility", - "VideoAbility" - ], - "when": "inuse" - } - } + "module": { + "extensionAbilities": [ + { + "name": "EntryFormAbility", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "srcEntrance": "./ets/entryformability/EntryFormAbility.ts", + "label": "$string:EntryFormAbility_label", + "description": "$string:EntryFormAbility_desc", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } ] - } + } + ] + } } ``` @@ -627,11 +677,11 @@ usedScene示例 : forms标签标识卡片的配置,form卡片是可以嵌入桌面上并接收定期更新的应用简要视图。
配置方式如下:
-extensionAbility标签配置type为form,并配置metadata信息:name :"ohos.extability.form"。resource :指定form信息的资源位置。 +extensionAbility标签配置type为form,并配置metadata信息:name :"ohos.extension.form"。resource :指定form信息的资源位置。 -表14 form对象内部结构说明 +表17 form对象内部结构说明 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | | ------------------- | ------------------------------------------------------------ | ---------- | ----------------------------- | | name | 标识卡片的名称。最大长度为127字节。 | 字符串 | 不可缺省。 | | description | 标识卡片的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。最大长度为255字节。 | 字符串 | 可缺省,缺省值为空。 | @@ -645,7 +695,7 @@ extensionAbility标签配置type为form,并配置metadata信息:name :"ohos. | scheduledUpdateTime | 该标签标识卡片定点刷新的时间,采用24小时计数,精确到分钟。 | 字符串 | 可缺省,缺省值为空。 | | updateDuration | 该标签标识卡片定时刷新的更新频率,单位为30分钟,取值为30的倍数。卡片的最高频率为每30分钟刷新一次,和定点刷新二选一,二者都配置的情况下,定时优先。 | 数值 | 可缺省,缺省值为空。 | | metadata | 该标签标识卡片的元信息。参考[metadata对象内部结构](#metadata对象内部结构)。 | 对象数组 | 可缺省,缺省值为空。 | -| formConfigAbility | 该标签标识卡片调整的Ability名称。最大长度127字节。该标签值必须满足下面的格式 :
ability://单个ability名字
单个ability名字必须为本应用的ability。 | 字符串 | 可缺省,缺省值为空。 | +| formConfigAbility | 该标签标识卡片调整的Ability名称。最大长度127字节。该标签值必须满足下面的格式 :
ability://单个ability名字。
单个ability名字必须为本应用的ability。 | 字符串 | 可缺省,缺省值为空。 | | formVisibleNotify | 该标签标识卡片是否被允许使用卡片可见性通知。 | 布尔值 | 可缺省,缺省值为false。 | form示例 : @@ -654,120 +704,72 @@ form示例 : ```json { - "forms": [ - { - "name": "Form_Js", - "description": "$string:description", - "src": "./js/pages/card/index", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "colorMode": "auto", - "formConfigAbility": "ability://xxx", - "formVisibleNotify": false, - "isDefault": true, - "updateEnabled": true, - "scheduledUpdateTime": "10:30", - "updateDuration": 1, - "defaultDimension": "2*2", - "updateEnabled": true, - "supportDimensions": [ - "2*2" - ], - "metadata": [ - { - "name": "name", - "value": "value", - "resource": "$profile:resource" - } - ] - } - ] + "forms": [ + { + "name": "widget", + "description": "This is a service widget.", + "src": "./js/widget/pages/index/index", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ] + } + ] } ``` -2.在module.json5的extensionAbilities标签下定义metadata信息 : +2.在module.json5的extensionAbilities标签下配置metadata信息: ```json { - "module": { - "extensionAbilities": [ - { - "type": "form", - "metadata": [ - { - "name": "ohos.extability.form", - "resource": "$profile:form_config" - } - ] - } + "module": { + "extensionAbilities": [ + { + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } ] - } + } + ] + } } ``` -#### shortcuts对象内部结构 - -标识应用的快捷方式信息。最多可以配置四个快捷方式。
-配置方式如下:
-ability标签配置metadata信息。name :"ohos.ability.shortcuts"。resource :指定shortcuts信息的资源位置。 - -表15 shortcut对象内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ---------- | ------------------------------------------------------------ | -------- | -------------------------- | -| shortcutId | 标识快捷方式的ID。最大长度为63字节。 | 字符串 | 不可缺省。 | -| label | 标识快捷方式的标签信息,即快捷方式对外显示的文字描述信息。取值可以是描述性内容,也可以是标识label的资源索引。字符串最大长度为63字节。 | 字符串 | 可缺省,缺省值为空。 | -| icon | 该标签标识shortcut的图标,标签值为资源文件的索引。 | 字符串 | 可缺省,缺省值为空。 | -| wants | 该标签标识快捷方式内定义的目标wants信息集合,每个want可配置两个子标签,bundleName,abilityName。
bundleName :快捷方式目标包名,字符串类型。
abilityName :快捷方式的目标组件名,字符串类型。 | 对象数组 | 可缺省,缺省值为空。 | +#### window对象内部结构 -shortcuts示例 : +定义与显示窗口相关的配置。 -1.在开发视图的resources/base/profile下面定义配置文件shortcuts_config.json(文件名称可由开发者定义): +表18 window对象内部结构说明 -```json -{ - "shortcuts": [ - { - "shortcutId": "shortcut_id", - "label": "$string:label", - "icon": "$media:icon", - "wants": [ - { - "bundleName": "bundleName", - "abilityName": "abilityName" - } - ] - } - ] -} -``` +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------------- | +| designWidth | 定义页面设计基准宽度,根据实际设备宽度来缩放元素大小。 | 数值 | 可缺省,缺省值为750。 | +| autoDesignWidth | 定义页面设计基准宽度是否自动计算,当设置为true时,designWidth将被忽略,设计基准宽度由设备宽度与屏幕密度计算得出。 | 布尔值 | 可缺省,缺省值为false。 | -2.在module.json5的abilities标签下定义metadata信息 : +window示例 : ```json { - "module": { - "abilities": [ - { - "name": "MainAbility", - "srcEntrance": "./abilities/MainAbility.ts", - "skills": [ - { - "actions": ["action.system.home"], - "entities": ["entity.system.home"] - } - ], - "metadata": [ - { - "name": "ohos.ability.shortcuts", - "resource": "$profile:shortcuts_config" - } - ] - } - ] + "forms": [ + { + "window": { + "designWidth": 720, + "autoDesignWidth": true + } } + ] } ``` @@ -777,12 +779,12 @@ commonEvents标签标识注册静态公共事件信息。
配置方式如下:
extensionAbility标签配置type为staticSubscriber,并配置metadata信息:name :"ohos.extability.staticSubscriber"。resource :指定commonEvents信息的资源位置。 -表16 commonEvent对象内部结构 +表19 commonEvent对象内部结构 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------- | ------------------------------------------------------------ | ---------- | -------------------------- | | name | 该标签指明当前静态公共事件对应的ability名,该类需要在ability中标明。 | 字符串 | 不可缺省。 | -| permission | 该标签标识实现该静态公共事件需要申请的权限,以字符串类型表示一个权限名称,通常采用反向域名方式表示(最大255字节)。 | 字符串 | 可缺省,缺省值为空。 | +| permission | 该标签标识实现该静态公共事件需要申请的权限,以字符串类型表示一个权限名称,通常采用反向域名方式表示(最大长度255字节)。 | 字符串 | 可缺省,缺省值为空。 | | types | 该标签配置当前静态公共事件的类别数组,字符串数组类型,每个数组元素为一个类别名称。 | 字符串数组 | 可缺省,缺省值为空。 | | events | 该标签标识能够接收的意图的event值的集合,取值通常为系统预定义的event值,也允许自定义。 | 字符串数组 | 不可缺省。 | @@ -809,124 +811,127 @@ commonEvents示例 : } ``` -2.在module.json5的extensionAbilities标签下定义metadata信息 : +2.在module.json5的extensionAbilities标签下配置metadata信息: ```json { - "module": { - "extensionAbilities": [ - { - "name": "subscriber", - "srcEntrance": "./extension/subscriber.js", - "type": "staticSubscriber", - "metadata": [ - { - "name": "ohos.extability.staticSubscriber", - "resource": "$profile:common_event_config" - } - ] - } + "module": { + "extensionAbilities": [ + { + "name": "subscriber", + "srcEntrance": "./ets/subscriber/Subscriber.ts", + "type": "staticSubscriber", + "metadata": [ + { + "name": "ohos.extability.staticSubscriber", + "resource": "$profile:common_event_config" + } ] - } + } + ] + } } ``` -#### distroFilter对象内部结构 +#### definePermissions对象内部结构 -标识应用的分发规则。 +该标签标识HAP定义的权限。该标签只支持系统应用配置。 -该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括API Version、屏幕形状、窗口分辨率、屏幕分辨率、国家码。在进行分发时,通过deviceType与这五个属性的匹配关系,唯一确定一个用于分发到设备的HAP。
-配置方式如下:
-module标签配置metadata信息。name :"ohos.module.distro"。resource :指定distroFilter信息的资源位置。 +表20 definePermission对象内部结构说明 -表17 distroFilter对象内部结构 +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | +| ---------------------- | ------------------------------------------------------------ | -------- | ------------------------------ | +| name | 标识权限的名称。 | 字符串 | 不可缺省。 | +| grantMode | 标识权限的授予方式,授予模式如下:
system_grant:安装后系统自动授予该权限。
user_grant:应用动态申请,用户授权后才可使用。 | 字符串 | 可缺省,缺省值为"system_grant"。 | +| availableLevel | 标识权限限制门限,可选值为system_core、system_basic、normal。
system_core:系统核心权限。
system_basic:系统基础权限。
normal:普通权限。所有应用允许申请的权限。 | 字符串 | 可缺省,缺省值为"normal"。 | +| provisionEnable | 标识权限是否支持证书方式申请权限,包括高级别的权限,true标识需要开发者可以通过provision证书acls方式申请权限。 | 布尔值 | 可缺省,缺省值为true。 | +| distributedSceneEnable | 标识权限是否支持分布式场景下使用该权限。 | 布尔值 | 可缺省,缺省值为false。 | +| label | 标识权限的简短描述,配置为对描述内容的资源索引。 | 字符串 | 可缺省,缺省值为空。 | +| description | 标识权限的详细描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引。 | 字符串 | 可缺省,缺省值为空。 | -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ------------- | ------------------------------------------------------------ | -------- | -------------------------- | -| apiVersion | 标识支持的apiVersion。 | 对象 | 可缺省,缺省值为空。 | -| screenShape | 标识屏幕形状的支持策略。仅支持liteWearable设备配置。 | 对象 | 可缺省,缺省值为空。 | -| screenWindow | 标识应用运行时窗口的分辨率支持策略。仅支持liteWearable设备配置。 | 对象 | 可缺省,缺省值为空。 | -| screenDensity | 标识屏幕的像素密度(dpi : Dot Per Inch)。 | 对象 | 可缺省,缺省值为空。 | -| countryCode | 标识应用需要分发的国家地区码。具体值以ISO-3166-1标准为准。 | 对象 | 可缺省,缺省值为空。 | +definePermissions示例 : -表18 apiVersion对象内部结构 +```json +{ + "module": { + "definePermissions": [ + { + "name": "permissionName", + "grantMode": "user_grant", + "availableLevel": "system_basic", + "provisionEnable": false, + "distributedSceneEnable": true, + "label": "$string:label", + "description": "$string:description" + } + ] + } +} +``` -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | 标识该子属性取值的黑白名单规则。配置为"exclude"或"include"。"include"表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 支持的取值为API Version存在的整数值,例如4、5、6,最小取值为3。场景示例 :某应用,针对相同设备型号,同时在网的为使用API 5和API 6开发的两个软件版本,则允许上架2个entry类型的安装包,分别支持到对应设备侧软件版本的分发。 | 数值数组 | 可缺省,缺省值为空。 | +#### requestPermissions对象内部结构 -表19 screenShape对象内部结构 +该标签标识应用运行时需向系统申请的权限集合。 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | 标识该子属性取值的黑白名单规则。配置为"exclude"或"include"。"include"表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 支持的取值为circle(圆形屏幕)、rect(矩形屏幕)。场景示例:针对智能穿戴设备,可为圆形表盘和矩形表盘分别提供不同的HAP。 | 字符串数组 | 可缺省,缺省值为空。 | +表21 requestPermission对象内部结构说明 -表20 screenWindow对象内部结构 +| 属性名称 | 含义 | 数据类型
| 是否可缺省 | +| ------| ------| -------- | ------------------------------ | +| name | 需要申请的权限名称。| 字符串 | 不可缺省。 | +| reason | 申请权限的原因。配置为描述内容的资源索引,以支持多语言。 | 字符串 | 可缺省,缺省值为空。当申请权限的grantMode为user_grant时不可缺省。 | +| usedScene | 权限使用的场景和时机。参考[usedScene对象内部结构](#usedscene对象内部结构)。| 对象 | 可缺省,缺省值为空。当申请权限的grantMode为user_grant时不可缺省。 | -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | 标识该子属性取值的黑白名单规则。配置为"include"。"include"表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 单个字符串的取值格式为 :“宽 * 高”,取值为整数像素值,例如“454 * 454”。 | 字符串数组 | 可缺省,缺省值为空。 | +requestPermissions示例 : -表21 screenDensity对象内部结构 +```json +{ + "module": { + "requestPermissions": [ + { + "name": "permissionName", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "inuse" + } + } + ] + } +} +``` -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | 标识该子属性取值的黑白名单规则。配置为"exclude"或"include"。"include"表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 字符串范围如下:
sdpi :表示小规模的屏幕密度(Small-scale Dots per Inch),适用于dpi取值为(0,120]的设备。
mdpi :表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120,160]的设备。
ldpi :表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160,240]的设备。
xldpi :表示大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240,320]的设备。
xxldpi :表示大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320,480]的设备。
xxxldpi :表示大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480, 640]的设备。 | 字符串数组 | 可缺省,缺省值为空。 | +权限访问的更多说明,可参考[访问控制开发指导](../security/accesstoken-guidelines.md) -表22 countryCode对象内部结构 +#### usedScene对象内部结构 -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| -------- | ------------------------------------------------------------ | -------- | -------------------- | -| policy | 标识该子属性取值的黑白名单规则。配置为"exclude"或"include"。"include"表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | -| value | 支持多个国家和地区枚举定义。字符串表示所支持的国家或地区,由两个大写字母组成。 | 字符串数组 | 可缺省,缺省值为空。 | +该标签标识权限使用的场景和时机。 -distroFilter示例 : +表22 usedScene对象内部结构说明 -1.在开发视图的resources/base/profile下面定义配置文件distro_filter_config.json(文件名称可由开发者定义): +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ------- | --------------------| -------- | ------ | +| abilities | 标识需要使用到该权限的ability。| 字符串数组 | 不可缺省。 | +| when | 标识使用该权限的时机,可选值为inuse和always。inuse表示仅前台使用,always表示前后台都可使用。 | 字符串 | 可缺省,缺省值为空。 | -```json -"distroFilter": [ - { - "apiVersion": { - "policy": "include", - "value": [4, 5] - }, - "screenShape": { - "policy": "include", - "value": ["circle", "rect"] - }, - "screenWindow": { - "policy": "include", - "value": ["454*454", "466*466"] - }, - "screenDensity": { - "policy": "exclude", - "value": ["ldpi", "xldpi"] - }, - "countryCode": { - "policy": "include", - "value": ["CN", "HK"] - } - } -] -``` -2.在module.json5的module标签下定义metadata信息 : +usedScene示例 : ```json { - "module":{ - "metadata": [ - { - "name": "ohos.module.distro", - "resource": "$profile:distro_filter_config" - } - ] - } + "module": { + "requestPermissions": [ + { + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "inuse" + } + } + ] + } } ``` @@ -943,10 +948,14 @@ distroFilter示例 : testRunner示例 : -``` -"testRunner": { - "name": "testRunnerName", - "srcPath": "etc/test/TestRunner.ts" +```json +{ + "module": { + "testRunner": { + "name": "testRunnerName", + "srcPath": "ets/test/TestRunner.ts" + } + } } ``` diff --git a/zh-cn/application-dev/quick-start/syscap.md b/zh-cn/application-dev/quick-start/syscap.md index 4525ff3cd6cc8d75534bdf9ccbb4959efcc16502..fc98c0e05570f40281523fb766a525b070c47e49 100644 --- a/zh-cn/application-dev/quick-start/syscap.md +++ b/zh-cn/application-dev/quick-start/syscap.md @@ -1,66 +1,54 @@ -# SysCap使用指南 +# 系统能力SystemCapability使用指南 ## 概述 ### 系统能力与 API -SysCap,全称SystemCapability,即系统能力,指操作系统中每一个相对独立的特性,如蓝牙,WIFI,NFC,摄像头等,都是系统能力之一。每个系统能力对应多个 API,这些 API 绑定在一起,随着目标设备是否支持该系统能力共同存在或消失,也会随着 IDE 一起提供给开发者做联想。 +SysCap,全称SystemCapability,即系统能力,指操作系统中每一个相对独立的特性,如蓝牙,WIFI,NFC,摄像头等,都是系统能力之一。每个系统能力对应多个API,随着目标设备是否支持该系统能力共同存在或消失,也会随着DevEco Studio一起提供给开发者做联想。 ![image-20220326064841782](figures/image-20220326064841782.png) 开发者可以在[SysCap列表](../reference/syscap-list.md)中查询OpenHarmony的能力集。 - - ### 支持能力集,联想能力集与要求能力集 支持能力集,联想能力集与要求能力集都是系统能力的集合。 支持能力集描述的是设备能力,要求能力集描述的是应用能力。若应用A的要求能力集是设备N的支持能力集的子集,则应用A可分发到设备N上安装运行,否则不能分发。 -联想能力集是该应用开发时,IDE 可联想的 API 所在的系统能力集合。 +联想能力集是该应用开发时,DevEco Studio可联想的API所在的系统能力集合。 ![image-20220326064913834](figures/image-20220326064913834.png) - - ### 设备与支持能力集 每个设备根据其硬件能力,对应不同的支持能力集。 -SDK 将设备分为两组,典型设备和自定义设备,典型设备的支持能力集由 OpenHarmony 来定义,自定义设备由设备厂商给出。 +SDK将设备分为两组,典型设备和自定义设备,典型设备的支持能力集由OpenHarmony来定义,自定义设备由设备厂商给出。 ![image-20220326064955505](figures/image-20220326064955505.png) - - ### 设备与SDK能力的对应 -SDK 提供全量的 API 给 IDE,IDE 通过开发者的项目支持的设备,找到该设备的支持能力集,筛选支持能力集包含的 API 提供给开发者做联想。 +SDK向DevEco Studio提供全量API,DevEco Studio识别开发者项目中选择的设备形态,找到该设备的支持能力集,筛选支持能力集包含的API并提供API联想。 ![image-20220326065043006](figures/image-20220326065043006.png) - - ## SysCap开发指导 ### PCID获取 -PCID,全称 Product Compatibility ID,包含当前设备支持的 syscap 信息。获取所有设备 PCID 的认证中心正在建设中,目前需要找对应设备的厂商获取该设备的 PCID。 - - +PCID,全称Product Compatibility ID,包含当前设备支持的SysCap信息。获取所有设备PCID的认证中心正在建设中,目前需要找对应设备的厂商获取该设备的PCID。 ### PCID导入 -DevEco Studio 工程支持 PCID 的导入。导入的 PCID 文件解码后输出的 syscap 会被写入 syscap.json 文件中。 +DevEco Studio工程支持PCID的导入。导入的PCID文件解码后输出的SysCap会被写入syscap.json文件中。 -在工程目录右键后选择 Import Product Compatibility ID,即可上传 PCID 文件并导入至 syscap.json 中。 +在工程目录右键后选择Import Product Compatibility ID,即可上传PCID文件并导入至syscap.json中。 ![20220329-103626](figures/20220329-103626.gif) - - ### 配置联想能力集和要求能力集 -IDE 会根据创建的工程所支持的设置自动配置联想能力集和要求能力集,开发者也可以自行修改。 -对于联想能力集,开发者通过添加更多的系统能力,在 IDE 中可以使用更多的 API,但要注意这些 API 可能在设备上不支持,使用前需要判断。 +DevEco Studio会根据创建的工程所支持的设置自动配置联想能力集和要求能力集,开发者也可以自行修改。 +对于联想能力集,开发者通过添加更多的系统能力,在DevEco Studio中可以使用更多的API,但要注意这些API可能在设备上不支持,使用前需要判断。 对于要求能力集,开发者修改时要十分慎重,修改不当会导致应用无法分发到目标设备上。 ```json @@ -91,51 +79,44 @@ IDE 会根据创建的工程所支持的设置自动配置联想能力集和要 } ``` - - ### 单设备应用开发 默认应用的联想能力集,要求系统能力集和设备的支持系统能力集相等,开发者修改要求能力集需要慎重。 ![image-20220326065124911](figures/image-20220326065124911.png) - - ### 跨设备应用开发 默认应用的联想能力集是多个设备支持能力集的并集,要求能力集则是交集。 ![image-20220326065201867](figures/image-20220326065201867.png) - - ### 判断 API 是否可以使用 -首先我们定义了 API canIUse 帮助开发者来判断该工程是否支持某个特定的syscap。 +- 方法1:OpenHarmony定义了API canIUse帮助开发者来判断该工程是否支持某个特定的syscap。 -``` -if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) { - console.log("该应用支持SystemCapability.ArkUI.ArkUI.Full"); -} else { - console.log("该应用不支持SystemCapability.ArkUI.ArkUI.Full"); -} -``` - -开发者可通过 import 的方式将模块导入,若当前设备不支持该模块,import 的结果为 undefined,开发者在使用其 API 时,需要判断其是否存在。 + ``` + if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) { + console.log("该应用支持SystemCapability.ArkUI.ArkUI.Full"); + } else { + console.log("该应用不支持SystemCapability.ArkUI.ArkUI.Full"); + } + ``` -``` -import geolocation from '@ohos.geolocation'; - -if (geolocation) { - geolocation.getCurrentLocation((location) => { - console.log(location.latitude, location.longitude); - }); -} else { - console.log('该设备不支持位置信息'); -} -``` +- 方法2:开发者可通过 import 的方式将模块导入,若当前设备不支持该模块,import 的结果为 undefined,开发者在使用其 API 时,需要判断其是否存在。 + ``` + import geolocation from '@ohos.geolocation'; + if (geolocation) { + geolocation.getCurrentLocation((location) => { + console.log(location.latitude, location.longitude); + }); + } else { + console.log('该设备不支持位置信息'); + } + ``` +除此之外,开发者可以通过API参考文档查询API接口所属的SysCap。 ### 不同设备相同能力的差异检查 @@ -159,7 +140,6 @@ authenticator.execute('FACE_ONLY', 'S1', (err, result) => { }) ``` - ### 设备间的SysCap差异如何产生的 设备的SysCap因产品解决方案厂商拼装的部件组合不同而不同,整体流程如下图: diff --git a/zh-cn/application-dev/reference/Readme-CN.md b/zh-cn/application-dev/reference/Readme-CN.md index 8f418c7d5b60e0926e4dd14e7480a7c44827ab7b..502f38196f237fc4c916082c288d176807e2d822 100644 --- a/zh-cn/application-dev/reference/Readme-CN.md +++ b/zh-cn/application-dev/reference/Readme-CN.md @@ -1,9 +1,11 @@ # 开发参考 + - [Syscap列表](syscap-list.md) - [组件参考(基于ArkTS的声明式开发范式)](arkui-ts/Readme-CN.md) - [组件参考(兼容JS的类Web开发范式)](arkui-js/Readme-CN.md) - [JS服务卡片UI组件参考](js-service-widget-ui/Readme-CN.md) - [接口参考(JS及TS API)](apis/Readme-CN.md) +- [错误码参考](errorcodes/Readme-CN.md) - 接口参考(Native API) - [OpenHarmony Native API](native-apis/Readme-CN.md) - [Native API标准库](native-lib/Readme-CN.md) diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 575c006baa4a6393ab491448679656177a6435e0..f312bde9d48259e6ad7209bd995a1ce2d2c0b0d7 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -1,4 +1,4 @@ -# 接口 +# 接口 - [开发说明](development-intro.md) @@ -36,6 +36,7 @@ - [@ohos.ability.dataUriUtils (DataUriUtils模块)](js-apis-DataUriUtils.md) - [@ohos.ability.errorCode (ErrorCode)](js-apis-ability-errorCode.md) - [@ohos.ability.wantConstant (wantConstant)](js-apis-ability-wantConstant.md) + - [@ohos.app.ability.appRecovery (appRecovery)](js-apis-app-ability-appRecovery.md) - [@ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](js-apis-abilityDelegatorRegistry.md) - [@ohos.application.abilityManager (AbilityManager)](js-apis-application-abilityManager.md) - [@ohos.application.appManager (appManager)](js-apis-appmanager.md) @@ -182,7 +183,6 @@ - [@ohos.net.http (数据请求)](js-apis-http.md) - [@ohos.net.sharing (网络共享管理)](js-apis-net-sharing.md) - [@ohos.net.socket (Socket连接)](js-apis-socket.md) - - [@ohos.net.tlsSocket (TLSSocket连接)](js-apis-tlsSocket.md) - [@ohos.net.webSocket (WebSocket连接)](js-apis-webSocket.md) - [@ohos.request (上传下载)](js-apis-request.md) @@ -249,6 +249,8 @@ - [@ohos.runningLock (Runninglock锁)](js-apis-runninglock.md) - [@ohos.sensor (传感器)](js-apis-sensor.md) - [@ohos.settings (设置数据项名称)](js-apis-settings.md) + - [@ohos.stationary (设备状态感知框架)](js-apis-stationary.md) + - [@ohos.systemCapability (系统能力)](js-apis-system-capability.md) - [@ohos.systemParameterV9 (系统属性)](js-apis-system-parameterV9.md) - [@ohos.thermal (热管理)](js-apis-thermal.md) - [@ohos.update (升级)](js-apis-update.md) @@ -261,7 +263,7 @@ - [@ohos.account.osAccount (系统帐号管理)](js-apis-osAccount.md) - 定制管理 - - [@ohos.configPolicy (配置策略)](js-apis-config-policy.md) + - [@ohos.configPolicy (配置策略)](js-apis-configPolicy.md) - [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.enterprise.adminManager (企业设备管理)](js-apis-enterprise-adminManager.md) - [@ohos.enterprise.dateTimeManager(系统时间管理)](js-apis-enterprise-dateTimeManager.md) @@ -311,6 +313,7 @@ - [@ohos.reminderAgent (后台代理提醒)](js-apis-reminderAgent.md) - [@ohos.systemParameter (系统属性)](js-apis-system-parameter.md) - [@ohos.usb (USB管理)](js-apis-usb-deprecated.md) + - [@ohos.workScheduler (延迟任务调度)](js-apis-workScheduler.md) - [@system.app (应用上下文)](js-apis-system-app.md) - [@system.battery (电量信息)](js-apis-system-battery.md) - [@system.bluetooth (蓝牙)](js-apis-system-bluetooth.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md index 472be9b1a763cf47d800450115c693648ce23971..23fee9213ef0bd10075ad52e8ef943062029c1ee 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md @@ -46,7 +46,7 @@ SystemCapability.BundleManager.DistributedBundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 获得的ElementName信息。 | | callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | 是 | 程序启动作为入参的回调函数,返回远程基本能力信息。 | @@ -75,7 +75,7 @@ SystemCapability.BundleManager.DistributedBundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | -------------------------------------------- | ---- | ----------------------- | | elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 获得的ElementName信息。 | @@ -107,10 +107,10 @@ SystemCapability.BundleManager.DistributedBundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | 是 | ElementName信息,最大数组长度为10 | -| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | 是 | 程序启动作为入参的回调函数,返回远程基本能力信息。 | +| callback | AsyncCallback> | 是 | 程序启动作为入参的回调函数,返回远程基本能力信息。 | @@ -136,7 +136,7 @@ SystemCapability.BundleManager.DistributedBundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | --------------------------------------------------- | ---- | ----------------------- | | elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | 是 | ElementName信息,最大数组长度为10。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md index 696acdc370e7d3d87a16858890399352fbbca04b..207cfec2689d0a833865827e561429bf9dd58de7 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -446,7 +446,7 @@ SystemCapability.BundleManager.BundleFramework | -------- | ------------------------------------------------------------ | ---- | ---------------- | | callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | 是 | 安装应用程序包。 | -## bundle.cleanBundleCacheFilesdeprecated +## bundle.cleanBundleCacheFiles8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles)替代。 @@ -473,7 +473,7 @@ SystemCapability.BundleManager.BundleFramework | bundleName | string | 是 | 指示要清除其缓存数据的应用程序包名称. | | callback | AsyncCallback\ | 是 | 为返回操作结果而调用的回调。 | -## bundle.cleanBundleCacheFilesdeprecated +## bundle.cleanBundleCacheFiles8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles)替代。 @@ -505,7 +505,7 @@ SystemCapability.BundleManager.BundleFramework | ------------- | ------------------------------------ | | Promise\ | 返回值为Promise对象,Promise中为空。 | -## bundle.setApplicationEnableddeprecated +## bundle.setApplicationEnabled8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled)替代。 @@ -533,7 +533,7 @@ SystemCapability.BundleManager.BundleFramework | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 | | callback | AsyncCallback\ | 是 | 为返回操作结果而调用的回调。 | -## bundle.setApplicationEnableddeprecated +## bundle.setApplicationEnabled8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled)替代。 @@ -566,7 +566,7 @@ SystemCapability.BundleManager.BundleFramework | ------------- | ------------------------------------ | | Promise\ | 返回值为Promise对象,Promise中为空。 | -## bundle.setAbilityEnableddeprecated +## bundle.setAbilityEnabled8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled)替代。 @@ -594,7 +594,7 @@ SystemCapability.BundleManager.BundleFramework | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 | | callback | AsyncCallback\ | 是 | 为返回操作结果而调用的回调。 | -## bundle.setAbilityEnableddeprecated +## bundle.setAbilityEnabled8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled)替代。 @@ -627,7 +627,7 @@ SystemCapability.BundleManager.BundleFramework | ------------- | ------------------------------------ | | Promise\ | 返回值为Promise对象,Promise中为空。 | -## bundle.getPermissionDefdeprecated +## bundle.getPermissionDef8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef)替代。 @@ -654,7 +654,7 @@ SystemCapability.BundleManager.BundleFramework | permissionName | string | 是 | 指定权限的名称。 | | callback | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef)> | 是 | 程序启动作为入参的回调函数,返回定义的权限信息。 | -## bundle.getPermissionDefdeprecated +## bundle.getPermissionDef8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef)替代。 @@ -750,7 +750,7 @@ SystemCapability.BundleManager.BundleFramework | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag | -| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | | callback | AsyncCallback> | 是 | 程序启动作为入参的回调函数,返回应用信息列表。 | **示例:** @@ -956,7 +956,7 @@ bundle.getAbilityInfo(bundleName, abilityName, (err, data) => { }) ``` -## bundle.getAbilityLabeldeprecated +## bundle.getAbilityLabel8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel)替代。 @@ -998,7 +998,7 @@ bundle.getAbilityLabel(bundleName, abilityName) }) ``` -## bundle.getAbilityLabeldeprecated +## bundle.getAbilityLabel8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel)替代。 @@ -1036,7 +1036,7 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => { }) ``` -## bundle.isAbilityEnableddeprecated +## bundle.isAbilityEnabled8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled)替代。 @@ -1074,7 +1074,7 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{ }) ``` -## bundle.isAbilityEnableddeprecated +## bundle.isAbilityEnabled8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled)替代。 @@ -1109,7 +1109,7 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{ }) ``` -## bundle.isApplicationEnableddeprecated +## bundle.isApplicationEnabled8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled)替代。 @@ -1145,7 +1145,7 @@ bundle.isApplicationEnabled(bundleName) }) ``` -## bundle.isApplicationEnableddeprecated +## bundle.isApplicationEnabled8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled)替代。 @@ -1388,7 +1388,7 @@ bundle.getLaunchWantForBundle(bundleName, (err, data) => { ``` -## bundle.getNameForUiddeprecated +## bundle.getNameForUid8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid)替代。 @@ -1423,7 +1423,7 @@ bundle.getNameForUid(uid) }) ``` -## bundle.getNameForUiddeprecated +## bundle.getNameForUid8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid)替代。 @@ -1456,7 +1456,7 @@ bundle.getNameForUid(uid, (err, data) => { ``` -## bundle.getAbilityIcondeprecated +## bundle.getAbilityIcon8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon)替代。 @@ -1497,7 +1497,7 @@ bundle.getAbilityIcon(bundleName, abilityName) }) ``` -## bundle.getAbilityIcondeprecated +## bundle.getAbilityIcon8+ deprecated > 从API version 9开始不再维护,建议使用[bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon)替代。 @@ -1593,7 +1593,7 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { **系统能力:** SystemCapability.BundleManager.BundleFramework -| 参数名 | 类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ---- | ---- | ----------------------------------------------------- | | userId | number | 是 | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | @@ -1605,7 +1605,7 @@ Ability类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 参数名 | 类型 | 说明 | +| 名称 | 值 | 说明 | | ------- | ---- | --------------------------- | | UNKNOWN | 无 | 未知Ability类型 | | PAGE | 无 | 表示基于Page模板开发的FA,用于提供与用户交互的能力 | @@ -1620,7 +1620,7 @@ Ability类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 参数名 | 类型 | 说明 | +| 名称 | 值 | 说明 | | ------------- | ---- | ------------------------ | | UNSPECIFIED | 无 | 屏幕方向--不指定 | | LANDSCAPE | 无 | 屏幕方向--横屏 | @@ -1634,7 +1634,7 @@ Ability类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 参数名 | 类型 | 说明 | +| 名称 | 值 | 说明 | | --------- | ---- | ------------------- | | SINGLETON | 0 | Ability只有一个实例 | | STANDARD | 1 | Ability有多个实例 | @@ -1646,7 +1646,7 @@ Ability的子类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 参数名 | 类型 | 说明 | +| 名称 | 值 | 说明 | | ----------- | ---- | ----------------------------- | | UNSPECIFIED | 0 | 未定义Ability子类型 | | CA | 1 | Ability子类型是带有 UI 的服务 | @@ -1658,7 +1658,7 @@ Ability的子类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 参数名 | 类型 | 说明 | +| 名称 | 值 | 说明 | | ---------- | ---- | -------- | | AUTO_MODE | -1 | 自动模式 | | DARK_MODE | 0 | 黑色模式 | @@ -1673,7 +1673,7 @@ Ability的子类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 参数名 | 类型 | 说明 | +| 名称 | 值 | 说明 | | ------------------ | ---- | ------------ | | PERMISSION_DENIED | -1 | 拒绝授予权限 | | PERMISSION_GRANTED | 0 | 授予权限 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md index 5f9195932a5a290805d973bc0780bd30947c057b..3e84088d2b8826e175eb14c9d8e8dd6eea431f50 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md @@ -1,6 +1,6 @@ # AbilityRunningInfo -AbilityRunningInfo模块提供对Ability运行的相关信息和状态进行设置和查询的能力。 +AbilityRunningInfo模块提供对Ability运行的相关信息和状态的定义。 > **说明:** > diff --git a/zh-cn/application-dev/reference/apis/js-apis-animator.md b/zh-cn/application-dev/reference/apis/js-apis-animator.md index daf072b7ecedd24f2d7770308ad1bedb80a638c4..6233ea127e29015e9c482330209b52f9d28dc60a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-animator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-animator.md @@ -27,6 +27,7 @@ create(options: AnimatorOptions): AnimatorResult | options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | **返回值:** + | 类型 | 说明 | | --------------------------------- | ------------- | | [AnimatorResult](#animatorresult) | Animator结果接口。 | @@ -51,8 +52,6 @@ create(options: AnimatorOptions): AnimatorResult 定义Animator结果接口。 - - ### reset9+ reset(options: AnimatorOptions): void @@ -71,7 +70,7 @@ reset(options: AnimatorOptions): void 以下错误码的详细介绍请参见[ohos.animator(动画)](../errorcodes/errorcode-animator.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | @@ -181,6 +180,7 @@ onframe: (progress: number) => void | progress | number | 是 | 动画的当前进度。 | **示例:** + ```js let animatorResult = animator.create(options) animatorResult.onframe = function(value) { @@ -208,7 +208,7 @@ animatorResult.onfinish = function() { ### oncancel oncancel: () => void -不再维护 + 动画被取消时回调。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full @@ -247,7 +247,7 @@ animatorResult.onrepeat = function() { **系统能力:** SystemCapability.ArkUI.ArkUI.Full -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ---------------------------------------- | ---- | ---------------------------------------- | | duration | number | 是 | 动画播放的时长,单位毫秒,默认为0。 | | easing | string | 是 | 动画插值曲线,默认为'ease'。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-appControl.md b/zh-cn/application-dev/reference/apis/js-apis-appControl.md index 54bfbd04652fcaa8e3fe6cb81a7ac64dfec53d20..10b9377c92a73e341ade7e2a376617aef7703e05 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appControl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appControl.md @@ -39,13 +39,13 @@ setDisposedStatus(appId: string, disposedWant: Want): Promise\ | ------------------------- | ------------------ | | Promise\ | Promise对象。无返回结果的Promise对象。 | -**错误码** +**错误码:** 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700005 | The specified appId was not found. | +| 17700005 | The specified app ID is not found. | **示例:** @@ -85,13 +85,13 @@ setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\ | 是 | 回调函数,当设置处置状态成功,err为undefined,否则为错误对象。 | -**错误码** +**错误码:** 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700005 | The specified appId was not found. | +| 17700005 | The specified app ID is not found. | **示例:** @@ -136,13 +136,13 @@ getDisposedStatus(appId: string): Promise\; | ------------------------- | ------------------ | | Promise\ | Promise对象,返回应用的处置状态。 | -**错误码** +**错误码:** 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700005 | The specified appId was not found. | +| 17700005 | The specified app ID is not found. | **示例:** @@ -180,13 +180,13 @@ getDisposedStatus(appId: string, callback: AsyncCallback\): void; | appId | string | 是 | 要查询的应用的appId
appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 | | callback | AsyncCallback\ | 是 | 回调函数。当获取应用的处置状态成功时,err为undefined,data为获取到的处置状态;否则为错误对象。 | -**错误码** +**错误码:** 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700005 | The specified appId was not found. | +| 17700005 | The specified app ID is not found. | **示例:** @@ -230,13 +230,13 @@ deleteDisposedStatus(appId: string): Promise\ | ------------------------- | ------------------ | | Promise\ | Promise对象,无返回结果的Promise对象 | -**错误码** +**错误码:** 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700005 | The specified appId was not found. | +| 17700005 | The specified app ID is not found. | **示例:** @@ -274,13 +274,13 @@ deleteDisposedStatus(appId: string, callback: AsyncCallback\) : void | appId | string | 是 | 要查询的应用的appId。
appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 | | callback | AsyncCallback\ | 是 | 回调函数,当设置处置状态成功时,err返回undefined。否则回调函数返回具体错误对象。 | -**错误码** +**错误码:** 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700005 | The specified appId was not found. | +| 17700005 | The specified app ID is not found. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md index c4493e348a9a4cda5d3c1a6e70ab5aa39717fa9f..ae0674c7f4425bf08ad369aa8ba396251d397d7d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md @@ -127,7 +127,7 @@ update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueB | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | | uri | string | 是 | 指示要更新的数据的路径。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。 | | valueBucket | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示要更新的数据。 | | callback | AsyncCallback<number> | 是 | 回调函数。返回更新的数据记录数。 | @@ -170,7 +170,7 @@ delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callba | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ---------------------------------- | | uri | string | 是 | 指示要删除的数据的路径。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。 | | callback | AsyncCallback<number> | 是 | 回调函数。返回已删除的数据记录数。 | **示例:** @@ -212,7 +212,7 @@ query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | | uri | string | 是 | 指示要查询的数据的路径。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。 | | columns | Array<string> | 是 | 指示要查询的列。如果此参数为空,则查询所有列。 | | callback | AsyncCallback<Object> | 是 | 回调函数。返回查询到的结果集。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md index 9f77de28addb28d66abe81edf4b5e0c7bd827c15..013c1c109ca88d3b006c59e38720e9c7aaa37ef5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md @@ -339,13 +339,15 @@ onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}) **示例:** ```js - class myAbility extends Ability { - onSaveState(reason, wantParam) { - console.log('onSaveState'); - wantParams["myData"] = "my1234567"; - return AbilityConstant.OnSaveResult.RECOVERY_AGREE; - } - } +import AbilityConstant from '@ohos.application.AbilityConstant' + +class myAbility extends Ability { + onSaveState(reason, wantParam) { + console.log('onSaveState'); + wantParam["myData"] = "my1234567"; + return AbilityConstant.OnSaveResult.RECOVERY_AGREE; + } +} ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md index 86691ff6534c167e399c2d8c2c745428ebe7bd9a..c9fba61a134167085217637aadc74b87493fd2e6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md @@ -22,7 +22,7 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); ### addAbilityMonitor9+ -addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\): void +addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\): void; 添加AbilityMonitor实例(callback形式) @@ -30,7 +30,7 @@ addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填说明 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | | monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | 是 | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor)实例 | | callback | AsyncCallback\ | 是 | 表示指定的回调方法 | @@ -55,11 +55,9 @@ abilityDelegator.addAbilityMonitor(monitor, (err : any) => { }); ``` - - ### addAbilityMonitor9+ -addAbilityMonitor(monitor: AbilityMonitor): Promise\ +addAbilityMonitor(monitor: AbilityMonitor): Promise\; 添加AbilityMonitor实例(promise形式) @@ -101,7 +99,7 @@ abilityDelegator.addAbilityMonitor(monitor).then(() => { ### removeAbilityMonitor9+ -removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\): void +removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\): void; 删除已经添加的AbilityMonitor实例(callback形式) @@ -138,7 +136,7 @@ abilityDelegator.removeAbilityMonitor(monitor, (err : any) => { ### removeAbilityMonitor9+ -removeAbilityMonitor(monitor: AbilityMonitor): Promise\ +removeAbilityMonitor(monitor: AbilityMonitor): Promise\; 删除已经添加的AbilityMonitor实例(promise形式) @@ -146,7 +144,7 @@ removeAbilityMonitor(monitor: AbilityMonitor): Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | 是 | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor)实例 | @@ -180,7 +178,7 @@ abilityDelegator.removeAbilityMonitor(monitor).then(() => { ### waitAbilityMonitor9+ -waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\): void +waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\): void; 等待与AbilityMonitor实例匹配的ability到达OnCreate生命周期,并返回ability实例(callback形式) @@ -191,7 +189,7 @@ waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\): | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | 是 | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor)实例 | -| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | 是 | 表示指定的回调方法 | +| callback | AsyncCallback\<[UIAbility](js-apis-application-ability.md#Ability)> | 是 | 表示指定的回调方法 | **示例:** @@ -213,11 +211,9 @@ abilityDelegator.waitAbilityMonitor(monitor, (err : any, data : any) => { }); ``` - - ### waitAbilityMonitor9+ -waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback\): void +waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback\): void; 设置等待时间,等待与AbilityMonitor实例匹配的ability到达OnCreate生命周期,并返回ability实例(callback形式) @@ -229,7 +225,7 @@ waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCall | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | 是 | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor)实例 | | timeout | number | 是 | 最大等待时间,单位毫秒(ms) | -| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | 是 | 表示指定的回调方法 | +| callback | AsyncCallback\<[UIAbility](js-apis-application-ability.md#Ability)> | 是 | 表示指定的回调方法 | **示例:** @@ -256,7 +252,7 @@ abilityDelegator.waitAbilityMonitor(monitor, timeout, (err : any, data : any) => ### waitAbilityMonitor9+ -waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\ +waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\; 设置等待时间,等待与AbilityMonitor实例匹配的ability到达OnCreate生命周期,并返回ability实例(promise形式) @@ -273,7 +269,7 @@ waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\ | 类型 | 说明 | | ----------------------------------------------------------- | -------------------------- | -| Promise\<[Ability](js-apis-application-ability.md#Ability)> | 以Promise形式返回Ability。 | +| Promise\<[UIAbility](js-apis-application-ability.md#Ability)> | 以Promise形式返回Ability。 | **示例:** @@ -299,7 +295,7 @@ abilityDelegator.waitAbilityMonitor(monitor).then((data : any) => { ### getAppContext9+ -getAppContext(): Context +getAppContext(): Context; 获取应用Context @@ -324,7 +320,7 @@ var context = abilityDelegator.getAppContext(); ### getAbilityState9+ -getAbilityState(ability: Ability): number +getAbilityState(ability: UIAbility): number; 获取指定ability的生命周期状态 @@ -334,7 +330,7 @@ getAbilityState(ability: Ability): number | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------------------------- | ---- | --------------- | -| ability | [Ability](js-apis-application-ability.md#Ability) | 是 | 指定Ability对象 | +| ability | [UIAbility](js-apis-application-ability.md#Ability) | 是 | 指定Ability对象 | **返回值:** @@ -361,7 +357,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ### getCurrentTopAbility9+ -getCurrentTopAbility(callback: AsyncCallback\): void +getCurrentTopAbility(callback: AsyncCallback\): void; 获取当前应用顶部ability(callback形式) @@ -371,7 +367,7 @@ getCurrentTopAbility(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------ | -| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | 是 | 表示指定的回调方法 | +| callback | AsyncCallback\<[UIAbility](js-apis-application-ability.md#Ability)> | 是 | 表示指定的回调方法 | **示例:** @@ -390,7 +386,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ### getCurrentTopAbility9+ -getCurrentTopAbility(): Promise\ +getCurrentTopAbility(): Promise\; 获取当前应用顶部ability(promise形式) @@ -400,7 +396,7 @@ getCurrentTopAbility(): Promise\ | 类型 | 说明 | | ----------------------------------------------------------- | -------------------------------------- | -| Promise\<[Ability](js-apis-application-ability.md#Ability)> | 以Promise形式返回当前应用顶部ability。 | +| Promise\<[UIAbility](js-apis-application-ability.md#Ability)> | 以Promise形式返回当前应用顶部ability。 | **示例:** @@ -419,7 +415,7 @@ abilityDelegator.getCurrentTopAbility().then((data : any) => { ### startAbility9+ -startAbility(want: Want, callback: AsyncCallback\): void +startAbility(want: Want, callback: AsyncCallback\): void; 启动指定ability(callback形式) @@ -451,7 +447,7 @@ abilityDelegator.startAbility(want, (err : any, data : any) => { ### startAbility9+ -startAbility(want: Want): Promise\ +startAbility(want: Want): Promise\; 启动指定ability(promise形式) @@ -488,7 +484,7 @@ abilityDelegator.startAbility(want).then((data: any) => { ### doAbilityForeground9+ -doAbilityForeground(ability: Ability, callback: AsyncCallback\): void +doAbilityForeground(ability: UIAbility, callback: AsyncCallback\): void; 调度指定ability生命周期状态到Foreground状态(callback形式) @@ -498,8 +494,8 @@ doAbilityForeground(ability: Ability, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | ------------------------------------------------------- | -| ability | Ability | 是 | 指定Ability对象 | -| callback | AsyncCallback\ | 是 | 表示指定的回调方法
\- true:成功
\- false:失败 | +| ability | UIAbility | 是 | 指定Ability对象 | +| callback | AsyncCallback\ | 是 | 表示指定的回调方法
\- true:成功
\- false:失败 | **示例:** @@ -521,7 +517,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ### doAbilityForeground9+ -doAbilityForeground(ability: Ability): Promise\ +doAbilityForeground(ability: UIAbility): Promise\; 调度指定ability生命周期状态到Foreground状态(promise形式) @@ -531,7 +527,7 @@ doAbilityForeground(ability: Ability): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------- | ------- | ---- | --------------- | -| ability | Ability | 是 | 指定Ability对象 | +| ability | UIAbility | 是 | 指定Ability对象 | **返回值:** @@ -559,7 +555,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ### doAbilityBackground9+ -doAbilityBackground(ability: Ability, callback: AsyncCallback\): void +doAbilityBackground(ability: UIAbility, callback: AsyncCallback\): void; 调度指定ability生命周期状态到Background状态(callback形式) @@ -569,8 +565,8 @@ doAbilityBackground(ability: Ability, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | ------------------------------------------------------- | -| ability | Ability | 是 | 指定Ability对象 | -| callback | AsyncCallback\ | 是 | 表示指定的回调方法
\- true:成功
\- false:失败 | +| ability | UIAbility | 是 | 指定Ability对象 | +| callback | AsyncCallback\ | 是 | 表示指定的回调方法
\- true:成功
\- false:失败 | **示例:** @@ -592,7 +588,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ### doAbilityBackground9+ -doAbilityBackground(ability: Ability): Promise\ +doAbilityBackground(ability: UIAbility): Promise\; 调度指定ability生命周期状态到Background状态(promise形式) @@ -602,7 +598,7 @@ doAbilityBackground(ability: Ability): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------- | ------- | ---- | --------------- | -| ability | Ability | 是 | 指定Ability对象 | +| ability | UIAbility | 是 | 指定Ability对象 | **返回值:** @@ -630,7 +626,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ### printSync9+ -printSync(msg: string): void +printSync(msg: string): void; 打印日志信息到单元测试终端控制台 @@ -656,7 +652,7 @@ abilityDelegator.printSync(msg); ### print -print(msg: string, callback: AsyncCallback\): void +print(msg: string, callback: AsyncCallback\): void; 打印日志信息到单元测试终端控制台(callback形式) @@ -685,7 +681,7 @@ abilityDelegator.print(msg, (err : any) => { ### print -print(msg: string): Promise\ +print(msg: string): Promise\; 打印日志信息到单元测试终端控制台(promise形式) @@ -719,7 +715,7 @@ abilityDelegator.print(msg).then(() => { ### executeShellCommand -executeShellCommand(cmd: string, callback: AsyncCallback\): void +executeShellCommand(cmd: string, callback: AsyncCallback\): void; 执行指定的shell命令(callback形式) @@ -748,7 +744,7 @@ abilityDelegator.executeShellCommand(cmd, (err : any, data : any) => { ### executeShellCommand -executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback\): void +executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback\): void; 指定超时时间,并执行指定的shell命令(callback形式) @@ -779,7 +775,7 @@ abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => { ### executeShellCommand -executeShellCommand(cmd: string, timeoutSecs?: number): Promise\ +executeShellCommand(cmd: string, timeoutSecs?: number): Promise\; 指定超时时间,并执行指定的shell命令(promise形式) @@ -815,7 +811,7 @@ abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => { ### finishTest9+ -finishTest(msg: string, code: number, callback: AsyncCallback\): void +finishTest(msg: string, code: number, callback: AsyncCallback\): void; 结束测试并打印日志信息到单元测试终端控制台(callback形式) @@ -845,7 +841,7 @@ abilityDelegator.finishTest(msg, 0, (err : any) => { ### finishTest9+ -finishTest(msg: string, code: number): Promise\ +finishTest(msg: string, code: number): Promise\; 结束测试并打印日志信息到单元测试终端控制台(promise形式) @@ -886,7 +882,7 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\ | 是 | 表示指定的回调方法 | @@ -955,7 +951,7 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\ **参数:** -| 参数名 | 类型 | 必填说明 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | | monitor | [AbilityStageMonitor](#abilitystagemonitor) | 是 | [AbilityStageMonitor](#abilitystagemonitor) 实例 | | callback | AsyncCallback\ | 是 | 表示指定的回调方法 | @@ -1024,7 +1020,7 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\ | 是 | 成功返回AbilityStage对象,失败返回空。 | @@ -1062,7 +1058,7 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | monitor | [AbilityStageMonitor](#abilitystagemonitor) | 是 | [AbilityStageMonitor](#abilitystagemonitor) 实例 | -| timeout | number | 否 | 超时最大等待时间,以毫秒为单位。 | +| timeout | number | 是 | 超时最大等待时间,以毫秒为单位。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md index 14b7c0b1b88aeafcf0e180a7c114abff881790dc..37962b3ae0bb6e5d583c6e602f7ef098c98542ee 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md @@ -156,16 +156,18 @@ onAbilityContinue(ability: Ability): void; **示例:** - ```js - import Ability from "@ohos.application.Ability"; - - export default class MyAbility extends Ability { - onCreate() { - console.log("MyAbility onCreate") - let AbilityLifecycleCallback = { - onAbilityCreate(ability){ - console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); - }, +```js +import AbilityStage from "@ohos.application.AbilityStage"; + +var lifecycleid; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + let AbilityLifecycleCallback = { + onAbilityCreate(ability){ + console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); + }, onWindowStageCreate(ability, windowStage){ console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + JSON.stringify(ability)); console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + JSON.stringify(windowStage)); @@ -182,30 +184,30 @@ onAbilityContinue(ability: Ability): void; console.log("AbilityLifecycleCallback onWindowStageDestroy ability:" + JSON.stringify(ability)); console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + JSON.stringify(windowStage)); }, - onAbilityDestroy(ability){ - console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability)); - }, - onAbilityForeground(ability){ - console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability)); - }, - onAbilityBackground(ability){ - console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability)); - }, - onAbilityContinue(ability){ - console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability)); - } - } - // 1.通过context属性获取applicationContext - let applicationContext = this.context.getApplicationContext(); - // 2.通过applicationContext注册监听应用内生命周期 - let lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback); - console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid)); - }, - onDestroy() { - let applicationContext = this.context.getApplicationContext(); - applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => { - console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); - }); - } - } - ``` \ No newline at end of file + onAbilityDestroy(ability){ + console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability)); + }, + onAbilityForeground(ability){ + console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability)); + }, + onAbilityBackground(ability){ + console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability)); + }, + onAbilityContinue(ability){ + console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability)); + } + } + // 1.通过context属性获取applicationContext + let applicationContext = this.context.getApplicationContext(); + // 2.通过applicationContext注册监听应用内生命周期 + lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback); + console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid)); + } + onDestroy() { + let applicationContext = this.context.getApplicationContext(); + applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => { + console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); + }); + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md b/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md index 05ec3041cace1d337c20e239940bf573af73b871..f7e93d61b7bae065d54e54414256e23870301119 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md @@ -15,7 +15,6 @@ ApplicationContext模块提供开发者应用级别的的上下文的能力, let applicationContext = this.context.getApplicationContext(); ``` - ## ApplicationContext.registerAbilityLifecycleCallback registerAbilityLifecycleCallback(callback: AbilityLifecycleCallback): **number**; @@ -38,7 +37,7 @@ registerAbilityLifecycleCallback(callback: AbilityLifecycleCallback): **number** **示例:** - ```js +```js import Ability from "@ohos.application.Ability"; var lifecycleId; @@ -46,36 +45,36 @@ var lifecycleId; export default class MyAbility extends Ability { onCreate() { console.log("MyAbility onCreate") - let AbilityLifecycleCallback = { - onAbilityCreate(ability){ - console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); + let AbilityLifecycleCallback = { + onAbilityCreate(ability) { + console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); }, - onWindowStageCreate(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + JSON.stringify(ability)); - console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + JSON.stringify(windowStage)); + onWindowStageCreate(ability, windowStage) { + console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + JSON.stringify(ability)); + console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + JSON.stringify(windowStage)); }, - onWindowStageActive(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageActive ability:" + JSON.stringify(ability)); - console.log("AbilityLifecycleCallback onWindowStageActive windowStage:" + JSON.stringify(windowStage)); + onWindowStageActive(ability, windowStage) { + console.log("AbilityLifecycleCallback onWindowStageActive ability:" + JSON.stringify(ability)); + console.log("AbilityLifecycleCallback onWindowStageActive windowStage:" + JSON.stringify(windowStage)); }, - onWindowStageInactive(ability, windowStage){ + onWindowStageInactive(ability, windowStage) { console.log("AbilityLifecycleCallback onWindowStageInactive ability:" + JSON.stringify(ability)); - console.log("AbilityLifecycleCallback onWindowStageInactive windowStage:" + JSON.stringify(windowStage)); + console.log("AbilityLifecycleCallback onWindowStageInactive windowStage:" + JSON.stringify(windowStage)); }, - onWindowStageDestroy(ability, windowStage){ + onWindowStageDestroy(ability, windowStage) { console.log("AbilityLifecycleCallback onWindowStageDestroy ability:" + JSON.stringify(ability)); - console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + JSON.stringify(windowStage)); + console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + JSON.stringify(windowStage)); }, - onAbilityDestroy(ability){ - console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability)); + onAbilityDestroy(ability) { + console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability)); }, - onAbilityForeground(ability){ - console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability)); + onAbilityForeground(ability) { + console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability)); }, - onAbilityBackground(ability){ - console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability)); + onAbilityBackground(ability) { + console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability)); }, - onAbilityContinue(ability){ + onAbilityContinue(ability) { console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability)); } } @@ -84,16 +83,9 @@ export default class MyAbility extends Ability { // 2.通过applicationContext注册监听应用内生命周期 lifecycleId = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback); console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleId)); - }, - onDestroy() { - let applicationContext = this.context.getApplicationContext(); - applicationContext.unregisterAbilityLifecycleCallback(lifecycleId, (error, data) => { - console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); - }); } } - ``` - +``` ## ApplicationContext.unregisterAbilityLifecycleCallback @@ -112,14 +104,21 @@ unregisterAbilityLifecycleCallback(callbackId: **number**, callback: AsyncCallb **示例:** - ```js - let applicationContext = this.context.getApplicationContext(); - let lifecycleId = 1; - console.log("stage applicationContext: " + JSON.stringify(applicationContext)); - applicationContext.unregisterAbilityLifecycleCallback(lifecycleId, (error, data) => { - console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); - }); - ``` +```js +import Ability from "@ohos.application.Ability"; + +var lifecycleId; + +export default class MyAbility extends Ability { + onDestroy() { + let applicationContext = this.context.getApplicationContext(); + console.log("stage applicationContext: " + JSON.stringify(applicationContext)); + applicationContext.unregisterAbilityLifecycleCallback(lifecycleId, (error, data) => { + console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); + }); + } +} +``` ## ApplicationContext.registerEnvironmentCallback @@ -143,7 +142,7 @@ registerEnvironmentCallback(callback: EnvironmentCallback): **number**; **示例:** - ```js +```js import Ability from "@ohos.application.Ability"; var callbackId; @@ -163,14 +162,8 @@ export default class MyAbility extends Ability { callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback); console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId)); } - onDestroy() { - let applicationContext = globalThis.applicationContext; - applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { - console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); - }); - } } - ``` +``` ## ApplicationContext.unregisterEnvironmentCallback @@ -189,10 +182,17 @@ unregisterEnvironmentCallback(callbackId: **number**, callback: AsyncCallback<* **示例:** - ```js - let applicationContext = this.context.getApplicationContext(); - let callbackId = 1; - applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { - console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); - }); - ``` +```js +import Ability from "@ohos.application.Ability"; + +var callbackId; + +export default class MyAbility extends Ability { + onDestroy() { + let applicationContext = this.context.getApplicationContext(); + applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { + console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); + }); + } +} +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-application-context.md index 93e910fa9df0e5ac443c94c29c661a960d9cfada..1ef83c3ba8356bccf9d6afc3495f5a2ecd439121 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-context.md @@ -67,17 +67,10 @@ createBundleContext(bundleName: string): Context; **示例:** ```js -import Ability from '@ohos.application.Ability' - -class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - let test = "com.example.test"; - let context = this.context.createBundleContext(test); - } -} +let test = "com.example.test"; +let context = this.context.createBundleContext(test); ``` - ## Context.createModuleContext createModuleContext(moduleName: string): Context; @@ -101,17 +94,10 @@ createModuleContext(moduleName: string): Context; **示例:** ```js -import Ability from '@ohos.application.Ability' - -class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - let moduleName = "module"; - let context = this.context.createModuleContext(moduleName); - } -} +let moduleName = "module"; +let context = this.context.createModuleContext(moduleName); ``` - ## Context.createModuleContext createModuleContext(bundleName: string, moduleName: string): Context; @@ -138,15 +124,9 @@ createModuleContext(bundleName: string, moduleName: string): Context; **示例:** ```js -import Ability from '@ohos.application.Ability' - -class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - let bundleName = "com.example.bundle"; - let moduleName = "module"; - let context = this.context.createModuleContext(bundleName, moduleName); - } -} +let bundleName = "com.example.bundle"; +let moduleName = "module"; +let context = this.context.createModuleContext(bundleName, moduleName); ``` ## Context.getApplicationContext @@ -166,16 +146,9 @@ getApplicationContext(): ApplicationContext; **示例:** ```js -import Ability from '@ohos.application.Ability' - -class MainAbility extends Ability { - onWindowStageCreate(windowStage) { - let applicationContext = this.context.getApplicationContext(); - } -} +let applicationContext = this.context.getApplicationContext(); ``` - ## AreaMode 访问的文件分区,每个文件分区有对应自己的内容。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-quickFixManager.md b/zh-cn/application-dev/reference/apis/js-apis-application-quickFixManager.md index fe4f9c1bb9f2360ab03a1a3ad7afb06b5e6c962b..6a9e42f12f5339e29a6f27575ba3efe97582e8a4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-quickFixManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-quickFixManager.md @@ -9,7 +9,7 @@ quickFixManager模块提供快速修复的能力,快速修复是OpenHarmony提 ## 导入模块 ``` -import quickFixManager from '@ohos.application.quickFixManager'; +import quickFixManager from '@ohos.app.ability.quickFixManager'; ``` ## HapModuleQuickFixInfo @@ -65,7 +65,7 @@ applyQuickFix(hapModuleQuickFixFiles: Array\, callback: AsyncCallback\ { @@ -104,7 +104,7 @@ applyQuickFix(hapModuleQuickFixFiles: Array\): Promise\; **示例:** ```js - import quickFixManager from '@ohos.application.quickFixManager' + import quickFixManager from '@ohos.app.ability.quickFixManager' let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"] quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => { @@ -136,7 +136,7 @@ getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\ { @@ -175,7 +175,7 @@ getApplicationQuickFixInfo(bundleName: string): Promise\ { diff --git a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md index 6c3e7763ed04d650db9a31930b971aafa480d3cf..6d59237a33abfab55d17deacea5cf0b1b1f8b28b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md @@ -51,11 +51,6 @@ ArrayList的构造函数。 ```ts let arrayList = new ArrayList(); -try { - let arrayList2 = ArrayList(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -89,21 +84,16 @@ add(element: T): boolean **示例:** - ```ts - let arrayList = new ArrayList(); - let result = arrayList.add("a"); - let result1 = arrayList.add(1); - let b = [1, 2, 3]; - let result2 = arrayList.add(b); - let c = {name: "Dylon", age: "13"}; - let result3 = arrayList.add(c); - let result4 = arrayList.add(false); - try { - arrayList.add.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 - } catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); - } - ``` +```ts +let arrayList = new ArrayList(); +let result = arrayList.add("a"); +let result1 = arrayList.add(1); +let b = [1, 2, 3]; +let result2 = arrayList.add(b); +let c = {name: "Dylon", age: "13"}; +let result3 = arrayList.add(c); +let result4 = arrayList.add(false); +``` ### insert @@ -136,21 +126,6 @@ let arrayList = new ArrayList(); arrayList.insert("A", 0); arrayList.insert(0, 1); arrayList.insert(true, 2); -try { - arrayList.insert.bind({}, 1, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - let res = arrayList.insert(8, 11); // 测试越界异常 -} catch (err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - let res = arrayList.insert("a", "b"); // 测试类型异常 -} catch (err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### has @@ -188,11 +163,6 @@ let arrayList = new ArrayList(); let result = arrayList.has("squirrel"); arrayList.add("squirrel"); let result1 = arrayList.has("squirrel"); -try { - arrayList.has.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getIndexOf @@ -235,11 +205,6 @@ arrayList.add(1); arrayList.add(2); arrayList.add(4); let result = arrayList.getIndexOf(2); -try { - arrayList.getIndexOf.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getLastIndexOf @@ -282,11 +247,6 @@ arrayList.add(1); arrayList.add(2); arrayList.add(4); let result = arrayList.getLastIndexOf(2); -try { - arrayList.getLastIndexOf.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### removeByIndex @@ -328,21 +288,6 @@ arrayList.add(5); arrayList.add(2); arrayList.add(4); let result = arrayList.removeByIndex(2); -try { - arrayList.removeByIndex.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - arrayList.removeByIndex("a"); // 测试类型异常 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - arrayList.removeByIndex(8); // 测试越界异常 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### remove @@ -382,11 +327,6 @@ arrayList.add(4); arrayList.add(5); arrayList.add(4); let result = arrayList.remove(2); -try { - arrayList.remove.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### removeByRange @@ -422,16 +362,6 @@ arrayList.add(4); arrayList.add(5); arrayList.add(4); arrayList.removeByRange(2, 4); -try { - arrayList.removeByRange.bind({}, 2, 4)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - arrayList.removeByRange(8, 4); // 测试越界异常 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### replaceAllElements @@ -480,13 +410,6 @@ arrayList.replaceAllElements((value: number, index: number)=> { arrayList.replaceAllElements((value: number, index: number) => { return value = value - 2; }); -try { - arrayList.replaceAllElements.bind({}, (value: number, index: number)=> { - return value = 2 * value; - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### forEach @@ -532,13 +455,6 @@ arrayList.add(4); arrayList.forEach((value, index) => { console.log(`value:${value}`, index); }); -try { - arrayList.forEach.bind({}, (value, index) => { - console.log(`value:${value}`, index); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### sort @@ -581,11 +497,6 @@ arrayList.add(4); arrayList.sort((a: number, b: number) => a - b); arrayList.sort((a: number, b: number) => b - a); arrayList.sort(); -try { - arrayList.sort.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### subArrayList @@ -629,16 +540,6 @@ arrayList.add(4); let result1 = arrayList.subArrayList(2, 4); let result2 = arrayList.subArrayList(4, 3); let result3 = arrayList.subArrayList(2, 6); -try { - arrayList.subArrayList.bind({}, 2, 4)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - arrayList.subArrayList(6, 4); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### clear @@ -666,11 +567,6 @@ arrayList.add(4); arrayList.add(5); arrayList.add(4); arrayList.clear(); -try { - arrayList.clear.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### clone @@ -705,11 +601,6 @@ arrayList.add(4); arrayList.add(5); arrayList.add(4); let result = arrayList.clone(); -try { - arrayList.clone.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getCapacity @@ -743,11 +634,6 @@ arrayList.add(4); arrayList.add(5); arrayList.add(4); let result = arrayList.getCapacity(); -try { - arrayList.getCapacity.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### convertToArray @@ -781,11 +667,6 @@ arrayList.add(4); arrayList.add(5); arrayList.add(4); let result = arrayList.convertToArray(); -try { - arrayList.convertToArray.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### isEmpty @@ -819,11 +700,6 @@ arrayList.add(4); arrayList.add(5); arrayList.add(4); let result = arrayList.isEmpty(); -try { - arrayList.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### increaseCapacityTo @@ -858,11 +734,6 @@ arrayList.add(5); arrayList.add(4); arrayList.increaseCapacityTo(2); arrayList.increaseCapacityTo(8); -try { - arrayList.increaseCapacityTo.bind({}, 5)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### trimToCurrentLength @@ -890,11 +761,6 @@ arrayList.add(4); arrayList.add(5); arrayList.add(4); arrayList.trimToCurrentLength(); -try { - arrayList.trimToCurrentLength.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### [Symbol.iterator] @@ -940,9 +806,4 @@ while(temp != undefined) { console.log(`value:${temp}`); temp = iter.next().value; } -try { - arrayList[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index bb081db93b235ef92b4f0d0238621b3eb208928b..af3771b9a3331d18da722abf56ad75e7cc2eca85 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -487,7 +487,7 @@ async function createTonePlayerBefore(){ ## AudioSamplingRate8+ -枚举,音频采样率。 +枚举,音频采样率,具体设备支持的采样率规格可能不同。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core @@ -706,7 +706,7 @@ async function createTonePlayerBefore(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device | 名称 | 类型 | 必填 | 说明 | -| ---------- | ----------------------------------- | ---- | ---- | -------------------------------------------------------- | +| ---------- | ----------------------------------- | ---- |-------------------------------------------------------- | | mute | boolean | 是 | 回调返回系统麦克风静音状态,true为静音,false为非静音。 | ## ConnectType9+ @@ -1920,7 +1920,7 @@ getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeI **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | -------- | --------------------------- | | callback | AsyncCallback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | 是 | 回调函数,返回当前音频渲染器的信息。 | @@ -2014,7 +2014,7 @@ getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeI **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ----------------------------------- | --------- | -------------------------------------------------------- | | callback | AsyncCallback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | 是 | 回调函数,返回当前音频采集器的信息。 | @@ -2104,7 +2104,7 @@ on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArr **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------- | --------- | ------------------------------------------------------------------------ | | type | string | 是 | 事件类型,支持的事件`'audioRendererChange'`:当音频渲染器发生更改时触发。 | | callback | Callback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | 是 | 回调函数。 | @@ -2154,7 +2154,7 @@ off(type: "audioRendererChange"): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------- | ---- | ---------------- | | type | string | 是 | 事件类型,支持的事件`'audioRendererChange'`:音频渲染器更改事件。 | @@ -2183,7 +2183,7 @@ on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArr **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------- | --------- | ----------------------------------------------------------------------- | | type | string | 是 | 事件类型,支持的事件`'audioCapturerChange'`:当音频采集器发生更改时触发。 | | callback | Callback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | 是 | 回调函数。 | @@ -2232,7 +2232,7 @@ off(type: "audioCapturerChange"): void; **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | --- | ------------------------------------------------------------- | | type | string |是 | 事件类型,支持的事件`'audioCapturerChange'`:音频采集器更改事件。 | @@ -2256,7 +2256,7 @@ console.info('######### CapturerChange Off is called #########'); isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -获取指定音量流是否为活跃状态,使用callback方式异步返回结果。 +获取指定音频流是否为活跃状态,使用callback方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Renderer @@ -2264,7 +2264,7 @@ isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): v | 参数名 | 类型 | 必填 | 说明 | | ---------- | ----------------------------------- | ---- | ------------------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音频流类型。 | | callback | AsyncCallback<boolean> | 是 | 回调返回流的活跃状态,true为活跃,false为不活跃。 | **示例:** @@ -2283,7 +2283,7 @@ audioStreamManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { isActive(volumeType: AudioVolumeType): Promise<boolean> -获取指定音量流是否为活跃状态,使用Promise方式异步返回结果。 +获取指定音频流是否为活跃状态,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Multimedia.Audio.Renderer @@ -2291,7 +2291,7 @@ isActive(volumeType: AudioVolumeType): Promise<boolean> | 参数名 | 类型 | 必填 | 说明 | | ---------- | ----------------------------------- | ---- | ------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音频流类型。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md index b363572eecbea607524e9ef94f5a5794df03f124..36c67f2fcc03d8c0f59b0462ac09054eae21d960 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -34,7 +34,7 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------------ | | reason | string | 是 | 延迟挂起申请的原因。 | | callback | Callback<void> | 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 | @@ -72,7 +72,7 @@ getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | --------------------------- | ---- | ---------------------------------------- | | requestId | number | 是 | 延迟挂起的请求ID。这个值通过调用[requestSuspendDelay](#backgroundtaskmanagerrequestsuspenddelay)方法获取。 | | callback | AsyncCallback<number> | 是 | 指定的callback回调方法。用于返回应用程序进入挂起状态之前的剩余时间,以毫秒为单位。 | @@ -103,7 +103,7 @@ getRemainingDelayTime(requestId: number): Promise<number> **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ---------- | | requestId | number | 是 | 延迟挂起的请求ID。这个值通过调用[requestSuspendDelay](#backgroundtaskmanagerrequestsuspenddelay)方法获取。 | @@ -135,7 +135,7 @@ cancelSuspendDelay(requestId: number): void **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ---------- | | requestId | number | 是 | 延迟挂起的请求ID。这个值通过调用[requestSuspendDelay](#backgroundtaskmanagerrequestsuspenddelay)方法获取。 | @@ -159,7 +159,7 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | ---------------------------------- | ---- | ---------------------------------------- | | context | Context | 是 | 应用运行的上下文。
FA模型的应用Context定义见[Context](js-apis-Context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | | bgMode | [BackgroundMode](#backgroundmode8) | 是 | 向系统申请的后台模式。 | @@ -251,7 +251,7 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | ---------------------------------- | ---- | ---------------------------------------- | | context | Context | 是 | 应用运行的上下文。
FA模型的应用Context定义见[Context](js-apis-Context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | | bgMode | [BackgroundMode](#backgroundmode8) | 是 | 向系统申请的后台模式。 | @@ -337,7 +337,7 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------------------------------------- | | context | Context | 是 | 应用运行的上下文。
FA模型的应用Context定义见[Context](js-apis-Context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果。 | @@ -393,7 +393,7 @@ stopBackgroundRunning(context: Context): Promise<void> **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------- | ------- | ---- | ---------------------------------------- | | context | Context | 是 | 应用运行的上下文。
FA模型的应用Context定义见[Context](js-apis-Context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | @@ -436,13 +436,76 @@ export default class MainAbility extends Ability { }; ``` +## backgroundTaskManager.applyEfficiencyResources9+ + +applyEfficiencyResources(request: [EfficiencyResourcesRequest](#efficiencyresourcesrequest9)): boolean + +向系统申请或释放能效资源,使用boolean形式返回结果。 +通过EfficiencyResourcesRequest参数中的isApply变量,设置是申请还是释放。 +应用使用此接口,需要向应用中心申请获得相应特权。 +进程和它所属的应用可以同时申请某一类资源,例如CPU资源,但是应用释放资源的时候会将进程的资源一起释放。 + +**系统能力**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + +**系统API**: 此接口为系统接口。 + +**参数**: + +| 名称 | 类型 | 必填 | 说明 | +| ------- | ------- | ---- | ---------------------------------------- | +| request | [EfficiencyResourcesRequest](#efficiencyresourcesrequest9) | 是 | 请求的必要信息。包括资源类型,超时时间等信息。详见[EfficiencyResourcesRequest](#efficiencyresourcesrequest9)。 | + +**返回值**: + +| 类型 | 说明 | +| -------------- | ---------------- | +| boolean | true代表申请成功,false代表申请失败。 | + +**示例**: + +```js +import backgroundTaskManager from '@ohos.backgroundTaskManager'; + +let request = { + resourceTypes: backgroundTaskManager.ResourceType.CPU, + // 如果将isApply置为false,则表示释放资源 + isApply: true, + timeOut: 0, + reason: "apply", + isPersist: true, + isProcess: false, +}; +let res = backgroundTaskManager.applyEfficiencyResources(request); +console.info("result of applyEfficiencyResources is: " + res) +``` + +## backgroundTaskManager.resetAllEfficiencyResources9+ + +resetAllEfficiencyResources(): void + +释放所有已经申请的资源。 +应用使用此接口,需要向应用中心申请获得相应特权。 + +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + +**系统API**: 此接口为系统接口。 + +**示例**: + +```js +import backgroundTaskManager from '@ohos.backgroundTaskManager'; + +backgroundTaskManager.resetAllEfficiencyResources(); + +``` + ## DelaySuspendInfo 延迟挂起信息。 **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------------- | ------ | ---- | ---------------------------------------- | | requestId | number | 是 | 延迟挂起的请求ID。 | | actualDelayTime | number | 是 | 应用的实际挂起延迟时间,以毫秒为单位。
一般情况下默认值为180000,低电量(依据系统低电量广播)时默认值为60000。 | @@ -452,14 +515,49 @@ export default class MainAbility extends Ability { **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -| 参数名 | 描述 | -| ----------------------- | --------------------- | -| DATA_TRANSFER | 数据传输。 | -| AUDIO_PLAYBACK | 音频播放。 | -| AUDIO_RECORDING | 录音。 | -| LOCATION | 定位导航。 | -| BLUETOOTH_INTERACTION | 蓝牙相关。 | -| MULTI_DEVICE_CONNECTION | 多设备互联。 | -| WIFI_INTERACTION | WLAN相关(此接口为系统接口)。 | -| VOIP | 音视频通话(此接口为系统接口)。 | -| TASK_KEEPING | 计算任务(仅在特定设备生效)。 | \ No newline at end of file +| 名称 | 值 | 描述 | +| ----------------------- | ---- | --------------------- | +| DATA_TRANSFER | 1 | 数据传输。 | +| AUDIO_PLAYBACK | 2 | 音频播放。 | +| AUDIO_RECORDING | 3 | 录音。 | +| LOCATION | 4 | 定位导航。 | +| BLUETOOTH_INTERACTION | 5 | 蓝牙相关。 | +| MULTI_DEVICE_CONNECTION | 6 | 多设备互联。 | +| WIFI_INTERACTION | 7 | WLAN相关
此接口为系统接口。 | +| VOIP | 8 | 音视频通话
此接口为系统接口。 | +| TASK_KEEPING | 9 | 计算任务(仅在特定设备生效)。 | + +## EfficiencyResourcesRequest9+ + +能效资源申请参数。 + +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + +**系统API**: 此接口为系统接口。 + +| 名称 | 类型 | 必填 | 说明 | +| --------------- | ------ | ---- | ---------------------------------------- | +| resourceTypes | number | 是 | 申请的资源类型。 | +| isApply | boolean | 是 | 申请资源或者是释放资源。 | +| timeOut | number | 是 | 资源的使用时间,以毫秒为单位。 | +| isPersist | boolean | 否 | 是否永久持有资源,如果是true,那么timeOut就无效。 | +| isProcess | boolean | 否 | 应用申请或者是进程申请。 | +| reason | string | 是 | 申请资源的原因。 | + +## ResourceType9+ + +能效资源类型。 + +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + +**系统API**: 此接口为系统接口。 + +| 名称 | 值 | 描述 | +| ----------------------- | ---- | --------------------- | +| CPU | 1 | CPU资源,申请后不被挂起。 | +| COMMON_EVENT | 2 | 公共事件,申请后挂起状态下不被代理掉。 | +| TIMER | 4 | 计时器,申请后挂起状态下不被代理掉。 | +| WORK_SCHEDULER | 8 | 延迟任务,申请后有更长的执行时间。 | +| BLUETOOTH | 16 | 蓝牙相关,申请后挂起状态下不被代理掉。 | +| GPS | 32 | GPS相关,申请后挂起状态下不被代理掉。 | +| AUDIO | 64 | 音频资源,申请后挂起状态下不被代理掉。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-buffer.md b/zh-cn/application-dev/reference/apis/js-apis-buffer.md index f4086c7c60cff9de2a446944e2a4a7507796313e..56e93709a22753453726ef329a46d5d0cabe1de7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-buffer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-buffer.md @@ -13,6 +13,26 @@ 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 ### 属性 @@ -39,24 +59,9 @@ import buffer from '@ohos.buffer'; import buffer from '@ohos.buffer'; let buf = buffer.from("1236"); -try { - buf.length = 10; -} catch (err) { - console.log("set length exception: " + JSON.stringify(err)); -} - -let buf1 = buffer.from("123"); -try { - buf.buffer = buf1; -} catch (err) { - console.log("set buffer exception: " + JSON.stringify(err)); -} - -try { - buf.byteOffset = 3; -} catch (err) { - console.log("set byteOffset exception: " + JSON.stringify(err)); -} +console.log(buf.length); +console.log(buf.buffer); +console.log(buf.byteOffset); ``` ### alloc @@ -73,7 +78,7 @@ alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): | -------- | -------- | -------- | -------- | | size | number | 是 | 指定的Buffer实例长度,单位:字节。 | | fill | string \| Buffer \| number | 否 | 预填充的值,默认值: 0 | -| encoding | BufferEncoding | 否 | 编码方式(当`fill`为string时,才有意义)。 默认值: 'utf-8' | +| encoding | [BufferEncoding](#bufferencoding) | 否 | 编码方式(当`fill`为string时,才有意义)。 默认值: 'utf-8' | **返回值:** @@ -89,12 +94,6 @@ import buffer from '@ohos.buffer'; let buf1 = buffer.alloc(5); let buf2 = buffer.alloc(5, 'a'); let buf3 = buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); - -try { - let buf = buffer.alloc(-5); -} catch (err) { - console.log("alloc exception: " + JSON.stringify(err)); -} ``` ### allocUninitializedFromPool @@ -125,12 +124,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(10); buf.fill(0); - -try { - let buf = buffer.allocUninitializedFromPool(-5); -} catch (err) { - console.log("allocUninitializedFromPool exception: " + JSON.stringify(err)); -} ``` ### allocUninitialized @@ -160,12 +153,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitialized(10); buf.fill(0); - -try { - let buf = buffer.allocUninitialized(-5); -} catch (err) { - console.log("allocUninitialized exception: " + JSON.stringify(err)); -} ``` ### byteLength @@ -181,7 +168,7 @@ byteLength(string: string | Buffer | TypedArray | DataView | ArrayBuffer | Share | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | string | string \| Buffer \| TypedArray \| DataView \| ArrayBuffer \| SharedArrayBuffer | 是 | 指定字符串。 | -| encoding | BufferEncoding | 否 | 编码方式。 默认值: 'utf-8' | +| encoding | [BufferEncoding](#bufferencoding) | 否 | 编码方式。 默认值: 'utf-8' | **返回值:** @@ -197,12 +184,6 @@ import buffer from '@ohos.buffer'; let str = '\u00bd + \u00bc = \u00be'; console.log(`${str}: ${str.length} characters, ${buffer.byteLength(str, 'utf-8')} bytes`); // 打印: ½ + ¼ = ¾: 9 characters, 12 bytes - -try { - let byteLen = buffer.byteLength(10); -} catch (err) { - console.log("byteLength exception: " + JSON.stringify(err)); -} ``` ### compare @@ -236,14 +217,7 @@ let buf1 = buffer.from('1234'); let buf2 = buffer.from('0123'); let res = buf1.compare(buf2); -console.log(Number(res).toString()); -// 打印 1 - -try { - let res = buffer.compare(10, buf2); -} catch (err) { - console.log("compare exception: " + JSON.stringify(err)); -} +console.log(Number(res).toString()); // 打印 1 ``` ### concat @@ -284,18 +258,6 @@ let buf1 = buffer.from("1234"); let buf2 = buffer.from("abcd"); let buf = buffer.concat([buf1, buf2]); console.log(buf.toString('hex')); // 3132333461626364 - -try { - buf = buffer.concat("test string"); -} catch (err) { - console.log("concat exception: " + JSON.stringify(err)); -} - -try { - buf = buffer.concat([buf1, buf2], -1); -} catch (err) { - console.log("concat exception: " + JSON.stringify(err)); -} ``` ### from @@ -325,12 +287,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); console.log(buf.toString('hex')); // 627566666572 - -try { - const buf = buffer.from(10); -} catch (err) { - console.log("from exception: " + JSON.stringify(err)); -} ``` ### from @@ -378,11 +334,6 @@ array[1] = '2'; array[2] = '3'; array[3] = '4'; array[4] = '5'; -try { - const buf = buffer.from(arrayBuffer, 6, 1); -} catch (err) { - console.log("from exception: " + JSON.stringify(err)); -} ``` ### from @@ -412,12 +363,6 @@ import buffer from '@ohos.buffer'; let buf1 = buffer.from('buffer'); let buf2 = buffer.from(buf1); - -try { - const buf = buffer.from(10); -} catch (err) { - console.log("from exception: " + JSON.stringify(err)); -} ``` ### from @@ -448,12 +393,6 @@ from(object: Object, offsetOrEncoding: number | string, length: number): Buffer import buffer from '@ohos.buffer'; let buf = buffer.from(new String('this is a test')); - -try { - const buf = buffer.from(10, 0, 1); -} catch (err) { - console.log("from exception: " + JSON.stringify(err)); -} ``` ### from @@ -469,7 +408,7 @@ from(string: String, encoding?: BufferEncoding): Buffer | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | string | String | 是 | 字符串 | -| encoding | BufferEncoding | 否 | 编码格式。 默认值: 'utf-8'。 | +| encoding | [BufferEncoding](#bufferencoding) | 否 | 编码格式。 默认值: 'utf-8'。 | **返回值:** @@ -487,12 +426,6 @@ let buf2 = buffer.from('7468697320697320612074c3a97374', 'hex'); console.log(buf1.toString()); // 打印: this is a test console.log(buf2.toString()); - -try { - const buf = buffer.from("test string", "utf9"); -} catch (err) { - console.log("from exception: " + JSON.stringify(err)); -} ``` @@ -594,13 +527,6 @@ let buf2 = buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]); console.log(buf1.compare(buf2, 5, 9, 0, 4).toString()); // 打印: 0 console.log(buf1.compare(buf2, 0, 6, 4).toString()); // 打印: -1 console.log(buf1.compare(buf2, 5, 6, 5).toString()); // 打印: 1 - -let buf = buffer.from("1236"); -try { - let res = buf.compare(10); -} catch (err) { - console.log("compare exception: " + JSON.stringify(err)); -} ``` ### copy @@ -649,21 +575,6 @@ for (let i = 0; i < 26; i++) { buf1.copy(buf2, 8, 16, 20); console.log(buf2.toString('ascii', 0, 25)); // 打印: !!!!!!!!qrst!!!!!!!!!!!!! - -let buf3 = buffer.from("123656"); -try { - let num = buf3.copy(10); -} catch (err) { - console.log("copy exception: " + JSON.stringify(err)); -} - -let buf4 = buffer.from("123656"); -let buf5 = buffer.from("1235"); -try { - let num = buf4.copy(buf5, -1); -} catch (err) { - console.log("copy exception: " + JSON.stringify(err)); -} ``` ### entries @@ -716,12 +627,6 @@ let buf3 = buffer.from('ABCD'); console.log(buf1.equals(buf2).toString()); // 打印: true console.log(buf1.equals(buf3).toString()); // 打印: false - -try { - let res = buf1.equals("1236"); -} catch (err) { - console.log("equals exception: " + JSON.stringify(err)); -} ``` ### fill @@ -739,7 +644,7 @@ fill(value: string | Buffer | Uint8Array | number, offset?: number, end?: number | value | string \| Buffer \| Uint8Array \| number | 是 | 用于填充的值。 | | offset | number | 否 | 起始偏移量。 默认值: 0。 | | end | number | 否 | 结束偏移量(不包括在内)。 默认值: buf.length。 | -| encoding | BufferEncoding | 否 | 字符编码格式(`value`为string才有意义)。 默认值: 'utf-8'。 | +| encoding | [BufferEncoding](#bufferencoding) | 否 | 字符编码格式(`value`为string才有意义)。 默认值: 'utf-8'。 | **返回值:** @@ -762,12 +667,6 @@ import buffer from '@ohos.buffer'; let b = buffer.allocUninitializedFromPool(50).fill('h'); console.log(b.toString()); - -try { - let buf = buffer.alloc(3).fill("$*$", -1); -} catch (err) { - console.log("fill exception: " + JSON.stringify(err)); -} ``` @@ -785,7 +684,7 @@ includes(value: string | number | Buffer | Uint8Array, byteOffset?: number, enco | -------- | -------- | -------- | -------- | | value | string \| number \| Buffer \| Uint8Array | 是 | 要搜索的内容。 | | byteOffset | number | 否 | 字节偏移量。 如果为负数,则从末尾开始计算偏移量。 默认值: 0。 | -| encoding | BufferEncoding | 否 | 字符编码格式。 默认值: 'utf-8'。 | +| encoding | [BufferEncoding](#bufferencoding) | 否 | 字符编码格式。 默认值: 'utf-8'。 | **返回值:** @@ -801,13 +700,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.from('this is a buffer'); console.log(buf.includes('this').toString()); // 打印: true console.log(buf.includes('be').toString()); // 打印: false - -let buf1 = buffer.from("13236"); -try { - let flag = buf1.includes(true); -} catch (err) { - console.log("includes exception: " + JSON.stringify(err)); -} ``` ### indexOf @@ -824,7 +716,7 @@ indexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encod | -------- | -------- | -------- | -------- | | value | string \| number \| Buffer \| Uint8Array | 是 | 要搜索的内容。 | | byteOffset | number | 否 | 字节偏移量。 如果为负数,则从末尾开始计算偏移量。 默认值: 0。 | -| encoding | BufferEncoding | 否 | 字符编码格式。 默认值: 'utf-8'。 | +| encoding | [BufferEncoding](#bufferencoding) | 否 | 字符编码格式。 默认值: 'utf-8'。 | **返回值:** @@ -840,19 +732,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.from('this is a buffer'); console.log(buf.indexOf('this').toString()); // 打印: 0 console.log(buf.indexOf('is').toString()); // 打印: 2 - -let buf1 = buffer.from("13236"); -try { - let index = buf1.indexOf(true); -} catch (err) { - console.log("indexOf exception: " + JSON.stringify(err)); -} - -try { - let index1 = buf1.indexOf("a", "utf9"); -} catch (err) { - console.log("indexOf exception: " + JSON.stringify(err)); -} ``` ### keys @@ -894,7 +773,7 @@ lastIndexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, e | -------- | -------- | -------- | -------- | | value | string \| number \| Buffer \| Uint8Array | 是 | 要搜索的内容。 | | byteOffset | number | 否 | 字节偏移量。 如果为负数,则从末尾开始计算偏移量。 默认值: 0。 | -| encoding | BufferEncoding | 否 | 字符编码格式。 默认值: 'utf-8'。 | +| encoding | [BufferEncoding](#bufferencoding) | 否 | 字符编码格式。 默认值: 'utf-8'。 | **返回值:** @@ -910,20 +789,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.from('this buffer is a buffer'); console.log(buf.lastIndexOf('this').toString()); // 打印: 0 console.log(buf.lastIndexOf('buffer').toString()); // 打印: 17 - -let buf1 = buffer.from("13236"); -try { - let index = buf1.lastIndexOf(true); -} catch (err) { - console.log("lastIndexOf exception: " + JSON.stringify(err)); -} - -try { - let index1 = buf1.lastIndexOf("a", "utf9"); -} catch (err) { - console.log("lastIndexOf exception: " + JSON.stringify(err)); -} - ``` @@ -966,11 +831,6 @@ console.log(buf.readBigInt64BE(0).toString()); let buf1 = buffer.allocUninitializedFromPool(8); buf1.writeBigInt64BE(0x0102030405060708n, 0); -try { - let ref = buf1.readBigInt64BE(1).toString(16); -} catch (err) { - console.log("readBigInt64BE exception: " + JSON.stringify(err)); -} ``` ### readBigInt64LE @@ -1012,11 +872,6 @@ console.log(buf.readBigInt64LE(0).toString()); let buf1 = buffer.allocUninitializedFromPool(8); buf1.writeBigInt64BE(0x0102030405060708n, 0); -try { - let ref = buf1.readBigInt64LE(1).toString(16); -} catch (err) { - console.log("readBigInt64LE exception: " + JSON.stringify(err)); -} ``` ### readBigUInt64BE @@ -1058,11 +913,6 @@ console.log(buf.readBigUInt64BE(0).toString()); let buf1 = buffer.allocUninitializedFromPool(8); buf1.writeBigUInt64BE(0xdecafafecacefaden, 0); -try { - let ref = buf1.readBigUInt64BE(1).toString(16); -} catch (err) { - console.log("readBigUInt64BE exception: " + JSON.stringify(err)); -} ``` ### readBigUInt64LE @@ -1104,11 +954,6 @@ console.log(buf.readBigUInt64LE(0).toString()); let buf1 = buffer.allocUninitializedFromPool(8); buf1.writeBigUInt64BE(0xdecafafecacefaden, 0); -try { - let ref = buf1.readBigUInt64LE(1).toString(16); -} catch (err) { - console.log("readBigUInt64LE exception: " + JSON.stringify(err)); -} ``` ### readDoubleBE @@ -1149,11 +994,6 @@ console.log(buf.readDoubleBE(0).toString()); let buf1 = buffer.allocUninitializedFromPool(8); buf1.writeDoubleBE(123.456, 0); -try { - let ref = buf1.readDoubleBE(1); -} catch (err) { - console.log("readDoubleBE exception: " + JSON.stringify(err)); -} ``` ### readDoubleLE @@ -1194,11 +1034,6 @@ console.log(buf.readDoubleLE(0).toString()); let buf1 = buffer.allocUninitializedFromPool(8); buf1.writeDoubleLE(123.456, 0); -try { - let ref = buf1.readDoubleLE(1); -} catch (err) { - console.log("readDoubleLE exception: " + JSON.stringify(err)); -} ``` ### readFloatBE @@ -1239,11 +1074,6 @@ console.log(buf.readFloatBE(0).toString()); let buf1 = buffer.allocUninitializedFromPool(4); buf1.writeFloatBE(0xcabcbcbc, 0); -try { - let ref = buf1.readFloatBE(1).toString(16); -} catch (err) { - console.log("readFloatBE exception: " + JSON.stringify(err)); -} ``` ### readFloatLE @@ -1284,11 +1114,6 @@ console.log(buf.readFloatLE(0).toString()); let buf1 = buffer.allocUninitializedFromPool(4); buf1.writeFloatLE(0xcabcbcbc, 0); -try { - let ref = buf1.readFloatLE(1).toString(16); -} catch (err) { - console.log("readFloatLE exception: " + JSON.stringify(err)); -} ``` ### readInt8 @@ -1330,11 +1155,6 @@ console.log(buf.readInt8(1).toString()); // 打印: 5 let buf1 = buffer.allocUninitializedFromPool(2); buf1.writeInt8(0x12); -try { - let ref = buf1.readInt8(2).toString(16); -} catch (err) { - console.log("readInt8 exception: " + JSON.stringify(err)); -} ``` ### readInt16BE @@ -1375,11 +1195,6 @@ console.log(buf.readInt16BE(0).toString()); // 打印: 5 let buf1 = buffer.alloc(2); buf1.writeInt16BE(0x1234, 0); -try { - let ref = buf1.readInt16BE(1).toString(16); -} catch (err) { - console.log("readInt16BE exception: " + JSON.stringify(err)); -} ``` ### readInt16LE @@ -1420,11 +1235,6 @@ console.log(buf.readInt16LE(0).toString()); // 打印: 1280 let buf1 = buffer.alloc(2); buf1.writeInt16BE(0x1234, 0); -try { - let ref = buf1.readInt16LE(1); -} catch (err) { - console.log("readInt16LE exception: " + JSON.stringify(err)); -} ``` ### readInt32BE @@ -1465,11 +1275,6 @@ console.log(buf.readInt32BE(0).toString()); // 打印: 5 let buf1 = buffer.alloc(4); buf1.writeInt32BE(0x12345678, 0); -try { - let ref = buf1.readInt32BE(1); -} catch (err) { - console.log("readInt32BE exception: " + JSON.stringify(err)); -} ``` ### readInt32LE @@ -1510,11 +1315,6 @@ console.log(buf.readInt32LE(0).toString()); // 打印: 83886080 let buf1 = buffer.alloc(4); buf1.writeInt32BE(0x12345678, 0); -try { - let ref = buf1.readInt32LE(1); -} catch (err) { - console.log("readInt32LE exception: " + JSON.stringify(err)); -} ``` ### readIntBE @@ -1558,11 +1358,6 @@ console.log(num.toString()); // 97 let buf1 = buffer.allocUninitializedFromPool(6); buf1.writeIntBE(0x123456789011, 0, 6); -try { - let ref = buf1.readIntBE(2, 5).toString(16); -} catch (err) { - console.log("readIntBE exception: " + JSON.stringify(err)); -} ``` @@ -1606,11 +1401,6 @@ console.log(buf.readIntLE(0, 6).toString(16)); let buf1 = buffer.allocUninitializedFromPool(6); buf1.writeIntLE(0x123456789011, 0, 6); -try { - let ref = buf1.readIntLE(2, 5).toString(16); -} catch (err) { - console.log("readIntBE exception: " + JSON.stringify(err)); -} ``` ### readUInt8 @@ -1653,11 +1443,6 @@ console.log(buf.readUInt8(1).toString()); let buf1 = buffer.allocUninitializedFromPool(4); buf1.writeUInt8(0x42); -try { - let ref = buf1.readUInt8(4).toString(16); -} catch (err) { - console.log("readUInt8 exception: " + JSON.stringify(err)); -} ``` ### readUInt16BE @@ -1700,11 +1485,6 @@ console.log(buf.readUInt16BE(1).toString(16)); let buf1 = buffer.allocUninitializedFromPool(4); buf1.writeUInt16BE(0x1234, 0); -try { - let ref = buf1.readUInt16BE(3).toString(16); -} catch (err) { - console.log("readUInt16BE exception: " + JSON.stringify(err)); -} ``` ### readUInt16LE @@ -1747,11 +1527,6 @@ console.log(buf.readUInt16LE(1).toString(16)); let buf1 = buffer.allocUninitializedFromPool(4); buf1.writeUInt16LE(0x1234, 0); -try { - let ref = buf1.readUInt16LE(3).toString(16); -} catch (err) { - console.log("readUInt16LE exception: " + JSON.stringify(err)); -} ``` ### readUInt32BE @@ -1793,11 +1568,6 @@ console.log(buf.readUInt32BE(0).toString(16)); let buf1 = buffer.allocUninitializedFromPool(4); buf1.writeUInt32BE(0x12345678, 0); -try { - let ref = buf1.readUInt32BE(1).toString(16); -} catch (err) { - console.log("readUInt32BE exception: " + JSON.stringify(err)); -} ``` ### readUInt32LE @@ -1839,11 +1609,6 @@ console.log(buf.readUInt32LE(0).toString(16)); let buf1 = buffer.allocUninitializedFromPool(4); buf1.writeUInt32LE(0x12345678, 0); -try { - let ref = buf1.readUInt32LE(1).toString(16); -} catch (err) { - console.log("readUInt32LE exception: " + JSON.stringify(err)); -} ``` ### readUIntBE @@ -1886,11 +1651,6 @@ console.log(buf.readUIntBE(0, 6).toString(16)); let buf1 = buffer.allocUninitializedFromPool(4); buf1.writeUIntBE(0x13141516, 0, 4); -try { - let ref = buf1.readUIntBE(2, 3).toString(16); -} catch (err) { - console.log("readUIntBE exception: " + JSON.stringify(err)); -} ``` ### readUIntLE @@ -1933,11 +1693,6 @@ console.log(buf.readUIntLE(0, 6).toString(16)); let buf1 = buffer.allocUninitializedFromPool(4); buf1.writeUIntLE(0x13141516, 0, 4); -try { - let ref = buf1.readUIntLE(2, 3).toString(16); -} catch (err) { - console.log("readUIntLE exception: " + JSON.stringify(err)); -} ``` ### subarray @@ -2009,13 +1764,6 @@ console.log(buf1.toString('hex')); // 打印: 0102030405060708 buf1.swap16(); console.log(buf1.toString('hex')); // 打印: 0201040306050807 - -let buf2 = buffer.from("132"); -try { - buf2.swap16(); -} catch (err) { - console.log("swap16 exception: " + JSON.stringify(err)); -} ``` ### swap32 @@ -2051,13 +1799,6 @@ console.log(buf1.toString('hex')); // 打印: 0102030405060708 buf1.swap32(); console.log(buf1.toString('hex')); // 打印: 0403020108070605 - -let buf2 = buffer.from("132"); -try { - buf2.swap32(); -} catch (err) { - console.log("swap32 exception: " + JSON.stringify(err)); -} ``` ### swap64 @@ -2092,13 +1833,6 @@ let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); console.log(buf1.toString('hex')); // 打印: 0102030405060708 buf1.swap64(); console.log(buf1.toString('hex')); // 打印: 0807060504030201 - -let buf2 = buffer.from("1234567"); -try { - buf2.swap64(); -} catch (err) { - console.log("swap64 exception: " + JSON.stringify(err)); -} ``` ### toJSON @@ -2160,13 +1894,6 @@ for (let i = 0; i < 26; i++) { } console.log(buf1.toString('utf-8')); // 打印: abcdefghijklmnopqrstuvwxyz - -let buf2 = buffer.from("abc"); -try { - let str = buf2.toString("utf9"); -} catch (err) { - console.log("toString exception: " + JSON.stringify(err)); -} ``` ### values @@ -2196,7 +1923,7 @@ for (let value of buf1.values()) { ### 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 @@ -2209,7 +1936,7 @@ write(str: string, offset?: number, length?: number, encoding?: BufferEncoding): | str | string | 是 | 要写入Buffer的字符串。 | | offset | number | 否 | 偏移量。 默认值: 0。 | | length | number | 否 | 最大字节长度。 默认值: (buf.length - offset)。| -| encoding | BufferEncoding | 否 | 字符编码。 默认值: 'utf-8'。 | +| encoding | string | 否 | 字符编码。 默认值: 'utf-8'。 | **返回值:** @@ -2238,27 +1965,6 @@ console.log(`${len} bytes: ${buf.toString('utf-8', 0, len)}`); let buffer1 = buffer.alloc(10); let length = buffer1.write('abcd', 8); - -let buf1 = buffer.alloc(8); -try { - let offset1 = buf1.write("abcde", "utf9"); -} catch (err) { - console.log("write exception: " + JSON.stringify(err)); -} - -let buf2 = buffer.alloc(8); -try { - let offset2 = buf2.write(10); -} catch (err) { - console.log("write exception: " + JSON.stringify(err)); -} - -let buf3 = buffer.alloc(8); -try { - let offset3 = buf3.write("abcde", -1); -} catch (err) { - console.log("write exception: " + JSON.stringify(err)); -} ``` ### writeBigInt64BE @@ -2298,13 +2004,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(8); buf.writeBigInt64BE(0x0102030405060708n, 0); - -let buf1 = buffer.allocUninitializedFromPool(8); -try { - let ref = buf1.writeBigInt64BE(0x0102030405060708n, 1); -} catch (err) { - console.log("writeBigInt64BE exception: " + JSON.stringify(err)); -} ``` ### writeBigInt64LE @@ -2344,13 +2043,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(8); buf.writeBigInt64LE(0x0102030405060708n, 0); - -let buf1 = buffer.allocUninitializedFromPool(8); -try { - let ref = buf1.writeBigInt64LE(0x0102030405060708n, 1); -} catch (err) { - console.log("writeBigInt64LE exception: " + JSON.stringify(err)); -} ``` ### writeBigUInt64BE @@ -2390,13 +2082,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(8); buf.writeBigUInt64BE(0xdecafafecacefaden, 0); - -let buf1 = buffer.allocUninitializedFromPool(8); -try { - let ref = buf1.writeBigUInt64BE(0xdecafafecacefaden, 1); -} catch (err) { - console.log("writeBigUInt64BE exception: " + JSON.stringify(err)); -} ``` ### writeBigUInt64LE @@ -2436,13 +2121,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(8); buf.writeBigUInt64LE(0xdecafafecacefaden, 0); - -let buf1 = buffer.allocUninitializedFromPool(8); -try { - let ref = buf1.writeBigUInt64LE(0xdecafafecacefaden, 1); -} catch (err) { - console.log("writeBigUInt64LE exception: " + JSON.stringify(err)); -} ``` ### writeDoubleBE @@ -2482,13 +2160,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(8); buf.writeDoubleBE(123.456, 0); - -let buf1 = buffer.allocUninitializedFromPool(8); -try { - let ref = buf1.writeDoubleBE(123.456, 1); -} catch (err) { - console.log("writeDoubleBE exception: " + JSON.stringify(err)); -} ``` ### writeDoubleLE @@ -2528,13 +2199,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(8); buf.writeDoubleLE(123.456, 0); - -let buf1 = buffer.allocUninitializedFromPool(8); -try { - let ref = buf1.writeDoubleLE(123.456, 1); -} catch (err) { - console.log("writeDoubleLE exception: " + JSON.stringify(err)); -} ``` ### writeFloatBE @@ -2574,13 +2238,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(8); buf.writeFloatBE(0xcafebabe, 0); - -let buf1 = buffer.allocUninitializedFromPool(4); -try { - let ref = buf1.writeFloatBE(0xcabcbcbc, 5); -} catch (err) { - console.log("writeFloatBE exception: " + JSON.stringify(err)); -} ``` @@ -2621,13 +2278,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(8); buf.writeFloatLE(0xcafebabe, 0); - -let buf1 = buffer.allocUninitializedFromPool(4); -try { - let ref = buf1.writeFloatLE(0xcabcbcbc, 5); -} catch (err) { - console.log("writeFloatLE exception: " + JSON.stringify(err)); -} ``` ### writeInt8 @@ -2668,13 +2318,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(2); buf.writeInt8(2, 0); buf.writeInt8(-2, 1); - -let buf1 = buffer.allocUninitializedFromPool(2); -try { - let ref = buf1.writeInt8(2, -1); -} catch (err) { - console.log("writeInt8 exception: " + JSON.stringify(err)); -} ``` @@ -2715,13 +2358,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(2); buf.writeInt16BE(0x0102, 0); - -let buf1 = buffer.alloc(2); -try { - let ref = buf1.writeInt16BE(0x7bca, -1); -} catch (err) { - console.log("writeInt16BE exception: " + JSON.stringify(err)); -} ``` @@ -2762,13 +2398,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(2); buf.writeInt16LE(0x0304, 0); - -let buf1 = buffer.alloc(2); -try { - let ref = buf1.writeInt16LE(0x7bca, -1); -} catch (err) { - console.log("writeInt16LE exception: " + JSON.stringify(err)); -} ``` ### writeInt32BE @@ -2808,13 +2437,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(4); buf.writeInt32BE(0x01020304, 0); - -let buf1 = buffer.alloc(4); -try { - let ref = buf1.writeInt32BE(0x12345678, -1); -} catch (err) { - console.log("writeInt32BE exception: " + JSON.stringify(err)); -} ``` @@ -2855,13 +2477,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(4); buf.writeInt32LE(0x05060708, 0); - -let buf1 = buffer.alloc(4); -try { - let ref = buf1.writeInt32LE(0x12345678, -1); -} catch (err) { - console.log("writeInt32LE exception: " + JSON.stringify(err)); -} ``` ### writeIntBE @@ -2902,13 +2517,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(6); buf.writeIntBE(0x1234567890ab, 0, 6); - -let buf1 = buffer.allocUninitializedFromPool(6); -try { - let ref = buf1.writeIntBE(0x1234567890ab, 1, 6); -} catch (err) { - console.log("writeIntBE exception: " + JSON.stringify(err)); -} ``` @@ -2950,13 +2558,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(6); buf.writeIntLE(0x1234567890ab, 0, 6); - -let buf1 = buffer.allocUninitializedFromPool(6); -try { - let ref = buf1.writeIntLE(0x1234567890ab, 1, 6); -} catch (err) { - console.log("writeIntLE exception: " + JSON.stringify(err)); -} ``` ### writeUInt8 @@ -2999,13 +2600,6 @@ buf.writeUInt8(0x3, 0); buf.writeUInt8(0x4, 1); buf.writeUInt8(0x23, 2); buf.writeUInt8(0x42, 3); - -let buf1 = buffer.allocUninitializedFromPool(4); -try { - let ref = buf1.writeUInt8(0x42, -1); -} catch (err) { - console.log("writeUInt8 exception: " + JSON.stringify(err)); -} ``` ### writeUInt16BE @@ -3046,13 +2640,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(4); buf.writeUInt16BE(0xdead, 0); buf.writeUInt16BE(0xbeef, 2); - -let buf1 = buffer.allocUninitializedFromPool(4); -try { - let ref = buf1.writeUInt16BE(0xdeadfc, 0); -} catch (err) { - console.log("writeUInt16BE exception: " + JSON.stringify(err)); -} ``` ### writeUInt16LE @@ -3093,13 +2680,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(4); buf.writeUInt16LE(0xdead, 0); buf.writeUInt16LE(0xbeef, 2); - -let buf1 = buffer.allocUninitializedFromPool(4); -try { - let ref = buf1.writeUInt16LE(0xdeadfc, 0); -} catch (err) { - console.log("writeUInt16LE exception: " + JSON.stringify(err)); -} ``` ### writeUInt32BE @@ -3139,13 +2719,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(4); buf.writeUInt32BE(0xfeedface, 0); - -let buf1 = buffer.allocUninitializedFromPool(4); -try { - let ref = buf1.writeUInt32BE(0xfeedface, -1); -} catch (err) { - console.log("writeUInt32BE exception: " + JSON.stringify(err)); -} ``` ### writeUInt32LE @@ -3185,13 +2758,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(4); buf.writeUInt32LE(0xfeedface, 0); - -let buf1 = buffer.allocUninitializedFromPool(4); -try { - let ref = buf1.writeUInt32LE(0xfeedface, -1); -} catch (err) { - console.log("writeUInt32LE exception: " + JSON.stringify(err)); -} ``` ### writeUIntBE @@ -3232,13 +2798,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(6); buf.writeUIntBE(0x1234567890ab, 0, 6); - -let buf1 = buffer.allocUninitializedFromPool(4); -try { - let ref = buf1.writeUIntBE(0x13141516, 0, 1); -} catch (err) { - console.log("writeUIntBE exception: " + JSON.stringify(err)); -} ``` ### writeUIntLE @@ -3279,13 +2838,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(6); buf.writeUIntLE(0x1234567890ab, 0, 6); - -let buf1 = buffer.allocUninitializedFromPool(4); -try { - let ref = buf1.writeUIntLE(0x13141516, 0, 1); -} catch (err) { - console.log("writeUIntLE exception: " + JSON.stringify(err)); -} ``` ### transcode @@ -3318,25 +2870,6 @@ import buffer from '@ohos.buffer'; let buf = buffer.alloc(50); let newBuf = buffer.transcode(buffer.from('€'), 'utf-8', 'ascii'); console.log(newBuf.toString('ascii')); - -try { - let buf1 = buffer.transcode(10, "utf8", "ucs2"); -} catch (err) { - console.log("transcode exception: " + JSON.stringify(err)); -} - -let buf2 = buffer.from("测试"); -try { - let buf3 = buffer.transcode(buf2, 0, "ucs2"); -} catch (err) { - console.log("transcode exception: " + JSON.stringify(err)); -} - -try { - let buf3 = buffer.transcode(buf2, "utf8", 0); -} catch (err) { - console.log("transcode exception: " + JSON.stringify(err)); -} ``` ## Blob @@ -3367,24 +2900,12 @@ Blob的构造函数。 **示例:** - ```ts - import buffer from '@ohos.buffer'; - - let blob = new buffer.Blob(['a', 'b', 'c']); - let blob1 = new buffer.Blob(['a', 'b', 'c'], {endings:'native', type: 'MIME'}); - - try { - let blob1 = new buffer.Blob(["a", "b", "c"], 10); - } catch (err) { - console.log("Blob constructor exception: " + JSON.stringify(err)); - } +```ts +import buffer from '@ohos.buffer'; - try { - let blob2 = new buffer.Blob("abc", { type: "new type", endings: "transparent" }); - } catch (err) { - console.log("Blob constructor exception: " + JSON.stringify(err)); - } - ``` +let blob = new buffer.Blob(['a', 'b', 'c']); +let blob1 = new buffer.Blob(['a', 'b', 'c'], {endings:'native', type: 'MIME'}); +``` ### encode @@ -3400,14 +2921,14 @@ arrayBuffer(): Promise<ArrayBuffer> | Promise<ArrayBuffer> | 返回包含Blob数据的ArrayBuffer的Promise。 | **示例:** - ```ts - let blob = new buffer.Blob(['a', 'b', 'c']); - let pro = blob.arrayBuffer(); - pro.then(val => { - let uintarr = new Uint8Array(val); - console.log(uintarr.toString()); - }); - ``` +```ts +let blob = new buffer.Blob(['a', 'b', 'c']); +let pro = blob.arrayBuffer(); +pro.then(val => { + let uintarr = new Uint8Array(val); + console.log(uintarr.toString()); +}); +``` ### slice slice(start?: number, end?: number, type?: string): Blob @@ -3430,11 +2951,11 @@ slice(start?: number, end?: number, type?: string): Blob | Blob | 新的Blob实例对象。 | **示例:** - ```ts - let blob = new buffer.Blob(['a', 'b', 'c']); - let blob2 = blob.slice(0, 2); - let blob3 = blob.slice(0, 2, "MIME"); - ``` +```ts +let blob = new buffer.Blob(['a', 'b', 'c']); +let blob2 = blob.slice(0, 2); +let blob3 = blob.slice(0, 2, "MIME"); +``` ### text @@ -3450,10 +2971,10 @@ text(): Promise<string> | Promise<string> | 包含以UTF8编码的文本的Promise。 | **示例:** - ```ts - let blob = new buffer.Blob(['a', 'b', 'c']); - let pro = blob.text(); - pro.then(val => { - console.log(val) - }); - ``` \ No newline at end of file +```ts +let blob = new buffer.Blob(['a', 'b', 'c']); +let pro = blob.text(); +pro.then(val => { + console.log(val) +}); +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md index 2fa78df889c3b29a0c2b7c3e993e5ff22233b778..7de063bca0d78be314e1cf0260748efe23ab532d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md @@ -13,32 +13,32 @@ Ability信息,未做特殊说明的属性,均通过GET_BUNDLE_DEFAULT获取 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 名称 | 类型 | 可读 | 可写 | 说明 | -| --------------------- | -------------------------------------------------------- | ---- | ---- | ----------------------------------------- | -| bundleName | string | 是 | 否 | 应用包名 | -| name | string | 是 | 否 | Ability名称 | -| label | string | 是 | 否 | Ability对用户显示的名称 | -| description | string | 是 | 否 | Ability的描述 | -| icon | string | 是 | 否 | Ability的图标资源文件索引 | -| descriptionId | number | 是 | 否 | Ability的描述id | -| iconId | number | 是 | 否 | Ability的图标id | -| moduleName | string | 是 | 否 | Ability所属的HAP包的名称 | -| process | string | 是 | 否 | Ability的进程,如果不设置,默认为包的名称 | -| targetAbility | string | 是 | 否 | 当前Ability重用的目标Ability
此属性仅可在FA模型下使用 | -| backgroundModes | number | 是 | 否 | 表示后台服务的类型
此属性仅可在FA模型下使用 | -| isVisible | boolean | 是 | 否 | 判断Ability是否可以被其他应用调用 | -| formEnabled | boolean | 是 | 否 | 判断Ability是否提供卡片能力
此属性仅可在FA模型下使用 | -| type | AbilityType | 是 | 否 | Ability类型
此属性仅可在FA模型下使用 | -| orientation | DisplayOrientation | 是 | 否 | Ability的显示模式 | -| launchMode | LaunchMode | 是 | 否 | Ability的启动模式 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------------- | -------------------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | +| bundleName | string | 是 | 否 | 应用包名 | +| name | string | 是 | 否 | Ability名称 | +| label | string | 是 | 否 | Ability对用户显示的名称 | +| description | string | 是 | 否 | Ability的描述 | +| icon | string | 是 | 否 | Ability的图标资源文件索引 | +| descriptionId | number | 是 | 否 | Ability的描述id | +| iconId | number | 是 | 否 | Ability的图标id | +| moduleName | string | 是 | 否 | Ability所属的HAP包的名称 | +| process | string | 是 | 否 | Ability的进程,如果不设置,默认为包的名称 | +| targetAbility | string | 是 | 否 | 当前Ability重用的目标Ability
此属性仅可在FA模型下使用 | +| backgroundModes | number | 是 | 否 | 表示后台服务的类型
此属性仅可在FA模型下使用 | +| isVisible | boolean | 是 | 否 | 判断Ability是否可以被其他应用调用 | +| formEnabled | boolean | 是 | 否 | 判断Ability是否提供卡片能力
此属性仅可在FA模型下使用 | +| type | bundle.AbilityType | 是 | 否 | Ability类型
此属性仅可在FA模型下使用 | +| orientation | bundle.DisplayOrientation | 是 | 否 | Ability的显示模式 | +| launchMode | bundle.LaunchMode | 是 | 否 | Ability的启动模式 | | permissions | Array\ | 是 | 否 | 被其他应用Ability调用时需要申请的权限集合
通过传入GET_ABILITY_INFO_WITH_PERMISSION获取 | -| deviceTypes | Array\ | 是 | 否 | Ability支持的设备类型 | -| deviceCapabilities | Array\ | 是 | 否 | Ability需要的设备能力 | -| readPermission | string | 是 | 否 | 读取Ability数据所需的权限
此属性仅可在FA模型下使用 | -| writePermission | string | 是 | 否 | 向Ability写数据所需的权限
此属性仅可在FA模型下使用 | +| deviceTypes | Array\ | 是 | 否 | Ability支持的设备类型 | +| deviceCapabilities | Array\ | 是 | 否 | Ability需要的设备能力 | +| readPermission | string | 是 | 否 | 读取Ability数据所需的权限
此属性仅可在FA模型下使用 | +| writePermission | string | 是 | 否 | 向Ability写数据所需的权限
此属性仅可在FA模型下使用 | | applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | 否 | 应用程序的配置信息
通过传入GET_ABILITY_INFO_WITH_APPLICATION获取 | | uri | string | 是 | 否 | 获取Ability的统一资源标识符(URI)
此属性仅可在FA模型下使用 | -| labelId | number | 是 | 否 | Ability的标签id | -| subType | AbilitySubType | 是 | 否 | Ability中枚举使用的模板的子类型
此属性仅可在FA模型下使用 | -| metadata8+ | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | 是 | 否 | ability的元信息
通过传入GET_ABILITY_INFO_WITH_METADATA获取 | -| enabled8+ | boolean | 是 | 否 | ability是否可用 | \ No newline at end of file +| labelId | number | 是 | 否 | Ability的标签id | +| subType | bundle.AbilitySubType | 是 | 否 | Ability中枚举使用的模板的子类型
此属性仅可在FA模型下使用 | +| metadata8+ | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | 是 | 否 | ability的元信息
通过传入GET_ABILITY_INFO_WITH_METADATA获取 | +| enabled8+ | boolean | 是 | 否 | ability是否可用 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md index 785b892076bc1bd7226501b2372eadd05da25678..eed36b5c390982d6146d05e43a6b9e4a26eb223b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md @@ -25,7 +25,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | | bundleFilePaths | Array<string> | 是 | 指示存储应用程序包的路径。路径应该是当前应用程序的数据目录的相对路径。 | | param | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 | @@ -51,7 +51,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | bundleName | string | 是 | 包名 | | param | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 | @@ -77,7 +77,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | bundleName | string | 是 | 包名 | | param | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md index f6f6c7f55cca6dd02909085134ae24c1723ba21a..be617aafe7ad5a6245f997245ad837e96d50e765 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md @@ -1,9 +1,8 @@ # ShortcutInfo(deprecated) -> 从API version 9开始不再维护,建议使用[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)替代 -> **说明:** -> + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md index 831e412913495983681409371a4572a81400dfd0..6922e72eb6ab0ea69f2655454f428e13373841e2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md @@ -206,10 +206,6 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo]( | ----------------------------------------------------------- | ------------------------------------- | | Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回当前应用的BundleInfo。| -**错误码:** - -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 - **示例:** ```ts @@ -241,10 +237,6 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息。 | | callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的当前应用的BundleInfo;否则为错误对象。 | -**错误码:** - -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 - **示例:** ```ts @@ -292,7 +284,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: | 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 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. | **示例:** @@ -364,6 +356,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< | 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | | 17700026 | The specified bundle is disabled. | **示例:** @@ -419,7 +412,7 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n | 错误码ID | 错误信息 | | -------- | --------------------------------------| | 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. | **示例:** @@ -487,10 +480,10 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use | 错误码ID | 错误信息 | | -------- | --------------------------------------| | 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. | -**示例:** +**示例:** ```ts import bundleManager from '@ohos.bundle.bundleManager' @@ -538,6 +531,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal | 错误码ID | 错误信息 | | -------- | --------------------------------------| | 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | | 17700026 | The specified bundle is disabled. | **示例:** @@ -593,7 +587,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use | 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 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. | **示例:** @@ -641,7 +635,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A | 错误码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): void; | 错误码ID | 错误信息 | | -------- | ------------------------------------------------------------ | | 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. | **示例:** @@ -1551,7 +1555,7 @@ cleanBundleCacheFiles(bundleName: string): Promise\; | 错误码ID | 错误信息 | | -------- | ---------------------------------------------------------- | | 17700001 | The specified bundleName is not found. | -| 17700030 | The specified bundle 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 | 错误码ID | 错误信息 | | -------- | --------------------------------------| | 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. | **示例:** @@ -2078,6 +2082,7 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\): void | 错误码ID | 错误信息 | | -------- | --------------------------------------| | 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | | 17700026 | The specified bundle is disabled. | **示例:** @@ -2131,7 +2136,7 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\; | 错误码ID | 错误信息 | | -------- | --------------------------------------| | 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. | **示例:** @@ -2177,7 +2182,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName 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. | | 17700029 | The specified ability is disabled. | @@ -2232,7 +2237,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName 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. | | 17700029 | The specified ability is disabled. | @@ -2280,11 +2285,11 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ | -| moduleName | string | 是 | 表示应用程序的moduleName。 | -| extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName。 | -| metadataName | string | 是 | 表示应用程序的metadataName。 | +| moduleName | string | 是 | 表示应用程序的moduleName。 | +| extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName。 | +| metadataName | string | 是 | 表示应用程序的metadataName。 | | callback | AsyncCallback> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\;否则为错误对象。 | **错误码:** @@ -2294,8 +2299,8 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m | 错误码ID | 错误信息 | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed. | -| 17700003 | The specified extensionAbilityName is not existed. | -| 17700024 | The specified metadataName is not existed or the profile is not json-format. | +| 17700003 | The specified extensionAbilityName not existed. | +| 17700024 | Failed to get the profile because there is no profile in the HAP. | | 17700026 | The specified bundle is disabled. | **示例:** @@ -2329,7 +2334,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------ | ---- | ---------------------------------- | | moduleName | string | 是 | 表示应用程序的moduleName。 | | extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName。 | @@ -2348,8 +2353,8 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m | 错误码ID | 错误信息 | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed. | -| 17700003 | The specified extensionAbilityName is not existed. | -| 17700024 | The specified metadataName is not existed or the profile is not json-format. | +| 17700003 | The specified extensionAbilityName not existed. | +| 17700024 | Failed to get the profile because there is no profile in the HAP. | | 17700026 | The specified bundle is disabled. | **示例:** @@ -2395,9 +2400,9 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| permissionName | string | 是 | 表示权限名称。 | +| permissionName | string | 是 | 表示权限名称。 | | callback | AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\;否则为错误对象。 | **错误码:** @@ -2440,7 +2445,7 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------------- | ------ | ---- | -------------- | | permissionName | string | 是 | 表示权限参数名。 | @@ -2729,7 +2734,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num | 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 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. | **示例:** @@ -2830,7 +2835,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId | 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 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. | **示例:** @@ -2881,6 +2886,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [Bund | 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | | 17700026 | The specified bundle is disabled. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md b/zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md index 49b782bf5001832ff1b73d19b19f623460f31ae9..36940069382ecbecf5d4149357bcced22b87aa3d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md @@ -37,11 +37,11 @@ on(type: BundleChangedEvent, callback: Callback\): void; 注册监听应用的安装,卸载,更新。 -**需要权限:**ohos.permission.LISTEN_BUNDLE_CHANGE +**需要权限:** ohos.permission.LISTEN_BUNDLE_CHANGE **系统API:** 此接口为系统接口,三方应用不支持调用 -**系统能力:**SystemCapability.BundleManager.BundleFramework.Core +**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **参数:** @@ -50,10 +50,6 @@ on(type: BundleChangedEvent, callback: Callback\): void; | BundleChangedEvent | string | 是 | 注册监听的事件类型。 | | Callback\ | callback | 是 | 注册监听的回调函数。 | -**错误码:** - -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 - **示例:** ```ts @@ -74,11 +70,11 @@ off(type: BundleChangedEvent, callback?: Callback\): void; 注销监听应用的安装,卸载,更新。 -**需要权限:**ohos.permission.LISTEN_BUNDLE_CHANGE +**需要权限:** ohos.permission.LISTEN_BUNDLE_CHANGE **系统API:** 此接口为系统接口,三方应用不支持调用 -**系统能力:**SystemCapability.BundleManager.BundleFramework.Core +**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **参数:** @@ -87,10 +83,6 @@ off(type: BundleChangedEvent, callback?: Callback\): void; | BundleChangedEvent | string | 是 | 注销监听的事件类型。 | | Callback\ | callback | 是 | 注销监听的回调函数,当为空时表示注销当前事件的所有callback。 | -**错误码:** - -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 - **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md b/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md index f5a241b2dbf92f80d280f13ae4f363cf46a458fe..662a9af618a06d34717e3ff7104db8fe068c5cd7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md @@ -5,7 +5,6 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - ## 导入模块 ``` @@ -18,7 +17,7 @@ import cardEmulation from '@ohos.nfc.cardEmulation'; **系统能力**:SystemCapability.Communication.NFC.Core -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | -------- | -------- | | HCE | 0 | HCE 卡模拟。 | | UICC | 1 | SIM 卡模拟。 | @@ -40,9 +39,9 @@ isSupported(feature: number): boolean **返回值:** - | **类型** | **说明** | - | -------- | -------- | - | boolean | true: 支持该类型卡模拟, false: 不支持该类型卡模拟。 | +| **类型** | **说明** | +| -------- | -------- | +| boolean | true: 支持该类型卡模拟, false: 不支持该类型卡模拟。| ## HceService8+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-config-policy.md b/zh-cn/application-dev/reference/apis/js-apis-configPolicy.md similarity index 99% rename from zh-cn/application-dev/reference/apis/js-apis-config-policy.md rename to zh-cn/application-dev/reference/apis/js-apis-configPolicy.md index 03ba2c499362119c7206d46fcacddaab74e08130..043d3c5fd074fd52a97f814f18d3048848ccadcc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-config-policy.md +++ b/zh-cn/application-dev/reference/apis/js-apis-configPolicy.md @@ -24,6 +24,7 @@ getOneCfgFile(relPath: string, callback: AsyncCallback<string>) **系统能力**:SystemCapability.Customization.ConfigPolicy **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | --------------------- | | relPath | string | 是 | 配置文件名 | @@ -50,11 +51,13 @@ getOneCfgFile(relPath: string): Promise<string> **系统能力**:SystemCapability.Customization.ConfigPolicy **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ----- | | relPath | string | 是 | 配置文件名 | **返回值:** + | 类型 | 说明 | | --------------------- | ------------ | | Promise<string> | 最高优先级配置文件的路径 | @@ -79,6 +82,7 @@ getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>) **系统能力**:SystemCapability.Customization.ConfigPolicy **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------- | | relPath | string | 是 | 配置文件名 | @@ -105,11 +109,13 @@ getCfgFiles(relPath: string): Promise<Array<string>> **系统能力**:SystemCapability.Customization.ConfigPolicy **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ----- | | relPath | string | 是 | 配置文件名 | **返回值:** + | 类型 | 说明 | | ---------------------------------- | ---- | | Promise<Array<string>> | 文件列表 | @@ -133,6 +139,7 @@ getCfgDirList(callback: AsyncCallback<Array<string>>) **系统能力**:SystemCapability.Customization.ConfigPolicy **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------------- | | callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回配置层级目录列表 | @@ -158,6 +165,7 @@ getCfgDirList(): Promise<Array<string>> **系统能力**:SystemCapability.Customization.ConfigPolicy **返回值:** + | 类型 | 说明 | | ---------------------------------- | -------- | | Promise<Array<string>> | 配置层级目录列表 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-connectedTag.md b/zh-cn/application-dev/reference/apis/js-apis-connectedTag.md index 412d965ba806772193c751ebf212f67321e0fe14..52ebd6787631f3d850ca367a71767e234fff3562 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-connectedTag.md +++ b/zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @@ -5,14 +5,12 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - ## 导入模块 -``` +```js import connectedTag from '@ohos.connectedTag'; ``` - ## connectedTag.init init(): boolean @@ -23,11 +21,11 @@ init(): boolean **系统能力**:SystemCapability.Communication.ConnectedTag -- 返回值: - | **类型** | **说明** | - | -------- | -------- | - | boolean | true:初始化成功, false:初始化失败。 | +**返回值:** +| **类型** | **说明** | +| -------- | -------- | +| boolean | true:初始化成功, false:初始化失败。 | ## connectedTag.uninit @@ -39,11 +37,11 @@ uninit(): boolean **系统能力**:SystemCapability.Communication.ConnectedTag -- 返回值: - | **类型** | **说明** | - | -------- | -------- | - | boolean | true:卸载操作成功, false:卸载操作失败。 | +**返回值:** +| **类型** | **说明** | +| -------- | -------- | +| boolean | true:卸载操作成功, false:卸载操作失败。 | ## connectedTag.readNdefTag @@ -55,19 +53,21 @@ readNdefTag(): Promise<string> **系统能力**:SystemCapability.Communication.ConnectedTag -- 返回值: - | **类型** | **说明** | - | -------- | -------- | - | Promise<string> | 返回读取有源标签内容。 | +**返回值:** + +| **类型** | **说明** | +| -------- | -------- | +| Promise<string> | 返回读取有源标签内容。 | + +**示例:** -- 示例 - ``` - import connectedTag from '@ohos.connectedTag'; +```js +import connectedTag from '@ohos.connectedTag'; - connectedTag.readNdefTag().then(result => { - console.log("promise recv ndef response: " + result); - }); - ``` +connectedTag.readNdefTag().then(result => { + console.log("promise recv ndef response: " + result); +}); +``` ## connectedTag.readNdefTag @@ -79,19 +79,21 @@ readNdefTag(callback: AsyncCallback<string>): void **系统能力**:SystemCapability.Communication.ConnectedTag -- 参数 - | **参数名** | **类型** | **必填** | **说明** | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<string> | 是 | 读取有源标签内容回调函数。 | +**参数:** -- 示例 - ``` - import connectedTag from '@ohos.connectedTag'; - - connectedTag.readNdefTag(result => { - console.log("callback recv ndef response: " + result); - }); - ``` +| **参数名** | **类型** | **必填** | **说明** | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<string> | 是 | 读取有源标签内容回调函数。 | + +**示例:** + +```js +import connectedTag from '@ohos.connectedTag'; + +connectedTag.readNdefTag(result => { + console.log("callback recv ndef response: " + result); +}); +``` ## connectedTag.writeNdefTag @@ -103,29 +105,32 @@ writeNdefTag(data: string): Promise<void> **系统能力**:SystemCapability.Communication.ConnectedTag -- 参数 - | **参数名** | **类型** | **必填** | **说明** | - | -------- | -------- | -------- | -------- | - | data | string | 是 | 有源标签内容, 长度最大是1024个字节。 | +**参数:** -- 返回值: - | **类型** | **说明** | - | -------- | -------- | - | Promise<void> | 无返回值。 | +| **参数名** | **类型** | **必填** | **说明** | +| -------- | -------- | -------- | -------- | +| data | string | 是 | 有源标签内容, 长度最大是1024个字节。 | -- 示例 - ``` - import connectedTag from '@ohos.connectedTag'; - - writeNdefTag.write("010203") - .then((value) => { - // 事件写入正常 - console.log(`success to write event: ${value}`); - }).catch((err) => { - // 事件写入异常 - console.error(`failed to write event because ${err.code}`); - }); - ``` +**返回值:** + +| **类型** | **说明** | +| -------- | -------- | +| Promise<void> | 无返回值。 | + +**示例:** + +```js +import connectedTag from '@ohos.connectedTag'; + +connectedTag.write("010203") + .then((value) => { + // 事件写入正常 + console.log(`success to write event: ${value}`); + }).catch((err) => { + // 事件写入异常 + console.error(`failed to write event because ${err.code}`); + }); +``` ## connectedTag.writeNdefTag @@ -137,27 +142,29 @@ writeNdefTag(data: string, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.Communication.ConnectedTag -- 参数 - | **参数名** | **类型** | **必填** | **说明** | - | -------- | -------- | -------- | -------- | - | data | string | 是 | 有源标签内容, 长度最大是1024个字节。 | - | callback | AsyncCallback<string> | 是 | 读取有源标签内容回调函数。 | +**参数:** -- 示例 - ``` - import connectedTag from '@ohos.connectedTag'; - - connectedTag.writeNdefTag("010203", (err, value) => { - if (err) { - // 事件写入异常 - console.error(`failed to write event because ${err.code}`); - return; - } - - // 事件写入正常 - console.log(`success to write event: ${value}`); - }); - ``` +| **参数名** | **类型** | **必填** | **说明** | +| -------- | -------- | -------- | -------- | +| data | string | 是 | 有源标签内容, 长度最大是1024个字节。 | +| callback | AsyncCallback<string> | 是 | 读取有源标签内容回调函数。 | + +**示例:** + +```js +import connectedTag from '@ohos.connectedTag'; + +connectedTag.writeNdefTag("010203", (err, value) => { + if (err) { + // 事件写入异常 + console.error(`failed to write event because ${err.code}`); + return; + } + + // 事件写入正常 + console.log(`success to write event: ${value}`); +}); +``` ## connectedTag.on('notify') @@ -169,18 +176,12 @@ on(type: "notify", callback: Callback<number>): void **系统能力**:SystemCapability.Communication.ConnectedTag -- 参数 - | **参数名** | **类型** | **必填** | **说明** | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 固定填"notify"字符串 | - | callback | Callback<number> | 是 | 状态改变回调函数。 | - -- 状态改变事件的枚举。 - | **枚举值** | **说明** | - | -------- | -------- | - | 0 | NFC离场事件 | - | 1 | NFC进场事件 | +**参数:** +| **参数名** | **类型** | **必填** | **说明** | +| -------- | -------- | -------- | -------- | +| type | string | 是 | 固定填"notify"字符串 | +| callback | Callback<number> | 是 | 状态改变回调函数,返回值参见[NfcRfType](#nfcrftype)。 | ## connectedTag.off('notify') @@ -192,28 +193,28 @@ off(type: "notify", callback?: Callback<number>): void **系统能力**:SystemCapability.Communication.ConnectedTag -- 参数 - | **参数名** | **类型** | **必填** | **说明** | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 固定填"notify"字符串 | - | callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将“去注册”该事件关联的所有回调函数。 | +**参数:** -- 示例 - ``` - import connectedTag from '@ohos.connectedTag'; - - var NFC_RF_NOTIFY = "notify"; - - var recvNfcRfNotifyFunc = result => { - console.info("nfc rf receive state: " + result); - } - - // Register event - connectedTag.on(NFC_RF_NOTIFY, recvNfcRfNotifyFunc); +| **参数名** | **类型** | **必填** | **说明** | +| -------- | -------- | -------- | -------- | +| type | string | 是 | 固定填"notify"字符串 | +| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将“去注册”该事件关联的所有回调函数。| + +**示例:** + +```js +import connectedTag from '@ohos.connectedTag'; + +var recvNfcRfNotifyFunc = result => { + console.info("nfc rf receive state: " + result); +} - // Unregister event - connectedTag.off(NFC_RF_NOTIFY, recvNfcRfNotifyFunc); - ``` +// Register event +connectedTag.on("notify", recvNfcRfNotifyFunc); + +// Unregister event +connectedTag.off("notify", recvNfcRfNotifyFunc); +``` ## NfcRfType @@ -221,7 +222,7 @@ off(type: "notify", callback?: Callback<number>): void **系统能力**:SystemCapability.Communication.ConnectedTag -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | -------- | -------- | | NFC_RF_LEAVE | 0 | NFC离场事件 | | NFC_RF_ENTER | 1 | NFC进场事件 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-cooperate.md b/zh-cn/application-dev/reference/apis/js-apis-cooperate.md index f4101a76c1b6c0ec3a1c65af2415c37decb68189..542bb7ae293ec50afccc3cf8b260524ffe215445 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-cooperate.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cooperate.md @@ -20,7 +20,7 @@ enable(enable: boolean, callback: AsyncCallback<void>): void 开启、关闭键鼠穿越,使用AsyncCallback异步方式返回结果。 -**系统能力**: SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**: SystemCapability.MultimodalInput.Input.Cooperator **参数**: @@ -54,7 +54,7 @@ enable(enable: boolean): Promise<void> 开启、关闭键鼠穿越,使用Promise异步方式返回结果。 -**系统能力**: SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**: SystemCapability.MultimodalInput.Input.Cooperator **参数**: @@ -92,7 +92,7 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCal 启动键鼠穿越,使用AsyncCallback异步方式返回结果。 -**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperator **参数**: @@ -135,7 +135,7 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\ 启动键鼠穿越,使用Promise异步方式返回结果。 -**系统能力**: SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**: SystemCapability.MultimodalInput.Input.Cooperator **参数**: @@ -183,7 +183,7 @@ stop(callback: AsyncCallback\): void 停止键鼠穿越,使用AsyncCallback异步方式返回结果。 -**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperator **参数**: @@ -215,7 +215,7 @@ stop(): Promise\ 停止键鼠穿越,使用Promise异步方式返回结果。 -**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperator **返回值**: @@ -243,7 +243,7 @@ getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): 获取键鼠穿越开关的状态,使用AsyncCallback异步方式返回结果。 -**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperator **参数**: @@ -275,7 +275,7 @@ getState(deviceDescriptor: string): Promise<{ state: boolean }> 获取键鼠穿越开关的状态,使用Promise异步方式返回结果。 -**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperator **参数**: @@ -314,7 +314,7 @@ on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, even 注册监听键鼠穿越状态。 -**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperator **参数**: @@ -343,7 +343,7 @@ off(type: 'cooperation', callback?: AsyncCallback\): void 关闭监听键鼠穿越状态。 -**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperator **参数**: @@ -387,7 +387,7 @@ try { 键鼠穿越事件。 -**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperator | 名称 | 值 | 说明 | | -------- | --------- | ----------------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md b/zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md index 3f94de43f81ab122891744a4676e06c062a6f73a..4d5781e7aae01d6336c926ac698c46d7dcaf678f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md @@ -18,7 +18,7 @@ import cryptoFramework from "@ohos.security.cryptoFramework" **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ------------------------------------- | -------- | ---------------------------- | | INVALID_PARAMS | 401 | 非法入参。 | | NOT_SUPPORT | 801 | 操作不支持。 | @@ -37,7 +37,7 @@ import cryptoFramework from "@ohos.security.cryptoFramework" buffer数组。 **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | ---------- | ---- | ---- | ------ | | data | Uint8Array | 是 | 是 | 数据。 | @@ -46,9 +46,9 @@ buffer数组。 buffer数组的列表。 **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | ---------- | ---- | ---- | ---------- | -| data | Uint8Array | 是 | 是 | 数据列表。 | +| data | Array | 是 | 是 | 数据列表。 | ## EncodingFormat @@ -56,7 +56,7 @@ buffer数组的列表。 **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ---------- | ------ | --------- | | FORMAT_DER | 0 | DER格式。 | | FORMAT_PEM | 1 | PEM格式。 | @@ -70,9 +70,9 @@ buffer数组的列表。 **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------------- | --------------------------------- | ---- | ---- | ------------------------------ | -| data | Uint8Array | 是 | 是 | 传入的数据中,包含的证书数量。 | +| data | Uint8Array | 是 | 是 | 传入的证书数据。 | | encodingFormat | [EncodingFormat](#encodingformat) | 是 | 是 | 指明证书编码格式。 | @@ -84,7 +84,7 @@ buffer数组的列表。 **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------------- | --------------------------------- | ---- | ---- | ------------------------------------------------------------ | | data | Uint8Array | 是 | 是 | 证书数据,按照长度(2字节)-数据的形式传入,如:08ABCDEFGH07ABCDEFG,第一本证书,前2个字节表示证书的长度为8字节,后面附加8字节的证书数据;第2本证书前2个字节表示证书的长度为7字节,后面附加7字节的证书数据。 | | count | number | 是 | 是 | 传入的数据中,包含的证书数量。 | @@ -1017,7 +1017,7 @@ promiseGenerateRand.then(randData => { **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | ------ | ---- | ---- | ----------------------- | | algoName | string | 是 | 是 | 指明对称加解密参数的算法模式。可选值如下:
- "IvParamsSpec": 适用于CBC\|CTR\|OFB\|CFB模式
- "GcmParamsSpec": 适用于GCM模式
- "CcmParamsSpec": 适用于CCM模式 | @@ -1030,7 +1030,7 @@ promiseGenerateRand.then(randData => { **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | --------------------- | ---- | ---- | ------------------------------------------------------------ | | iv | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数iv。常见取值如下:
- AES的CBC\|CTR\|OFB\|CFB模式:iv长度为16字节
- 3DES的CBC\|OFB\|CFB模式:iv长度为8字节 | @@ -1043,7 +1043,7 @@ promiseGenerateRand.then(randData => { **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------- | --------------------- | ---- | ---- | ------------------------------------------------------------ | | iv | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数iv,长度为12字节 | | aad | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数aad,长度为8字节 | @@ -1058,7 +1058,7 @@ promiseGenerateRand.then(randData => { **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------- | --------------------- | ---- | ---- | ------------------------------------------------------------ | | iv | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数iv,长度为7字节 | | aad | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数aad,长度为8字节 | @@ -1073,7 +1073,7 @@ promiseGenerateRand.then(randData => { **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 值 | 描述 | +| 名称 | 值 | 说明 | | ------------ | ---- | ---------------- | | ENCRYPT_MODE | 0 | 表示进行加密操作 | | DECRYPT_MODE | 1 | 表示进行解密操作 | @@ -1086,7 +1086,7 @@ promiseGenerateRand.then(randData => { **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------- | ------ | ---- | ---- | ---------------------------- | | format | string | 是 | 否 | 密钥的格式。 | | algName | string | 是 | 否 | 密钥对应的算法名(含长度)。 | @@ -1101,7 +1101,7 @@ getEncoded() : DataBlob **返回值:** -| 类型 | 描述 | +| 类型 | 说明 | | --------------------- | ------------------------ | | [DataBlob](#datablob) | 用于查看密钥的具体内容。 | @@ -1158,7 +1158,7 @@ console.info("key hex:" + uint8ArrayToShowStr(encodedKey.data)); // 输出全 **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------- | ------ | ---- | ---- | ---------------------------- | | format | string | 是 | 否 | 密钥的格式。 | | algName | string | 是 | 否 | 密钥对应的算法名(含长度)。 | @@ -1174,7 +1174,7 @@ getEncoded() : DataBlob **返回值:** -| 类型 | 描述 | +| 类型 | 说明 | | --------------------- | ------------------------ | | [DataBlob](#datablob) | 用于查看密钥的具体内容。 | @@ -1202,7 +1202,7 @@ console.info("key encoded:" + uint8ArrayToShowStr(encodedKey.data)); **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------- | ------ | ---- | ---- | ---------------------------- | | format | string | 是 | 否 | 密钥的格式。 | | algName | string | 是 | 否 | 密钥对应的算法名(含长度)。 | @@ -1217,7 +1217,7 @@ getEncoded() : DataBlob **返回值:** -| 类型 | 描述 | +| 类型 | 说明 | | --------------------- | ------------------------ | | [DataBlob](#datablob) | 用于查看密钥的具体内容。 | @@ -1252,6 +1252,20 @@ let key; // key为使用非对称密钥生成器生成的非对称密钥的私 key.clearMem(); ``` +## KeyPair + +非对称密钥对,包含:公钥与私钥,。
可以通过非对称密钥生成器AsyKeyGenerator来生成。 + +### 属性 + +**系统能力:** SystemCapability.Security.CryptoFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------- | ------ | ---- | ---- | ------------ | +| priKey | [PriKey](#prikey) | 是 | 否 | 私钥。 | +| pubKey | [PubKey](#pubkey) | 是 | 否 | 公钥。 | + + ## cryptoFramework.createSymKeyGenerator createSymKeyGenerator(algName : string) : SymKeyGenerator @@ -1287,7 +1301,7 @@ let symKeyGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------- | ------ | ---- | ---- | ------------------------------ | | algName | string | 是 | 否 | 对称密钥生成器指定的算法名称。 | @@ -1301,7 +1315,7 @@ generateSymKey(callback : AsyncCallback\) : void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ------------------------------------------------------------ | | callback | AsyncCallback\<[SymKey](#symkey)> | 是 | 回调函数。当生成对称密钥成功,err为undefined,data为获取到的SymKey;否则为错误对象。 | @@ -1370,7 +1384,7 @@ convertKey(key : DataBlob, callback : AsyncCallback\) : void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ------------------------------------------------------------ | | key | [DataBlob](#datablob) | 是 | 指定的对称密钥材料。 | | callback | AsyncCallback\<[SymKey](#symkey)> | 是 | 回调函数。当生成对称密钥成功,err为undefined,data为获取到的SymKey;否则为错误对象。 | @@ -1417,7 +1431,7 @@ convertKey(key : DataBlob) : Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | --------------------- | ---- | -------------------- | | key | [DataBlob](#datablob) | 是 | 指定的密钥材料数据。 | @@ -1461,6 +1475,7 @@ symKeyGenerator.convertKey(keyMaterialBlob) ## cryptoFramework.createAsyKeyGenerator createAsyKeyGenerator(algName : string) : AsyKeyGenerator + 通过指定算法名称的字符串,获取相应的非对称密钥生成器实例。 **系统能力:** SystemCapability.Security.CryptoFramework @@ -1493,7 +1508,7 @@ let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator("ECC256"); **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------- | ------ | ---- | ---- | -------------------------------- | | algName | string | 是 | 否 | 非对称密钥生成器指定的算法名称。 | @@ -1507,7 +1522,7 @@ generateKeyPair(callback : AsyncCallback\) : void; **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | ------------------------------ | | callback | AsyncCallback\ | 是 | 回调函数,用于获取非对称密钥。 | @@ -1565,10 +1580,10 @@ convertKey(pubKey : DataBlob, priKey : DataBlob, callback : AsyncCallback\ | 是 | 回调函数,用于获取非对称密钥。 | **示例:** @@ -1597,10 +1612,10 @@ convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ---------------- | -| pubKey | DataBlob | 否 | 指定的公钥材料。 | -| priKey | DataBlob | 否 | 指定的私钥材料。 | +| pubKey | DataBlob | 是 | 指定的公钥材料。如果公钥不需要转换,可直接传入null | +| priKey | DataBlob | 是 | 指定的私钥材料。如果私钥不需要转换,可直接传入null | **返回值:** @@ -1683,7 +1698,7 @@ try { **系统能力:** SystemCapability.Security.CryptoFramework -| 名称 | 类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------- | ------ | ---- | ---- | ---------------------------- | | algName | string | 是 | 否 | 加解密生成器指定的算法名称。 | @@ -1697,7 +1712,7 @@ init(opMode : CryptoMode, key : Key, params : ParamsSpec, callback : AsyncCallba **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | | opMode | [CryptoMode](#cryptomode) | 是 | 加密或者解密模式。 | | key | [Key](#key) | 是 | 指定加密或解密的密钥。 | @@ -1739,7 +1754,7 @@ init(opMode : CryptoMode, key : Key, params : ParamsSpec) : Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------------------- | ---- | ------------------------------------------------------------ | | opMode | [CryptoMode](#cryptomode) | 是 | 加密或者解密模式。 | | key | [Key](#key) | 是 | 指定加密或解密的密钥。 | @@ -1789,7 +1804,7 @@ update(data : DataBlob, callback : AsyncCallback\) : void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | ------------------------------------------------------------ | | data | [DataBlob](#datablob) | 是 | 加密或者解密的数据。data不能为null,也不允许传入{data : Uint8Array(空) } | | callback | AsyncCallback\<[DataBlob](#datablob)> | 是 | 回调函数。当更新加/解密数据成功,err为undefined,data为此次更新的加/解密结果DataBlob;否则为错误对象。 | @@ -1846,7 +1861,7 @@ update(data : DataBlob) : Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | --------------------- | ---- | -------------------- | | data | [DataBlob](#datablob) | 是 | 加密或者解密的数据。data不能为null,也不允许传入{data : Uint8Array(空) } | @@ -1911,7 +1926,7 @@ doFinal(data : DataBlob, callback : AsyncCallback\) : void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | ------------------------------------------------------------ | | data | [DataBlob](#datablob) | 是 | 加密或者解密的数据。在对称加解密中允许为null,但不允许传入{data : Uint8Array(空) }。 | | callback | AsyncCallback\<[DataBlob](#datablob)> | 是 | 回调函数。当最终加/解密数据成功,err为undefined,data为剩余数据的加/解密结果DataBlob;否则为错误对象。 | @@ -1963,7 +1978,7 @@ doFinal(data : DataBlob) : Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | --------------------- | ---- | -------------------- | | data | [DataBlob](#datablob) | 是 | 加密或者解密的数据。data参数允许为null,但不允许传入{data : Uint8Array(空) } | @@ -2104,7 +2119,7 @@ init(priKey : PriKey, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ---------------- | -| priKey | Key | 是 | 用于Sign的初始化 | +| priKey | PriKey | 是 | 用于Sign的初始化 | | callback | AsyncCallback\ | 是 | 回调函数的 | ### init @@ -2119,7 +2134,7 @@ init(opMode : CryptoMode, key : Key, params : ParamsSpec) : Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ---- | ---- | ---------------- | -| priKey | Key | 是 | 用于Sign的初始化 | +| priKey | PriKey | 是 | 用于Sign的初始化 | **返回值:** @@ -2175,7 +2190,7 @@ sign(data : DataBlob, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ---------- | | data | DataBlob | 是 | 传入的消息 | -| callback | AsyncCallback\ | 是 | 回调函数 | +| callback | AsyncCallback\ | 是 | 回调函数 | ### sign @@ -2323,7 +2338,7 @@ init(pubKey : PubKey, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ---------------------------- | -| pubKey | Key | 是 | 公钥对象,用于Verify的初始化 | +| pubKey | PubKey | 是 | 公钥对象,用于Verify的初始化 | | callback | AsyncCallback\ | 是 | 回调函数 | ### init @@ -2338,7 +2353,7 @@ init(pubKey : PubKey) : Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ---- | ---- | ---------------------------- | -| pubKey | Key | 是 | 公钥对象,用于Verify的初始化 | +| pubKey | PubKey | 是 | 公钥对象,用于Verify的初始化 | **返回值:** @@ -2395,7 +2410,7 @@ verify(data : DataBlob, signatureData : DataBlob, callback : AsyncCallback\ | 是 | 回调函数 | +| callback | AsyncCallback\ | 是 | 回调函数 | ### verify @@ -2571,7 +2586,7 @@ createX509Cert(inStream : EncodingBlob, callback : AsyncCallback\) : v | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | -------------------------- | | inStream | [EncodingBlob](#encodingblob) | 是 | X509证书序列化数据 | -| callback | AsyncCallback\ | 否 | 回调函数。表示X509证书对象 | +| callback | AsyncCallback\ | 是 | 回调函数。表示X509证书对象 | **示例**: @@ -2612,8 +2627,8 @@ createX509Cert(inStream : EncodingBlob) : Promise\ **返回值**: | 类型 | 说明 | -| :------- | ---------------- | -| X509Cert | 表示X509证书对象 | +| ------- | ---------------- | +| Promise\ | 表示X509证书对象 | **示例**: @@ -2651,7 +2666,7 @@ verify(key : PubKey, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ------------------------------------------------------------ | | key | [PubKey](#pubkey) | 是 | 用于验签的公钥对象 | -| callback | AsyncCallback\) | 否 | 回调函数。使用AsyncCallback的第一个error参数判断是否验签成功,error为null表示成功,不为null表示失败 | +| callback | AsyncCallback\ | 是 | 回调函数。使用AsyncCallback的第一个error参数判断是否验签成功,error为null表示成功,不为null表示失败 | **示例**: @@ -2742,7 +2757,7 @@ getEncoded(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------- | ---- | -------------------------------- | -| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | 否 | 回调函数。表示X509证书序列化数据 | +| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | 是 | 回调函数。表示X509证书序列化数据 | **示例**: @@ -2823,7 +2838,7 @@ getPublicKey(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | -------------------------- | -| callback | AsyncCallback | 否 | 回调函数,X509证书公钥对象 | +| callback | AsyncCallback\ | 是 | 回调函数,X509证书公钥对象 | **示例**: @@ -2905,7 +2920,7 @@ checkValidityWithDate(date: string, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------------------------------------------ | | date | string | 是 | 日期 | -| callback | AsyncCallback\ | 否 | 回调函数。使用AsyncCallback的第一个error参数判断是否检查成功,error为null表示成功,不为null表示失败 | +| callback | AsyncCallback\ | 是 | 回调函数。使用AsyncCallback的第一个error参数判断是否检查成功,error为null表示成功,不为null表示失败 | **示例**: @@ -3535,7 +3550,7 @@ createX509Crl(inStream : EncodingBlob, callback : AsyncCallback\) : voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | ------------------------------ | | inStream | [EncodingBlob](#encodingblob) | 是 | 表示证书吊销列表序列化数据 | -| callback | AsyncCallback\ | 否 | 回调函数。表示证书吊销列表对象 | +| callback | AsyncCallback\ | 是 | 回调函数。表示证书吊销列表对象 | **示例**: @@ -3615,7 +3630,7 @@ isRevoked(cert : X509Cert, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | ----------------------------------------------------------- | | cert | [X509Cert](#x509cert) | 是 | 表示被检查的证书对象 | -| callback | AsyncCallback\ | 否 | 回调函数。表示证书吊销状态,true表示已吊销,false表示未吊销 | +| callback | AsyncCallback\ | 是 | 回调函数。表示证书吊销状态,true表示已吊销,false表示未吊销 | **示例**: @@ -3742,7 +3757,7 @@ getEncoded(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------- | ---- | ------------------------------------------ | -| callback | AsyncCallback\ | 否 | 回调函数,表示X509证书吊销列表的序列化数据 | +| callback | AsyncCallback\ | 是 | 回调函数,表示X509证书吊销列表的序列化数据 | **示例**: @@ -3824,7 +3839,7 @@ verify(key : PubKey, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------------------------------------------ | | key | PubKey | 是 | 表示用于验签的公钥对象 | -| callback | AsyncCallback\ | 否 | 回调函数,使用AsyncCallback的第一个error参数判断是否验签成功,error为null表示成功,error不为null表示失败。 | +| callback | AsyncCallback\ | 是 | 回调函数,使用AsyncCallback的第一个error参数判断是否验签成功,error为null表示成功,error不为null表示失败。 | **示例**: @@ -4060,7 +4075,7 @@ getRevokedCert(serialNumber : number, callback : AsyncCallback\) : | 参数名 | 类型 | 必填 | 说明 | | ------------ | ---------------------------- | ---- | -------------------------------- | | serialNumber | number | 是 | 表示证书序列号 | -| callback | AsyncCallback\ | 否 | 回调函数。表示被吊销X509证书对象 | +| callback | AsyncCallback\ | 是 | 回调函数。表示被吊销X509证书对象 | **示例**: @@ -4152,7 +4167,7 @@ getRevokedCertWithCert(cert : X509Cert, callback : AsyncCallback\) | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------- | ---- | ------------------------------- | | cert | X509Cert | 是 | 表示证书对象 | -| callback | AsyncCallback\ | 否 | 回调函数,表示被吊销X509证书对象 | +| callback | AsyncCallback\ | 是 | 回调函数,表示被吊销X509证书对象 | **示例**: @@ -4243,7 +4258,7 @@ getRevokedCerts(callback : AsyncCallback>) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | -------------------------------- | -| callback | AsyncCallback> | 否 | 回调函数。表示被吊销X509证书列表 | +| callback | AsyncCallback> | 是 | 回调函数。表示被吊销X509证书列表 | **示例**: @@ -4324,7 +4339,7 @@ getTbsInfo(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | ------------------------------------------- | -| callback | AsyncCallback\<[DataBlob](#datablob)> | 否 | 回调函数。表示证书吊销列表的tbsCertList信息 | +| callback | AsyncCallback\<[DataBlob](#datablob)> | 是 | 回调函数。表示证书吊销列表的tbsCertList信息 | **示例**: @@ -4569,6 +4584,16 @@ let validator = cryptoFramework.createCertChainValidator("PKIX"); 证书链校验器对象。 + +### 属性 + +**系统能力:** SystemCapability.Security.CryptoFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------- | ------ | ---- | ---- | -------------------------- | +| algorithm | string | 是 | 否 | X509证书链校验器算法名称。 | + + ### validate validate(certChain : CertChainData, callback : AsyncCallback\) : void @@ -4583,7 +4608,7 @@ validate(certChain : CertChainData, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------------- | ---- | ------------------------------------------------------------ | | certChain | [CertChainData](#certchaindata) | 是 | 表示X509证书链序列化数据 | -| callback | AsyncCallback\ | 否 | 回调函数。使用AsyncCallback的第一个error参数判断是否校验成功,error为null表示成功,error不为null表示失败 | +| callback | AsyncCallback\ | 是 | 回调函数。使用AsyncCallback的第一个error参数判断是否校验成功,error为null表示成功,error不为null表示失败 | **示例**: @@ -4655,19 +4680,6 @@ validator.validate(certChainData).then(result => { }); ``` -### algorithm - -algorithm : string - -表示X509证书链校验器算法名称。 - -**系统能力**:SystemCapability.Security.CryptoFramework - -**返回值**: - -| 类型 | 说明 | -| ------ | ------------------------ | -| string | 表示证书链校验器算法名称 | **示例**: @@ -4694,7 +4706,7 @@ getEncoded(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------- | ---- | ------------------------------------ | -| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | 否 | 回调函数。表示被吊销证书的序列化数据 | +| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | 是 | 回调函数。表示被吊销证书的序列化数据 | **示例**: @@ -4777,7 +4789,7 @@ getCertIssuer(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | ------------------------------------ | -| callback | AsyncCallback\<[DataBlob](#datablob)> | 否 | 回调函数。表示被吊销证书的颁发者信息 | +| callback | AsyncCallback\<[DataBlob](#datablob)> | 是 | 回调函数。表示被吊销证书的颁发者信息 | **示例**: @@ -4836,7 +4848,7 @@ getRevocationDate(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ------------------------------ | -| callback | AsyncCallback\ | 否 | 回调函数。表示证书被吊销的日期 | +| callback | AsyncCallback\ | 是 | 回调函数。表示证书被吊销的日期 | **示例**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md b/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md index 0500df64e30280ce6c6e476ef66b6d3cf5ceb36d..385e6946c965e718cbc8a5ada9c3382532ebdfab 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md @@ -53,7 +53,7 @@ dataShareHelper.query(uri, da, columns).then((data) => { **系统能力:** SystemCapability.DistributedDataManager.DataShare.Core -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ----------- | ------------- | ---- | ------------------------ | | columnNames | Array<string> | 是 | 结果集中所有列的名称。 | | columnCount | number | 是 | 结果集中的列数。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md b/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md index 210f71874173df8a86ca48e9eba81b36af3af2a0..5745a9d4de1c19f94a9811aaf0b8bf467ffa548d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md @@ -125,7 +125,7 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback<void>): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | type | string | 是 | 订阅的事件/回调类型,支持的事件为'dataChange',当数据更改时,触发该事件。 | | uri | string | 是 | 表示指定的数据路径。 | @@ -152,7 +152,7 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback<void>): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | type | string | 是 | 取消订阅的事件/回调类型,支持的事件为'dataChange'。 | | uri | string | 是 | 表示指定的数据路径。 | @@ -179,7 +179,7 @@ insert(uri: string, value: ValuesBucket, callback: AsyncCallback<number>): **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要插入的数据的路径。 | | value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示要插入的数据。如果此参数为空,将插入一个空行。 | @@ -218,7 +218,7 @@ insert(uri: string, value: ValuesBucket): Promise<number> **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | --------------------------------------------------------- | ---- | -------------------------------------------------- | | uri | string | 是 | 指示要插入的数据的路径。 | | value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示要插入的数据。如果此参数为空,将插入一个空行。 | @@ -260,10 +260,10 @@ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callbac **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要删除的数据的路径。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
delete接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB的删除目前仅支持inKeys谓词。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
delete接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB的删除目前仅支持inKeys谓词。 | | callback | AsyncCallback<number> | 是 | 回调函数。当从数据库中删除一条或多条数据记录成功,err为undefined,data为获取到的已删除的数据记录数;否则为错误对象。
因部分数据库(如KVDB)的相应接口并不提供相应支持,故若服务端使用此数据库,则此callback也无法返回删除的数据记录数。 | **示例:** @@ -298,10 +298,10 @@ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promis **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要删除的数据的路径。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
delete接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB的删除目前仅支持inKeys谓词。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
delete接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB的删除目前仅支持inKeys谓词。 | **返回值:** @@ -339,10 +339,10 @@ query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要查询的数据的路径。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
query接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB目前仅支持inKeys和prefixKey。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
query接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB目前仅支持inKeys和prefixKey。 | | columns | Array<string> | 是 | 指示要查询的列。如果此参数为空,则查询所有列。 | | callback | AsyncCallback<[DataShareResultSet](js-apis-data-DataShareResultSet.md#datashareresultset)> | 是 | 回调函数。当查询数据库中的数据成功,err为undefined,data为获取到的查询到的结果集;否则为错误对象。 | @@ -379,10 +379,10 @@ query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要查询的数据的路径。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
query接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB目前仅支持inKeys和prefixKey。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
query接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB目前仅支持inKeys和prefixKey。 | | columns | Array<string> | 是 | 指示要查询的列。如果此参数为空,则查询所有列。 | **返回值:** @@ -422,10 +422,10 @@ update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要更新的数据的路径。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
update接口是否支持谓词筛选条件取决于服务端所选用的数据库,如KVDB目前并不支持谓词筛选条件,仅RDB支持。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
update接口是否支持谓词筛选条件取决于服务端所选用的数据库,如KVDB目前并不支持谓词筛选条件,仅RDB支持。 | | value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示要更新的数据。 | | callback | AsyncCallback<number> | 是 | 回调函数。当更新数据库中的数据记录成功,err为undefined,data为获取到的更新的数据记录数;否则为错误对象。
因部分数据库(如KVDB)的相应接口并不提供相应支持,故若服务端使用此数据库,则此callback也无法返回更新的数据记录数。 | @@ -467,10 +467,10 @@ update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要更新的数据的路径。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
update接口是否支持谓词筛选条件取决于服务端所选用的数据库,如KVDB目前并不支持谓词筛选条件,仅RDB支持。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
update接口是否支持谓词筛选条件取决于服务端所选用的数据库,如KVDB目前并不支持谓词筛选条件,仅RDB支持。 | | value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示要更新的数据。 | **返回值:** @@ -515,7 +515,7 @@ batchInsert(uri: string, values: Array<ValuesBucket>, callback: AsyncCallb **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要插入的数据的路径。 | | values | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | 是 | 指示要插入的数据。 | @@ -552,7 +552,7 @@ batchInsert(uri: string, values: Array<ValuesBucket>): Promise<number&g **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------------------------------------------------------ | ---- | ------------------------ | | uri | string | 是 | 指示要插入的数据的路径。 | | values | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | 是 | 指示要插入的数据。 | @@ -592,7 +592,7 @@ normalizeUri(uri: string, callback: AsyncCallback<string>): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | -------------------------------------------------------- | | uri | string | 是 | 指示要规范化的[URI](js-apis-uri.md#uri)。 | | callback | AsyncCallback<string> | 是 | 回调函数。当将给定的DataShare URI转换为规范化URI成功,err为undefined,data为获取到的规范化URI(如果支持URI规范化,则返回规范化URI,否则返回空);否则为错误对象。 | @@ -621,7 +621,7 @@ normalizeUri(uri: string): Promise<string> **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ----------------------------------------- | | uri | string | 是 | 指示要规范化的[URI](js-apis-uri.md#uri)。 | @@ -653,7 +653,7 @@ denormalizeUri(uri: string, callback: AsyncCallback<string>): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | --------------------------------------------------- | | uri | string | 是 | 指示要反规范化的[URI](js-apis-uri.md#uri)。 | | callback | AsyncCallback<string> | 是 | 回调函数。当将指定的URI转换为非规范化URI,err为undefined,data为获取到的反规范化URI(如果反规范化成功,则返回反规范化的URI;如果无需进行反规范化,则返回原始URI;若不支持则返回空);否则为错误对象。 | @@ -682,7 +682,7 @@ denormalizeUri(uri: string): Promise<string> **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------------------------------------- | | uri | string | 是 | 指示要反规范化的[URI](js-apis-uri.md#uri)。 | @@ -714,7 +714,7 @@ notifyChange(uri: string, callback: AsyncCallback<void>): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | uri | string | 是 | 表示指定的数据路径。 | | callback | AsyncCallback<void> | 是 | 回调函数。当通知已注册的观察者指定URI对应的数据资源已发生变更成功,err为undefined;否则为错误对象。 | @@ -739,7 +739,7 @@ notifyChange(uri: string): Promise<void> **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | -------------------- | | uri | string | 是 | 表示指定的数据路径。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md index c8af16df46fd351df8260a52a735b6bdd4140b23..8793efbbe27896b0893ee6617a76ea341f3c829b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md @@ -2656,7 +2656,7 @@ try { **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------------- | ------------- | ---- | --------------------------------------------------------- | | name | string | 是 | 数据库文件名。 | | securityLevel | SecurityLevel | 是 | 设置数据库安全级别 | @@ -4649,7 +4649,7 @@ try { **系统能力:**SystemCapability.DistributedDataManager.RelationalStore.Core -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 数据库文件名。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md index be98b82dab1e822070f37cf16c69135b7f2ffba7..18c840d6aa7868737595510dc9617fda511bd048 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -9,7 +9,6 @@ 使用前根据具体情况引入如下模块 ``` -import featureAbility from '@ohos.ability.featureAbility' import ohos_data_ability from '@ohos.data.dataAbility' import ohos_data_rdb from '@ohos.data.rdb' ``` @@ -24,11 +23,11 @@ openFile(uri: string, mode: string, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---------------------------------- | | uri | string | 是 | 指示要打开的文件的路径。 | | mode | string | 是 | 指示文件打开模式‘rwt’。 | -| callback | AsyncCallback\ | 是 | 被指定的回调方法,返回文件描述符。 | +| callback | AsyncCallback\ | 是 | 被指定的回调方法,返回文件说明符。 | **示例:** @@ -56,7 +55,7 @@ openFile(uri: string, mode: string): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------------------ | | uri | string | 是 | 指示要打开的文件的路径。 | | mode | string | 是 | 指示文件打开模式‘rwt’。 | @@ -65,7 +64,7 @@ openFile(uri: string, mode: string): Promise\ | 类型 | 说明 | | ---------------- | ---------------- | -| Promise\ | 返回文件描述符。 | +| Promise\ | 返回文件说明符。 | **示例:** @@ -92,7 +91,7 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | type | string | 是 | 数据更改。 | | uri | string | 是 | 指示要操作的数据的路径。 | @@ -125,7 +124,7 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | type | string | 是 | 数据更改。 | | uri | string | 是 | 指示要操作的数据的路径。 | @@ -162,7 +161,7 @@ getType(uri: string, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | --------------------------------------------- | | uri | string | 是 | 指示要操作的数据的路径。 | | callback | AsyncCallback\ | 是 | 回调方法,返回与uri指定的数据匹配的MIME类型。 | @@ -191,7 +190,7 @@ getType(uri: string): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------------------ | | uri | string | 是 | 指示要操作的数据的路径。 | @@ -225,7 +224,7 @@ getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback> **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------------- | ------ | ---- | ---------------------------- | | uri | string | 是 | 指示要获取的文件的路径。 | | mimeTypeFilter | string | 是 | 指示要获取的文件的MIME类型。 | @@ -294,7 +293,7 @@ normalizeUri(uri: string, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要规范化的uri对象。 | | callback | AsyncCallback\ | 是 | 回调方法。如果数据功能支持uri规范化,则返回规范化uri对象;否则返回null。 | @@ -323,7 +322,7 @@ normalizeUri(uri: string): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ----------------------- | | uri | string | 是 | 指示要规范化的uri对象。 | @@ -357,7 +356,7 @@ denormalizeUri(uri: string, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | --------------------------------------------------- | | uri | string | 是 | 指示要规范化的uri对象。 | | callback | AsyncCallback\ | 是 | 回调方法。如果反规范化成功,则返回反规范化uri对象。 | @@ -388,7 +387,7 @@ denormalizeUri(uri: string): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ----------------------- | | uri | string | 是 | 指示要规范化的uri对象。 | @@ -422,7 +421,7 @@ notifyChange(uri: string, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | uri | string | 是 | 指示要操作的数据的路径。 | | callback | AsyncCallback\ | 是 | 回调方法。 | @@ -451,7 +450,7 @@ notifyChange(uri: string): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------------------ | | uri | string | 是 | 指示要操作的数据的路径。 | @@ -485,7 +484,7 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ---------------- | ---- | ------------------------------------------------------ | | uri | string | 是 | 指示要插入的数据的路径。 | | valuesBucket | rdb.ValuesBucket | 是 | 指示要插入的数据记录。如果此参数为空,将插入一个空行。 | @@ -564,7 +563,7 @@ batchInsert(uri: string, valuesBuckets: Array, callback: Async **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ----------------------- | ---- | -------------------------------- | | uri | string | 是 | 指示要插入的数据的路径。 | | valuesBucket | Array | 是 | 指示要插入的数据记录。 | @@ -598,7 +597,7 @@ batchInsert(uri: string, valuesBuckets: Array): Promise\ | 是 | 指示要插入的数据记录。 | @@ -637,7 +636,7 @@ delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: Asy **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | --------------------------------- | ---- | ------------------------------------------------ | | uri | string | 是 | 指示要删除的数据的路径。 | | valuesBucket | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | @@ -670,7 +669,7 @@ delete(uri: string, predicates?: dataAbility.DataAbilityPredicates): Promise\, predicates: dataAbility.DataAbilityP **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | | uri | string | 是 | 指示要查询的数据的路径。 | | columns | rdb.ValuesBucket | 是 | 指示要查询的列。如果此参数为空,则查询所有列。 | @@ -833,7 +832,7 @@ query(uri: string, columns?: Array\, predicates?: dataAbility.DataAbilit **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | | uri | string | 是 | 指示要查询的数据的路径。 | | columns | rdb.ValuesBucket | 是 | 指示要查询的列。如果此参数为空,则查询所有列。 | @@ -874,7 +873,7 @@ call(uri: string, method: string, arg: string, extras: PacMap): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | | uri | string | 是 | 指定待处理的DataAbility。例:"dataability:///com.example.xxx.xxxx" | | method | string | 是 | 被调用的方法名。 | @@ -910,7 +909,7 @@ call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCa **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | | uri | string | 是 | 指定待处理的DataAbility。例:"dataability:///com.example.xxx.xxxx" | | method | string | 是 | 被调用的方法名。 | @@ -943,7 +942,7 @@ executeBatch(uri: string, operations: Array\, callback: As **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | | uri | string | 是 | 指定待处理的DataAbility。例:"dataability:///com.example.xxx.xxxx"。| | operations | Array\<[DataAbilityOperation](#dataabilityoperation)> | 是 | 指示数据操作列表,其中可以包含对数据库的多个操作。 | @@ -976,7 +975,7 @@ executeBatch(uri: string, operations: Array\): Promise\ | 是 | 指示数据操作列表,其中可以包含对数据库的多个操作。 | @@ -1009,7 +1008,7 @@ dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbi **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel -| 名称 | 参数类型 | 必填 | 说明 | +| 参数名 | 参数类型 | 必填 | 说明 | | ------ | ------ | ------ | ------ | | [key: string] | number \| string \| boolean \| Array\ \| null | Yes| 数据存储在键值对中。| @@ -1017,7 +1016,7 @@ dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbi **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.FAModel -| 名称 | 参数类型 | 可读 | 可写 | 必填| 说明 | +| 名称 | 类型 | 可读 | 可写 | 必填| 说明 | | -------- | -------- | -------- | -------- | --------| -------- | | uri | string | 是 | 否 | 是 | 指定待处理的DataAbility。例:"dataability:///com.example.xxx.xxxx"。 | | type | featureAbility.DataAbilityOperationType | 是 | 否 | 是 | 指示操作类型。 | @@ -1032,7 +1031,7 @@ dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbi **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.FAModel -| 名称 | 参数类型 | 可读 | 可写 | 必填 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -------- | -------- | | uri? | string | 是 | 否 | 否 | 指定待处理的DataAbility。例:"dataability:///com.example.xxx.xxxx"。 | | count? | number | 是 | 否 | 否 | 指示受操作影响的行数。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md b/zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md index d361c9959ac6406e2543ab892dd3ad29eadea919..8f5a273bf75b5e797e19017e0247c66736ce45bc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md @@ -27,7 +27,7 @@ import defaultAppMgr from '@ohos.bundle.defaultAppManager'; **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp -| 参数名 | 类型 | 值 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------------------------------------- | -------------------------------------- | | BROWSER | string | Web Browser | 默认浏览器。 | | IMAGE | string | Image Gallery | 默认图片查看器。 | @@ -58,10 +58,6 @@ isDefaultApplication(type: string): Promise\ | ------------------------- | ------------------ | | Promise\ | Promise形式返回当前应用是否是默认应用,true表示是默认应用,false表示不是默认应用。 | -**错误码:** - -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 - **示例:** @@ -90,10 +86,6 @@ isDefaultApplication(type: string, callback: AsyncCallback\): void | type | string | 是 | 要查询的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值。 | | callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数,返回当前应用是否是默认应用,true表示是默认应用,false表示不是默认应用。 | -**错误码:** - -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 - **示例:** ```js @@ -138,7 +130,7 @@ getDefaultApplication(type: string, userId?: number): Promise\ | 错误码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. | | 17700025 | The specified type is invalid. | @@ -189,7 +181,7 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\) : void | 错误码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. | | 17700025 | The specified type is invalid. | @@ -266,11 +258,11 @@ defaultAppMgr.getDefaultApplication("image/png", (err, data) => { ## defaultAppMgr.setDefaultApplication -setDefaultApplication(type: string, elementName: ElementName, userId?: number): Promise\<**返回值:** +setDefaultApplication(type: string, elementName: ElementName, userId?: number): Promise\ | 类型 | 说明 | | ----------------------------------------------------------- | --------------------------- | -| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise对象,返回BundleInfo | +| Promise\ | Promise对象,返回BundleInfo | > @@ -302,9 +294,9 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number): | 错误码ID | 错误信息 | | -------- | ---------------------------------------------- | -| 17700004 | The specified user id is not found. | +| 17700004 | The specified user ID is not found. | | 17700025 | The specified type is invalid. | -| 17700028 | The specified ability and type does not match. | +| 17700028 | The specified ability does not match the type. | **示例:** @@ -369,9 +361,9 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca | 错误码ID | 错误信息 | | -------- | ---------------------------------------------- | -| 17700004 | The specified user id is not found. | +| 17700004 | The specified user ID is not found. | | 17700025 | The specified type is invalid. | -| 17700028 | The specified ability and type does not match. | +| 17700028 | The specified ability does not match the type. | **示例:** @@ -429,9 +421,9 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal | 错误码ID | 错误信息 | | -------- | ---------------------------------------------- | -| 17700004 | The specified user id is not found. | +| 17700004 | The specified user ID is not found. | | 17700025 | The specified type is invalid. | -| 17700028 | The specified ability and type does not match. | +| 17700028 | The specified ability does not match the type. | **示例:** @@ -487,7 +479,7 @@ resetDefaultApplication(type: string, userId?: number): Promise\ | 错误码ID | 错误信息 | | -------- | ----------------------------------- | -| 17700004 | The specified user id is not found. | +| 17700004 | The specified user ID is not found. | | 17700025 | The specified type is invalid. | **示例:** @@ -538,7 +530,7 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\) : void; | 错误码ID | 错误信息 | | -------- | ----------------------------------- | -| 17700004 | The specified user id is not found. | +| 17700004 | The specified user ID is not found. | | 17700025 | The specified type is invalid. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-deque.md b/zh-cn/application-dev/reference/apis/js-apis-deque.md index 482b3eb1faeaec10507cda27eb644931649a8abc..1c668636764e92114653dc8afe5a7de38958925e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-deque.md +++ b/zh-cn/application-dev/reference/apis/js-apis-deque.md @@ -50,11 +50,6 @@ Deque的构造函数。 ```ts let deque = new Deque(); -try { - let deque2 = Deque(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### insertFront @@ -90,11 +85,6 @@ deque.insertFront(b); let c = {name : "Dylon", age : "13"}; deque.insertFront(c); deque.insertFront(false); -try { - deque.insertFront.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### insertEnd @@ -130,11 +120,6 @@ deque.insertEnd(b); let c = {name : "Dylon", age : "13"}; deque.insertEnd(c); deque.insertEnd(false); -try { - deque.insertEnd.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### has @@ -172,11 +157,6 @@ let deque = new Deque(); let result = deque.has("squirrel"); deque.insertFront("squirrel"); let result1 = deque.has("squirrel"); -try { - deque.has.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### popFirst @@ -211,11 +191,6 @@ deque.insertEnd(5); deque.insertFront(2); deque.insertFront(4); let result = deque.popFirst(); -try { - deque.popFirst.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### popLast @@ -250,11 +225,6 @@ deque.insertFront(5); deque.insertFront(2); deque.insertFront(4); let result = deque.popLast(); -try { - deque.popLast.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### forEach @@ -300,13 +270,6 @@ deque.insertEnd(4); deque.forEach((value, index) => { console.log("value:" + value, index); }); -try { - deque.forEach.bind({}, (value, index) => { - console.log("value:" + value, index); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getFirst @@ -340,11 +303,6 @@ deque.insertEnd(4); deque.insertFront(5); deque.insertFront(4); let result = deque.getFirst(); -try { - deque.getFirst.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getLast @@ -378,11 +336,6 @@ deque.insertFront(4); deque.insertFront(5); deque.insertFront(4); let result = deque.getLast(); -try { - deque.getLast.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### [Symbol.iterator] @@ -427,9 +380,4 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - deque[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md index 3b7ed92b83cddfb82a351e6482904a35e61d5f74..a575cfb2cab3d04a9d775bcb3d19716cb318f733 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md @@ -74,7 +74,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ---------------------- | ------------------------- | ---- | -------- | | deviceId | string | 是 | 设备的唯一标识。 | | deviceName | string | 是 | 设备名称。 | @@ -88,7 +88,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | ------------ | ---- | ---- | | SPEAKER | 0x0A | 智能音箱 | | PHONE | 0x0E | 手机 | @@ -105,7 +105,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | ------- | ---- | --------------- | | ONLINE | 0 | 设备物理上线状态。 | | READY | 1 | 设备可用状态,表示设备间信息已在分布式数据中同步完成, 可以运行分布式业务。 | @@ -118,7 +118,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ------------- | --------------------------------- | ---- | ----------------- | | subscribeId | number | 是 | 发现标识,用于标识不同的发现周期。 | | mode | [DiscoverMode ](#discovermode) | 否 | 发现模式。 | @@ -135,7 +135,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | --------------------- | ---- | ----- | | DISCOVER_MODE_PASSIVE | 0x55 | 被动模式。 | | DISCOVER_MODE_ACTIVE | 0xAA | 主动模式。 | @@ -147,7 +147,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | ---- | ---- | --------- | | AUTO | 0 | 自动发现类型。 | | BLE | 1 | 蓝牙发现类型。 | @@ -160,7 +160,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | ---------- | ---- | ----- | | LOW | 0 | 低频率。 | | MID | 1 | 中频率。 | @@ -174,7 +174,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | ------------------------- | ---- | -------------- | | SUBSCRIBE_CAPABILITY_DDMP | 0 | DDMP能力,后续会被废弃。 | | SUBSCRIBE_CAPABILITY_OSD | 1 | OSD能力。 | @@ -186,10 +186,10 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | --------- | -------------------- | ---- | ---------- | | authType | number | 是 | 认证类型。 | -| extraInfo | {[key:string] : any} | 否 | 认证参数可扩展字段。 | +| extraInfo | {[key:string] : any} | 否 | 认证参数可扩展字段。 | ## AuthInfo @@ -197,19 +197,19 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | --------- | -------------------- | ---- | ---------- | | authType | number | 是 | 认证类型。 | | token | number | 是 | 认证Token。 | -| extraInfo | {[key:string] : any} | 否 | 认证信息可扩展字段。 | +| extraInfo | {[key:string] : any} | 否 | 认证信息可扩展字段。 | -## PublishInfo9+
+## PublishInfo9+ 发布设备参数 **系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ------------- | --------------------------------- | ---- | ----------------- | | publishId | number | 是 | 发布设备标识,用于标识不同的发布周期。 | | mode | [DiscoverMode ](#discovermode) | 是 | 发现模式。 | @@ -288,7 +288,7 @@ getTrustedDeviceList(callback:AsyncCallback<Array<DeviceInfo>>): voi **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | --------------------- | | callback | AsyncCallback<Array<[DeviceInfo](#deviceinfo)>> | 是 | 获取所有可信设备列表的回调,返回设备信息。 | @@ -390,7 +390,7 @@ getLocalDeviceInfo(callback:AsyncCallback<DeviceInfo>): void **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | --------- | | callback | AsyncCallback<[DeviceInfo](#deviceinfo)> | 是 | 获取本地设备信息。 | @@ -450,7 +450,7 @@ getLocalDeviceInfo(): Promise<DeviceInfo> }); ``` -### startDeviceDiscovery8+
+### startDeviceDiscovery8+ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void @@ -460,7 +460,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ------------- | ------------------------------- | ---- | ----- | | subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | 发现信息。| @@ -494,7 +494,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void } ``` -### startDeviceDiscovery9+
+### startDeviceDiscovery9+ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void @@ -504,7 +504,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ------------- | ------------------------------- | ---- | ----- | | subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | 发现信息。 | | filterOptions | string | 否 | 发现设备过滤信息。| @@ -558,7 +558,7 @@ stopDeviceDiscovery(subscribeId: number): void **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ----- | | subscribeId | number | 是 | 发现标识。 | @@ -581,7 +581,7 @@ stopDeviceDiscovery(subscribeId: number): void } ``` -### publishDeviceDiscovery9+
+### publishDeviceDiscovery9+ publishDeviceDiscovery(publishInfo: PublishInfo): void @@ -591,7 +591,7 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ------------- | ------------------------------- | ---- | ----- | | publishInfo | [PublishInfo](#publishinfo) | 是 | 发布设备发现信息。 | @@ -622,7 +622,7 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void } ``` -### unPublishDeviceDiscovery9+
+### unPublishDeviceDiscovery9+ unPublishDeviceDiscovery(publishId: number): void @@ -632,7 +632,7 @@ unPublishDeviceDiscovery(publishId: number): void **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ----------- | -------- | ---- | ----- | | publishId | number | 是 | 发布标识。 | @@ -657,7 +657,7 @@ unPublishDeviceDiscovery(publishId: number): void ### authenticateDevice -authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback<{deviceId: string, pinToken ?: number}>): void +authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback<{deviceId: string, pinToken ?: number}>): void 认证设备。 @@ -665,11 +665,11 @@ authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: Async **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------------------------- | ---- | ------- | | deviceInfo | [DeviceInfo](#deviceinfo) | 是 | 设备信息。 | | authParam | [AuthParam](#authparam) | 是 | 认证参数。 | - | callback | AsyncCallback<{ deviceId: string, pinToken ?: number }> | 是 | 认证结果回调。 | + | callback | AsyncCallback<{deviceId: string, pinToken ?: number}> | 是 | 认证结果回调。 | **错误码:** @@ -717,7 +717,7 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------- | ---- | ----- | | deviceInfo | [DeviceInfo](#deviceinfo) | 是 | 设备信息。 | @@ -741,7 +741,7 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void ### verifyAuthInfo -verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, level: number}>): void +verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, level: number}>): void 验证认证信息。 @@ -749,10 +749,10 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, le **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------- | | authInfo | [AuthInfo](#authinfo) | 是 | 认证信息。 | - | callback | AsyncCallback<{ deviceId: string, level: number }> | 是 | 验证结果回调。 | + | callback | AsyncCallback<{deviceId: string, level: number}> | 是 | 验证结果回调。 | **错误码:** @@ -783,7 +783,7 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, le } ``` -### setUserOperation9+
+### setUserOperation9+ setUserOperation(operateAction: number, params: string): void; @@ -793,7 +793,7 @@ setUserOperation(operateAction: number, params: string): void; **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ------------- | --------------- | ---- | ------------------- | | operateAction | number | 是 | 用户操作动作。 | | params | string | 是 | 表示用户的输入参数。 | @@ -817,9 +817,9 @@ setUserOperation(operateAction: number, params: string): void; } ``` -### on('uiStateChange')9+
+### on('uiStateChange')9+ -on(type: 'uiStateChange', callback: Callback<{ param: string}>): void; +on(type: 'uiStateChange', callback: Callback<{ param: string}>): void; ui状态变更回调。 @@ -827,10 +827,10 @@ ui状态变更回调。 **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------ | ---- | ------------------------------ | | type | string | 是 | 注册的设备管理器 ui 状态回调,以便在状态改变时通知应用。 | - | callback | Callback<{ param: string}> | 是 | 指示要注册的设备管理器 ui 状态回调,返回ui状态。 | + | callback | Callback<{ param: string}> | 是 | 指示要注册的设备管理器 ui 状态回调,返回ui状态。 | **示例:** @@ -850,9 +850,9 @@ ui状态变更回调。 } ``` -### off('uiStateChange')9+
+### off('uiStateChange')9+ -off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void; +off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void; 取消ui状态变更回调 @@ -860,10 +860,10 @@ off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void; **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | ------------------------------ | | type | string | 是 | 取消注册的设备管理器 ui 状态回调。 | - | callback | Callback<{ param: string}> | 是 | 指示要取消注册的设备管理器 ui 状态,返回UI状态。 | + | callback | Callback<{ param: string}> | 否 | 指示要取消注册的设备管理器 ui 状态,返回UI状态。 | **示例:** @@ -885,7 +885,7 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------ | | type | string | 是 | 注册设备状态回调,固定为deviceStateChange。 | | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | 是 | 指示要注册的设备状态回调,返回设备状态和设备信息。 | @@ -912,10 +912,10 @@ off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChang **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | --------------------------- | | type | string | 是 | 根据应用程序的包名取消注册设备状态回调。 | - | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo)  }> | 是 | 指示要取消注册的设备状态回调,返回设备状态和设备信息。 | + | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | 否 | 指示要取消注册的设备状态回调,返回设备状态和设备信息。 | **示例:** @@ -939,10 +939,10 @@ on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: Dev **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | -------------------------- | | type | string | 是 | 注册设备发现回调,以便在发现周边设备时通知应用程序。 | - | callback | Callback<{ subscribeId: number, device: DeviceInfo }> | 是 | 注册设备发现的回调方法。 | + | callback | Callback<{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }> | 是 | 注册设备发现的回调方法。 | **示例:** @@ -966,10 +966,10 @@ off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: D **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | --------------------------- | | type | string | 是 | 取消注册设备发现回调。 | - | callback | Callback<{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }> | 是 | 指示要取消注册的设备发现回调,返回设备状态和设备信息。 | + | callback | Callback<{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }> | 否 | 指示要取消注册的设备发现回调,返回设备状态和设备信息。 | **示例:** @@ -993,10 +993,10 @@ on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: nu **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------ | | type | string | 是 | 注册设备发现失败回调,以便在发现周边设备失败时通知应用程序。 | - | callback | Callback<{ subscribeId: number, reason: number }> | 是 | 注册设备发现失败的回调方法。 | + | callback | Callback<{ subscribeId: number, reason: number }> | 是 | 注册设备发现失败的回调方法。 | **示例:** @@ -1020,10 +1020,10 @@ off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------------- | | type | string | 是 | 取消注册设备发现失败回调。 | - | callback | Callback<{ subscribeId: number, reason: number }> | 是 | 指示要取消注册的设备发现失败回调。 | + | callback | Callback<{ subscribeId: number, reason: number }> | 否 | 指示要取消注册的设备发现失败回调。 | **示例:** @@ -1037,7 +1037,7 @@ off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: } ``` -### on('publishSuccess')9+
+### on('publishSuccess')9+ on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): void @@ -1047,10 +1047,10 @@ on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): voi **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | -------------------------- | | type | string | 是 | 注册发布设备成功回调,以便将发布成功时通知应用程序。 | - | callback | Callback<{ publishId: number }> | 是 | 注册设备发布成功的回调方法。 | + | callback | Callback<{ publishId: number }> | 是 | 注册设备发布成功的回调方法。 | **示例:** @@ -1065,7 +1065,7 @@ on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): voi } ``` -### off('publishSuccess')9+
+### off('publishSuccess')9+ off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): void @@ -1075,10 +1075,10 @@ off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): v **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | --------------------------- | | type | string | 是 | 取消注册设备发布成功回调。 | - | callback | Callback<{ publishId: number }> | 是 | 指示要取消注册的设备发布成功回调。 | + | callback | Callback<{ publishId: number }> | 否 | 指示要取消注册的设备发布成功回调。 | **示例:** @@ -1092,7 +1092,7 @@ off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): v } ``` -### on('publishFail')9+
+### on('publishFail')9+ on(type: 'publishFail', callback: Callback<{ publishId: number, reason: number }>): void @@ -1102,10 +1102,10 @@ on(type: 'publishFail', callback: Callback<{ publishId: number, reason: numbe **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------------- | ---- | ------------------------------ | | type | string | 是 | 注册设备发布失败回调,以便在发布设备失败时通知应用程序。 | - | callback | Callback<{ publishId: number, reason: number }> | 是 | 注册设备发布失败的回调方法。 | + | callback | Callback<{ publishId: number, reason: number }> | 是 | 注册设备发布失败的回调方法。 | **示例:** @@ -1119,7 +1119,7 @@ on(type: 'publishFail', callback: Callback<{ publishId: number, reason: numbe } ``` -### off('publishFail')9+
+### off('publishFail')9+ off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: number }>): void @@ -1129,10 +1129,10 @@ off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: num **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------------- | ---- | ----------------- | | type | string | 是 | 取消注册设备发布失败回调。 | - | callback | Callback<{ publishId: number, reason: number }> | 是 | 指示要取消注册设备发布失败回调。 | + | callback | Callback<{ publishId: number, reason: number }> | 否 | 指示要取消注册设备发布失败回调。 | **示例:** @@ -1156,7 +1156,7 @@ on(type: 'serviceDie', callback: () => void): void **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | ---------------------------------------- | | type | string | 是 | 注册serviceDie回调,以便在devicemanager服务异常终止时通知应用程序。 | | callback | () => void | 是 | 注册serviceDie的回调方法。 | @@ -1183,7 +1183,7 @@ off(type: 'serviceDie', callback?: () => void): void **参数:** - | 名称 | 参数类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | ---------------------------------------- | | type | string | 是 | 取消注册serviceDie回调,以便在devicemanager服务异常终止时通知应用程序。 | | callback | () => void | 否 | 取消注册serviceDie的回调方法。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md b/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md deleted file mode 100644 index facfc200a5d4cb84090fb641aecc3392461d4429..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md +++ /dev/null @@ -1,22 +0,0 @@ -# DispatchInfo - - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - - -调度信息类 - -## DispatchInfo - -**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.FreeInstall - -**系统API:**此接口为系统接口,三方应用不支持调用 - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------------------ | ------ | ---- | ---- | ------------------------ | -| version | string | 是 | 否 | 包含dispatchInfo版本信息 | -| dispatchAPIVersion | string | 是 | 否 | 包含免安装接口版本号 | - diff --git a/zh-cn/application-dev/reference/apis/js-apis-display.md b/zh-cn/application-dev/reference/apis/js-apis-display.md index 3541d6f2d145842797d0f052eee8a3e3fa9a009e..aa22f55e0c5128428590b9d5bd704f65e9bf706a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -236,7 +236,7 @@ on(type: 'add'|'remove'|'change', callback: Callback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| type | string | 是 | 监听事件。
- type为"add",表示增加显示设备事件。例如:PC上插入显示器。
- type为"remove",表示移除显示设备事件。例如:PC上移除显示器。
- type为"change",表示改变显示设备事件。例如:显示器方向改变。 | +| type | string | 是 | 监听事件。
- type为"add",表示增加显示设备事件。例如:插入显示器。
- type为"remove",表示移除显示设备事件。例如:移除显示器。
- type为"change",表示改变显示设备事件。例如:显示器方向改变。 | | callback | Callback<number> | 是 | 回调函数。返回监听到的显示设备的id。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md index 6501cbf3d71da90d07e6db905ff2c3738a7f1751..93c96717ce46016e99d1c3326bdd61d025b6e87d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @@ -162,7 +162,7 @@ getKVStore<T extends KVStore>(storeId: string, options: Options, callback: | ----- | ------ | ------ | ------ | | storeId | string | 是 | 数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | | options | [Options](#options) | 是 | 创建KVStore实例的配置信息。 | -| callback | AsyncCallback<T>,<T extends [KVStore](#kvstore)> | 是 | 回调函数。返回创建的KVStore数据库实例。 | +| callback | AsyncCallback<T> | 是 | 回调函数。返回创建的KVStore数据库实例。 | **示例:** @@ -2328,7 +2328,7 @@ putBatch(entries: Entry[], callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | entries |[Entry](#entry)[] | 是 |表示要批量插入的键值对。 | -| callback |Asyncallback<void> |是 |回调函数。 | +| callback |AsyncCallback<void> |是 |回调函数。 | **示例:** @@ -2955,7 +2955,7 @@ get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | numb | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | -| callback |AsyncCallback<Uint8Array \| string \| boolean \| number>) | 是 |回调函数。返回获取查询的值。 | +| callback |AsyncCallback<Uint8Array \| string \| boolean \| number> | 是 |回调函数。返回获取查询的值。 | **示例:** @@ -4369,7 +4369,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvS | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | keyPrefix |string | 是 |表示要匹配的键前缀。 | -| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数。返回与指定设备ID和key前缀匹配的KvStoreResultSet对象。 | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数。返回与指定设备ID和key前缀匹配的KvStoreResultSet对象。 | **示例:** @@ -4409,7 +4409,7 @@ getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet&g | 类型 | 说明 | | ------ | ------- | -|Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise对象。返回与指定设备ID和key前缀匹配的KvStoreResultSet对象。| +|Promise<[KvStoreResultSet](#kvstoreresultset8)> |Promise对象。返回与指定设备ID和key前缀匹配的KvStoreResultSet对象。| **示例:** @@ -4447,7 +4447,7 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回与指定Query对象匹配的KvStoreResultSet对象。 | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数,返回与指定Query对象匹配的KvStoreResultSet对象。 | **示例:** @@ -4504,7 +4504,7 @@ getResultSet(query: Query): Promise<KvStoreResultSet> | 类型 | 说明 | | ------ | ------- | -|Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise对象。返回与指定Query对象匹配的KvStoreResultSet对象。| +|Promise<[KvStoreResultSet](#kvstoreresultset8)> |Promise对象。返回与指定Query对象匹配的KvStoreResultSet对象。| **示例:** @@ -4564,7 +4564,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreR | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |KvStoreResultSet对象所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | -| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数。返回与指定设备ID和Query对象匹配的KvStoreResultSet对象。 | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数。返回与指定设备ID和Query对象匹配的KvStoreResultSet对象。 | **示例:** @@ -4621,7 +4621,7 @@ getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet> | 类型 | 说明 | | ------ | ------- | -|Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise对象。返回与指定设备ID和Query对象匹配的KvStoreResultSet对象。| +|Promise<[KvStoreResultSet](#kvstoreresultset8)> |Promise对象。返回与指定设备ID和Query对象匹配的KvStoreResultSet对象。| **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributedBundle.md b/zh-cn/application-dev/reference/apis/js-apis-distributedBundle.md index 4609135f3f65cdd95c9aad4a917e26a5633f4966..55fb10d7444ac0b12ae812f95bbfbe27be230b39 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributedBundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributedBundle.md @@ -53,7 +53,7 @@ getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback\; |----------|-------------------------| | 17700001 | The specified bundle 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. | **示例:** @@ -158,7 +158,7 @@ getRemoteAbilityInfo(elementNames: Array\, callback: AsyncCallback\ |----------|-------------------------| | 17700001 | The specified bundle 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. | **示例:** @@ -221,7 +221,7 @@ getRemoteAbilityInfo(elementNames: Array\): Promise\, locale: string, callback |---------------|-------------------------| | 17700001 | The specified bundle 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. | **示例:** @@ -449,7 +449,7 @@ getRemoteAbilityInfo(elementNames: Array\, locale: string): Promise |----------|-------------------------| | 17700001 | The specified bundle 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. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md b/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md index bec88516f18b34a540732e0226186a56a7dc4bb4..8a8c6fef9eee8e22d9e799723cc1b9209960ff9a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md @@ -2269,7 +2269,7 @@ putBatch(entries: Entry[], callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | ------------------------ | | entries | [Entry](#entry)[] | 是 | 表示要批量插入的键值对。 | -| callback | Asyncallback<void> | 是 | 回调函数。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **错误码:** @@ -2396,7 +2396,7 @@ putBatch(value: Array<ValuesBucket>, callback: AsyncCallback<void>): | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------ | | value | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | 是 | 表示要插入的数据。 | -| callback | Asyncallback<void> | 是 | 回调函数。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **错误码:** @@ -2605,7 +2605,7 @@ delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallb | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **错误码:** @@ -2651,7 +2651,7 @@ delete(predicates: dataSharePredicates.DataSharePredicates): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | **返回值:** @@ -2941,7 +2941,7 @@ get(key: string, callback: AsyncCallback) | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | -| callback |AsyncCallback<boolean \| string \| number \| Uint8Array>) | 是 |回调函数。返回获取查询的值。 | +| callback |AsyncCallback<boolean \| string \| number \| Uint8Array> | 是 |回调函数。返回获取查询的值。 | **错误码:** @@ -3566,7 +3566,7 @@ getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: Asyn | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | | callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | 是 | 回调函数,获取与指定Predicates对象匹配的KVStoreResultSet对象。 | **错误码:** @@ -3622,7 +3622,7 @@ getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise<KV | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | **返回值:** @@ -5311,7 +5311,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KVS | --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | deviceId | string | 是 | 标识要查询其数据的设备。 | | keyPrefix | string | 是 | 表示要匹配的键前缀。 | -| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)[]> | 是 | 回调函数。返回与指定设备ID和key前缀匹配的KVStoreResultSet对象。 | +| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | 是 | 回调函数。返回与指定设备ID和key前缀匹配的KVStoreResultSet对象。 | **错误码:** @@ -5367,7 +5367,7 @@ getResultSet(deviceId: string, keyPrefix: string): Promise<KVStoreResultSet&g | 类型 | 说明 | | ------------------------------------------------------ | ------------------------------------------------------------ | -| Promise<[KVStoreResultSet](#kvstoreresultset)[]> | Promise对象。返回与指定设备ID和key前缀匹配的KVStoreResultSet对象。 | +| Promise<[KVStoreResultSet](#kvstoreresultset)> | Promise对象。返回与指定设备ID和key前缀匹配的KVStoreResultSet对象。 | **错误码:** @@ -5414,7 +5414,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KVStoreR | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | deviceId | string | 是 | KVStoreResultSet对象所属的设备ID。 | | query | [Query](query) | 是 | 表示查询对象。 | -| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)[]> | 是 | 回调函数。返回与指定设备ID和Query对象匹配的KVStoreResultSet对象。 | +| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | 是 | 回调函数。返回与指定设备ID和Query对象匹配的KVStoreResultSet对象。 | **错误码:** @@ -5491,7 +5491,7 @@ getResultSet(deviceId: string, query: Query): Promise<KVStoreResultSet> | 类型 | 说明 | | ------------------------------------------------------ | ------------------------------------------------------------ | -| Promise<[KVStoreResultSet](#kvstoreresultset)[]> | Promise对象。返回与指定设备ID和Query对象匹配的KVStoreResultSet对象。 | +| Promise<[KVStoreResultSet](#kvstoreresultset)> | Promise对象。返回与指定设备ID和Query对象匹配的KVStoreResultSet对象。 | **错误码:** @@ -5561,7 +5561,7 @@ getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicat | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | deviceId | string | 是 | 标识要查询其数据的设备。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | | callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | 是 | 回调函数,获取与指定Predicates对象匹配的KVStoreResultSet对象。 | **错误码:** @@ -5618,7 +5618,7 @@ getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicat | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | | deviceId | string | 是 | 标识要查询其数据的设备。 | -| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceInfo.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceInfo.md deleted file mode 100644 index 1551ab55fe4bbe2b4e22c36145d54b0c174cd0b5..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceInfo.md +++ /dev/null @@ -1,104 +0,0 @@ -# 企业设备信息管理 - -本模块提供企业设备信息管理能力,包括获取设备序列号等。仅企业设备管理员应用才能调用。 - -> **说明:** -> -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## 导入模块 - -```js -import deviceInfo from '@ohos.enterprise.deviceInfo'; -``` - -## deviceInfo.getDeviceSerial - -getDeviceSerial(admin: Want, callback: AsyncCallback): void - -获取设备序列号,使用callback形式返回设备序列号。 - -**需要权限:** ohos.permission.ENTERPRISE_GET_DEVICE_INFO - -**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager - -**系统API**: 此接口为系统接口。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | -| callback | AsyncCallback<string> | 是 | callback方式返回设备序列号 | - -**错误码**: - -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) - -| 类型 | 说明 | -| ------- | ---------------------------------------------------------------------------- | -| 9200001 | The application is not a administrator of the device. | -| 9200002 | the administrator application does not have permission to manage the device. | - -**示例:** - -```js -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -deviceInfo.getDeviceSerial(wantTemp, (error, result) => { - if (error != null) { - console.log("error code:" + error.code + " error message:" + error.message); - return; - } - console.log(result); -}); -``` - -## deviceInfo.getDeviceSerial - -getDeviceSerial(admin: Want, callback: AsyncCallback): void - -获取设备序列号,使用callback形式返回设备序列号。 - -**需要权限:** ohos.permission.ENTERPRISE_GET_DEVICE_INFO - -**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager - -**系统API**: 此接口为系统接口。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | - -**返回值:** - -| 类型 | 说明 | -| --------------------- | ------------------------- | -| Promise<string> | Promise方式返回设备序列号 | - -**错误码**: - -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) - -| 类型 | 说明 | -| ------- | ---------------------------------------------------------------------------- | -| 9200001 | The application is not a administrator of the device. | -| 9200002 | the administrator application does not have permission to manage the device. | - -**示例:** - -```js -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -deviceInfo.getDeviceSerial(wantTemp).then((result) => { - console.log(result); -}).catch(error => { - console.log("error code:" + error.code + " error message:" + error.message); -}); -``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md index 02420af54b470196cc8ca4ddac266174aaa808a2..181e7c03165c457c078437ba690af67eb6c799cb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md +++ b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md @@ -23,7 +23,6 @@ export default class MainAbility extends Ability { } ``` - ## EventHub.on on(event: string, callback: Function): void; diff --git a/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md b/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md index 8a844f7c141ed323a759a2db23212e7e8f016c5a..1534e378c585b37c110aadc783018518f05453ac 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md +++ b/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md @@ -12,9 +12,9 @@ import faultLogger from '@ohos.faultLogger' 故障类型枚举。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.Hiview.FaultLogger。 +**系统能力:** SystemCapability.HiviewDFX.Hiview.FaultLogger -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | -------- | -------- | | NO_SPECIFIC | 0 | 不区分故障类型 | | CPP_CRASH | 2 | C++程序故障类型 | @@ -25,9 +25,9 @@ import faultLogger from '@ohos.faultLogger' 故障信息数据结构,获取到的故障信息的数据结构。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.Hiview.FaultLogger。 +**系统能力:** SystemCapability.HiviewDFX.Hiview.FaultLogger -| 名称 | 参数类型 | 说明 | +| 名称 | 类型 | 说明 | | -------- | -------- | -------- | | pid | number | 故障进程的进程id | | uid | number | 故障进程的用户id | @@ -53,7 +53,7 @@ querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<Faul | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | faultType | [FaultType](#faulttype) | 是 | 输入要查询的故障类型。 | -| callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloginfo)>> | 是 | 回调函数,在回调函数中获取故障信息数组。
- value拿到故障信息数组;value为undefined表示获取过程中出现异常,error返回错误提示字符串 +| callback | AsyncCallback<Array<[FaultLogInfo](#faultloginfo)>> | 是 | 回调函数,在回调函数中获取故障信息数组。
- value拿到故障信息数组;value为undefined表示获取过程中出现异常,error返回错误提示字符串 **示例:** @@ -138,13 +138,13 @@ query(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo> | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | faultType | [FaultType](#faulttype) | 是 | 输入要查询的故障类型。 | -| callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloginfo)>> | 是 | 回调函数,在回调函数中获取故障信息数组。
- value拿到故障信息数组;value为undefined表示获取过程中出现异常,error返回错误提示字符串 +| callback | AsyncCallback<Array<[FaultLogInfo](#faultloginfo)>> | 是 | 回调函数,在回调函数中获取故障信息数组。
- value拿到故障信息数组;value为undefined表示获取过程中出现异常,error返回错误提示字符串 **错误码:** 以下错误码的详细介绍参见[ohos.faultLogger错误码](../errorcodes/errorcode-faultlogger.md)。 -| 错误码ID | 错误信息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | | --- | --- | | 10600001 | The service is not running or broken | @@ -201,7 +201,7 @@ query(faultType: FaultType) : Promise<Array<FaultLogInfo>> 以下错误码的详细介绍参见[ohos.faultLogger错误码](../errorcodes/errorcode-faultlogger.md)。 -| 错误码ID | 错误信息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | | --- | --- | | 10600001 | The service is not running or broken | diff --git a/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md b/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md index 904e7d0854931644be98e6a66d2e5785e0a87485..537f2a233fb591bb878d160fea9614c8f5f85a62 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md @@ -27,7 +27,7 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\) **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ---------------------------------------- | ---- | -------------- | | parameter | [StartAbilityParameter](#startabilityparameter) | 是 | 表示被启动的Ability。 | | callback | AsyncCallback\ | 是 | 被指定的回调方法。 | @@ -70,7 +70,7 @@ startAbility(parameter: StartAbilityParameter): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ---------------------------------------- | ---- | -------------- | | parameter | [StartAbilityParameter](#startabilityparameter) | 是 | 表示被启动的Ability。 | @@ -109,7 +109,7 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------ | | uri | string | 是 | 指示要打开的文件的路径。 | @@ -138,7 +138,7 @@ startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ---------------------------------------- | ---- | -------------- | | parameter | [StartAbilityParameter](#startabilityparameter) | 是 | 表示被启动的Ability。 | | callback | AsyncCallback\<[AbilityResult](#abilityresult)> | 是 | 被指定的回调方法。 | @@ -179,7 +179,7 @@ startAbilityForResult(parameter: StartAbilityParameter): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ---------------------------------------- | ---- | ------------- | | parameter | [StartAbilityParameter](#startabilityparameter) | 是 | 表示被启动的Ability | @@ -235,7 +235,7 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------------- | ---- | -------------- | | parameter | [AbilityResult](#abilityresult) | 是 | 表示被启动的Ability。 | | callback | AsyncCallback\ | 是 | 被指定的回调方法。 | @@ -287,7 +287,7 @@ terminateSelfWithResult(parameter: AbilityResult): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------------- | ---- | ------------- | | parameter | [AbilityResult](#abilityresult) | 是 | 表示被启动的Ability | @@ -343,7 +343,7 @@ hasWindowFocus(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | ---------------------------------------- | | callback | AsyncCallback\ | 是 | 被指定的回调方法。
如果此Ability当前具有视窗焦点,则返回true;否则返回false。 | @@ -389,7 +389,7 @@ getWant(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | --------- | | callback | AsyncCallback\<[Want](js-apis-application-Want.md)> | 是 | 被指定的回调方法。 | @@ -459,7 +459,7 @@ terminateSelf(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | -------- | | callback | AsyncCallback\ | 是 | 被指定的回调方法 | @@ -507,7 +507,7 @@ connectAbility(request: Want, options:ConnectOptions): number **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | -------------- | ---- | --------------------- | | request | [Want](js-apis-application-Want.md) | 是 | 表示被连接的ServiceAbility。 | | options | [ConnectOptions](#connectoptions) | 是 | 被指定的回调方法。 | @@ -518,7 +518,7 @@ ConnectOptions类型说明 **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core -| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| 参数名 | 读写属性 | 类型 | 必填 | 说明 | | ------------ | ---- | -------- | ---- | ------------------------- | | onConnect7+ | 只读 | function | 是 | 连接成功时的回调函数。 | | onDisconnect7+ | 只读 | function | 是 | 连接失败时的回调函数。 | @@ -568,7 +568,7 @@ disconnectAbility(connection: number, callback:AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | -------------------- | ---- | ----------------------- | | connection | number | 是 | 指定断开连接的ServiceAbilityID | | callback | AsyncCallback\ | 是 | 被指定的回调方法 | @@ -615,7 +615,7 @@ disconnectAbility(connection: number): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ----------------------- | | connection | number | 是 | 指定断开连接的ServiceAbilityID | @@ -669,7 +669,7 @@ getWindow(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | ----------------------------- | | callback | AsyncCallback\ | 是 | 返回与当前Ability对应的窗口。 | @@ -713,7 +713,7 @@ onConnect(elementName: ElementName, remote: rpc.IRemoteObject): void; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ----------------- | ---- | -------- | | elementName | ElementName | 是 | 元素名。 | | remote | rpc.IRemoteObject | 是 | rpc远程对象。 | @@ -756,7 +756,7 @@ onDisconnect(elementName: ElementName): void; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ----------- | ---- | ---- | | elementName | ElementName | 是 | 元素名。 | @@ -798,7 +798,7 @@ ConnectAbility调用失败时的回调函数。 **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | --------- | | code | number | 是 | number类型。 | @@ -846,7 +846,7 @@ featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.FAModel -| 名称 | 参数 | 描述 | +| 名称 | 值 | 说明 | | ---------------------------------------- | ---- | ---------------------------------------- | | WINDOW_MODE_UNDEFINED7+ | 0 | 未定义。 | | WINDOW_MODE_FULLSCREEN7+ | 1 | 全屏。 | @@ -869,11 +869,11 @@ featureAbility.AbilityStartSetting.BOUNDS_KEY **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.FAModel -| 名称 | 参数 | 描述 | +| 名称 | 值 | 说明 | | ---------------------------- | --------------- | ---------------------------------------- | -| BOUNDS_KEY7+ | "abilityBounds" | 窗口显示大小属性的名称。 | -| WINDOW_MODE_KEY7+ | "windowMode" | 窗口显示模式属性的名称。| -| DISPLAY_ID_KEY7+ | "displayId" | 窗口显示设备ID属性的名称。 | +| BOUNDS_KEY7+ | "abilityBounds" | 窗口显示大小属性的参数名。 | +| WINDOW_MODE_KEY7+ | "windowMode" | 窗口显示模式属性的参数名。| +| DISPLAY_ID_KEY7+ | "displayId" | 窗口显示设备ID属性的参数名。 | ## ErrorCode @@ -881,7 +881,7 @@ featureAbility.AbilityStartSetting.BOUNDS_KEY **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.FAModel -| 变量 | 值 | 说明 | +| 名称 | 值 | 说明 | | ------------------------------ | ---- | ---------------------------------------- | | NO_ERROR7+ | 0 | 没有错误。 | | INVALID_PARAMETER7+ | -1 | 无效的参数。 | @@ -895,7 +895,7 @@ featureAbility.AbilityStartSetting.BOUNDS_KEY **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.FAModel -| 变量 | 值 | 说明 | +| 名称 | 值 | 说明 | | ------------------------ | ---- | ---------------------------------------- | | TYPE_INSERT7+ | 1 | 插入类型。 | | TYPE_UPDATE7+ | 2 | 修改类型。 | @@ -908,25 +908,25 @@ featureAbility.AbilityStartSetting.BOUNDS_KEY **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ----------------------- | ---- | ------------- | ---- | ------------------------------------- | -| resultCode7+ | 只读 | number | 是 | 指示销毁该能力后返回的结果代码。您可以定义结果代码来识别错误(暂不支持)。 | -| want7+ | 只读 | [Want](js-apis-application-Want.md) | 否 | 指示销毁该能力后返回的数据。您可以定义返回的数据。此参数可以为null。 | +| 名称 | 类型 | 可读| 可写 | 必填 | 说明 | +| --------------- |-------- | ------ | ------------- | ---- | ------------------------------------- | +| resultCode7+| number| 是 | 否 | 是 | 指示销毁该能力后返回的结果代码。您可以定义结果代码来识别错误(暂不支持)。 | +| want7+ | [Want](js-apis-application-Want.md)| 是 | 否 | 否 | 指示销毁该能力后返回的数据。您可以定义返回的数据。此参数可以为null。 | ## StartAbilityParameter **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.FAModel -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ------------------- | ---- | -------------------- | ---- | -------------------------------------- | -| want | 只读 | [Want](js-apis-application-Want.md) | 是 | 表示需要包含有关目标启动能力的信息。 | -| abilityStartSetting | 只读 | {[key: string]: any} | 否 | 表示能力的特殊属性,当开发者启动能力时,该属性可以作为调用中的输入参数传递。 | +| 参数名 | 类型 | 可读| 可写 | 必填 | 说明 | +| ------------------- | -------- | -------------------- | ---- | -------------------------------------- | +| want | [Want](js-apis-application-Want.md)| 是 | 否 | 是 | 表示需要包含有关目标启动能力的信息。 | +| abilityStartSetting | {[key: string]: any} | 是 |否 | 否 | 表示能力的特殊属性,当开发者启动能力时,该属性可以作为调用中的输入参数传递。 | ## flags说明 **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase -| 名称 | 参数 | 描述 | +| 名称 | 值 | 说明 | | ------------------------------------ | ---------- | ---------------------------------------- | | FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | 指示对URI执行读取操作的授权。 | | FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | 指示对URI执行写入操作的授权。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index 4d5643fc7481e3a9f04d44e79b062fa851d635b6..9880350580321a96304e73f59b72f6c4522bf80b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -385,7 +385,7 @@ closeSync(fd: number): void ## fileio.copyFile -copyFile(src: string | number, dest: string | number, mode?: number): Promise<void> +copyFile(src: string|number, dest: string|number, mode?: number): Promise<void> 复制文件,使用Promise异步回调。 @@ -395,8 +395,8 @@ copyFile(src: string | number, dest: string | number, mode?: number): Promise< | 参数名 | 类型 | 必填 | 说明 | | ---- | -------------------------- | ---- | ---------------------------------------- | - | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | - | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | + | src | string\|number | 是 | 待复制文件的路径或待复制文件的描述符。 | + | dest | string\|number | 是 | 目标文件路径或目标文件描述符。 | | mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。
0:完全覆盖目标文件,未覆盖部分将被裁切掉。 | **返回值:** @@ -915,7 +915,7 @@ unlinkSync(path: string): void ## fileio.write -write(fd: number, buffer: ArrayBuffer | string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): Promise<number> +write(fd: number, buffer: ArrayBuffer|string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): Promise<number> 将数据写入文件,使用Promise异步回调。 @@ -926,7 +926,7 @@ write(fd: number, buffer: ArrayBuffer | string, options?: { offset?: number; len | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | 是 | 待写入文件的文件描述符。 | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | buffer | ArrayBuffer\|string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
约束:offset+length<=buffer.size。 | **返回值:** @@ -3020,7 +3020,7 @@ write(buffer: ArrayBuffer|string, options: { offset?: number; length?: number; p ### writeSync7+ -writeSync(buffer: ArrayBuffer | string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): number +writeSync(buffer: ArrayBuffer|string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): number 以同步方法将数据写入流文件。 @@ -3030,7 +3030,7 @@ writeSync(buffer: ArrayBuffer | string, options?: { offset?: number; length?: nu | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------------------------------------- | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | buffer | ArrayBuffer\|string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
约束:offset+length<=buffer.size。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md b/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md index eef03ac00d7a5e57358e2ea677a5d59e2370bb66..ce3b837eace82c797d35893d8d4bc74f499dd443 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md +++ b/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md @@ -363,10 +363,6 @@ getDispatchInfo(callback: AsyncCallback\): void; | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | callback | AsyncCallback<[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)> | 是 | 回调函数。当函数调用成功,err为null,data为获取到的[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)信息。否则为错误对象。 | -**错误码:** - -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 - **示例:** ```js @@ -402,10 +398,6 @@ getDispatchInfo(): Promise\; | ------------------------------------------------ | ------------------------------------------------------------ | | Promise<[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)> | Promise对象,返回[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)信息。 | -**错误码:** - -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 - **示例:** ```js diff --git a/zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md b/zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md index 7f46f13cb22bfa0731e00c2eb2ee997eb64e7ac0..aacaa3135597ee870ae8297b5344b91fc39e1deb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md @@ -41,735 +41,11 @@ import geoLocationManager from '@ohos.geoLocationManager'; ``` -## geoLocationManager.on('locationChange') - -on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>): void - -开启位置变化订阅,并发起定位请求。定位结果按照[LocationRequest](#locationrequest)的属性进行上报, - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“locationChange”,表示位置变化。 | - | request | [LocationRequest](#locationrequest) | 是 | 设置位置请求参数。 | - | callback | Callback<[Location](#location)> | 是 | 接收位置变化状态变化监听。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301200 | Failed to obtain the geographical location. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; - var locationChange = (location) => { - console.log('locationChanger: data: ' + JSON.stringify(location)); - }; - try { - geoLocationManager.on('locationChange', requestInfo, locationChange); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - - ``` - - -## geoLocationManager.off('locationChange') - -off(type: 'locationChange', callback?: Callback<Location>): void - -关闭位置变化订阅,并删除对应的定位请求。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“locationChange”,表示位置变化。 | - | callback | Callback<[Location](#location)> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301200 | Failed to obtain the geographical location. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; - var locationChange = (location) => { - console.log('locationChanger: data: ' + JSON.stringify(location)); - }; - try { - geoLocationManager.on('locationChange', requestInfo, locationChange); - geoLocationManager.off('locationChange', locationChange); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - -## geoLocationManager.on('locationEnabledChange') - -on(type: 'locationEnabledChange', callback: Callback<boolean>): void - -订阅位置服务状态变化。 - -**系统能力**:SystemCapability.Location.Location.Core - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“locationEnabledChange”,表示位置服务状态。 | - | callback | Callback<boolean> | 是 | 接收位置服务状态变化监听。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var locationEnabledChange = (state) => { - console.log('locationEnabledChange: ' + JSON.stringify(state)); - } - try { - geoLocationManager.on('locationEnabledChange', locationEnabledChange); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - -## geoLocationManager.off('locationEnabledChange') - -off(type: 'locationEnabledChange', callback?: Callback<boolean>): void; - -取消订阅位置服务状态变化。 - -**系统能力**:SystemCapability.Location.Location.Core - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“locationEnabledChange”,表示位置服务状态。 | - | callback | Callback<boolean> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var locationEnabledChange = (state) => { - console.log('locationEnabledChange: state: ' + JSON.stringify(state)); - } - try { - geoLocationManager.on('locationEnabledChange', locationEnabledChange); - geoLocationManager.off('locationEnabledChange', locationEnabledChange); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - -## geoLocationManager.on('cachedGnssLocationsChange') - -on(type: 'cachedGnssLocationsChange', request: CachedGnssLocationsRequest, callback: Callback<Array<Location>>): void; - -订阅缓存GNSS定位结果上报事件。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Gnss - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“cachedGnssLocationsChange”,表示GNSS缓存定位结果上报。 | - | request | [CachedGnssLocationsRequest](#cachedgnsslocationsrequest) | 是 | GNSS缓存功能配置参数 | - | callback | Callback<boolean> | 是 | 接收GNSS缓存位置上报。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301200 | Failed to obtain the geographical location. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var cachedLocationsCb = (locations) => { - console.log('cachedGnssLocationsChange: locations: ' + JSON.stringify(locations)); - } - var requestInfo = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true}; - try { - geoLocationManager.on('cachedGnssLocationsChange', requestInfo, cachedLocationsCb); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - -## geoLocationManager.off('cachedGnssLocationsChange') - -off(type: 'cachedGnssLocationsChange', callback?: Callback<Array<Location>>): void; - -取消订阅缓存GNSS定位结果上报事件。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Gnss - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“cachedGnssLocationsChange”,表示GNSS缓存定位结果上报。 | - | callback | Callback<boolean> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301200 | Failed to obtain the geographical location. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var cachedLocationsCb = (locations) => { - console.log('cachedGnssLocationsChange: locations: ' + JSON.stringify(locations)); - } - var requestInfo = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true}; - try { - geoLocationManager.on('cachedGnssLocationsChange', requestInfo, cachedLocationsCb); - geoLocationManager.off('cachedGnssLocationsChange'); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - -## geoLocationManager.on('satelliteStatusChange') - -on(type: 'satelliteStatusChange', callback: Callback<SatelliteStatusInfo>): void; - -订阅GNSS卫星状态信息上报事件。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Gnss - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“satelliteStatusChange”,表示订阅GNSS卫星状态信息上报。 | - | callback | Callback<[SatelliteStatusInfo](#satellitestatusinfo)> | 是 | 接收GNSS卫星状态信息上报。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var gnssStatusCb = (satelliteStatusInfo) => { - console.log('satelliteStatusChange: ' + JSON.stringify(satelliteStatusInfo)); - } - - try { - geoLocationManager.on('satelliteStatusChange', gnssStatusCb); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - -## geoLocationManager.off('satelliteStatusChange') - -off(type: 'satelliteStatusChange', callback?: Callback<SatelliteStatusInfo>): void; - -取消订阅GNSS卫星状态信息上报事件。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Gnss - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“satelliteStatusChange”,表示订阅GNSS卫星状态信息上报。 | - | callback | Callback<[SatelliteStatusInfo](#satellitestatusinfo)> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | - - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var gnssStatusCb = (satelliteStatusInfo) => { - console.log('satelliteStatusChange: ' + JSON.stringify(satelliteStatusInfo)); - } - try { - geoLocationManager.on('satelliteStatusChange', gnssStatusCb); - geoLocationManager.off('satelliteStatusChange', gnssStatusCb); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - -## geoLocationManager.on('nmeaMessage') - -on(type: 'nmeaMessage', callback: Callback<string>): void; - -订阅GNSS NMEA信息上报事件。 - -**需要权限**:ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Gnss - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“nmeaMessage”,表示订阅GNSS NMEA信息上报。 | - | callback | Callback<string> | 是 | 接收GNSS NMEA信息上报。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | - - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var nmeaCb = (str) => { - console.log('nmeaMessage: ' + JSON.stringify(str)); - } - - try { - geoLocationManager.on('nmeaMessage', nmeaCb ); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - -## geoLocationManager.off('nmeaMessage') - -off(type: 'nmeaMessage', callback?: Callback<string>): void; - -取消订阅GNSS NMEA信息上报事件。 - -**需要权限**:ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Gnss - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“nmeaMessage”,表示订阅GNSS NMEA信息上报。 | - | callback | Callback<string> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | - - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var nmeaCb = (str) => { - console.log('nmeaMessage: ' + JSON.stringify(str)); - } - - try { - geoLocationManager.on('nmeaMessage', nmeaCb); - geoLocationManager.off('nmeaMessage', nmeaCb); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - -## geoLocationManager.on('gnssFenceStatusChange') - -on(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): void; - -添加一个围栏,并订阅地理围栏事件。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Geofence - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“gnssFenceStatusChange”,表示订阅围栏事件上报。 | - | request | [GeofenceRequest](#geofencerequest) | 是 | 围栏的配置参数。 | - | want | WantAgent | 是 | 用于接收地理围栏事件上报(进出围栏)。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301600 | Failed to operate the geofence. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - import wantAgent from '@ohos.wantAgent'; - - let wantAgentInfo = { - wants: [ - { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", - action: "action1", - } - ], - operationType: wantAgent.OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG], - }; - - wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { - var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}}; - try { - geoLocationManager.on('gnssFenceStatusChange', requestInfo, wantAgentObj); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - }); - ``` - - -## geoLocationManager.off('gnssFenceStatusChange') - -off(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): void; - -删除一个围栏,并取消订阅该围栏事件。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Geofence - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“gnssFenceStatusChange”,表示订阅围栏事件上报。 | - | request | [GeofenceRequest](#geofencerequest) | 是 | 围栏的配置参数。 | - | want | WantAgent | 是 | 用于接收地理围栏事件上报(进出围栏)。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301600 | Failed to operate the geofence. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - import wantAgent from '@ohos.wantAgent'; - - let wantAgentInfo = { - wants: [ - { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", - action: "action1", - } - ], - operationType: wantAgent.OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - - wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { - var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}}; - try { - geoLocationManager.on('gnssFenceStatusChange', requestInfo, wantAgentObj); - geoLocationManager.off('gnssFenceStatusChange', requestInfo, wantAgentObj); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - }); - ``` - - -## geoLocationManager.on('countryCodeChange') - -on(type: 'countryCodeChange', callback: Callback<CountryCode>): void; - -订阅国家码信息变化事件。 - -**系统能力**:SystemCapability.Location.Location.Core - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“countryCodeChange”,表示订阅国家码信息变化事件。 | - | callback | Callback<[CountryCode](#countrycode)> | 是 | 接收国家码信息上报。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301500 | Failed to query the area information. | - - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var callback = (code) => { - console.log('countryCodeChange: ' + JSON.stringify(code)); - } - - try { - geoLocationManager.on('countryCodeChange', callback); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - -## geoLocationManager.off('countryCodeChange') - -off(type: 'countryCodeChange', callback?: Callback<CountryCode>): void; - -取消订阅国家码变化事件。 - -**系统能力**:SystemCapability.Location.Location.Core - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置事件类型。type为“countryCodeChange”,表示取消订阅国家码信息变化事件。 | - | callback | Callback<[CountryCode](#countrycode)> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301500 | Failed to query the area information. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var callback = (code) => { - console.log('countryCodeChange: ' + JSON.stringify(code)); - } - - try { - geoLocationManager.on('countryCodeChange', callback); - geoLocationManager.off('countryCodeChange', callback); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - - -## geoLocationManager.getCurrentLocation - -getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>): void - -获取当前位置,使用callback回调异步返回结果。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Core - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | request | [CurrentLocationRequest](#currentlocationrequest) | 是 | 设置位置请求参数。 | - | callback | AsyncCallback<[Location](#location)> | 是 | 用来接收位置信息的回调。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301200 | Failed to obtain the geographical location. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; - var locationChange = (err, location) => { - if (err) { - console.log('locationChanger: err=' + JSON.stringify(err)); - } - if (location) { - console.log('locationChanger: location=' + JSON.stringify(location)); - } - }; - - try { - geoLocationManager.getCurrentLocation(requestInfo, locationChange); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - -## geoLocationManager.getCurrentLocation - -getCurrentLocation(callback: AsyncCallback<Location>): void; - -获取当前位置,通过callback方式异步返回结果。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Core - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[Location](#location)> | 是 | 用来接收位置信息的回调。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301200 | Failed to obtain the geographical location. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var locationChange = (err, location) => { - if (err) { - console.log('locationChanger: err=' + JSON.stringify(err)); - } - if (location) { - console.log('locationChanger: location=' + JSON.stringify(location)); - } - }; - - try { - geoLocationManager.getCurrentLocation(locationChange); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - -## geoLocationManager.getCurrentLocation - -getCurrentLocation(request?: CurrentLocationRequest): Promise<Location> +## geoLocationManager.on('countryCodeChange') -获取当前位置,使用Promise方式异步返回结果。 +on(type: 'countryCodeChange', callback: Callback<CountryCode>): void; -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION +订阅国家码信息变化事件。 **系统能力**:SystemCapability.Location.Location.Core @@ -777,13 +53,8 @@ getCurrentLocation(request?: CurrentLocationRequest): Promise<Location> | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | request | [CurrentLocationRequest](#currentlocationrequest) | 否 | 设置位置请求参数。 | - -**返回值**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | Promise<[Location](#location)> | [Location](#location) | NA | 返回位置信息。 | + | type | string | 是 | 设置事件类型。type为“countryCodeChange”,表示订阅国家码信息变化事件。 | + | callback | Callback<[CountryCode](#countrycode)> | 是 | 接收国家码信息上报。 | **错误码**: @@ -793,73 +64,39 @@ getCurrentLocation(request?: CurrentLocationRequest): Promise<Location> | -------- | ---------------------------------------- | |3301000 | Location service is unavailable. | |3301100 | The location switch is off. | -|3301200 | Failed to obtain the geographical location. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - var requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; - geoLocationManager.getCurrentLocation(requestInfo).then((result) => { - console.log('current location: ' + JSON.stringify(result)); - }) - .catch((error) => { - console.log('promise, getCurrentLocation: error=' + JSON.stringify(error)); - }); - ``` - - -## geoLocationManager.getLastLocation - -getLastLocation(): Location - -获取上一次位置。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Core - -**返回值**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | Location | [Location](#location) | NA | 位置信息。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 +|3301500 | Failed to query the area information. | -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301200 |Failed to obtain the geographical location. | **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; + var callback = (code) => { + console.log('countryCodeChange: ' + JSON.stringify(code)); + } + try { - var location = geoLocationManager.getLastLocation(); + geoLocationManager.on('countryCodeChange', callback); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); } ``` -## geoLocationManager.isLocationEnabled +## geoLocationManager.off('countryCodeChange') -isLocationEnabled(): boolean +off(type: 'countryCodeChange', callback?: Callback<CountryCode>): void; -判断位置服务是否已经使能。 +取消订阅国家码变化事件。 **系统能力**:SystemCapability.Location.Location.Core -**返回值**: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | boolean | boolean | NA | 位置服务是否已经使能。 | + | type | string | 是 | 设置事件类型。type为“countryCodeChange”,表示取消订阅国家码信息变化事件。 | + | callback | Callback<[CountryCode](#countrycode)> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | **错误码**: @@ -867,98 +104,26 @@ isLocationEnabled(): boolean | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | +|3301000 | Location service is unavailable. | +|3301100 | The location switch is off. | +|3301500 | Failed to query the area information. | **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; + var callback = (code) => { + console.log('countryCodeChange: ' + JSON.stringify(code)); + } try { - var locationEnabled = geoLocationManager.isLocationEnabled(); + geoLocationManager.on('countryCodeChange', callback); + geoLocationManager.off('countryCodeChange', callback); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); } ``` -## geoLocationManager.requestEnableLocation - -requestEnableLocation(callback: AsyncCallback<boolean>): void - -请求使能位置服务,使用callback回调异步返回结果。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Core - -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | callback返回true表示用户同意使能位置服务,false表示用户不同意使能位置服务。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301700 | No response to the request. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - geoLocationManager.requestEnableLocation((err, data) => { - if (err) { - console.log('requestEnableLocation: err=' + JSON.stringify(err)); - } - if (data) { - console.log('requestEnableLocation: data=' + JSON.stringify(data)); - } - }); - ``` - - -## geoLocationManager.requestEnableLocation - -requestEnableLocation(): Promise<boolean> - -请求使能位置服务,使用Promise方式异步返回结果。 - -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION - -**系统能力**:SystemCapability.Location.Location.Core - -**返回值**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | Promise<boolean> | boolean | NA | 返回true表示用户同意使能位置服务,false表示用户不同意使能位置服务。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301700 | No response to the request. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - geoLocationManager.requestEnableLocation().then((result) => { - console.log('promise, requestEnableLocation: ' + JSON.stringify(result)); - }) - .catch((error) => { - console.log('promise, requestEnableLocation: error=' + JSON.stringify(error)); - }); - ``` - - ## geoLocationManager.enableLocation enableLocation(callback: AsyncCallback<void>): void; @@ -1037,9 +202,9 @@ enableLocation(): Promise<void> ## geoLocationManager.disableLocation -disableLocation(): void; +disableLocation(callback: AsyncCallback<void>): void; -关闭位置服务。 +关闭位置服务,使用callback回调异步返回结果。 **系统API**:此接口为系统接口,三方应用不支持调用。 @@ -1047,41 +212,11 @@ disableLocation(): void; **系统能力**:SystemCapability.Location.Location.Core -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - try { - geoLocationManager.disableLocation(); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` - - - -## geoLocationManager.getAddressesFromLocation - -getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void - -调用逆地理编码服务,将坐标转换为地理描述,使用callback回调异步返回结果。 - -**系统能力**:SystemCapability.Location.Location.Geocoder - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | 是 | 设置逆地理编码请求的相关参数。 | - | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | 是 | 接收逆地理编码结果的回调函数。 | + | callback | AsyncCallback<void> | 是 | 用来接收错误码的回调。 | **错误码**: @@ -1089,44 +224,41 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301300 | Reverse geocoding query failed. | +|3301000 | Location service is unavailable. | **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; - geoLocationManager.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { - if (err) { - console.log('getAddressesFromLocation: err=' + JSON.stringify(err)); - } - if (data) { - console.log('getAddressesFromLocation: data=' + JSON.stringify(data)); - } - }); + try { + geoLocationManager.disableLocation((err, data) => { + if (err) { + console.log('disableLocation: err=' + JSON.stringify(err)); + } + }); + } catch (err) { + console.error("errCode:" + err.code + ",errMessage:" + err.message); + } ``` -## geoLocationManager.getAddressesFromLocation +## geoLocationManager.disableLocation -getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<GeoAddress>>; +disableLocation(): Promise<void> -调用逆地理编码服务,将坐标转换为地理描述,使用Promise方式异步返回结果。 +关闭位置服务,使用Promise方式异步返回结果。 -**系统能力**:SystemCapability.Location.Location.Geocoder +**系统API**:此接口为系统接口,三方应用不支持调用。 -**参数**: +**需要权限**:ohos.permission.MANAGE_SECURE_SETTINGS - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | 是 | 设置逆地理编码请求的相关参数。 | +**系统能力**:SystemCapability.Location.Location.Core **返回值**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | Promise<Array<[GeoAddress](#geoaddress)>> | Array<[GeoAddress](#geoaddress)> | NA | 返回地理描述信息。 | + | Promise<void> | void | NA |返回错误码。 | **错误码**: @@ -1134,37 +266,37 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<Ge | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301300 | Reverse geocoding query failed. | +|3301000 | Location service is unavailable. | **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; - geoLocationManager.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { - console.log('getAddressesFromLocation: ' + JSON.stringify(data)); + geoLocationManager.disableLocation().then((result) => { + console.log('promise, disableLocation succeed'); }) .catch((error) => { - console.log('promise, getAddressesFromLocation: error=' + JSON.stringify(error)); -}); + console.log('promise, disableLocation: error=' + JSON.stringify(error)); + }); ``` -## geoLocationManager.getAddressesFromLocationName +## geoLocationManager.isLocationPrivacyConfirmed -getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void +isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>): void; -调用地理编码服务,将地理描述转换为具体坐标,使用callback回调异步返回结果。 +查询用户是否同意定位服务隐私申明,是否同意启用定位服务。只有系统应用才能调用。 -**系统能力**:SystemCapability.Location.Location.Geocoder +**系统API**:此接口为系统接口,三方应用不支持调用。 + +**系统能力**:SystemCapability.Location.Location.Core **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | request | [GeoCodeRequest](#geocoderequest) | 是 | 设置地理编码请求的相关参数。 | - | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | 是 | 接收地理编码结果的回调函数。 | + | type | [LocationPrivacyType](#locationprivacytype)| 是 | 指定隐私申明场景,例如开机向导中的隐私申明、开启网络定位功能时弹出的隐私申明等。 | + | callback | AsyncCallback<boolean> | 是 | 表示用户是否同意定位服务隐私申明。 | **错误码**: @@ -1172,44 +304,44 @@ getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback< | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301400 | Geocoding query failed. | +|3301000 | Location service is unavailable. | **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - var geocodeRequest = {"description": "上海市浦东新区xx路xx号", "maxItems": 1}; - geoLocationManager.getAddressesFromLocationName(geocodeRequest, (err, data) => { + geoLocationManager.isLocationPrivacyConfirmed(1, (err, result) => { if (err) { - console.log('getAddressesFromLocationName: err=' + JSON.stringify(err)); + console.log('isLocationPrivacyConfirmed: err=' + JSON.stringify(err)); } - if (data) { - console.log('getAddressesFromLocationName: data=' + JSON.stringify(data)); + if (result) { + console.log('isLocationPrivacyConfirmed: result=' + JSON.stringify(result)); } }); ``` -## geoLocationManager.getAddressesFromLocationName +## geoLocationManager.isLocationPrivacyConfirmed -getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAddress>> +isLocationPrivacyConfirmed(type : LocationPrivacyType,): Promise<boolean>; -调用地理编码服务,将地理描述转换为具体坐标,使用Promise方式异步返回结果。 +查询用户是否同意定位服务隐私申明,是否同意启用定位服务。只有系统应用才能调用。 -**系统能力**:SystemCapability.Location.Location.Geocoder +**系统API**:此接口为系统接口,三方应用不支持调用。 + +**系统能力**:SystemCapability.Location.Location.Core **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | request | [GeoCodeRequest](#geocoderequest) | 是 | 设置地理编码请求的相关参数。 | + | type | [LocationPrivacyType](#locationprivacytype) | 是 | 指定隐私申明场景,例如开机向导中的隐私申明、开启网络定位功能时弹出的隐私申明等。 | **返回值**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | Promise<Array<[GeoAddress](#geoaddress)>> | Array<[GeoAddress](#geoaddress)> | NA | 返回地理编码查询结果。 | + | Promise<boolean> |boolean| NA | 表示用户是否同意定位服务隐私申明。 | **错误码**: @@ -1217,71 +349,37 @@ getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAd | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301400 | Geocoding query failed. | +|3301000 | Location service is unavailable. | **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - var geocodeRequest = {"description": "上海市浦东新区xx路xx号", "maxItems": 1}; - geoLocationManager.getAddressesFromLocationName(geocodeRequest).then((result) => { - console.log('getAddressesFromLocationName: ' + JSON.stringify(result)); - }) - .catch((error) => { - console.log('promise, getAddressesFromLocationName: error=' + JSON.stringify(error)); + geoLocationManager.isLocationPrivacyConfirmed(1).then((result) => { + console.log('promise, isLocationPrivacyConfirmed: ' + JSON.stringify(result)); }); ``` -## geoLocationManager.isGeocoderAvailable - -isGeocoderAvailable(): boolean; - -判断(逆)地理编码服务状态。 - -**系统能力**:SystemCapability.Location.Location.Geocoder - -**返回值**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | boolean | boolean | NA | 返回(逆)地理编码服务是否可用。 | - -**错误码**: - -以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | - -**示例** - - ```ts - import geoLocationManager from '@ohos.geoLocationManager'; - try { - var isAvailable = geoLocationManager.isGeocoderAvailable(); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } - ``` +## geoLocationManager.setLocationPrivacyConfirmStatus -## geoLocationManager.getCachedGnssLocationsSize +setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback<void>): void; -getCachedGnssLocationsSize(callback: AsyncCallback<number>): void; +设置用户勾选定位服务隐私申明的状态,记录用户是否同意启用定位服务。只有系统应用才能调用。 -获取GNSS芯片缓存位置的个数。 +**系统API**:此接口为系统接口,三方应用不支持调用。 -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION +**需要权限**:ohos.permission.MANAGE_SECURE_SETTINGS -**系统能力**:SystemCapability.Location.Location.Gnss +**系统能力**:SystemCapability.Location.Location.Core **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<number> | 是 | 用来接收GNSS芯片缓存位置个数的回调。 | + | type | [LocationPrivacyType](#locationprivacytype) | 是 | 指定隐私申明场景,例如开机向导中的隐私申明、开启网络定位功能时弹出的隐私申明等。 | + | isConfirmed | boolean | 是 | 表示用户是否同意定位服务隐私申明。 | + | callback | AsyncCallback<void> | 是 | 接收错误码信息。 | **错误码**: @@ -1289,39 +387,44 @@ getCachedGnssLocationsSize(callback: AsyncCallback<number>): void; | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | +|3301000 | Location service is unavailable. | **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - geoLocationManager.getCachedGnssLocationsSize((err, size) => { + geoLocationManager.setLocationPrivacyConfirmStatus(1, true, (err, result) => { if (err) { - console.log('getCachedGnssLocationsSize: err=' + JSON.stringify(err)); - } - if (size) { - console.log('getCachedGnssLocationsSize: size=' + JSON.stringify(size)); + console.log('setLocationPrivacyConfirmStatus: err=' + JSON.stringify(err)); } }); ``` -## geoLocationManager.getCachedGnssLocationsSize +## geoLocationManager.setLocationPrivacyConfirmStatus -getCachedGnssLocationsSize(): Promise<number>; +setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean): Promise<void>; -获取GNSS芯片缓存位置的个数。 +设置用户勾选定位服务隐私申明的状态,记录用户是否同意启用定位服务。只有系统应用才能调用。 -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION +**系统API**:此接口为系统接口,三方应用不支持调用。 -**系统能力**:SystemCapability.Location.Location.Gnss +**需要权限**:ohos.permission.MANAGE_SECURE_SETTINGS + +**系统能力**:SystemCapability.Location.Location.Core + +**参数**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | [LocationPrivacyType](#locationprivacytype) | 是 | 指定隐私申明场景,例如开机向导中的隐私申明、开启网络定位功能时弹出的隐私申明等。 | + | isConfirmed | boolean | 是 | 表示用户是否同意定位服务隐私申明。 | **返回值**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | Promise<number> | number | NA | 返回GNSS缓存位置的个数。 | + | Promise<void> |void|NA| 接收错误码。 | **错误码**: @@ -1329,37 +432,34 @@ getCachedGnssLocationsSize(): Promise<number>; | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | +|3301000 | Location service is unavailable. | **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - geoLocationManager.getCachedGnssLocationsSize().then((result) => { - console.log('promise, getCachedGnssLocationsSize: ' + JSON.stringify(result)); - }) + geoLocationManager.setLocationPrivacyConfirmStatus(1, true).then((result) => { + console.log('promise, setLocationPrivacyConfirmStatus succeed'); + }) .catch((error) => { - console.log('promise, getCachedGnssLocationsSize: error=' + JSON.stringify(error)); + console.log('promise, disableLocation: error=' + JSON.stringify(error)); }); ``` -## geoLocationManager.flushCachedGnssLocations - -flushCachedGnssLocations(callback: AsyncCallback<void>): void; +## geoLocationManager.getCountryCode -读取并清空GNSS芯片所有缓存位置。 +getCountryCode(callback: AsyncCallback<CountryCode>): void; -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION +查询当前的国家码。 -**系统能力**:SystemCapability.Location.Location.Gnss +**系统能力**:SystemCapability.Location.Location.Core **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 用来接收错误码信息。 | + | callback | AsyncCallback<[CountryCode](#countrycode)> | 是 | 用来接收国家码。 | **错误码**: @@ -1367,37 +467,37 @@ flushCachedGnssLocations(callback: AsyncCallback<void>): void; | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301200 | Failed to obtain the geographical location. | +|3301000 | Location service is unavailable. | +|3301500 | Failed to query the area information.| **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - geoLocationManager.flushCachedGnssLocations((err, result) => { + geoLocationManager.getCountryCode((err, result) => { if (err) { - console.log('flushCachedGnssLocations: err=' + JSON.stringify(err)); + console.log('getCountryCode: err=' + JSON.stringify(err)); + } + if (result) { + console.log('getCountryCode: result=' + JSON.stringify(result)); } }); ``` -## geoLocationManager.flushCachedGnssLocations - -flushCachedGnssLocations(): Promise<void>; +## geoLocationManager.getCountryCode -读取并清空GNSS芯片所有缓存位置。 +getCountryCode(): Promise<CountryCode>; -**需要权限**:ohos.permission.APPROXIMATELY_LOCATION +查询当前的国家码。 -**系统能力**:SystemCapability.Location.Location.Gnss +**系统能力**:SystemCapability.Location.Location.Core **返回值**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | Promise<void> | void | NA | 接收错误码。 | + | Promise<[CountryCode](#countrycode)> | [CountryCode](#countrycode) | NA | 用来接收国家码。 | **错误码**: @@ -1405,37 +505,38 @@ flushCachedGnssLocations(): Promise<void>; | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | -|3301200 | Failed to obtain the geographical location. | +|3301000 | Location service is unavailable. | +|3301500 | Failed to query the area information.| **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - geoLocationManager.flushCachedGnssLocations().then((result) => { - console.log('promise, flushCachedGnssLocations success'); + geoLocationManager.getCountryCode() + .then((result) => { + console.log('promise, getCountryCode: result=' + JSON.stringify(result)); }) .catch((error) => { - console.log('promise, flushCachedGnssLocations: error=' + JSON.stringify(error)); + console.log('promise, getCountryCode: error=' + JSON.stringify(error)); }); ``` -## geoLocationManager.sendCommand +## geoLocationManager.enableLocationMock -sendCommand(command: LocationCommand, callback: AsyncCallback<void>): void; +enableLocationMock(callback: AsyncCallback<void>): void; -给位置服务子系统的各个部件发送扩展命令。 +使能位置模拟功能。 **系统能力**:SystemCapability.Location.Location.Core +**系统API**:此接口为系统接口,三方应用不支持调用。 + **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | command | [LocationCommand](#locationcommand) | 是 | 指定目标场景,和将要发送的命令(字符串)。 | - | callback | AsyncCallback<void> | 是 | 用来接收错误码。 | + | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | **错误码**: @@ -1443,40 +544,35 @@ sendCommand(command: LocationCommand, callback: AsyncCallback<void>): void | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -|3301000 | Location service is unavailable. | +|3301000 | Location service is unavailable. | +|3301100 | The location switch is off.| **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - var requestInfo = {'scenario': 0x301, 'command': "command_1"}; - geoLocationManager.sendCommand(requestInfo, (err, result) => { + geoLocationManager.enableLocationMock((err, result) => { if (err) { - console.log('sendCommand: err=' + JSON.stringify(err)); + console.log('enableLocationMock: err=' + JSON.stringify(err)); } }); ``` +## geoLocationManager.enableLocationMock -## geoLocationManager.sendCommand - -sendCommand(command: LocationCommand): Promise<void>; +enableLocationMock(): Promise<void>; -给位置服务子系统的各个部件发送扩展命令。 +使能位置模拟功能。 **系统能力**:SystemCapability.Location.Location.Core -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | command | [LocationCommand](#locationcommand) | 是 | 指定目标场景,和将要发送的命令(字符串)。 | +**系统API**:此接口为系统接口,三方应用不支持调用。 **返回值**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | Promise<void> | void | NA | 接收错误码。 | + | Promise<void> | void|NA|用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | **错误码**: @@ -1485,34 +581,39 @@ sendCommand(command: LocationCommand): Promise<void>; | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | |3301000 | Location service is unavailable. | +|3301100 | The location switch is off.| **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - var requestInfo = {'scenario': 0x301, 'command': "command_1"}; - geoLocationManager.sendCommand(requestInfo).then((result) => { - console.log('promise, sendCommand success'); - }) + geoLocationManager.enableLocationMock() + .then((result) => { + console.log('promise, enableLocationMock: succeed'); + }) .catch((error) => { - console.log('promise, sendCommand: error=' + JSON.stringify(error)); + if (error) { + console.log('promise, enableLocationMock: error=' + JSON.stringify(error)); + } }); ``` -## geoLocationManager.getCountryCode +## geoLocationManager.disableLocationMock -getCountryCode(callback: AsyncCallback<CountryCode>): void; +disableLocationMock(callback: AsyncCallback<void>): void; -查询当前的国家码。 +去使能位置模拟功能。 **系统能力**:SystemCapability.Location.Location.Core +**系统API**:此接口为系统接口,三方应用不支持调用。 + **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[CountryCode](#countrycode)> | 是 | 用来接收国家码。 | + | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | **错误码**: @@ -1521,36 +622,35 @@ getCountryCode(callback: AsyncCallback<CountryCode>): void; | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | |3301000 | Location service is unavailable. | -|3301500 | Failed to query the area information.| +|3301100 | The location switch is off.| **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - geoLocationManager.getCountryCode((err, result) => { + geoLocationManager.disableLocationMock((err, result) => { if (err) { - console.log('getCountryCode: err=' + JSON.stringify(err)); - } - if (result) { - console.log('getCountryCode: result=' + JSON.stringify(result)); + console.log('disableLocationMock: err=' + JSON.stringify(err)); } }); ``` -## geoLocationManager.getCountryCode +## geoLocationManager.disableLocationMock -getCountryCode(): Promise<CountryCode>; +disableLocationMock(): Promise<void>; -查询当前的国家码。 +去使能位置模拟功能。 **系统能力**:SystemCapability.Location.Location.Core +**系统API**:此接口为系统接口,三方应用不支持调用。 + **返回值**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | Promise<[CountryCode](#countrycode)> | [CountryCode](#countrycode) | NA | 用来接收国家码。 | + | Promise<void> |void|NA| 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | **错误码**: @@ -1559,32 +659,41 @@ getCountryCode(): Promise<CountryCode>; | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | |3301000 | Location service is unavailable. | -|3301500 | Failed to query the area information.| +|3301100 | The location switch is off.| **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - geoLocationManager.getCountryCode() + geoLocationManager.disableLocationMock() .then((result) => { - console.log('promise, getCountryCode: result=' + JSON.stringify(result)); + console.log('promise, disableLocationMock succeed'); }) .catch((error) => { - console.log('promise, getCountryCode: error=' + JSON.stringify(error)); + if (error) { + console.log('promise, disableLocationMock: error=' + JSON.stringify(error)); + } }); ``` -## geoLocationManager.enableLocationMock +## geoLocationManager.setMockedLocations -enableLocationMock(): void; +setMockedLocations(config: LocationMockConfig, callback: AsyncCallback<void>): void; -使能位置模拟功能。 +设置模拟的位置信息,后面会以该接口中携带的时间间隔上报模拟位置。 **系统能力**:SystemCapability.Location.Location.Core **系统API**:此接口为系统接口,三方应用不支持调用。 +**参数**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | config | [LocationMockConfig](#locationmockconfig) | 是 | 指示位置模拟的配置参数,包含模拟位置上报的时间间隔和模拟位置数组。 | + | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | + **错误码**: 以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 @@ -1598,24 +707,43 @@ enableLocationMock(): void; ```ts import geoLocationManager from '@ohos.geoLocationManager'; - try { - geoLocationManager.enableLocationMock(); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } + var locations = [ + {"latitude": 30.12, "longitude": 120.11, "altitude": 123, "accuracy": 1, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 1000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 31.13, "longitude": 121.11, "altitude": 123, "accuracy": 2, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 2000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 32.14, "longitude": 122.11, "altitude": 123, "accuracy": 3, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 3000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 33.15, "longitude": 123.11, "altitude": 123, "accuracy": 4, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 4000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 34.16, "longitude": 124.11, "altitude": 123, "accuracy": 5, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 5000000000, "additionSize": 0, "isFromMock": true} + ]; + var config = {"timeInterval": 5, "locations": locations}; + geoLocationManager.setMockedLocations(config, (err, data) => { + if (err) { + console.log('setMockedLocations: err=' + JSON.stringify(err)); + } + }); ``` +## geoLocationManager.setMockedLocations -## geoLocationManager.disableLocationMock - -disableLocationMock(): void; +setMockedLocations(config: LocationMockConfig): Promise<void>; -去使能位置模拟功能。 +设置模拟的位置信息,后面会以该接口中携带的时间间隔上报模拟位置。 **系统能力**:SystemCapability.Location.Location.Core **系统API**:此接口为系统接口,三方应用不支持调用。 +**参数**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | config | [LocationMockConfig](#locationmockconfig) | 是 | 指示位置模拟的配置参数,包含模拟位置上报的时间间隔和模拟位置数组。 | + +**返回值**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<void> |void|NA| 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | + **错误码**: 以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 @@ -1629,19 +757,31 @@ disableLocationMock(): void; ```ts import geoLocationManager from '@ohos.geoLocationManager'; - try { - geoLocationManager.disableLocationMock(); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } + var locations = [ + {"latitude": 30.12, "longitude": 120.11, "altitude": 123, "accuracy": 1, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 1000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 31.13, "longitude": 121.11, "altitude": 123, "accuracy": 2, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 2000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 32.14, "longitude": 122.11, "altitude": 123, "accuracy": 3, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 3000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 33.15, "longitude": 123.11, "altitude": 123, "accuracy": 4, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 4000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 34.16, "longitude": 124.11, "altitude": 123, "accuracy": 5, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 5000000000, "additionSize": 0, "isFromMock": true} + ]; + var config = {"timeInterval": 5, "locations":locations}; + geoLocationManager.setMockedLocations(config) + .then((result) => { + console.log('promise, setMockedLocations succeed'); + }) + .catch((error) => { + if (error) { + console.log('promise, setMockedLocations: error=' + JSON.stringify(error)); + } + }); ``` -## geoLocationManager.setMockedLocations +## geoLocationManager.enableReverseGeocodingMock -setMockedLocations(config: LocationMockConfig): void; +enableReverseGeocodingMock(callback: AsyncCallback<void>): void; -设置模拟的位置信息,后面会以该接口中携带的时间间隔上报模拟位置。 +使能逆地理编码模拟功能。 **系统能力**:SystemCapability.Location.Location.Core @@ -1651,7 +791,7 @@ setMockedLocations(config: LocationMockConfig): void; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | config | [LocationMockConfig](#locationmockconfig) | 是 | 指示位置模拟的配置参数,包含模拟位置上报的时间间隔和模拟位置数组。 | + | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | **错误码**: @@ -1660,31 +800,22 @@ setMockedLocations(config: LocationMockConfig): void; | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | |3301000 | Location service is unavailable. | -|3301100 | The location switch is off.| **示例** ```ts import geoLocationManager from '@ohos.geoLocationManager'; - var locations = [ - {"latitude": 30.12, "longitude": 120.11, "altitude": 123, "accuracy": 1, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 1000000000, "additionSize": 0, "isFromMock": true}, - {"latitude": 31.13, "longitude": 121.11, "altitude": 123, "accuracy": 2, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 2000000000, "additionSize": 0, "isFromMock": true}, - {"latitude": 32.14, "longitude": 122.11, "altitude": 123, "accuracy": 3, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 3000000000, "additionSize": 0, "isFromMock": true}, - {"latitude": 33.15, "longitude": 123.11, "altitude": 123, "accuracy": 4, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 4000000000, "additionSize": 0, "isFromMock": true}, - {"latitude": 34.16, "longitude": 124.11, "altitude": 123, "accuracy": 5, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 5000000000, "additionSize": 0, "isFromMock": true} - ]; - var config = {"timeInterval": 5, "locations": locations}; - try { - geoLocationManager.setMockedLocations(config); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } + geoLocationManager.enableReverseGeocodingMock((err, data) => { + if (err) { + console.log('enableReverseGeocodingMock: err=' + JSON.stringify(err)); + } + }); ``` ## geoLocationManager.enableReverseGeocodingMock -enableReverseGeocodingMock(): void; +enableReverseGeocodingMock(): Promise<void>; 使能逆地理编码模拟功能。 @@ -1692,6 +823,12 @@ enableReverseGeocodingMock(): void; **系统API**:此接口为系统接口,三方应用不支持调用。 +**返回值**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<void> | void|NA|用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | + **错误码**: 以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 @@ -1704,17 +841,21 @@ enableReverseGeocodingMock(): void; ```ts import geoLocationManager from '@ohos.geoLocationManager'; - try { - geoLocationManager.enableReverseGeocodingMock(); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } + geoLocationManager.enableReverseGeocodingMock() + .then((result) => { + console.log('promise, enableReverseGeocodingMock succeed'); + }) + .catch((error) => { + if (error) { + console.log('promise, enableReverseGeocodingMock: error=' + JSON.stringify(error)); + } + }); ``` ## geoLocationManager.disableReverseGeocodingMock -disableReverseGeocodingMock(): void; +disableReverseGeocodingMock(callback: AsyncCallback<void>): void; 去使能逆地理编码模拟功能。 @@ -1722,6 +863,12 @@ disableReverseGeocodingMock(): void; **系统API**:此接口为系统接口,三方应用不支持调用。 +**参数**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | + **错误码**: 以下错误码的详细介绍请参见[位置服务子系统错误码](../errorcodes/errorcode-geoLocationManager.md)。 @@ -1734,29 +881,29 @@ disableReverseGeocodingMock(): void; ```ts import geoLocationManager from '@ohos.geoLocationManager'; - try { - geoLocationManager.disableReverseGeocodingMock(); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } + geoLocationManager.disableReverseGeocodingMock((err, result) => { + if (err) { + console.log('disableReverseGeocodingMock: err=' + JSON.stringify(err)); + } + }); ``` -## geoLocationManager.setReverseGeocodingMockInfo +## geoLocationManager.disableReverseGeocodingMock -setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): void; +disableReverseGeocodingMock(): Promise<void>; -设置逆地理编码模拟功能的配置信息,包含了位置和地名的对应关系,后续进行逆地理编码查询时如果位置信息位于配置信息中,就返回对应的地名。 +去使能逆地理编码模拟功能。 **系统能力**:SystemCapability.Location.Location.Core **系统API**:此接口为系统接口,三方应用不支持调用。 -**参数**: +**返回值**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | mockInfos | Array<[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)> | 是 | 指示逆地理编码模拟功能的配置参数数组。逆地理编码模拟功能的配置参数包含了一个位置和一个地名。 | + | Promise<void> |void|NA| 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | **错误码**: @@ -1770,42 +917,34 @@ setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): v ```ts import geoLocationManager from '@ohos.geoLocationManager'; - var mockInfos = [ - {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, - {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, - ]; - try { - geoLocationManager.setReverseGeocodingMockInfo(mockInfos); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } + geoLocationManager.disableReverseGeocodingMock() + .then((result) => { + console.log('promise, disableReverseGeocodingMock succeed'); + }) + .catch((error) => { + if (error) { + console.log('promise, disableReverseGeocodingMock: error=' + JSON.stringify(error)); + } + }); ``` -## geoLocationManager.isLocationPrivacyConfirmed - -isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean; +## geoLocationManager.setReverseGeocodingMockInfo -查询用户是否同意定位服务隐私申明,是否同意启用定位服务。只有系统应用才能调用。 +setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>, callback: AsyncCallback<void>): void; -**系统API**:此接口为系统接口,三方应用不支持调用。 +设置逆地理编码模拟功能的配置信息,包含了位置和地名的对应关系,后续进行逆地理编码查询时如果位置信息位于配置信息中,就返回对应的地名。 **系统能力**:SystemCapability.Location.Location.Core -**参数**: - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [LocationPrivacyType](#locationprivacytype)| 是 | 指定隐私申明场景,例如开机向导中的隐私申明、开启网络定位功能时弹出的隐私申明等。 | +**系统API**:此接口为系统接口,三方应用不支持调用。 -**返回值**: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | boolean | boolean | NA | 表示用户是否同意定位服务隐私申明。 | + | mockInfos | Array<[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)> | 是 | 指示逆地理编码模拟功能的配置参数数组。逆地理编码模拟功能的配置参数包含了一个位置和一个地名。 | + | callback | AsyncCallback<void> | 是 | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | **错误码**: @@ -1819,32 +958,42 @@ isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean; ```ts import geoLocationManager from '@ohos.geoLocationManager'; - try { - var isConfirmed = geoLocationManager.isLocationPrivacyConfirmed(1); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } + var mockInfos = [ + {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, + ]; + geoLocationManager.setReverseGeocodingMockInfo(mockInfos, (err, data) => { + if (err) { + console.log('promise, setReverseGeocodingMockInfo, err:' + JSON.stringify(err)); + } + }); ``` -## geoLocationManager.setLocationPrivacyConfirmStatus +## geoLocationManager.setReverseGeocodingMockInfo -setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): void; +setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): Promise<void>; -设置用户勾选定位服务隐私申明的状态,记录用户是否同意启用定位服务。只有系统应用才能调用。 +设置逆地理编码模拟功能的配置信息,包含了位置和地名的对应关系,后续进行逆地理编码查询时如果位置信息位于配置信息中,就返回对应的地名。 + +**系统能力**:SystemCapability.Location.Location.Core **系统API**:此接口为系统接口,三方应用不支持调用。 -**需要权限**:ohos.permission.MANAGE_SECURE_SETTINGS +**参数**: -**系统能力**:SystemCapability.Location.Location.Core + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | mockInfos | Array<[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)> | 是 | 指示逆地理编码模拟功能的配置信息数组。逆地理编码模拟功能的配置信息包含了一个位置和一个地名。 | -**参数**: +**返回值**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | type | [LocationPrivacyType](#locationprivacytype) | 是 | 指定隐私申明场景,例如开机向导中的隐私申明、开启网络定位功能时弹出的隐私申明等。 | - | isConfirmed | boolean | 是 | 表示用户是否同意定位服务隐私申明。 | + | Promise<void> | void | NA | 用来接收执行结果,如果执行成功就返回nullptr,否则就返回错误信息。 | **错误码**: @@ -1858,11 +1007,22 @@ setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean) ```ts import geoLocationManager from '@ohos.geoLocationManager'; - try { - geoLocationManager.setLocationPrivacyConfirmStatus(1, true); - } catch (err) { - console.error("errCode:" + err.code + ",errMessage:" + err.message); - } + var mockInfos = [ + {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, + ]; + geoLocationManager.setReverseGeocodingMockInfo(mockInfos) + .then((result) => { + console.log('promise, setReverseGeocodingMockInfo succeed'); + }) + .catch((error) => { + if (error) { + console.log('promise, setReverseGeocodingMockInfo: error=' + JSON.stringify(error)); + } + }); ``` @@ -2035,8 +1195,9 @@ GNSS围栏的配置参数。目前只支持圆形围栏。 | 名称 | 类型 | 可读|可写 | 说明 | | -------- | -------- | -------- | -------- | -| scenario | [LocationRequestScenario](#locationrequestscenario) | 是 | 是 | 表示定位场景。 | -| geofence | [Geofence](#geofence)| 是 | 是 | 表示围栏信息。 | +| priority | [LocationRequestPriority](#locationrequestpriority) | 是 | 是 | 表示位置信息优先级。 | +| scenario | [LocationRequestScenario](#locationrequestscenario) | 是 | 是 | 表示定位场景。 | +| geofence | [Geofence](#geofence) | 是 | 是 | 表示围栏信息。 | ## LocationPrivacyType diff --git a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md index ea6287ba8cc7ad3feffb90d36fd2d8b7f5836b59..5269a4e3f0f42778f311af9856eae32ec0687dc2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md @@ -4,7 +4,36 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> 从API Version 9开始,该接口不再维护,推荐使用新接口[geoLocationManager](js-apis-geoLocationManager.md)。 + + +## 申请权限 + +应用在使用系统能力前,需要检查是否已经获取用户授权访问设备位置信息。如未获得授权,可以向用户申请需要的位置权限,申请方式请参考下文。 + +系统提供的定位权限有: +- ohos.permission.LOCATION + +- ohos.permission.APPROXIMATELY_LOCATION + +- ohos.permission.LOCATION_IN_BACKGROUND + +访问设备的位置信息,必须申请权限,并且获得用户授权。 + +API9之前的版本,申请ohos.permission.LOCATION即可。 + +API9及之后的版本,需要申请ohos.permission.APPROXIMATELY_LOCATION或者同时申请ohos.permission.APPROXIMATELY_LOCATION和ohos.permission.LOCATION;无法单独申请ohos.permission.LOCATION。 + +| 使用的API版本 | 申请位置权限 | 申请结果 | 位置的精确度 | +| -------- | -------- | -------- | -------- | +| 小于9 | ohos.permission.LOCATION | 成功 | 获取到精准位置,精准度在米级别。 | +| 大于等于9 | ohos.permission.LOCATION | 失败 | 无法获取位置。 | +| 大于等于9 | ohos.permission.APPROXIMATELY_LOCATION | 成功 | 获取到模糊位置,精确度为5公里。 | +| 大于等于9 | ohos.permission.APPROXIMATELY_LOCATION和ohos.permission.LOCATION | 成功 | 获取到精准位置,精准度在米级别。 | + +如果应用在后台运行时也需要访问设备位置,除需要将应用声明为允许后台运行外,还必须申请ohos.permission.LOCATION_IN_BACKGROUND权限,这样应用在切入后台之后,系统可以继续上报位置信息。 + +开发者可以在应用配置文件中声明所需要的权限,具体可参考[授权申请指导](../../security/accesstoken-guidelines.md)。 + ## 导入模块 @@ -12,15 +41,12 @@ import geolocation from '@ohos.geolocation'; ``` -## geolocation.on('locationChange')(deprecated) +## geolocation.on('locationChange') on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>): void 开启位置变化订阅,并发起定位请求。定位结果按照[LocationRequest](#locationrequest)的属性进行上报, -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -47,15 +73,12 @@ on(type: 'locationChange', request: LocationRequest, callback: Callback<Locat ``` -## geolocation.off('locationChange')(deprecated) +## geolocation.off('locationChange') off(type: 'locationChange', callback?: Callback<Location>): void 关闭位置变化订阅,并删除对应的定位请求。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -81,15 +104,12 @@ off(type: 'locationChange', callback?: Callback<Location>): void ``` -## geolocation.on('locationServiceState')(deprecated) +## geolocation.on('locationServiceState') on(type: 'locationServiceState', callback: Callback<boolean>): void 订阅位置服务状态变化。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.on('locationEnabledChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationenabledchange)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -113,15 +133,12 @@ on(type: 'locationServiceState', callback: Callback<boolean>): void ``` -## geolocation.off('locationServiceState')(deprecated) +## geolocation.off('locationServiceState') off(type: 'locationServiceState', callback?: Callback<boolean>): void; 取消订阅位置服务状态变化。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.off('locationEnabledChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationenabledchange)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -146,16 +163,12 @@ off(type: 'locationServiceState', callback?: Callback<boolean>): void; ``` -## geolocation.on('cachedGnssLocationsReporting')(deprecated) +## geolocation.on('cachedGnssLocationsReporting')8+ on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback<Array<Location>>): void; 订阅缓存GNSS定位结果上报事件。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.on('cachedGnssLocationsChange')](js-apis-geoLocationManager.md#geolocationmanageroncachedgnsslocationschange)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss @@ -181,16 +194,12 @@ on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, ca ``` -## geolocation.off('cachedGnssLocationsReporting')(deprecated) +## geolocation.off('cachedGnssLocationsReporting')8+ off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>): void; 取消订阅缓存GNSS定位结果上报事件。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.off('cachedGnssLocationsChange')](js-apis-geoLocationManager.md#geolocationmanageroffcachedgnsslocationschange)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss @@ -216,16 +225,12 @@ off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Locati ``` -## geolocation.on('gnssStatusChange')(deprecated) +## geolocation.on('gnssStatusChange')8+ on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>): void; 订阅GNSS卫星状态信息上报事件。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.on('satelliteStatusChange')](js-apis-geoLocationManager.md#geolocationmanageronsatellitestatuschange)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss @@ -249,16 +254,12 @@ on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>): voi ``` -## geolocation.off('gnssStatusChange')(deprecated) +## geolocation.off('gnssStatusChange')8+ off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>): void; 取消订阅GNSS卫星状态信息上报事件。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.off('satelliteStatusChange')](js-apis-geoLocationManager.md#geolocationmanageroffsatellitestatuschange)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss @@ -282,16 +283,12 @@ off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>): v ``` -## geolocation.on('nmeaMessageChange')(deprecated) +## geolocation.on('nmeaMessageChange')8+ on(type: 'nmeaMessageChange', callback: Callback<string>): void; 订阅GNSS NMEA信息上报事件。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.on('nmeaMessage')](js-apis-geoLocationManager.md#geolocationmanageronnmeamessage)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss @@ -315,16 +312,12 @@ on(type: 'nmeaMessageChange', callback: Callback<string>): void; ``` -## geolocation.off('nmeaMessageChange')(deprecated) +## geolocation.off('nmeaMessageChange')8+ off(type: 'nmeaMessageChange', callback?: Callback<string>): void; 取消订阅GNSS NMEA信息上报事件。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.off('nmeaMessage')](js-apis-geoLocationManager.md#geolocationmanageroffnmeamessage)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss @@ -349,16 +342,12 @@ off(type: 'nmeaMessageChange', callback?: Callback<string>): void; ``` -## geolocation.on('fenceStatusChange')(deprecated) +## geolocation.on('fenceStatusChange')8+ on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; 添加一个围栏,并订阅地理围栏事件。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.on('gnssFenceStatusChange')](js-apis-geoLocationManager.md#geolocationmanagerongnssfencestatuschange)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geofence @@ -398,16 +387,12 @@ on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; ``` -## geolocation.off('fenceStatusChange')(deprecated) +## geolocation.off('fenceStatusChange')8+ off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; 删除一个围栏,并取消订阅该围栏事件。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.off('gnssFenceStatusChange')](js-apis-geoLocationManager.md#geolocationmanageroffgnssfencestatuschange)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geofence @@ -447,14 +432,12 @@ off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; ``` -## geolocation.getCurrentLocation(deprecated) +## geolocation.getCurrentLocation getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>): void -获取当前位置,使用callback回调异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation)替代。 +获取当前位置,使用callback回调异步返回结果。 **需要权限**:ohos.permission.LOCATION @@ -485,14 +468,12 @@ getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<L ``` -## geolocation.getCurrentLocation(deprecated) +## geolocation.getCurrentLocation getCurrentLocation(request?: CurrentLocationRequest): Promise<Location> -获取当前位置,使用Promise方式异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation-2)替代。 +获取当前位置,使用Promise方式异步返回结果。 **需要权限**:ohos.permission.LOCATION @@ -506,9 +487,9 @@ getCurrentLocation(request?: CurrentLocationRequest): Promise<Location> **返回值**: - | 参数名 | 说明 | - | -------- | -------- | - | Promise<[Location](#location)> | 返回位置信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<[Location](#location)> |[Location](#location)|NA| 返回位置信息。 | **示例** @@ -522,15 +503,12 @@ getCurrentLocation(request?: CurrentLocationRequest): Promise<Location> ``` -## geolocation.getLastLocation(deprecated) +## geolocation.getLastLocation getLastLocation(callback: AsyncCallback<Location>): void 获取上一次位置,使用callback回调异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.getLastLocation](js-apis-geoLocationManager.md#geolocationmanagergetlastlocation)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -557,24 +535,21 @@ getLastLocation(callback: AsyncCallback<Location>): void ``` -## geolocation.getLastLocation(deprecated) +## geolocation.getLastLocation getLastLocation(): Promise<Location> 获取上一次位置,使用Promise方式异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.getLastLocation](js-apis-geoLocationManager.md#geolocationmanagergetlastlocation)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core **返回值**: - | 参数名 | 说明 | - | -------- | -------- | - | Promise<[Location](#location)> | 返回上次位置信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<[Location](#location)> | [Location](#location)|NA|返回上次位置信息。 | **示例** @@ -587,14 +562,12 @@ getLastLocation(): Promise<Location> ``` -## geolocation.isLocationEnabled(deprecated) +## geolocation.isLocationEnabled isLocationEnabled(callback: AsyncCallback<boolean>): void -判断位置服务是否已经打开,使用callback回调异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.isLocationEnabled](js-apis-geoLocationManager.md#geolocationmanagerislocationenabled)替代。 +判断位置服务是否已经打开,使用callback回调异步返回结果。 **需要权限**:ohos.permission.LOCATION @@ -621,24 +594,21 @@ isLocationEnabled(callback: AsyncCallback<boolean>): void ``` -## geolocation.isLocationEnabled(deprecated) +## geolocation.isLocationEnabled isLocationEnabled(): Promise<boolean> 判断位置服务是否已经开启,使用Promise方式异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.isLocationEnabled](js-apis-geoLocationManager.md#geolocationmanagerislocationenabled)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core **返回值**: - | 参数名 | 说明 | - | -------- | -------- | - | Promise<boolean> | 返回位置服务是否可用的状态。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<boolean> | boolean|NA|返回位置服务是否可用的状态。 | **示例** @@ -650,14 +620,12 @@ isLocationEnabled(): Promise<boolean> ``` -## geolocation.requestEnableLocation(deprecated) +## geolocation.requestEnableLocation requestEnableLocation(callback: AsyncCallback<boolean>): void -请求打开位置服务,使用callback回调异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.requestEnableLocation](js-apis-geoLocationManager.md#geolocationmanagerrequestenablelocation)替代。 +请求打开位置服务,使用callback回调异步返回结果。 **需要权限**:ohos.permission.LOCATION @@ -684,24 +652,21 @@ requestEnableLocation(callback: AsyncCallback<boolean>): void ``` -## geolocation.requestEnableLocation(deprecated) +## geolocation.requestEnableLocation requestEnableLocation(): Promise<boolean> 请求打开位置服务,使用Promise方式异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.requestEnableLocation](js-apis-geoLocationManager.md#geolocationmanagerrequestenablelocation-1)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core **返回值**: - | 参数名 | 说明 | - | -------- | -------- | - | Promise<boolean> | 返回位置服务是否可用。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<boolean> | boolean|NA|返回位置服务是否可用。 | **示例** @@ -713,15 +678,132 @@ requestEnableLocation(): Promise<boolean> ``` -## geolocation.isGeoServiceAvailable(deprecated) +## geolocation.enableLocation + +enableLocation(callback: AsyncCallback<boolean>): void; + +打开位置服务,使用callback回调异步返回结果。 + +**系统API**:此接口为系统接口,三方应用不支持调用。 + +**需要权限**:ohos.permission.MANAGE_SECURE_SETTINGS + +**系统能力**:SystemCapability.Location.Location.Core + +**参数**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | 是 | 用来接收位置服务状态的回调。 | + +**示例** + + ```ts + import geolocation from '@ohos.geolocation'; + geolocation.enableLocation((err, data) => { + if (err) { + console.log('enableLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('enableLocation: data=' + JSON.stringify(data)); + } + }); + ``` + + +## geolocation.enableLocation + +enableLocation(): Promise<boolean> + +打开位置服务,使用Promise方式异步返回结果。 + +**系统API**:此接口为系统接口,三方应用不支持调用。 + +**需要权限**:ohos.permission.MANAGE_SECURE_SETTINGS + +**系统能力**:SystemCapability.Location.Location.Core + +**返回值**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<boolean> | boolean|NA|返回位置服务是否可用。 | + +**示例** + + ```ts + import geolocation from '@ohos.geolocation'; + geolocation.enableLocation().then((result) => { + console.log('promise, enableLocation: ' + JSON.stringify(result)); + }); + ``` + +## geolocation.disableLocation + +disableLocation(callback: AsyncCallback<boolean>): void; + +关闭位置服务,使用callback回调异步返回结果。 + +**系统API**:此接口为系统接口,三方应用不支持调用。 + +**需要权限**:ohos.permission.MANAGE_SECURE_SETTINGS + +**系统能力**:SystemCapability.Location.Location.Core + +**参数**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | 是 | 用来接收位置服务状态的回调。 | + +**示例** + + ```ts + import geolocation from '@ohos.geolocation'; + geolocation.disableLocation((err, data) => { + if (err) { + console.log('disableLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('disableLocation: data=' + JSON.stringify(data)); + } + }); + ``` + + +## geolocation.disableLocation + +disableLocation(): Promise<boolean> + +关闭位置服务,使用Promise方式异步返回结果。 + +**系统API**:此接口为系统接口,三方应用不支持调用。 + +**需要权限**:ohos.permission.MANAGE_SECURE_SETTINGS + +**系统能力**:SystemCapability.Location.Location.Core + +**返回值**: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<boolean> | boolean|NA|返回位置服务是否可用。 | + +**示例** + + ```ts + import geolocation from '@ohos.geolocation'; + geolocation.disableLocation().then((result) => { + console.log('promise, disableLocation: ' + JSON.stringify(result)); + }); + ``` + +## geolocation.isGeoServiceAvailable isGeoServiceAvailable(callback: AsyncCallback<boolean>): void 判断(逆)地理编码服务状态,使用callback回调异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.isGeocoderAvailable](js-apis-geoLocationManager.md#geolocationmanagerisgeocoderavailable)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geocoder @@ -747,24 +829,21 @@ isGeoServiceAvailable(callback: AsyncCallback<boolean>): void ``` -## geolocation.isGeoServiceAvailable(deprecated) +## geolocation.isGeoServiceAvailable isGeoServiceAvailable(): Promise<boolean> 判断(逆)地理编码服务状态,使用Promise方式异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.isGeocoderAvailable](js-apis-geoLocationManager.md#geolocationmanagerisgeocoderavailable)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geocoder **返回值**: - | 参数名 | 说明 | - | -------- | -------- | - | Promise<boolean> | 返回地理编码服务是否可用的状态。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<boolean> |boolean|NA| 返回地理编码服务是否可用的状态。 | **示例** @@ -776,15 +855,12 @@ isGeoServiceAvailable(): Promise<boolean> ``` -## geolocation.getAddressesFromLocation(deprecated) +## geolocation.getAddressesFromLocation getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void 调用逆地理编码服务,将坐标转换为地理描述,使用callback回调异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.getAddressesFromLocation](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocation)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geocoder @@ -812,15 +888,12 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback ``` -## geolocation.getAddressesFromLocation(deprecated) +## geolocation.getAddressesFromLocation getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<GeoAddress>>; 调用逆地理编码服务,将坐标转换为地理描述,使用Promise方式异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.getAddressesFromLocation](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocation-1)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geocoder @@ -833,9 +906,9 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<Ge **返回值**: - | 参数名 | 说明 | - | -------- | -------- | - | Promise<Array<[GeoAddress](#geoaddress)>> | 返回地理描述信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<Array<[GeoAddress](#geoaddress)>> | Array<[GeoAddress](#geoaddress)>|NA|返回地理描述信息。 | **示例** @@ -848,15 +921,12 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<Ge ``` -## geolocation.getAddressesFromLocationName(deprecated) +## geolocation.getAddressesFromLocationName getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void 调用地理编码服务,将地理描述转换为具体坐标,使用callback回调异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.getAddressesFromLocationName](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocationname)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geocoder @@ -884,15 +954,12 @@ getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback< ``` -## geolocation.getAddressesFromLocationName(deprecated) +## geolocation.getAddressesFromLocationName getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAddress>> 调用地理编码服务,将地理描述转换为具体坐标,使用Promise方式异步返回结果。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.getAddressesFromLocationName](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocationname-1)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geocoder @@ -905,9 +972,9 @@ getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAd **返回值**: - | 参数名 | 说明 | - | -------- | -------- | - | Promise<Array<[GeoAddress](#geoaddress)>> | 设置接收地理编码请求的回调参数。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<Array<[GeoAddress](#geoaddress)>> | Array<[GeoAddress](#geoaddress)>|NA|设置接收地理编码请求的回调参数。 | **示例** @@ -920,16 +987,12 @@ getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAd ``` -## geolocation.getCachedGnssLocationsSize(deprecated) +## geolocation.getCachedGnssLocationsSize8+ getCachedGnssLocationsSize(callback: AsyncCallback<number>): void; 获取GNSS芯片缓存位置的个数。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.getCachedGnssLocationsSize](js-apis-geoLocationManager.md#geolocationmanagergetcachedgnsslocationssize)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss @@ -955,25 +1018,21 @@ getCachedGnssLocationsSize(callback: AsyncCallback<number>): void; ``` -## geolocation.getCachedGnssLocationsSize(deprecated) +## geolocation.getCachedGnssLocationsSize8+ getCachedGnssLocationsSize(): Promise<number>; 获取GNSS芯片缓存位置的个数。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.getCachedGnssLocationsSize](js-apis-geoLocationManager.md#geolocationmanagergetcachedgnsslocationssize-1)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss **返回值**: - | 参数名 | 说明 | - | -------- | -------- | - | Promise<number> | 返回GNSS缓存位置的个数。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<number> | number|NA|返回GNSS缓存位置的个数。 | **示例** @@ -985,16 +1044,12 @@ getCachedGnssLocationsSize(): Promise<number>; ``` -## geolocation.flushCachedGnssLocations(deprecated) +## geolocation.flushCachedGnssLocations8+ flushCachedGnssLocations(callback: AsyncCallback<boolean>): void; 读取并清空GNSS芯片所有缓存位置。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.flushCachedGnssLocations](js-apis-geoLocationManager.md#geolocationmanagerflushcachedgnsslocations)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss @@ -1020,25 +1075,21 @@ flushCachedGnssLocations(callback: AsyncCallback<boolean>): void; ``` -## geolocation.flushCachedGnssLocations(deprecated) +## geolocation.flushCachedGnssLocations8+ flushCachedGnssLocations(): Promise<boolean>; 读取并清空GNSS芯片所有缓存位置。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.flushCachedGnssLocations](js-apis-geoLocationManager.md#geolocationmanagerflushcachedgnsslocations-1)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss **返回值**: - | 参数名 | 说明 | - | -------- | -------- | - | Promise<boolean> | 清空所有GNSS缓存位置是否成功。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<boolean> |boolean|NA| 清空所有GNSS缓存位置是否成功。 | **示例** @@ -1050,16 +1101,12 @@ flushCachedGnssLocations(): Promise<boolean>; ``` -## geolocation.sendCommand(deprecated) +## geolocation.sendCommand8+ sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>): void; 给位置服务子系统的各个部件发送扩展命令。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.sendCommand](js-apis-geoLocationManager.md#geolocationmanagersendcommand)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -1087,16 +1134,12 @@ sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>): v ``` -## geolocation.sendCommand(deprecated) +## geolocation.sendCommand8+ sendCommand(command: LocationCommand): Promise<boolean>; 给位置服务子系统的各个部件发送扩展命令。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.sendCommand](js-apis-geoLocationManager.md#geolocationmanagersendcommand)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -1109,9 +1152,9 @@ sendCommand(command: LocationCommand): Promise<boolean>; **返回值**: - | 参数名 | 说明 | - | -------- | -------- | - | Promise<boolean> | 表示命令发送成功或失败。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | Promise<boolean> |boolean|NA| 表示命令发送成功或失败。 | **示例** @@ -1124,12 +1167,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; ``` -## LocationRequestPriority(deprecated) -位置请求中位置信息优先级设置。 +## LocationRequestPriority -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.LocationRequestPriority](js-apis-geoLocationManager.md#locationrequestpriority)替代。 +位置请求中位置信息优先级设置。 **需要权限**:ohos.permission.LOCATION @@ -1143,13 +1184,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; | FIRST_FIX | 0x203 | 表示快速获取位置优先,如果应用希望快速拿到1个位置,可以将优先级设置为该字段。 | -## LocationRequestScenario(deprecated) +## LocationRequestScenario 位置请求中定位场景设置。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.LocationRequestScenario](js-apis-geoLocationManager.md#locationrequestscenario)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -1164,13 +1202,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; | NO_POWER | 0x305 | 表示无功耗功场景,这种场景下不会主动触发定位,会在其他应用定位时,才给当前应用返回位置。 | -## GeoLocationErrorCode(deprecated) +## GeoLocationErrorCode 位置服务中的错误码信息。 -> **说明:**
-> 从API version 9开始废弃。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -1186,13 +1221,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; | LOCATION_REQUEST_TIMEOUT_ERROR7+ | 107 | 表示单次定位,没有在指定时间内返回位置。 | -## ReverseGeoCodeRequest(deprecated) +## ReverseGeoCodeRequest 逆地理编码请求接口。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.ReverseGeoCodeRequest](js-apis-geoLocationManager.md#reversegeocoderequest)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geocoder @@ -1205,13 +1237,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; | maxItems | number | 是 | 是 | 指定返回位置信息的最大个数。 | -## GeoCodeRequest(deprecated) +## GeoCodeRequest 地理编码请求接口。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.GeoCodeRequest](js-apis-geoLocationManager.md#geocoderequest)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geocoder @@ -1227,13 +1256,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; | maxLongitude | number | 是 | 是 | 表示最大经度信息。 | -## GeoAddress(deprecated) +## GeoAddress 地理编码类型。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.GeoAddress](js-apis-geoLocationManager.md#geoaddress)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geocoder @@ -1260,13 +1286,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; | descriptionsSize7+ | number | 是 | 否 | 表示附加的描述信息数量。 | -## LocationRequest(deprecated) +## LocationRequest 位置信息请求类型。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.LocationRequest](js-apis-geoLocationManager.md#locationrequest)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -1280,13 +1303,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; | maxAccuracy | number | 是 | 是 | 表示精度信息。仅在精确位置功能场景下有效,模糊位置功能生效场景下该字段无意义。 | -## CurrentLocationRequest(deprecated) +## CurrentLocationRequest 当前位置信息请求类型。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.CurrentLocationRequest](js-apis-geoLocationManager.md#currentlocationrequest)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -1299,14 +1319,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; | timeoutMs | number | 是 | 是 | 表示超时时间,单位是毫秒,最小为1000毫秒。 | -## SatelliteStatusInfo(deprecated) +## SatelliteStatusInfo8+ 卫星状态信息。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.SatelliteStatusInfo](js-apis-geoLocationManager.md#satellitestatusinfo)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss @@ -1321,14 +1337,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; | carrierFrequencies | Array<number> | 是 | 否 | 表示载波频率。 | -## CachedGnssLocationsRequest(deprecated) +## CachedGnssLocationsRequest8+ 请求订阅GNSS缓存位置上报功能接口的配置参数。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.CachedGnssLocationsRequest](js-apis-geoLocationManager.md#cachedgnsslocationsrequest)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Gnss @@ -1339,14 +1351,10 @@ sendCommand(command: LocationCommand): Promise<boolean>; | wakeUpCacheQueueFull | boolean | 是 | 是 | true表示GNSS芯片底层缓存队列满之后会主动唤醒AP芯片,并把缓存位置上报给应用。
false表示GNSS芯片底层缓存队列满之后不会主动唤醒AP芯片,会把缓存位置直接丢弃。 | -## Geofence(deprecated) +## Geofence8+ GNSS围栏的配置参数。目前只支持圆形围栏。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.Geofence](js-apis-geoLocationManager.md#geofence)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geofence @@ -1359,14 +1367,10 @@ GNSS围栏的配置参数。目前只支持圆形围栏。 | expiration | number | 是 | 是 | 围栏存活的时间,单位是毫秒。 | -## GeofenceRequest(deprecated) +## GeofenceRequest8+ 请求添加GNSS围栏消息中携带的参数,包括定位优先级、定位场景和围栏信息。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.GeofenceRequest](js-apis-geoLocationManager.md#geofencerequest)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Geofence @@ -1378,14 +1382,10 @@ GNSS围栏的配置参数。目前只支持圆形围栏。 | geofence | [Geofence](#geofence)| 是 | 是 | 表示围栏信息。 | -## LocationPrivacyType(deprecated) +## LocationPrivacyType8+ 定位服务隐私协议类型。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.LocationPrivacyType](js-apis-geoLocationManager.md#locationprivacytype)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -1397,14 +1397,10 @@ GNSS围栏的配置参数。目前只支持圆形围栏。 | CORE_LOCATION | 2 | 开启网络定位时弹出的隐私协议。 | -## LocationCommand(deprecated) +## LocationCommand8+ 扩展命令结构体。 -> **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[geoLocationManager.LocationCommand](js-apis-geoLocationManager.md#locationcommand)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core @@ -1415,13 +1411,10 @@ GNSS围栏的配置参数。目前只支持圆形围栏。 | command | string | 是 | 是 | 扩展命令字符串。 | -## Location(deprecated) +## Location 位置信息类型。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.Location](js-apis-geoLocationManager.md#location)替代。 - **需要权限**:ohos.permission.LOCATION **系统能力**:SystemCapability.Location.Location.Core diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md index dd8a05fc41bd7bbea1c8240542efd158cd62ef90..733f25a1b8fbb5ea4dd32848eb45a4a5002902a4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md @@ -52,11 +52,6 @@ HashMap的构造函数。 ```ts let hashMap = new HashMap(); -try { - let hashMap2 = HashMap(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -87,11 +82,6 @@ isEmpty(): boolean ```ts const hashMap = new HashMap(); let result = hashMap.isEmpty(); -try { - hashMap.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -130,11 +120,6 @@ let hashMap = new HashMap(); let result = hashMap.hasKey("squirrel"); hashMap.set("squirrel", 123); let result1 = hashMap.hasKey("squirrel"); -try { - hashMap.hasKey.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -173,11 +158,6 @@ let hashMap = new HashMap(); let result = hashMap.hasValue(123); hashMap.set("squirrel", 123); let result1 = hashMap.hasValue(123); -try { - hashMap.hasValue.bind({}, 123)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -216,11 +196,6 @@ let hashMap = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let result = hashMap.get("sparrow"); -try { - hashMap.get.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -254,11 +229,6 @@ hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let newHashMap = new HashMap(); hashMap.setAll(newHashMap); -try { - hashMap.setAll.bind({}, newHashMap)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -296,11 +266,6 @@ set(key: K, value: V): Object ```ts let hashMap = new HashMap(); let result = hashMap.set("squirrel", 123); -try { - hashMap.set.bind({}, "squirrel", 123)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -339,11 +304,6 @@ let hashMap = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let result = hashMap.remove("sparrow"); -try { - hashMap.remove.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -370,11 +330,6 @@ let hashMap = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); hashMap.clear(); -try { - hashMap.clear.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -412,11 +367,6 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - hashMap.keys.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -454,11 +404,6 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - hashMap.values.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -497,11 +442,6 @@ replace(key: K, newValue: V): boolean let hashMap = new HashMap(); hashMap.set("sparrow", 123); let result = hashMap.replace("sparrow", 357); -try { - hashMap.replace.bind({}, "sparrow", 357)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -544,13 +484,6 @@ hashMap.set("gull", 357); hashMap.forEach((value, key) => { console.log("value:" + value, key); }); -try { - hashMap.forEach.bind({}, (value, key) => { - console.log("value:" + value, key); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -589,11 +522,6 @@ while(temp != undefined) { console.log("value:" + temp[1]); temp = iter.next().value; } -try { - hashMap.entries.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -639,9 +567,4 @@ while(temp != undefined) { console.log("value:" + temp[1]); temp = iter.next().value; } -try { - hashMap[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashset.md b/zh-cn/application-dev/reference/apis/js-apis-hashset.md index 239f9874427b4a093117c4d994f23c39637f5c59..f15c8db78b8e00a478432d8666b0d467b44ab416 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashset.md @@ -60,11 +60,6 @@ HashSet的构造函数。 ```ts let hashSet = new HashSet(); -try { - let hashSet2 = HashSet(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -95,11 +90,6 @@ isEmpty(): boolean ```ts const hashSet = new HashSet(); let result = hashSet.isEmpty(); -try { - hashSet.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -138,11 +128,6 @@ let hashSet = new HashSet(); let result = hashSet.has("squirrel"); hashSet.add("squirrel"); let result1 = hashSet.has("squirrel"); -try { - hashSet.has.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -179,11 +164,6 @@ add(value: T): boolean ```ts let hashSet = new HashSet(); let result = hashSet.add("squirrel"); -try { - hashSet.add.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -222,11 +202,6 @@ let hashSet = new HashSet(); hashSet.add("squirrel"); hashSet.add("sparrow"); let result = hashSet.remove("sparrow"); -try { - hashSet.remove.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -253,11 +228,6 @@ let hashSet = new HashSet(); hashSet.add("squirrel"); hashSet.add("sparrow"); hashSet.clear(); -try { - hashSet.remove.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -295,11 +265,6 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - hashSet.values.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -342,13 +307,6 @@ hashSet.add("squirrel"); hashSet.forEach((value, key) => { console.log("value:" + value, key); }); -try { - hashSet.forEach.bind({}, (value, key) => { - console.log("value:" + value, key); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -386,11 +344,6 @@ while(temp != undefined) { console.log("value:" + temp[1]); temp = iter.next().value; } -try { - hashSet.entries.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -435,9 +388,4 @@ while(temp != undefined) { console.log("value: " + temp); temp = iter.next().value; } -try { - hashSet[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md b/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md index 43f00e1041a110133007d0d60d1506032eacb377..1813e0fa5f8ff31eadee966faecae29568d68069 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md @@ -58,7 +58,7 @@ write(eventName: string, eventType: EventType, keyValues: object, callback: Asyn | eventName | string | 是 | 事件名称。 | | eventType | [EventType](#eventtype) | 是 | 事件类型。 | | keyValues | object | 是 | 事件参数。 | -| callback | AsyncCallback<void> | 否 | 事件回调函数。 | +| callback | AsyncCallback<void> | 是 | 事件回调函数。 | **示例:** @@ -151,7 +151,7 @@ hiAppEvent.configure({ **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ------- | ---- | ------------------------------------------------------------ | | disable | boolean | 否 | 应用打点功能开关。配置值为true表示关闭打点功能,false表示不关闭打点功能。 | | maxStorage | string | 否 | 打点数据本地存储文件所在目录的配额大小,默认限额为“10M”。所在目录大小超出限额后会对目录进行清理操作,会按从旧到新的顺序逐个删除打点数据文件,直到目录大小不超出限额时停止。 | @@ -163,12 +163,12 @@ hiAppEvent.configure({ **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 默认值 | 说明 | -| --------- | ------ | -------------- | -| FAULT | 1 | 故障类型事件。 | -| STATISTIC | 2 | 统计类型事件。 | -| SECURITY | 3 | 安全类型事件。 | -| BEHAVIOR | 4 | 行为类型事件。 | +| 名称 | 值 | 说明 | +| --------- | ---- | -------------- | +| FAULT | 1 | 故障类型事件。 | +| STATISTIC | 2 | 统计类型事件。 | +| SECURITY | 3 | 安全类型事件。 | +| BEHAVIOR | 4 | 行为类型事件。 | ## Event @@ -177,11 +177,11 @@ hiAppEvent.configure({ **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------------------------- | -------- | ---- | ---- | -------------------- | -| USER_LOGIN | string | 是 | 否 | 用户登录事件。 | -| USER_LOGOUT | string | 是 | 否 | 用户登出事件。 | -| DISTRIBUTED_SERVICE_START | string | 是 | 否 | 分布式服务启动事件。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------------- | ------ | ---- | ---- | -------------------- | +| USER_LOGIN | string | 是 | 否 | 用户登录事件。 | +| USER_LOGOUT | string | 是 | 否 | 用户登出事件。 | +| DISTRIBUTED_SERVICE_START | string | 是 | 否 | 分布式服务启动事件。 | ## Param @@ -190,8 +190,8 @@ hiAppEvent.configure({ **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------------------------------- | -------- | ---- | ---- | ------------------ | -| USER_ID | string | 是 | 否 | 用户自定义ID。 | -| DISTRIBUTED_SERVICE_NAME | string | 是 | 否 | 分布式服务名称。 | -| DISTRIBUTED_SERVICE_INSTANCE_ID | string | 是 | 否 | 分布式服务实例ID。 | \ No newline at end of file +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------------------- | ------ | ---- | ---- | ------------------ | +| USER_ID | string | 是 | 否 | 用户自定义ID。 | +| DISTRIBUTED_SERVICE_NAME | string | 是 | 否 | 分布式服务名称。 | +| DISTRIBUTED_SERVICE_INSTANCE_ID | string | 是 | 否 | 分布式服务实例ID。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-hidebug.md b/zh-cn/application-dev/reference/apis/js-apis-hidebug.md index 2d81b2b7faef6ee269588dcadf9889bf59ce6da2..2cea5e98558c4bf7f15d2880301b2f54d95a319d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hidebug.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hidebug.md @@ -234,7 +234,7 @@ hidebug.dumpHeapData("heap-20220216"); ## hidebug.getServiceDump9+ -getServiceDump(serviceid : number, fd : number, args : Array) : void +getServiceDump(serviceid : number, fd : number, args : Array\) : void 获取系统服务信息。 @@ -248,7 +248,7 @@ getServiceDump(serviceid : number, fd : number, args : Array) : void | -------- | ------ | ---- | ------------------------------------------------------------ | | serviceid | number | 是 | 基于该用户输入的service id获取系统服务信息。| | fd | number | 是 | 文件描述符,该接口会往该fd中写入数据。| -| args | Array | 是 | 系统服务的Dump接口所对应的参数列表。| +| args | Array\ | 是 | 系统服务的Dump接口所对应的参数列表。| **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-hilog.md b/zh-cn/application-dev/reference/apis/js-apis-hilog.md index 20c261f17b9702e2b14aeefbf8e5009fda475c00..0339c6b52fe7b0ce20c3f2f6394451207c0098b1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hilog.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hilog.md @@ -45,7 +45,7 @@ hilog.isLoggable(0x0001, "testTag", hilog.LogLevel.INFO); **系统能力:** SystemCapability.HiviewDFX.HiLog -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | ----- | ------ | ------------------------------------------------------------ | | DEBUG | 3 | 详细的流程记录,通过该级别的日志可以更详细地分析业务流程和定位分析问题。 | | INFO | 4 | 用于记录业务关键流程节点,可以还原业务的主要运行过程;
用于记录可预料的非正常情况信息,如无网络信号、登录失败等。
这些日志都应该由该业务内处于支配地位的模块来记录,避免在多个被调用的模块或低级函数中重复记录。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md b/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md index 94dd6d732addadbf1f5757c5bc5e6c56bd304de8..c847cb0731aeea326ff5e8c2a27a96c0174d5be1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md @@ -19,7 +19,7 @@ import hiSysEvent from '@ohos.hiSysEvent'; **系统能力:** SystemCapability.HiviewDFX.HiSysEvent -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | -------- | -------- | | FAULT | 1 | 错误事件类型。 | | STATISTIC | 2 | 统计事件类型。 | @@ -32,7 +32,7 @@ import hiSysEvent from '@ohos.hiSysEvent'; **系统能力:** SystemCapability.HiviewDFX.HiSysEvent -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | domain | string | 是 | 事件领域。 | | name | string | 是 | 事件名称。 | @@ -168,7 +168,7 @@ try { **系统能力:** SystemCapability.HiviewDFX.HiSysEvent -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | -------- | -------- | | WHOLE_WORD | 1 | 全词匹配类型。 | | PREFIX | 2 | 前缀匹配类型。 | @@ -180,7 +180,7 @@ try { **系统能力:** SystemCapability.HiviewDFX.HiSysEvent -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | domain | string | 是 | 事件领域。 | | name | string | 是 | 事件名称。 | @@ -193,7 +193,7 @@ try { **系统能力:** SystemCapability.HiviewDFX.HiSysEvent -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | rules | [WatchRule](#watchrule)[] | 是 | 订阅对象数组,每个订阅者对象包含多个订阅规则。 | | onEvent | function | 是 | 订阅事件的回调方法(info: [SysEventInfo](#syseventinfo)) => void。 | @@ -307,7 +307,7 @@ try { **系统能力:** SystemCapability.HiviewDFX.HiSysEvent -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | beginTime | number | 是 | 查询的系统事件起始时间(13位时间戳)。 | | endTime | number | 是 | 查询的系统事件结束时间(13位时间戳)。 | @@ -319,7 +319,7 @@ try { **系统能力:** SystemCapability.HiviewDFX.HiSysEvent -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | domain | string | 是 | 查询包含的事件领域。 | | names | string[] | 是 | 查询所包含的多个事件名称,每个查询规则对象包含多个系统事件名称。 | @@ -330,7 +330,7 @@ try { **系统能力:** SystemCapability.HiviewDFX.HiSysEvent -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | onQuery | function | 是 | 返回查询到的系统事件的回调方法(infos: [SysEventInfo](#syseventinfo)[]) => void。 | | onComplete | function | 是 | 查询结果统计的回调方法(reason: number, total: number) => void。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md b/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md index 9f3481c7ecc5dea5bdc225f260384c40bca16416..65e279f0eaaf4e8aa5f208fa810dd3c101518dc6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md @@ -18,7 +18,7 @@ import hiTraceChain from '@ohos.hiTraceChain'; **系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.HiTrace。 -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | -------- | -------- | | DEFAULT | 0 | 缺省标志。 | | INCLUDE_ASYNC | 1 | 异步调用标志。启动跟踪时,缺省只跟踪同步调用。设置该标志,同时跟踪同步、异步调用。 | @@ -35,7 +35,7 @@ import hiTraceChain from '@ohos.hiTraceChain'; **系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.HiTrace。 -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | -------- | -------- | | CS | 0 | 客户端发送类型,标识client侧的发送埋点。 | | CR | 1 | 客户端接收类型,标识client侧的接收埋点。 | @@ -49,7 +49,7 @@ import hiTraceChain from '@ohos.hiTraceChain'; **系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.HiTrace。 -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | -------- | -------- | | DEFAULT | 0 | 缺省通信类型 | | THREAD | 1 | 线程间通信类型 | @@ -62,7 +62,7 @@ import hiTraceChain from '@ohos.hiTraceChain'; **系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.HiTrace。 -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | chainId | bigint | 是 | 跟踪链标识。 | | spanId | number | 否 | 分支标识。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md b/zh-cn/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md index ab79995e38e9bbcada9927895da534b52d0734c8..2c388822b6da580e6434606c7d35de39c129ce45 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md @@ -119,7 +119,7 @@ hiAppEvent.write({ **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | ----------------------- | ---- | ---------- | | domain | string | 是 | 事件领域。 | | name | string | 是 | 事件名称。 | @@ -168,7 +168,7 @@ hiAppEvent.configure({ **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ------- | ---- | ------------------------------------------------------------ | | disable | boolean | 否 | 打点功能开关,默认值为false。true:关闭打点功能,false:不关闭打点功能。 | | maxStorage | string | 否 | 打点数据存放目录的配额大小,默认值为“10M”。
在目录大小超出配额后,下次打点会触发对目录的清理操作:按从旧到新的顺序逐个删除打点数据文件,直到目录大小不超出配额时结束。 | @@ -299,7 +299,7 @@ hiAppEvent.removeWatcher(watcher); **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | name | string | 是 | 观察者名称,用于唯一标识观察者。 | | triggerCondition | [TriggerCondition](#triggercondition) | 否 | 订阅回调触发条件,需要与回调函数一同传入才会生效。 | @@ -312,11 +312,11 @@ hiAppEvent.removeWatcher(watcher); **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 参数类型 | 必填 | 说明 | -| ------- | -------- | ---- | -------------------------------------- | -| row | number | 否 | 满足触发回调的事件总数量。 | -| size | number | 否 | 满足触发回调的事件总大小,单位为byte。 | -| timeOut | number | 否 | 满足触发回调的超时时长,单位为30s。 | +| 名称 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | -------------------------------------- | +| row | number | 否 | 满足触发回调的事件总数量。 | +| size | number | 否 | 满足触发回调的事件总大小,单位为byte。 | +| timeOut | number | 否 | 满足触发回调的超时时长,单位为30s。 | ## AppEventFilter @@ -324,7 +324,7 @@ hiAppEvent.removeWatcher(watcher); **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ------------------------- | ---- | ------------------------ | | domain | string | 是 | 需要订阅的事件领域。 | | eventTypes | [EventType](#eventtype)[] | 否 | 需要订阅的事件类型集合。 | @@ -411,12 +411,12 @@ let eventPkg = holder.takeNext(); **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 参数类型 | 说明 | -| --------- | -------- | ------------------------------ | -| packageId | number | 事件包ID,从0开始自动递增。 | -| row | number | 事件包的事件数量。 | -| size | number | 事件包的事件大小,单位为byte。 | -| data | string[] | 事件包的事件信息。 | +| 名称 | 类型 | 必填 | 说明 | +| --------- | -------- | ---- | ------------------------------ | +| packageId | number | 是 | 事件包ID,从0开始自动递增。 | +| row | number | 是 | 事件包的事件数量。 | +| size | number | 是 | 事件包的事件大小,单位为byte。 | +| data | string[] | 是 | 事件包的事件信息。 | ## hiAppEvent.clearData @@ -439,12 +439,12 @@ hiAppEvent.clearData(); **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 默认值 | 说明 | -| --------- | ------ | -------------- | -| FAULT | 1 | 故障类型事件。 | -| STATISTIC | 2 | 统计类型事件。 | -| SECURITY | 3 | 安全类型事件。 | -| BEHAVIOR | 4 | 行为类型事件。 | +| 名称 | 值 | 说明 | +| --------- | ---- | -------------- | +| FAULT | 1 | 故障类型事件。 | +| STATISTIC | 2 | 统计类型事件。 | +| SECURITY | 3 | 安全类型事件。 | +| BEHAVIOR | 4 | 行为类型事件。 | ## Event @@ -453,11 +453,11 @@ hiAppEvent.clearData(); **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------------------------- | -------- | ---- | ---- | -------------------- | -| USER_LOGIN | string | 是 | 否 | 用户登录事件。 | -| USER_LOGOUT | string | 是 | 否 | 用户登出事件。 | -| DISTRIBUTED_SERVICE_START | string | 是 | 否 | 分布式服务启动事件。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------------- | ------ | ---- | ---- | -------------------- | +| USER_LOGIN | string | 是 | 否 | 用户登录事件。 | +| USER_LOGOUT | string | 是 | 否 | 用户登出事件。 | +| DISTRIBUTED_SERVICE_START | string | 是 | 否 | 分布式服务启动事件。 | ## Param @@ -466,8 +466,8 @@ hiAppEvent.clearData(); **系统能力:** SystemCapability.HiviewDFX.HiAppEvent -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------------------------------- | -------- | ---- | ---- | ------------------ | -| USER_ID | string | 是 | 否 | 用户自定义ID。 | -| DISTRIBUTED_SERVICE_NAME | string | 是 | 否 | 分布式服务名称。 | -| DISTRIBUTED_SERVICE_INSTANCE_ID | string | 是 | 否 | 分布式服务实例ID。 | \ No newline at end of file +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------------------- | ------ | ---- | ---- | ------------------ | +| USER_ID | string | 是 | 否 | 用户自定义ID。 | +| DISTRIBUTED_SERVICE_NAME | string | 是 | 否 | 分布式服务名称。 | +| DISTRIBUTED_SERVICE_INSTANCE_ID | string | 是 | 否 | 分布式服务实例ID。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-http.md b/zh-cn/application-dev/reference/apis/js-apis-http.md index e09a76d0f65f51eb5b7d21f44d7fb2e049928602..5c876cb18906e44eb81a9ee75f917dad130536da 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-http.md +++ b/zh-cn/application-dev/reference/apis/js-apis-http.md @@ -2,7 +2,7 @@ 本模块提供HTTP数据请求能力。应用可以通过HTTP发起一个数据请求,支持常见的GET、POST、OPTIONS、HEAD、PUT、DELETE、TRACE、CONNECT方法。 ->**说明:** +>**说明:** > >本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > @@ -38,8 +38,12 @@ httpRequest.request( extraData: { "data": "data to send", }, + expectDataType: http.HttpDataType.STRING, // 可选,指定返回数据的类型 + usingCache: true, // 可选,默认为true + priority: 1, // 可选,默认为1 connectTimeout: 60000, // 可选,默认为60000ms readTimeout: 60000, // 可选,默认为60000ms + usingProtocol: http.HttpProtocol.HTTP1_1, // 可选,协议类型默认值由系统自动指定 }, (err, data) => { if (!err) { // data.result为HTTP响应内容,可根据业务需要进行解析 @@ -78,7 +82,6 @@ import http from '@ohos.net.http'; let httpRequest = http.createHttp(); ``` - ## HttpRequest HTTP请求任务。在调用HttpRequest的方法前,需要先通过[createHttp\(\)](#httpcreatehttp)创建一个任务。 @@ -158,7 +161,6 @@ httpRequest.request("EXAMPLE_URL", }); ``` - ### request request\(url: string, options? : HttpRequestOptions\): Promise @@ -226,7 +228,7 @@ on\(type: 'headerReceive', callback: AsyncCallback\): void 订阅HTTP Response Header 事件。 ->![](public_sys-resources/icon-note.gif) **说明:** +>![](public_sys-resources/icon-note.gif) **说明:** >此接口已废弃,建议使用[on\('headersReceive'\)8+](#onheadersreceive8)替代。 **系统能力**:SystemCapability.Communication.NetStack @@ -250,14 +252,13 @@ httpRequest.on('headerReceive', (err, data) => { }); ``` - ### off\('headerReceive'\) off\(type: 'headerReceive', callback?: AsyncCallback\): void 取消订阅HTTP Response Header 事件。 ->![](public_sys-resources/icon-note.gif) **说明:** +>![](public_sys-resources/icon-note.gif) **说明:** > >1. 此接口已废弃,建议使用[off\('headersReceive'\)8+](#offheadersreceive8)替代。 > @@ -301,14 +302,13 @@ httpRequest.on('headersReceive', (header) => { }); ``` - ### off\('headersReceive'\)8+ off\(type: 'headersReceive', callback?: Callback\): void 取消订阅HTTP Response Header 事件。 ->![](public_sys-resources/icon-note.gif) **说明:** +>![](public_sys-resources/icon-note.gif) **说明:** >可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 **系统能力**:SystemCapability.Communication.NetStack @@ -359,9 +359,13 @@ httpRequest.once('headersReceive', (header) => { | -------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | | method | [RequestMethod](#requestmethod) | 否 | 请求方式。 | | extraData | string \| Object \| ArrayBuffer6+ | 否 | 发送请求的额外数据。
- 当HTTP请求为POST、PUT等方法时,此字段为HTTP请求的content。
- 当HTTP请求为GET、OPTIONS、DELETE、TRACE、CONNECT等方法时,此字段为HTTP请求的参数补充,参数内容会拼接到URL中进行发送。6+
- 开发者传入string对象,开发者需要自行编码,将编码后的string传入。6+ | +| expectDataType9+ | [HttpDataType](#httpdatatype9) | 否 | 指定返回数据的类型。如果设置了此参数,系统将优先返回指定的类型。 | +| usingCache9+ | boolean | 否 | 是否使用缓存,默认为true。 | +| priority9+ | number | 否 | 优先级,范围\[1,1000],默认是1。 | | header | Object | 否 | HTTP请求头字段。默认{'Content-Type': 'application/json'}。 | | readTimeout | number | 否 | 读取超时时间。单位为毫秒(ms),默认为60000ms。 | | connectTimeout | number | 否 | 连接超时时间。单位为毫秒(ms),默认为60000ms。 | +| usingProtocol9+ | [HttpProtocol](#httpprotocol9) | 否 | 使用协议。默认值由系统自动指定。 | ## RequestMethod @@ -433,10 +437,149 @@ request方法回调函数的返回值类型。 | 参数名 | 类型 | 必填 | 说明 | | -------------------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | | result | string \| Object \| ArrayBuffer6+ | 是 | HTTP请求根据响应头中Content-type类型返回对应的响应格式内容:
- application/json:返回JSON格式的字符串,如需HTTP响应具体内容,需开发者自行解析
- application/octet-stream:ArrayBuffer
- 其他:string | +| resultType9+ | [HttpDataType](#httpdatatype9) | 是 | 返回值类型。 | | responseCode | [ResponseCode](#responsecode) \| number | 是 | 回调函数执行成功时,此字段为[ResponseCode](#responsecode)。若执行失败,错误码将会从AsyncCallback中的err字段返回。错误码参考[Response错误码](#response常用错误码)。 | | header | Object | 是 | 发起HTTP请求返回来的响应头。当前返回的是JSON格式字符串,如需具体字段内容,需开发者自行解析。常见字段及解析方式如下:
- Content-Type:header['Content-Type'];
- Status-Line:header['Status-Line'];
- Date:header.Date/header['Date'];
- Server:header.Server/header['Server']; | | cookies8+ | Array\ | 是 | 服务器返回的 cookies。 | +## http.createHttpResponseCache9+ + +createHttpResponseCache(cacheSize?: number): HttpResponseCache + +创建一个默认的对象来存储HTTP访问请求的响应。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | ---------- | +| cacheSize | number | 否 | 缓存大小最大为10\*1024\*1024(10MB),默认最大。 | + +**返回值:** + +| 类型 | 说明 | +| :---------- | :----------------------------------------------------------- | +| [HttpResponseCache](#httpresponsecache9) | 返回一个存储HTTP访问请求响应的对象。 | + +**示例:** + +```js +import http from '@ohos.net.http'; +let httpResponseCache = http.createHttpResponseCache(); +``` + +## HttpResponseCache9+ + +存储HTTP访问请求响应的对象。 + +### flush9+ + +flush(callback: AsyncCallback\): void + +将缓存中的数据写入文件系统,以便在下一个HTTP请求中访问所有缓存数据,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\ | 是 | 回调函数返回写入结果。 | + +**示例:** + +```js +import http from '@ohos.net.http'; +let httpResponseCache = http.createHttpResponseCache(); +httpResponseCache.flush(err => { + if (err) { + console.log('flush fail'); + return; + } + console.log('flush success'); +}); +``` + +### flush9+ + +flush(): Promise\ + +将缓存中的数据写入文件系统,以便在下一个HTTP请求中访问所有缓存数据,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 类型 | 说明 | +| --------------------------------- | ------------------------------------- | +| Promise\> | 以Promise形式返回写入结果。 | + +**示例:** + +```js +import http from '@ohos.net.http'; +let httpResponseCache = http.createHttpResponseCache(); +http.flush().then(() => { + console.log('flush success'); +}).catch(err => { + console.log('flush fail'); +}); +``` + +### delete9+ + +delete(callback: AsyncCallback\): void + +禁用缓存并删除其中的数据,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\ | 是 | 回调函数返回删除结果。| + +**示例:** + +```js +import http from '@ohos.net.http'; +let httpResponseCache = http.createHttpResponseCache(); +httpResponseCache.delete(err => { + if (err) { + console.log('delete fail'); + return; + } + console.log('delete success'); +}); +``` +### delete9+ + +delete(): Promise\ + +禁用缓存并删除其中的数据,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 类型 | 说明 | +| --------------------------------- | ------------------------------------- | +| Promise\ | 以Promise形式返回删除结果。 | + +**示例:** + +```js +import http from '@ohos.net.http'; +let httpResponseCache = http.createHttpResponseCache(); +httpResponseCache.delete().then() => { + console.log('delete success'); +}).catch(err => { + console.log('delete fail'); +}); +``` + ## Response常用错误码 | 错误码 | 说明 | @@ -448,3 +591,21 @@ request方法回调函数的返回值类型。 | 6 | 无法解析主机。 | | 7 | 无法连接代理或主机。 | +## HttpDataType9+ + +http的数据类型。 + +| **HttpDataType 的合法值** | 说明 | +| :------------------ | :----------- | +| STRING | 字符串类型。 | +| OBJECT | 对象类型。 | +| ARRAY_BUFFER | 二进制数组类型。| + +## HttpProtocol9+ + +http协议版本。 + +| **HttpProtocol 的合法值** | 说明 | +| :----------------- | :----------- | +| HTTP1_1 | 协议http1.1 | +| HTTP2 | 协议http2 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md index 11da53c811085c125ac82ce38a3c7726fa02379d..4d1a4d240db46e5b30fff2b762a4507c365713a1 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @@ -30,7 +30,7 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): v | 参数名 | 类型 | 必填 | 说明 | | ---------- | -------------------------- | ---- | ---------------------------------------- | | type | string | 是 | 事件类型,目前只支持”key“。 | -| keyOptions | [keyOptions](#keyoptions) | 是 | 组合键选项。 | +| keyOptions | [KeyOptions](#keyoptions) | 是 | 组合键选项。 | | callback | Callback<KeyOptions> | 是 | 回调函数,当满足条件的组合按键输入事件发生时,异步上报组合按键数据。 | **示例:** @@ -61,7 +61,7 @@ off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): | 参数名 | 类型 | 必填 | 说明 | | ---------- | -------------------------- | ---- | ------------------------------- | | type | string | 是 | 事件类型,当前只支持”key“。 | -| keyOptions | [keyOptions](#keyoptions) | 是 | 组合键选项。 | +| keyOptions | [KeyOptions](#keyoptions) | 是 | 组合键选项。 | | callback | Callback<KeyOptions> | 否 | 需要取消订阅的回调函数,若无此参数,则取消当前应用的组合键选项已订阅的所有回调函数。 | **示例:** @@ -108,7 +108,7 @@ try { | 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | ------ | ---- | ---- | ------- | -| preKeys | Array | 是 | 否 | 前置按键集合,数量范围[0, 4],前置按键无顺序要求。 | -| finalKey | Number | 是 | 否 | 最终按键,此项必填,最终按键触发上报回调函数。 | +| preKeys | Array\ | 是 | 否 | 前置按键集合,数量范围[0, 4],前置按键无顺序要求。 | +| finalKey | number | 是 | 否 | 最终按键,此项必填,最终按键触发上报回调函数。 | | isFinalKeyDown | boolean | 是 | 否 | 最终按键状态。 | -| finalKeyDownDuration | Number | 是 | 否 | 最终按键保持按下持续时间,为0时立即触发回调函数,大于0时,当isFinalKeyDown为true,则最终按键按下超过此时长后触发回调函数,当isFinalKeyDown为false,则最终按键按下到抬起时间小于此时长时触发回调函数。 | +| finalKeyDownDuration | number | 是 | 否 | 最终按键保持按下持续时间,为0时立即触发回调函数,大于0时,当isFinalKeyDown为true,则最终按键按下超过此时长后触发回调函数,当isFinalKeyDown为false,则最终按键按下到抬起时间小于此时长时触发回调函数。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md index c10857c6d46f251994ed7a930eea161b1694254f..e10e496b951d41df40df0522a0e000c9c2b40357 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -482,7 +482,7 @@ try { | id | number | 是 | 否 | 输入设备的唯一标识,同一个物理设备反复插拔,设备id会发生变化。 | | name | string | 是 | 否 | 输入设备的名字。 | | sources | Array<[SourceType](#sourcetype)> | 是 | 否 | 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 | -| axisRanges | Array<[axisRanges](#axisrange)> | 是 | 否 | 输入设备的轴信息。 | +| axisRanges | Array<[AxisRange](#axisrange)> | 是 | 否 | 输入设备的轴信息。 | | bus9+ | number | 是 | 否 | 输入设备的总线类型。 | | product9+ | number | 是 | 否 | 输入设备的产品信息。 | | vendor9+ | number | 是 | 否 | 输入设备的厂商信息。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index 04e7b3799a4536104a0486980a7fa564121b2351..4e7c475ee9678b07d61c724a2b54407739350a8f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -613,7 +613,7 @@ try { showSoftKeyboard(callback: AsyncCallback<void>): void -显示软键盘。使用callback异步回调。 +显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用callback异步回调。 **需要权限:** ohos.permission.CONNECT_IME_ABILITY @@ -648,9 +648,7 @@ inputMethodController.showSoftKeyboard((err) => { ### showSoftKeyboard9+ -showSoftKeyboard(): Promise<void> - -显示软键盘,使用Promise异步回调。 +显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用Promise异步回调。 **需要权限:** ohos.permission.CONNECT_IME_ABILITY @@ -836,7 +834,7 @@ on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, input | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
-type为‘imeChange’时表示订阅输入法及子类型变化监听事件。 | -| callback | [InputMethodProperty](#inputmethodproperty8), [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype) | 是 | 回调函数,返回输入法属性对象及输入法子类型对象。 | +| callback | (inputMethodProperty: [InputMethodProperty](#inputmethodproperty8), inputMethodSubtype: [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)) => void | 是 | 回调函数,返回输入法属性对象及输入法子类型对象。 | **示例:** @@ -859,7 +857,7 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
-type为‘imeChange’时表示取消订阅输入法及子类型变化监听事件。 | -| callback | [InputMethodProperty](#inputmethodproperty8), [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype) | 否 | 回调函数,返回取消订阅的输入法属性对象及输入法子类型对象。 | +| callback | (inputMethodProperty: [InputMethodProperty](#inputmethodproperty8), inputMethodSubtype: [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)) => void | 否 | 回调函数,返回取消订阅的输入法属性对象及输入法子类型对象。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md index ceb131a45c167ddd38c0748944ee0c640ad07a78..c5a1de1cc7f6fb63efc14024e32cd3520aee4785 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -100,7 +100,7 @@ getInputMethodEngine(): InputMethodEngine > **说明:** > ->从API version 8开始支持,API version 9开始废弃, 建议使用[getInputMethodAbility()](#inputmethodenginegetinputmethodability9)替代。 +> 从API version 8开始支持,API version 9开始废弃, 建议使用[getInputMethodAbility()](#inputmethodenginegetinputmethodability9)替代。 **系统能力:** SystemCapability.MiscServices.InputMethodFramework @@ -157,7 +157,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | -| callback | [KeyboardController](#keyboardcontroller), [TextInputClient](#textinputclient) | 是 | 回调函数,返回订阅输入法的KeyboardController和TextInputClient实例。 | +| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [TextInputClient](#textinputclient)) => void | 是 | 回调函数,返回订阅输入法的KeyboardController和TextInputClient实例。 | **示例:** @@ -181,7 +181,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | type | string | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | -| callback | [KeyboardController](#keyboardcontroller), [TextInputClient](#textinputclient) | 否 | 回调函数,返回取消订阅的KeyboardController和TextInputClient实例。 | +| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [TextInputClient](#textinputclient)) => void | 否 | 回调函数,返回取消订阅的KeyboardController和TextInputClient实例。 | **示例:** @@ -204,7 +204,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | void | 是 | 回调函数。 | +| callback | () => void | 是 | 回调函数。 | **示例:** @@ -230,7 +230,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | void | 否 | 回调函数。 | +| callback | () => void | 否 | 回调函数。 | **示例:** @@ -260,7 +260,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient: | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | -| callback | [KeyboardController](#keyboardcontroller), [InputClient](#inputclient9) | 是 | 回调函数,返回输入法操作相关实例。 | +| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [InputClient](#inputclient9)) => void | 是 | 回调函数,返回输入法操作相关实例。 | **示例:** @@ -284,7 +284,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClien | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | type | string | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | -| callback | [KeyboardController](#keyboardcontroller), [InputClient](#inputclient9) | 否 | 回调函数,返回输入法操作相关实例。 | +| callback | (kbController: [KeyboardController](#keyboardcontroller), textInputClient: [InputClient](#inputclient9)) => void | 否 | 回调函数,返回输入法操作相关实例。 | **示例:** @@ -307,7 +307,7 @@ on(type: 'inputStop', callback: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
-type为‘inputStop’时表示订阅停止输入法应用事件。 | -| callback | void | 是 | 回调函数。 | +| callback | () => void | 是 | 回调函数。 | **示例:** @@ -330,7 +330,7 @@ off(type: 'inputStop', callback: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
-type为‘inputStop’时表示订阅停止输入法应用事件。 | -| callback | void | 是 | 回调函数。 | +| callback | () => void | 是 | 回调函数。 | **示例:** @@ -353,7 +353,7 @@ on(type: 'setCallingWindow', callback: (wid:number) => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 | -| callback | number | 是 | 回调函数,返回调用方window id。 | +| callback | (wid:number) => void | 是 | 回调函数,返回调用方window id。 | **示例:** @@ -376,7 +376,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 | -| callback | number | 是 | 回调函数,返回调用方window id。 | +| callback | (wid:number) => void | 是 | 回调函数,返回调用方window id。 | **示例:** @@ -399,7 +399,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | void | 否 | 回调函数。 | +| callback | () => void | 否 | 回调函数。 | **示例:** @@ -425,7 +425,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | void | 否 | 回调函数。 | +| callback | () => void | 否 | 回调函数。 | **示例:** @@ -451,7 +451,7 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'setSubtype',表示订阅输入法子类型设置。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | InputMethodSubtype | 是 | 回调函数,返回调用方的输入法子类型。 | +| callback | (inputMethodSubtype: [InputMethodSubtype](js-apis-inputmethod-subtype.md)) => void | 是 | 回调函数,返回调用方的输入法子类型。 | **示例:** @@ -474,7 +474,7 @@ off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => v | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'setSubtype',表示取消订阅输入法子类型设置。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | InputMethodSubtype | 否 | 回调函数,返回调用方的输入法子类型。 | +| callback | (inputMethodSubtype: [InputMethodSubtype](js-apis-inputmethod-subtype.md)) => void | 否 | 回调函数,返回调用方的输入法子类型。 | **示例:** @@ -501,7 +501,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'keyDown',表示订阅硬键盘按下。
- type为'keyUp',表示订阅硬键盘抬起。 | -| callback | [KeyEvent](#keyevent) | 是 | 回调函数,返回按键信息。 | +| callback | (event: [KeyEvent](#keyevent)) => boolean | 是 | 回调函数,返回按键信息。 | **示例:** @@ -531,7 +531,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'keyDown',表示订阅硬键盘按下。
- type为'keyUp',表示订阅硬键盘抬起。 | -| callback | [KeyEvent](#keyevent) | 否 | 回调函数,返回按键信息。 | +| callback | (event: [KeyEvent](#keyevent)) => boolean | 否 | 回调函数,返回按键信息。 | **示例:** @@ -559,11 +559,11 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 光标变化事件。
-type为’cursorContextChange‘时,表示光标变化。 | -| callback | number | 是 | 回调函数,返回光标信息。 | +| callback | (x: number, y:number, height:number) => void | 是 | 回调函数,返回光标信息。 | - **示例:** +**示例:** ```js inputMethodEngine.getKeyboardDelegate().on('cursorContextChange', (x, y, height) => { @@ -586,7 +586,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 光标变化事件。
-type为’cursorContextChange‘时,表示光标变化。 | -| callback | number | 否 | 回调函数,返回光标信息。 | +| callback | (x: number, y:number, height:number) => void | 否 | 回调函数,返回光标信息。 | **示例:** @@ -609,7 +609,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 文本选择变化事件。
-type为’selectionChange‘时,表示选择文本变化。 | -| callback | number | 是 | 回调函数,返回文本选择信息。 | +| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。 | **示例:** @@ -635,7 +635,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 文本选择变化事件。
-type为’selectionChange‘时,表示选择文本变化。 | -| callback | number | 否 | 回调函数,返回文本选择信息。 | +| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 否 | 回调函数,返回文本选择信息。 | **示例:** @@ -659,7 +659,7 @@ on(type: 'textChange', callback: (text: string) => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 文本变化事件。
-type为’textChange‘时,表示当前文本变化。 | -| callback | string | 是 | 回调函数,返回当前文本内容。 | +| callback | (text: string) => void | 是 | 回调函数,返回当前文本内容。 | **示例:** @@ -682,7 +682,7 @@ off(type: 'textChange', callback?: (text: string) => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 文本变化事件。
-type为’textChange‘时,表示当前文本变化。 | -| callback | string | 否 | 回调函数,返回当前文本内容。 | +| callback | (text: string) => void | 否 | 回调函数,返回当前文本内容。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-installer.md b/zh-cn/application-dev/reference/apis/js-apis-installer.md index b7372b8c3822deaaa0d036ca3903dae4856a0226..93cab24807b7e0d633ce3f2c473254ff4c4d2f1a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-installer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-installer.md @@ -35,10 +35,6 @@ getBundleInstaller(callback: AsyncCallback\): void; | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | callback | AsyncCallback\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | 是 | 回调函数,获取BundleInstaller对象,err为undefined,data为获取到的BundleInstaller对象;否则为错误对象。 | -**错误码:** - -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 - **示例:** ```ts @@ -72,10 +68,6 @@ getBundleInstaller(): Promise\; | ------------------------------------------------------------ | ------------------------------------ | | Promise\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | Promise对象,返回BundleInstaller对象。 | -**错误码:** - -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 - **示例:** ```ts @@ -115,17 +107,17 @@ install(hapFilePaths: Array<string>, installParam: InstallParam, callback: 以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误信息 | -| -------- | ------------------------------------------------------ | -| 17700004 | The specified userId is not existed. | -| 17700010 | To parse file of config.json or module.json failed. | -| 17700011 | To verify signature failed. | -| 17700012 | Invalid hap file path or too large file size. | -| 17700015 | Multiple haps have inconsistent configured information. | -| 17700016 | No disk space left for installation. | -| 17700017 | Downgrade installation is prohibited. | -| 17700101 | The system service is excepted. | -| 17700103 | I/O operation is failed. | +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------------------------ | +| 17700004 | The specified user ID is not found. | +| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | +| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | +| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | +| 17700015 | Failed to install the HAPs because they have different configuration information. | +| 17700016 | Failed to install the HAP because of insufficient system disk space. | +| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | +| 17700101 | The system service is excepted. | +| 17700103 | I/O operation is failed. | **示例:** @@ -181,9 +173,9 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac | 错误码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. | -| 17700101 | The system service is excepted. | +| 17700101 | The system service is excepted. | **示例:** @@ -239,7 +231,7 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback& | 错误码ID | 错误信息 | | -------- | ----------------------------------- | -| 17700004 | The specified userId is not existed. | +| 17700004 | The specified user ID is not found. | **示例:** @@ -277,10 +269,10 @@ try { **系统接口:** 此接口为系统接口,三方应用不支持调用 -| 参数名 | 类型 | 说明 | -| ---------- | ------ | ---------------- | -| moduleName | string | 应用程序模块名称。 | -| hashValue | string | 哈希值。 | +| 名称 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---------------- | ---------------- | +| moduleName | string | 是 | 应用程序模块名称。 | +| hashValue | string | 是 | 哈希值。 | ## InstallParam @@ -290,10 +282,10 @@ try { **系统接口:** 此接口为系统接口,三方应用不支持调用 -| 参数名 | 类型 | 说明 | -| ------------------------------ | ------------------------------ | ------------------ | -| userId | number | 指示用户id,可使用[queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#queryosaccountlocalidfromprocess9)获取当前进程所在用户。 | -| installFlag | number | 指示安装标志,枚举值:0:应用初次安装,1:应用覆盖安装。 | -| isKeepData | boolean | 卸载时是否保留数据目录。 | -| hashParams | Array<[HashParam](#hashparam)> | 哈希值参数。 | -| crowdtestDeadline| number |[众测](https://developer.huawei.com/consumer/cn/agconnect/crowd-test/)截止日期。 | \ No newline at end of file +| 名称 | 类型 | 必填 | 说明 | +| ------------------------------ | ------------------------------ | ------------------ | ------------------ | +| userId | number | 是 | 指示用户id,可使用[queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#queryosaccountlocalidfromprocess9)获取当前进程所在用户。 | +| installFlag | number | 是 | 指示安装标志,枚举值:0:应用初次安装,1:应用覆盖安装。 | +| isKeepData | boolean | 是 | 卸载时是否保留数据目录。 | +| hashParams | Array<[HashParam](#hashparam)> | 是 | 哈希值参数。 | +| crowdtestDeadline| number | 是 |[众测](https://developer.huawei.com/consumer/cn/agconnect/crowd-test/)截止日期。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-keycode.md b/zh-cn/application-dev/reference/apis/js-apis-keycode.md index 817111a4877788bf4e983a202a002e3bc1cb6221..95ee341fe264b996c7e9d147b678f95af54451f3 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-keycode.md +++ b/zh-cn/application-dev/reference/apis/js-apis-keycode.md @@ -15,335 +15,335 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode'; **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------------------------------- | ------ | ---- | ---- | --------------------------- | -| KEYCODE_FN | number | 是 | 否 | 功能(Fn)键 | -| KEYCODE_UNKNOWN | number | 是 | 否 | 未知按键 | -| KEYCODE_HOME | number | 是 | 否 | 功能(Home)键 | -| KEYCODE_BACK | number | 是 | 否 | 返回键 | -| KEYCODE_MEDIA_PLAY_PAUSE | number | 是 | 否 | 多媒体键 播放/暂停 | -| KEYCODE_MEDIA_STOP | number | 是 | 否 | 多媒体键 停止 | -| KEYCODE_MEDIA_NEXT | number | 是 | 否 | 多媒体键 下一首 | -| KEYCODE_MEDIA_PREVIOUS | number | 是 | 否 | 多媒体键 上一首 | -| KEYCODE_MEDIA_REWIND | number | 是 | 否 | 多媒体键 快退 | -| KEYCODE_MEDIA_FAST_FORWARD | number | 是 | 否 | 多媒体键 快进 | -| KEYCODE_VOLUME_UP | number | 是 | 否 | 音量增加键 | -| KEYCODE_VOLUME_DOWN | number | 是 | 否 | 音量减小键 | -| KEYCODE_POWER | number | 是 | 否 | 电源键 | -| KEYCODE_CAMERA | number | 是 | 否 | 拍照键 | -| KEYCODE_VOLUME_MUTE | number | 是 | 否 | 扬声器静音键 | -| KEYCODE_MUTE | number | 是 | 否 | 话筒静音键 | -| KEYCODE_BRIGHTNESS_UP | number | 是 | 否 | 亮度调节按键 调亮 | -| KEYCODE_BRIGHTNESS_DOWN | number | 是 | 否 | 亮度调节按键 调暗 | -| KEYCODE_0 | number | 是 | 否 | 按键'0' | -| KEYCODE_1 | number | 是 | 否 | 按键'1' | -| KEYCODE_2 | number | 是 | 否 | 按键'2' | -| KEYCODE_3 | number | 是 | 否 | 按键'3' | -| KEYCODE_4 | number | 是 | 否 | 按键'4' | -| KEYCODE_5 | number | 是 | 否 | 按键'5' | -| KEYCODE_6 | number | 是 | 否 | 按键'6' | -| KEYCODE_7 | number | 是 | 否 | 按键'7' | -| KEYCODE_8 | number | 是 | 否 | 按键'8' | -| KEYCODE_9 | number | 是 | 否 | 按键'9' | -| KEYCODE_STAR | number | 是 | 否 | 按键'*' | -| KEYCODE_POUND | number | 是 | 否 | 按键'#' | -| KEYCODE_DPAD_UP | number | 是 | 否 | 导航键 向上 | -| KEYCODE_DPAD_DOWN | number | 是 | 否 | 导航键 向下 | -| KEYCODE_DPAD_LEFT | number | 是 | 否 | 导航键 向左 | -| KEYCODE_DPAD_RIGHT | number | 是 | 否 | 导航键 向右 | -| KEYCODE_DPAD_CENTER | number | 是 | 否 | 导航键 确定键 | -| KEYCODE_A | number | 是 | 否 | 按键'A' | -| KEYCODE_B | number | 是 | 否 | 按键'B' | -| KEYCODE_C | number | 是 | 否 | 按键'C' | -| KEYCODE_D | number | 是 | 否 | 按键'D' | -| KEYCODE_E | number | 是 | 否 | 按键'E' | -| KEYCODE_F | number | 是 | 否 | 按键'F' | -| KEYCODE_G | number | 是 | 否 | 按键'G' | -| KEYCODE_H | number | 是 | 否 | 按键'H' | -| KEYCODE_I | number | 是 | 否 | 按键'I' | -| KEYCODE_J | number | 是 | 否 | 按键'J' | -| KEYCODE_K | number | 是 | 否 | 按键'K' | -| KEYCODE_L | number | 是 | 否 | 按键'L' | -| KEYCODE_M | number | 是 | 否 | 按键'M' | -| KEYCODE_N | number | 是 | 否 | 按键'N' | -| KEYCODE_O | number | 是 | 否 | 按键'O' | -| KEYCODE_P | number | 是 | 否 | 按键'P' | -| KEYCODE_Q | number | 是 | 否 | 按键'Q' | -| KEYCODE_R | number | 是 | 否 | 按键'R' | -| KEYCODE_S | number | 是 | 否 | 按键'S' | -| KEYCODE_T | number | 是 | 否 | 按键'T' | -| KEYCODE_U | number | 是 | 否 | 按键'U' | -| KEYCODE_V | number | 是 | 否 | 按键'V' | -| KEYCODE_W | number | 是 | 否 | 按键'W' | -| KEYCODE_X | number | 是 | 否 | 按键'X' | -| KEYCODE_Y | number | 是 | 否 | 按键'Y' | -| KEYCODE_Z | number | 是 | 否 | 按键'Z' | -| KEYCODE_COMMA | number | 是 | 否 | 按键',' | -| KEYCODE_PERIOD | number | 是 | 否 | 按键'.' | -| KEYCODE_ALT_LEFT | number | 是 | 否 | 左Alt键 | -| KEYCODE_ALT_RIGHT | number | 是 | 否 | 右Alt键 | -| KEYCODE_SHIFT_LEFT | number | 是 | 否 | 左Shift键 | -| KEYCODE_SHIFT_RIGHT | number | 是 | 否 | 右Shift键 | -| KEYCODE_TAB | number | 是 | 否 | Tab键 | -| KEYCODE_SPACE | number | 是 | 否 | 空格键 | -| KEYCODE_SYM | number | 是 | 否 | 符号修改器按键 | -| KEYCODE_EXPLORER | number | 是 | 否 | 浏览器功能键,此键用于启动浏览器应用程序。 | -| KEYCODE_ENVELOPE | number | 是 | 否 | 电子邮件功能键,此键用于启动电子邮件应用程序。 | -| KEYCODE_ENTER | number | 是 | 否 | 回车键 | -| KEYCODE_DEL | number | 是 | 否 | 退格键 | -| KEYCODE_GRAVE | number | 是 | 否 | 按键'`' | -| KEYCODE_MINUS | number | 是 | 否 | 按键'-' | -| KEYCODE_EQUALS | number | 是 | 否 | 按键'=' | -| KEYCODE_LEFT_BRACKET | number | 是 | 否 | 按键'[' | -| KEYCODE_RIGHT_BRACKET | number | 是 | 否 | 按键']' | -| KEYCODE_BACKSLASH | number | 是 | 否 | 按键'\\' | -| KEYCODE_SEMICOLON | number | 是 | 否 | 按键';' | -| KEYCODE_APOSTROPHE | number | 是 | 否 | 按键''' (单引号) | -| KEYCODE_SLASH | number | 是 | 否 | 按键'/' | -| KEYCODE_AT | number | 是 | 否 | 按键'@' | -| KEYCODE_PLUS | number | 是 | 否 | 按键'+' | -| KEYCODE_MENU | number | 是 | 否 | 菜单键 | -| KEYCODE_PAGE_UP | number | 是 | 否 | 向上翻页键 | -| KEYCODE_PAGE_DOWN | number | 是 | 否 | 向下翻页键 | -| KEYCODE_ESCAPE | number | 是 | 否 | ESC键 | -| KEYCODE_FORWARD_DEL | number | 是 | 否 | 删除键 | -| KEYCODE_CTRL_LEFT | number | 是 | 否 | 左Ctrl键 | -| KEYCODE_CTRL_RIGHT | number | 是 | 否 | 右Ctrl键 | -| KEYCODE_CAPS_LOCK | number | 是 | 否 | 大写锁定键 | -| KEYCODE_SCROLL_LOCK | number | 是 | 否 | 滚动锁定键 | -| KEYCODE_META_LEFT | number | 是 | 否 | 左元修改器键 | -| KEYCODE_META_RIGHT | number | 是 | 否 | 右元修改器键 | -| KEYCODE_FUNCTION | number | 是 | 否 | 功能键 | -| KEYCODE_SYSRQ | number | 是 | 否 | 系统请求/打印屏幕键 | -| KEYCODE_BREAK | number | 是 | 否 | Break/Pause键 | -| KEYCODE_MOVE_HOME | number | 是 | 否 | 光标移动到开始键 | -| KEYCODE_MOVE_END | number | 是 | 否 | 光标移动到末尾键 | -| KEYCODE_INSERT | number | 是 | 否 | 插入键 | -| KEYCODE_FORWARD | number | 是 | 否 | 前进键 | -| KEYCODE_MEDIA_PLAY | number | 是 | 否 | 多媒体键 播放 | -| KEYCODE_MEDIA_PAUSE | number | 是 | 否 | 多媒体键 暂停 | -| KEYCODE_MEDIA_CLOSE | number | 是 | 否 | 多媒体键 关闭 | -| KEYCODE_MEDIA_EJECT | number | 是 | 否 | 多媒体键 弹出 | -| KEYCODE_MEDIA_RECORD | number | 是 | 否 | 多媒体键 录音 | -| KEYCODE_F1 | number | 是 | 否 | 按键'F1' | -| KEYCODE_F2 | number | 是 | 否 | 按键'F2' | -| KEYCODE_F3 | number | 是 | 否 | 按键'F3' | -| KEYCODE_F4 | number | 是 | 否 | 按键'F4' | -| KEYCODE_F5 | number | 是 | 否 | 按键'F5' | -| KEYCODE_F6 | number | 是 | 否 | 按键'F6' | -| KEYCODE_F7 | number | 是 | 否 | 按键'F7' | -| KEYCODE_F8 | number | 是 | 否 | 按键'F8' | -| KEYCODE_F9 | number | 是 | 否 | 按键'F9' | -| KEYCODE_F10 | number | 是 | 否 | 按键'F10' | -| KEYCODE_F11 | number | 是 | 否 | 按键'F11' | -| KEYCODE_F12 | number | 是 | 否 | 按键'F12' | -| KEYCODE_NUM_LOCK | number | 是 | 否 | 小键盘锁 | -| KEYCODE_NUMPAD_0 | number | 是 | 否 | 小键盘按键'0' | -| KEYCODE_NUMPAD_1 | number | 是 | 否 | 小键盘按键'1' | -| KEYCODE_NUMPAD_2 | number | 是 | 否 | 小键盘按键'2' | -| KEYCODE_NUMPAD_3 | number | 是 | 否 | 小键盘按键'3' | -| KEYCODE_NUMPAD_4 | number | 是 | 否 | 小键盘按键'4' | -| KEYCODE_NUMPAD_5 | number | 是 | 否 | 小键盘按键'5' | -| KEYCODE_NUMPAD_6 | number | 是 | 否 | 小键盘按键'6' | -| KEYCODE_NUMPAD_7 | number | 是 | 否 | 小键盘按键'7' | -| KEYCODE_NUMPAD_8 | number | 是 | 否 | 小键盘按键'8' | -| KEYCODE_NUMPAD_9 | number | 是 | 否 | 小键盘按键'9' | -| KEYCODE_NUMPAD_DIVIDE | number | 是 | 否 | 小键盘按键'/' | -| KEYCODE_NUMPAD_MULTIPLY | number | 是 | 否 | 小键盘按键'*' | -| KEYCODE_NUMPAD_SUBTRACT | number | 是 | 否 | 小键盘按键'-' | -| KEYCODE_NUMPAD_ADD | number | 是 | 否 | 小键盘按键'+' | -| KEYCODE_NUMPAD_DOT | number | 是 | 否 | 小键盘按键'.' | -| KEYCODE_NUMPAD_COMMA | number | 是 | 否 | 小键盘按键',' | -| KEYCODE_NUMPAD_ENTER | number | 是 | 否 | 小键盘按键回车 | -| KEYCODE_NUMPAD_EQUALS | number | 是 | 否 | 小键盘按键'=' | -| KEYCODE_NUMPAD_LEFT_PAREN | number | 是 | 否 | 小键盘按键'(' | -| KEYCODE_NUMPAD_RIGHT_PAREN | number | 是 | 否 | 小键盘按键')' | -| KEYCODE_VIRTUAL_MULTITASK | number | 是 | 否 | 虚拟多任务键 | -| KEYCODE_SLEEP | number | 是 | 否 | 睡眠键 | -| KEYCODE_ZENKAKU_HANKAKU | number | 是 | 否 | 日文全宽/半宽键 | -| KEYCODE_102ND | number | 是 | 否 | 102nd按键 | -| KEYCODE_RO | number | 是 | 否 | 日文Ro键 | -| KEYCODE_KATAKANA | number | 是 | 否 | 日文片假名键 | -| KEYCODE_HIRAGANA | number | 是 | 否 | 日文平假名键 | -| KEYCODE_HENKAN | number | 是 | 否 | 日文转换键 | -| KEYCODE_KATAKANA_HIRAGANA | number | 是 | 否 | 日语片假名/平假名键 | -| KEYCODE_MUHENKAN | number | 是 | 否 | 日文非转换键 | -| KEYCODE_LINEFEED | number | 是 | 否 | 换行键 | -| KEYCODE_MACRO | number | 是 | 否 | 宏键 | -| KEYCODE_NUMPAD_PLUSMINUS | number | 是 | 否 | 数字键盘上的加号/减号键 | -| KEYCODE_SCALE | number | 是 | 否 | 扩展键 | -| KEYCODE_HANGUEL | number | 是 | 否 | 日文韩语键 | -| KEYCODE_HANJA | number | 是 | 否 | 日文汉语键 | -| KEYCODE_YEN | number | 是 | 否 | 日元键 | -| KEYCODE_STOP | number | 是 | 否 | 停止键 | -| KEYCODE_AGAIN | number | 是 | 否 | 重复键 | -| KEYCODE_PROPS | number | 是 | 否 | 道具键 | -| KEYCODE_UNDO | number | 是 | 否 | 撤消键 | -| KEYCODE_COPY | number | 是 | 否 | 复制键 | -| KEYCODE_OPEN | number | 是 | 否 | 打开键 | -| KEYCODE_PASTE | number | 是 | 否 | 粘贴键 | -| KEYCODE_FIND | number | 是 | 否 | 查找键 | -| KEYCODE_CUT | number | 是 | 否 | 剪切键 | -| KEYCODE_HELP | number | 是 | 否 | 帮助键 | -| KEYCODE_CALC | number | 是 | 否 | 计算器特殊功能键,用于启动计算器应用程序 | -| KEYCODE_FILE | number | 是 | 否 | 文件按键 | -| KEYCODE_BOOKMARKS | number | 是 | 否 | 书签键 | -| KEYCODE_NEXT | number | 是 | 否 | 下一个按键 | -| KEYCODE_PLAYPAUSE | number | 是 | 否 | 播放/暂停键 | -| KEYCODE_PREVIOUS | number | 是 | 否 | 上一个按键 | -| KEYCODE_STOPCD | number | 是 | 否 | CD停止键 | -| KEYCODE_CONFIG | number | 是 | 否 | 配置键 | -| KEYCODE_REFRESH | number | 是 | 否 | 刷新键 | -| KEYCODE_EXIT | number | 是 | 否 | 退出键 | -| KEYCODE_EDIT | number | 是 | 否 | 编辑键 | -| KEYCODE_SCROLLUP | number | 是 | 否 | 向上滚动键 | -| KEYCODE_SCROLLDOWN | number | 是 | 否 | 向下滚动键 | -| KEYCODE_NEW | number | 是 | 否 | 新建键 | -| KEYCODE_REDO | number | 是 | 否 | 恢复键 | -| KEYCODE_CLOSE | number | 是 | 否 | 关闭键 | -| KEYCODE_PLAY | number | 是 | 否 | 播放键 | -| KEYCODE_BASSBOOST | number | 是 | 否 | 低音增强键 | -| KEYCODE_PRINT | number | 是 | 否 | 打印键 | -| KEYCODE_CHAT | number | 是 | 否 | 聊天键 | -| KEYCODE_FINANCE | number | 是 | 否 | 金融键 | -| KEYCODE_CANCEL | number | 是 | 否 | 取消键 | -| KEYCODE_KBDILLUM_TOGGLE | number | 是 | 否 | 键盘灯光切换键 | -| KEYCODE_KBDILLUM_DOWN | number | 是 | 否 | 键盘灯光调亮键 | -| KEYCODE_KBDILLUM_UP | number | 是 | 否 | 键盘灯光调暗键 | -| KEYCODE_SEND | number | 是 | 否 | 发送键 | -| KEYCODE_REPLY | number | 是 | 否 | 答复键 | -| KEYCODE_FORWARDMAIL | number | 是 | 否 | 邮件转发键 | -| KEYCODE_SAVE | number | 是 | 否 | 保存键 | -| KEYCODE_DOCUMENTS | number | 是 | 否 | 文件键 | -| KEYCODE_VIDEO_NEXT | number | 是 | 否 | 下一个视频键 | -| KEYCODE_VIDEO_PREV | number | 是 | 否 | 上一个视频键 | -| KEYCODE_BRIGHTNESS_CYCLE | number | 是 | 否 | 背光渐变键 | -| KEYCODE_BRIGHTNESS_ZERO | number | 是 | 否 | 亮度调节为0键 | -| KEYCODE_DISPLAY_OFF | number | 是 | 否 | 显示关闭键 | -| KEYCODE_BTN_MISC | number | 是 | 否 | 游戏手柄上的各种按键 | -| KEYCODE_GOTO | number | 是 | 否 | 进入键 | -| KEYCODE_INFO | number | 是 | 否 | 信息查看键 | -| KEYCODE_PROGRAM | number | 是 | 否 | 程序键 | -| KEYCODE_PVR | number | 是 | 否 | 个人录像机(PVR)键 | -| KEYCODE_SUBTITLE | number | 是 | 否 | 字幕键 | -| KEYCODE_FULL_SCREEN | number | 是 | 否 | 全屏键 | -| KEYCODE_KEYBOARD | number | 是 | 否 | 键盘 | -| KEYCODE_ASPECT_RATIO | number | 是 | 否 | 屏幕纵横比调节键 | -| KEYCODE_PC | number | 是 | 否 | 端口控制键 | -| KEYCODE_TV | number | 是 | 否 | TV键 | -| KEYCODE_TV2 | number | 是 | 否 | TV键2 | -| KEYCODE_VCR | number | 是 | 否 | 录像机开启键 | -| KEYCODE_VCR2 | number | 是 | 否 | 录像机开启键2 | -| KEYCODE_SAT | number | 是 | 否 | SIM卡应用工具包(SAT)键 | -| KEYCODE_CD | number | 是 | 否 | CD键 | -| KEYCODE_TAPE | number | 是 | 否 | 磁带键 | -| KEYCODE_TUNER | number | 是 | 否 | 调谐器键 | -| KEYCODE_PLAYER | number | 是 | 否 | 播放器键 | -| KEYCODE_DVD | number | 是 | 否 | DVD键 | -| KEYCODE_AUDIO | number | 是 | 否 | 音频键 | -| KEYCODE_VIDEO | number | 是 | 否 | 视频键 | -| KEYCODE_MEMO | number | 是 | 否 | 备忘录键 | -| KEYCODE_CALENDAR | number | 是 | 否 | 日历键 | -| KEYCODE_RED | number | 是 | 否 | 红色指示器 | -| KEYCODE_GREEN | number | 是 | 否 | 绿色指示器 | -| KEYCODE_YELLOW | number | 是 | 否 | 黄色指示器 | -| KEYCODE_BLUE | number | 是 | 否 | 蓝色指示器 | -| KEYCODE_CHANNELUP | number | 是 | 否 | 频道向上键 | -| KEYCODE_CHANNELDOWN | number | 是 | 否 | 频道向下键 | -| KEYCODE_LAST | number | 是 | 否 | 末尾键 | -| KEYCODE_RESTART | number | 是 | 否 | 重启键 | -| KEYCODE_SLOW | number | 是 | 否 | 慢速键 | -| KEYCODE_SHUFFLE | number | 是 | 否 | 随机播放键 | -| KEYCODE_VIDEOPHONE | number | 是 | 否 | 可视电话键 | -| KEYCODE_GAMES | number | 是 | 否 | 游戏键 | -| KEYCODE_ZOOMIN | number | 是 | 否 | 放大键 | -| KEYCODE_ZOOMOUT | number | 是 | 否 | 缩小键 | -| KEYCODE_ZOOMRESET | number | 是 | 否 | 缩放重置键 | -| KEYCODE_WORDPROCESSOR | number | 是 | 否 | 文字处理键 | -| KEYCODE_EDITOR | number | 是 | 否 | 编辑器键 | -| KEYCODE_SPREADSHEET | number | 是 | 否 | 电子表格键 | -| KEYCODE_GRAPHICSEDITOR | number | 是 | 否 | 图形编辑器键 | -| KEYCODE_PRESENTATION | number | 是 | 否 | 演示文稿键 | -| KEYCODE_DATABASE | number | 是 | 否 | 数据库键标 | -| KEYCODE_NEWS | number | 是 | 否 | 新闻键 | -| KEYCODE_VOICEMAIL | number | 是 | 否 | 语音信箱 | -| KEYCODE_ADDRESSBOOK | number | 是 | 否 | 通讯簿 | -| KEYCODE_MESSENGER | number | 是 | 否 | 通信键 | -| KEYCODE_BRIGHTNESS_TOGGLE | number | 是 | 否 | 亮度切换键 | -| KEYCODE_SPELLCHECK | number | 是 | 否 | AL拼写检查 | -| KEYCODE_COFFEE | number | 是 | 否 | 终端锁/屏幕保护程序 | -| KEYCODE_MEDIA_REPEAT | number | 是 | 否 | 媒体循环键 | -| KEYCODE_IMAGES | number | 是 | 否 | 图像键 | -| KEYCODE_BUTTONCONFIG | number | 是 | 否 | 按键配置键 | -| KEYCODE_TASKMANAGER | number | 是 | 否 | 任务管理器 | -| KEYCODE_JOURNAL | number | 是 | 否 | 日志按键 | -| KEYCODE_CONTROLPANEL | number | 是 | 否 | 控制面板键 | -| KEYCODE_APPSELECT | number | 是 | 否 | 应用程序选择键 | -| KEYCODE_SCREENSAVER | number | 是 | 否 | 屏幕保护程序键 | -| KEYCODE_ASSISTANT | number | 是 | 否 | 辅助键 | -| KEYCODE_KBD_LAYOUT_NEXT | number | 是 | 否 | 下一个键盘布局键 | -| KEYCODE_BRIGHTNESS_MIN | number | 是 | 否 | 最小亮度键 | -| KEYCODE_BRIGHTNESS_MAX | number | 是 | 否 | 最大亮度键 | -| KEYCODE_KBDINPUTASSIST_PREV | number | 是 | 否 | 键盘输入Assist_Previous | -| KEYCODE_KBDINPUTASSIST_NEXT | number | 是 | 否 | 键盘输入Assist_Next | -| KEYCODE_KBDINPUTASSIST_PREVGROUP | number | 是 | 否 | 键盘输入Assist_Previous | -| KEYCODE_KBDINPUTASSIST_NEXTGROUP | number | 是 | 否 | 键盘输入Assist_Next | -| KEYCODE_KBDINPUTASSIST_ACCEPT | number | 是 | 否 | 键盘输入Assist_Accept | -| KEYCODE_KBDINPUTASSIST_CANCEL | number | 是 | 否 | 键盘输入Assist_Cancel | -| KEYCODE_FRONT | number | 是 | 否 | 挡风玻璃除雾器开关 | -| KEYCODE_SETUP | number | 是 | 否 | 设置键 | -| KEYCODE_WAKEUP | number | 是 | 否 | 唤醒键 | -| KEYCODE_SENDFILE | number | 是 | 否 | 发送文件按键 | -| KEYCODE_DELETEFILE | number | 是 | 否 | 删除文件按键 | -| KEYCODE_XFER | number | 是 | 否 | 文件传输(XFER)按键 | -| KEYCODE_PROG1 | number | 是 | 否 | 程序键1 | -| KEYCODE_PROG2 | number | 是 | 否 | 程序键2 | -| KEYCODE_MSDOS | number | 是 | 否 | MS-DOS键(微软磁盘操作系统 | -| KEYCODE_SCREENLOCK | number | 是 | 否 | 屏幕锁定键 | -| KEYCODE_DIRECTION_ROTATE_DISPLAY | number | 是 | 否 | 方向旋转显示键 | -| KEYCODE_CYCLEWINDOWS | number | 是 | 否 | Windows循环键 | -| KEYCODE_COMPUTER | number | 是 | 否 | 按键 | -| KEYCODE_EJECTCLOSECD | number | 是 | 否 | 弹出CD键 | -| KEYCODE_ISO | number | 是 | 否 | ISO键 | -| KEYCODE_MOVE | number | 是 | 否 | 移动键 | -| KEYCODE_F13 | number | 是 | 否 | 按键'F13' | -| KEYCODE_F14 | number | 是 | 否 | 按键'F14' | -| KEYCODE_F15 | number | 是 | 否 | 按键'F15' | -| KEYCODE_F16 | number | 是 | 否 | 按键'F16' | -| KEYCODE_F17 | number | 是 | 否 | 按键'F17' | -| KEYCODE_F18 | number | 是 | 否 | 按键'F18' | -| KEYCODE_F19 | number | 是 | 否 | 按键'F19' | -| KEYCODE_F20 | number | 是 | 否 | 按键'F20' | -| KEYCODE_F21 | number | 是 | 否 | 按键'F21' | -| KEYCODE_F22 | number | 是 | 否 | 按键'F22' | -| KEYCODE_F23 | number | 是 | 否 | 按键'F23' | -| KEYCODE_F24 | number | 是 | 否 | 按键'F24' | -| KEYCODE_PROG3 | number | 是 | 否 | 程序键3 | -| KEYCODE_PROG4 | number | 是 | 否 | 程序键4 | -| KEYCODE_DASHBOARD | number | 是 | 否 | 仪表板 | -| KEYCODE_SUSPEND | number | 是 | 否 | 挂起键 | -| KEYCODE_HP | number | 是 | 否 | 高阶路径键 | -| KEYCODE_SOUND | number | 是 | 否 | 音量键 | -| KEYCODE_QUESTION | number | 是 | 否 | 疑问按键 | -| KEYCODE_CONNECT | number | 是 | 否 | 连接键 | -| KEYCODE_SPORT | number | 是 | 否 | 运动按键 | -| KEYCODE_SHOP | number | 是 | 否 | 商城键 | -| KEYCODE_ALTERASE | number | 是 | 否 | 交替键 | -| KEYCODE_SWITCHVIDEOMODE | number | 是 | 否 | 在可用视频之间循环输出(监视器/LCD/TV输出/等) | -| KEYCODE_BATTERY | number | 是 | 否 | 电池按键 | -| KEYCODE_BLUETOOTH | number | 是 | 否 | 蓝牙按键 | -| KEYCODE_WLAN | number | 是 | 否 | 无线局域网 | -| KEYCODE_UWB | number | 是 | 否 | 超宽带(UWB) | -| KEYCODE_WWAN_WIMAX | number | 是 | 否 | WWAN WiMAX按键 | -| KEYCODE_RFKILL | number | 是 | 否 | 控制所有收音机的键 | -| KEYCODE_CHANNEL | number | 是 | 否 | 向上频道键 | -| KEYCODE_BTN_0 | number | 是 | 否 | 按键0 | -| KEYCODE_BTN_1 | number | 是 | 否 | 按键1 | -| KEYCODE_BTN_2 | number | 是 | 否 | 按键2 | -| KEYCODE_BTN_3 | number | 是 | 否 | 按键3 | -| KEYCODE_BTN_4 | number | 是 | 否 | 按键4 | -| KEYCODE_BTN_5 | number | 是 | 否 | 按键5 | -| KEYCODE_BTN_6 | number | 是 | 否 | 按键6 | -| KEYCODE_BTN_7 | number | 是 | 否 | 按键7 | -| KEYCODE_BTN_8 | number | 是 | 否 | 按键8 | -| KEYCODE_BTN_9 | number | 是 | 否 | 按键9 | +| 名称 | 值 | 说明 | +| -------------------------------- | ------ | --------------------------- | +| KEYCODE_FN | 0 | 功能(Fn)键 | +| KEYCODE_UNKNOWN | -1 | 未知按键 | +| KEYCODE_HOME | 1 | 功能(Home)键 | +| KEYCODE_BACK | 2 | 返回键 | +| KEYCODE_MEDIA_PLAY_PAUSE | 10 | 多媒体键 播放/暂停 | +| KEYCODE_MEDIA_STOP | 11 | 多媒体键 停止 | +| KEYCODE_MEDIA_NEXT | 12 | 多媒体键 下一首 | +| KEYCODE_MEDIA_PREVIOUS | 13 | 多媒体键 上一首 | +| KEYCODE_MEDIA_REWIND | 14 | 多媒体键 快退 | +| KEYCODE_MEDIA_FAST_FORWARD | 15 | 多媒体键 快进 | +| KEYCODE_VOLUME_UP | 16 | 音量增加键 | +| KEYCODE_VOLUME_DOWN | 17 | 音量减小键 | +| KEYCODE_POWER | 18 | 电源键 | +| KEYCODE_CAMERA | 19 | 拍照键 | +| KEYCODE_VOLUME_MUTE | 22 | 扬声器静音键 | +| KEYCODE_MUTE | 23 | 话筒静音键 | +| KEYCODE_BRIGHTNESS_UP | 40 | 亮度调节按键 调亮 | +| KEYCODE_BRIGHTNESS_DOWN | 41 | 亮度调节按键 调暗 | +| KEYCODE_0 | 2000 | 按键'0' | +| KEYCODE_1 | 2001 | 按键'1' | +| KEYCODE_2 | 2002 | 按键'2' | +| KEYCODE_3 | 2003 | 按键'3' | +| KEYCODE_4 | 2004 | 按键'4' | +| KEYCODE_5 | 2005 | 按键'5' | +| KEYCODE_6 | 2006 | 按键'6' | +| KEYCODE_7 | 2007 | 按键'7' | +| KEYCODE_8 | 2008 | 按键'8' | +| KEYCODE_9 | 2009 | 按键'9' | +| KEYCODE_STAR | 2010 | 按键'*' | +| KEYCODE_POUND | 2011 | 按键'#' | +| KEYCODE_DPAD_UP | 2012 | 导航键 向上 | +| KEYCODE_DPAD_DOWN | 2013 | 导航键 向下 | +| KEYCODE_DPAD_LEFT | 2014 | 导航键 向左 | +| KEYCODE_DPAD_RIGHT | 2015 | 导航键 向右 | +| KEYCODE_DPAD_CENTER | 2016 | 导航键 确定键 | +| KEYCODE_A | 2017 | 按键'A' | +| KEYCODE_B | 2018 | 按键'B' | +| KEYCODE_C | 2019 | 按键'C' | +| KEYCODE_D | 2020 | 按键'D' | +| KEYCODE_E | 2021 | 按键'E' | +| KEYCODE_F | 2022 | 按键'F' | +| KEYCODE_G | 2023 | 按键'G' | +| KEYCODE_H | 2024 | 按键'H' | +| KEYCODE_I | 2025 | 按键'I' | +| KEYCODE_J | 2026 | 按键'J' | +| KEYCODE_K | 2027 | 按键'K' | +| KEYCODE_L | 2028 | 按键'L' | +| KEYCODE_M | 2029 | 按键'M' | +| KEYCODE_N | 2030 | 按键'N' | +| KEYCODE_O | 2031 | 按键'O' | +| KEYCODE_P | 2032 | 按键'P' | +| KEYCODE_Q | 2033 | 按键'Q' | +| KEYCODE_R | 2034 | 按键'R' | +| KEYCODE_S | 2035 | 按键'S' | +| KEYCODE_T | 2036 | 按键'T' | +| KEYCODE_U | 2037 | 按键'U' | +| KEYCODE_V | 2038 | 按键'V' | +| KEYCODE_W | 2039 | 按键'W' | +| KEYCODE_X | 2040 | 按键'X' | +| KEYCODE_Y | 2041 | 按键'Y' | +| KEYCODE_Z | 2042 | 按键'Z' | +| KEYCODE_COMMA | 2043 | 按键',' | +| KEYCODE_PERIOD | 2044 | 按键'.' | +| KEYCODE_ALT_LEFT | 2045 | 左Alt键 | +| KEYCODE_ALT_RIGHT | 2046 | 右Alt键 | +| KEYCODE_SHIFT_LEFT | 2047 | 左Shift键 | +| KEYCODE_SHIFT_RIGHT | 2048 | 右Shift键 | +| KEYCODE_TAB | 2049 | Tab键 | +| KEYCODE_SPACE | 2050 | 空格键 | +| KEYCODE_SYM | 2051 | 符号修改器按键 | +| KEYCODE_EXPLORER | 2052 | 浏览器功能键,此键用于启动浏览器应用程序。 | +| KEYCODE_ENVELOPE | 2053 | 电子邮件功能键,此键用于启动电子邮件应用程序。 | +| KEYCODE_ENTER | 2054 | 回车键 | +| KEYCODE_DEL | 2055 | 退格键 | +| KEYCODE_GRAVE | 2056 | 按键'`' | +| KEYCODE_MINUS | 2057 | 按键'-' | +| KEYCODE_EQUALS | 2058 | 按键'=' | +| KEYCODE_LEFT_BRACKET | 2059 | 按键'[' | +| KEYCODE_RIGHT_BRACKET | 2060 | 按键']' | +| KEYCODE_BACKSLASH | 2061 | 按键'\\' | +| KEYCODE_SEMICOLON | 2062 | 按键';' | +| KEYCODE_APOSTROPHE | 2063 | 按键''' (单引号) | +| KEYCODE_SLASH | 2064 | 按键'/' | +| KEYCODE_AT | 2065 | 按键'@' | +| KEYCODE_PLUS | 2066 | 按键'+' | +| KEYCODE_MENU | 2067 | 菜单键 | +| KEYCODE_PAGE_UP | 2068 | 向上翻页键 | +| KEYCODE_PAGE_DOWN | 2069 | 向下翻页键 | +| KEYCODE_ESCAPE | 2070 | ESC键 | +| KEYCODE_FORWARD_DEL | 2071 | 删除键 | +| KEYCODE_CTRL_LEFT | 2072 | 左Ctrl键 | +| KEYCODE_CTRL_RIGHT | 2073 | 右Ctrl键 | +| KEYCODE_CAPS_LOCK | 2074 | 大写锁定键 | +| KEYCODE_SCROLL_LOCK | 2075 | 滚动锁定键 | +| KEYCODE_META_LEFT | 2076 | 左元修改器键 | +| KEYCODE_META_RIGHT | 2077 | 右元修改器键 | +| KEYCODE_FUNCTION | 2078 | 功能键 | +| KEYCODE_SYSRQ | 2079 | 系统请求/打印屏幕键 | +| KEYCODE_BREAK | 2080 | Break/Pause键 | +| KEYCODE_MOVE_HOME | 2081 | 光标移动到开始键 | +| KEYCODE_MOVE_END | 2082 | 光标移动到末尾键 | +| KEYCODE_INSERT | 2083 | 插入键 | +| KEYCODE_FORWARD | 2084 | 前进键 | +| KEYCODE_MEDIA_PLAY | 2085 | 多媒体键 播放 | +| KEYCODE_MEDIA_PAUSE | 2086 | 多媒体键 暂停 | +| KEYCODE_MEDIA_CLOSE | 2087 | 多媒体键 关闭 | +| KEYCODE_MEDIA_EJECT | 2088 | 多媒体键 弹出 | +| KEYCODE_MEDIA_RECORD | 2089 | 多媒体键 录音 | +| KEYCODE_F1 | 2090 | 按键'F1' | +| KEYCODE_F2 | 2091 | 按键'F2' | +| KEYCODE_F3 | 2092 | 按键'F3' | +| KEYCODE_F4 | 2093 | 按键'F4' | +| KEYCODE_F5 | 2094 | 按键'F5' | +| KEYCODE_F6 | 2095 | 按键'F6' | +| KEYCODE_F7 | 2096 | 按键'F7' | +| KEYCODE_F8 | 2097 | 按键'F8' | +| KEYCODE_F9 | 2098 | 按键'F9' | +| KEYCODE_F10 | 2099 | 按键'F10' | +| KEYCODE_F11 | 2100 | 按键'F11' | +| KEYCODE_F12 | 2101 | 按键'F12' | +| KEYCODE_NUM_LOCK | 2102 | 小键盘锁 | +| KEYCODE_NUMPAD_0 | 2103 | 小键盘按键'0' | +| KEYCODE_NUMPAD_1 | 2104 | 小键盘按键'1' | +| KEYCODE_NUMPAD_2 | 2105 | 小键盘按键'2' | +| KEYCODE_NUMPAD_3 | 2106 | 小键盘按键'3' | +| KEYCODE_NUMPAD_4 | 2107 | 小键盘按键'4' | +| KEYCODE_NUMPAD_5 | 2108 | 小键盘按键'5' | +| KEYCODE_NUMPAD_6 | 2109 | 小键盘按键'6' | +| KEYCODE_NUMPAD_7 | 2110 | 小键盘按键'7' | +| KEYCODE_NUMPAD_8 | 2111 | 小键盘按键'8' | +| KEYCODE_NUMPAD_9 | 2112 | 小键盘按键'9' | +| KEYCODE_NUMPAD_DIVIDE | 2113 | 小键盘按键'/' | +| KEYCODE_NUMPAD_MULTIPLY | 2114 | 小键盘按键'*' | +| KEYCODE_NUMPAD_SUBTRACT | 2115 | 小键盘按键'-' | +| KEYCODE_NUMPAD_ADD | 2116 | 小键盘按键'+' | +| KEYCODE_NUMPAD_DOT | 2117 | 小键盘按键'.' | +| KEYCODE_NUMPAD_COMMA | 2118 | 小键盘按键',' | +| KEYCODE_NUMPAD_ENTER | 2119 | 小键盘按键回车 | +| KEYCODE_NUMPAD_EQUALS | 2120 | 小键盘按键'=' | +| KEYCODE_NUMPAD_LEFT_PAREN | 2121 | 小键盘按键'(' | +| KEYCODE_NUMPAD_RIGHT_PAREN | 2122 | 小键盘按键')' | +| KEYCODE_VIRTUAL_MULTITASK | 2210 | 虚拟多任务键 | +| KEYCODE_SLEEP | 2600 | 睡眠键 | +| KEYCODE_ZENKAKU_HANKAKU | 2601 | 日文全宽/半宽键 | +| KEYCODE_102ND | 2602 | 102nd按键 | +| KEYCODE_RO | 2603 | 日文Ro键 | +| KEYCODE_KATAKANA | 2604 | 日文片假名键 | +| KEYCODE_HIRAGANA | 2605 | 日文平假名键 | +| KEYCODE_HENKAN | 2606 | 日文转换键 | +| KEYCODE_KATAKANA_HIRAGANA | 2607 | 日语片假名/平假名键 | +| KEYCODE_MUHENKAN | 2608 | 日文非转换键 | +| KEYCODE_LINEFEED | 2609 | 换行键 | +| KEYCODE_MACRO | 2610 | 宏键 | +| KEYCODE_NUMPAD_PLUSMINUS | 2611 | 数字键盘上的加号/减号键 | +| KEYCODE_SCALE | 2612 | 扩展键 | +| KEYCODE_HANGUEL | 2613 | 日文韩语键 | +| KEYCODE_HANJA | 2614 | 日文汉语键 | +| KEYCODE_YEN | 2615 | 日元键 | +| KEYCODE_STOP | 2616 | 停止键 | +| KEYCODE_AGAIN | 2617 | 重复键 | +| KEYCODE_PROPS | 2618 | 道具键 | +| KEYCODE_UNDO | 2619 | 撤消键 | +| KEYCODE_COPY | 2620 | 复制键 | +| KEYCODE_OPEN | 2621 | 打开键 | +| KEYCODE_PASTE | 2622 | 粘贴键 | +| KEYCODE_FIND | 2623 | 查找键 | +| KEYCODE_CUT | 2624 | 剪切键 | +| KEYCODE_HELP | 2625 | 帮助键 | +| KEYCODE_CALC | 2626 | 计算器特殊功能键,用于启动计算器应用程序 | +| KEYCODE_FILE | 2627 | 文件按键 | +| KEYCODE_BOOKMARKS | 2628 | 书签键 | +| KEYCODE_NEXT | 2629 | 下一个按键 | +| KEYCODE_PLAYPAUSE | 2630 | 播放/暂停键 | +| KEYCODE_PREVIOUS | 2631 | 上一个按键 | +| KEYCODE_STOPCD | 2632 | CD停止键 | +| KEYCODE_CONFIG | 2634 | 配置键 | +| KEYCODE_REFRESH | 2635 | 刷新键 | +| KEYCODE_EXIT | 2636 | 退出键 | +| KEYCODE_EDIT | 2637 | 编辑键 | +| KEYCODE_SCROLLUP | 2638 | 向上滚动键 | +| KEYCODE_SCROLLDOWN | 2639 | 向下滚动键 | +| KEYCODE_NEW | 2640 | 新建键 | +| KEYCODE_REDO | 2641 | 恢复键 | +| KEYCODE_CLOSE | 2642 | 关闭键 | +| KEYCODE_PLAY | 2643 | 播放键 | +| KEYCODE_BASSBOOST | 2644 | 低音增强键 | +| KEYCODE_PRINT | 2645 | 打印键 | +| KEYCODE_CHAT | 2646 | 聊天键 | +| KEYCODE_FINANCE | 2647 | 金融键 | +| KEYCODE_CANCEL | 2648 | 取消键 | +| KEYCODE_KBDILLUM_TOGGLE | 2649 | 键盘灯光切换键 | +| KEYCODE_KBDILLUM_DOWN | 2650 | 键盘灯光调亮键 | +| KEYCODE_KBDILLUM_UP | 2651 | 键盘灯光调暗键 | +| KEYCODE_SEND | 2652 | 发送键 | +| KEYCODE_REPLY | 2653 | 答复键 | +| KEYCODE_FORWARDMAIL | 2654 | 邮件转发键 | +| KEYCODE_SAVE | 2655 | 保存键 | +| KEYCODE_DOCUMENTS | 2656 | 文件键 | +| KEYCODE_VIDEO_NEXT | 2657 | 下一个视频键 | +| KEYCODE_VIDEO_PREV | 2658 | 上一个视频键 | +| KEYCODE_BRIGHTNESS_CYCLE | 2659 | 背光渐变键 | +| KEYCODE_BRIGHTNESS_ZERO | 2660 | 亮度调节为0键 | +| KEYCODE_DISPLAY_OFF | 2661 | 显示关闭键 | +| KEYCODE_BTN_MISC | 2662 | 游戏手柄上的各种按键 | +| KEYCODE_GOTO | 2663 | 进入键 | +| KEYCODE_INFO | 2664 | 信息查看键 | +| KEYCODE_PROGRAM | 2665 | 程序键 | +| KEYCODE_PVR | 2666 | 个人录像机(PVR)键 | +| KEYCODE_SUBTITLE | 2667 | 字幕键 | +| KEYCODE_FULL_SCREEN | 2668 | 全屏键 | +| KEYCODE_KEYBOARD | 2669 | 键盘 | +| KEYCODE_ASPECT_RATIO | 2670 | 屏幕纵横比调节键 | +| KEYCODE_PC | 2671 | 端口控制键 | +| KEYCODE_TV | 2672 | TV键 | +| KEYCODE_TV2 | 2673 | TV键2 | +| KEYCODE_VCR | 2674 | 录像机开启键 | +| KEYCODE_VCR2 | 2675 | 录像机开启键2 | +| KEYCODE_SAT | 2676 | SIM卡应用工具包(SAT)键 | +| KEYCODE_CD | 2677 | CD键 | +| KEYCODE_TAPE | 2678 | 磁带键 | +| KEYCODE_TUNER | 2679 | 调谐器键 | +| KEYCODE_PLAYER | 2680 | 播放器键 | +| KEYCODE_DVD | 2681 | DVD键 | +| KEYCODE_AUDIO | 2682 | 音频键 | +| KEYCODE_VIDEO | 2683 | 视频键 | +| KEYCODE_MEMO | 2684 | 备忘录键 | +| KEYCODE_CALENDAR | 2685 | 日历键 | +| KEYCODE_RED | 2686 | 红色指示器 | +| KEYCODE_GREEN | 2687 | 绿色指示器 | +| KEYCODE_YELLOW | 2688 | 黄色指示器 | +| KEYCODE_BLUE | 2689 | 蓝色指示器 | +| KEYCODE_CHANNELUP | 2690 | 频道向上键 | +| KEYCODE_CHANNELDOWN | 2691 | 频道向下键 | +| KEYCODE_LAST | 2692 | 末尾键 | +| KEYCODE_RESTART | 2693 | 重启键 | +| KEYCODE_SLOW | 2694 | 慢速键 | +| KEYCODE_SHUFFLE | 2695 | 随机播放键 | +| KEYCODE_VIDEOPHONE | 2696 | 可视电话键 | +| KEYCODE_GAMES | 2697 | 游戏键 | +| KEYCODE_ZOOMIN | 2698 | 放大键 | +| KEYCODE_ZOOMOUT | 2699 | 缩小键 | +| KEYCODE_ZOOMRESET | 2700 | 缩放重置键 | +| KEYCODE_WORDPROCESSOR | 2701 | 文字处理键 | +| KEYCODE_EDITOR | 2702 | 编辑器键 | +| KEYCODE_SPREADSHEET | 2703 | 电子表格键 | +| KEYCODE_GRAPHICSEDITOR | 2704 | 图形编辑器键 | +| KEYCODE_PRESENTATION | 2705 | 演示文稿键 | +| KEYCODE_DATABASE | 2706 | 数据库键标 | +| KEYCODE_NEWS | 2707 | 新闻键 | +| KEYCODE_VOICEMAIL | 2708 | 语音信箱 | +| KEYCODE_ADDRESSBOOK | 2709 | 通讯簿 | +| KEYCODE_MESSENGER | 2710 | 通信键 | +| KEYCODE_BRIGHTNESS_TOGGLE | 2711 | 亮度切换键 | +| KEYCODE_SPELLCHECK | 2712 | AL拼写检查 | +| KEYCODE_COFFEE | 2713 | 终端锁/屏幕保护程序 | +| KEYCODE_MEDIA_REPEAT | 2714 | 媒体循环键 | +| KEYCODE_IMAGES | 2715 | 图像键 | +| KEYCODE_BUTTONCONFIG | 2716 | 按键配置键 | +| KEYCODE_TASKMANAGER | 2717 | 任务管理器 | +| KEYCODE_JOURNAL | 2718 | 日志按键 | +| KEYCODE_CONTROLPANEL | 2719 | 控制面板键 | +| KEYCODE_APPSELECT | 2720 | 应用程序选择键 | +| KEYCODE_SCREENSAVER | 2721 | 屏幕保护程序键 | +| KEYCODE_ASSISTANT | 2722 | 辅助键 | +| KEYCODE_KBD_LAYOUT_NEXT | 2723 | 下一个键盘布局键 | +| KEYCODE_BRIGHTNESS_MIN | 2724 | 最小亮度键 | +| KEYCODE_BRIGHTNESS_MAX | 2725 | 最大亮度键 | +| KEYCODE_KBDINPUTASSIST_PREV | 2726 | 键盘输入Assist_Previous | +| KEYCODE_KBDINPUTASSIST_NEXT | 2727 | 键盘输入Assist_Next | +| KEYCODE_KBDINPUTASSIST_PREVGROUP | 2728 | 键盘输入Assist_Previous | +| KEYCODE_KBDINPUTASSIST_NEXTGROUP | 2729 | 键盘输入Assist_Next | +| KEYCODE_KBDINPUTASSIST_ACCEPT | 2730 | 键盘输入Assist_Accept | +| KEYCODE_KBDINPUTASSIST_CANCEL | 2731 | 键盘输入Assist_Cancel | +| KEYCODE_FRONT | 2800 | 挡风玻璃除雾器开关 | +| KEYCODE_SETUP | 2801 | 设置键 | +| KEYCODE_WAKEUP | 2802 | 唤醒键 | +| KEYCODE_SENDFILE | 2803 | 发送文件按键 | +| KEYCODE_DELETEFILE | 2804 | 删除文件按键 | +| KEYCODE_XFER | 2805 | 文件传输(XFER)按键 | +| KEYCODE_PROG1 | 2806 | 程序键1 | +| KEYCODE_PROG2 | 2807 | 程序键2 | +| KEYCODE_MSDOS | 2808 | MS-DOS键(微软磁盘操作系统 | +| KEYCODE_SCREENLOCK | 2809 | 屏幕锁定键 | +| KEYCODE_DIRECTION_ROTATE_DISPLAY | 2810 | 方向旋转显示键 | +| KEYCODE_CYCLEWINDOWS | 2811 | Windows循环键 | +| KEYCODE_COMPUTER | 2812 | 按键 | +| KEYCODE_EJECTCLOSECD | 2813 | 弹出CD键 | +| KEYCODE_ISO | 2814 | ISO键 | +| KEYCODE_MOVE | 2815 | 移动键 | +| KEYCODE_F13 | 2816 | 按键'F13' | +| KEYCODE_F14 | 2817 | 按键'F14' | +| KEYCODE_F15 | 2818 | 按键'F15' | +| KEYCODE_F16 | 2819 | 按键'F16' | +| KEYCODE_F17 | 2820 | 按键'F17' | +| KEYCODE_F18 | 2821 | 按键'F18' | +| KEYCODE_F19 | 2822 | 按键'F19' | +| KEYCODE_F20 | 2823 | 按键'F20' | +| KEYCODE_F21 | 2824 | 按键'F21' | +| KEYCODE_F22 | 2825 | 按键'F22' | +| KEYCODE_F23 | 2826 | 按键'F23' | +| KEYCODE_F24 | 2827 | 按键'F24' | +| KEYCODE_PROG3 | 2828 | 程序键3 | +| KEYCODE_PROG4 | 2829 | 程序键4 | +| KEYCODE_DASHBOARD | 2830 | 仪表板 | +| KEYCODE_SUSPEND | 2831 | 挂起键 | +| KEYCODE_HP | 2832 | 高阶路径键 | +| KEYCODE_SOUND | 2833 | 音量键 | +| KEYCODE_QUESTION | 2834 | 疑问按键 | +| KEYCODE_CONNECT | 2836 | 连接键 | +| KEYCODE_SPORT | 2837 | 运动按键 | +| KEYCODE_SHOP | 2838 | 商城键 | +| KEYCODE_ALTERASE | 2839 | 交替键 | +| KEYCODE_SWITCHVIDEOMODE | 2841 | 在可用视频之间循环输出(监视器/LCD/TV输出/等) | +| KEYCODE_BATTERY | 2842 | 电池按键 | +| KEYCODE_BLUETOOTH | 2843 | 蓝牙按键 | +| KEYCODE_WLAN | 2844 | 无线局域网 | +| KEYCODE_UWB | 2845 | 超宽带(UWB) | +| KEYCODE_WWAN_WIMAX | 2846 | WWAN WiMAX按键 | +| KEYCODE_RFKILL | 2847 | 控制所有收音机的键 | +| KEYCODE_CHANNEL | 3001 | 向上频道键 | +| KEYCODE_BTN_0 | 3100 | 按键0 | +| KEYCODE_BTN_1 | 3101 | 按键1 | +| KEYCODE_BTN_2 | 3102 | 按键2 | +| KEYCODE_BTN_3 | 3103 | 按键3 | +| KEYCODE_BTN_4 | 3104 | 按键4 | +| KEYCODE_BTN_5 | 3105 | 按键5 | +| KEYCODE_BTN_6 | 3106 | 按键6 | +| KEYCODE_BTN_7 | 3107 | 按键7 | +| KEYCODE_BTN_8 | 3108 | 按键8 | +| KEYCODE_BTN_9 | 3109 | 按键9 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-keyevent.md b/zh-cn/application-dev/reference/apis/js-apis-keyevent.md index b1bf555396839b7ab0570ab059cf1b255be796f2..84d3df2187cd6cad52fb94b118bb07b5c5689c8e 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-keyevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-keyevent.md @@ -16,11 +16,11 @@ import {Action, Key, KeyEvent} from '@ohos.multimodalInput.keyEvent'; **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------ | -------- | ---- | ---- | -------- | -| CANCEL | number | 是 | 否 | 按键取消 | -| DOWN | number | 是 | 否 | 按键按下 | -| UP | number | 是 | 否 | 按键抬起 | +| 名称 | 值 | 说明 | +| ------ | ------- | -------- | +| CANCEL | 0 | 按键取消 | +| DOWN | 1 | 按键按下 | +| UP | 2 | 按键抬起 | ## Key diff --git a/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md index f0bdc396400ea3c39d2dc4d543a5695df077fd36..8026d31849d082111d171b3134522528263eaef3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md @@ -27,7 +27,7 @@ getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallba **参数:** -| 参数名 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | -------------- | | bundleName | string | 是 | 应用程序包名称。 | | userId | number | 是 | 被查询的用户id。| @@ -78,7 +78,7 @@ getLauncherAbilityInfo(bundleName: string, userId: number) : Promise { console.log("value:" + value, key); }); -try { - lightWeightMap.forEach.bind({}, (value, key) => { - console.log("value:" + value, key); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -906,11 +787,6 @@ while(temp != undefined) { console.log("value:" + temp[1]); temp = iter.next().value; } -try { - lightWeightMap.entries.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### toString @@ -942,11 +818,6 @@ let lightWeightMap = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.toString(); -try { - lightWeightMap.toString.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### [Symbol.iterator] @@ -992,9 +863,4 @@ while(temp != undefined) { console.log("value:" + temp[1]); temp = iter.next().value; } -try { - lightWeightMap[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md index 91a8e23a1080e8919bf714bbc5c79ad663dd9231..248b209c9cc8d4bdd6733a235497f882863a55de 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md @@ -22,8 +22,6 @@ LightWeightSet和[HashSet](js-apis-hashset.md)都是用来存储键值的集合 import LightWeightSet from '@ohos.util.LightWeightSet'; ``` - - ## LightWeightSet ### 属性 @@ -55,11 +53,6 @@ LightWeightSet的构造函数。 ```ts let lightWeightSet = new LightWeightSet(); -try { - let lightWeightSet2 = LightWeightSet(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -90,11 +83,6 @@ isEmpty(): boolean ```ts const lightWeightSet = new LightWeightSet(); let result = lightWeightSet.isEmpty(); -try { - lightWeightSet.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### add @@ -130,11 +118,6 @@ add(obj: T): boolean ```ts let lightWeightSet = new LightWeightSet(); let result = lightWeightSet.add("squirrel"); -try { - lightWeightSet.add.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -169,11 +152,6 @@ lightWeightSet.add("sparrow"); let set = new LightWeightSet(); set.add("gull"); let result = lightWeightSet.addAll(set); -try { - lightWeightSet.addAll.bind({}, set)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -214,11 +192,6 @@ lightWeightSet.add("sparrow"); let set = new LightWeightSet(); set.add("sparrow"); let result = lightWeightSet.hasAll(set); -try { - lightWeightSet.hasAll.bind({}, set)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -257,11 +230,6 @@ let lightWeightSet = new LightWeightSet(); let result = lightWeightSet.has(123); lightWeightSet.add(123); result = lightWeightSet.has(123); -try { - lightWeightSet.has.bind({}, 123)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -301,11 +269,6 @@ lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let obj = ["squirrel", "sparrow"]; let result = lightWeightSet.equal(obj); -try { - lightWeightSet.equal.bind({}, obj)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -337,16 +300,6 @@ increaseCapacityTo(minimumCapacity: number): void ```ts let lightWeightSet = new LightWeightSet(); lightWeightSet.increaseCapacityTo(10); -try { - lightWeightSet.increaseCapacityTo.bind({}, 10)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - lightWeightSet.increaseCapacityTo(2); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -385,11 +338,6 @@ let lightWeightSet = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.getIndexOf("sparrow"); -try { - lightWeightSet.getIndexOf.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -428,11 +376,6 @@ let lightWeightSet = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.remove("sparrow"); -try { - lightWeightSet.remove.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -471,11 +414,6 @@ let lightWeightSet = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.removeAt(1); -try { - lightWeightSet.removeAt.bind({}, 1)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -514,11 +452,6 @@ let lightWeightSet = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.getValueAt(1); -try { - lightWeightSet.getValueAt.bind({}, 1)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -545,11 +478,6 @@ let lightWeightSet = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); lightWeightSet.clear(); -try { - lightWeightSet.clear.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -582,11 +510,6 @@ let lightWeightSet = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.toString(); -try { - lightWeightSet.toString.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -619,11 +542,6 @@ let lightWeightSet = new LightWeightSet(); lightWeightSet.add("squirrel"); lightWeightSet.add("sparrow"); let result = lightWeightSet.toArray(); -try { - lightWeightSet.toArray.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -661,11 +579,6 @@ while(index < lightWeightSet.length) { console.log(JSON.stringify(iter.next().value)); index++; } -try { - lightWeightSet.values.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -708,13 +621,6 @@ lightWeightSet.add("gull"); lightWeightSet.forEach((value, key) => { console.log("value:" + value, key); }); -try { - lightWeightSet.forEach.bind({}, (value, key) => { - console.log("value:" + value, key); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -752,11 +658,6 @@ while(index < lightWeightSet.length) { console.log(JSON.stringify(iter.next().value)); index++; } -try { - lightWeightSet.entries.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -801,9 +702,4 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - lightWeightSet[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md index 90d5256fd06058cd46e7dc8bf8f425b35527c867..ae0d094d5c8fe3de792ada84c3b12bfc832e9c74 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md @@ -20,9 +20,6 @@ LinkedList和[ArrayList](js-apis-arraylist.md)相比,存取数据的效率不 import LinkedList from '@ohos.util.LinkedList'; ``` - - - ## LinkedList ### 属性 @@ -55,11 +52,6 @@ LinkedList的构造函数。 ```ts let linkedList = new LinkedList(); -try { - let linkedList2 = LinkedList(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -102,11 +94,6 @@ let result2 = linkedList.add(b); let c = {name : "Dylon", age : "13"}; let result3 = linkedList.add(c); let result4 = linkedList.add(false); -try { - linkedList.add.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### addFirst @@ -142,11 +129,6 @@ linkedList.addFirst(b); let c = {name : "Dylon", age : "13"}; linkedList.addFirst(c); linkedList.addFirst(false); -try { - linkedList.addFirst.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### insert @@ -180,16 +162,6 @@ let linkedList = new LinkedList(); linkedList.insert(0, "A"); linkedList.insert(1, 0); linkedList.insert(2, true); -try { - linkedList.insert.bind({}, 3, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - linkedList.insert(6, "b"); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### has @@ -227,11 +199,6 @@ let linkedList = new LinkedList(); let result1 = linkedList.has("squirrel"); linkedList.add("squirrel"); let result = linkedList.has("squirrel"); -try { - linkedList.has.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### get @@ -274,11 +241,6 @@ linkedList.add(1); linkedList.add(2); linkedList.add(4); let result = linkedList.get(2); -try { - linkedList.get.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getLastIndexOf @@ -321,11 +283,6 @@ linkedList.add(1); linkedList.add(2); linkedList.add(4); let result = linkedList.getLastIndexOf(2); -try { - linkedList.getLastIndexOf.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getIndexOf @@ -368,11 +325,6 @@ linkedList.add(1); linkedList.add(2); linkedList.add(4); let result = linkedList.getIndexOf(2); -try { - linkedList.getIndexOf.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### removeByIndex @@ -414,16 +366,6 @@ linkedList.add(5); linkedList.add(2); linkedList.add(4); let result = linkedList.removeByIndex(2); -try { - linkedList.removeByIndex.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - linkedList.removeByIndex(8); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### removeFirst @@ -453,22 +395,12 @@ removeFirst(): T ```ts let linkedList = new LinkedList(); -try { - linkedList.removeFirst(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(2); linkedList.add(4); let result = linkedList.removeFirst(); -try { - linkedList.removeFirst.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### removeLast @@ -498,22 +430,12 @@ removeLast(): T ```ts let linkedList = new LinkedList(); -try { - linkedList.removeLast(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(2); linkedList.add(4); let result = linkedList.removeLast(); -try { - linkedList.removeLast.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### remove @@ -553,11 +475,6 @@ linkedList.add(4); linkedList.add(5); linkedList.add(4); let result = linkedList.remove(2); -try { - linkedList.remove.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### removeFirstFound @@ -593,21 +510,11 @@ removeFirstFound(element: T): boolean ```ts let linkedList = new LinkedList(); -try { - linkedList.removeFirstFound(4); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); let result = linkedList.removeFirstFound(4); -try { - linkedList.removeFirstFound.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### removeLastFound @@ -643,21 +550,11 @@ removeLastFound(element: T): boolean ```ts let linkedList = new LinkedList(); -try { - linkedList.removeLastFound(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); let result = linkedList.removeLastFound(4); -try { - linkedList.removeLastFound.bind({}, 4)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### clone @@ -691,11 +588,6 @@ linkedList.add(4); linkedList.add(5); linkedList.add(4); let result = linkedList.clone(); -try { - linkedList.clone.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### forEach @@ -741,13 +633,6 @@ linkedList.add(4); linkedList.forEach((value, index) => { console.log("value:" + value, index); }); -try { - linkedList.forEach.bind({}, (value, index) => { - console.log("value:" + value, index); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### clear @@ -775,11 +660,6 @@ linkedList.add(4); linkedList.add(5); linkedList.add(4); linkedList.clear(); -try { - linkedList.clear.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### set @@ -821,16 +701,6 @@ linkedList.add(4); linkedList.add(5); linkedList.add(4); let result = linkedList.set(2, "b"); -try { - linkedList.set.bind({}, 2, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - linkedList.set(8, "b"); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### convertToArray @@ -863,11 +733,6 @@ linkedList.add(4); linkedList.add(5); linkedList.add(4); let result = linkedList.convertToArray(); -try { - linkedList.convertToArray.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getFirst @@ -901,11 +766,6 @@ linkedList.add(4); linkedList.add(5); linkedList.add(4); let result = linkedList.getFirst(); -try { - linkedList.getFirst.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getLast @@ -939,11 +799,6 @@ linkedList.add(4); linkedList.add(5); linkedList.add(4); linkedList.getLast(); -try { - linkedList.getLast.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### [Symbol.iterator] @@ -989,9 +844,4 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - linkedList[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-list.md b/zh-cn/application-dev/reference/apis/js-apis-list.md index 0328e55bade32c76e74a622a92ade601a5262e62..ecf5c521e3d541741d73f19bded9837de19afea5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-list.md +++ b/zh-cn/application-dev/reference/apis/js-apis-list.md @@ -50,11 +50,6 @@ List的构造函数。 ```ts let list = new List(); -try { - let list2 = List(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -97,11 +92,6 @@ let result3 = list.add(b); let c = {name : "Dylon", age : "13"}; let result4 = list.add(c); let result5 = list.add(false); -try { - list.add.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### insert @@ -135,16 +125,6 @@ let list = new List(); list.insert("A", 0); list.insert(0, 1); list.insert(true, 2); -try { - list.insert.bind({}, "b", 3)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - list.insert("b", 6); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### has @@ -182,11 +162,6 @@ let list = new List(); let result = list.has("squirrel"); list.add("squirrel"); let result1 = list.has("squirrel"); -try { - list.has.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### get @@ -229,11 +204,6 @@ list.add(1); list.add(2); list.add(4); let result = list.get(2); -try { - list.get.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getLastIndexOf @@ -276,11 +246,6 @@ list.add(1); list.add(2); list.add(4); let result = list.getLastIndexOf(2); -try { - list.getLastIndexOf.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getIndexOf @@ -324,11 +289,6 @@ list.add(2); list.add(4); list.getIndexOf(2); let result = list.getIndexOf(2); -try { - list.getIndexOf.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### equal @@ -374,11 +334,6 @@ obj1.add(5); list.equal(obj1); let obj2 = {name : "Dylon", age : "13"}; let result = list.equal(obj2); -try { - list.equal.bind({}, obj2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### removeByIndex @@ -420,16 +375,6 @@ list.add(5); list.add(2); list.add(4); let result = list.removeByIndex(2); -try { - list.removeByIndex.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - list.removeByIndex(8); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### remove @@ -469,11 +414,6 @@ list.add(4); list.add(5); list.add(4); let result = list.remove(2); -try { - list.remove.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### replaceAllElements @@ -522,13 +462,6 @@ list.replaceAllElements((value: number, index: number) => { list.replaceAllElements((value: number, index: number) => { return value = value - 2; }); -try { - list.replaceAllElements.bind({}, (value: number, index: number) => { - return value = 2 * value; - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### forEach @@ -574,14 +507,6 @@ list.add(4); list.forEach((value, index) => { console.log("value: " + value, index); }); -try { - list.forEach.bind({}, (value, index) => { - console.log("value: " + value, index); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} - ``` ### sort @@ -623,11 +548,6 @@ list.add(5); list.add(4); list.sort((a: number, b: number) => a - b); list.sort((a: number, b: number) => b - a); -try { - list.sort.bind({}, (a: number, b: number) => b - a)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getSubList @@ -671,16 +591,6 @@ list.add(4); let result = list.getSubList(2, 4); let result1 = list.getSubList(4, 3); let result2 = list.getSubList(2, 6); -try { - list.getSubList.bind({}, 2, 4)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - list.getSubList(2, 10); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### clear @@ -708,11 +618,6 @@ list.add(4); list.add(5); list.add(4); list.clear(); -try { - list.clear.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### set @@ -754,16 +659,6 @@ list.add(4); list.add(5); list.add(4); list.set(2, "b"); -try { - list.set.bind({}, 3, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - list.set(8, "b"); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### convertToArray @@ -797,11 +692,6 @@ list.add(4); list.add(5); list.add(4); let result = list.convertToArray(); -try { - list.convertToArray.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### isEmpty @@ -835,11 +725,6 @@ list.add(4); list.add(5); list.add(4); let result = list.isEmpty(); -try { - list.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getFirst @@ -873,11 +758,6 @@ list.add(4); list.add(5); list.add(4); let result = list.getFirst(); -try { - list.getFirst.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getLast @@ -911,11 +791,6 @@ list.add(4); list.add(5); list.add(4); let result = list.getLast(); -try { - list.getLast.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### [Symbol.iterator] @@ -961,9 +836,4 @@ while(temp != undefined) { console.log("value: " + temp); temp = iter.next().value; } -try { - list[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index 94e38c88cfe4f0b51cc613bea4293c5d85829b67..816a9f9d80a8d811fbe66db76b64d10ad1f85415 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -338,7 +338,7 @@ audioPlayer.stop(); reset(): void -切换播放音频资源。 +重置播放音频资源。 **系统能力:** SystemCapability.Multimedia.Media.AudioPlayer @@ -957,7 +957,7 @@ videoPlayer.stop().then(() => { reset(callback: AsyncCallback\): void -通过回调方式切换播放视频。 +通过回调方式重置播放视频。 **系统能力:** SystemCapability.Multimedia.Media.VideoPlayer @@ -983,7 +983,7 @@ videoPlayer.reset((err) => { reset(): Promise\ -通过Promise方式切换播放视频。 +通过Promise方式重置播放视频。 **系统能力:** SystemCapability.Multimedia.Media.VideoPlayer diff --git a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md index e53e77bac534a379890688064173c26def31be2e..cf68988e0c1d19145740c5daf091b4c33c16cfe7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md +++ b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @@ -192,7 +192,7 @@ media.getFileAssets(imagesFetchOp).then(function(fetchFileResult) { ### on8+ -on(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange', callback: Callback<void>): void +on(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange', callback: Callback<void>): void 打开媒体库变更通知,使用callback方式返回异步结果。 @@ -214,7 +214,7 @@ media.on('imageChange', () => { ``` ### off8+ -off(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange', callback?: Callback<void>): void +off(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange', callback?: Callback<void>): void 关闭媒体库变更通知,使用callback方式返回异步结果。 @@ -2471,25 +2471,25 @@ async function example() { | 名称 | 值 | 说明 | | ------------- | ------------------- | ---------------------------------------------------------- | -| ID | file_id | 文件编号 | -| RELATIVE_PATH | relative_path | 相对公共目录路径 | -| DISPLAY_NAME | display_name | 显示名字 | -| PARENT | parent | 父目录id | -| MIME_TYPE | mime_type | 文件扩展属性 | -| MEDIA_TYPE | media_type | 媒体类型 | -| SIZE | size | 文件大小(单位:字节) | -| DATE_ADDED | date_added | 添加日期(添加文件时间到1970年1月1日的秒数值) | -| DATE_MODIFIED | date_modified | 修改日期(修改文件时间到1970年1月1日的秒数值) | -| DATE_TAKEN | date_taken | 拍摄日期(文件拍照时间到1970年1月1日的秒数值) | -| TITLE | title | 文件标题 | -| ARTIST | artist | 作者 | -| AUDIOALBUM | audio_album | 专辑 | -| DURATION | duration | 持续时间(单位:毫秒) | -| WIDTH | width | 图片宽度(单位:像素) | -| HEIGHT | height | 图片高度(单位:像素) | -| ORIENTATION | orientation | 图片显示方向,即顺时针旋转角度,如0,90,180。(单位:度) | -| ALBUM_ID | bucket_id | 文件所归属的相册编号 | -| ALBUM_NAME | bucket_display_name | 文件所归属相册名称 | +| ID | "file_id" | 文件编号 | +| RELATIVE_PATH | "relative_path" | 相对公共目录路径 | +| DISPLAY_NAME | "display_name" | 显示名字 | +| PARENT | "parent" | 父目录id | +| MIME_TYPE | "mime_type" | 文件扩展属性 | +| MEDIA_TYPE | "media_type" | 媒体类型 | +| SIZE | "size" | 文件大小(单位:字节) | +| DATE_ADDED | "date_added" | 添加日期(添加文件时间到1970年1月1日的秒数值) | +| DATE_MODIFIED | "date_modified" | 修改日期(修改文件时间到1970年1月1日的秒数值) | +| DATE_TAKEN | "date_taken" | 拍摄日期(文件拍照时间到1970年1月1日的秒数值) | +| TITLE | "title" | 文件标题 | +| ARTIST | "artist" | 作者 | +| AUDIOALBUM | "audio_album" | 专辑 | +| DURATION | "duration" | 持续时间(单位:毫秒) | +| WIDTH | "width" | 图片宽度(单位:像素) | +| HEIGHT | "height" | 图片高度(单位:像素) | +| ORIENTATION | "orientation" | 图片显示方向,即顺时针旋转角度,如0,90,180。(单位:度) | +| ALBUM_ID | "bucket_id" | 文件所归属的相册编号 | +| ALBUM_NAME | "bucket_display_name" | 文件所归属相册名称 | ## DirectoryType8+ @@ -2575,7 +2575,7 @@ async function example() { | 名称 | 类型 | 可读 | 可写 | 说明 | | ----- | ------ | ---- | ---- | -------------------- | -| type | string | 是 | 是 | 媒体类型,包括:image, video, media,当前仅支持media类型 | +| type | 'image' | 'video' | 'media' | 是 | 是 | 媒体类型,包括:image, video, media,当前仅支持media类型 | | count | number | 是 | 是 | 媒体选择,count = 1表示单选,count大于1表示多选。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md b/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md index 55271b859b96339c341e577a47421b94b71ec9f3..a177974721b93ab4059a671bdeebd63c1be9073a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md @@ -14,11 +14,6 @@ import mediaquery from '@ohos.mediaquery' ``` -## 权限 - -无 - - ## mediaquery.matchMediaSync matchMediaSync(condition: string): MediaQueryListener @@ -28,19 +23,22 @@ matchMediaSync(condition: string): MediaQueryListener **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ---------------------------------------- | | condition | string | 是 | 媒体事件的匹配条件,具体可参考[媒体查询语法规则](../../ui/ui-ts-layout-mediaquery.md#语法规则)。 | **返回值:** + | 类型 | 说明 | | ------------------ | ---------------------- | | MediaQueryListener | 媒体事件监听句柄,用于注册和去注册监听回调。 | **示例:** - ```js + +```js let listener = mediaquery.matchMediaSync('(orientation: landscape)'); //监听横屏事件 - ``` +``` ## MediaQueryListener @@ -66,12 +64,14 @@ on(type: 'change', callback: Callback<MediaQueryResult>): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------- | ---- | ---------------- | | type | string | 是 | 必须填写字符串'change'。 | | callback | Callback<MediaQueryResult> | 是 | 向媒体查询注册的回调 | **示例:** + 详见[off示例](#off)。 @@ -84,12 +84,14 @@ off(type: 'change', callback?: Callback<MediaQueryResult>): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------- | ---- | ----------------------------- | | type | boolean | 是 | 必须填写字符串'change'。 | | callback | Callback<MediaQueryResult> | 否 | 需要去注册的回调,如果参数缺省则去注册该句柄下所有的回调。 | **示例:** + ```js import mediaquery from '@ohos.mediaquery' diff --git a/zh-cn/application-dev/reference/apis/js-apis-missionManager.md b/zh-cn/application-dev/reference/apis/js-apis-missionManager.md index 59f6aba82dd3d32187e44a6b1c7010d7791c9140..b1c070ac602d9771dc977f900059a562111d9ad7 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-missionManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-missionManager.md @@ -49,7 +49,8 @@ registerMissionListener(listener: MissionListener): number; onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")}, onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")}, onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")}, - onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")} + onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}, + onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")} }; console.log("registerMissionListener") var listenerid = missionManager.registerMissionListener(listener); @@ -84,7 +85,8 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback<void> onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")}, onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")}, onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")}, - onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")} + onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}, + onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")} }; console.log("registerMissionListener") var listenerid = missionManager.registerMissionListener(listener); @@ -128,7 +130,8 @@ unregisterMissionListener(listenerId: number): Promise<void>; onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")}, onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")}, onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")}, - onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")} + onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}, + onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")} }; console.log("registerMissionListener") var listenerid = missionManager.registerMissionListener(listener); diff --git a/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md b/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md index 9df3148c907354854aed3c1b606b9d24b18441a0..9463c4c7c48a5dcc99ea78b7411510fe9a62f056 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md @@ -15,41 +15,41 @@ import {Action,Button,Axis,AxisValue,MouseEvent} from '@ohos.multimodalInput.mou **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----------- | -------- | ---- | ---- | -------------------- | -| CANCEL | number | 是 | 否 | 取消 | -| MOVE | number | 是 | 否 | 鼠标移动 | -| BUTTON_DOWN | number | 是 | 否 | 鼠标按钮按下 | -| BUTTON_UP | number | 是 | 否 | 鼠标按钮抬起 | -| AXIS_BEGIN | number | 是 | 否 | 鼠标轴事件开始 | -| AXIS_UPDATE | number | 是 | 否 | 鼠标轴事件更新 | -| AXIS_END | number | 是 | 否 | 鼠标轴事件结束 | +| 名称 | 值 | 说明 | +| ----------- | -------- | -------------------- | +| CANCEL | 0 | 取消 | +| MOVE | 1 | 鼠标移动 | +| BUTTON_DOWN | 2 | 鼠标按钮按下 | +| BUTTON_UP | 3 | 鼠标按钮抬起 | +| AXIS_BEGIN | 4 | 鼠标轴事件开始 | +| AXIS_UPDATE | 5 | 鼠标轴事件更新 | +| AXIS_END | 6 | 鼠标轴事件结束 | ## Button **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------- | ------ | ---- | ---- | ----- | -| LEFT | number | 是 | 否 | 鼠标左键 | -| MIDDLE | number | 是 | 否 | 鼠标中键 | -| RIGHT | number | 是 | 否 | 鼠标右键 | -| SIDE | number | 是 | 否 | 鼠标侧边键 | -| EXTRA | number | 是 | 否 | 鼠标扩展键 | -| FORWARD | number | 是 | 否 | 鼠标前进键 | -| BACK | number | 是 | 否 | 鼠标后退键 | -| TASK | number | 是 | 否 | 鼠标任务键 | +| 名称 | 值 | 说明 | +| ------- | ------| ----- | +| LEFT | 0 | 鼠标左键 | +| MIDDLE | 1 | 鼠标中键 | +| RIGHT | 2 | 鼠标右键 | +| SIDE | 3 | 鼠标侧边键 | +| EXTRA | 4 | 鼠标扩展键 | +| FORWARD | 5 | 鼠标前进键 | +| BACK | 6 | 鼠标后退键 | +| TASK | 7 | 鼠标任务键 | ## Axis **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----------------- | ------ | ---- | ---- | ----- | -| SCROLL_VERTICAL | number | 是 | 否 | 垂直滚动轴 | -| SCROLL_HORIZONTAL | number | 是 | 否 | 水平滚动轴 | -| PINCH | number | 是 | 否 | 捏合轴 | +| 名称 | 值 | 说明 | +| ----------------- | ------- | ----- | +| SCROLL_VERTICAL | 0 | 垂直滚动轴 | +| SCROLL_HORIZONTAL | 1 | 水平滚动轴 | +| PINCH | 2 | 捏合轴 | ## AxisValue diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfcController.md b/zh-cn/application-dev/reference/apis/js-apis-nfcController.md index 0217b818620d5295e3aa5c47e95a3e02d105013a..dd7b4d23c0cce73e1191bb8c0817328d711932e9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcController.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcController.md @@ -5,10 +5,9 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - ## **导入模块** -``` +```js import controller from '@ohos.nfc.controller'; ``` @@ -18,7 +17,7 @@ import controller from '@ohos.nfc.controller'; **系统能力**:SystemCapability.Communication.NFC.Core -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | -------- | -------- | | STATE_OFF | 1 | NFC已关闭状态。 | | STATE_TURNING_ON | 2 | NFC正在打开状态。 | @@ -110,12 +109,10 @@ on(type: "nfcStateChange", callback: Callback<[NfcState](#nfcstate)>): voi **参数** - | **参数名** | **类型** | **必填** | **说明** | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 固定填"nfcStateChange"字符串。 | - | callback | Callback<[NfcState](#nfcstate)> | 是 | NFC状态改变通知的回调函数。 | - - +| **参数名** | **类型** | **必填** | **说明** | +| -------- | -------- | -------- | -------- | +| type | string | 是 | 固定填"nfcStateChange"字符串。 | +| callback | Callback<[NfcState](#nfcstate)> | 是 | NFC状态改变通知的回调函数。 | ## controller.off('nfcStateChange') @@ -126,41 +123,38 @@ off(type: "nfcStateChange", callback?: Callback<[NfcState](#nfcstate)>): v **系统能力**:SystemCapability.Communication.NFC.Core **参数** - - | **参数名** | **类型** | **必填** | **说明** | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 固定填"nfcStateChange"字符串。 | + +| **参数名** | **类型** | **必填** | **说明** | +| -------- | -------- | -------- | -------- | +| type | string | 是 | 固定填"nfcStateChange"字符串。 | | callback | Callback<[NfcState](#nfcstate)> | 否 | NFC状态改变回调函数,可以空缺不填。 | **示例** - ```js - import controller from '@ohos.nfc.controller'; - - // callback key definition - var NFC_STATE_CALLBACK_KEY = "nfcStateChange"; - - // register callback to receive the nfc state changed notification - controller.on(NFC_STATE_CALLBACK_KEY, (err, nfcState)=> { - if (err) { - console.log("controller on callback err: " + err); - } else { - console.log("controller on callback nfcState: " + nfcState); - } - }); - - // open nfc, require permission: ohos.permission.MANAGE_SECURE_SETTINGS - if (!controller.isNfcOpen()) { - var ret = controller.openNfc(); - console.log("controller openNfc ret: " + ret); - } +```js +import controller from '@ohos.nfc.controller'; - // close nfc, require permission: ohos.permission.MANAGE_SECURE_SETTINGS - if (controller.isNfcOpen()) { - var ret = controller.closeNfc(); - console.log("controller closeNfc ret: " + ret); +// register callback to receive the nfc state changed notification +controller.on("nfcStateChange", (err, nfcState)=> { + if (err) { + console.log("controller on callback err: " + err); + } else { + console.log("controller on callback nfcState: " + nfcState); } - - // unregister callback - controller.off(NFC_STATE_CALLBACK_KEY); - ``` +}); + +// open nfc, require permission: ohos.permission.MANAGE_SECURE_SETTINGS +if (!controller.isNfcOpen()) { + var ret = controller.openNfc(); + console.log("controller openNfc ret: " + ret); +} + +// close nfc, require permission: ohos.permission.MANAGE_SECURE_SETTINGS +if (controller.isNfcOpen()) { + var ret = controller.closeNfc(); + console.log("controller closeNfc ret: " + ret); +} + +// unregister callback +controller.off("nfcStateChange"); +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md index e2aa810f1382baeea9df6845f028ef2cbec3d9e2..2448a3008a82d215551407dbf0763695ffe9b157 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @@ -59,6 +59,7 @@ import tag from '@ohos.nfc.tag'; ``` ## **tag.TagInfo** + 在对相关Tag类型卡片进行读写之前,必须先获取TagInfo相关属性值,以确认设备读取到的Tag卡片支持哪些技术类型。这样Tag应用程序才能调用正确的接口和所读取到的Tag卡片进行通信。 ```js import tag from '@ohos.nfc.tag'; @@ -69,7 +70,7 @@ onCreate(want, launchParam) { // want is initialized by nfc service, contains tag info for this found tag var tagInfo; try { - tag.getTagInfo(want); + tagInfo = tag.getTagInfo(want); } catch (error) { console.log("tag.getTagInfo catched error: " + error); } @@ -191,16 +192,19 @@ getIsoDep(tagInfo: [TagInfo](#taginfo)): [IsoDepTag](js-apis-nfctech.md#isoDepTa **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------- | ---- | ---------------------------------------- | | taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 | **返回值:** + | **类型** | **说明** | | ---------- | ------------------| | [IsoDepTag](js-apis-nfctech.md#isodeptag9) | IsoDep类型Tag对象,通过该对象访问IsoDep类型的相关接口。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| @@ -215,16 +219,19 @@ getNdef(tagInfo: [TagInfo](#taginfo)): [NdefTag](js-apis-nfctech.md#ndeftag9) **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------- | ---- | ---------------------------------------- | | taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 | **返回值:** + | **类型** | **说明** | | ---------| -------------- | | [NdefTag](js-apis-nfctech.md#ndeftag9) | NDEF类型Tag对象,通过该对象访问NDEF类型的相关接口。| **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| @@ -239,11 +246,13 @@ getMifareClassic(tagInfo: [TagInfo](#taginfo)): [MifareClassicTag](js-apis-nfcte **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------- | ---- | ---------------------------------------- | | taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 | **返回值:** + | **类型** | **说明** | | ----------------- | ------------------------| | [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | MIFARE Classic类型Tag对象,通过该对象访问MIFARE Classic类型的相关接口。 | @@ -268,11 +277,13 @@ getMifareUltralight(tagInfo: [TagInfo](#taginfo)): [MifareUltralightTag](js-apis | taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 | **返回值:** + | **类型** | **说明** | | -------------------- | ---------------------------| | [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | MIFARE Ultralight类型Tag对象,通过该对象访问MIFARE Ultralight类型的相关接口。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| @@ -287,11 +298,13 @@ getNdefFormatable(tagInfo: [TagInfo](#taginfo)): [NdefFormatableTag](js-apis-nfc **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | NDEF Formatable类型Tag对象,通过该对象访问NDEF Formatable类型的相关接口。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| @@ -306,11 +319,13 @@ getTagInfo(want: [Want](js-apis-application-Want.md#Want)): [TagInfo](#taginfo) **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------- | ---- | ---------------------------------------- | | want | [Want](js-apis-application-Want.md#Want) | 是 | 分发Ability时,在系统onCreate入口函数的参数中获取。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | [TagInfo](#taginfo) | TagInfo对象,用于获取不同技术类型的Tag对象。 | @@ -331,11 +346,13 @@ makeUriRecord(uri: string): [NdefRecord](#ndefrecord9); | uri | string | 是 | 写入到NDEF Record里面的数据内容。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -362,17 +379,20 @@ makeTextRecord(text: string, locale: string): [NdefRecord](#ndefrecord9); **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | text | string | 是 | 写入到NDEF Record里面的文本数据内容。 | | locale | string | 是 | 文本数据内容的编码方式。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -398,26 +418,29 @@ makeMimeRecord(mimeType: string, mimeData: number[]): [NdefRecord](#ndefrecord9) 根据输入的MIME数据和类型,构建NDEF标签的Record。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | mimeType | string | 是 | 符合RFC规则的MIME类型,比如"text/plain"或"image/jpeg"。 | | mimeData | number[] | 是 | MIME数据内容,每个number十六进制表示,范围是0x00~0xFF。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; try { let mimeType = "text/plain"; // change it to be correct. - let mimeData = [0x01, 0x02, 0x03, 0x04, ...]; // change it to be correct. + let mimeData = [0x01, 0x02, 0x03, 0x04]; // change it to be correct. let ndefRecord = tag.ndef.makeMimeRecord(mimeType, mimeData); if (ndefRecord != undefined) { console.log("ndefMessage makeMimeRecord rtdType: " + ndefRecord.rtdType); @@ -435,9 +458,10 @@ makeExternalRecord(domainName: string, type: string, externalData: number[]): [N 根据应用程序特定的外部数据,构建NDEF标签的Record。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | domainName | string | 是 | 外部数据发布组织的域名,一般是应用程序的包名。 | @@ -445,18 +469,20 @@ makeExternalRecord(domainName: string, type: string, externalData: number[]): [N | externalData | number[] | 是 | 外部数据内容,每个number十六进制表示,范围是0x00~0xFF。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; try { let domainName = "ohos.nfc.application"; // change it to be correct. let type = "test"; // change it to be correct. - let externalData = [0x01, 0x02, 0x03, 0x04, ...]; // change it to be correct. + let externalData = [0x01, 0x02, 0x03, 0x04]; // change it to be correct. let ndefRecord = tag.ndef.makeExternalRecord(domainName, type, externalData); if (ndefRecord != undefined) { console.log("ndefMessage makeExternalRecord rtdType: " + ndefRecord.rtdType); @@ -475,19 +501,22 @@ messageToBytes(ndefMessage: [NdefMessage](js-apis-nfctech.md#ndefmessage9)): num 把输入的NDEF消息数据对象,转换为字节格式的数据。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | ndefMessage | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | 是 | NDEF消息数据对象。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | number[] | NDEF消息数据对象,所转换成的字节格式的数据。每个number十六进制表示,范围是0x00~0xFF。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -513,14 +542,16 @@ createNdefMessage(data: number[]): [NdefMessage](js-apis-nfctech.md#ndefmessage9 使用原始字节数据创建NDEF标签的Message。该数据必须符合NDEF Record数据格式,如果不符合格式,则返回的NdeMessage数据对象,所包含的NDE Record列表会为空。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | **参数名** | **类型** | **必填** | **说明** | | -------- | -------- | -------- | -------- | | data | number[] | 是 | 原始字节,每个number十六进制表示,范围是0x00~0xFF。要求必须满足NDEF Record的格式。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF标签的Message,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | @@ -548,16 +579,19 @@ createNdefMessage(ndefRecords: NdefRecord[]): [NdefMessage](js-apis-nfctech.md#n **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | **参数名** | **类型** | **必填** | **说明** | | -------- | -------- | -------- | -------- | | ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | 是 | NDEF标签的Record列表,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF标签的Message,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -581,30 +615,30 @@ NFC服务在读取到标签时给出的对象,通过改对象属性,应用 **需要权限**:ohos.permission.NFC_TAG -| **参数名** | **类型** | **说明** | -| -------- | -------- | -------- | -| uid9+ | number[] | 标签的uid,每个number值是十六进制表示,范围是0x00~0xFF。 | -| technology9+ | number[] | 支持的技术类型,每个number值表示所支持技术类型的常量值。 | -| supportedProfiles | number[] | 支持的技术类型,从API9开始不支持,使用technology替代。 | +| **名称** | **类型** | **可读** | **可写** | **说明** | +| -------- | -------- | -------- | -------- | -------- | +| uid9+ | number[] | 是 | 否 | 标签的uid,每个number值是十六进制表示,范围是0x00~0xFF。 | +| technology9+ | number[] | 是 | 否 | 支持的技术类型,每个number值表示所支持技术类型的常量值。 | +| supportedProfiles | number[] | 是 | 否 | 支持的技术类型,从API9开始不支持,使用technology替代。 | ## NdefRecord9+ NDEF标签Record属性的定义,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。 **系统能力**:SystemCapability.Communication.NFC.Core -| **参数名** | **类型** | **说明** | -| -------- | -------- | -------- | -| tnf | number | NDEF Record的TNF(Type Name Field)。 | -| rtdType| number[] | NDEF Record的RTD(Record Type Definition)类型值,每个number十六进制表示,范围是0x00~0xFF。 | -| id | number[] | NDEF Record的ID,每个number十六进制表示,范围是0x00~0xFF。| -| payload | number[] | NDEF Record的PAYLOAD,每个number十六进制表示,范围是0x00~0xFF。 | +| **名称** | **类型** | **可读** | **可写** | **说明** | +| -------- | -------- | -------- | -------- | -------- | +| tnf | number | 是 | 否 | NDEF Record的TNF(Type Name Field)。 | +| rtdType| number[] | 是 | 否 | NDEF Record的RTD(Record Type Definition)类型值,每个number十六进制表示,范围是0x00~0xFF。 | +| id | number[] | 是 | 否 | NDEF Record的ID,每个number十六进制表示,范围是0x00~0xFF。| +| payload | number[] | 是 | 否 | NDEF Record的PAYLOAD,每个number十六进制表示,范围是0x00~0xFF。 | ## 技术类型定义 NFC Tag有多种不同的技术类型,定义常量描述不同的技术类型。 **系统能力**:SystemCapability.Communication.NFC.Core -| **参数名** | **常量值** | **说明** | +| **名称** | **值** | **说明** | | -------- | -------- | -------- | | NFC_A | 1 | NFC-A (ISO 14443-3A)技术。| | NFC_B | 2 | NFC-A (ISO 14443-3B)技术。| @@ -621,7 +655,7 @@ NDEF Record的TNF(Type Name Field)类型值,参考NDEF标签技术规范《NFC **系统能力**:SystemCapability.Communication.NFC.Core -| **参数名** | **常量值** | **说明** | +| **名称** | **值** | **说明** | | -------- | -------- | -------- | | TNF_EMPTY | 0x0 | Empty。| | TNF_WELL_KNOWN | 0x01 | NFC Forum well-known type [NFC RTD]。| @@ -636,7 +670,7 @@ NDEF Record的RTD(Record Type Definition)类型值,参考NDEF标签技术规 **系统能力**:SystemCapability.Communication.NFC.Core -| **参数名** | **常量值** | **说明** | +| **名称** | **值** | **说明** | | -------- | -------- | -------- | | RTD_TEXT9+ | [0x54] | 文本类型的NDEF Record。| | RTD_URI9+ | [0x55] | URI类型的NDEF Record。| @@ -646,7 +680,7 @@ NFC Forum标准里面Tag类型的定义。 **系统能力**:SystemCapability.Communication.NFC.Core -| **参数名** | **常量值** | **说明** | +| **名称** | **值** | **说明** | | -------- | -------- | -------- | | NFC_FORUM_TYPE_1 | 1 | NFC论坛类型1。 | | NFC_FORUM_TYPE_2 | 2 | NFC论坛类型2。 | @@ -659,7 +693,7 @@ MIFARE Classic标签类型的定义。 **系统能力**:SystemCapability.Communication.NFC.Core -| **参数名** | **常量值** | **说明** | +| **名称** | **值** | **说明** | | -------- | -------- | -------- | | TYPE_UNKNOWN | 0 | 未知的MIFARE类型。 | | TYPE_CLASSIC | 1 | MIFARE Classic类型。| @@ -671,7 +705,7 @@ MIFARE Classic标签存储大小的定义。 **系统能力**:SystemCapability.Communication.NFC.Core -| **参数名** | **常量值** | **说明** | +| **名称** | **值** | **说明** | | -------- | -------- | -------- | | MC_SIZE_MINI | 320 | 每个标签5个扇区,每个扇区4个块。 | | MC_SIZE_1K | 1024 | 每个标签16个扇区,每个扇区4个块。| @@ -683,9 +717,9 @@ MIFARE Ultralight标签类型的定义。 **系统能力**:SystemCapability.Communication.NFC.Core -| **参数名** | **常量值** | **说明** | +| **名称** | **值** | **说明** | | -------- | -------- | -------- | -| TYPE_UNKOWN | 0 | 未知的 MIFARE 类型。 | +| TYPE_UNKNOWN | 0 | 未知的 MIFARE 类型。 | | TYPE_ULTRALIGHT | 1 | MIFARE Ultralight类型。| | TYPE_ULTRALIGHT_C | 2 | MIFARE UltralightC 类型。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfctech.md b/zh-cn/application-dev/reference/apis/js-apis-nfctech.md index 159daa8d2819971d08ec506ae7465167f400835a..a82483bbf56ff7fca8f9c917356c1392dfe47dbb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfctech.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfctech.md @@ -13,7 +13,7 @@ import tag from '@ohos.nfc.tag'; ## NfcATag -NfcATag 提供 NFC-A(ISO 14443-3A)技术的属性和I/O操作的访问,继承自TagSession。 +NfcATag 提供 NFC-A(ISO 14443-3A)技术的属性和I/O操作的访问,继承自[TagSession](js-apis-tagSession.md)。 TagSession是所有NFC Tag技术类型的基类, 提供建立连接和发送数据等共同接口。具体请参见[TagSession](js-apis-tagSession.md)。 @@ -268,11 +268,13 @@ getHistoricalBytes(): number[] **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | number[] | IsoDepTag 标签的历史字节,每个number十六进制表示,范围是0x00~0xFF。如果该IsoDep类型Tag是基于NfcB技术的,则该返回值为空。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -290,11 +292,13 @@ getHiLayerResponse(): number[] **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | number[] | IsoDepTag 标签的更高层响应字节,每个number十六进制表示,范围是0x00~0xFF。如果该IsoDep类型Tag是基于NfcA技术的,则该返回值为空。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -314,17 +318,20 @@ isExtendedApduSupported(): Promise<boolean> **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | Promise<boolean> | 检查结果,true: 支持, false: 不支持。| **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -361,16 +368,20 @@ isExtendedApduSupported(callback: AsyncCallback\): void **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | callback | AsyncCallback\ | 是 | 回调函数,true: 支持, false: 不支持。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | +**示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -401,18 +412,20 @@ try { ### NdefMessage.getNdefRecords9+ -getNdefRecords(): [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] +getNdefRecords(): [tag.NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] 获取NDEF消息中的所有记录。 **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| -| [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | NDEF标签的Record列表,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | +| [tag.NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | NDEF标签的Record列表,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -434,18 +447,20 @@ TagSession是所有NFC Tag技术类型的基类, 提供建立连接和发送 ### NdefTag.getNdefTagType9+ -getNdefTagType(): NfcForumType +getNdefTagType(): [tag.NfcForumType](js-apis-nfcTag.md#nfcforumtype9) 获取NDEF标签的类型。 **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| -| [NfcForumType](js-apis-nfcTag.md#nfcforumtype9) | NDEF标签类型,包括NFC FORUM TYPE 1/2/3/4等。| +| [tag.NfcForumType](js-apis-nfcTag.md#nfcforumtype9) | NDEF标签类型,包括NFC FORUM TYPE 1/2/3/4等。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -456,13 +471,14 @@ console.log("ndef ndefTagType: " + ndefTagType); ### NdefTag.getNdefMessage9+ -getNdefMessage(): NdefMessage +getNdefMessage(): [NdefMessage](#ndefmessage9) 获取发现NDEF标签时,从标签读取的Message。 **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | [NdefMessage](#ndefmessage9) | NDEF标签的Message,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。| @@ -485,11 +501,13 @@ isNdefWritable(): boolean; **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | boolean | 检查结果,true: 可写, false: 不可写。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -500,7 +518,7 @@ console.log("ndef isNdefWritable: " + isWritable); ### NdefTag.readNdef9+ -readNdef(): Promise\ +readNdef(): Promise\<[NdefMessage](#ndefmessage9)> 读取标签上的NDEF消息,使用Promise方式作为异步方法。 @@ -509,17 +527,20 @@ readNdef(): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | Promise\<[NdefMessage](#ndefmessage9)> | 以Promise形式返回从NDEF标签中读取到的Message数据对象。| **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -555,17 +576,20 @@ readNdef(callback: AsyncCallback\<[NdefMessage](#ndefmessage9)>): void **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | callback | AsyncCallback\<[NdefMessage](#ndefmessage9)> | 是 | 回调函数,返回从NDEF标签中读取到的Message信息。| **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -603,17 +627,20 @@ writeNdef(msg: NdefMessage): Promise\; **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | msg | NdefMessage | 是 | NDEF Message数据对象。| **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -643,7 +670,7 @@ try { ### NdefTag.writeNdef9+ -writeNdef(msg: NdefMessage, callback: AsyncCallback\): void +writeNdef(msg: [NdefMessage](#ndefmessage9), callback: AsyncCallback\): void 将NDEF Message数据对象写入此标签,使用AsyncCallback方式作为异步方法。 @@ -652,18 +679,21 @@ writeNdef(msg: NdefMessage, callback: AsyncCallback\): void **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | -| msg | NdefMessage | 是 | NDEF Message数据对象。 | +| msg | [NdefMessage](#ndefmessage9) | 是 | NDEF Message数据对象。 | | callback | AsyncCallback\ | 是 | 回调函数。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -704,17 +734,20 @@ canSetReadOnly(): boolean **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | boolean| true: NDEF标签可设置为只读, false: NDEF标签不可设置为只读。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -734,12 +767,14 @@ setReadOnly(): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -775,17 +810,20 @@ setReadOnly(callback: AsyncCallback\): void **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | callback | AsyncCallback\ | 是 | 回调函数。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -814,23 +852,26 @@ try { ### NdefTag.getNdefTagTypeString9+ -getNdefTagTypeString(type: [NfcForumType](js-apis-nfcTag.md#nfcforumtype9)): string +getNdefTagTypeString(type: [tag.NfcForumType](js-apis-nfcTag.md#nfcforumtype9)): string 将NFC论坛类型,转换为NFC论坛中定义的字符串描述。 **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | -| type | [NfcForumType](js-apis-nfcTag.md#nfcforumtype9) | 是 | NDEF标签类型,包括NFC FORUM TYPE 1/2/3/4等。 | +| type | [tag.NfcForumType](js-apis-nfcTag.md#nfcforumtype9) | 是 | NDEF标签类型,包括NFC FORUM TYPE 1/2/3/4等。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | string | NFC论坛类型的字符串描述。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -846,7 +887,7 @@ try { ## MifareClassicTag9+ -MifareClassicTag提供对MIFARE Classic属性和I/O操作的访问,继承自TagSession。 +MifareClassicTag提供对MIFARE Classic属性和I/O操作的访问,继承自[TagSession](js-apis-tagSession.md)。 TagSession是所有NFC Tag技术类型的基类, 提供建立连接和发送数据等共同接口。具体请参见[TagSession](js-apis-tagSession.md)。 @@ -863,6 +904,7 @@ authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | sectorIndex | number | 是 | 待验证的扇区索引,从0开始。 | @@ -870,12 +912,14 @@ authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise | isKeyA | boolean | 是 | isKeyA标志。true 表示KeyA,false 表示KeyB。| **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -913,6 +957,7 @@ authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | sectorIndex | number | 是 | 待验证的扇区索引,从0开始。 | @@ -921,6 +966,7 @@ authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback | callback | AsyncCallback\ | 是 | 回调函数。| **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| @@ -966,22 +1012,26 @@ readSingleBlock(blockIndex: number): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 要读取的块索引,从0开始。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | Promise\ | 读取的块数据。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1018,18 +1068,21 @@ readSingleBlock(blockIndex: number, callback: AsyncCallback\): void **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 要读取的块索引,从0开始。 | | callback | AsyncCallback\ | 是 | 回调函数,返回读取到的数据。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1068,18 +1121,21 @@ writeSingleBlock(blockIndex: number, data: number[]): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 要写入的块索引,从0开始。 | | data | number[] | 是 | 要写入的数据,大小必须是16个字节。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1095,7 +1151,8 @@ if (!mifareClassic.isTagConnected()) { try { let blockIndex = 1; // change it to be correct index. - let rawData = [0x01, 0x02, ..., 0x0F, 0x10]; // MUST be 16 bytes, change it to be correct data. + let rawData = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10]; // MUST be 16 bytes, change it to be correct data. mifareClassic.writeSingleBlock(blockIndex, rawData).then(() => { console.log("mifareClassic writeSingleBlock Promise success."); }).catch((err)=> { @@ -1117,6 +1174,7 @@ writeSingleBlock(blockIndex: number, data: number[], callback: AsyncCallback\ | 是 | 回调函数。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1145,7 +1205,8 @@ if (!mifareClassic.isTagConnected()) { try { let blockIndex = 1; // change it to be correct index. - let rawData = [0x01, 0x02, ..., 0x15, 0x16]; // MUST be 16 bytes, change it to be correct data. + let rawData = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10]; // MUST be 16 bytes, change it to be correct data. mifareClassic.writeSingleBlock(blockIndex, rawData, (err)=> { if (err) { console.log("mifareClassic writeSingleBlock AsyncCallback err: " + err); @@ -1169,18 +1230,21 @@ incrementBlock(blockIndex: number, value: number): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 要指定增加的块索引,从0开始。 | | value | number | 是 | 要指定增加的数据,非负数。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1218,6 +1282,7 @@ incrementBlock(blockIndex: number, value: number, callback: AsyncCallback\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 要被运算的块索引,从0开始。 | @@ -1225,12 +1290,14 @@ incrementBlock(blockIndex: number, value: number, callback: AsyncCallback\ | callback | AsyncCallback\ | 是 | 回调函数。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1270,18 +1337,21 @@ decrementBlock(blockIndex: number, value: number): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 要被运算的块索引,从0开始。 | | value | number | 是 | 要减少的数值,非负数。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1319,6 +1389,7 @@ decrementBlock(blockIndex: number, value: number, callback: AsyncCallback\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 要被运算的块索引,从0开始。 | @@ -1326,12 +1397,14 @@ decrementBlock(blockIndex: number, value: number, callback: AsyncCallback\ | callback | AsyncCallback\ | 是 | 回调函数。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1371,17 +1444,20 @@ transferToBlock(blockIndex: number): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 被操作的块的索引,从0开始。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1418,18 +1494,21 @@ transferToBlock(blockIndex: number, callback: AsyncCallback\): void **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 被操作的块的索引,从0开始。 | | callback | AsyncCallback\ | 是 | 回调函数。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1468,17 +1547,20 @@ restoreFromBlock(blockIndex: number): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 被操作的块的索引,从0开始。| **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1515,18 +1597,21 @@ restoreFromBlock(blockIndex: number, callback: AsyncCallback\): void **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 被操作的块的索引,从0开始。 | | callback | AsyncCallback\ | 是 | 回调函数。| **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1563,11 +1648,13 @@ getSectorCount(): number **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | number | 标签中的扇区数量。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1585,16 +1672,19 @@ getBlockCountInSector(sectorIndex: number): number **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | sectorIndex | number | 是 | 扇区序号,从0开始。| **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | number | 该扇区内的块数量。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1611,18 +1701,20 @@ try { ### MifareClassicTag.getType9+ -getType(): [MifareClassicType](js-apis-nfcTag.md#mifareclassictype9) +getType(): [tag.MifareClassicType](js-apis-nfcTag.md#mifareclassictype9) 获取MIFARE Classic标签的类型。 **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| -| [MifareClassicType](js-apis-nfcTag.md#mifareclassictype9) | MifareClassic标签的类型。| +| [tag.MifareClassicType](js-apis-nfcTag.md#mifareclassictype9) | MifareClassic标签的类型。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1640,11 +1732,13 @@ getTagSize(): number **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | number | 标签的大小,单位为字节,请参见[MifareClassicSize](js-apis-nfcTag.md#mifareclassicsize9)。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1662,11 +1756,13 @@ isEmulatedTag(): boolean **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | boolean |检查结果,true: 是;false:否。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1684,16 +1780,19 @@ getBlockIndex(sectorIndex: number): number **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | sectorIndex | number | 是 | 扇区序号,从0开始。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | number | 该扇区内的第一个块的序号,从0开始。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1714,21 +1813,22 @@ getSectorIndex(blockIndex: number): number 获取包含指定块号的扇区序号。 -**需要权限**:ohos.permission.NFC_TAG - **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | blockIndex | number | 是 | 块序号,从0开始。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | number | 扇区序号,从0开始。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1768,17 +1868,20 @@ readMultiplePages(pageIndex: number): Promise\ | pageIndex | number | 是 | 要读取页面的索引,从0开始。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | Promise\ | 读取的4页的数据,共16字节。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1816,18 +1919,21 @@ readMultiplePages(pageIndex: number, callback: AsyncCallback\): void **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | pageIndex | number | 是 | 要读取页面的索引,从0开始。 | | callback | AsyncCallback\ | 是 | 回调函数,返回读取到的数据,共16字节。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1866,18 +1972,21 @@ writeSinglePage(pageIndex: number, data: number[]): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | pageIndex | number | 是 | 要写入页面的索引,从0开始。 | | data | number[] | 是 | 要写入页面的数据内容,必须是4个字节大小。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1915,6 +2024,7 @@ writeSinglePage(pageIndex: number, data: number[], callback: AsyncCallback\ |是| 回调函数。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1958,18 +2070,20 @@ try { ### MifareUltralightTag.getType9+ -getType(): MifareUltralightType +getType(): [tag.MifareUltralightType](js-apis-nfcTag.md#mifareultralighttype9) -获取MIFARE Ultralight标签的类型,具体请参见 [MifareUltralightType](js-apis-nfcTag.md#mifareultralighttype9)。 +获取MIFARE Ultralight标签的类型。 **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| -| MifareUltralightType | MIFARE Ultralight标签的类型,具体请参见 [MifareUltralightType](js-apis-nfcTag.md#mifareultralighttype9)。| +| [tag.MifareUltralightType](js-apis-nfcTag.md#mifareultralighttype9) | MIFARE Ultralight标签的类型。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -1997,11 +2111,13 @@ format(message: [NdefMessage](#ndefmessage9)): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | message | [NdefMessage](#ndefmessage9) | 是 | 格式化成功时要写入的NDEF消息。可以为null,为null时仅格式化标签,不写入内容。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| @@ -2048,17 +2164,20 @@ format(message: [NdefMessage](#ndefmessage9), callback: AsyncCallback\): v **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | message | [NdefMessage](#ndefmessage9) | 是 | 格式化成功时要写入的Ndef消息。可以为null,为null时仅格式化标签,不写入内容。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | callback: AsyncCallback\ | 回调函数。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -2100,17 +2219,20 @@ formatReadOnly(message: [NdefMessage](#ndefmessage9)): Promise\ **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | message | [NdefMessage](#ndefmessage9) | 是 | 格式化成功时要写入的NDEF消息。可以为null,为null时仅格式化标签,不写入内容。 | **错误码:** + 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 | 错误码ID | 错误信息| | ------- | -------| | 3100201 | Tag running state is abnormal in service. | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -2150,17 +2272,20 @@ formatReadOnly(message: [NdefMessage](#ndefmessage9), callback: AsyncCallback\ | 回调函数。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; diff --git a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md index c95dda4a10d00080ecb38462f1a050172bd2696b..b414aab9865a84fcee7e2e891625b63a558e2420 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @@ -27,8 +27,7 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\): **参数:** - -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ----------------------------------------------- | ---- | ----------------- | | parameter | [StartAbilityParameter](js-apis-featureAbility.md#startabilityparameter) | 是 | 指示启动的ability | | callback | AsyncCallback\ | 是 | 被指定的回调方法 | @@ -59,8 +58,6 @@ particleAbility.startAbility( ) ``` - - ## particleAbility.startAbility startAbility(parameter: StartAbilityParameter): Promise\; @@ -71,8 +68,7 @@ startAbility(parameter: StartAbilityParameter): Promise\; **参数:** - -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ----------------------------------------------- | ---- | ----------------- | | parameter | [StartAbilityParameter](js-apis-featureAbility.md#startabilityparameter) | 是 | 指示启动的ability | @@ -117,7 +113,7 @@ terminateSelf(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法 | @@ -169,7 +165,7 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | :--- | ------ | ---- | ------------------------ | | uri | string | 是 | 指示要打开的文件的路径。 | @@ -386,7 +382,7 @@ connectAbility(request: Want, options:ConnectOptions): number **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | -------------- | ---- | ---------------------------- | | request | [Want](js-apis-application-Want.md) | 是 | 表示被连接的ServiceAbility。 | | options | ConnectOptions | 是 | 被指定的回调方法。 | @@ -396,7 +392,7 @@ connectAbility(request: Want, options:ConnectOptions): number **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core -| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| 参数名 | 读写属性 | 类型 | 必填 | 说明 | | ------------ | ---- | -------- | ---- | ------------------------- | | onConnect | 只读 | function | 是 | 连接成功时的回调函数。 | | onDisconnect | 只读 | function | 是 | 连接失败时的回调函数。 | @@ -546,7 +542,7 @@ particleAbility.disconnectAbility(connId).then((data) => { **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel -| 变量 | 值 | 说明 | +| 名称 | 值 | 说明 | | ----------------------------- | ---- | ------------------------------------------------------------ | | INVALID_PARAMETER | -1 | 无效的参数。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md index 4aff2d3116e50b96dd6f4f4678b28cf3e67a0b94..e8211ed280f82754e753e9f9c15ebf9984c8d8b4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @@ -1337,9 +1337,9 @@ setData(data: PasteData): Promise<void> **参数:** -| 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| data | [PasteData](#pastedata) | PasteData对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| data | [PasteData](#pastedata) | 是 | PasteData对象。 | **返回值:** @@ -1702,9 +1702,9 @@ setPasteData(data: PasteData): Promise<void> **参数:** -| 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| data | [PasteData](#pastedata) | PasteData对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| data | [PasteData](#pastedata) | 是 | PasteData对象。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md index 22b2e5dcdfb2cbd33848563420a88d1a204e1b6f..9c96d802b0118b45a474e2d4b130a72a66237328 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md +++ b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md @@ -53,11 +53,6 @@ PlainArray的构造函数。 ```ts let plainArray = new PlainArray(); -try { - let plainArray2 = PlainArray(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -88,11 +83,6 @@ isEmpty(): boolean ```ts const plainArray = new PlainArray(); let result = plainArray.isEmpty(); -try { - plainArray.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -131,11 +121,6 @@ let plainArray = new PlainArray(); plainArray.has(1); plainArray.add(1, "squirrel"); let result1 = plainArray.has(1); -try { - plainArray.has.bind({}, 1)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -174,11 +159,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let result = plainArray.get(1); -try { - plainArray.get.bind({}, 1)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -217,11 +197,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let result = plainArray.getIndexOfKey(2); -try { - plainArray.getIndexOfKey.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -260,11 +235,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let result = plainArray.getIndexOfValue("squirrel"); -try { - plainArray.getIndexOfValue.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -303,11 +273,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let result = plainArray.getKeyAt(1); -try { - plainArray.getKeyAt.bind({}, 1)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getValueAt @@ -346,16 +311,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let result = plainArray.getValueAt(1); -try { - plainArray.getValueAt.bind({}, 1)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - plainArray.getValueAt(10); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### clone @@ -387,11 +342,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let newPlainArray = plainArray.clone(); -try { - plainArray.clone.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -423,11 +373,6 @@ add(key: number, value: T): void ```ts let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); -try { - plainArray.add.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -466,11 +411,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let result = plainArray.remove(2); -try { - plainArray.remove.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -509,11 +449,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let result = plainArray.removeAt(1); -try { - plainArray.removeAt.bind({}, 1)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -554,16 +489,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let result = plainArray.removeRangeFrom(1, 3); -try { - plainArray.removeRangeFrom.bind({}, 1, 3)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - plainArray.removeRangeFrom(10, 3); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -598,16 +523,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); plainArray.setValueAt(1, 3546); -try { - plainArray.setValueAt.bind({}, 1, 3546)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} -try { - plainArray.setValueAt(10, 3); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -640,11 +555,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let result = plainArray.toString(); -try { - plainArray.toString.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -671,11 +581,6 @@ let plainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); plainArray.clear(); -try { - plainArray.clear.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -718,13 +623,6 @@ plainArray.add(2, "sparrow"); plainArray.forEach((value, index) => { console.log("value:" + value, index); }); -try { - plainArray.forEach.bind({}, (value, index) => { - console.log("value:" + value, index); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -771,9 +669,4 @@ while(temp != undefined) { console.log("value:" + temp[1]); temp = iter.next().value; } -try { - plainArray[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-promptAction.md b/zh-cn/application-dev/reference/apis/js-apis-promptAction.md index af1d690e2d349dc7625d64d130005c9e454492a0..6b274b6c8c03afbd53e3d471645acd53759f3227 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-promptAction.md +++ b/zh-cn/application-dev/reference/apis/js-apis-promptAction.md @@ -30,7 +30,7 @@ showToast(options: ShowToastOptions): void 以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | @@ -86,7 +86,7 @@ showDialog(options: ShowDialogOptions): Promise<ShowDialogSuccessResponse> 以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | @@ -140,7 +140,7 @@ showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSucc 以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | @@ -216,7 +216,7 @@ showActionMenu(options: ActionMenuOptions, callback: AsyncCallback<ActionMenu 以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | @@ -274,7 +274,7 @@ showActionMenu(options: ActionMenuOptions): Promise<ActionMenuSuccessResponse 以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-queue.md b/zh-cn/application-dev/reference/apis/js-apis-queue.md index cbbd9bd227454911ec84f88023ddf833eb93e968..4bdf0f9d81155aff8306d11f8da4ba567d2b8a08 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-queue.md +++ b/zh-cn/application-dev/reference/apis/js-apis-queue.md @@ -50,11 +50,6 @@ Queue的构造函数。 ```ts let queue = new Queue(); -try { - let queue2 = Queue(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -96,11 +91,6 @@ let b = [1, 2, 3]; let result2 = queue.add(b); let c = {name : "Dylon", age : "13"}; let result3 = queue.add(c); -try { - queue.add.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### pop @@ -135,11 +125,6 @@ queue.add(5); queue.add(2); queue.add(4); let result = queue.pop(); -try { - queue.pop.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### getFirst @@ -150,7 +135,7 @@ getFirst(): T **系统能力:** SystemCapability.Utils.Lang -**参数:** +**返回值:** | 类型 | 说明 | | -------- | -------- | @@ -173,11 +158,6 @@ queue.add(4); queue.add(5); queue.add(2); let result = queue.getFirst(); -try { - queue.getFirst.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### forEach @@ -223,13 +203,6 @@ queue.add(4); queue.forEach((value, index) => { console.log("value:" + value, index); }); -try { - queue.forEach.bind({}, (value, index) => { - console.log("value:" + value, index); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### [Symbol.iterator] @@ -274,9 +247,4 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - queue[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index a96c64782159fda2bc0daeef2ed413709dce7acb..102a5d57dfbe6182e88217ac4823120bf6a7353c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -132,7 +132,7 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | config | [UploadConfig](#uploadconfig) | 是 | 上传的配置信息。 | - | callback | AsyncCallback<[UploadTask](#uploadtask)> | 否 | 回调函数,异步返回UploadTask对象。 | + | callback | AsyncCallback<[UploadTask](#uploadtask)> | 是 | 回调函数,异步返回UploadTask对象。 | **示例:** @@ -216,7 +216,7 @@ upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback<Up | -------- | -------- | -------- | -------- | | context | BaseContext | 是 | 基于应用程序的上下文。 | | config | [UploadConfig](#uploadconfig) | 是 | 上传的配置信息。 | - | callback | AsyncCallback<[UploadTask](#uploadtask)> | 否 | 回调函数,异步返回UploadTask对象。 | + | callback | AsyncCallback<[UploadTask](#uploadtask)> | 是 | 回调函数,异步返回UploadTask对象。 | **示例:** @@ -305,7 +305,7 @@ uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback&l | -------- | -------- | -------- | -------- | | context | BaseContext | 是 | 基于应用程序的上下文。 | | config | [UploadConfig](#uploadconfig) | 是 | 上传的配置信息。 | -| callback | AsyncCallback<[UploadTask](#uploadtask)> | 否 | 回调函数,异步返回UploadTask对象。 | +| callback | AsyncCallback<[UploadTask](#uploadtask)> | 是 | 回调函数,异步返回UploadTask对象。 | **错误码:** 以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。 @@ -708,7 +708,7 @@ delete(callback: AsyncCallback<boolean>): void | 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | url | string | 是 | 资源地址。 | -| header | object | 是 | 添加要包含在上载请求中的HTTP或HTTPS标志头。 | +| header | Object | 是 | 添加要包含在上载请求中的HTTP或HTTPS标志头。 | | method | string | 是 | 请求方法:POST、PUT。缺省为POST。 | | files | Array<[File](#file)> | 是 | 要上传的文件列表。请使用 multipart/form-data提交。 | | data | Array<[RequestData](#requestdata)> | 是 | 请求的表单数据。 | @@ -808,7 +808,7 @@ download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): v | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | config | [DownloadConfig](#downloadconfig) | 是 | 下载的配置信息。 | - | callback | AsyncCallback<[DownloadTask](#downloadtask)> | 否 | 下载接口的回调函数。 | + | callback | AsyncCallback<[DownloadTask](#downloadtask)> | 是 | 下载接口的回调函数。 | **示例:** @@ -879,7 +879,7 @@ download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback&l | -------- | -------- | -------- | -------- | | context | BaseContext | 是 | 基于应用程序的上下文。 | | config | [DownloadConfig](#downloadconfig) | 是 | 下载的配置信息。 | - | callback | AsyncCallback<[DownloadTask](#downloadtask)> | 否 | 下载接口的回调函数。 | + | callback | AsyncCallback<[DownloadTask](#downloadtask)> | 是 | 下载接口的回调函数。 | **示例:** @@ -956,7 +956,7 @@ downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallba | -------- | -------- | -------- | -------- | | context | BaseContext | 是 | 基于应用程序的上下文。 | | config | [DownloadConfig](#downloadconfig) | 是 | 下载的配置信息。 | -| callback | AsyncCallback<[DownloadTask](#downloadtask)> | 否 | 下载接口的回调函数。 | +| callback | AsyncCallback<[DownloadTask](#downloadtask)> | 是 | 下载接口的回调函数。 | **错误码:** 以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。 @@ -1839,7 +1839,7 @@ restore(callback: AsyncCallback<boolean>): void | 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | url | string | 是 | 资源地址。 | -| header | object | 否 | 添加要包含在下载请求中的HTTPS标志头。
开发者可以通过header的X-TLS-Version参数指定需要使用的TLS版本(如果不指定,则默认使用CURL_SSLVERSION_TLSv1_2版本,指定则使用指定版本。)
CURL_SSLVERSION_TLSv1_0
CURL_SSLVERSION_TLSv1_1
CURL_SSLVERSION_TLSv1_2
CURL_SSLVERSION_TLSv1_3
通过header的X-Cipher-List参数指定需要使用的密码套件(如果不指定,则默认使用安全密码套件,指定则使用指定密码套件。)
-1.2允许使用的密码套件白名单:
TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_DSS_RSA_WITH_AES_256_GCM_SHA384,
TLS_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,
TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CCM,
TLS_DHE_RSA_WITH_AES_256_CCM,TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
TLS_PSK_WITH_AES_256_CCM,TLS_DHE_PSK_WITH_AES_128_CCM,
TLS_DHE_PSK_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_AES_128_CCM,
TLS_ECDHE_ECDSA_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
-1.3允许使用的密码套件白名单:
TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_128_CCM_SHA256
-1.3新增国密算法套:
TLS_SM4_GCM_SM3,TLS_SM4_CCM_SM3 | +| header | Object | 否 | 添加要包含在下载请求中的HTTPS标志头。
开发者可以通过header的X-TLS-Version参数指定需要使用的TLS版本(如果不指定,则默认使用CURL_SSLVERSION_TLSv1_2版本,指定则使用指定版本。)
CURL_SSLVERSION_TLSv1_0
CURL_SSLVERSION_TLSv1_1
CURL_SSLVERSION_TLSv1_2
CURL_SSLVERSION_TLSv1_3
通过header的X-Cipher-List参数指定需要使用的密码套件(如果不指定,则默认使用安全密码套件,指定则使用指定密码套件。)
-1.2允许使用的密码套件白名单:
TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_DSS_RSA_WITH_AES_256_GCM_SHA384,
TLS_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,
TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CCM,
TLS_DHE_RSA_WITH_AES_256_CCM,TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
TLS_PSK_WITH_AES_256_CCM,TLS_DHE_PSK_WITH_AES_128_CCM,
TLS_DHE_PSK_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_AES_128_CCM,
TLS_ECDHE_ECDSA_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
-1.3允许使用的密码套件白名单:
TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_128_CCM_SHA256
-1.3新增国密算法套:
TLS_SM4_GCM_SM3,TLS_SM4_CCM_SM3 | | enableMetered | boolean | 否 | 设置是否允许在按流量计费的连接下下载。
- true:是
- false:否 | | enableRoaming | boolean | 否 | 设置是否允许在漫游网络中下载。
- true:是
- false:否| | description | string | 否 | 设置下载会话的描述。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md index 6e4cb79de19f291f726377d612f73ba1e2d232ce..33144a5658e12bf4573e046df3ae25f463a94ce5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @@ -1375,15 +1375,16 @@ getRawFd(path: string, callback: AsyncCallback<RawFileDescriptor>): void try { this.context.resourceManager.getRawFd("test.xml", (error, value) => { if (error != null) { - console.log("error is " + error); + console.log(`callback getRawFd failed error code: ${error.code}, message: ${error.message}.`); } else { let fd = value.fd; let offset = value.offset; let length = value.length; } - }).catch(error => { - console.log("getRawFd callback error is " + error); - }); + }); + } catch (error) { + console.error(`callback getRawFd failed, error code: ${error.code}, message: ${error.message}.`) + }; ``` ### getRawFd9+ @@ -1421,10 +1422,10 @@ getRawFd(path: string): Promise<RawFileDescriptor> let offset = value.offset; let length = value.length; }).catch(error => { - console.log("getRawFd promise error is " + error); + console.log(`promise getRawFd error error code: ${error.code}, message: ${error.message}.`); }); } catch (error) { - console.log("getRawFd promise error is " + error); + console.error(`promise getRawFd failed, error code: ${error.code}, message: ${error.message}.`); }; ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md index 4289e22a78269e582ec9d7e8e94003d406ad786a..26b0cbbc9c1063494d2619cb274b8f6af3af894a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md @@ -32,7 +32,7 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------------ | | reason | string | 是 | 延迟挂起申请的原因。 | | callback | Callback<void> | 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 | @@ -86,7 +86,7 @@ getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | --------------------------- | ---- | ---------------------------------------- | | requestId | number | 是 | 延迟挂起的请求ID。 | | callback | AsyncCallback<number> | 是 | 指定的callback回调方法。用于返回应用程序进入挂起状态之前的剩余时间,以毫秒为单位。 | @@ -137,7 +137,7 @@ getRemainingDelayTime(requestId: number): Promise<number> **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ---------- | | requestId | number | 是 | 延迟挂起的请求ID。 | @@ -188,7 +188,7 @@ cancelSuspendDelay(requestId: number): void **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ---------- | | requestId | number | 是 | 延迟挂起的请求ID。 | @@ -231,7 +231,7 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | ---------------------------------- | ---- | ---------------------------------------- | | context | Context | 是 | 应用运行的上下文。
FA模型的应用Context定义见[Context](js-apis-Context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | | bgMode | [BackgroundMode](#backgroundmode) | 是 | 向系统申请的后台模式。 | @@ -305,7 +305,7 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | ---------------------------------- | ---- | ---------------------------------------- | | context | Context | 是 | 应用运行的上下文。
FA模型的应用Context定义见[Context](js-apis-Context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | | bgMode | [BackgroundMode](#backgroundmode) | 是 | 向系统申请的后台模式。 | @@ -378,7 +378,7 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------------------------------------- | | context | Context | 是 | 应用运行的上下文。
FA模型的应用Context定义见[Context](js-apis-Context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果。 | @@ -434,7 +434,7 @@ stopBackgroundRunning(context: Context): Promise<void> **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------- | ------- | ---- | ---------------------------------------- | | context | Context | 是 | 应用运行的上下文。
FA模型的应用Context定义见[Context](js-apis-Context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | @@ -492,7 +492,7 @@ applyEfficiencyResources(request: [EfficiencyResourcesRequest](#efficiencyresour **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------- | ------- | ---- | ---------------------------------------- | | request | [EfficiencyResourcesRequest](#efficiencyresourcesrequest) | 是 | 请求的必要信息。包括资源类型,超时时间等信息。详见[EfficiencyResourcesRequest](#efficiencyresourcesrequest)。 | @@ -570,7 +570,7 @@ try { **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------------- | ------ | ---- | ---------------------------------------- | | requestId | number | 是 | 延迟挂起的请求ID。 | | actualDelayTime | number | 是 | 应用的实际挂起延迟时间,以毫秒为单位。
一般情况下默认值为180000,低电量(依据系统低电量广播)时默认值为60000。 | @@ -580,7 +580,7 @@ try { **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -| 参数名 | 参数值 | 描述 | +| 名称 | 值 | 描述 | | ----------------------- | ---- | --------------------- | | DATA_TRANSFER | 1 | 数据传输。 | | AUDIO_PLAYBACK | 2 | 音频播放。 | @@ -600,7 +600,7 @@ try { **系统API**: 此接口为系统接口。 -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------------- | ------ | ---- | ---------------------------------------- | | resourceTypes | number | 是 | 申请的资源类型。 | | isApply | boolean | 是 | 申请资源或者是释放资源。 | @@ -617,13 +617,13 @@ try { **系统API**: 此接口为系统接口。 -| 参数名 | 描述 | -| ----------------------- | --------------------- | -| CPU | CPU资源,申请后不被挂起。 | -| COMMON_EVENT | 公共事件,申请后挂起状态下不被代理掉。 | -| TIMER | 计时器,申请后挂起状态下不被代理掉。 | -| WORK_SCHEDULER | 延迟任务,申请后有更长的执行时间。 | -| BLUETOOTH | 蓝牙相关,申请后挂起状态下不被代理掉。 | -| GPS | GPS相关,申请后挂起状态下不被代理掉。 | -| AUDIO | 音频资源,申请后挂起状态下不被代理掉。 | +| 名称 | 值 | 描述 | +| ----------------------- | ---- | --------------------- | +| CPU | 1 | CPU资源,申请后不被挂起。 | +| COMMON_EVENT | 2 | 公共事件,申请后挂起状态下不被代理掉。 | +| TIMER | 4 | 计时器,申请后挂起状态下不被代理掉。 | +| WORK_SCHEDULER | 8 | 延迟任务,申请后有更长的执行时间。 | +| BLUETOOTH | 16 | 蓝牙相关,申请后挂起状态下不被代理掉。 | +| GPS | 32 | GPS相关,申请后挂起状态下不被代理掉。 | +| AUDIO | 64 | 音频资源,申请后挂起状态下不被代理掉。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md index 41cb656ad6e883056069734d28d1ec309b85a566..0ddce05d36ce0774e91590d3b3d01a566badc23f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md @@ -26,7 +26,7 @@ startWork(work: WorkInfo): void **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---- | --------------------- | ---- | -------------- | | work | [WorkInfo](#workinfo) | 是 | 指示要添加到执行队列的工作。 | @@ -77,7 +77,7 @@ stopWork(work: WorkInfo, needCancel?: boolean): void **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | --------------------- | ---- | ---------- | | work | [WorkInfo](#workinfo) | 是 | 指示要停止的工作。 | | needCancel | boolean | 是 | 是否需要取消的工作。 | @@ -127,7 +127,7 @@ getWorkStatus(workId: number, callback : AsyncCallback\): void **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | ---------------------------------------- | | workId | number | 是 | work的id。 | | callback | AsyncCallback\<[WorkInfo](#workinfo)> | 是 | 指定的callback回调方法。如果指定的工作Id有效,则返回从WorkSchedulerService获取的有效工作状态;否则返回null。 | @@ -170,7 +170,7 @@ getWorkStatus(workId: number): Promise\ **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | -------- | | workId | number | 是 | work的id。 | @@ -216,7 +216,7 @@ obtainAllWorks(callback : AsyncCallback\): Array\ **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------------- | | callback | AsyncCallback\ | 是 | 指定的callback回调方法。返回与应用程序关联的所有工作。 | @@ -326,7 +326,7 @@ isLastWorkTimeOut(workId: number, callback : AsyncCallback\): boolean **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ---------------------------------------- | | workId | number | 是 | work的id。 | | callback | AsyncCallback\ | 是 | 指定的callback回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | @@ -372,7 +372,7 @@ isLastWorkTimeOut(workId: number): Promise\ **参数**: -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | -------- | | workId | number | 是 | work的id。 | @@ -413,7 +413,7 @@ isLastWorkTimeOut(workId: number): Promise\ **系统能力**:SystemCapability.ResourceSchedule.WorkScheduler -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------------- | --------------------------------- | ---- | ---------------- | | workId | number | 是 | 当前工作的ID | | bundleName | string | 是 | 延迟任务包名 | @@ -437,45 +437,45 @@ isLastWorkTimeOut(workId: number): Promise\ **系统能力**:SystemCapability.ResourceSchedule.WorkScheduler -| 名称 | 说明 | -| ---------------------- | ----------------------- | -| NETWORK_TYPE_ANY | 表示这个触发条件是任何类型的网络连接。 | -| NETWORK_TYPE_MOBILE | 表示这个触发条件是Mobile网络连接。 | -| NETWORK_TYPE_WIFI | 表示这个触发条件是Wifi类型的网络连接。 | -| NETWORK_TYPE_BLUETOOTH | 表示这个触发条件是Bluetooth网络连接。 | -| NETWORK_TYPE_WIFI_P2P | 表示这个触发条件是Wifi P2P网络连接。 | -| NETWORK_TYPE_ETHERNET | 表示这个触发条件是有线网络连接。 | +| 名称 | 值 | 说明 | +| ---------------------- | ---- | ----------------------- | +| NETWORK_TYPE_ANY | 0 | 表示这个触发条件是任何类型的网络连接。 | +| NETWORK_TYPE_MOBILE | 1 | 表示这个触发条件是Mobile网络连接。 | +| NETWORK_TYPE_WIFI | 2 | 表示这个触发条件是Wifi类型的网络连接。 | +| NETWORK_TYPE_BLUETOOTH | 3 | 表示这个触发条件是Bluetooth网络连接。 | +| NETWORK_TYPE_WIFI_P2P | 4 | 表示这个触发条件是Wifi P2P网络连接。 | +| NETWORK_TYPE_ETHERNET | 5 | 表示这个触发条件是有线网络连接。 | ## ChargingType 触发工作的充电类型。 **系统能力**:SystemCapability.ResourceSchedule.WorkScheduler -| 名称 | 说明 | -| ------------------------- | -------------------- | -| CHARGING_PLUGGED_ANY | 表示这个触发条件是任何类型的充电器连接。 | -| CHARGING_PLUGGED_AC | 表示这个触发条件是直流充电器连接。 | -| CHARGING_PLUGGED_USB | 表示这个触发条件是USB充连接。 | -| CHARGING_PLUGGED_WIRELESS | 表示这个触发条件是无线充电器连接。 | +| 名称 | 值 | 说明 | +| ------------------------- | ---- | -------------------- | +| CHARGING_PLUGGED_ANY | 0 | 表示这个触发条件是任何类型的充电器连接。 | +| CHARGING_PLUGGED_AC | 1 | 表示这个触发条件是直流充电器连接。 | +| CHARGING_PLUGGED_USB | 2 | 表示这个触发条件是USB充连接。 | +| CHARGING_PLUGGED_WIRELESS | 3 | 表示这个触发条件是无线充电器连接。 | ## BatteryStatus 触发工作的电池状态。 **系统能力**:SystemCapability.ResourceSchedule.WorkScheduler -| 名称 | 说明 | -| -------------------------- | -------------------------- | -| BATTERY_STATUS_LOW | 表示这个触发条件是低电告警。 | -| BATTERY_STATUS_OKAY | 表示这个触发条件是从低电恢复到正常电量。 | -| BATTERY_STATUS_LOW_OR_OKAY | 表示这个触发条件是从低电恢复到正常电量或者低电告警。 | +| 名称 | 值 | 说明 | +| -------------------------- | ---- | -------------------------- | +| BATTERY_STATUS_LOW | 0 | 表示这个触发条件是低电告警。 | +| BATTERY_STATUS_OKAY | 1 | 表示这个触发条件是从低电恢复到正常电量。 | +| BATTERY_STATUS_LOW_OR_OKAY | 2 | 表示这个触发条件是从低电恢复到正常电量或者低电告警。 | ## StorageRequest 触发工作的存储状态。 **系统能力**:SystemCapability.ResourceSchedule.WorkScheduler -| 名称 | 说明 | -| ------------------------- | ------------------------------ | -| STORAGE_LEVEL_LOW | 表示这个触发条件是存储空间不足。 | -| STORAGE_LEVEL_OKAY | 表示这个触发条件是从存储空间不足恢复到正常。 | -| STORAGE_LEVEL_LOW_OR_OKAY | 表示这个触发条件是从存储空间不足恢复到正常或者存储空间不足。 | \ No newline at end of file +| 名称 | 值 | 说明 | +| ------------------------- | ---- | ------------------------------ | +| STORAGE_LEVEL_LOW | 0 | 表示这个触发条件是存储空间不足。 | +| STORAGE_LEVEL_OKAY | 1 | 表示这个触发条件是从存储空间不足恢复到正常。 | +| STORAGE_LEVEL_LOW_OR_OKAY | 2 | 表示这个触发条件是从存储空间不足恢复到正常或者存储空间不足。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-router.md b/zh-cn/application-dev/reference/apis/js-apis-router.md index f13771a442e172f3e02488017033fb8876859590..20e6d1f7881226ebb0307709c42c2dc489f9c9d4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-router.md @@ -38,7 +38,7 @@ pushUrl(options: RouterOptions): Promise<void> 以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | | 100002 | Uri error. The uri of router is not exist. | @@ -87,7 +87,7 @@ pushUrl(options: RouterOptions, callback: AsyncCallback<void>): void 以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | | 100002 | Uri error. The uri of router is not exist. | @@ -141,7 +141,7 @@ pushUrl(options: RouterOptions, mode: RouterMode): Promise<void> 以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | | 100002 | Uri error. The uri of router is not exist. | @@ -191,7 +191,7 @@ pushUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback<voi 以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | | 100002 | Uri error. The uri of router is not exist. | @@ -245,7 +245,7 @@ replaceUrl(options: RouterOptions): Promise<void> 以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | | 200002 | Uri error. The uri of router is not exist. | @@ -290,7 +290,7 @@ replaceUrl(options: RouterOptions, callback: AsyncCallback<void>): void 以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | | 200002 | Uri error. The uri of router is not exist. | @@ -342,7 +342,7 @@ replaceUrl(options: RouterOptions, mode: RouterMode): Promise<void> 以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | | 200002 | Uri error. The uri of router is not exist. | @@ -388,7 +388,7 @@ replaceUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback< 以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | | 200002 | Uri error. The uri of router is not exist. | @@ -522,7 +522,7 @@ enableBackPageAlert(options: EnableAlertOptions): void 以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | --------- | ------- | | 100001 | Internal error. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-rpc.md b/zh-cn/application-dev/reference/apis/js-apis-rpc.md index eb996347f3af2a477c0af8b79bddd85770161ce3..69e19bdf138826175af3d55f372706c1ee2dcaa4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-rpc.md +++ b/zh-cn/application-dev/reference/apis/js-apis-rpc.md @@ -14,6 +14,29 @@ import rpc from '@ohos.rpc'; ``` +## ErrorCode9+ + +从API version 9起,IPC支持异常返回功能。错误码对应数值及含义如下。 + +**系统能力**:SystemCapability.Communication.IPC.Core + + | 名称 | 值 | 说明 | + | ------------------------------------- | ------- | --------------------------------------------- | + | OS_MMAP_ERROR | 1900001 | 执行系统调用mmap失败。 | + | OS_IOCTL_ERROR | 1900002 | 在共享内存文件描述符上执行系统调用ioctl失败。 | + | WRITE_TO_ASHMEM_ERROR | 1900003 | 向共享内存写数据失败。 | + | READ_FROM_ASHMEM_ERROR | 1900004 | 从共享内存读数据失败。 | + | ONLY_PROXY_OBJECT_PERMITTED_ERROR | 1900005 | 只有proxy对象允许该操作。 | + | ONLY_REMOTE_OBJECT_PERMITTED_ERROR | 1900006 | 只有remote对象允许该操作。 | + | COMMUNICATION_ERROR | 1900007 | 和远端对象进行进程间通信失败。 | + | PROXY_OR_REMOTE_OBJECT_INVALID_ERROR | 1900008 | 非法的代理对象或者远端对象。 | + | WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR | 1900009 | 向MessageSequence写数据失败。 | + | READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR | 1900010 | 读取MessageSequence数据失败。 | + | PARCEL_MEMORY_ALLOC_ERROR | 1900011 | 序列化过程中内存分配失败。 | + | CALL_JS_METHOD_ERROR | 1900012 | 执行JS回调方法失败。 | + | OS_DUP_ERROR | 1900013 | 执行系统调用dup失败。 | + + ## MessageSequence9+ 在RPC过程中,发送方可以使用MessageSequence提供的写方法,将待发送的数据以特定格式写入该对象。接收方可以使用MessageSequence提供的读方法从该对象中读取特定格式的数据。数据格式包括:基础类型及数组、IPC对象、接口描述符和自定义序列化对象。 @@ -796,7 +819,7 @@ writeFloat(val: number): void | 错误码ID | 错误信息 | | ------- | ------- | - | 1900010 | write data to message sequence failed | + | 1900009 | write data to message sequence failed | **示例:** @@ -2543,6 +2566,7 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): void **系统能力**:SystemCapability.Communication.IPC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----------- | --------------- | ---- | ---------------------------------------------- | | objectArray | IRemoteObject[] | 是 | 要写入MessageSequence的IRemoteObject对象数组。 | @@ -2681,7 +2705,7 @@ readRemoteObjectArray(): IRemoteObject[] ``` -### closeFileDescriptor8+ +### closeFileDescriptor9+ static closeFileDescriptor(fd: number): void @@ -2891,7 +2915,7 @@ writeAshmem(ashmem: Ashmem): void | 错误码ID | 错误信息 | | ------- | ------- | - | 1900009 | write data to message sequence failed | + | 1900003 | write data to message sequence failed | **示例:** @@ -2933,7 +2957,7 @@ readAshmem(): Ashmem | 错误码ID | 错误信息 | | ------- | -------- | - | 1900010 | read data from message sequence failed | + | 1900004 | read data from message sequence failed | **示例:** @@ -5738,12 +5762,12 @@ onRemoteDied(): void **系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 - | 参数名 | 类型 | 必填 | 说明 | - | ------- | --------------- | ---- | ------------------------------------- | - | errCode | number | 是 | 错误码。 | - | code | number | 是 | 消息代码。 | - | data | MessageSequence | 是 | 发送给对端进程的MessageSequence对象。 | - | reply | MessageSequence | 是 | 对端进程返回的MessageSequence对象。 | + | 名称 | 类型 | 可读 | 可写 | 说明 | + | ------- | --------------- | ---- | ---- |-------------------------------------- | + | errCode | number | 是 | 否 | 错误码。 | + | code | number | 是 | 否 | 消息代码。 | + | data | MessageSequence | 是 | 否 | 发送给对端进程的MessageSequence对象。 | + | reply | MessageSequence | 是 | 否 | 对端进程返回的MessageSequence对象。 | ## SendRequestResult8+(deprecated) @@ -5753,12 +5777,12 @@ onRemoteDied(): void **系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------- | ---- | ----------------------------------- | - | errCode | number | 是 | 错误码。 | - | code | number | 是 | 消息代码。 | - | data | MessageParcel | 是 | 发送给对端进程的MessageParcel对象。 | - | reply | MessageParcel | 是 | 对端进程返回的MessageParcel对象。 | + | 名称 | 类型 | 可读 | 可写 | 说明 | + | ------- | ------------- | ---- | ---- | ----------------------------------- | + | errCode | number | 是 | 否 | 错误码。 | + | code | number | 是 | 否 | 消息代码。 | + | data | MessageParcel | 是 | 否 | 发送给对端进程的MessageParcel对象。 | + | reply | MessageParcel | 是 | 否 | 对端进程返回的MessageParcel对象。 | ## IRemoteObject @@ -5973,7 +5997,7 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean ### unregisterDeathRecipient9+ -removeDeathRecipient(recipient: DeathRecipient, flags: number): void +unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void 注销用于接收远程对象死亡通知的回调。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-sensor.md index 6be2c9cd36e49db2dcddc5f5bf61eff3a359c597..4bbe3ce2628956bf4a449314ab9a267252750e83 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md @@ -1428,6 +1428,7 @@ try { ### PEDOMETER_DETECTION9+ once(type: SensorId.PEDOMETER_DETECTION, callback: Callback<PedometerDetectionResponse>): void + 获取一次计步检测器传感器数据。 **需要权限**:ohos.permission.ACTIVITY_MOTION @@ -1659,7 +1660,7 @@ off(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback?: Callback<Accelerome | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | type | [SensorId](#sensorid9).ACCELEROMETER_UNCALIBRATED | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER_UNCALIBRATED。 | -| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-socket.md b/zh-cn/application-dev/reference/apis/js-apis-socket.md index 078dbaf17a9d404ea8529daf3b4f44490b6f6b06..4f44634d66d940abbbd332666118be42b0f20529 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-socket.md +++ b/zh-cn/application-dev/reference/apis/js-apis-socket.md @@ -1453,3 +1453,1067 @@ TCPSocket连接的其他属性。 | sendBufferSize | number | 否 | 发送缓冲区大小(单位:Byte)。 | | reuseAddress | boolean | 否 | 是否重用地址。默认为false。 | | socketTimeout | number | 否 | 套接字超时时间,单位毫秒(ms)。 | + +## socket.constructTLSSocketInstance9+ + +constructTLSSocketInstance(): TLSSocket + +创建并返回一个TLSSocket对象。 + +**需要权限**:ohos.permission.INTERNET + +**系统能力**:SystemCapability.Communication.NetStack + +**返回值:** + +| 类型 | 说明 | +| :--------------------------------- | :---------------------- | +| [TLSSocket](#tlssocket9) | 返回一个TLSSocket对象。 | + +**示例:** + +```js +let tls = socket.constructTLSSocketInstance(); +``` + +## TLSSocket9+ + +TLSSocket连接。在调用TLSSocket的方法前,需要先通过[socket.constructTLSSocketInstance](#socketconstructtlssocketinstance9)创建TLSSocket对象。 + +### bind9+ + +bind\(address: NetAddress, callback: AsyncCallback\): void + +绑定IP地址和端口。使用callback方法作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------- | ---- | ------------------------------------------------------ | +| address | [NetAddress](#netaddress) | 是 | 目标地址信息,参考[NetAddress](#netaddress)。 | +| callback | AsyncCallback\ | 是 | 回调函数。成功返回TLSSocket绑定本机的IP地址和端口的结果。 失败返回错误码,错误信息。| + +**错误码:** + +| 错误码ID | 错误信息 | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2303198 | Address already in use. | +| 2300002 | System internal error. | + +**示例:** + +```js +let tls = socket.constructTLSSocketInstance(); +tls.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}); +``` + +### bind9+ + +bind\(address: NetAddress\): Promise + +绑定IP地址和端口。使用Promise方法作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------- | ---- | ------------------------------------------------------ | +| address | [NetAddress](#netaddress) | 是 | 目标地址信息,参考[NetAddress](#netaddress)。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :------------------------------------------------------- | +| Promise\ | 以Promise形式返回TLSSocket绑定本机的IP地址和端口的结果。失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 401 | Parameter error. | +| 201 | Permission denied. | +| 2303198 | Address already in use. | +| 2300002 | System internal error. | + +**示例:** + +```js +let tls = socket.constructTLSSocketInstance(); +let promise = tls.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}); +promise.then(() => { + console.log('bind success'); +}).catch(err => { + console.log('bind fail'); +}); +``` + +### getState9+ + +getState\(callback: AsyncCallback\): void + +在TLSSocket的bind成功之后,获取TLSSocket状态。使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------ | ---- | ---------- | +| callback | AsyncCallback\<[SocketStateBase](#socketstatebase)> | 是 | 回调函数。成功返回TLSSocket状态,失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303188 | Socket operation on non-socket.| +| 2300002 | System internal error. | + +**示例:** + +```js +let tls = socket.constructTLSSocketInstance(); +let promise = tls.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}); +tls.getState((err, data) => { + if (err) { + console.log('getState fail'); + return; + } + console.log('getState success:' + JSON.stringify(data)); +}); +``` + +### getState9+ + +getState\(\): Promise + +在TLSSocket的bind成功之后,获取TLSSocket状态。使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**返回值:** + +| 类型 | 说明 | +| :----------------------------------------------- | :----------------------------------------- | +| Promise\<[SocketStateBase](#socketstatebase)> | 以Promise形式返回获取TLSSocket状态的结果。失败返回错误码,错误信息。| + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303188 | Socket operation on non-socket.| +| 2300002 | System internal error. | + +**示例:** + +```js +let tls = socket.constructTLSSocketInstance(); +tls.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}); +let promise = tls.getState(); +promise.then(() => { + console.log('getState success'); +}).catch(err => { + console.log('getState fail'); +}); +``` + +### setExtraOptions9+ + +setExtraOptions\(options: TCPExtraOptions, callback: AsyncCallback\): void + +在TLSSocket的bind成功之后,设置TCPSocket连接的其他属性。使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPExtraOptions](#tcpextraoptions) | 是 | TCPSocket连接的其他属性,参考[TCPExtraOptions](#tcpextraoptions)。 | +| callback | AsyncCallback\ | 是 | 回调函数。成功返回设置TCPSocket连接的其他属性的结果,失败返回错误码,错误信息。| + +**错误码:** + +| 错误码ID | 错误信息 | +| 401 | Parameter error. | +| 2303188 | Socket operation on non-socket.| +| 2300002 | System internal error. | + +**示例:** + +```js +let tls = socket.constructTLSSocketInstance(); +tls.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}); + +tls.setExtraOptions({ + keepAlive: true, + OOBInline: true, + TCPNoDelay: true, + socketLinger: { on:true, linger:10 }, + receiveBufferSize: 1000, + sendBufferSize: 1000, + reuseAddress: true, + socketTimeout: 3000, +},err => { + if (err) { + console.log('setExtraOptions fail'); + return; + } + console.log('setExtraOptions success'); +}); +``` + +### setExtraOptions9+ + +setExtraOptions\(options: TCPExtraOptions\): Promise + +在TLSSocket的bind成功之后,设置TCPSocket连接的其他属性,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPExtraOptions](#tcpextraoptions) | 是 | TCPSocket连接的其他属性,参考[TCPExtraOptions](#tcpextraoptions)。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :--------------------------------------------------- | +| Promise\ | 以Promise形式返回设置TCPSocket连接的其他属性的结果。失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 401 | Parameter error. | +| 2303188 | Socket operation on non-socket.| +| 2300002 | System internal error. | + +**示例:** + +```js +let tls = socket.constructTLSSocketInstance(); +tls.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}); +let promise = tls.setExtraOptions({ + keepAlive: true, + OOBInline: true, + TCPNoDelay: true, + socketLinger: { on:true, linger:10 }, + receiveBufferSize: 1000, + sendBufferSize: 1000, + reuseAddress: true, + socketTimeout: 3000, +}); +promise.then(() => { + console.log('setExtraOptions success'); +}).catch(err => { + console.log('setExtraOptions fail'); +}); +``` + +### connect9+ + +connect(options: TLSConnectOptions, callback: AsyncCallback\): void + +在TLSSocket上bind成功之后,进行通信连接,并创建和初始化TLS会话,实现建立连接过程,启动与服务器的TLS/SSL握手,实现数据传输功能,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------| ----| --------------- | +| options | [TLSConnectOptions](#tlsconnectoptions9) | 是 | TLSSocket连接所需要的参数。| +| callback | AsyncCallback\ | 是 | 回调函数,成功无返回,失败返回错误码,错误信息。| + +**错误码:** + +| 错误码ID | 错误信息 | +| 401 | Parameter error. | +| 2303104 | Interrupted system call. | +| 2303109 | Bad file number. | +| 2303111 | Resource temporarily unavailable try again. | +| 2303113 | System permission denied. | +| 2303188 | Socket operation on non-socket. | +| 2303191 | Protocol wrong type for socket. | +| 2303198 | Address already in use. | +| 2303199 | Cannot assign requested address. | +| 2303210 | Connection timed out. | +| 2303501 | SSL is null. | +| 2303502 | Error in tls reading. | +| 2303503 | Error in tls writing | +| 2303505 | Error occurred in the tls system call. | +| 2303506 | Error clearing tls connection. | +| 2300002 | System internal error. | + +**示例:** + +```js +let tls = socket.constructTLSSocketInstance(); // Two way authentication +tls.bind({address: '192.168.xxx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}); +let Protocol = socket.Protocol; +let options = { + ALPNProtocols: ["spdy/1", "http/1.1"], + address: { + address: "192.168.xx.xxx", + port: xxxx, + family: 1, + }, + secureOptions: { + key: "xxxx", + cert: "xxxx", + ca: ["xxxx"], + passwd: "xxxx", + protocols: [Protocol.TLSv12], + useRemoteCipherPrefer: true, + signatureAlgorithms: rsa_pss_rsae_sha256:ECDSA+SHA25, + cipherSuite: AES256-SHA256, + }, +}; +tls.connect(options, (err, data) => { + console.info(err); + console.info(data); +}); + +let tlsOneWay = socket.constructTLSSocketInstance(); // One way authentication +tlsOneWay.bind({address: '192.168.xxx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}); +let oneWayOptions = { + address: { + address: "192.168.xxx.xxx", + port: xxxx, + family: 1, + }, + secureOptions: { + ca: ["xxxx","xxxx"], + cipherSuite: AES256-SHA256, + }, +}; +tlsOneWay.connect(options, (err, data) => { + console.info(err); + console.info(data); +}); +``` + +### connect9+ + +connect(options: TLSConnectOptions): Promise\ + +在TLSSocket上bind成功之后,进行通信连接,并创建和初始化TLS会话,实现建立连接过程,启动与服务器的TLS/SSL握手,实现数据传输功能,该连接包括两种认证方式,单向认证与双向认证,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------| ----| --------------- | +| options | [TLSConnectOptions](#tlsconnectoptions9) | 是 | 连接所需要的参数。| + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------- | ----------------------------- | +| Promise\ | 以Promise形式返回,成功无返回,失败返回错误码,错误信息。| + +**错误码:** + +| 错误码ID | 错误信息 | +| 401 | Parameter error. | +| 2303104 | Interrupted system call. | +| 2303109 | Bad file number. | +| 2303111 | Resource temporarily unavailable try again. | +| 2303113 | System permission denied. | +| 2303188 | Socket operation on non-socket. | +| 2303191 | Protocol wrong type for socket. | +| 2303198 | Address already in use. | +| 2303199 | Cannot assign requested address. | +| 2303210 | Connection timed out. | +| 2303501 | SSL is null. | +| 2303502 | Error in tls reading. | +| 2303503 | Error in tls writing | +| 2303505 | Error occurred in the tls system call. | +| 2303506 | Error clearing tls connection. | +| 2300002 | System internal error. | + +**示例:** + +```js +let tls = socket.constructTLSSocketInstance(); // Two way authentication +tls.bind({address: '192.168.xxx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}); +let Protocol = socket.Protocol; +let options = { + ALPNProtocols: ["spdy/1", "http/1.1"], + address: { + address: "xxxx", + port: xxxx, + family: 1, + }, + secureOptions: { + key: "xxxx", + cert: "xxxx", + ca: ["xxxx"], + passwd: "xxxx", + protocols: [Protocol.TLSv12], + useRemoteCipherPrefer: true, + signatureAlgorithms: rsa_pss_rsae_sha256:ECDSA+SHA25, + cipherSuite: AES256-SHA256, + }, +}; +tls.connect(options).then(data => { + console.info(data); +}).catch(err => { + console.error(err); +}); + +let tlsOneWay = socket.constructTLSSocketInstance(); // One way authentication +tlsOneWay.bind({address: '192.168.xxx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}); +let oneWayOptions = { + address: { + address: "192.168.xxx.xxx", + port: xxxx, + family: 1, + }, + secureOptions: { + ca: ["xxxx","xxxx"], + cipherSuite: AES256-SHA256, + }, +}; +tlsOneWay.connect(oneWayOptions).then(data => { + console.info(data); +}).catch(err => { + console.error(err); +}); +``` + +### getRemoteAddress9+ + +getRemoteAddress\(callback: AsyncCallback\): void + +在TLSSocket通信连接成功之后,获取对端Socket地址。使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\<[NetAddress](#netaddress)> | 是 | 回调函数。成功返回对端的socket地址,失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303188 | Socket operation on non-socket.| +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getRemoteAddress((err, data) => { + if (err) { + console.log('getRemoteAddress fail'); + return; + } + console.log('getRemoteAddress success:' + JSON.stringify(data)); +}); +``` + +### getRemoteAddress9+ + +getRemoteAddress\(\): Promise\ + +在TLSSocket通信连接成功之后,获取对端Socket地址。使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**返回值:** + +| 类型 | 说明 | +| :------------------------------------------ | :------------------------------------------ | +| Promise\<[NetAddress](#netaddress)> | 以Promise形式返回获取对端socket地址的结果。失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303188 | Socket operation on non-socket.| +| 2300002 | System internal error. | + +**示例:** + +```js +let promise = tls.getRemoteAddress(); +promise.then(() => { + console.log('getRemoteAddress success'); +}).catch(err => { + console.log('getRemoteAddress fail'); +}); +``` + +### getCertificate9+ + +getCertificate(callback: AsyncCallback\<[X509CertRawData](#x509certrawdata9)>): void + +在TLSSocket通信连接成功之后,获取本地的数字证书,该接口只适用于双向认证时,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------| ---- | ---------------| +| callback | AsyncCallback\<[X509CertRawData](#x509certrawdata9)> | 是 | 回调函数,成功返回本地的证书,失败返回错误码,错误信息。| + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2303504 | Error looking up x509. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getCertificate((err, data) => { + if (err) { + console.log("getCertificate callback error = " + err); + } else { + console.log("getCertificate callback = " + data); + } +}); +``` + +### getCertificate9+ + +getCertificate():Promise\<[X509CertRawData](#x509certrawdata9)> + +在TLSSocket通信连接之后,获取本地的数字证书,该接口只适用于双向认证时,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**返回值:** + +| 类型 | 说明 | +| -------------- | -------------------- | +| Promise\<[X509CertRawData](#x509certrawdata9)> | 以Promise形式返回本地的数字证书的结果。失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2303504 | Error looking up x509. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getCertificate().then(data => { + console.info(data); +}).catch(err => { + console.error(err); +}); +``` + +### getRemoteCertificate9+ + +getRemoteCertificate(callback: AsyncCallback\<[X509CertRawData](#x509certrawdata9)>): void + +在TLSSocket通信连接成功之后,获取服务端的数字证书,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------| ---- | ---------------| +| callback | AsyncCallback\<[X509CertRawData](#x509certrawdata9)> | 是 | 回调函数,返回服务端的证书。失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getRemoteCertificate((err, data) => { + if (err) { + console.log("getRemoteCertificate callback error = " + err); + } else { + console.log("getRemoteCertificate callback = " + data); + } +}); +``` + +### getRemoteCertificate9+ + +getRemoteCertificate():Promise\<[X509CertRawData](#x509certrawdata9)> + +在TLSSocket通信连接成功之后,获取服务端的数字证书,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**返回值:** + +| 类型 | 说明 | +| -------------- | -------------------- | +| Promise\<[X509CertRawData](#x509certrawdata9)> | 以Promise形式返回服务端的数字证书的结果。失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getRemoteCertificate().then(data => { + console.info(data); +}).catch(err => { + console.error(err); +}); +``` + +### getProtocol9+ + +getProtocol(callback: AsyncCallback\): void + +在TLSSocket通信连接成功之后,获取通信的协议版本,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------| ---- | ---------------| +| callback | AsyncCallback\ | 是 | 回调函数,返回通信的协议。失败返回错误码,错误信息。| + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2303505 | Error occurred in the tls system call. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getProtocol((err, data) => { + if (err) { + console.log("getProtocol callback error = " + err); + } else { + console.log("getProtocol callback = " + data); + } +}); +``` + +### getProtocol9+ + +getProtocol():Promise\ + +在TLSSocket通信连接成功之后,获取通信的协议版本,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**返回值:** + +| 类型 | 说明 | +| -------------- | -------------------- | +| Promise\ | 以Promise形式返回通信的协议。失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2303505 | Error occurred in the tls system call. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getProtocol().then(data => { + console.info(data); +}).catch(err => { + console.error(err); +}); +``` + +### getCipherSuite9+ + +getCipherSuite(callback: AsyncCallback\>): void + +在TLSSocket通信连接成功之后,获取通信双方协商后的加密套件,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------| ---- | ---------------| +| callback | AsyncCallback\> | 是 | 回调函数,返回通信双方支持的加密套件。 失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2303502 | Error in tls reading. | +| 2303505 | Error occurred in the tls system call. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getCipherSuite((err, data) => { + if (err) { + console.log("getCipherSuite callback error = " + err); + } else { + console.log("getCipherSuite callback = " + data); + } +}); +``` + +### getCipherSuite9+ + +getCipherSuite(): Promise\> + +在TLSSocket通信连接成功之后,获取通信双方协商后的加密套件,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | --------------------- | +| Promise\> | 以Promise形式返回通信双方支持的加密套件。失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2303502 | Error in tls reading. | +| 2303505 | Error occurred in the tls system call. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getCipherSuite().then(data => { + console.info(data); +}).catch(err => { + console.error(err); +}); +``` + +### getSignatureAlgorithms9+ + +getSignatureAlgorithms(callback: AsyncCallback\>): void + +在TLSSocket通信连接成功之后,获取通信双方协商后签名算法,该接口只适配双向认证模式下,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------| ---- | ---------------| +| callback | AsyncCallback\> | 是 | 回调函数,返回双方支持的签名算法。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getSignatureAlgorithms((err, data) => { + if (err) { + console.log("getSignatureAlgorithms callback error = " + err); + } else { + console.log("getSignatureAlgorithms callback = " + data); + } +}); +``` + +### getSignatureAlgorithms9+ + +getSignatureAlgorithms(): Promise\> + +在TLSSocket通信连接成功之后,获取通信双方协商后的签名算法,该接口只适配双向认证模式下,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | -------------------- | +| Promise\> | 以Promise形式返回获取到的双方支持的签名算法。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.getSignatureAlgorithms().then(data => { + console.info(data); +}).catch(err => { + console.error(err); +}); +``` + +### send9+ + +send(data: string, callback: AsyncCallback\): void + +在TLSSocket通信连接成功之后,向服务端发送消息,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -----------------------------| ---- | ---------------| +| data | string | 是 | 发送的数据内容。 | +| callback | AsyncCallback\ | 是 | 回调函数,返回TLSSocket发送数据的结果。失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 401 | Parameter error. | +| 2303501 | SSL is null. | +| 2303503 | Error in tls writing | +| 2303505 | Error occurred in the tls system call. | +| 2303506 | Error clearing tls connection. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.send("xxxx", (err) => { + if (err) { + console.log("send callback error = " + err); + } else { + console.log("send success"); + } +}); +``` + +### send9+ + +send(data: string): Promise\ + +在TLSSocket通信连接成功之后,向服务端发送消息,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -----------------------------| ---- | ---------------| +| data | string | 是 | 发送的数据内容。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 401 | Parameter error. | +| 2303501 | SSL is null. | +| 2303503 | Error in tls writing | +| 2303505 | Error occurred in the tls system call. | +| 2303506 | Error clearing tls connection. | +| 2300002 | System internal error. | + +**返回值:** + +| 类型 | 说明 | +| -------------- | -------------------- | +| Promise\ | 以Promise形式返回,返回TLSSocket发送数据的结果。失败返回错误码,错误信息。 | + +**示例:** + +```js +tls.send("xxxx").then(() =>{ + console.log("send success"); +}).catch(err => { + console.error(err); +}); +``` + +### close9+ + +close(callback: AsyncCallback\): void + +在TLSSocket通信连接成功之后,断开连接,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -----------------------------| ---- | ---------------| +| callback | AsyncCallback\ | 是 | 回调函数,成功返回TLSSocket关闭连接的结果。 失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2303505 | Error occurred in the tls system call. | +| 2303506 | Error clearing tls connection. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.close((err) => { + if (err) { + console.log("close callback error = " + err); + } else { + console.log("close success"); + } +}); +``` + +### close9+ + +close(): Promise\ + +在TLSSocket通信连接成功之后,断开连接,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetStack + +**返回值:** + +| 类型 | 说明 | +| -------------- | -------------------- | +| Promise\ | 以Promise形式返回,返回TLSSocket关闭连接的结果。失败返回错误码,错误信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| 2303501 | SSL is null. | +| 2303505 | Error occurred in the tls system call. | +| 2303506 | Error clearing tls connection. | +| 2300002 | System internal error. | + +**示例:** + +```js +tls.close().then(() =>{ + console.log("close success"); +}).catch(err => { + console.error(err); +}); +``` + +## TLSConnectOptions9+ + +TLS连接的操作。 + +**系统能力**:SystemCapability.Communication.NetStack + +| 参数名 | 类型 | 说明 | +| -------------- | ------------------------------------- | -------------- | +| address | [NetAddress](#netaddress) | 网关地址。 | +| secureOptions | [TLSSecureOptions](#tlssecureoptions9) | TLS安全相关操作。| +| ALPNProtocols | Array\ | ALPN协议。 | + +## TLSSecureOptions9+ + +TLS安全相关操作,其中ca证书为必选参数,其他参数为可选参数。当本地证书cert和私钥key不为空时,开启双向验证模式。cert和key其中一项为空时,开启单向验证模式。 + +**系统能力**:SystemCapability.Communication.NetStack + +| 参数名 | 类型 | 说明 | +| --------------------- | ---------------------- | ----------------------------------- | +| ca | string \| Array\ | 服务端的ca证书,用于认证校验服务端的数字证书。| +| cert | string | 本地客户端的数字证书。 | +| key | string | 本地数字证书的私钥。 | +| passwd | string | 读取私钥的密码。 | +| protocols | [Protocol](#protocol9) \| Array\<[Protocol](#protocol9)> | TLS的协议版本。 | +| useRemoteCipherPrefer | boolean | 优先使用对等方的密码套件。 | +| signatureAlgorithms | string | 通信过程中的签名算法。 | +| cipherSuite | string | 通信过程中的加密套件。 | + +## Protocol9+ + +TLS通信的协议版本。 + +**系统能力**:SystemCapability.Communication.NetStack + +| **protocol 的合法值** | 说明 | +| :------------------ | :------------------ | +| TLSv12 | 使用TLSv1.2协议通信。 | +| TLSv13 | 使用TLSv1.3协议通信。 | + +## X509CertRawData9+ + +存储证书的数据。 + +**系统能力**:SystemCapability.Communication.NetStack + +| 参数名 | 类型 | 说明 | +| -------------- | ----------------------------- | -------------- | +| data | Uint8Array | 证书内容。 | +| encodingFormat | number | 编码格式der。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-stack.md b/zh-cn/application-dev/reference/apis/js-apis-stack.md index 2a43f80c5a865a1be7fd045f1159ecec73b9d3c9..65d45d39c68c7e1ca3c140e833a068052284cd1d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-stack.md +++ b/zh-cn/application-dev/reference/apis/js-apis-stack.md @@ -18,9 +18,6 @@ Stack和[Queue](js-apis-queue.md)相比,Queue基于循环队列实现,只能 import Stack from '@ohos.util.Stack'; ``` - - - ## Stack ### 属性 @@ -52,11 +49,6 @@ Stack的构造函数。 ```ts let stack = new Stack(); -try { - let stack2 = Stack(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -98,11 +90,6 @@ let b = [1, 2, 3]; let result2 = stack.push(b); let c = {name : "Dylon", age : "13"}; let result3 = stack.push(c); -try { - stack.push.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### pop @@ -137,11 +124,6 @@ stack.push(5); stack.push(2); stack.push(4); let result = stack.pop(); -try { - stack.pop.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### peek @@ -175,11 +157,6 @@ stack.push(4); stack.push(5); stack.push(2); let result = stack.peek(); -try { - stack.peek.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### locate @@ -219,11 +196,6 @@ stack.push(4); stack.push(5); stack.push(2); let result = stack.locate(2); -try { - stack.locate.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### forEach @@ -269,13 +241,6 @@ stack.push(4); stack.forEach((value, index) => { console.log("value:" + value, index); }); -try { - stack.forEach.bind({}, (value, index) => { - console.log("value:" + value, index); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### isEmpty @@ -309,11 +274,6 @@ stack.push(4); stack.push(5); stack.push(4); let result = stack.isEmpty(); -try { - stack.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### [Symbol.iterator] @@ -358,9 +318,4 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - stack[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-stationary.md b/zh-cn/application-dev/reference/apis/js-apis-stationary.md new file mode 100644 index 0000000000000000000000000000000000000000..5a87f940e9aa5e54c04da3b09b31555866f5c553 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-stationary.md @@ -0,0 +1,129 @@ +# 设备状态感知框架 + +设备状态感知框架提供设备状态感知能力,包括绝对静止和相对静止。 + +> **说明:** +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import stationary from '@ohos.stationary' +``` + +## ActivityResponse + +服务响应抽象接口。 + +**系统能力** SystemCapability.Msdp.DeviceStatus.Stationary + +### 属性 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| state | [ActivityState](#activitystate) | 是 | 否 | 设备状态变化返回值。 | + +## ActivityType + +设备状态类型。 + +**系统能力** SystemCapability.Msdp.DeviceStatus.Stationary + +| 名称 | 描述 | +| -------- | -------- | +| still | 绝对静止。 | +| relativeStill | 相对静止。 | + +## ActivityEvent + +设备状态事件。 + +**系统能力** SystemCapability.Msdp.DeviceStatus.Stationary + +| 变量 | 值 | 说明 | +| ------------------------------ | ---- | ---------------------------------------- | +| ENTER | 1 | 进入。 | +| EXIT | 2 | 退出。 | +| ENTER_EXIT | 3 | 进入和退出。 | + +## ActivityState + +设备状态返回值。 + +**系统能力** SystemCapability.Msdp.DeviceStatus.Stationary + +| 变量 | 值 | 说明 | +| ------------------------------ | ---- | ---------------------------------------- | +| ENTER | 1 | 进入。 | +| EXIT | 2 | 退出。 | + +## stationary.on('still' | 'relativeStill') + +on(activity: ActivityType, event: ActivityEvent, reportLatencyNs: number, callback: Callback<ActivityResponse>): void + +设备状态管理,订阅设备状态服务。 + +**系统能力** SystemCapability.Msdp.DeviceStatus.Stationary + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------------------- | -------------------------------------------------- | ---- | ---------------------------- | +| activity | [ActivityType](#activitytype) | 是 | 设备状态能力类型。 | +| event | [ActivityEvent](#activityevent) | 是 | 事件类型。 | +| reportLatencyNs | number | 是 | 报告延时。 | +| callback | Callback<[ActivityResponse](#activityresponse)\> | 是 | 回调函数,接收上报状态变化事件。 | + +**示例:** + +```js +var reportLatencyNs = 100; +stationary.on('still', stationary.ActivityEvent.ENTER, reportLatencyNs, (data) => { + console.log('data='+ JSON.stringify(data)); +}) +``` + +## stationary.once('still' | 'relativeStill') + +once(activity: ActivityType, callback: Callback<ActivityResponse>): void + +设备状态管理,查询设备状态。 + +**系统能力** SystemCapability.Msdp.DeviceStatus.Stationary + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------------------- | -------------------------------------------------- | ---- | ---------------------------- | +| activity | [ActivityType](#activitytype) | 是 | 设备状态能力类型。 | +| callback | Callback<[ActivityResponse](#activityresponse)\> | 是 | 回调函数,接收上报状态变化事件。 | + +**示例:** + +```js +stationary.once('still', (data) => { + console.log("data="+ JSON.stringify(data)); +}) +``` + +## stationary.off('still' | 'relativeStill') + +off(activity: ActivityType, event: ActivityEvent, callback?: Callback<ActivityResponse>): void + +设备状态管理,取消订阅设备状态服务。 + +**系统能力** SystemCapability.Msdp.DeviceStatus.Stationary + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------------------- | -------------------------------------------------- | ---- | ---------------------------- | +| activity | [ActivityType](#activitytype) | 是 | 设备状态能力类型。 | +| event | [ActivityEvent](#activityevent) | 是 | 事件类型。 | +| callback | Callback<[ActivityResponse](#activityresponse)\> | 否 | 回调函数,接收上报状态变化事件。 | + +**示例:** + +```js +stationary.off('still', stationary.ActivityEvent.ENTER); +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-capability.md b/zh-cn/application-dev/reference/apis/js-apis-system-capability.md new file mode 100755 index 0000000000000000000000000000000000000000..70b91f50ab52636310a2f5ca9309acd172bb0e0a --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-capability.md @@ -0,0 +1,80 @@ +# 系统能力 + +系统能力(SystemCapability,简称SysCap),指操作系统中每一个相对独立的特性。不同的设备对应不同的系统能力集,每个系统能力对应多个接口。开发者可根据系统能力来判断是否可以使用某接口。本模块提供接口可查询系统能力的集合。 + +> **说明:** +> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 本模块接口为系统接口。 + + +## 导入模块 + +```ts +import systemcapability from '@ohos.systemCapability' +``` + +## systemcapability.querySystemCapabilities + +querySystemCapabilities(callback: AsyncCallback): void; + +获取系统能力集合的字符串,并调用回调函数。 + +**系统能力:** SystemCapability.Developtools.Syscap + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback | 是 | 回调函数 | + + +**示例:** + +```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<string> + +获取系统能力的集合。 + +**系统能力:** SystemCapability.Startup.SystemInfo + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<string> | 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集合形式均为编码后的数字字符串形式。 + + diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-location.md b/zh-cn/application-dev/reference/apis/js-apis-system-location.md index 83b262dc2a9bfce4615c4bd94011ed0a31bda858..2443d76ceabbf54ef932fa2b3736b69106824cbe 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-location.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-location.md @@ -1,8 +1,9 @@ # 地理位置 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.geolocation`](js-apis-geolocation.md)。 +> > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> - 从API Version 9开始,该接口不再维护,推荐使用新接口[geoLocationManager](js-apis-geoLocationManager.md)。 ## 导入模块 @@ -18,15 +19,12 @@ import geolocation from '@system.geolocation'; ohos.permission.LOCATION -## geolocation.getLocation(deprecated) +## geolocation.getLocation getLocation(Object): void 获取设备的地理位置。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation)替代。 - **系统能力:** SystemCapability.Location.Location.Lite **参数:** @@ -77,15 +75,12 @@ export default { ``` -## geolocation.getLocationType(deprecated) +## geolocation.getLocationType getLocationType(Object): void 获取当前设备支持的定位类型。 -> **说明:**
-> 从API version 9开始废弃。 - **系统能力:** SystemCapability.Location.Location.Lite **参数:** @@ -120,15 +115,12 @@ export default { ``` -## geolocation.subscribe(deprecated) +## geolocation.subscribe subscribe(Object): void 订阅设备的地理位置信息。多次调用的话,只有最后一次的调用生效。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange)替代。 - **系统能力:** SystemCapability.Location.Location.Lite **参数:** @@ -175,15 +167,12 @@ export default { ``` -## geolocation.unsubscribe(deprecated) +## geolocation.unsubscribe unsubscribe(): void 取消订阅设备的地理位置信息。 -> **说明:**
-> 从API version 9开始废弃,建议使用[geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange)替代。 - **系统能力:** SystemCapability.Location.Location.Lite **示例:** @@ -197,15 +186,12 @@ export default { ``` -## geolocation.getSupportedCoordTypes(deprecated) +## geolocation.getSupportedCoordTypes getSupportedCoordTypes(): Array<string> 获取设备支持的坐标系类型。 -> **说明:**
-> 从API version 9开始废弃。 - **系统能力:** SystemCapability.Location.Location.Lite **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md b/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md index f7c9679d6a4b8cd6d845663edd48a1b64cab4c8f..9d5f8318a4d88ea2e86fe9cf54e300bfa8ca9784 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @@ -164,7 +164,7 @@ setSync(key: string, value: string): void > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 此接口只能用于系统应用的参数设置。 -> - 所授权的系统应用需要配置对应selinux和dac规则,具体配置方法请参照系统参数指导文档:[系统参数](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-boot-init-sysparam.md)。 +> - 所授权的系统应用需要配置对应selinux和dac规则,具体配置方法请参照系统参数指导文档:[系统参数](../../../device-dev/subsystems/subsys-boot-init-sysparam.md)。 **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-time.md index d71b6e72fbadc966cd6a51bbc42658513da0b96d..fbb25a8b6f8145c3b22454b76f8da999ed12a826 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-time.md @@ -453,7 +453,7 @@ setTimezone(timezone: string, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | -------------------------- | -| timezone | string | 是 | 系统时区。 | +| timezone | string | 是 | 系统时区。 具体可见[支持的系统时区](#支持的系统时区) 。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** @@ -482,7 +482,7 @@ setTimezone(timezone: string): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ---------- | -| timezone | string | 是 | 系统时区。 | +| timezone | string | 是 | 系统时区。具体可见[支持的系统时区](#支持的系统时区) 。 | **返回值:** @@ -512,7 +512,7 @@ getTimezone(callback: AsyncCallback<string>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------- | ---- | ------------------------ | -| callback | AsyncCallback<string> | 是 | 回调函数,返回系统时区。 | +| callback | AsyncCallback<string> | 是 | 回调函数,返回系统时区。具体可见[支持的系统时区](#支持的系统时区) 。 | **示例:** @@ -538,7 +538,7 @@ getTimezone(): Promise<string> | 类型 | 说明 | | --------------------- | ------------------------------------- | -| Promise<string> | Promise对象,返回系统时区。 | +| Promise<string> | Promise对象,返回系统时区。具体可见[支持的系统时区](#支持的系统时区) 。 | **示例:** @@ -548,4 +548,42 @@ systemTime.getTimezone().then((data) => { }).catch((error) => { console.error(`Failed to get system time zone. Cause:` + JSON.stringify(error)); }); -``` \ No newline at end of file +``` + +## 支持的系统时区 + +支持的系统时区及各时区与0时区相比的偏移量(单位:h)可见下表。 + +| 时区 | 偏移量 | +| ------------------------------ | --------------------- | +| Antarctica/McMurdo | 12 | +| America/Argentina/Buenos_Aires | -3 | +| Australia/Sydney | 10 | +| America/Noronha | -2 | +| America/St_Johns | -3 | +| Africa/Kinshasa | 1 | +| America/Santiago | -3 | +| Asia/Shanghai | 8 | +| Asia/Nicosia | 3 | +| Europe/Berlin | 2 | +| America/Guayaquil | -5 | +| Europe/Madrid | 2 | +| Pacific/Pohnpei | 11 | +| America/Godthab | -2 | +| Asia/Jakarta | 7 | +| Pacific/Tarawa | 12 | +| Asia/Almaty | 6 | +| Pacific/Majuro | 12 | +| Asia/Ulaanbaatar | 8 | +| America/Mexico_City | -5 | +| Asia/Kuala_Lumpur | 8 | +| Pacific/Auckland | 12 | +| Pacific/Tahiti | -10 | +| Pacific/Port_Moresby | 10 | +| Asia/Gaza | 3 | +| Europe/Lisbon | 1 | +| Europe/Moscow | 3 | +| Europe/Kiev | 3 | +| Pacific/Wake | 12 | +| America/New_York | -4 | +| Asia/Tashkent | 5 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-timer.md b/zh-cn/application-dev/reference/apis/js-apis-system-timer.md index 1b49b914013f57b423f316c6bbcbab3b1b2b4da7..ddb0a5d148e2f6dd72b8db7158f3396fd8297771 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-timer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-timer.md @@ -2,336 +2,356 @@ 本模块主要由系统定时器功能组成。开发者可以使用定时功能实现定时服务,如闹钟等。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** ->- 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ->- 本模块接口为系统接口,三方应用不支持调用。 +> **说明:** +> +> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 本模块接口为系统接口。 ## 导入模块 -``` +```js import systemTimer from '@ohos.systemTimer'; ``` +## 常量 + +支持创建的定时器类型。 + +| 名称 | 类型 | 值 | 说明 | +| ------------------- | ------ | ---- | ---------------------------- | +| TIMER_TYPE_REALTIME | number | 1 | 系统启动时间定时器。(定时器启动时间不能晚于当前设置的系统时间) | +| TIMER_TYPE_WAKEUP | number | 2 | 唤醒定时器。 | +| TIMER_TYPE_EXACT | number | 4 | 精准定时器。 | +| TIMER_TYPE_IDLE | number | 8 | IDLE模式定时器(暂不支持)。 | + + ## TimerOptions + +创建系统定时器的初始化选项。 + +**系统能力:** SystemCapability.MiscServices.Time + +| 名称 | 类型 | 必填 | 说明 | +| --------- | --------------------------------- | ---- | ------------------------------------------------------------ | +| type | number | 是 | 定时器类型。
取值为1时,表示为系统启动时间定时器(定时器启动时间不能晚于当前设置的系统时间) ;
取值为2时,表示为唤醒定时器;
取值为4时,表示为精准定时器;
取值为5时,表示为IDLE模式定时器(暂不支持)。 | +| repeat | boolean | 是 | true为循环定时器,false为单次定时器。 | +| interval | number | 否 | 如果是循环定时器,repeat值应大于5000毫秒,非重复定时器置为0。 | +| wantAgent | [WantAgent](js-apis-wantAgent.md) | 否 | 设置通知的WantAgent,定时器到期后通知。(支持拉起应用MainAbility,暂不支持拉起ServiceAbility。) | +| callback | number | 是 | 以回调函数的形式返回定时器的ID。 | + ## systemTimer.createTimer createTimer(options: TimerOptions, callback: AsyncCallback<number>): void -创建定时器。 +创建定时器,使用callback异步回调。 **系统能力:** SystemCapability.MiscServices.Time **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------- | ---------------------------------| ---- | --------------------------------------------------------------------------- | -| options | [TimerOptions](#timeroptions) | 是 | 创建系统定时器,包括定时器类型,是否循环触发,间隔时间,WantAgent通知机制。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------------- | ------------------------------------------------------------ | -| syncCallback<number>| 以回调函数的形式返回定时器的ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------- | ---- | ------------------------------------------------------------ | +| options | [TimerOptions](#timeroptions) | 是 | 创建系统定时器的初始化选项,包括定时器类型、是否循环触发、间隔时间、WantAgent通知机制等。 | +| callback | AsyncCallback<number> | 是 | 回调函数,返回定时器的ID。 | **示例:** - ```js +```js export default { systemTimer () { - var options = { + let options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat: false - } + }; systemTimer.createTimer(options, (error, data) => { if (error) { - console.error(`failed to systemTime.createTimer ` + JSON.stringify(error)); + console.error(`Failed to create timer. Cause:` + JSON.stringify(error)); return; } - console.log(`systemTime.createTimer success data : ` + JSON.stringify(data)); + console.log(`Succeeded in creating timer. Data:` + JSON.stringify(data)); }); } } - ``` - +``` ## systemTimer.createTimer createTimer(options: TimerOptions): Promise<number> -创建定时器。 +创建定时器,使用Promise异步回调。 **系统能力:** SystemCapability.MiscServices.Time **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------- | ---------------------------------| ---- | --------------------------------------------------------------------------- | -| options | [TimerOptions](#timeroptions) | 是 | 创建系统定时器,包括定时器类型,是否循环触发,间隔时间,WantAgent通知机制。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------- | ---- | ------------------------------------------------------------ | +| options | [TimerOptions](#timeroptions) | 是 | 创建系统定时器的初始化选项,包括定时器类型、是否循环触发、间隔时间、WantAgent通知机制等。 | **返回值:** -| 类型 | 说明 | -| --------------------- | ------------------------------------------------------------ | -| Promise<number> | 以Promise形式返回定时器的ID。 | +| 类型 | 说明 | +| --------------------- | ----------------------------- | +| Promise<number> | Promise对象,返回定时器的ID。 | **示例:** - ```js +```js export default { systemTimer () { - var options = { + let options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false - } + }; systemTimer.createTimer(options).then((data) => { - console.log(`systemTime.createTimer success data : ` + JSON.stringify(data)); + console.log(`Succeeded in creating timer. Data:` + JSON.stringify(data)); }).catch((error) => { - console.error(`failed to systemTime.createTimer because ` + JSON.stringify(error)); + console.error(`Failed to create timer. Cause:` + JSON.stringify(error)); }); } } - ``` - +``` ## systemTimer.startTimer startTimer(timer: number, triggerTime: number, callback: AsyncCallback<void>): void -开始定时器。 +开始定时器,使用callback异步回调。 **系统能力:** SystemCapability.MiscServices.Time **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | -| timer | number | 是 | 定时器的ID。 | -| triggerTime | number | 是 | 定时器的触发时间,单位:毫秒。 | - +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ---------------------- | ---- | ------------------------------ | +| timer | number | 是 | 定时器的ID。 | +| triggerTime | number | 是 | 定时器的触发时间,单位:毫秒。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** - ```js +```js export default { async systemTimer () { - var options = { + let options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false } - let timerId = await systemTimer.createTimer(options) - let triggerTime = new Date().getTime() - triggerTime += 3000 - systemTimer.startTimer(timerId, triggerTime, (error, data) => { - if (error) { - console.error(`failed to systemTime.startTimer ` + JSON.stringify(error)); - return; - } - console.log(`systemTime.startTimer success data : ` + JSON.stringify(data)); - }); + let timerId = await systemTimer.createTimer(options) + let triggerTime = new Date().getTime() + triggerTime += 3000 + systemTimer.startTimer(timerId, triggerTime, (error, data) => { + if (error) { + console.error(`Failed to start timer. Cause:` + JSON.stringify(error)); + return; + } + console.log(`Succeeded in startting timer. Data:` + JSON.stringify(data)); + }); } } - ``` +``` ## systemTimer.startTimer startTimer(timer: number, triggerTime: number): Promise<void> -开始定时器。 +开始定时器,使用Promise异步回调。 **系统能力:** SystemCapability.MiscServices.Time **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | -| timer | number | 是 | 定时器的ID。 -| triggerTime | number | 是 | 定时器的触发时间,单位:毫秒。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------ | ---- | ------------------------------ | +| timer | number | 是 | 定时器的ID。 | +| triggerTime | number | 是 | 定时器的触发时间,单位:毫秒。 | +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | 无返回结果的Promise对象。 | **示例:** - ```js +```js export default { async systemTimer (){ - var options = { + let options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false } let timerId = await systemTimer.createTimer(options) - let triggerTime = new Date().getTime() + let triggerTime = new Date().getTime() triggerTime += 3000 systemTimer.startTimer(timerId, triggerTime).then((data) => { - console.log(`systemTime.startTimer success data : ` + JSON.stringify(data)); + console.log(`Succeeded in startting timer. Data:` + JSON.stringify(data)); }).catch((error) => { - console.error(`failed to systemTime.startTimer because ` + JSON.stringify(error)); + console.error(`Failed to start timer. Cause:` + JSON.stringify(error)); }); } } - ``` - +``` ## systemTimer.stopTimer stopTimer(timer: number, callback: AsyncCallback<void>): void -停止定时器。 +停止定时器,使用callback异步回调。 **系统能力:** SystemCapability.MiscServices.Time **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| timer | number | 是 | 定时器的ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------ | +| timer | number | 是 | 定时器的ID。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** - ```js +```js export default { - async systemTimer () { - var options = { - type: systemTimer.TIMER_TYPE_REALTIME, - repeat:false - } - let timerId = await systemTimer.createTimer(options) - let triggerTime = new Date().getTime() - triggerTime += 3000 - systemTimer.startTimer(timerId, triggerTime) - systemTimer.stopTimer(timerId, (error) => { - if (error) { - console.error(`failed to systemTime.startTimer ` + JSON.stringify(error)); - return; - } - }); - } + async systemTimer () { + let options = { + type: systemTimer.TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = await systemTimer.createTimer(options) + let triggerTime = new Date().getTime() + triggerTime += 3000 + systemTimer.startTimer(timerId, triggerTime) + systemTimer.stopTimer(timerId, (error) => { + if (error) { + console.error(`Failed to stop timer. Cause:` + JSON.stringify(error)); + return; + } + }); + } } - ``` - +``` ## systemTimer.stopTimer stopTimer(timer: number): Promise<void> -停止定时器。 +停止定时器,使用Promise异步回调。 **系统能力:** SystemCapability.MiscServices.Time **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------- | ---- | ------------------------------------------------------------ | -| timer | number | 是 | 定时器的ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------ | +| timer | number | 是 | 定时器的ID。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | 无返回结果的Promise对象。 | **示例:** - ```js +```js export default { - async systemTimer (){ - var options = { - type: systemTimer.TIMER_TYPE_REALTIME, - repeat:false - } - let timerId = await systemTimer.createTimer(options) - let triggerTime = new Date().getTime() - triggerTime += 3000 - systemTimer.startTimer(timerId, triggerTime) - systemTimer.stopTimer(timerId).then((data) => { - console.log(`systemTime.startTimer success data : ` + JSON.stringify(data)); - }).catch((error) => { - console.error(`failed to systemTime.startTimer because ` + JSON.stringify(error)); - }); - } + async systemTimer (){ + let options = { + type: systemTimer.TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = await systemTimer.createTimer(options) + let triggerTime = new Date().getTime() + triggerTime += 3000 + systemTimer.startTimer(timerId, triggerTime) + systemTimer.stopTimer(timerId).then((data) => { + console.log(`Succeeded in stopping timer. Data:` + JSON.stringify(data)); + }).catch((error) => { + console.error(`Failed to stop timer. Cause:` + JSON.stringify(error)); + }); + } } - ``` - +``` ## systemTimer.destroyTimer destroyTimer(timer: number, callback: AsyncCallback<void>): void -销毁定时器。 +销毁定时器,使用callback异步回调。 **系统能力:** SystemCapability.MiscServices.Time **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| timer | number | 是 | 定时器的ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------ | +| timer | number | 是 | 定时器的ID。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** - ```js +```js export default { async systemTimer () { - var options = { + let options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false } let timerId = await systemTimer.createTimer(options) - let triggerTime = new Date().getTime() + let triggerTime = new Date().getTime() triggerTime += 3000 systemTimer.startTimer(timerId, triggerTime) systemTimer.stopTimer(timerId) systemTimer.destroyTimer(timerId, (error) => { if (error) { - console.error(`failed to systemTime.startTimer ` + JSON.stringify(error)); + console.error(`Failed to destroy timer. Cause:` + JSON.stringify(error)); return; } }); } } - ``` - +``` ## systemTimer.destroyTimer destroyTimer(timer: number): Promise<void> -销毁定时器。 +销毁定时器,使用Promise异步回调。 **系统能力:** SystemCapability.MiscServices.Time **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------- | ---- | ------------------------------------------------------------ | -| timer | number | 是 | 定时器的ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------ | +| timer | number | 是 | 定时器的ID。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | 无返回结果的Promise对象。 | **示例:** - ```js +```js export default { async systemTimer (){ - var options = { + let options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false } let timerId = await systemTimer.createTimer(options) - let triggerTime = new Date().getTime() + let triggerTime = new Date().getTime() triggerTime += 3000 systemTimer.startTimer(timerId, triggerTime) systemTimer.stopTimer(timerId) systemTimer.destroyTimer(timerId, 10000).then((data) => { - console.log(`systemTime.startTimer success data : ` + JSON.stringify(data)); + console.log(`Succeeded in destroying timer. Data:` + JSON.stringify(data)); }).catch((error) => { - console.error(`failed to systemTime.startTimer because ` + JSON.stringify(error)); + console.error(`Failed to destroy timer. Cause:` + JSON.stringify(error)); }); } } - ``` - - ## TimerOptions - -createTimer的初始化选项。 - -**系统能力:** SystemCapability.MiscServices.Time - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------| ---- | ------------------------------------------------------------------------------------------------------------------------- | -| type | number | 是 | const TIMER_TYPE_REALTIME: 设置为系统启动时间定时器(当设置系统时间超过定时器启动时间,定时器则失效),否则为walltime定时器;
const TIMER_TYPE_WAKEUP: 设置为唤醒定时器,否则为非唤醒;
const TIMER_TYPE_EXACT: 设置为精准定时器,否则为非精准定时器;
const TIMER_TYPE_IDLE: number: 设置为IDLE模式定时器,否则为非IDLE模式定时器(暂不支持) | -| repeat | boolean | 是 | true 为循环定时器,false为单次定时器。 | -| interval | number | 否 | 如果是循环定时器,repeat值应大于5000毫秒,非重复定时器置为0。 | -| wantAgent| wantAgent | 否 | 设置通知的wantagent,定时器到期后通知。(支持拉起应用MainAbility,暂不支持拉起ServiceAbility) | -| callback | number | 是 | 以回调函数的形式返回定时器的ID | \ No newline at end of file +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-tagSession.md b/zh-cn/application-dev/reference/apis/js-apis-tagSession.md index 7196bcf24b46dc61da69642ef1178a1cfb897c13..57b6709752bd6205ce94483c536522b481f4d095 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-tagSession.md +++ b/zh-cn/application-dev/reference/apis/js-apis-tagSession.md @@ -30,18 +30,20 @@ getTagInfo(): tag.TagInfo **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | TagInfo | NFC服务所提供的Tag数据对象。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; // see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched. // the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ... -let tagInfo = tag.getXXX(tagInfo).getTagInfo(); +let tagInfo = tag.getIsoDep(tagInfo).getTagInfo(); console.log("tag tagInfo: " + tagInfo); ``` @@ -56,18 +58,20 @@ connectTag(): boolean; **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | boolean | 连接建立成功返回true,失败返回false。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; // see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched. // the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ... -let connectStatus = tag.getXXX(tagInfo).connectTag(); +let connectStatus = tag.getIsoDep(tagInfo).connectTag(); console.log("connectStatus: " + connectStatus); ``` @@ -82,13 +86,14 @@ reset(): void **系统能力**:SystemCapability.Communication.NFC.Core **示例:** + ```js import tag from '@ohos.nfc.tag'; // see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched. // the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ... -tag.getXXX(tagInfo).reset(); +tag.getIsoDep(tagInfo).reset(); ``` ### tagSession.isTagConnected @@ -102,18 +107,20 @@ isTagConnected(): boolean **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | boolean | 已建立连接返回 true,未建立连接返回false。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; // see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched. // the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ... -let isTagConnected = tag.getXXX(tagInfo).isTagConnected(); +let isTagConnected = tag.getIsoDep(tagInfo).isTagConnected(); console.log("isTagConnected: " + isTagConnected); ``` @@ -128,6 +135,7 @@ getMaxSendLength(): number **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | number | 可以发送到标签的最大数据长度,非负数。 | @@ -139,7 +147,7 @@ import tag from '@ohos.nfc.tag'; // see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched. // the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ... -let maxSendLen = tag.getXXX(tagInfo).getMaxSendLength(); +let maxSendLen = tag.getIsoDep(tagInfo).getMaxSendLength(); console.log("tag maxSendLen: " + maxSendLen); ``` @@ -154,18 +162,20 @@ getSendDataTimeout(): number **系统能力**:SystemCapability.Communication.NFC.Core **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | number | 发送数据到Tag的等待超时时间,单位是毫秒,非负数。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; // see 'tag.TagInfo' at 'js-apis-nfcTag.md', tagInfo is an Object given by nfc service when tag is dispatched. // the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ... -let sendDataTimeout = tag.getXXX(tagInfo).getSendDataTimeout(); +let sendDataTimeout = tag.getIsoDep(tagInfo).getSendDataTimeout(); console.log("tag sendDataTimeout: " + sendDataTimeout); ``` @@ -180,11 +190,13 @@ setSendDataTimeout(timeout: number): boolean **系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | timeout | number | 是 | 超时时间,单位毫秒,非负值。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | boolean | 设置超时时间成功返回true,设置失败返回false。 | @@ -198,7 +210,7 @@ import tag from '@ohos.nfc.tag'; // the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ... let timeoutMs = 700; // change it to be correct. -let setStatus = tag.getXXX(tagInfo).setSendDataTimeout(timeoutMs); +let setStatus = tag.getIsoDep(tagInfo).setSendDataTimeout(timeoutMs); console.log("tag setSendDataTimeout setStatus: " + setStatus); ``` @@ -210,19 +222,22 @@ sendData(data: number[]): Promise **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | data | number[] | 是 | 要发送的指令。每个number十六进制表示,范围是0x00~0xFF。 | **返回值:** + | **类型** | **说明** | | ------------------ | --------------------------| | Promise | 对端Tag对指令的响应数据。每个number十六进制表示,范围是0x00~0xFF。| **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -230,15 +245,15 @@ import tag from '@ohos.nfc.tag'; // the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ... // connect the tag at first if not connected. -if (!tag.getXXX(tagInfo).isTagConnected()) { - if (!tag.getXXX(tagInfo).connectTag()) { +if (!tag.getIsoDep(tagInfo).isTagConnected()) { + if (!tag.getIsoDep(tagInfo).connectTag()) { console.log("tagSession connectTag failed."); return; } } -let cmdData = [0x01, 0x02, ...]; // change the raw data to be correct. -tag.getXXX(tagInfo).sendData(cmdData).then((response) => { +let cmdData = [0x01, 0x02, 0x03, 0x04]; // change the raw data to be correct. +tag.getIsoDep(tagInfo).sendData(cmdData).then((response) => { console.log("tagSession sendData Promise response: " + response); }).catch((err)=> { console.log("tagSession sendData Promise err: " + err); @@ -253,15 +268,17 @@ sendData(data: number[], callback: AsyncCallback): void **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | data | number[] | 是 | 要发送的指令。每个number十六进制表示,范围是0x00~0xFF。 | | callback | AsyncCallback | 是 | 回调函数,返回响应数据。每个number十六进制表示,范围是0x00~0xFF。 | **示例:** + ```js import tag from '@ohos.nfc.tag'; @@ -269,15 +286,15 @@ import tag from '@ohos.nfc.tag'; // the folowing getXXX, can be one of getIsoDep, getNdef, getMifareClassic, ... // connect the tag at first if not connected. -if (!tag.getXXX(tagInfo).isTagConnected()) { - if (!tag.getXXX(tagInfo).connectTag()) { +if (!tag.getIsoDep(tagInfo).isTagConnected()) { + if (!tag.getIsoDep(tagInfo).connectTag()) { console.log("tagSession connectTag failed."); return; } } -let cmdData = [0x01, 0x02, ...]; // change the raw data to be correct. -tag.getXXX(tagInfo).sendData(cmdData, (err, response)=> { +let cmdData = [0x01, 0x02, 0x03, 0x04]; // change the raw data to be correct. +tag.getIsoDep(tagInfo).sendData(cmdData, (err, response)=> { if (err) { console.log("tagSession sendData AsyncCallback err: " + err); } else { diff --git a/zh-cn/application-dev/reference/apis/js-apis-tlsSocket.md b/zh-cn/application-dev/reference/apis/js-apis-tlsSocket.md deleted file mode 100644 index 3d20d8473bf82661aeb2c21002d87723b9ac1b4c..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-tlsSocket.md +++ /dev/null @@ -1,486 +0,0 @@ -# TLSSocket - -TLS Socket通信是对Socket通信的拓展。在Socket通信的基础上添加了一层安全性保护,提供了更高的安全性,分为三个子模块,包括密钥,证书,通信。 - -> **说明:** -> -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## 导入模块 - -```js -import socket from '@ohos.net.tlssocket' -``` - -## socket.constructTLSSocketInstance - -constructTLSSocketInstance(): TLSSocket - -创建并返回一个TLSSocket对象。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**示例:** - -```js -let tlssocket = socket.constructTLSSocketInstance(); -``` - -## tlssocket.connect - -connect(options: TLSConnectOptions, callback: AsyncCallback\): void - -在TLSSocket上进行通信连接,并创建和初始化TLS会话,实现建立连接过程,启动与服务器的TLS/SSL握手,实现数据传输功能,使用callback方式作为异步方法。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------| ----| --------------- | -| options | [TLSConnectOptions](#tlsconnectoptions) | 是 | 连接所需要的参数。| -| callback | AsyncCallback\ | 是 | 回调函数,成功无返回,失败返回对应错误码。 | - -**示例:** - -```js -let options = { - ALPNProtocols: ["spdy/1", "http/1.1"], - address: { - address: "xxx", - port: "xxxx", - family: 1, - }, - secureOptions: { - key: "xxxx", - cert: "xxxx", - ca: ["xxxx"], - passwd: "xxxx", - protocols: "TlsV1_2", - useRemoteCipherPrefer: true, - signatureAlgorithms: SHA256, - cipherSuites: AES256-SHA256, - }, -}; - -tlssocket.connect(options, (err, data) => { - console.info(err); - console.info(data); -}); -``` - -## tlssocket.connect - -connect(options: TLSConnectOptions): Promise\; - -在TLSSocket上进行通信连接,并创建和初始化TLS会话,实现建立连接过程,启动与服务器的TLS/SSL握手,实现数据传输功能,使用Promise方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------| ----| --------------- | -| options | [TLSConnectOptions](#tlsconnectoptions) | 是 | 连接所需要的参数。| - -**返回值:** - -| 类型 | 说明 | -| ------------------------------------------- | ----------------------------- | -| Promise\ | 以Promise形式返回,成功无返回,失败返回对应错误码。 | - -**示例:** - -```js -let options = { - ALPNProtocols: ["spdy/1", "http/1.1"], - address: { - address: "xxxx", - port: "xxxx", - family: 1, - }, - secureOptions: { - key: "xxxx", - cert: "xxxx", - ca: ["xxxx"], - passwd: "xxxx", - protocols: "TlsV1_2", - useRemoteCipherPrefer: true, - signatureAlgorithms: SHA256, - cipherSuites: AES256-SHA256, - }, -}; - -tlssocket.connect(options).then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.getCertificate - -getCertificate(callback: AsyncCallback\): void; - -在TLSSocket通信连接之后,获取本地的数字证书,使用callback方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------| ---- | ---------------| -| callback | AsyncCallback\ | 是 | 回调函数,返回本地的证书。| - -**示例:** - -```js -tlssocket.getCertificate((err, data) => { - if (err) { - console.log("getCertificate callback error = " + err); - } else { - console.log("getCertificate callback = " + data); - } -}); -``` - -## tlssocket.getCertificate - -getCertificate():Promise\; - -在TLSSocket通信连接之后,获取本地的数字证书,使用Promise方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**返回值:** - -| 类型 | 说明 | -| -------------- | -------------------- | -| Promise\ | 以Promise形式返回本地的数字证书。 | - -**示例:** - -```js -tlssocket.getCertificate().then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.getRemoteCertificate - -getRemoteCertificate(callback: AsyncCallback\): void; - -在TLSSocket通信连接之后,获取对等方的数字证书,使用callback方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------| ---- | ---------------| -| callback | AsyncCallback\ | 是 | 回调函数,返回对等方的证书。 | - -**示例:** - -```js -tlssocket.getRemoteCertificate((err, data) => { - if (err) { - console.log("getRemoteCertificate callback error = " + err); - } else { - console.log("getRemoteCertificate callback = " + data); - } -}); -``` - -## tlssocket.getRemoteCertificate - -getRemoteCertificate():Promise\; - -在TLSSocket通信连接之后,获取对等方的数字证书,使用Promise方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**返回值:** - -| 类型 | 说明 | -| -------------- | -------------------- | -| Promise\ | 以Promise形式返回对等方的数字证书。 | - -**示例:** - -```js -tlssocket.getRemoteCertificate().then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.getProtocol - -getProtocol(callback: AsyncCallback\): void; - -在TLSSocket通信连接之后,获取通信的协议,使用callback方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------| ---- | ---------------| -| callback | AsyncCallback\ | 是 | 回调函数,返回通信的协议。 | - -**示例:** - -```js -tlssocket.getProtocol((err, data) => { - if (err) { - console.log("getProtocol callback error = " + err); - } else { - console.log("getProtocol callback = " + data); - } -}); -``` - -## tlssocket.getProtocol - -getProtocol():Promise\; - -在TLSSocket通信连接之后,获取通信的协议,使用Promise方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**返回值:** - -| 类型 | 说明 | -| -------------- | -------------------- | -| Promise\ | 以Promise形式返回通信的协议。 | - -**示例:** - -```js -tlssocket.getProtocol().then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.getCipherSuites - -getCipherSuites(callback: AsyncCallback\>): void; - -在TLSSocket通信连接之后,获取通信双方支持的加密套件,使用callback方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------| ---- | ---------------| -| callback | AsyncCallback\> | 是 | 回调函数,返回通信双方支持的加密套件。 | - -**示例:** - -```js -tlssocket.getCipherSuites((err, data) => { - if (err) { - console.log("getCipherSuites callback error = " + err); - } else { - console.log("getCipherSuites callback = " + data); - } -}); -``` - -## tlssocket.getCipherSuites - -getCipherSuites(): Promise\>; - -在TLSSocket通信连接之后,获取通信双方支持的加密套件,使用Promise方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**返回值:** - -| 类型 | 说明 | -| ---------------------- | --------------------- | -| Promise\> | 以Promise形式返回通信双方支持的加密套件。 | - -**示例:** - -```js -tlssocket.getCipherSuites().then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.getSignatureAlgorithms - -getSignatureAlgorithms(callback: AsyncCallback\>): void; - -在TLSSocket通信连接之后,获取通信双方支持的签名算法,使用callback方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------| ---- | ---------------| -| callback | AsyncCallback\> | 是 | 回调函数,返回双方支持的签名算法。 | - -**示例:** - -```js -tlssocket.getSignatureAlgorithms((err, data) => { - if (err) { - console.log("getSignatureAlgorithms callback error = " + err); - } else { - console.log("getSignatureAlgorithms callback = " + data); - } -}); -``` - -## tlssocket.getSignatureAlgorithms - -getSignatureAlgorithms(): Promise\>; - -在TLSSocket通信连接之后,获取通信双方支持的签名算法,使用Promise方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**返回值:** - -| 类型 | 说明 | -| ---------------------- | -------------------- | -| Promise\> | 以Promise形式返回获取到的双方支持的签名算法。 | - -**示例:** - -```js -tlssocket.getSignatureAlgorithms().then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.close - -close(callback: AsyncCallback\): void; - -在TLSSocket通信连接之后,断开连接,使用callback方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -----------------------------| ---- | ---------------| -| callback | AsyncCallback\ | 是 | 回调函数,返回TLSSocket关闭连接的结果。 | - -**示例:** - -```js -tlssocket.close((err) => { - if (err) { - console.log("close callback error = " + err); - } else { - console.log("close success"); - } -}); -``` - -## tlssocket.close - -close(): Promise\; - -在TLSSocket通信连接之后,断开连接,使用Promise方式作为异步方法。 - -**需要权限**:ohos.permission.INTERNET - -**系统能力**:SystemCapability.Communication.NetStack - -**返回值:** - -| 类型 | 说明 | -| -------------- | -------------------- | -| Promise\ | 以Promise形式返回,返回TLSSocket关闭连接的结果。 | - -**示例:** - -```js -tlssocket.close().then(() => - console.log("close success"); -}).catch(err => { - console.error(err); -}); -``` - -## TLSConnectOptions - -TLS连接的操作。 - -**系统能力**:SystemCapability.Communication.NetStack - -| 参数名 | 类型 | 说明 | -| -------------- | ------------------------------------- | -------------- | -| address | [NetAddress](#netaddress) | 网关地址。 | -| secureOptions | [TLSSecureOptions](#tlssecureoptions) | TLS安全相关操作。| -| ALPNProtocols | Array\ | ALPN协议。 | - -## NetAddress - -网络地址。 - -**系统能力**:SystemCapability.Communication.NetStack - -| 参数名 | 类型 | 说明 | -| ------- | ------ | ---------------------------- | -| address | string | 地址。 | -| family | number | IPv4 = 1,IPv6 = 2,默认IPv4。 | -| port | number | 端口,取值范围\[0, 65535]。 | - -## TLSSecureOptions - -TLS安全相关操作。 - -**系统能力**:SystemCapability.Communication.NetStack - -| 参数名 | 类型 | 说明 | -| --------------------- | ---------------------- | ---------------------- | -| ca | string \| Array\ | ca证书。 | -| cert | string | 本地数字证书。 | -| key | string | 本地数字证书私钥。 | -| passwd | string | 密码。 | -| protocols | string | 协议名。 | -| useRemoteCipherPrefer | boolean | 优先使用对等方的密码套件。 | -| signatureAlgorithms | string | 设置签名算法。 | -| cipherSuites | string | 加密套件。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-touchevent.md b/zh-cn/application-dev/reference/apis/js-apis-touchevent.md index 403cf5e7cecd370115bcca1b707e2722a05fac38..be251953ec7c26b96c4d40695ee007d341c91256 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-touchevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-touchevent.md @@ -16,37 +16,37 @@ import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------ | ------ | ---- | ---- | ---- | -| CANCEL | number | 是 | 否 | 触摸取消 | -| DOWN | number | 是 | 否 | 触摸按下 | -| MOVE | number | 是 | 否 | 触摸移动 | -| UP | number | 是 | 否 | 触摸抬起 | +| 名称 | 值 | 说明 | +| ------ | ------ | ---- | +| CANCEL | 0 | 触摸取消 | +| DOWN | 1 | 触摸按下 | +| MOVE | 2 | 触摸移动 | +| UP | 3 | 触摸抬起 | ## ToolType **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------- | ------ | ---- | ---- | ---- | -| FINGER | number | 是 | 否 | 手指 | -| PEN | number | 是 | 否 | 笔 | -| RUBBER | number | 是 | 否 | 橡皮擦 | -| BRUSH | number | 是 | 否 | 笔刷 | -| PENCIL | number | 是 | 否 | 铅笔 | -| AIRBRUSH | number | 是 | 否 | 气笔 | -| MOUSE | number | 是 | 否 | 鼠标 | -| LENS | number | 是 | 否 | 透镜 | +| 名称 | 值 | 说明 | +| -------- | ------ | ---- | +| FINGER | 0 | 手指 | +| PEN | 1 | 笔 | +| RUBBER | 2 | 橡皮擦 | +| BRUSH | 3 | 笔刷 | +| PENCIL | 4 | 铅笔 | +| AIRBRUSH | 5 | 气笔 | +| MOUSE | 6 | 鼠标 | +| LENS | 7 | 透镜 | ## SourceType **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------------ | ------ | ---- | ---- | ---- | -| TOUCH_SCREEN | number | 是 | 否 | 触摸屏 | -| PEN | number | 是 | 否 | 手写笔 | -| TOUCH_PAD | number | 是 | 否 | 触摸板 | +| 名称 | 值 | 说明 | +| ------------ | ------ | ---- | +| TOUCH_SCREEN | 0 | 触摸屏 | +| PEN | 1 | 手写笔 | +| TOUCH_PAD | 2 | 触摸板 | ## Touch diff --git a/zh-cn/application-dev/reference/apis/js-apis-treemap.md b/zh-cn/application-dev/reference/apis/js-apis-treemap.md index 572b16437e8f0fdb6f8160e4b924b9b82cf1b4d0..9c2f2ec25a31c9c88a8175371dc78cd46c298556 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treemap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treemap.md @@ -58,11 +58,6 @@ TreeMap的构造函数。 ```ts let treeMap = new TreeMap(); -try { - let treeMap2 = TreeMap(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -93,11 +88,6 @@ isEmpty(): boolean ```ts const treeMap = new TreeMap(); let result = treeMap.isEmpty(); -try { - treeMap.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -136,11 +126,6 @@ let treeMap = new TreeMap(); let result = treeMap.hasKey("squirrel"); treeMap.set("squirrel", 123); let result1 = treeMap.hasKey("squirrel"); -try { - treeMap.hasKey.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -179,11 +164,6 @@ let treeMap = new TreeMap(); let result = treeMap.hasValue(123); treeMap.set("squirrel", 123); let result1 = treeMap.hasValue(123); -try { - treeMap.hasValue.bind({}, 123)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -222,11 +202,6 @@ let treeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); let result = treeMap.get("sparrow"); -try { - treeMap.get.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -259,11 +234,6 @@ let treeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); let result = treeMap.getFirstKey(); -try { - treeMap.getFirstKey.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -296,11 +266,6 @@ let treeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); let result = treeMap.getLastKey(); -try { - treeMap.getLastKey.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -334,11 +299,6 @@ treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); let map = new TreeMap(); treeMap.setAll(map); -try { - treeMap.setAll.bind({}, map)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -376,11 +336,6 @@ set(key: K, value: V): Object ```ts let treeMap = new TreeMap(); treeMap.set("squirrel", 123); -try { - treeMap.set.bind({}, "squirrel", 123)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -419,11 +374,6 @@ let treeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); treeMap.remove("sparrow"); -try { - treeMap.remove.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -463,11 +413,6 @@ treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); treeMap.set("gander", 356); let result = treeMap.getLowerKey("sparrow"); -try { - treeMap.getLowerKey.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -507,11 +452,6 @@ treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); treeMap.set("gander", 356); let result = treeMap.getHigherKey("sparrow"); -try { - treeMap.getHigherKey.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` ### replace @@ -549,11 +489,6 @@ replace(key: K, newValue: V): boolean let treeMap = new TreeMap(); treeMap.set("sparrow", 123); let result = treeMap.replace("sparrow", 357); -try { - treeMap.replace.bind({}, "sparrow", 357)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -580,11 +515,6 @@ let treeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); treeMap.clear(); -try { - treeMap.clear.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -622,11 +552,6 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - treeMap.keys.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -664,11 +589,6 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - treeMap.values.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -711,13 +631,6 @@ treeMap.set("gull", 357); treeMap.forEach((value, key) => { console.log("value:" + value, key); }); -try { - treeMap.forEach.bind({}, (value, key) => { - console.log("value:" + value, key); - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -756,11 +669,6 @@ while(temp != undefined) { console.log("value:" + temp[1]); temp = iter.next().value; } -try { - treeMap.entries.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -806,9 +714,4 @@ while(temp != undefined) { console.log("value:" + temp[1]); temp = iter.next().value; } -try { - treeMap[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-treeset.md b/zh-cn/application-dev/reference/apis/js-apis-treeset.md index 27ed062edd7d0d632e091a807cca2bb5cec59c5f..732b4c5a334a72f72459d1252ffa1475688ceb3a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treeset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treeset.md @@ -55,11 +55,6 @@ TreeSet的构造函数。 ```ts let treeSet = new TreeSet(); -try { - let treeSet2 = TreeSet(); -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -90,11 +85,6 @@ isEmpty(): boolean ```ts const treeSet = new TreeSet(); let result = treeSet.isEmpty(); -try { - treeSet.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -133,11 +123,6 @@ let treeSet = new TreeSet(); treeSet.has(123); treeSet.add(123); let result1 = treeSet.has(123); -try { - treeSet.has.bind({}, 123)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -170,11 +155,6 @@ let treeSet = new TreeSet(); treeSet.add("squirrel"); treeSet.add("sparrow"); let result = treeSet.getFirstValue(); -try { - treeSet.getFirstValue.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -207,11 +187,6 @@ let treeSet = new TreeSet(); treeSet.add("squirrel"); treeSet.add("sparrow"); let result = treeSet.getLastValue(); -try { - treeSet.getLastValue.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -248,11 +223,6 @@ add(value: T): boolean ```ts let treeSet = new TreeSet(); let result = treeSet.add("squirrel"); -try { - treeSet.add.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -291,11 +261,6 @@ let treeSet = new TreeSet(); treeSet.add("squirrel"); treeSet.add("sparrow"); let result = treeSet.remove("sparrow"); -try { - treeSet.remove.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -335,11 +300,6 @@ treeSet.add("squirrel"); treeSet.add("sparrow"); treeSet.add("gander"); let result = treeSet.getLowerValue("sparrow"); -try { - treeSet.getLowerValue.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -379,11 +339,6 @@ treeSet.add("squirrel"); treeSet.add("sparrow"); treeSet.add("gander"); let result = treeSet.getHigherValue("sparrow"); -try { - treeSet.getHigherValue.bind({}, "sparrow")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -416,11 +371,6 @@ let treeSet = new TreeSet(); treeSet.add("squirrel"); treeSet.add("sparrow"); let result = treeSet.popFirst(); -try { - treeSet.popFirst.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -453,11 +403,6 @@ let treeSet = new TreeSet(); treeSet.add("squirrel"); treeSet.add("sparrow"); let result = treeSet.popLast(); -try { - treeSet.popLast.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -484,11 +429,6 @@ let treeSet = new TreeSet(); treeSet.add("squirrel"); treeSet.add("sparrow"); treeSet.clear(); -try { - treeSet.clear.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -526,11 +466,6 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - treeSet.values.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -573,13 +508,6 @@ treeSet.add("gull"); treeSet.forEach((value, key) => { console.log("value:" + value, key) }); -try { - treeSet.forEach.bind({}, (value, key) => { - console.log("value:" + value, key) - })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -618,11 +546,6 @@ while(temp != undefined) { console.log("value:" + temp[1]); temp = iter.next().value; } -try { - treeSet.entries.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` @@ -667,9 +590,4 @@ while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; } -try { - treeSet[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 -} catch(err) { - console.log(`${err.code} - ${err.name} - ${err.message}`); -} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-uitest.md b/zh-cn/application-dev/reference/apis/js-apis-uitest.md index dc83e9ecc263c644abf9af3c04d0cf37dd66378f..66bd21067457c2e935637a7edd4d0c3d4018c146 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uitest.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uitest.md @@ -840,7 +840,7 @@ isCheckable(): Promise\ **返回值:** -| 错误码ID | 错误信息 | +| 类型 | 说明 | | ----------------- | ------------------------------------------------------------ | | Promise\ | 以Promise形式返回控件对象能否可被勾选属性,true:可被勾选,false:不可被勾选。 | @@ -848,7 +848,7 @@ isCheckable(): Promise\ 以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 -| 类型 | 说明 | +| 错误码ID | 错误信息 | | -------- | ---------------------------------------- | | 17000002 | API does not allow calling concurrently. | | 17000004 | Component lost/UiWindow lost. | @@ -1295,7 +1295,7 @@ static create(): Driver **返回值:** -| 错误码ID | 错误信息 | +| 类型 | 说明 | | -------- | ---------------------- | | Driver | 返回构造的Driver对象。 | @@ -1303,7 +1303,7 @@ static create(): Driver 以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 -| 类型 | 说明 | +| 错误码ID | 错误信息 | | -------- | ------------------ | | 17000001 | Initialize failed. | @@ -2518,7 +2518,7 @@ split(): Promise\ 以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 -| 类型 | 说明 | +| 错误码ID | 错误信息 | | -------- | ---------------------------------------- | | 17000002 | API does not allow calling concurrently. | | 17000004 | Component lost/UiWindow lost. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-uri.md b/zh-cn/application-dev/reference/apis/js-apis-uri.md index 642bf26604dcbbf0bffd0a6e7c48a97953524d80..913a4fbde89d14be8d8c691aaf57c4d3688c5222 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uri.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uri.md @@ -1,6 +1,7 @@ # URI字符串解析 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** +> > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -16,7 +17,7 @@ import uri from '@ohos.uri' **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | scheme | string | 是 | 否 | 获取URI 的协议部分。 | | userInfo | string | 是 | 否 | 获取 URI 的用户信息部分。 | @@ -39,9 +40,9 @@ constructor是URI的构造函数。 **参数:** -| 参数名 | 类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| uri | string | 是 | 是 | 入参对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 入参对象。 | **示例:** @@ -77,8 +78,10 @@ result.toString() ### equals(deprecated) -> **说明:**
-> 从API version 9开始废弃,建议使用[equalsTo9+](#equalsto9)替代。 + +> **说明:** +> +> 从API version 8开始支持,从API version 9开始废弃,建议使用[equalsTo9+](#equalsto9)替代。 equals(other: URI): boolean @@ -170,6 +173,7 @@ normalize(): URI | URI | 返回一个path被规范化后的URI对象。 | **示例:** + ```js const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp'); let uriInstance1 = uriInstance.normalize(); diff --git a/zh-cn/application-dev/reference/apis/js-apis-usb-deprecated.md b/zh-cn/application-dev/reference/apis/js-apis-usb-deprecated.md index 0c20c4b3b4aa03f528d7d8b7a23f6887a95c34cf..fd9a8bfde8daee0c84468caa68df2a68ffa65a6e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-usb-deprecated.md +++ b/zh-cn/application-dev/reference/apis/js-apis-usb-deprecated.md @@ -350,7 +350,7 @@ let ret = usb.getFileDescriptor(devicepipe); ## usb.controlTransfer -controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number> +controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout?: number): Promise<number> 控制传输。 @@ -363,7 +363,7 @@ controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: nu | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | pipe | [USBDevicePipe](#usbdevicepipe) | 是 | 用于确定设备。 | -| contrlparam | [USBControlParams](#usbcontrolparams) | 是 | 控制传输参数。 | +| controlparam | [USBControlParams](#usbcontrolparams) | 是 | 控制传输参数。 | | timeout | number | 否 | 超时时间(单位:ms),可选参数,默认为0不超时。 | **返回值:** @@ -640,16 +640,16 @@ let ret = usb.getSupportedModes(0); **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ------------- | ------------------------------------------- | ------------- | -| address | number | 端点地址。 | -| attributes | number | 端点属性。 | -| interval | number | 端点间隔。 | -| maxPacketSize | number | 端点最大数据包大小。 | -| direction | [USBRequestDirection](#usbrequestdirection) | 端点的方向。 | -| number | number | 端点号。 | -| type | number | 端点类型。 | -| interfaceId | number | 端点所属的接口的唯一标识。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ------------------------------------------- | ------------- |------------ | +| address | number | 是 |端点地址。 | +| attributes | number | 是 |端点属性。 | +| interval | number | 是 |端点间隔。 | +| maxPacketSize | number | 是 |端点最大数据包大小。 | +| direction | [USBRequestDirection](#usbrequestdirection) | 是 |端点的方向。 | +| number | number | 是 |端点号。 | +| type | number | 是 |端点类型。 | +| interfaceId | number | 是 |端点所属的接口的唯一标识。 | ## USBInterface @@ -657,15 +657,15 @@ let ret = usb.getSupportedModes(0); **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ---------------- | ---------------------------------------- | --------------------- | -| id | number | 接口的唯一标识。 | -| protocol | number | 接口的协议。 | -| clazz | number | 设备类型。 | -| subClass | number | 设备子类。 | -| alternateSetting | number | 在同一个接口中的多个描述符中进行切换设置。 | -| name | string | 接口名称。 | -| endpoints | Array<[USBEndpoint](#usbendpoint)> | 当前接口所包含的端点。 | +| 名称 | 类型 | 必填 |说明 | +| ---------------- | ---------------------------------------- | ------------- |--------------------- | +| id | number | 是 |接口的唯一标识。 | +| protocol | number | 是 |接口的协议。 | +| clazz | number | 是 |设备类型。 | +| subClass | number | 是 |设备子类。 | +| alternateSetting | number | 是 |在同一个接口中的多个描述符中进行切换设置。 | +| name | string | 是 |接口名称。 | +| endpoints | Array<[USBEndpoint](#usbendpoint)> | 是 |当前接口所包含的端点。 | ## USBConfig @@ -673,15 +673,15 @@ USB配置,一个[USBDevice](#usbdevice)中可以含有多个配置。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| -------------- | ------------------------------------------------ | --------------- | -| id | number | 配置的唯一标识。 | -| attributes | number | 配置的属性。 | -| maxPower | number | 最大功耗,以毫安为单位。 | -| name | string | 配置的名称,可以为空。 | -| isRemoteWakeup | boolean | 检查当前配置是否支持远程唤醒。 | -| isSelfPowered | boolean | 检查当前配置是否支持独立电源。 | -| interfaces | Array <[USBInterface](#usbinterface)> | 配置支持的接口属性。 | +| 名称 | 类型 | 必填 |说明 | +| -------------- | ------------------------------------------------ | --------------- |----------- | +| id | number | 是 |配置的唯一标识。 | +| attributes | number | 是 |配置的属性。 | +| maxPower | number | 是 |最大功耗,以毫安为单位。 | +| name | string | 是 |配置的名称,可以为空。 | +| isRemoteWakeup | boolean | 是 |检查当前配置是否支持远程唤醒。 | +| isSelfPowered | boolean | 是 |检查当前配置是否支持独立电源。 | +| interfaces | Array <[USBInterface](#usbinterface)> | 是 |配置支持的接口属性。 | ## USBDevice @@ -689,21 +689,21 @@ USB设备信息。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ---------------- | ------------------------------------ | ---------- | -| busNum | number | 总线地址。 | -| devAddress | number | 设备地址。 | -| serial | string | 序列号。 | -| name | string | 设备名字。 | -| manufacturerName | string | 产商信息。 | -| productName | string | 产品信息。 | -| version | string | 版本。 | -| vendorId | number | 厂商ID。 | -| productId | number | 产品ID。 | -| clazz | number | 设备类。 | -| subClass | number | 设备子类。 | -| protocol | number | 设备协议码。 | -| configs | Array<[USBConfig](#usbconfig)> | 设备配置描述符信息。 | +| 名称 | 类型 | 必填 |说明 | +| ---------------- | ------------------------------------ | ---------- |---------- | +| busNum | number | 是 |总线地址。 | +| devAddress | number | 是 |设备地址。 | +| serial | string | 是 |序列号。 | +| name | string | 是 |设备名字。 | +| manufacturerName | string | 是 |产商信息。 | +| productName | string | 是 |产品信息。 | +| version | string | 是 |版本。 | +| vendorId | number | 是 |厂商ID。 | +| productId | number | 是 |产品ID。 | +| clazz | number | 是 |设备类。 | +| subClass | number | 是 |设备子类。 | +| protocol | number | 是 |设备协议码。 | +| configs | Array<[USBConfig](#usbconfig)> | 是 |设备配置描述符信息。 | ## USBDevicePipe @@ -711,10 +711,10 @@ USB设备消息传输通道,用于确定设备。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ---------- | ------ | ----- | -| busNum | number | 总线地址。 | -| devAddress | number | 设备地址。 | +| 名称 | 类型 | 必填 |说明 | +| ---------- | ------ | ----- |----- | +| busNum | number | 是 |总线地址。 | +| devAddress | number | 是 |设备地址。 | ## USBControlParams @@ -722,14 +722,14 @@ USB设备消息传输通道,用于确定设备。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ------- | ----------------------------------------------- | ---------------- | -| request | number | 请求类型。 | -| target | [USBRequestTargetType](#usbrequesttargettype) | 请求目标类型。 | -| reqType | [USBControlRequestType](#usbcontrolrequesttype) | 请求控制类型。 | -| value | number | 请求参数。 | -| index | number | 请求参数value对应的索引值。 | -| data | Uint8Array | 用于写入或读取的缓冲区。 | +| 名称 | 类型 | 必填 |说明 | +| ------- | ----------------------------------------------- | ---------------- |---------------- | +| request | number | 是 |请求类型。 | +| target | [USBRequestTargetType](#usbrequesttargettype) | 是 |请求目标类型。 | +| reqType | [USBControlRequestType](#usbcontrolrequesttype) | 是 |请求控制类型。 | +| value | number | 是 |请求参数。 | +| index | number | 是 |请求参数value对应的索引值。 | +| data | Uint8Array | 是 |用于写入或读取的缓冲区。 | ## USBPort9+ @@ -739,11 +739,11 @@ USB设备端口。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| -------------- | -------------------------------- | ----------------------------------- | -| id | number | USB端口唯一标识。 | -| supportedModes | [PortModeType](#portmodetype9) | USB端口所支持的模式的数字组合掩码。 | -| status | [USBPortStatus](#usbportstatus9) | USB端口角色。 | +| 名称 | 类型 | 必填 |说明 | +| -------------- | -------------------------------- | -------------- |----------------------------------- | +| id | number | 是 |USB端口唯一标识。 | +| supportedModes | [PortModeType](#portmodetype9) | 是 |USB端口所支持的模式的数字组合掩码。 | +| status | [USBPortStatus](#usbportstatus9) | 是 |USB端口角色。 | ## USBPortStatus9+ @@ -753,11 +753,11 @@ USB设备端口角色信息。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ---------------- | -------- | ---------------------- | -| currentMode | number | 当前的USB模式。 | -| currentPowerRole | number | 当前设备充电模式。 | -| currentDataRole | number | 当前设备数据传输模式。 | +| 名称 | 类型 | 必填 |说明 | +| ---------------- | -------- | ----------- |---------------------- | +| currentMode | number | 是 |当前的USB模式。 | +| currentPowerRole | number | 是 |当前设备充电模式。 | +| currentDataRole | number | 是 |当前设备数据传输模式。 | ## USBRequestTargetType diff --git a/zh-cn/application-dev/reference/apis/js-apis-usb.md b/zh-cn/application-dev/reference/apis/js-apis-usb.md index 2780155db9df46c9eaeabed1696644f4c01128a2..a7673ac5985027504f3a6e6e13f527ea13a20d95 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-usb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-usb.md @@ -428,7 +428,7 @@ let ret = usb.getFileDescriptor(devicepipe); ## usb.controlTransfer -controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number> +controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout?: number): Promise<number> 控制传输。 @@ -441,7 +441,7 @@ controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: nu | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | pipe | [USBDevicePipe](#usbdevicepipe) | 是 | 用于确定设备。 | -| contrlparam | [USBControlParams](#usbcontrolparams) | 是 | 控制传输参数。 | +| controlparam | [USBControlParams](#usbcontrolparams) | 是 | 控制传输参数。 | | timeout | number | 否 | 超时时间(单位:ms),可选参数,默认为0不超时。 | **返回值:** @@ -718,16 +718,16 @@ let ret = usb.getSupportedModes(0); **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ------------- | ------------------------------------------- | ------------- | -| address | number | 端点地址。 | -| attributes | number | 端点属性。 | -| interval | number | 端点间隔。 | -| maxPacketSize | number | 端点最大数据包大小。 | -| direction | [USBRequestDirection](#usbrequestdirection) | 端点的方向。 | -| number | number | 端点号。 | -| type | number | 端点类型。 | -| interfaceId | number | 端点所属的接口的唯一标识。 | +| 名称 | 类型 | 必填 |说明 | +| ------------- | ------------------------------------------- | ------------- |------------- | +| address | number | 是 |端点地址。 | +| attributes | number | 是 |端点属性。 | +| interval | number | 是 |端点间隔。 | +| maxPacketSize | number | 是 |端点最大数据包大小。 | +| direction | [USBRequestDirection](#usbrequestdirection) | 是 |端点的方向。 | +| number | number | 是 |端点号。 | +| type | number | 是 |端点类型。 | +| interfaceId | number | 是 |端点所属的接口的唯一标识。 | ## USBInterface @@ -735,15 +735,15 @@ let ret = usb.getSupportedModes(0); **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ---------------- | ---------------------------------------- | --------------------- | -| id | number | 接口的唯一标识。 | -| protocol | number | 接口的协议。 | -| clazz | number | 设备类型。 | -| subClass | number | 设备子类。 | -| alternateSetting | number | 在同一个接口中的多个描述符中进行切换设置。 | -| name | string | 接口名称。 | -| endpoints | Array<[USBEndpoint](#usbendpoint)> | 当前接口所包含的端点。 | +| 名称 | 类型 | 必填 |说明 | +| ---------------- | ---------------------------------------- | ------------- |--------------------- | +| id | number | 是 |接口的唯一标识。 | +| protocol | number | 是 |接口的协议。 | +| clazz | number | 是 |设备类型。 | +| subClass | number | 是 |设备子类。 | +| alternateSetting | number | 是 |在同一个接口中的多个描述符中进行切换设置。 | +| name | string | 是 |接口名称。 | +| endpoints | Array<[USBEndpoint](#usbendpoint)> | 是 |当前接口所包含的端点。 | ## USBConfig @@ -751,15 +751,15 @@ USB配置,一个[USBDevice](#usbdevice)中可以含有多个配置。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| -------------- | ------------------------------------------------ | --------------- | -| id | number | 配置的唯一标识。 | -| attributes | number | 配置的属性。 | -| maxPower | number | 最大功耗,以毫安为单位。 | -| name | string | 配置的名称,可以为空。 | -| isRemoteWakeup | boolean | 检查当前配置是否支持远程唤醒。 | -| isSelfPowered | boolean | 检查当前配置是否支持独立电源。 | -| interfaces | Array <[USBInterface](#usbinterface)> | 配置支持的接口属性。 | +| 名称 | 类型 | 必填 |说明 | +| -------------- | ------------------------------------------------ | --------------- |--------------- | +| id | number | 是 |配置的唯一标识。 | +| attributes | number | 是 |配置的属性。 | +| maxPower | number | 是 |最大功耗,以毫安为单位。 | +| name | string | 是 |配置的名称,可以为空。 | +| isRemoteWakeup | boolean | 是 |检查当前配置是否支持远程唤醒。 | +| isSelfPowered | boolean | 是 | 检查当前配置是否支持独立电源。 | +| interfaces | Array <[USBInterface](#usbinterface)> | 是 |配置支持的接口属性。 | ## USBDevice @@ -767,21 +767,21 @@ USB设备信息。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ---------------- | ------------------------------------ | ---------- | -| busNum | number | 总线地址。 | -| devAddress | number | 设备地址。 | -| serial | string | 序列号。 | -| name | string | 设备名字。 | -| manufacturerName | string | 产商信息。 | -| productName | string | 产品信息。 | -| version | string | 版本。 | -| vendorId | number | 厂商ID。 | -| productId | number | 产品ID。 | -| clazz | number | 设备类。 | -| subClass | number | 设备子类。 | -| protocol | number | 设备协议码。 | -| configs | Array<[USBConfig](#usbconfig)> | 设备配置描述符信息。 | +| 名称 | 类型 | 必填 |说明 | +| ---------------- | ------------------------------------ | ---------- |---------- | +| busNum | number | 是 |总线地址。 | +| devAddress | number | 是 |设备地址。 | +| serial | string | 是 |序列号。 | +| name | string | 是 |设备名字。 | +| manufacturerName | string | 是 | 产商信息。 | +| productName | string | 是 |产品信息。 | +| version | string | 是 |版本。 | +| vendorId | number | 是 |厂商ID。 | +| productId | number | 是 |产品ID。 | +| clazz | number | 是 |设备类。 | +| subClass | number | 是 |设备子类。 | +| protocol | number | 是 |设备协议码。 | +| configs | Array<[USBConfig](#usbconfig)> | 是 |设备配置描述符信息。 | ## USBDevicePipe @@ -789,10 +789,10 @@ USB设备消息传输通道,用于确定设备。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ---------- | ------ | ----- | -| busNum | number | 总线地址。 | -| devAddress | number | 设备地址。 | +| 名称 | 类型 | 必填 |说明 | +| ---------- | ------ | ----- |----- | +| busNum | number |是 | 总线地址。 | +| devAddress | number |是 | 设备地址。 | ## USBControlParams @@ -800,14 +800,14 @@ USB设备消息传输通道,用于确定设备。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ------- | ----------------------------------------------- | ---------------- | -| request | number | 请求类型。 | -| target | [USBRequestTargetType](#usbrequesttargettype) | 请求目标类型。 | -| reqType | [USBControlRequestType](#usbcontrolrequesttype) | 请求控制类型。 | -| value | number | 请求参数。 | -| index | number | 请求参数value对应的索引值。 | -| data | Uint8Array | 用于写入或读取的缓冲区。 | +| 名称 | 类型 | 必填 |说明 | +| ------- | ----------------------------------------------- | ---------------- |---------------- | +| request | number | 是 |请求类型。 | +| target | [USBRequestTargetType](#usbrequesttargettype) | 是 |请求目标类型。 | +| reqType | [USBControlRequestType](#usbcontrolrequesttype) | 是 |请求控制类型。 | +| value | number | 是 |请求参数。 | +| index | number | 是 |请求参数value对应的索引值。 | +| data | Uint8Array | 是 |用于写入或读取的缓冲区。 | ## USBPort @@ -817,11 +817,11 @@ USB设备端口。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| -------------- | -------------------------------- | ----------------------------------- | -| id | number | USB端口唯一标识。 | -| supportedModes | [PortModeType](#portmodetype) | USB端口所支持的模式的数字组合掩码。 | -| status | [USBPortStatus](#usbportstatus) | USB端口角色。 | +| 名称 | 类型 | 必填 |说明 | +| -------------- | ------------------------------- | ------------------- |------------------------ | +| id | number | 是 |USB端口唯一标识。 | +| supportedModes | [PortModeType](#portmodetype) | 是 |USB端口所支持的模式的数字组合掩码。 | +| status | [USBPortStatus](#usbportstatus) | 是 |USB端口角色。 | ## USBPortStatus @@ -831,11 +831,11 @@ USB设备端口角色信息。 **系统能力:** SystemCapability.USB.USBManager -| 名称 | 参数类型 | 说明 | -| ---------------- | -------- | ---------------------- | -| currentMode | number | 当前的USB模式。 | -| currentPowerRole | number | 当前设备充电模式。 | -| currentDataRole | number | 当前设备数据传输模式。 | +| 名称 | 类型 | 必填 |说明 | +| ---------------- | -------- | ---------------- |---------------------- | +| currentMode | number | 是 |当前的USB模式。 | +| currentPowerRole | number | 是 |当前设备充电模式。 | +| currentDataRole | number | 是 |当前设备数据传输模式。 | ## USBRequestTargetType diff --git a/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md b/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md index 8c8c1a1b51a800017ac99a9277d3b9b8576467cd..10e80a94645dbda35653c72fd878423d6de3c647 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md @@ -1309,7 +1309,7 @@ getThumbnail(size: image.Size, callback: AsyncCallback<image.PixelMap>): v | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | ---------------- | -| size | Size | 是 | 缩略图尺寸 | +| size | [image.Size](js-apis-image.md#size) | 是 | 缩略图尺寸 | | callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调返回缩略图的PixelMap | **示例:** @@ -1352,7 +1352,7 @@ getThumbnail(size?: image.Size): Promise<image.PixelMap> | 参数名 | 类型 | 必填 | 说明 | | ---- | -------------- | ---- | ----- | -| size | Size | 否 | 缩略图尺寸 | +| size | [image.Size](js-apis-image.md#size) | 否 | 缩略图尺寸 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md b/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md index c0383e0497ec0e53e0e02da382adeac1405e8f9b..968bc6fbcd814f9a9b805fe5c3f1c8783df4d91b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @@ -30,21 +30,21 @@ constructor() | 类型 | 说明 | | ---------------------- | -------------------- | -| [FaceAuthManager](#faceauthmanager) | 人脸认证管理器对象 | +| [FaceAuthManager](#faceauthmanager) | 人脸认证管理器对象。 | **示例:** - ```js - import userIAM_faceAuth from '@ohos.userIAM.faceAuth'; +```js +import userIAM_faceAuth from '@ohos.userIAM.faceAuth'; - let faceAuthManager = new userIAM_faceAuth.FaceAuthManager(); - ``` +let faceAuthManager = new userIAM_faceAuth.FaceAuthManager(); +``` ### setSurfaceId 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 @@ -56,17 +56,28 @@ setSurfaceId(surfaceId: string): void; | -------------- | ---------------------------------- | ---- | -------------------------- | | surfaceId | string | 是 | [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID。 | +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errorcode-useriam.md) + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | ------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 12700001 | The operation is failed. | + **示例:** - ```js - import faceAuth from '@ohos.userIAM.faceAuth'; - - let surfaceId = "123456"; - let manager = new faceAuth.FaceAuthManager(); - try { - manager.setSurfaceId(surfaceId); - console.info("set surface id success"); - } catch (e) { - console.error("set surface id failed, error = " + e); - } - ``` +```js +import userIAM_faceAuth from '@ohos.userIAM.faceAuth'; + +// 该surfaceId应该从XComponent控件获取,此处仅用作示例。 +let surfaceId = "123456"; +let manager = new userIAM_faceAuth.FaceAuthManager(); +try { + manager.setSurfaceId(surfaceId); + console.info("set surface id success"); +} catch (e) { + console.error("set surface id failed, error = " + e); +} +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md index 5eb839a2e10eb986132ad007bb9afdffef298de0..127feea3d26e8200f34a2122e98516c3f5498b9a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -12,268 +12,115 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth'; ``` -## 完整示例 +## AuthResultInfo9+ -```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); - } - }, +**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core。 - 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 - } - }, +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ---------- | ---- | -------------------- | +| result | number | 是 | 认证结果。 | +| token | Uint8Array | 否 | 用户身份认证通过的凭证。 | +| remainAttempts | number | 否 | 剩余的认证操作次数。 | +| lockoutDuration | number | 否 | 认证操作的冻结时间。 | - 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); - } - }, +## TipInfo9+ - 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); - } - } -} -``` +**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core。 -```js -// API version 8 -import userIAM_userAuth from '@ohos.userIAM.userAuth'; -let auth = new userIAM_userAuth.UserAuth(); +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ---------- | ---- | -------------------- | +| module | number | 是 | 发送提示信息的模块标识。 | +| tip | number | 是 | 认证过程提示信息。 | -export default { - getVersion() { - console.info("start get version"); - let version = auth.getVersion(); - console.info("auth version = " + version); - }, - - startAuth() { - 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() { - 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接口获取 - 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); - } - }); - let cancelCode = this.auth.cancel(contextId); - if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { - console.info("cancel auth success"); - } else { - console.error("cancel auth fail"); - } - } -} -``` +## EventInfo9+ -```js -// API version 6 -import userIAM_userAuth from '@ohos.userIAM.userAuth'; +表示认证过程中事件信息的类型。 -export default { - 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); - // 此处添加认证失败逻辑 - }); - } -} -``` +**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core。 -## EventInfo9+ +| 取值类型 | 说明 | +| --------- | ----------------------- | +| [AuthResultInfo](#authresultinfo9) | 获取到的认证结果信息。 | +| [TipInfo](#tipinfo9) | 认证过程中的提示信息。 | -类型别名,用于表示认证事件信息的类型,取值可以为下表中的类型。 +## AuthEventKey9+ -**系统能力**:SystemCapability.UserIAM.UserAuth.Core +表示认证事件类型的关键字,作为[on](#on9)接口的的参数。 -| 类型 | 说明 | -| --------- | ----------------------- | -| [AuthResultInfo](#authresultinfo9) | 认证结果信息 | -| [TipInfo](#tipinfo9) | 认证过程中的提示信息 | +| 取值类型 | 说明 | +| ---------- | ----------------------- | +| "result" | [on](#on9)接口第一个参数为"result"时,[callback](#callback9)回调返回认证的结果信息。 | +| "tip" | [on](#on9)接口第一个参数为"tip"时,[callback](#callback9)回调返回认证操作中的提示信息。 | ## AuthEvent9+ -认证事件回调的对象。 +认证接口的异步回调对象。 ### callback9+ -callback: (result : EventInfo) => void +callback(result : EventInfo) : void -表示在认证结束后返回结果信息或者在认证操作中返回提示信息。 +通过该回调获取认证结果信息或认证过程中的提示信息。 **系统能力**:SystemCapability.UserIAM.UserAuth.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | -------------------------- | ---- | -------------------------------------------------------- | -| result | [EventInfo](#eventinfo9) | 是 | 返回的认证结果信息或提示信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | -------------------------- | ---- | ------------------------------ | +| result | [EventInfo](#eventinfo9) | 是 | 返回的认证结果信息或提示信息。 | **示例:** - ```js - import userIAM_userAuth from '@ohos.userIAM.userAuth'; - - 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", { +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); +let authType = userIAM_userAuth.UserAuthType.FACE; +let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; +// 通过callback获取认证结果 +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); } - }); - auth.start(); - console.log("authV9 start success"); - } catch (error) { - console.log("authV9 error = " + error); - // do error - } - ``` - -## AuthResultInfo9+ - -表示认证结果信息的对象。 - -**系统能力**:SystemCapability.UserIAM.UserAuth.Core - -| 名称 | 参数类型 | 必填 | 说明 | -| ------------ | ---------- | ---- | -------------------- | -| result | number | 是 | 认证结果。 | -| token | Uint8Array | 否 | 用户身份认证通过的凭证。 | -| remainAttempts | number | 否 | 剩余的认证操作次数。 | -| lockoutDuration | number | 否 | 认证操作的冻结时间。 | - -## TipInfo9+ - -表示认证过程中提示信息的对象。 - -**系统能力**:SystemCapability.UserIAM.UserAuth.Core - -| 名称 | 参数类型 | 必填 | 说明 | -| ------------ | ---------- | ---- | -------------------- | -| module | number | 否 | 认证模块。 | -| tip | number | 否 | 认证过程提示信息。 | - -## AuthEventKey9+ - -类型别名,表示认证事件的关键字,取值为表格内字符串。 - -| 取值 | 说明 | -| ---------- | ----------------------- | -| "result" | 取值为result时,事件回调返回认证的结果信息。 | -| "tip" | 取值为tip时,事件回调返回认证操作中的提示信息。 | + }); + auth.start(); + console.log("authV9 start success"); +} catch (error) { + console.log("authV9 error = " + 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 + } + } + }); + auth.start(); + console.log("authV9 start success"); +} catch (error) { + console.log("authV9 error = " + error); + // do error +} +``` ## AuthInstance9+ @@ -281,9 +128,12 @@ callback: (result : EventInfo) => void ### on9+ -on(name : AuthEventKey, callback : AuthEvent) : void +on : (name : AuthEventKey, callback : AuthEvent) => void + +订阅指定类型的用户认证事件。 -表示开启对认证事件的监听。 +> **说明:** +> 使用获取到的[AuthInstance](#authinstance9)对象调用该接口进行订阅。 **系统能力**:SystemCapability.UserIAM.UserAuth.Core @@ -291,151 +141,205 @@ on(name : AuthEventKey, callback : AuthEvent) : void | 参数名 | 类型 | 必填 | 说明 | | --------- | -------------------------- | ---- | ------------------------- | -| name | AuthEventKey | 是 | 认证事件的关键字 | -| callback | AuthEvent | 是 | 认证事件的回调函数 | +| name | [AuthEventKey](#autheventkey9) | 是 | 表示认证事件类型,取值为"result"时,回调函数返回认证结果;取值为"tip"时,回调函数返回认证过程中的提示信息。 | +| callback | [AuthEvent](#authevent9) | 是 | 认证接口的回调函数,用于返回认证结果或认证过程中的提示信息。 | + +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errorcode-useriam.md) + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | ------- | +| 401 | Incorrect parameters. | +| 12500002 | General operation error. | **示例:** - ```js - import userIAM_userAuth from '@ohos.userIAM.userAuth'; - - 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", { +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +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", { + }); + // 订阅认证过程中的提示信息 + 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 - } - ``` + }); + auth.start(); + console.log("authV9 start success"); +} catch (error) { + console.log("authV9 error = " + error); + // do error +} +``` ### off9+ -off(name : AuthEventKey) : void +off : (name : AuthEventKey) => void -表示关闭对认证事件的监听。 +取消订阅特定类型的认证事件。 + +> **说明:** +> 需要使用已经成功订阅事件的[AuthInstance](#authinstance9)对象调用该接口进行取消订阅。 **系统能力**:SystemCapability.UserIAM.UserAuth.Core -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | --------- | -------------------------- | ---- | ------------------------- | -| name | AuthEventKey | 是 | 认证事件的关键字 | +| name | [AuthEventKey](#autheventkey9) | 是 | 表示认证事件类型,取值为"result"时,取消订阅认证结果;取值为"tip"时,取消订阅认证过程中的提示信息。 | + +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errorcode-useriam.md) + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | ------- | +| 401 | Incorrect parameters. | +| 12500002 | General operation error. | **示例:** - ```js - import userIAM_userAuth from '@ohos.userIAM.userAuth'; +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; - 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 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 { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); +} catch (error) { + console.log("get auth instance failed" + error); +} - try { - let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); - auth.on("result", { +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("turn on authentication event listening success"); - } catch (error) { - console.log("turn off authentication event listening failed " + error); - // do error - } - - try { - let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); - auth.off("result"); - console.info("turn off authentication event listening success"); - } catch (error) { - console.info("turn off authentication event listening failed, error = " + error); - } - ``` + }); + console.log("subscribe authentication event success"); +} catch (error) { + console.log("subscribe authentication event failed " + error); +} +// 取消订阅认证结果 +try { + auth.off("result"); + console.info("cancel subscribe authentication event success"); +} catch (error) { + console.info("cancel subscribe authentication event failed, error = " + error); +} +``` ### start9+ -start() : void +start : () => void + +开始认证。 -表示开始认证。 +> **说明:** +> 使用获取到的[AuthInstance](#authinstance9)对象调用该接口进行认证。 **需要权限**:ohos.permission.ACCESS_BIOMETRIC **系统能力**:SystemCapability.UserIAM.UserAuth.Core +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errorcode-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 - import userIAM_userAuth from '@ohos.userIAM.userAuth'; - - 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(); - console.info("authV9 start auth success"); - } catch (error) { - console.info("authV9 start auth failed, error = " + error); - } - ``` +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +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(); + console.info("authV9 start auth success"); +} catch (error) { + console.info("authV9 start auth failed, error = " + error); +} +``` ### cancel9+ -cancel(): void +cancel : () => void -表示取消认证。 +取消认证。 + +> **说明:** +> 使用获取到的[AuthInstance](#authinstance9)对象调用该接口进行取消认证,此[AuthInstance](#authinstance9)需要是正在进行认证的对象。 **需要权限**:ohos.permission.ACCESS_BIOMETRIC **系统能力**:SystemCapability.UserIAM.UserAuth.Core +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errorcode-useriam.md) + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | ------- | +| 201 | Permission verification failed. | +| 401 | Incorrect parameters. | +| 12500002 | General operation error. | + **示例:** - ```js - import userIAM_userAuth from '@ohos.userIAM.userAuth'; - - 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 +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +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.cancel(); + console.info("cancel auth success"); +} catch (error) { + console.info("cancel auth failed, error = " + error); +} +``` ## userIAM_userAuth.getAuthInstance9+ @@ -444,7 +348,7 @@ getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel 获取AuthInstance对象,用于执行用户身份认证。 > **说明:** -> 每个AuthInstance只能用于发起一次认证,若需要再次发起认证需重新获取AuthInstance。 +> 每个AuthInstance只能进行一次认证,若需要再次进行认证则需重新获取AuthInstance。 **系统能力**:SystemCapability.UserIAM.UserAuth.Core @@ -462,21 +366,33 @@ getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel | ----------------------------------------- | ------------ | | [AuthInstance](#authinstance9) | 认证器对象。 | +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errorcode-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]); - let authType = userIAM_userAuth.UserAuthType.FACE; - let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; - try { - let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); - console.info("get auth instance success"); - } catch (error) { - console.info("get auth instance success failed, error = " + error); - } - ``` +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); + console.info("get auth instance success"); +} catch (error) { + console.info("get auth instance success failed, error = " + error); +} +``` ## userIAM_userAuth.getVersion9+ @@ -492,26 +408,35 @@ getVersion(): number | 类型 | 说明 | | ------ | ---------------------- | -| number | 获取的认证器版本信息。 | +| number | 认证器版本信息。 | + +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errorcode-useriam.md) + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | ------- | +| 201 | Permission verification failed. | +| 12500002 | General operation error. | **示例:** - ```js - import userIAM_userAuth from '@ohos.userIAM.userAuth'; +```js +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); - } - ``` +try { + let version = userIAM_userAuth.getVersion(); + console.info("auth version = " + version); +} catch (error) { + console.info("get version failed, error = " + error); +} +``` ## userIAM_userAuth.getAvailableStatus9+ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void -表示检查指定的认证等级的认证能力是否可用。 +查询指定类型和等级的认证能力是否支持。 **需要权限**:ohos.permission.ACCESS_BIOMETRIC @@ -522,28 +447,41 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): vo | 参数名 | 类型 | 必填 | 说明 | | -------------- | ---------------------------------- | ---- | -------------------------- | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前只支持FACE。 | -| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证结果的信任等级。 | +| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 | + +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errorcode-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 - import userIAM_userAuth from '@ohos.userIAM.userAuth'; +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; - 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); - } - ``` +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); +} +``` - ## ResultCodeV99+ +## ResultCodeV99+ -表示执行结果的枚举。 +表示返回码的枚举。 **系统能力**:SystemCapability.UserIAM.UserAuth.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ----------------------- | ------ | -------------------- | | SUCCESS | 12500000 | 执行成功。 | | FAIL | 12500001 | 执行失败。 | @@ -553,50 +491,49 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): vo | TYPE_NOT_SUPPORT | 12500005 | 不支持的认证类型。 | | TRUST_LEVEL_NOT_SUPPORT | 12500006 | 不支持的认证等级。 | | BUSY | 12500007 | 忙碌状态。 | -| INVALID_PARAMETERS | 12500008 | 无效参数。 | | LOCKED | 12500009 | 认证器已锁定。 | | NOT_ENROLLED | 12500010 | 用户未录入认证信息。 | ## UserAuth8+ -认证器的对象。 +认证器对象。 ### constructor(deprecated) constructor() +创建认证器对象。 + > **说明:** > 从 API version 9 开始废弃,请使用[getAuthInstance](#useriam_userauthgetauthinstance9)替代。
从 API version 8 开始支持。 -表示获取的认证器对象。 - **系统能力**:SystemCapability.UserIAM.UserAuth.Core **返回值:** | 类型 | 说明 | | ---------------------- | -------------------- | -| [UserAuth](#userauth8) | UserAuth认证器对象。 | +| [UserAuth](#userauth8) | 认证器对象。 | **示例:** - ```js - import userIAM_userAuth from '@ohos.userIAM.userAuth'; +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; - let auth = new userIAM_userAuth.UserAuth(); - ``` +let auth = new userIAM_userAuth.UserAuth(); +``` ### getVersion(deprecated) getVersion() : number +获取认证器的版本信息。 + > **说明:** > 从 API version 9 开始废弃,请使用[getVersion](#useriam_userauthgetversion9)替代。
从 API version 8 开始支持。 -表示获取的认证器版本信息。 - **需要权限**:ohos.permission.ACCESS_BIOMETRIC **系统能力**:SystemCapability.UserIAM.UserAuth.Core @@ -605,28 +542,28 @@ getVersion() : number | 类型 | 说明 | | ------ | ---------------------- | -| number | 获取的认证器版本信息。 | +| number | 认证器版本信息。 | **示例:** - ```js - import userIAM_userAuth from '@ohos.userIAM.userAuth'; +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; - let auth = new userIAM_userAuth.UserAuth(); - let version = auth.getVersion(); - console.info("auth version = " + version); - ``` +let auth = new userIAM_userAuth.UserAuth(); +let version = auth.getVersion(); +console.info("auth version = " + version); +``` ### getAvailableStatus(deprecated) getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number +查询指定类型和等级的认证能力是否支持。 + > **说明:** -> 从 API version 9 开始废弃,请使用开始废弃,请使用[getAvailableStatus](#useriam_userauthgetavailablestatus9)替代。 +> 从 API version 9 开始废弃,请使用[getAvailableStatus](#useriam_userauthgetavailablestatus9)替代。
从 API version 8 开始支持。 -表示检查指定的认证等级的认证能力是否可用。 - **需要权限**:ohos.permission.ACCESS_BIOMETRIC **系统能力**:SystemCapability.UserIAM.UserAuth.Core @@ -636,40 +573,38 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : n | 参数名 | 类型 | 必填 | 说明 | | -------------- | ---------------------------------- | ---- | -------------------------- | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前只支持FACE。 | -| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证结果的信任等级。 | +| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 | **返回值:** | 类型 | 说明 | | ------ | ------------------------------------------------------------ | -| number | 获取指定的认证等级的认证能力是否可用的检查结果,返回值参见[ResultCode](#resultcodedeprecated)。 | +| number | 查询结果,结果为SUCCESS时表示支持,其他返回值参见[ResultCode](#resultcodedeprecated)。 | **示例:** - ```js - import userIAM_userAuth from '@ohos.userIAM.userAuth'; - - let auth = new userIAM_userAuth.UserAuth(); - let checkCode = 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); - // 此处添加不支持指定类型认证的逻辑 - } - ``` +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +let auth = new userIAM_userAuth.UserAuth(); +let checkCode = 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); +} +``` ### auth(deprecated) auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array +执行用户认证,使用回调函数返回结果。 + > **说明:** > 从 API version 9 开始废弃,建议使用[start](#start9)代替。
从 API version 8 开始支持。 -表示执行用户认证,使用callback方式作为异步方法。 - **需要权限**:ohos.permission.ACCESS_BIOMETRIC **系统能力**:SystemCapability.UserIAM.UserAuth.Core @@ -680,8 +615,8 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev | -------------- | ---------------------------------------- | ---- | ------------------------ | | challenge | Uint8Array | 是 | 挑战值,可以填null。 | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前支持FACE。 | -| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 信任等级。 | -| callback | [IUserAuthCallback](#iuserauthcallbackdeprecated) | 是 | 回调函数。 | +| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 | +| callback | [IUserAuthCallback](#iuserauthcallbackdeprecated) | 是 | 回调函数。 | **返回值:** @@ -691,37 +626,37 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev **示例:** - ```js - 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); - } - } - }); - ``` +```js +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); + } + } +}); +``` ### cancelAuth(deprecated) cancelAuth(contextID : Uint8Array) : number +表示通过contextID取消本次认证操作。 + > **说明:** > 从 API version 9 开始废弃,建议使用[cancel](#cancel9)代替。
从 API version 8 开始支持。 -表示通过contextID取消本次认证操作。 - **需要权限**:ohos.permission.ACCESS_BIOMETRIC **系统能力**:SystemCapability.UserIAM.UserAuth.Core @@ -730,170 +665,145 @@ cancelAuth(contextID : Uint8Array) : number | 参数名 | 类型 | 必填 | 说明 | | --------- | ---------- | ---- | ------------------------------------------ | -| contextID | Uint8Array | 是 | 上下文ID信息,通过[auth](#authdeprecated)接口获得。 | +| contextID | Uint8Array | 是 | 上下文的标识,通过[auth](#authdeprecated)接口获取。 | **返回值:** | 类型 | 说明 | | ------ | ------------------------ | -| number | 取消本次认证操作的结果。 | +| number | 取消认证的结果,结果为SUCCESS时表示取消成功,其他返回值参见[ResultCode](#resultcodedeprecated)。 | **示例:** - ```js - import userIAM_userAuth from '@ohos.userIAM.userAuth'; - - // contextId可通过auth接口获取,此处直接定义 - let contextId = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7]); - let auth = new userIAM_userAuth.UserAuth(); - let cancelCode = auth.cancelAuth(contextId); - if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { - console.info("cancel auth success"); - } else { - console.error("cancel auth fail"); - } - ``` +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +// contextId可通过auth接口获取,此处直接定义 +let contextId = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7]); +let auth = new userIAM_userAuth.UserAuth(); +let cancelCode = auth.cancelAuth(contextId); +if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { + console.info("cancel auth success"); +} else { + console.error("cancel auth fail"); +} +``` ## IUserAuthCallback(deprecated) +返回认证结果的回调对象。 + > **说明:** > 从 API version 9 开始废弃,建议使用[AuthEvent](#authevent9)代替。
从 API version 8 开始支持。 -认证过程中回调结果的对象。 - ### onResult(deprecated) onResult: (result : number, extraInfo : AuthResult) => void +回调函数,返回认证结果。 + > **说明:** > 从 API version 9 开始废弃,建议使用[callback](#callback9)代替。
从 API version 8 开始支持。 -表示在认证操作中,获取认证结果。 - **系统能力**:SystemCapability.UserIAM.UserAuth.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | -------------------------- | ---- | ------------------------------------------------------------ | -| result | number | 是 | 认证结果,参见[ResultCode](#resultcodedeprecated)。 | -| extraInfo | [AuthResult](#authresultdeprecated) | 是 | 扩展信息,不同情况下的具体信息,
如果身份验证通过,则在extrainfo中返回用户认证令牌,
如果身份验证失败,则在extrainfo中返回剩余的用户认证次数,
如果身份验证执行器被锁定,则在extrainfo中返回冻结时间。 | - +| 参数名 | 类型 | 必填 | 说明 | +| --------- | -------------------------- | ---- | ------------------------------------------------ | +| result | number | 是 | 认证结果,参见[ResultCode](#resultcodedeprecated)。 | +| extraInfo | [AuthResult](#authresultdeprecated) | 是 | 扩展信息,不同情况下的具体信息,
如果身份验证通过,则在extraInfo中返回用户认证令牌,
如果身份验证失败,则在extraInfo中返回剩余的用户认证次数,
如果身份验证执行器被锁定,则在extraInfo中返回冻结时间。 | **示例:** - ```js - 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); - } - }, - - 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); - } - } - }); - ``` +```js +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); + } + } +}); +``` ### onAcquireInfo(deprecated) onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void +回调函数,返回认证过程中的提示信息,非必须实现。 + > **说明:** > 从 API version 9 开始废弃,建议使用[callback](#callback9)代替。
从 API version 8 开始支持。 -表示在认证过程中,获取提示码信息,非必须实现。 - **系统能力**:SystemCapability.UserIAM.UserAuth.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ------------------------------ | -| module | number | 是 | 认证执行器的类型。 | -| acquire | number | 是 | 认证执行器认证过程的交互信息。 | +| module | number | 是 | 发送提示信息的模块标识。 | +| acquire | number | 是 | 认证执过程中的提示信息。 | | extraInfo | any | 是 | 预留字段。 | **示例:** - ```js - 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); - } - }, - - 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); - } - } - }); - ``` +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +let auth = new userIAM_userAuth.UserAuth(); +auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { + 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); + } + } +}); +``` ## AuthResult(deprecated) +表示认证结果的对象。 + > **说明:** > 从 API version 9 开始废弃,建议使用[AuthResultInfo](#authresultinfo9)代替。
从 API version 8 开始支持。 -表示认证结果的对象。 - **系统能力**:SystemCapability.UserIAM.UserAuth.Core -| 名称 | 参数类型 | 必填 | 说明 | -| ------------ | ---------- | ---- | -------------------- | -| token | Uint8Array | 否 | 身份认证令牌。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ---------- | ---- | -------------------| +| token | Uint8Array | 否 | 认证通过的令牌信息。 | | remainTimes | number | 否 | 剩余的认证操作次数。 | | freezingTime | number | 否 | 认证操作的冻结时间。 | ## ResultCode(deprecated) +表示返回码的枚举。 + > **说明:** > 从 API version 9 开始废弃,建议使用[ResultCodeV9](#resultcodev99)代替。 -表示执行结果的枚举。 - **系统能力**:SystemCapability.UserIAM.UserAuth.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ----------------------- | ------ | -------------------- | | SUCCESS | 0 | 执行成功。 | | FAIL | 1 | 执行失败。 | @@ -906,14 +816,13 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void | LOCKED | 9 | 认证器已锁定。 | | NOT_ENROLLED | 10 | 用户未录入认证信息。 | - ## FaceTips8+ 表示人脸认证过程中提示码的枚举。 **系统能力**:SystemCapability.UserIAM.UserAuth.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ----------------------------- | ------ | ------------------------------------ | | FACE_AUTH_TIP_TOO_BRIGHT | 1 | 光线太强,获取的图像太亮。 | | FACE_AUTH_TIP_TOO_DARK | 2 | 光线太暗,获取的图像太暗。 | @@ -934,7 +843,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void **系统能力**:SystemCapability.UserIAM.UserAuth.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | --------------------------------- | ------ | -------------------------------------------------- | | FINGERPRINT_AUTH_TIP_GOOD | 0 | 获取的指纹图像良好。 | | FINGERPRINT_AUTH_TIP_DIRTY | 1 | 由于传感器上可疑或检测到的污垢,指纹图像噪音过大。 | @@ -950,7 +859,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void **系统能力**:SystemCapability.UserIAM.UserAuth.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ----------- | ------ | ---------- | | FACE | 2 | 人脸认证。 | | FINGERPRINT | 4 | 指纹认证。 | @@ -961,7 +870,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void **系统能力**:SystemCapability.UserIAM.UserAuth.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ---- | ------ | ------------------------- | | ATL1 | 10000 | 认证结果的信任等级级别1。 | | ATL2 | 20000 | 认证结果的信任等级级别2。 | @@ -972,11 +881,11 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void getAuthenticator(): Authenticator +获取Authenticator对象,用于执行用户身份认证。 + > **说明:** > 从 API version 8 开始废弃,建议使用[constructor](#constructordeprecated)替代。 -获取Authenticator对象,用于执行用户身份认证。 - **系统能力**:SystemCapability.UserIAM.UserAuth.Core **返回值:** @@ -992,61 +901,61 @@ getAuthenticator(): Authenticator ## Authenticator(deprecated) -> **说明:** -> 从 API version 8 开始废弃,建议使用[UserAuth](#userauth8)替代。 - 认证器对象。 +> **说明:** +> 从 API version 8 开始废弃,建议使用[UserAuth](#userauth8)替代。 ### execute(deprecated) execute(type: AuthType, level: SecureLevel, callback: AsyncCallback<number>): void +执行用户认证,使用callback方式作为异步方法。 + > **说明:** > 从 API version 8 开始废弃,建议使用[auth](#authdeprecated)替代。 -执行用户认证,使用callback方式作为异步方法。 - **需要权限**:ohos.permission.ACCESS_BIOMETRIC **系统能力**:SystemCapability.UserIAM.UserAuth.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------- | ---- | ------------------------------------------------------------ | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------------------- | | type | AuthType | 是 | 认证类型,当前只支持"FACE_ONLY"。
ALL为预留参数,当前版本暂不支持ALL类型的认证。 | -| level | SecureLevel | 是 | 安全级别,对应认证的安全级别,有效值为"S1"(最低)、"S2"、"S3"、"S4"(最高)。
具备3D人脸识别能力的设备支持"S3"及以下安全级别的认证。
具备2D人脸识别能力的设备支持"S2"及以下安全级别的认证。 | -| callback | AsyncCallback<number> | 否 | 回调函数。 | +| level | SecureLevel | 是 | 安全级别,对应认证的安全级别,有效值为"S1"(最低)、"S2"、"S3"、"S4"(最高)。
具备3D人脸识别能力的设备支持"S3"及以下安全级别的认证。
具备2D人脸识别能力的设备支持"S2"及以下安全级别的认证。 | +| callback | AsyncCallback<number> | 是 | 回调函数。 | - callback返回值: +callback返回值: | 类型 | 说明 | | ------ | ------------------------------------------------------------ | | number | 表示认证结果,参见[AuthenticationResult](#authenticationresultdeprecated)。 | **示例:** - ```js - let authenticator = userIAM_userAuth.getAuthenticator(); - authenticator.execute("FACE_ONLY", "S2", (error, code)=>{ - if (code === userIAM_userAuth.ResultCode.SUCCESS) { - console.info("auth success"); - return; - } - console.error("auth fail, code = " + code); - }); - ``` + +```js +let authenticator = userIAM_userAuth.getAuthenticator(); +authenticator.execute("FACE_ONLY", "S2", (error, code)=>{ + if (code === userIAM_userAuth.ResultCode.SUCCESS) { + console.info("auth success"); + return; + } + console.error("auth fail, code = " + code); +}); +``` ### execute(deprecated) -execute(type:AuthType, level:SecureLevel): Promise<number> +execute(type : AuthType, level : SecureLevel): Promise<number> + +执行用户认证,使用promise方式作为异步方法。 > **说明:** > 从 API version 8 开始废弃,建议使用[auth](#authdeprecated)替代。 -执行用户认证,使用promise方式作为异步方法。 - **需要权限**:ohos.permission.ACCESS_BIOMETRIC **系统能力**:SystemCapability.UserIAM.UserAuth.Core @@ -1066,25 +975,25 @@ execute(type:AuthType, level:SecureLevel): Promise<number> **示例:** - ```js - let authenticator = userIAM_userAuth.getAuthenticator(); - authenticator.execute("FACE_ONLY", "S2").then((code)=>{ - console.info("auth success"); - }).catch((error)=>{ - console.error("auth fail, code = " + error); - }); - ``` +```js +let authenticator = userIAM_userAuth.getAuthenticator(); +authenticator.execute("FACE_ONLY", "S2").then((code)=>{ + console.info("auth success"); +}).catch((error)=>{ + console.error("auth fail, code = " + error); +}); +``` ## AuthenticationResult(deprecated) +表示认证结果的枚举。 + > **说明:** > 从 API version 8 开始废弃,建议使用[ResultCode](#resultcodedeprecated)替代。 -表示认证结果的枚举。 - **系统能力**:SystemCapability.UserIAM.UserAuth.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ------------------ | ------ | -------------------------- | | NO_SUPPORT | -1 | 设备不支持当前的认证方式。 | | SUCCESS | 0 | 认证成功。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-wantAgent.md b/zh-cn/application-dev/reference/apis/js-apis-wantAgent.md index 63cd96b618711a3ac07affef4dd65580b966859b..db65d8906e8cf0c79586dfa4679d190a0b330fe9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wantAgent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wantAgent.md @@ -1,6 +1,6 @@ # WantAgent模块 -WantAgent模块提供了触发、取消、比较WantAgent实例和获取bundle名称的能力,包括创建WantAgent实例、获取实例的用户ID、获取want信息等。 +WantAgent模块提供了触发、取消、比较WantAgent实例和获取bundle参数名的能力,包括创建WantAgent实例、获取实例的用户ID、获取want信息等。 > **说明:** > @@ -22,7 +22,7 @@ getWantAgent(info: WantAgentInfo, callback: AsyncCallback\): void **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | -------- | --- | ---- | -------------------------- | ---- | ----------------------- | | info | 是 | 否 | WantAgentInfo | 是 | WantAgent信息。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 创建WantAgent的回调方法。 | @@ -79,7 +79,7 @@ getWantAgent(info: WantAgentInfo): Promise\ **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | ---- | --- | ---- | ------------- | ---- | ------------- | | info | 是 | 否 | WantAgentInfo | 是 | WantAgent信息。 | @@ -140,7 +140,7 @@ getBundleName(agent: WantAgent, callback: AsyncCallback\): void **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | -------- | --- | ---- | ----------------------- | ---- | --------------------------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 获取WantAgent实例的包名的回调方法。 | @@ -212,7 +212,7 @@ getBundleName(agent: WantAgent): Promise\ **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | ----- | --- | ---- | --------- | ---- | ------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | @@ -281,7 +281,7 @@ getUid(agent: WantAgent, callback: AsyncCallback\): void **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | -------- | --- | ---- | ----------------------- | ---- | ----------------------------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 获取WantAgent实例的用户ID的回调方法。 | @@ -353,7 +353,7 @@ getUid(agent: WantAgent): Promise\ **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | ----- | --- | ---- | --------- | ---- | ------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | @@ -424,7 +424,7 @@ getWant(agent: WantAgent, callback: AsyncCallback\): void **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | -------- | --- | ---- | --------------------- | ---- | ------------------------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 获取WantAgent对象want的回调方法。 | @@ -498,7 +498,7 @@ getWant(agent: WantAgent): Promise\ **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | ----- | --- | ---- | --------- | ---- | ------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | @@ -567,7 +567,7 @@ cancel(agent: WantAgent, callback: AsyncCallback\): void **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | -------- | --- | ---- | --------------------- | ---- | --------------------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 取消WantAgent实例的回调方法。 | @@ -639,7 +639,7 @@ cancel(agent: WantAgent): Promise\ **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | ----- | --- | ---- | --------- | ---- | ------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | @@ -708,7 +708,7 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback\ **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | ---------- | --- | ---- | --------- | ---- | ------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | | otherAgent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | @@ -930,7 +930,7 @@ getOperationType(agent: WantAgent, callback: AsyncCallback\): void; **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | ---------- | --- | ---- | ------------------------ | ---- | --------------------------------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 获取一个WantAgent的OperationType信息的回调方法。 | @@ -991,7 +991,7 @@ getOperationType(agent: WantAgent): Promise\; **参数:** -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 参数名 | 可读 | 可写 | 类型 | 必填 | 说明 | | ---------- | --- | ---- | --------- | ---- | ------------- | | agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | @@ -1049,13 +1049,11 @@ WantAgent.getOperationType(wantAgent).then((OperationType) => { }) ``` - - ## WantAgentInfo **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 | | -------------- | --- | ---- | ------------------------------- | ---- | ---------------------- | | wants | 是 | 是 | Array\ | 是 | 将被执行的动作列表。 | | operationType | 是 | 是 | wantAgent.OperationType | 是 | 动作类型。 | @@ -1063,26 +1061,22 @@ WantAgent.getOperationType(wantAgent).then((OperationType) => { | wantAgentFlags | 是 | 是 | Array | 否 | 动作执行属性。 | | extraInfo | 是 | 是 | {[key: string]: any} | 否 | 额外数据。 | - - ## WantAgentFlags **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core | 名称 | 值 | 说明 | | ------------------- | -------------- | ------------------------------------------------------------ | -| ONE_TIME_FLAG | WantAgentFlags | WantAgent仅能使用一次。 | -| NO_BUILD_FLAG | WantAgentFlags | 如果描述WantAgent对象不存在,则不创建它,直接返回null。 | -| CANCEL_PRESENT_FLAG | WantAgentFlags | 在生成一个新的WantAgent对象前取消已存在的一个WantAgent对象。 | -| UPDATE_PRESENT_FLAG | WantAgentFlags | 使用新的WantAgent的额外数据替换已存在的WantAgent中的额外数据。 | -| CONSTANT_FLAG | WantAgentFlags | WantAgent是不可变的。 | -| REPLACE_ELEMENT | WantAgentFlags | 当前Want中的element属性可被WantAgent.trigger()中Want的element属性取代 | -| REPLACE_ACTION | WantAgentFlags | 当前Want中的action属性可被WantAgent.trigger()中Want的action属性取代 | -| REPLACE_URI | WantAgentFlags | 当前Want中的uri属性可被WantAgent.trigger()中Want的uri属性取代 | -| REPLACE_ENTITIES | WantAgentFlags | 当前Want中的entities属性可被WantAgent.trigger()中Want的entities属性取代 | -| REPLACE_BUNDLE | WantAgentFlags | 当前Want中的bundleName属性可被WantAgent.trigger()中Want的bundleName属性取代 | - - +| ONE_TIME_FLAG | 0 | WantAgent仅能使用一次。 | +| NO_BUILD_FLAG | 1 | 如果说明WantAgent对象不存在,则不创建它,直接返回null。 | +| CANCEL_PRESENT_FLAG | 2 | 在生成一个新的WantAgent对象前取消已存在的一个WantAgent对象。 | +| UPDATE_PRESENT_FLAG | 3 | 使用新的WantAgent的额外数据替换已存在的WantAgent中的额外数据。 | +| CONSTANT_FLAG | 4 | WantAgent是不可变的。 | +| REPLACE_ELEMENT | 5 | 当前Want中的element属性可被WantAgent.trigger()中Want的element属性取代 | +| REPLACE_ACTION | 6 | 当前Want中的action属性可被WantAgent.trigger()中Want的action属性取代 | +| REPLACE_URI | 7 | 当前Want中的uri属性可被WantAgent.trigger()中Want的uri属性取代 | +| REPLACE_ENTITIES | 8 | 当前Want中的entities属性可被WantAgent.trigger()中Want的entities属性取代 | +| REPLACE_BUNDLE | 9 | 当前Want中的bundleName属性可被WantAgent.trigger()中Want的bundleName属性取代 | ## OperationType @@ -1090,19 +1084,17 @@ WantAgent.getOperationType(wantAgent).then((OperationType) => { | 名称 | 值 | 说明 | | ----------------- | ------------- | ------------------------- | -| UNKNOWN_TYPE | OperationType | 不识别的类型。 | -| START_ABILITY | OperationType | 开启一个有页面的Ability。 | -| START_ABILITIES | OperationType | 开启多个有页面的Ability。 | -| START_SERVICE | OperationType | 开启一个无页面的ability。 | -| SEND_COMMON_EVENT | OperationType | 发送一个公共事件。 | - - +| UNKNOWN_TYPE | 0 | 不识别的类型。 | +| START_ABILITY | 1 | 开启一个有页面的Ability。 | +| START_ABILITIES | 2 | 开启多个有页面的Ability。 | +| START_SERVICE | 3 | 开启一个无页面的ability。 | +| SEND_COMMON_EVENT | 4 | 发送一个公共事件。 | ## CompleteData **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 | | -------------- | --- | ---- | ------------------------------ | ---- | ---------------------- | | info | 是 | 是 | WantAgent | 是 | 触发的wantAgent。 | | want | 是 | 是 | Want | 是 | 存在的被触发的want。 | @@ -1110,13 +1102,11 @@ WantAgent.getOperationType(wantAgent).then((OperationType) => { | finalData | 是 | 是 | string | 否 | 公共事件收集的最终数据。 | | extraInfo | 是 | 是 | {[key: string]: any} | 否 | 额外数据。 | - - ## TriggerInfo **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 | | ---------- | --- | ---- | -------------------- | ---- | ----------- | | code | 是 | 是 | number | 是 | result code。 | | want | 是 | 是 | Want | 否 | Want。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-webview.md b/zh-cn/application-dev/reference/apis/js-apis-webview.md index 34e32a7810d8dc63369971310ffdbdb154bf2625..5c6bfe69b993af30ad3582d84f5e425f2d46fc5d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webview.md @@ -72,7 +72,7 @@ postMessageEvent(message: string): void | ------- | ------ | ---- | :------------- | | message | string | 是 | 要发送的消息。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -122,9 +122,9 @@ onMessageEvent(callback: (result: string) => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | :------------------- | -| callback | function | 是 | 接收消息的回调函数。 | +| result | string | 是 | 接收到的消息。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -198,10 +198,10 @@ loadUrl(url: string | Resource, headers?: Array\): void | 参数名 | 类型 | 必填 | 说明 | | ------- | ---------------- | ---- | :-------------------- | -| url | string | 是 | 需要加载的 URL。 | +| url | string \| Resource | 是 | 需要加载的 URL。 | | headers | Array\<[HeaderV9](#headerv9)> | 否 | URL的附加HTTP请求头。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -254,9 +254,9 @@ loadData(data: string, mimeType: string, encoding: string, baseUrl?: string, his | mimeType | string | 是 | 媒体类型(MIME)。 | | encoding | string | 是 | 编码类型,具体为“Base64"或者”URL编码。 | | baseUrl | string | 否 | 指定的一个URL路径(“http”/“https”/"data"协议),并由Web组件赋值给window.origin。 | -| historyUrl | string | 否 | 历史记录URL。非空时,可被历史记录管理,实现前进后退功能。当baseUrl为空时,此属性无效。 | +| historyUrl | string | 否 | 用作历史记录所使用的URL。非空时,历史记录以此URL进行管理。当baseUrl为空时,此属性无效。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -310,7 +310,7 @@ accessForward(): boolean | ------- | --------------------------------- | | boolean | 可以前进返回true,否则返回false。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -354,7 +354,7 @@ forward(): void **系统能力:** SystemCapability.Web.Webview.Core -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -447,7 +447,7 @@ backward(): void **系统能力:** SystemCapability.Web.Webview.Core -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -805,6 +805,14 @@ struct Index { build() { Column() { + Button('refresh') + .onClick(() => { + try { + this.controller.refresh(); + } catch (error) { + console.error(`Errorcode: ${error.code}, Message: ${error.message}`); + } + }) Button('Register JavaScript To Window') .onClick(() => { try { @@ -833,7 +841,7 @@ runJavaScript(script: string, callback : AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ---------------------------- | | script | string | 是 | JavaScript脚本。 | -| callback | AsyncCallback\ | 否 | 回调执行JavaScript脚本结果。JavaScript脚本若执行失败或无返回值时,返回null。 | +| callback | AsyncCallback\ | 是 | 回调执行JavaScript脚本结果。JavaScript脚本若执行失败或无返回值时,返回null。 | **错误码:** @@ -1059,9 +1067,9 @@ searchAllAsync(searchString: string): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------------ | -------- | ---- | ------ | -------------- | -| searchString | string | 是 | - | 查找的关键字。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | -------- | ---- | -------------- | +| searchString | string | 是 | 查找的关键字。 | **错误码:** @@ -1295,7 +1303,7 @@ struct WebComponent { | ---------------------- | ----------------- | | Array\ | web消息端口列表。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1348,7 +1356,7 @@ postMessage(name: string, ports: Array\, uri: string): void | ports | Array\ | 是 | 接收该消息的URI。 | | uri | string | 是 | 接收该消息的URI。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1472,7 +1480,7 @@ requestFocus(): void **系统能力:** SystemCapability.Web.Webview.Core -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1515,7 +1523,7 @@ zoomIn(): void **系统能力:** SystemCapability.Web.Webview.Core -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1559,7 +1567,7 @@ zoomOut(): void **系统能力:** SystemCapability.Web.Webview.Core -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1609,7 +1617,7 @@ getHitTestValue(): HitTestValue | ------------ | -------------------- | | [HitTestValue](#hittestvalue) | 点击区域的元素信息。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1660,7 +1668,7 @@ getWebId(): number | ------ | --------------------- | | number | 当前Web组件的索引值。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1710,7 +1718,7 @@ getUserAgent(): string | ------ | -------------- | | string | 默认用户代理。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1760,7 +1768,7 @@ getTitle(): string | ------ | -------------------- | | string | 返回文件选择器标题。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1810,7 +1818,7 @@ getPageHeight(): number | ------ | -------------------- | | number | 当前网页的页面高度。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1862,7 +1870,7 @@ storeWebArchive(baseName: string, autoName: boolean, callback: AsyncCallback\ | 是 | 返回文件存储路径,保持网页失败会返回null。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1927,7 +1935,7 @@ storeWebArchive(baseName: string, autoName: boolean): Promise\ | --------------- | ----------------------------------------------------- | | Promise\ | Promise实例,保存成功返回文件路径,保存失败返回null。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -1985,7 +1993,7 @@ getUrl(): string | ------ | ------------------- | | string | 当前页面的url地址。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -2029,7 +2037,7 @@ stop(): void **系统能力:** SystemCapability.Web.Webview.Core -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -2078,7 +2086,7 @@ backOrForward(step: number): void | ------ | -------- | ---- | ---------------------- | | step | number | 是 | 需要前进或后退的步长。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -2138,7 +2146,7 @@ static getCookie(url: string): string | ------ | ------------------------- | | string | 指定url对应的cookie的值。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) @@ -2189,14 +2197,14 @@ static setCookie(url: string, value: string): void | url | string | 是 | 要设置的cookie所属的url。 | | value | string | 是 | 要设置的cookie的值。 | -**错误码**: +**错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) | 错误码ID | 错误信息 | | -------- | ------------------------------------------------------ | | 17100002 | Invalid url. | -| 17100005 | Invaild cookie value. | +| 17100005 | Invalid cookie value. | **示例:** @@ -3217,6 +3225,133 @@ struct WebComponent { } ``` +## WebAsyncController + +通过WebAsyncController可以控制Web组件具有异步回调通知的行为,一个WebAsyncController对象控制一个Web组件。 + +### 创建对象 + + ```ts + // xxx.ets + import web_webview from '@ohos.web.webview' + + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + webAsyncController: WebAsyncController = new web_webview.WebAsyncController(this.controller) + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### constructor9+ + +constructor(controller: WebController) + +WebAsyncController的创建需要与一个[WebController](../arkui-ts/ts-basic-components-web.md#webcontroller)进行绑定。 + +**系统能力:** SystemCapability.Web.Webview.Core + +**参数:** + +| 参数名| 类型 | 必填 | 说明 | +| ----- | ---- | ---- | --- | +| controller | [WebController](../arkui-ts/ts-basic-components-web.md#webcontroller) | 是 | 所绑定的WebviewController。| + +### storeWebArchive9+ + +storeWebArchive(baseName: string, autoName: boolean, callback: AsyncCallback\): void + +以回调方式异步保存当前页面。 + +**系统能力:** SystemCapability.Web.Webview.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------------------------- | +| baseName | string | 是 | 文件存储路径,该值不能为空。 +| autoName | boolean | 是 | 决定是否自动生成文件名。
如果为false,则将baseName作为文件存储路径。
如果为true,则假定baseName是一个目录,将根据当前页的Url自动生成文件名。 +| callback | AsyncCallback\ | 是 | 返回文件存储路径,保持网页失败会返回null。 | + +**示例:** + + ```ts + // xxx.ets + import web_webview from '@ohos.web.webview' + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController() + build() { + Column() { + Button('saveWebArchive') + .onClick(() => { + let webAsyncController = new web_webview.WebAsyncController(this.controller) + webAsyncController.storeWebArchive("/data/storage/el2/base/", true, (filename) => { + if (filename != null) { + console.info(`save web archive success: ${filename}`) + } + }) + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### storeWebArchive9+ + +storeWebArchive(baseName: string, autoName: boolean): Promise\ + +以Promise方式异步保存当前页面。 + +**系统能力:** SystemCapability.Web.Webview.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------------------------- | +| baseName | string | 是 | 文件存储路径,该值不能为空。 +| autoName | boolean | 是 | 决定是否自动生成文件名。
如果为false,则将baseName作为文件存储路径。
如果为true,则假定baseName是一个目录,将根据当前页的Url自动生成文件名。 + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | ---------------------------------------- | +| Promise | Promise实例,保存成功返回文件路径,保存失败返回null。 | + +**示例:** + + ```ts + // xxx.ets + import web_webview from '@ohos.web.webview' + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + build() { + Column() { + Button('saveWebArchive') + .onClick(() => { + let webAsyncController = new web_webview.WebAsyncController(this.controller); + webAsyncController.storeWebArchive("/data/storage/el2/base/", true) + .then(filename => { + if (filename != null) { + console.info(`save web archive success: ${filename}`) + } + }) + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + ## GeolocationPermissions web组件地理位置权限管理对象。 @@ -3231,9 +3366,9 @@ static allowGeolocation(origin: string): void **参数:** -| 参数名 | 类型 | 说明 | -| ------ | ------ | ------------------ | -| origin | string | 指定源的字符串索引 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| origin | string | 是 |指定源的字符串索引 | **错误码:** @@ -3388,7 +3523,7 @@ static getAccessibleGeolocation(origin: string): Promise\ **参数:** -| 参数名 | 参数类型 | 必填 | 参数描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | -------------------- | | origin | string | 是 | 指定源的字符串索引。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index 4c66441fc26b614e59638a583f5b93f7e3914f4c..72a87f562421a03d563b743ed75209860418e460 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -108,14 +108,14 @@ import window from '@ohos.window'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 类型 | 可读 | 可写 | 必填 | 说明 | -| -------------------------------------- | -------- | ---- | ---- | ---- | ------------------------------------------------------------ | -| statusBarColor | string | 否 | 是 | 否 | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。默认值:`#0x66000000`。 | -| isStatusBarLightIcon7+ | boolean | 否 | 是 | 否 | 状态栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 | -| statusBarContentColor8+ | string | 否 | 是 | 否 | 状态栏文字颜色。当设置此属性后, `isStatusBarLightIcon`属性设置无效。默认值:`0xE5FFFFFF。` | -| navigationBarColor | string | 否 | 是 | 否 | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。默认值:`#0x66000000。` | -| isNavigationBarLightIcon7+ | boolean | 否 | 是 | 否 | 导航栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 | -| navigationBarContentColor8+ | string | 否 | 是 | 否 | 导航栏文字颜色。当设置此属性后, `isNavigationBarLightIcon`属性设置无效。默认值:`#0xE5FFFFFF。` | +| 名称 | 类型 | 必填 | 说明 | +| -------------------------------------- | -------- | ---- | ------------------------------------------------------------ | +| statusBarColor | string | 否 | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。默认值:`#0x66000000`。 | +| isStatusBarLightIcon7+ | boolean | 否 | 状态栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 | +| statusBarContentColor8+ | string | 否 | 状态栏文字颜色。当设置此属性后, `isStatusBarLightIcon`属性设置无效。默认值:`0xE5FFFFFF。` | +| navigationBarColor | string | 否 | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。默认值:`#0x66000000。` | +| isNavigationBarLightIcon7+ | boolean | 否 | 导航栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 | +| navigationBarContentColor8+ | string | 否 | 导航栏文字颜色。当设置此属性后, `isNavigationBarLightIcon`属性设置无效。默认值:`#0xE5FFFFFF。` | ## Orientation9+ @@ -248,7 +248,7 @@ import window from '@ohos.window'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | ---------- | ------ | -------------- | | DEFAULT | 0 | 默认色域模式。 | | WIDE_GAMUT | 1 | 广色域模式。 | @@ -1987,7 +1987,7 @@ setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncC | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------- | -- | --------- | -| names | Array<'status'|'navigation'> | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | +| names | Array<'status'\|'navigation'> | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **错误码:** @@ -2029,7 +2029,7 @@ setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void | 参数名 | 类型 | 必填 | 说明 | | ----- | ---------------------------- | -- | --------------------------------- | -| names | Array<'status'|'navigation'> | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | +| names | Array<'status'\|'navigation'> | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | **返回值:** @@ -4809,7 +4809,7 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallbac | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ | -| names | Array<'status'|'navigation'> | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | +| names | Array<'status'\|'navigation'> | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** @@ -4842,7 +4842,7 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------ | ---------------------------- | ---- | ------------------------ | -| names | Array<'status'|'navigation'> | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | +| names | Array<'status'\|'navigation'> | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | **返回值:** @@ -5852,12 +5852,12 @@ WindowStage生命周期。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | ---------- | ------ | ---------- | -| SHOWN | 1 | 切到前台。 | +| FOREGROUND | 1 | 切到前台。 | | ACTIVE | 2 | 获焦状态。 | | INACTIVE | 3 | 失焦状态。 | -| HIDDEN | 4 | 切到后台。 | +| BACKGROUND | 4 | 切到后台。 | ## WindowStage9+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md new file mode 100644 index 0000000000000000000000000000000000000000..546e615bff5693e2738953352d77fbdefebc77bd --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @@ -0,0 +1,362 @@ +# 延迟任务调度 + +本模块提供延迟任务注册、取消、查询的能力。 + +开发者在开发应用时,通过调用延迟任务注册接口,注册对实时性要求不高的延迟任务,该任务默认由系统安排,在系统空闲时根据性能、功耗、热等情况进行调度执行。 + +> **说明:** +> +> - 从API Version 9 开始,该接口不再维护,推荐使用新接口[@ohos.resourceschedule.workScheduler (延迟任务调度)](js-apis-resourceschedule-workScheduler.md)。 +> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 本模块接口仅可在Stage模型下使用。 +> - 延迟任务调度约束见[延迟任务调度约束](../../task-management/background-task-overview.md#延迟任务调度约束)。 + + +## 导入模块 + +```js +import workScheduler from '@ohos.workScheduler'; +``` + +## workScheduler.startWork +startWork(work: WorkInfo): boolean + +通知WorkSchedulerService将工作添加到执行队列。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 名称 | 类型 | 必填 | 说明 | +| ---- | --------------------- | ---- | -------------- | +| work | [WorkInfo](#workinfo) | 是 | 指示要添加到执行队列的工作。 | + +**返回值**: + +| 类型 | 说明 | +| ------- | -------------------------------- | +| boolean | 如果工作成功添加到执行队列,则返回true,否则返回false。 | + +**示例**: + +```js + let workInfo = { + workId: 1, + batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, + isRepeat: false, + isPersisted: true, + bundleName: "com.example.myapplication", + abilityName: "MyExtension", + parameters: { + mykey0: 1, + mykey1: "string value", + mykey2: true, + mykey3: 1.5 + } + } + let res = workScheduler.startWork(workInfo); + console.info(`workschedulerLog res: ${res}`); +``` + +## workScheduler.stopWork +stopWork(work: WorkInfo, needCancel?: boolean): boolean + +通知WorkSchedulerService停止指定工作。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 名称 | 类型 | 必填 | 说明 | +| ---------- | --------------------- | ---- | ---------- | +| work | [WorkInfo](#workinfo) | 是 | 指示要停止的工作。 | +| needCancel | boolean | 是 | 是否需要取消的工作。 | + +**返回值**: + +| 类型 | 说明 | +| ------- | ----------------------- | +| boolean | 如果成功,则返回true,否则返回false。 | + +**示例**: + +```js + let workInfo = { + workId: 1, + batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, + isRepeat: false, + isPersisted: true, + bundleName: "com.example.myapplication", + abilityName: "MyExtension", + parameters: { + mykey0: 1, + mykey1: "string value", + mykey2: true, + mykey3: 1.5 + } + } + let res = workScheduler.stopWork(workInfo, false); + console.info(`workschedulerLog res: ${res}`); +``` + +## workScheduler.getWorkStatus +getWorkStatus(workId: number, callback : AsyncCallback\): void + +获取工作的最新状态,使用Callback形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | ---------------------------------------- | +| workId | number | 是 | work的id。 | +| callback | AsyncCallback\<[WorkInfo](#workinfo)> | 是 | 指定的callback回调方法。如果指定的工作Id有效,则返回从WorkSchedulerService获取的有效工作状态;否则返回null。 | + +**示例**: + +```js + workScheduler.getWorkStatus(50, (err, res) => { + if (err) { + console.info(`workschedulerLog getWorkStatus failed, because: ${err.code}`); + } else { + for (let item in res) { + console.info(`workschedulerLog getWorkStatus success, ${item} is: ${res[item]}`); + } + } + }); +``` + +## workScheduler.getWorkStatus +getWorkStatus(workId: number): Promise\ + +获取工作的最新状态,使用Promise形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| workId | number | 是 | work的id。 | + +**返回值**: + +| 类型 | 说明 | +| ------------------------------- | ---------------------------------------- | +| Promise\<[WorkInfo](#workinfo)> | 指定的Promise回调方法。如果指定的工作ID有效,则返回从WorkSchedulerService获取的有效工作状态;否则返回null。 | + +**示例**: + +```js + workScheduler.getWorkStatus(50).then((res) => { + for (let item in res) { + console.info(`workschedulerLog getWorkStatus success, ${item} is: ${res[item]}`); + } + }).catch((err) => { + console.info(`workschedulerLog getWorkStatus failed, because: ${err.code}`); + }) +``` + +## workScheduler.obtainAllWorks +obtainAllWorks(callback : AsyncCallback\): Array\ + +获取与当前应用程序关联的所有工作,使用Callback形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------------------- | +| callback | AsyncCallback\ | 是 | 指定的callback回调方法。返回与应用程序关联的所有工作。 | + +**返回值**: + +| 类型 | 说明 | +| ----------------------------- | --------------- | +| Array\<[WorkInfo](#workinfo)> | 返回与应用程序关联的所有工作。 | + +**示例**: + +```js + workScheduler.obtainAllWorks((err, res) =>{ + if (err) { + console.info(`workschedulerLog obtainAllWorks failed, because: ${err.code}`); + } else { + console.info(`workschedulerLog obtainAllWorks success, data is: ${JSON.stringify(res)}`); + } + }); +``` + +## workScheduler.obtainAllWorks +obtainAllWorks(): Promise> + +获取与当前应用程序关联的所有工作,使用Promise形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**返回值**: + +| 类型 | 说明 | +| -------------------------------------- | ------------------------------ | +| Promise> | 指定的Promise回调方法。返回与应用程序关联的所有工作。 | + +**示例**: + +```js + workScheduler.obtainAllWorks().then((res) => { + console.info(`workschedulerLog obtainAllWorks success, data is: ${JSON.stringify(res)}`); + }).catch((err) => { + console.info(`workschedulerLog obtainAllWorks failed, because: ${err.code}`); + }) +``` + +## workScheduler.stopAndClearWorks +stopAndClearWorks(): boolean + +停止和取消与当前应用程序关联的所有工作。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**示例**: + +```js + let res = workScheduler.stopAndClearWorks(); + console.info(`workschedulerLog res: ${res}`); +``` + +## workScheduler.isLastWorkTimeOut +isLastWorkTimeOut(workId: number, callback : AsyncCallback\): boolean + +检查指定工作的最后一次执行是否为超时操作,使用Callback形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------------------------------- | +| workId | number | 是 | work的id。 | +| callback | AsyncCallback\ | 是 | 指定的callback回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | + +**返回值**: + +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 指定的callback回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | + +**示例**: + +```js + workScheduler.isLastWorkTimeOut(500, (err, res) =>{ + if (err) { + console.info(`workschedulerLog isLastWorkTimeOut failed, because: ${err.code}`); + } else { + console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`); + } + }); +``` + +## workScheduler.isLastWorkTimeOut +isLastWorkTimeOut(workId: number): Promise\ + +检查指定工作的最后一次执行是否为超时操作,使用Promise形式返回。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +**参数**: + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| workId | number | 是 | work的id。 | + +**返回值**: + +| 类型 | 说明 | +| ----------------- | ---------------------------------------- | +| Promise\ | 指定的Promise回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | + +**示例**: + +```js + workScheduler.isLastWorkTimeOut(500) + .then(res => { + console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`); + }) + .catch(err => { + console.info(`workschedulerLog isLastWorkTimeOut failed, because: ${err.code}`); + }); +``` + +## WorkInfo +提供工作的具体信息。WorkInfo设置参数约束见[延迟任务调度概述](../../task-management/background-task-overview.md#延迟任务调度约束) + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +| 名称 | 类型 | 必填 | 说明 | +| --------------- | --------------------------------- | ---- | ---------------- | +| workId | number | 是 | 当前工作的ID | +| bundleName | string | 是 | 延迟任务包名 | +| abilityName | string | 是 | 延迟任务回调通知的组件名(必填) | +| networkType | [NetworkType](#networktype) | 否 | 网络类型 | +| isCharging | boolean | 否 | 是否充电 | +| chargerType | [ChargingType](#chargingtype) | 否 | 充电类型 | +| batteryLevel | number | 否 | 电量 | +| batteryStatus | [BatteryStatus](#batterystatus) | 否 | 电池状态 | +| storageRequest | [StorageRequest](#storagerequest) | 否 | 存储状态 | +| isRepeat | boolean | 否 | 是否循环任务 | +| repeatCycleTime | number | 否 | 循环间隔 | +| repeatCount | number | 否 | 循环次数 | +| isPersisted | boolean | 否 | 是否持久化保存工作 | +| isDeepIdle | boolean | 否 | 是否要求设备进入空闲状态 | +| idleWaitTime | number | 否 | 空闲等待时间 | +| parameters | {[key: string]: any} | 否 | 携带参数信息 | + +## NetworkType +触发工作的网络类型。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +| 名称 | 值 | 说明 | +| ---------------------- | ---- | ----------------------- | +| NETWORK_TYPE_ANY | 0 | 表示这个触发条件是任何类型的网络连接。 | +| NETWORK_TYPE_MOBILE | 1 | 表示这个触发条件是Mobile网络连接。 | +| NETWORK_TYPE_WIFI | 2 | 表示这个触发条件是Wifi类型的网络连接。 | +| NETWORK_TYPE_BLUETOOTH | 3 | 表示这个触发条件是Bluetooth网络连接。 | +| NETWORK_TYPE_WIFI_P2P | 4 | 表示这个触发条件是Wifi P2P网络连接。 | +| NETWORK_TYPE_ETHERNET | 5 | 表示这个触发条件是有线网络连接。 | + +## ChargingType +触发工作的充电类型。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +| 名称 | 值 | 说明 | +| ------------------------- | ---- | -------------------- | +| CHARGING_PLUGGED_ANY | 0 | 表示这个触发条件是任何类型的充电器连接。 | +| CHARGING_PLUGGED_AC | 1 | 表示这个触发条件是直流充电器连接。 | +| CHARGING_PLUGGED_USB | 2 | 表示这个触发条件是USB充连接。 | +| CHARGING_PLUGGED_WIRELESS | 3 | 表示这个触发条件是无线充电器连接。 | + +## BatteryStatus +触发工作的电池状态。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +| 名称 | 值 | 说明 | +| -------------------------- | ---- | -------------------------- | +| BATTERY_STATUS_LOW | 0 | 表示这个触发条件是低电告警。 | +| BATTERY_STATUS_OKAY | 1 | 表示这个触发条件是从低电恢复到正常电量。 | +| BATTERY_STATUS_LOW_OR_OKAY | 2 | 表示这个触发条件是从低电恢复到正常电量或者低电告警。 | + +## StorageRequest +触发工作的存储状态。 + +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +| 名称 | 值 | 说明 | +| ------------------------- | ---- | ------------------------------ | +| STORAGE_LEVEL_LOW | 0 | 表示这个触发条件是存储空间不足。 | +| STORAGE_LEVEL_OKAY | 1 | 表示这个触发条件是从存储空间不足恢复到正常。 | +| STORAGE_LEVEL_LOW_OR_OKAY | 2 | 表示这个触发条件是从存储空间不足恢复到正常或者存储空间不足。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-worker.md b/zh-cn/application-dev/reference/apis/js-apis-worker.md index 423163c8cd4174b2ac3f845b112107d7cafeec20..c26b6a78be4c33a9460891fc13498d0be67e087c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-worker.md +++ b/zh-cn/application-dev/reference/apis/js-apis-worker.md @@ -16,7 +16,7 @@ import worker from '@ohos.worker'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------------------------------- | --------------------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | | workerPort9+ | [ThreadWorkerGlobalScope](#threadworkerglobalscope9) | 是 | 是 | worker线程用于与宿主线程通信的对象。 | | parentPort(deprecated) | [DedicatedWorkerGlobalScope](#dedicatedworkerglobalscope) | 是 | 是 | worker线程用于与宿主线程通信的对象。
此属性从api9开始被废弃,建议使用workerPort9+。 | @@ -28,9 +28,11 @@ Worker构造函数的选项信息,用于为Worker添加其他信息。 **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | -------- | ---- | ---- | -------------- | +| type | classic \| module | 是 | 是 | Worker执行脚本的模式类型,默认为classic类型,暂不支持module类型。 | | name | string | 是 | 是 | Worker的名称。 | +| shared | boolean | 是 | 是 | 暂不支持共享Worker功能。 | ## ThreadWorker9+ @@ -615,7 +617,7 @@ Worker线程自身的运行环境,GlobalScope类继承[WorkerEventTarget](#wor **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------- | | name | string | 是 | 否 | Worker的名字,new Worker时指定。 | | self | [GlobalScope](#globalscope9) & typeof globalThis | 是 | 否 | GlobalScope本身。 | @@ -1251,7 +1253,7 @@ parentPort.onmessageerror= function(e) { **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | ---- | ---- | --------------------------------- | | transfer | Object[] | 是 | 是 | ArrayBuffer数组,用于传递所有权。 | @@ -1262,7 +1264,7 @@ parentPort.onmessageerror= function(e) { **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | -------- | ---- | ---- | ---------------------------------- | | type | string | 是 | 否 | 指定事件的类型。 | | timeStamp | number | 是 | 否 | 事件创建时的时间戳(精度为毫秒)。 | @@ -1307,7 +1309,7 @@ workerInstance.addEventListener("alert", (e)=>{ **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | ---- | ---- | -------------------- | | message | string | 是 | 否 | 异常发生的错误信息。 | | filename | string | 是 | 否 | 出现异常所在的文件。 | @@ -1322,7 +1324,7 @@ workerInstance.addEventListener("alert", (e)=>{ **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | -------- | ---- | ---- | ------------------ | | data | T | 是 | 否 | 线程间传递的数据。 | @@ -1338,7 +1340,7 @@ Worker线程自身的运行环境,WorkerGlobalScope类继承[EventTarget](#eve **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------- | | name | string | 是 | 否 | Worker的名字,new Worker时指定。 | | self | [WorkerGlobalScope](#workerglobalscope) & typeof globalThis | 是 | 否 | WorkerGlobalScope本身。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-xml.md b/zh-cn/application-dev/reference/apis/js-apis-xml.md index e137f45c98981154d20a0e2e876ded514bb2f369..271c69b5e15a7a9ffd8dedd17f01b18abe29583d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-xml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-xml.md @@ -23,10 +23,10 @@ XmlSerializer的构造函数。 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| buffer | ArrayBuffer \| DataView | 是 | 用于接收写入xml信息的ArrayBuffer或DataView内存。 | -| encoding | string | 否 | 编码格式。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------- | ---- | ------------------------------------------------ | +| buffer | ArrayBuffer \| DataView | 是 | 用于接收写入xml信息的ArrayBuffer或DataView内存。 | +| encoding | string | 否 | 编码格式。 | **示例:** @@ -47,10 +47,10 @@ setAttributes(name: string, value: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| name | string | 是 | 属性的key值。 | -| value | string | 是 | 属性的value值。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | --------------- | +| name | string | 是 | 属性的key值。 | +| value | string | 是 | 属性的value值。 | **示例:** @@ -74,9 +74,9 @@ addEmptyElement(name: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| name | string | 是 | 该空元素的元素名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| name | string | 是 | 该空元素的元素名。 | **示例:** @@ -116,9 +116,9 @@ startElement(name: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| name | string | 是 | 当前元素的元素名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| name | string | 是 | 当前元素的元素名。 | **示例:** @@ -162,10 +162,10 @@ setNamespace(prefix: string, namespace: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| prefix | string | 是 | 当前元素及其子元素的前缀。 | -| namespace | string | 是 | 当前元素及其子元素的命名空间。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------------------------ | +| prefix | string | 是 | 当前元素及其子元素的前缀。 | +| namespace | string | 是 | 当前元素及其子元素的命名空间。 | **示例:** @@ -188,9 +188,9 @@ setComment(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| text | string | 是 | 当前元素的注释内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------- | +| text | string | 是 | 当前元素的注释内容。 | **示例:** @@ -213,9 +213,9 @@ setCDATA(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| text | string | 是 | CDATA属性的内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----------------- | +| text | string | 是 | CDATA属性的内容。 | **示例:** @@ -236,9 +236,9 @@ setText(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| text | string | 是 | text属性的内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------- | +| text | string | 是 | text属性的内容。 | **示例:** @@ -262,9 +262,9 @@ setDocType(text: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| text | string | 是 | DocType属性的内容。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------- | +| text | string | 是 | DocType属性的内容。 | **示例:** @@ -288,10 +288,10 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| buffer | ArrayBuffer \| DataView | 是 | 含有xml文本信息的ArrayBuffer或者DataView。 | -| encoding | string | 否 | 编码格式(仅支持utf-8)。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------- | ---- | ------------------------------------------ | +| buffer | ArrayBuffer \| DataView | 是 | 含有xml文本信息的ArrayBuffer或者DataView。 | +| encoding | string | 否 | 编码格式(仅支持utf-8)。 | **示例:** @@ -323,9 +323,9 @@ parse(option: ParseOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| option | [ParseOptions](#parseoptions) | 是 | 用户控制以及获取解析信息的选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------------------------- | ---- | -------------------------------- | +| option | [ParseOptions](#parseoptions) | 是 | 用户控制以及获取解析信息的选项。 | **示例:** @@ -371,13 +371,13 @@ xml解析选项。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.Utils.Lang -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| supportDoctype | boolean | 否 | 是否忽略Doctype , 默认false。 | -| ignoreNameSpace | boolean | 否 | 是否忽略NameSpace,默认false。 | -| tagValueCallbackFunction | (name: string, value: string)=> boolean | 否 | 获取tagValue回调函数。 | -| attributeValueCallbackFunction | (name: string, value: string)=> boolean | 否 | 获取attributeValue回调函数。 | -| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=> boolean | 否 | 获取tokenValue回调函数。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------------------------ | ------------------------------------------------------------ | ---- | --------------------------------------- | +| supportDoctype | boolean | 否 | 是否忽略Doctype , 默认false。 | +| ignoreNameSpace | boolean | 否 | 是否忽略NameSpace,默认false。 | +| tagValueCallbackFunction | (name: string, value: string) => boolean | 否 | 获取tagValue回调函数。 | +| attributeValueCallbackFunction | (name: string, value: string) => boolean | 否 | 获取attributeValue回调函数。 | +| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo)) => boolean | 否 | 获取tokenValue回调函数。 | ## ParseInfo @@ -394,8 +394,8 @@ getColumnNumber(): number **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | -------------- | | number | 返回当前列号。 | @@ -409,8 +409,8 @@ getDepth(): number **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | -------------------- | | number | 返回元素的当前深度。 | @@ -424,8 +424,8 @@ getLineNumber(): number **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | -------------- | | number | 返回当前行号。 | @@ -439,8 +439,8 @@ getName(): string **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ------------------ | | string | 返回当前元素名称。 | @@ -454,8 +454,8 @@ getNamespace(): string **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ------------------------ | | string | 返回当前元素的命名空间。 | @@ -469,8 +469,8 @@ getPrefix(): string **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ------------------ | | string | 返回当前元素前缀。 | @@ -484,8 +484,8 @@ getText(): string **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ------------------------ | | string | 返回当前事件的文本内容。 | @@ -499,8 +499,8 @@ isEmptyElementTag(): boolean **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------- | ---------------------------- | | boolean | 返回true,当前元素为空元素。 | @@ -514,8 +514,8 @@ isWhitespace(): boolean **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------- | -------------------------------------- | | boolean | 返回true,当前文本事件仅包含空格字符。 | @@ -528,8 +528,8 @@ getAttributeCount(): number **系统能力:** SystemCapability.Utils.Lang **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ---------------------- | | number | 当前开始标记的属性数。 | @@ -539,16 +539,16 @@ getAttributeCount(): number **系统能力:** 以下各项对应的系统能力均为SystemCapability.Utils.Lang -| 名称 | 枚举值 | 说明 | -| -------- | -------- | -------- | -| START_DOCUMENT | 0 | 启动文件事件。 | -| END_DOCUMENT | 1 | 结束文件事件。 | -| START_TAG | 2 | 启动标签事件。 | -| END_TAG | 3 | 结束标签事件。 | -| TEXT | 4 | 文本事件。 | -| CDSECT | 5 | CDATA事件。 | -| COMMENT | 6 | XML注释事件。 | -| DOCDECL | 7 | XML文档类型声明事件。 | -| INSTRUCTION | 8 | XML处理指令声明事件。 | -| ENTITY_REFERENCE | 9 | 实体引用事件。 | -| WHITESPACE | 10 | 空白事件。 | +| 名称 | 值 | 说明 | +| ---------------- | ---- | --------------------- | +| START_DOCUMENT | 0 | 启动文件事件。 | +| END_DOCUMENT | 1 | 结束文件事件。 | +| START_TAG | 2 | 启动标签事件。 | +| END_TAG | 3 | 结束标签事件。 | +| TEXT | 4 | 文本事件。 | +| CDSECT | 5 | CDATA事件。 | +| COMMENT | 6 | XML注释事件。 | +| DOCDECL | 7 | XML文档类型声明事件。 | +| INSTRUCTION | 8 | XML处理指令声明事件。 | +| ENTITY_REFERENCE | 9 | 实体引用事件。 | +| WHITESPACE | 10 | 空白事件。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-zlib.md b/zh-cn/application-dev/reference/apis/js-apis-zlib.md index b43bd4d6731744b3aabc467e75de7cda0a0feb2b..98544e3ab3a1a064d16159eb21c69e03b0dd8e29 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-zlib.md +++ b/zh-cn/application-dev/reference/apis/js-apis-zlib.md @@ -26,8 +26,8 @@ zipFile(inFile: string, outFile: string, options: Options): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------- | ---- | ------------------------------------------------------------ | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md),[Stage模型](js-apis-application-context.md)。 | -| outFile | string | 是 | 指定压缩结果的文件路径(文件的扩展名zip)。 | -| options | [Options](#options) | 否 | 压缩的可选参数。 | +| outFile | string | 是 | 指定压缩结果的文件路径(文件的扩展名zip)。 | +| options | [Options](#options) | 是 | 压缩的可选参数。 | **返回值:** @@ -90,8 +90,8 @@ unzipFile(inFile:string, outFile:string, options: Options): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------- | ---- | ------------------------------------------------------------ | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md),[stage模型](js-apis-application-context.md)。 | -| outFile | string | 是 | 指定的解压文件路径。 | -| options | [Options](#options) | 否 | 解压的可选参数。 | +| outFile | string | 是 | 指定的解压文件路径。 | +| options | [Options](#options) | 是 | 解压的可选参数。 | **返回值:** @@ -318,11 +318,11 @@ try { **系统能力:** SystemCapability.BundleManager.Zlib -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------- | ---- | --------------------------------------------------------- | -| level | CompressLeve | 否 | 参考[zip.CompressLevel枚举定义](#zipcompresslevel)。 | -| memLevel | MemLevel | 否 | 参考[zip.MemLevel枚举定义](#zipmemlevel)。 | -| strategy | CompressStrategy | 否 | 参考[zip.CompressStrategy枚举定义](#zipcompressstrategy)。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ---------------- | ---- | ---- | ---------------------------------------------------------- | +| level | CompressLevel | 是 | 否 | 参考[zip.CompressLevel枚举定义](#zipcompresslevel)。 | +| memLevel | MemLevel | 是 | 否 | 参考[zip.MemLevel枚举定义](#zipmemlevel)。 | +| strategy | CompressStrategy | 是 | 否 | 参考[zip.CompressStrategy枚举定义](#zipcompressstrategy)。 | ## zip.CompressLevel diff --git a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md index d8146c1f6c803a9eccfd039f8ef002db0705db5d..a0f754de20cb86ba2ba7bd370e52c5162e7d8417 100644 --- a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md @@ -1,104 +1,102 @@ # 兼容JS的类Web开发范式 - 组件通用信息 - - [通用属性](js-components-common-attributes.md) - - [通用样式](js-components-common-styles.md) - - [通用事件](js-components-common-events.md) - - [通用方法](js-components-common-methods.md) - - [动画样式](js-components-common-animation.md) - - [渐变样式](js-components-common-gradient.md) - - [转场样式](js-components-common-transition.md) - - [媒体查询](js-components-common-mediaquery.md) - - [自定义字体样式](js-components-common-customizing-font.md) - - [原子布局](js-components-common-atomic-layout.md) + - [通用属性](js-components-common-attributes.md) + - [通用样式](js-components-common-styles.md) + - [通用事件](js-components-common-events.md) + - [通用方法](js-components-common-methods.md) + - [动画样式](js-components-common-animation.md) + - [渐变样式](js-components-common-gradient.md) + - [转场样式](js-components-common-transition.md) + - [媒体查询](js-components-common-mediaquery.md) + - [自定义字体样式](js-components-common-customizing-font.md) + - [原子布局](js-components-common-atomic-layout.md) - 容器组件 - - [badge](js-components-container-badge.md) - - [dialog](js-components-container-dialog.md) - - [div](js-components-container-div.md) - - [form](js-components-container-form.md) - - [list](js-components-container-list.md) - - [list-item](js-components-container-list-item.md) - - [list-item-group](js-components-container-list-item-group.md) - - [panel](js-components-container-panel.md) - - [popup](js-components-container-popup.md) - - [refresh](js-components-container-refresh.md) - - [stack](js-components-container-stack.md) - - [stepper](js-components-container-stepper.md) - - [stepper-item](js-components-container-stepper-item.md) - - [swiper](js-components-container-swiper.md) - - [tabs](js-components-container-tabs.md) - - [tab-bar](js-components-container-tab-bar.md) - - [tab-content](js-components-container-tab-content.md) + - [badge](js-components-container-badge.md) + - [dialog](js-components-container-dialog.md) + - [div](js-components-container-div.md) + - [form](js-components-container-form.md) + - [list](js-components-container-list.md) + - [list-item](js-components-container-list-item.md) + - [list-item-group](js-components-container-list-item-group.md) + - [panel](js-components-container-panel.md) + - [popup](js-components-container-popup.md) + - [refresh](js-components-container-refresh.md) + - [stack](js-components-container-stack.md) + - [stepper](js-components-container-stepper.md) + - [stepper-item](js-components-container-stepper-item.md) + - [swiper](js-components-container-swiper.md) + - [tabs](js-components-container-tabs.md) + - [tab-bar](js-components-container-tab-bar.md) + - [tab-content](js-components-container-tab-content.md) - 基础组件 - - [button](js-components-basic-button.md) - - [chart](js-components-basic-chart.md) - - [divider](js-components-basic-divider.md) - - [image](js-components-basic-image.md) - - [image-animator](js-components-basic-image-animator.md) - - [input](js-components-basic-input.md) - - [label](js-components-basic-label.md) - - [marquee](js-components-basic-marquee.md) - - [menu](js-components-basic-menu.md) - - [option](js-components-basic-option.md) - - [picker](js-components-basic-picker.md) - - [picker-view](js-components-basic-picker-view.md) - - [piece](js-components-basic-piece.md) - - [progress](js-components-basic-progress.md) - - [qrcode](js-components-basic-qrcode.md) - - [rating](js-components-basic-rating.md) - - [richtext](js-components-basic-richtext.md) - - [search](js-components-basic-search.md) - - [select](js-components-basic-select.md) - - [slider](js-components-basic-slider.md) - - [span](js-components-basic-span.md) - - [switch](js-components-basic-switch.md) - - [text](js-components-basic-text.md) - - [textarea](js-components-basic-textarea.md) - - [toolbar](js-components-basic-toolbar.md) - - [toolbar-item](js-components-basic-toolbar-item.md) - - [toggle](js-components-basic-toggle.md) - - [web](js-components-basic-web.md) - - [xcomponent](js-components-basic-xcomponent.md) + - [button](js-components-basic-button.md) + - [chart](js-components-basic-chart.md) + - [divider](js-components-basic-divider.md) + - [image](js-components-basic-image.md) + - [image-animator](js-components-basic-image-animator.md) + - [input](js-components-basic-input.md) + - [label](js-components-basic-label.md) + - [marquee](js-components-basic-marquee.md) + - [menu](js-components-basic-menu.md) + - [option](js-components-basic-option.md) + - [picker](js-components-basic-picker.md) + - [picker-view](js-components-basic-picker-view.md) + - [piece](js-components-basic-piece.md) + - [progress](js-components-basic-progress.md) + - [qrcode](js-components-basic-qrcode.md) + - [rating](js-components-basic-rating.md) + - [richtext](js-components-basic-richtext.md) + - [search](js-components-basic-search.md) + - [select](js-components-basic-select.md) + - [slider](js-components-basic-slider.md) + - [span](js-components-basic-span.md) + - [switch](js-components-basic-switch.md) + - [text](js-components-basic-text.md) + - [textarea](js-components-basic-textarea.md) + - [toolbar](js-components-basic-toolbar.md) + - [toolbar-item](js-components-basic-toolbar-item.md) + - [toggle](js-components-basic-toggle.md) + - [web](js-components-basic-web.md) + - [xcomponent](js-components-basic-xcomponent.md) - 媒体组件 - - [video](js-components-media-video.md) + - [video](js-components-media-video.md) - 画布组件 - - [canvas组件](js-components-canvas-canvas.md) - - [CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md) - - [Image对象](js-components-canvas-image.md) - - [CanvasGradient对象](js-components-canvas-canvasgradient.md) - - [ImageData对象](js-components-canvas-imagedata.md) - - [Path2D对象](js-components-canvas-path2d.md) - - [ImageBitmap对象](js-components-canvas-imagebitmap.md) - - [OffscreenCanvas对象](js-components-canvas-offscreencanvas.md) - - [OffscreenCanvasRenderingContext2D对象](js-offscreencanvasrenderingcontext2d.md) + - [canvas组件](js-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md) + - [Image对象](js-components-canvas-image.md) + - [CanvasGradient对象](js-components-canvas-canvasgradient.md) + - [ImageData对象](js-components-canvas-imagedata.md) + - [Path2D对象](js-components-canvas-path2d.md) + - [ImageBitmap对象](js-components-canvas-imagebitmap.md) + - [OffscreenCanvas对象](js-components-canvas-offscreencanvas.md) + - [OffscreenCanvasRenderingContext2D对象](js-offscreencanvasrenderingcontext2d.md) - 栅格组件 - - [基本概念](js-components-grid-basic-concepts.md) - - [grid-container](js-components-grid-container.md) - - [grid-row](js-components-grid-row.md) - - [grid-col](js-components-grid-col.md) + - [基本概念](js-components-grid-basic-concepts.md) + - [grid-container](js-components-grid-container.md) + - [grid-row](js-components-grid-row.md) + - [grid-col](js-components-grid-col.md) - svg组件 - - [通用属性](js-components-svg-common-attributes.md) - - [svg](js-components-svg.md) - - [rect](js-components-svg-rect.md) - - [circle](js-components-svg-circle.md) - - [ellipse](js-components-svg-ellipse.md) - - [path](js-components-svg-path.md) - - [line](js-components-svg-line.md) - - [polyline](js-components-svg-polyline.md) - - [polygon](js-components-svg-polygon.md) - - [text](js-components-svg-text.md) - - [tspan](js-components-svg-tspan.md) - - [textPath](js-components-svg-textpath.md) - - [animate](js-components-svg-animate.md) - - [animateMotion](js-components-svg-animatemotion.md) - - [animateTransform](js-components-svg-animatetransform.md) - - + - [通用属性](js-components-svg-common-attributes.md) + - [svg](js-components-svg.md) + - [rect](js-components-svg-rect.md) + - [circle](js-components-svg-circle.md) + - [ellipse](js-components-svg-ellipse.md) + - [path](js-components-svg-path.md) + - [line](js-components-svg-line.md) + - [polyline](js-components-svg-polyline.md) + - [polygon](js-components-svg-polygon.md) + - [text](js-components-svg-text.md) + - [tspan](js-components-svg-tspan.md) + - [textPath](js-components-svg-textpath.md) + - [animate](js-components-svg-animate.md) + - [animateMotion](js-components-svg-animatemotion.md) + - [animateTransform](js-components-svg-animatetransform.md) - 自定义组件 - - [基本用法](js-components-custom-basic-usage.md) - - [数据传递与处理](js-components-custom-props.md) - - [继承样式](js-components-custom-style.md) - - [slot插槽](js-components-custom-slot.md) - - [生命周期定义](js-components-custom-lifecycle.md) + - [基本用法](js-components-custom-basic-usage.md) + - [数据传递与处理](js-components-custom-props.md) + - [继承样式](js-components-custom-style.md) + - [slot插槽](js-components-custom-slot.md) + - [生命周期定义](js-components-custom-lifecycle.md) - [动态创建组件](js-components-create-elements.md) - [数据类型说明](js-appendix-types.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index 3fa8f6e43b7c1a789255a82c614f3d686cd608e7..c421df5965f3a0a3f1490230e926fef0bef8d542 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -2,167 +2,167 @@ - [组件导读](ts-components-summary.md) - 组件通用信息 - - 通用事件 - - [点击事件](ts-universal-events-click.md) - - [触摸事件](ts-universal-events-touch.md) - - [挂载卸载事件](ts-universal-events-show-hide.md) - - [拖拽事件](ts-universal-events-drag-drop.md) - - [按键事件](ts-universal-events-key.md) - - [焦点事件](ts-universal-focus-event.md) - - [鼠标事件](ts-universal-mouse-key.md) - - [组件区域变化事件](ts-universal-component-area-change-event.md) - - [组件可见区域变化事件](ts-universal-component-visible-area-change-event.md) - - 通用属性 - - [尺寸设置](ts-universal-attributes-size.md) - - [位置设置](ts-universal-attributes-location.md) - - [布局约束](ts-universal-attributes-layout-constraints.md) - - [Flex布局](ts-universal-attributes-flex-layout.md) - - [边框设置](ts-universal-attributes-border.md) - - [图片边框设置](ts-universal-attributes-border-image.md) - - [背景设置](ts-universal-attributes-background.md) - - [透明度设置](ts-universal-attributes-opacity.md) - - [显隐控制](ts-universal-attributes-visibility.md) - - [禁用控制](ts-universal-attributes-enable.md) - - [浮层](ts-universal-attributes-overlay.md) - - [Z序控制](ts-universal-attributes-z-order.md) - - [图形变换](ts-universal-attributes-transformation.md) - - [图像效果](ts-universal-attributes-image-effect.md) - - [形状裁剪](ts-universal-attributes-sharp-clipping.md) - - [文本样式设置](ts-universal-attributes-text-style.md) - - [栅格设置](ts-universal-attributes-grid.md) - - [颜色渐变](ts-universal-attributes-gradient-color.md) - - [Popup控制](ts-universal-attributes-popup.md) - - [Menu控制](ts-universal-attributes-menu.md) - - [点击控制](ts-universal-attributes-click.md) - - [焦点控制](ts-universal-attributes-focus.md) - - [悬浮态效果](ts-universal-attributes-hover-effect.md) - - [组件标识](ts-universal-attributes-component-id.md) - - [触摸热区设置](ts-universal-attributes-touch-target.md) - - [多态样式](ts-universal-attributes-polymorphic-style.md) - - [触摸测试控制](ts-universal-attributes-hit-test-behavior.md) - - [背景模糊设置](ts-universal-attributes-backgroundBlurStyle.md) - - [分布式迁移标识](ts-universal-attributes-restoreId.md) - - 手势处理 - - [绑定手势方法](ts-gesture-settings.md) - - 基础手势 - - [TapGesture](ts-basic-gestures-tapgesture.md) - - [LongPressGesture](ts-basic-gestures-longpressgesture.md) - - [PanGesture](ts-basic-gestures-pangesture.md) - - [PinchGesture](ts-basic-gestures-pinchgesture.md) - - [RotationGesture](ts-basic-gestures-rotationgesture.md) - - [SwipeGesture](ts-basic-gestures-swipegesture.md) - - [组合手势](ts-combined-gestures.md) + - 通用事件 + - [点击事件](ts-universal-events-click.md) + - [触摸事件](ts-universal-events-touch.md) + - [挂载卸载事件](ts-universal-events-show-hide.md) + - [拖拽事件](ts-universal-events-drag-drop.md) + - [按键事件](ts-universal-events-key.md) + - [焦点事件](ts-universal-focus-event.md) + - [鼠标事件](ts-universal-mouse-key.md) + - [组件区域变化事件](ts-universal-component-area-change-event.md) + - [组件可见区域变化事件](ts-universal-component-visible-area-change-event.md) + - 通用属性 + - [尺寸设置](ts-universal-attributes-size.md) + - [位置设置](ts-universal-attributes-location.md) + - [布局约束](ts-universal-attributes-layout-constraints.md) + - [Flex布局](ts-universal-attributes-flex-layout.md) + - [边框设置](ts-universal-attributes-border.md) + - [图片边框设置](ts-universal-attributes-border-image.md) + - [背景设置](ts-universal-attributes-background.md) + - [透明度设置](ts-universal-attributes-opacity.md) + - [显隐控制](ts-universal-attributes-visibility.md) + - [禁用控制](ts-universal-attributes-enable.md) + - [浮层](ts-universal-attributes-overlay.md) + - [Z序控制](ts-universal-attributes-z-order.md) + - [图形变换](ts-universal-attributes-transformation.md) + - [图像效果](ts-universal-attributes-image-effect.md) + - [形状裁剪](ts-universal-attributes-sharp-clipping.md) + - [文本样式设置](ts-universal-attributes-text-style.md) + - [栅格设置](ts-universal-attributes-grid.md) + - [颜色渐变](ts-universal-attributes-gradient-color.md) + - [Popup控制](ts-universal-attributes-popup.md) + - [Menu控制](ts-universal-attributes-menu.md) + - [点击控制](ts-universal-attributes-click.md) + - [焦点控制](ts-universal-attributes-focus.md) + - [悬浮态效果](ts-universal-attributes-hover-effect.md) + - [组件标识](ts-universal-attributes-component-id.md) + - [触摸热区设置](ts-universal-attributes-touch-target.md) + - [多态样式](ts-universal-attributes-polymorphic-style.md) + - [触摸测试控制](ts-universal-attributes-hit-test-behavior.md) + - [背景模糊设置](ts-universal-attributes-backgroundBlurStyle.md) + - [分布式迁移标识](ts-universal-attributes-restoreId.md) + - 手势处理 + - [绑定手势方法](ts-gesture-settings.md) + - 基础手势 + - [TapGesture](ts-basic-gestures-tapgesture.md) + - [LongPressGesture](ts-basic-gestures-longpressgesture.md) + - [PanGesture](ts-basic-gestures-pangesture.md) + - [PinchGesture](ts-basic-gestures-pinchgesture.md) + - [RotationGesture](ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](ts-basic-gestures-swipegesture.md) + - [组合手势](ts-combined-gestures.md) - 基础组件 - - [Blank](ts-basic-components-blank.md) - - [Button](ts-basic-components-button.md) - - [Checkbox](ts-basic-components-checkbox.md) - - [CheckboxGroup](ts-basic-components-checkboxgroup.md) - - [DataPanel](ts-basic-components-datapanel.md) - - [DatePicker](ts-basic-components-datepicker.md) - - [Divider](ts-basic-components-divider.md) - - [Gauge](ts-basic-components-gauge.md) - - [Image](ts-basic-components-image.md) - - [ImageAnimator](ts-basic-components-imageanimator.md) - - [LoadingProgress](ts-basic-components-loadingprogress.md) - - [Marquee](ts-basic-components-marquee.md) - - [Navigation](ts-basic-components-navigation.md) - - [NavRouter](ts-basic-components-navrouter.md) - - [NavDestination](ts-basic-components-navdestination.md) - - [PatternLock](ts-basic-components-patternlock.md) - - [PluginComponent](ts-basic-components-plugincomponent.md) - - [Progress](ts-basic-components-progress.md) - - [QRCode](ts-basic-components-qrcode.md) - - [Radio](ts-basic-components-radio.md) - - [Rating](ts-basic-components-rating.md) - - [RemoteWindow](ts-basic-components-remotewindow.md) - - [RichText](ts-basic-components-richtext.md) - - [ScrollBar](ts-basic-components-scrollbar.md) - - [Search](ts-basic-components-search.md) - - [Select](ts-basic-components-select.md) - - [Slider](ts-basic-components-slider.md) - - [Span](ts-basic-components-span.md) - - [Stepper](ts-basic-components-stepper.md) - - [StepperItem](ts-basic-components-stepperitem.md) - - [Text](ts-basic-components-text.md) - - [TextArea](ts-basic-components-textarea.md) - - [TextClock](ts-basic-components-textclock.md) - - [TextInput](ts-basic-components-textinput.md) - - [TextPicker](ts-basic-components-textpicker.md) - - [TextTimer](ts-basic-components-texttimer.md) - - [TimePicker](ts-basic-components-timepicker.md) - - [Toggle](ts-basic-components-toggle.md) - - [Web](ts-basic-components-web.md) - - [XComponent](ts-basic-components-xcomponent.md) + - [Blank](ts-basic-components-blank.md) + - [Button](ts-basic-components-button.md) + - [Checkbox](ts-basic-components-checkbox.md) + - [CheckboxGroup](ts-basic-components-checkboxgroup.md) + - [DataPanel](ts-basic-components-datapanel.md) + - [DatePicker](ts-basic-components-datepicker.md) + - [Divider](ts-basic-components-divider.md) + - [Gauge](ts-basic-components-gauge.md) + - [Image](ts-basic-components-image.md) + - [ImageAnimator](ts-basic-components-imageanimator.md) + - [LoadingProgress](ts-basic-components-loadingprogress.md) + - [Marquee](ts-basic-components-marquee.md) + - [Navigation](ts-basic-components-navigation.md) + - [NavRouter](ts-basic-components-navrouter.md) + - [NavDestination](ts-basic-components-navdestination.md) + - [PatternLock](ts-basic-components-patternlock.md) + - [PluginComponent](ts-basic-components-plugincomponent.md) + - [Progress](ts-basic-components-progress.md) + - [QRCode](ts-basic-components-qrcode.md) + - [Radio](ts-basic-components-radio.md) + - [Rating](ts-basic-components-rating.md) + - [RemoteWindow](ts-basic-components-remotewindow.md) + - [RichText](ts-basic-components-richtext.md) + - [ScrollBar](ts-basic-components-scrollbar.md) + - [Search](ts-basic-components-search.md) + - [Select](ts-basic-components-select.md) + - [Slider](ts-basic-components-slider.md) + - [Span](ts-basic-components-span.md) + - [Stepper](ts-basic-components-stepper.md) + - [StepperItem](ts-basic-components-stepperitem.md) + - [Text](ts-basic-components-text.md) + - [TextArea](ts-basic-components-textarea.md) + - [TextClock](ts-basic-components-textclock.md) + - [TextInput](ts-basic-components-textinput.md) + - [TextPicker](ts-basic-components-textpicker.md) + - [TextTimer](ts-basic-components-texttimer.md) + - [TimePicker](ts-basic-components-timepicker.md) + - [Toggle](ts-basic-components-toggle.md) + - [Web](ts-basic-components-web.md) + - [XComponent](ts-basic-components-xcomponent.md) - 容器组件 - - [AbilityComponent](ts-container-ability-component.md) - - [AlphabetIndexer](ts-container-alphabet-indexer.md) - - [Badge](ts-container-badge.md) - - [Column](ts-container-column.md) - - [ColumnSplit](ts-container-columnsplit.md) - - [Counter](ts-container-counter.md) - - [Flex](ts-container-flex.md) - - [FlowItem](ts-container-flowitem.md) - - [GridContainer](ts-container-gridcontainer.md) - - [GridCol](ts-container-gridcol.md) - - [GridRow](ts-container-gridrow.md) - - [Grid](ts-container-grid.md) - - [GridItem](ts-container-griditem.md) - - [List](ts-container-list.md) - - [ListItem](ts-container-listitem.md) - - [ListItemGroup](ts-container-listitemgroup.md) - - [Navigator](ts-container-navigator.md) - - [Panel](ts-container-panel.md) - - [Refresh](ts-container-refresh.md) - - [RelativeContainer](ts-container-relativecontainer.md) - - [Row](ts-container-row.md) - - [RowSplit](ts-container-rowsplit.md) - - [Scroll](ts-container-scroll.md) - - [SideBarContainer](ts-container-sidebarcontainer.md) - - [Stack](ts-container-stack.md) - - [Swiper](ts-container-swiper.md) - - [Tabs](ts-container-tabs.md) - - [TabContent](ts-container-tabcontent.md) - - [WaterFlow](ts-container-waterflow.md) + - [AbilityComponent](ts-container-ability-component.md) + - [AlphabetIndexer](ts-container-alphabet-indexer.md) + - [Badge](ts-container-badge.md) + - [Column](ts-container-column.md) + - [ColumnSplit](ts-container-columnsplit.md) + - [Counter](ts-container-counter.md) + - [Flex](ts-container-flex.md) + - [FlowItem](ts-container-flowitem.md) + - [GridContainer](ts-container-gridcontainer.md) + - [GridCol](ts-container-gridcol.md) + - [GridRow](ts-container-gridrow.md) + - [Grid](ts-container-grid.md) + - [GridItem](ts-container-griditem.md) + - [List](ts-container-list.md) + - [ListItem](ts-container-listitem.md) + - [ListItemGroup](ts-container-listitemgroup.md) + - [Navigator](ts-container-navigator.md) + - [Panel](ts-container-panel.md) + - [Refresh](ts-container-refresh.md) + - [RelativeContainer](ts-container-relativecontainer.md) + - [Row](ts-container-row.md) + - [RowSplit](ts-container-rowsplit.md) + - [Scroll](ts-container-scroll.md) + - [SideBarContainer](ts-container-sidebarcontainer.md) + - [Stack](ts-container-stack.md) + - [Swiper](ts-container-swiper.md) + - [Tabs](ts-container-tabs.md) + - [TabContent](ts-container-tabcontent.md) + - [WaterFlow](ts-container-waterflow.md) - 媒体组件 - - [Video](ts-media-components-video.md) + - [Video](ts-media-components-video.md) - 绘制组件 - - [Circle](ts-drawing-components-circle.md) - - [Ellipse](ts-drawing-components-ellipse.md) - - [Line](ts-drawing-components-line.md) - - [Polyline](ts-drawing-components-polyline.md) - - [Polygon](ts-drawing-components-polygon.md) - - [Path](ts-drawing-components-path.md) - - [Rect](ts-drawing-components-rect.md) - - [Shape](ts-drawing-components-shape.md) + - [Circle](ts-drawing-components-circle.md) + - [Ellipse](ts-drawing-components-ellipse.md) + - [Line](ts-drawing-components-line.md) + - [Polyline](ts-drawing-components-polyline.md) + - [Polygon](ts-drawing-components-polygon.md) + - [Path](ts-drawing-components-path.md) + - [Rect](ts-drawing-components-rect.md) + - [Shape](ts-drawing-components-shape.md) - 画布组件 - - [Canvas](ts-components-canvas-canvas.md) - - [CanvasRenderingContext2D对象](ts-canvasrenderingcontext2d.md) - - [CanvasGradient对象](ts-components-canvas-canvasgradient.md) - - [ImageBitmap对象](ts-components-canvas-imagebitmap.md) - - [ImageData对象](ts-components-canvas-imagedata.md) - - [OffscreenCanvasRenderingContext2D对象](ts-offscreencanvasrenderingcontext2d.md) - - [Path2D对象](ts-components-canvas-path2d.md) - - [Lottie](ts-components-canvas-lottie.md) + - [Canvas](ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](ts-canvasrenderingcontext2d.md) + - [CanvasGradient对象](ts-components-canvas-canvasgradient.md) + - [ImageBitmap对象](ts-components-canvas-imagebitmap.md) + - [ImageData对象](ts-components-canvas-imagedata.md) + - [OffscreenCanvasRenderingContext2D对象](ts-offscreencanvasrenderingcontext2d.md) + - [Path2D对象](ts-components-canvas-path2d.md) + - [Lottie](ts-components-canvas-lottie.md) - 动画 - - [属性动画](ts-animatorproperty.md) - - [显式动画](ts-explicit-animation.md) - - 转场动画 - - [页面间转场](ts-page-transition-animation.md) - - [组件内转场](ts-transition-animation-component.md) - - [共享元素转场](ts-transition-animation-shared-elements.md) - - [路径动画](ts-motion-path-animation.md) + - [属性动画](ts-animatorproperty.md) + - [显式动画](ts-explicit-animation.md) + - 转场动画 + - [页面间转场](ts-page-transition-animation.md) + - [组件内转场](ts-transition-animation-component.md) + - [共享元素转场](ts-transition-animation-shared-elements.md) + - [路径动画](ts-motion-path-animation.md) - 全局UI方法 - - 弹窗 - - [警告弹窗](ts-methods-alert-dialog-box.md) - - [列表选择弹窗](ts-methods-action-sheet.md) - - [自定义弹窗](ts-methods-custom-dialog-box.md) - - [日期选择弹窗](ts-methods-datepicker-dialog.md) - - [时间选择弹窗](ts-methods-timepicker-dialog.md) - - [文本选择弹窗](ts-methods-textpicker-dialog.md) - - [菜单](ts-methods-menu.md) + - 弹窗 + - [警告弹窗](ts-methods-alert-dialog-box.md) + - [列表选择弹窗](ts-methods-action-sheet.md) + - [自定义弹窗](ts-methods-custom-dialog-box.md) + - [日期选择弹窗](ts-methods-datepicker-dialog.md) + - [时间选择弹窗](ts-methods-timepicker-dialog.md) + - [文本选择弹窗](ts-methods-textpicker-dialog.md) + - [菜单](ts-methods-menu.md) - [应用级变量的状态管理](ts-state-management.md) - [像素单位](ts-pixel-units.md) - [枚举说明](ts-appendix-enums.md) - [类型说明](ts-types.md) - 已停止维护的组件 - - [GridContainer(栅格)](ts-container-gridcontainer.md) \ No newline at end of file + - [GridContainer(栅格)](ts-container-gridcontainer.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md index dfaa799f790726acbca0a5bb892d93a95b674498..9d1669047af57332bf85b5a6122bd183ed2b49e7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md @@ -37,7 +37,7 @@ Checkbox(options?: {name?: string, group?: string }) | 名称 | 功能描述 | | ----------| -------- | -|onChange(callback: (value: boolean) => void) | 当选中状态发生变化时,触发该回调。
- value为true时,表示已选中。
- value为false时,表示未选中。 | +|onChange(callback: (value: boolean) => void) | 当选中状态发生变化时,触发该回调。(只有手动触发且Checkbox状态改变时才会触发onChange回调)
- value为true时,表示已选中。
- value为false时,表示未选中。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md index 05269dd69e318aed1f4ceef5e1e62be3fc06f058..df19c5e7c4a4781734ad174552f239fe63219a81 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md @@ -39,7 +39,7 @@ CheckboxGroup(options?: { group?: string }) | 名称 | 功能描述 | | -------- | -------- | -| onChange (callback: (event: [CheckboxGroupResult](#checkboxgroupresult对象说明)) => void ) |CheckboxGroup的选中状态或群组内的Checkbox的选中状态发生变化时,触发回调。| +| onChange (callback: (event: [CheckboxGroupResult](#checkboxgroupresult对象说明)) => void ) |CheckboxGroup的选中状态或群组内的Checkbox的选中状态发生变化时,触发回调。(只有手动触发且Checkbox或CheckboxGroup状态改变时才会触发onChange回调)| ## CheckboxGroupResult对象说明 | 名称 | 类型 | 描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md index e047ed2da951bb898627b9830bdb12737d6ad4c5..d1c026f7074546c14b41cff054ef2b99d7d43972 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md @@ -58,11 +58,10 @@ xcomponentController: XComponentController = new XComponentController() ### getXComponentSurfaceId -getXComponentSurfaceId() +getXComponentSurfaceId(): string 获取XComponent对应Surface的ID,供@ohos接口使用,比如camera相关接口。 -**系统接口:** 此接口为系统接口。 **返回值:** @@ -73,11 +72,10 @@ getXComponentSurfaceId() ### setXComponentSurfaceSize -setXComponentSurfaceSize(value: {surfaceWidth: number, surfaceHeight: number}) +setXComponentSurfaceSize(value: {surfaceWidth: number, surfaceHeight: number}): void 设置XComponent持有Surface的宽度和高度。 -**系统接口:** 此接口为系统接口。 **参数:** @@ -89,7 +87,7 @@ setXComponentSurfaceSize(value: {surfaceWidth: number, surfaceHeight: number}) ### getXComponentContext -getXComponentContext() +getXComponentContext(): Object 获取XComponent实例对象的context。 @@ -102,12 +100,10 @@ getXComponentContext() ## 示例 -提供surface类型XComponent,支持相机预览等能力。 示例效果请以真机运行为准,当前IDE预览器不支持。 ```ts // xxx.ets -import camera from '@ohos.multimedia.camera' @Entry @Component struct PreviewArea { @@ -123,9 +119,6 @@ struct PreviewArea { .onLoad(() => { this.xcomponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080}); this.surfaceId = this.xcomponentController.getXComponentSurfaceId() - camera.createPreviewOutput(this.surfaceId).then((previewOutput) => { - console.log('Promise returned with the PreviewOutput instance') - }) }) .width('640px') .height('480px') diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md index 09544a366d55618f9b6b11f1cf57148ec0983d5a..2dbd94b4cb78393b3a3d12faf28d34963fbad773 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md @@ -34,7 +34,7 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | listDirection | [Axis](ts-appendix-enums.md#axis) | 设置List组件排列方向。
默认值:Axis.Vertical | | divider | {
strokeWidth: [Length](ts-types.md#length),
color?:[ResourceColor](ts-types.md),
startMargin?: Length,
endMargin?: Length
} \| null | 设置ListItem分割线样式,默认无分割线。
- strokeWidth: 分割线的线宽。
- color: 分割线的颜色。
- startMargin: 分割线与列表侧边起始端的距离。
- endMargin: 分割线与列表侧边结束端的距离。 | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。
默认值:BarState.Off | -| cachedCount | number | 设置预加载的ListItem数量。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)。
默认值:1 | +| cachedCount | number | 设置列表中ListItem/ListItemGroup的预加载数量,其中ListItemGroup将作为一个整体进行计算,ListItemGroup中的所有ListItem会一次性全部加载出来。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)。
默认值:1 | | editMode | boolean | 声明当前List组件是否处于可编辑模式。
默认值:false | | edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置组件的滑动效果。
默认值:EdgeEffect.Spring | | chainAnimation | boolean | 设置当前List是否启用链式联动动效,开启后列表滑动以及顶部和底部拖拽时会有链式联动的效果。链式联动效果:List内的list-item间隔一定距离,在基本的滑动交互行为下,主动对象驱动从动对象进行联动,驱动效果遵循弹簧物理动效。
默认值:false
- false:不启用链式联动。
- true:启用链式联动。 | @@ -70,8 +70,8 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | onScrollIndex(event: (start: number, end: number) => void) | 列表滑动时触发。
计算索引值时,ListItemGroup作为一个整体占一个索引值,不计算ListItemGroup内部ListItem的索引值。
- start: 滑动起始位置索引值。
- end: 滑动结束位置索引值。 | | onReachStart(event: () => void) | 列表到达起始位置时触发。 | | onReachEnd(event: () => void) | 列表到底末尾位置时触发。 | -| onScrollBegin9+(event: (dx: number, dy: number) => { dxRemain: number, dyRemain: number }) | 列表开始滑动时触发。
\- dx:即将发生的水平方向滚动量。
\- dy:即将发生的竖直方向滚动量。
- dxRemain:水平方向滚动剩余量。
\- dyRemain:竖直方向滚动剩余量。 | -| onScrollStop(event: () => void) | 列表滑动停止时触发。 | +| onScrollBegin9+(event: (dx: number, dy: number) => { dxRemain: number, dyRemain: number }) | 列表开始滑动时触发,事件参数传入即将发生的滑动量,事件处理函数中可根据应用场景计算实际需要的滑动量并作为事件处理函数的返回值返回,列表将按照返回值的实际滑动量进行滑动。
\- dx:即将发生的水平方向滑动量。
\- dy:即将发生的竖直方向滑动量。
- dxRemain:水平方向实际滑动量。
\- dyRemain:竖直方向实际滑动量。 | +| onScrollStop(event: () => void) | 列表滑动停止时触发。手拖动列表或列表的滚动条触发的滑动,手离开屏幕并且滑动停止时会触发该事件;使用[Scroller](ts-container-scroll.md#scroller)滑动控制器触发的滑动,不会触发该事件。 | | onItemMove(event: (from: number, to: number) => boolean) | 列表元素发生移动时触发。
- from: 移动前索引值。
- to: 移动后索引值。 | | onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => ((() => any) \| void) | 开始拖拽列表元素时触发。
- event: 见[ItemDragInfo对象说明](ts-container-grid.md#itemdraginfo对象说明)。
- itemIndex: 被拖拽列表元素索引值。 | | onItemDragEnter(event: (event: ItemDragInfo) => void) | 拖拽进入列表元素范围内时触发。
- event: 见[ItemDragInfo对象说明](ts-container-grid.md#itemdraginfo对象说明)。 | @@ -84,8 +84,8 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | 名称 | 描述 | | ------ | ------------------------- | | Idle | 未滑动状态。 | -| Scroll | 惯性滑动状态。 | -| Fling | 手指拖动状态。 | +| Scroll | 手指拖动状态。 | +| Fling | 惯性滑动状态。 | > **说明:** > diff --git a/zh-cn/application-dev/reference/errorcodes/Readme-CN.md b/zh-cn/application-dev/reference/errorcodes/Readme-CN.md index 9ca17466bea91794c6a9291a59598d252e46a781..27c9f793bff0c3de4aac7b8dbfc98ad41e493a73 100644 --- a/zh-cn/application-dev/reference/errorcodes/Readme-CN.md +++ b/zh-cn/application-dev/reference/errorcodes/Readme-CN.md @@ -32,6 +32,7 @@ - 安全 - [AccessToken错误码](errorcode-access-token.md) - [HUKS错误码](errorcode-huks.md) + - [用户认证错误码](errorcode-useriam.md) - 数据管理 - [关系型数据库错误码](errorcode-data-rdb.md) - [数据共享错误码](errorcode-datashare.md) diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md b/zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md new file mode 100644 index 0000000000000000000000000000000000000000..8c8159524635a0d0369b9b9e76cf99316af09ed3 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md @@ -0,0 +1,93 @@ +# 用户认证错误码 + +## 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层调用出错。 + +**处理步骤** + +主要检查人脸认证服务的进程是否启动。 diff --git a/zh-cn/application-dev/reference/js-service-widget-ui/Readme-CN.md b/zh-cn/application-dev/reference/js-service-widget-ui/Readme-CN.md index 6810c9398d6dd287ef1351e934b41a7198acb492..1d010b8668696de709dea708bf03adc870c5b1f6 100644 --- a/zh-cn/application-dev/reference/js-service-widget-ui/Readme-CN.md +++ b/zh-cn/application-dev/reference/js-service-widget-ui/Readme-CN.md @@ -1,40 +1,40 @@ # JS服务卡片UI组件 - JS服务卡片UI框架说明 - - [文件组织](js-service-widget-file.md) - - 语法 - - [HML语法参考](js-service-widget-syntax-hml.md) - - [CSS语法参考](js-service-widget-syntax-css.md) - - [多语言支持](js-service-widget-multiple-languages.md) - - [版本兼容适配](js-service-widget-version-compatibility.md) - - [设置主题样式](js-service-widget-theme.md) + - [文件组织](js-service-widget-file.md) + - 语法 + - [HML语法参考](js-service-widget-syntax-hml.md) + - [CSS语法参考](js-service-widget-syntax-css.md) + - [多语言支持](js-service-widget-multiple-languages.md) + - [版本兼容适配](js-service-widget-version-compatibility.md) + - [设置主题样式](js-service-widget-theme.md) - 组件 - - 通用 - - [通用属性](js-service-widget-common-attributes.md) - - [通用样式](js-service-widget-common-styles.md) - - [通用事件](js-service-widget-common-events.md) - - [渐变样式](js-service-widget-common-gradient.md) - - [媒体查询](js-service-widget-common-mediaquery.md) - - [自定义字体样式](js-service-widget-common-customizing-font.md) - - [无障碍](js-service-widget-common-accessibility.md) - - [原子布局](js-service-widget-common-atomic-layout.md) - - 容器组件 - - [badge](js-service-widget-container-badge.md) - - [div](js-service-widget-container-div.md) - - [list](js-service-widget-container-list.md) - - [list-item](js-service-widget-container-list-item.md) - - [stack](js-service-widget-container-stack.md) - - [swiper](js-service-widget-container-swiper.md) - - 基础组件 - - [button](js-service-widget-basic-button.md) - - [calendar](js-service-widget-basic-calendar.md) - - [chart](js-service-widget-basic-chart.md) - - [clock](js-service-widget-basic-clock.md) - - [divider](js-service-widget-basic-divider.md) - - [image](js-service-widget-basic-image.md) - - [input](js-service-widget-basic-input.md) - - [progress](js-service-widget-basic-progress.md) - - [span](js-service-widget-basic-span.md) - - [text](js-service-widget-basic-text.md) + - 通用 + - [通用属性](js-service-widget-common-attributes.md) + - [通用样式](js-service-widget-common-styles.md) + - [通用事件](js-service-widget-common-events.md) + - [渐变样式](js-service-widget-common-gradient.md) + - [媒体查询](js-service-widget-common-mediaquery.md) + - [自定义字体样式](js-service-widget-common-customizing-font.md) + - [无障碍](js-service-widget-common-accessibility.md) + - [原子布局](js-service-widget-common-atomic-layout.md) + - 容器组件 + - [badge](js-service-widget-container-badge.md) + - [div](js-service-widget-container-div.md) + - [list](js-service-widget-container-list.md) + - [list-item](js-service-widget-container-list-item.md) + - [stack](js-service-widget-container-stack.md) + - [swiper](js-service-widget-container-swiper.md) + - 基础组件 + - [button](js-service-widget-basic-button.md) + - [calendar](js-service-widget-basic-calendar.md) + - [chart](js-service-widget-basic-chart.md) + - [clock](js-service-widget-basic-clock.md) + - [divider](js-service-widget-basic-divider.md) + - [image](js-service-widget-basic-image.md) + - [input](js-service-widget-basic-input.md) + - [progress](js-service-widget-basic-progress.md) + - [span](js-service-widget-basic-span.md) + - [text](js-service-widget-basic-text.md) - [自定义组件使用说明](js-service-widget-custom-basic-usage.md) - [数据类型说明](js-service-widget-appendix-types.md) diff --git a/zh-cn/application-dev/security/cryptoFramework-guidelines.md b/zh-cn/application-dev/security/cryptoFramework-guidelines.md index 0ff0c041763272f945df48f488979d51f9498165..d4f34d7421fd77a54ba7a17408c252f6696cb4ec 100644 --- a/zh-cn/application-dev/security/cryptoFramework-guidelines.md +++ b/zh-cn/application-dev/security/cryptoFramework-guidelines.md @@ -13,7 +13,7 @@ 1. 随机生成算法库密钥对象。该对象可用于后续的加解密等操作。 2. 根据指定数据生成算法库密钥对象(也就是将外部或存储的二进制数据转换为算法库的密钥对象)。该对象可用于后续的加解密等操作。 3. 获取算法库密钥对象的二进制数据,用于存储或传输。 -> **说明**:密钥对象Key包括对称密钥SymKey和非对称密钥(公钥PubKey和私钥PriKey),其中公钥和私钥组成密钥对KeyPair。密钥之间的具体关系可参考[接口声明](../reference/apis/js-apis-cryptoFramework.md)。 +> **说明**:密钥对象Key包括对称密钥SymKey和非对称密钥(公钥PubKey和私钥PriKey),其中公钥和私钥组成密钥对KeyPair。密钥之间的具体关系可参考[API参考](../reference/apis/js-apis-cryptoFramework.md)。 **接口及参数说明** @@ -107,7 +107,7 @@ function testGenerateAesKey() { import cryptoFramework from '@ohos.security.cryptoFramework'; function convertAsyKey() { - let rsaGenerator = cfm.createAsyKeyGenerator("RSA1024"); + let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024"); let pkval = new Uint8Array([48,129,159,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,129,141,0,48,129,137,2,129,129,0,174,203,113,83,113,3,143,213,194,79,91,9,51,142,87,45,97,65,136,24,166,35,5,179,42,47,212,79,111,74,134,120,73,67,21,19,235,80,46,152,209,133,232,87,192,140,18,206,27,106,106,169,106,46,135,111,118,32,129,27,89,255,183,116,247,38,12,7,238,77,151,167,6,102,153,126,66,28,253,253,216,64,20,138,117,72,15,216,178,37,208,179,63,204,39,94,244,170,48,190,21,11,73,169,156,104,193,3,17,100,28,60,50,92,235,218,57,73,119,19,101,164,192,161,197,106,105,73,2,3,1,0,1]); let pkBlob = {data : pkval}; rsaGenerator.convertKey(pkBlob, null, function(err, keyPair) { @@ -563,15 +563,15 @@ function encryptMessageCallback() { |Sign|init(priKey : PriKey) : Promise\|使用Promise方式设置密钥并初始化Sign对象| |Sign|update(data : DataBlob, callback : AsyncCallback\) : void|使用callback方式添加签名数据| |Sign|update(data : DataBlob) : Promise\|用Promise方式添加签名数据| -|Sign|sign(data : DataBlob, callback : AsyncCallback) : void|使用callback方式签名所有数据| -|Sign|sign(data : DataBlob) : Promise|使用Promise方式签名所有数据| +|Sign|sign(data : DataBlob, callback : AsyncCallback\) : void|使用callback方式签名所有数据| +|Sign|sign(data : DataBlob) : Promise\|使用Promise方式签名所有数据| |cryptoFramework|function createVerify(algName : string) : Verify|根据String设置的参数创建Verify对象| |Verify|init(priKey : PriKey, callback : AsyncCallback\) : void|使用callback方式设置密钥并初始化Verify对象| |Verify|init(priKey : PriKey) : Promise\|使用Promise方式设置密钥并初始化Verify对象| |Verify|update(data : DataBlob, callback : AsyncCallback\) : void|使用callback方式添加验签数据| |Verify|update(data : DataBlob) : Promise\|用Promise方式添加验签数据| -|Verify|verify(data : DataBlob, signatureData : DataBlob, callback : AsyncCallback) : void|使用callback方式验签所有数据| -|Verify|verify(data : DataBlob, signatureData : DataBlob) : Promise|使用Promise方式验签所有数据| +|Verify|verify(data : DataBlob, signatureData : DataBlob, callback : AsyncCallback\) : void|使用callback方式验签所有数据| +|Verify|verify(data : DataBlob, signatureData : DataBlob) : Promise\|使用Promise方式验签所有数据| **开发步骤** @@ -761,10 +761,10 @@ function verifyMessageCallback() { | 实例名 | 接口名 | 描述 | | --------------- | ------------------------------------------------------------ | -------------------------------------------------- | | cryptoFramework | function createMd(algName : string) : Md; | 指定摘要算法,生成摘要操作实例Md | -| Md | update(input : DataBlob, callback : AsyncCallback\) : void; | 接受用户输入数据,通过Callback的方式,异步更新摘要 | -| Md | update(input : DataBlob) : Promise\; | 接受用户输入数据,通过Promise的方式,异步更新摘要 | -| Md | digest(callback : AsyncCallback\) : void; | 通过Callback的方式,返回结果 | -| Md | digest() : Promise\; | 通过Promise的方式,返回结果 | +| Md | update(input : DataBlob, callback : AsyncCallback\) : void; | 接受用户输入数据,通过Callback的方式,异步更新摘要 | +| Md | update(input : DataBlob) : Promise\; | 接受用户输入数据,通过Promise的方式,异步更新摘要 | +| Md | digest(callback : AsyncCallback\) : void; | 通过Callback的方式,返回结果 | +| Md | digest() : Promise\; | 通过Promise的方式,返回结果 | | Md | getMdLength() : number; | 获取摘要的长度(由指定的摘要算法决定) | | Md | readonly algName : string; | 获取当前设置的摘要算法名 | @@ -923,12 +923,12 @@ Mac(message authentication code)可以对消息进行完整性校验,通过使 | 实例名 | 接口名 | 描述 | | --------------- | ------------------------------------------------------------ | --------------------------------------------------- | | cryptoFramework | function createMac(algName : string) : Mac; | 指定摘要算法,生成消息认证码实例Mac | -| Mac | init(key : SymKey, callback : AsyncCallback\) : void; | 接收输入对称密钥,通过Callback的方式,异步初始化MAC | -| Mac | init(key : SymKey) : Promise\; | 接收输入对称密钥,通过Promise的方式,异步初始化MAC | -| Mac | update(input : DataBlob, callback : AsyncCallback\) : void; | 接受输入数据,通过Callback的方式,异步更新MAC | -| Mac | update(input : DataBlob) : Promise\; | 接受输入数据,通过Promise的方式,异步更新MAC | -| Mac | doFinal(callback : AsyncCallback\) : void; | 通过Callback的方式,返回MAC计算结果 | -| Mac | doFinal() : Promise\; | 通过Promise的方式,返回MAC计算结果 | +| Mac | init(key : SymKey, callback : AsyncCallback\) : void; | 接收输入对称密钥,通过Callback的方式,异步初始化MAC | +| Mac | init(key : SymKey) : Promise\; | 接收输入对称密钥,通过Promise的方式,异步初始化MAC | +| Mac | update(input : DataBlob, callback : AsyncCallback\) : void; | 接受输入数据,通过Callback的方式,异步更新MAC | +| Mac | update(input : DataBlob) : Promise\; | 接受输入数据,通过Promise的方式,异步更新MAC | +| Mac | doFinal(callback : AsyncCallback\) : void; | 通过Callback的方式,返回MAC计算结果 | +| Mac | doFinal() : Promise\; | 通过Promise的方式,返回MAC计算结果 | | Mac | getMacLength() : number; | 获取MAC的长度(由指定的摘要算法决定) | | Mac | readonly algName : string; | 获取当前设置的摘要算法名 | @@ -1055,10 +1055,10 @@ function doHmacByCallback(algName) { | 实例名 | 接口名 | 描述 | | --------------- | ------------------------------------------------------------ | ---------------------------------------------- | | cryptoFramework | function createRandom() : Random; | 生成随机数Random实例 | -| Random | generateRandom(len : number, callback: AsyncCallback\) : void; | 接受输入长度,通过Callback,异步生成随机数 | -| Random | generateRandom(len : number) : Promise\; | 接受输入长度,通过Promise,异步生成随机数 | -| Random | setSeed(seed : DataBlob, callback : AsyncCallback\) : void; | 接受输入Blob,通过Callback的方式,异步设置种子 | -| Random | setSeed(seed : DataBlob) : Promise\; | 接受输入Blob,通过Promise的方式,异步设置种子 | +| Random | generateRandom(len : number, callback: AsyncCallback\) : void; | 接受输入长度,通过Callback,异步生成随机数 | +| Random | generateRandom(len : number) : Promise\; | 接受输入长度,通过Promise,异步生成随机数 | +| Random | setSeed(seed : DataBlob, callback : AsyncCallback\) : void; | 接受输入Blob,通过Callback的方式,异步设置种子 | +| Random | setSeed(seed : DataBlob) : Promise\; | 接受输入Blob,通过Promise的方式,异步设置种子 | **开发步骤** @@ -1135,16 +1135,16 @@ function doRandByCallback(len) { | 实例名 | 接口名 | 描述 | | --------------- | ------------------------------------------------------------ | -------------------------------------------- | -| cryptoFramework | createX509Cert(inStream : EncodingBlob, callback : AsyncCallback) : void | 使用callback方式解析X509证书数据生成证书对象 | -| cryptoFramework | createX509Cert(inStream : EncodingBlob) : Promise | 使用promise方式解析X509证书数据生成证书对象 | -| X509Cert | verify(key : PubKey, callback : AsyncCallback) : void | 使用callback方式进行证书验签 | -| X509Cert | verify(key : PubKey) : Promise | 使用promise方式进行证书验签 | -| X509Cert | getEncoded(callback : AsyncCallback) : void | 使用callback方式获取证书序列化数据 | -| X509Cert | getEncoded() : Promise | 使用promise方式获取证书序列化数据 | -| X509Cert | getPublicKey(callback : AsyncCallback) : void | 使用callback方式获取证书公钥 | -| X509Cert | getPublicKey() : Promise | 使用Promise方式获取证书公钥 | -| X509Cert | checkValidityWithDate(date: string, callback : AsyncCallback) : void | 使用callback方式校验证书有效期 | -| X509Cert | checkValidityWithDate(date: string) : Promise | 使用Promise方式校验证书有效期 | +| cryptoFramework | createX509Cert(inStream : EncodingBlob, callback : AsyncCallback\) : void | 使用callback方式解析X509证书数据生成证书对象 | +| cryptoFramework | createX509Cert(inStream : EncodingBlob) : Promise\ | 使用promise方式解析X509证书数据生成证书对象 | +| X509Cert | verify(key : PubKey, callback : AsyncCallback\) : void | 使用callback方式进行证书验签 | +| X509Cert | verify(key : PubKey) : Promise\ | 使用promise方式进行证书验签 | +| X509Cert | getEncoded(callback : AsyncCallback\) : void | 使用callback方式获取证书序列化数据 | +| X509Cert | getEncoded() : Promise\ | 使用promise方式获取证书序列化数据 | +| X509Cert | getPublicKey(callback : AsyncCallback\) : void | 使用callback方式获取证书公钥 | +| X509Cert | getPublicKey() : Promise\ | 使用Promise方式获取证书公钥 | +| X509Cert | checkValidityWithDate(date: string, callback : AsyncCallback\) : void | 使用callback方式校验证书有效期 | +| X509Cert | checkValidityWithDate(date: string) : Promise\ | 使用Promise方式校验证书有效期 | | X509Cert | getVersion() : number | 获取证书版本 | | X509Cert | getSerialNumber() : number | 获取证书序列号 | | X509Cert | getIssuerName() : DataBlob | 获取证书颁发者名称 | @@ -1287,27 +1287,27 @@ function certSample() { | 实例名 | 接口名 | 描述 | | --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| cryptoFramework | createX509Crl(inStream : EncodingBlob, callback : AsyncCallback) : void | 使用callback方式解析X509证书吊销列表数据生成证书吊销列表对象 | -| cryptoFramework | createX509Crl(inStream : EncodingBlob) : Promise | 使用promise方式解析X509证书吊销列表数据生成证书吊销列表对象 | -| X509Crl | isRevoked(cert : X509Cert, callback : AsyncCallback) : void | 使用callback方式检查证书是否被吊销 | -| X509Crl | isRevoked(cert : X509Cert) : Promise | 使用promise方式检查证书是否被吊销 | +| cryptoFramework | createX509Crl(inStream : EncodingBlob, callback : AsyncCallback\) : void | 使用callback方式解析X509证书吊销列表数据生成证书吊销列表对象 | +| cryptoFramework | createX509Crl(inStream : EncodingBlob) : Promise\ | 使用promise方式解析X509证书吊销列表数据生成证书吊销列表对象 | +| X509Crl | isRevoked(cert : X509Cert, callback : AsyncCallback\) : void | 使用callback方式检查证书是否被吊销 | +| X509Crl | isRevoked(cert : X509Cert) : Promise\ | 使用promise方式检查证书是否被吊销 | | X509Crl | getType() : string | 获取证书吊销列表类型 | -| X509Crl | getEncoded(callback : AsyncCallback) : void | 使用callback方式获取证书吊销列表序列化数据 | -| X509Crl | getEncoded() : Promise | 使用promise方式获取证书吊销列表序列化数据 | -| X509Crl | verify(key : PubKey, callback : AsyncCallback) : void | 使用callback方式进行证书吊销列表验签 | -| X509Crl | verify(key : PubKey) : Promise | 使用Promise方式进行证书吊销列表验签 | +| X509Crl | getEncoded(callback : AsyncCallback\) : void | 使用callback方式获取证书吊销列表序列化数据 | +| X509Crl | getEncoded() : Promise\ | 使用promise方式获取证书吊销列表序列化数据 | +| X509Crl | verify(key : PubKey, callback : AsyncCallback\) : void | 使用callback方式进行证书吊销列表验签 | +| X509Crl | verify(key : PubKey) : Promise\ | 使用Promise方式进行证书吊销列表验签 | | X509Crl | getVersion() : number | 获取证书吊销列表版本 | | X509Crl | getIssuerName() : DataBlob | 获取证书吊销列表颁发者名称 | | X509Crl | getLastUpdate() : string | 获取证书吊销列表lastUpdate日期 | | X509Crl | getNextUpdate() : string | 获取证书吊销列表nextUpdate日期 | -| X509Crl | getRevokedCert(serialNumber : number, callback : AsyncCallback) : void | 使用callback方式通过序列号获取证书吊销列表中的被吊销证书 | -| X509Crl | getRevokedCert(serialNumber : number) : Promise | 使用Promise方式通过序列号获取证书吊销列表中的被吊销证书 | -| X509Crl | getRevokedCertWithCert(cert : X509Cert, callback : AsyncCallback) : void | 使用callback方式通过X509证书获取证书吊销列表中的被吊销证书 | -| X509Crl | getRevokedCertWithCert(cert : X509Cert) : Promise | 使用Promise方式通过X509证书获取证书吊销列表中的被吊销证书 | -| X509Crl | getRevokedCerts(callback : AsyncCallback>) : void | 使用callback方式获取证书吊销列表的所有被吊销证书 | -| X509Crl | getRevokedCerts() : Promise> | 使用Promise方式获取证书吊销列表的所有被吊销证书 | -| X509Crl | getTbsInfo(callback : AsyncCallback) : void | 使用callback方式获取证书吊销列表的tbsCertList | -| X509Crl | getTbsInfo() : Promise | 使用Promise方式获取证书吊销列表的tbsCertList | +| X509Crl | getRevokedCert(serialNumber : number, callback : AsyncCallback\) : void | 使用callback方式通过序列号获取证书吊销列表中的被吊销证书 | +| X509Crl | getRevokedCert(serialNumber : number) : Promise\ | 使用Promise方式通过序列号获取证书吊销列表中的被吊销证书 | +| X509Crl | getRevokedCertWithCert(cert : X509Cert, callback : AsyncCallback\) : void | 使用callback方式通过X509证书获取证书吊销列表中的被吊销证书 | +| X509Crl | getRevokedCertWithCert(cert : X509Cert) : Promise\ | 使用Promise方式通过X509证书获取证书吊销列表中的被吊销证书 | +| X509Crl | getRevokedCerts(callback : AsyncCallback\>) : void | 使用callback方式获取证书吊销列表的所有被吊销证书 | +| X509Crl | getRevokedCerts() : Promise\> | 使用Promise方式获取证书吊销列表的所有被吊销证书 | +| X509Crl | getTbsInfo(callback : AsyncCallback\) : void | 使用callback方式获取证书吊销列表的tbsCertList | +| X509Crl | getTbsInfo() : Promise\ | 使用Promise方式获取证书吊销列表的tbsCertList | | X509Crl | getSignature() : DataBlob | 获取证书吊销列表的签名 | | X509Crl | getSignatureAlgName() : string | 获取证书吊销列表的签名算法名称 | | X509Crl | getSignatureAlgOid() : string | 获取证书吊销列表的签名算法OID | @@ -1437,8 +1437,8 @@ function crlSample() { | 实例名 | 接口名 | 描述 | | ------------------ | ------------------------------------------------------------ | -------------------------------- | | cryptoFramework | createCertChainValidator(algorithm :string) : CertChainValidator | 使用指定算法生成证书链校验器对象 | -| CertChainValidator | validate(certChain : CertChainData, callback : AsyncCallback) : void | 使用callback方式校验证书链 | -| CertChainValidator | validate(certChain : CertChainData) : Promise | 使用promise方式校验证书链 | +| CertChainValidator | validate(certChain : CertChainData, callback : AsyncCallback\) : void | 使用callback方式校验证书链 | +| CertChainValidator | validate(certChain : CertChainData) : Promise\ | 使用promise方式校验证书链 | | CertChainValidator | algorithm : string | 证书链校验器算法名称 | **开发步骤** @@ -1548,13 +1548,13 @@ function certChainValidatorSample() { | 实例名 | 接口名 | 描述 | | ------------ | ----------------------------------------------------------- | ------------------------------------------ | -| X509CrlEntry | getEncoded(callback : AsyncCallback) : void; | 使用callback方式获取被吊销证书的序列化数据 | -| X509CrlEntry | getEncoded() : Promise; | 使用promise方式获取被吊销证书的序列化数据 | +| X509CrlEntry | getEncoded(callback : AsyncCallback\) : void; | 使用callback方式获取被吊销证书的序列化数据 | +| X509CrlEntry | getEncoded() : Promise\; | 使用promise方式获取被吊销证书的序列化数据 | | X509CrlEntry | getSerialNumber() : number; | 获取被吊销证书的序列号 | -| X509CrlEntry | getCertIssuer(callback : AsyncCallback) : void; | 使用callback方式获取被吊销证书颁发者 | -| X509CrlEntry | getCertIssuer() : Promise; | 使用promise方式获取被吊销证书颁发者 | -| X509CrlEntry | getRevocationDate(callback : AsyncCallback) : void; | 使用callback方式获取被吊销证书的吊销日期 | -| X509CrlEntry | getRevocationDate() : Promise; | 使用promise方式获取被吊销证书的吊销日期 | +| X509CrlEntry | getCertIssuer(callback : AsyncCallback\) : void; | 使用callback方式获取被吊销证书颁发者 | +| X509CrlEntry | getCertIssuer() : Promise\; | 使用promise方式获取被吊销证书颁发者 | +| X509CrlEntry | getRevocationDate(callback : AsyncCallback\) : void; | 使用callback方式获取被吊销证书的吊销日期 | +| X509CrlEntry | getRevocationDate() : Promise\; | 使用promise方式获取被吊销证书的吊销日期 | **开发步骤** @@ -1606,4 +1606,3 @@ function crlEntrySample() { }); } ``` - diff --git a/zh-cn/application-dev/security/userauth-guidelines.md b/zh-cn/application-dev/security/userauth-guidelines.md index d30a71e607a2f8492b134e7ecc843347597ceac8..fa18eefba7491f6ec43b6a92c04c7426cdd59931 100644 --- a/zh-cn/application-dev/security/userauth-guidelines.md +++ b/zh-cn/application-dev/security/userauth-guidelines.md @@ -1,113 +1,239 @@ # 用户认证开发指导 > **说明:** -> 该开发指导需匹配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** 用户认证开放能力列表 -| 接口名 | 功能描述 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| getVersion() : number | 获取认证对象的版本信息。 | -| getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 | -| auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array | 执行用户认证,使用callback方式作为异步方法。 | -| cancelAuth(contextID : Uint8Array) : number | 通过contextID取消本次认证操作。 | - -## 开发步骤 - -开发前请完成以下准备工作: - -1. 在应用配置权限文件中,增加ohos.permission.ACCESS_BIOMETRIC的权限声明。 -2. 在使用用户认证能力的代码文件中增加import userIAM_userAuth from '@ohos.userIAM.userAuth'。 - -开发过程: - -1. 获取Authenticator的单例对象,代码示例如下: - - ```js - let auth = new userIAM_userAuth.UserAuth(); - ``` - -2. (可选)获取认证对象的版本信息,代码示例如下: - - ```js - let auth = new userIAM_userAuth.UserAuth(); - let version = auth.getVersion(); - console.info("auth version = " + version); - ``` - -3. 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力,代码示例如下: - - ```js - let auth = new userIAM_userAuth.UserAuth(); - let checkCode = 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); - // 此处添加不支持指定类型认证的逻辑 - } - ``` - -4. 执行认证操作,代码示例如下: - - ```js - 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); - } - }, - - 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); - } - } - }); - ``` - -5. 认证过程中取消认证,代码示例如下: - - ```js - let auth = new userIAM_userAuth.UserAuth(); - // 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); - } - }); - let cancelCode = auth.cancel(contextId); - if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { - console.info("cancel auth success"); - } else { - console.error("cancel auth fail"); - } - ``` +| 接口名称 | 功能描述 | +| ---------- | ----------------------- | +| getVersion() : number | 获取认证对象的版本信息。 | +| getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 | +| getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel : AuthTrustLevel): AuthInstance | 获取AuthInstance对象,用于执行用户身份认证。 | +| on(name : AuthEventKey, callback : AuthEvent) : void | 订阅指定类型的用户认证事件。 | +| off(name : AuthEventKey) : void | 取消订阅特定类型的认证事件。 | +| start: void | 执行用户认证。 | +| cancel: void | 取消本次认证操作。 | + +## 获取认证对象的版本信息 + +### 开发步骤 + +1. 申请权限。调用[getVersion](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetversion9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)。 + +2. 调用[getVersion](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetversion9)接口获取版本信息。 + + ```js + 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); + } + ``` + +## 查询当前设备是否支持相应的认证能力 + +### 开发步骤 + +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 + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + // 查询认证能力是否支持 + 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); + } + ``` + +## 执行认证操作并请阅认证结果 + +### 开发步骤 + +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 + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + 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 { + 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); + } + ``` + +## 执行认证操作并订阅认证过程中的提示信息 + +### 开发步骤 + +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 + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + 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 { + 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("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 + } + } + }); + 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); + } + ``` + +## 认证过程中取消认证 + +### 开发步骤 + +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 + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + 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 { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); + } catch (error) { + console.log("get auth instance 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); + } + ``` diff --git a/zh-cn/application-dev/security/userauth-overview.md b/zh-cn/application-dev/security/userauth-overview.md index 9c9ccf82781e6f17f0486af824bd55e3eb09c650..b566680f07552e94fe084eb3d552e82827499b39 100644 --- a/zh-cn/application-dev/security/userauth-overview.md +++ b/zh-cn/application-dev/security/userauth-overview.md @@ -1,24 +1,26 @@ # 用户认证开发概述 -提供用户认证能力,可应用于设备解锁、支付、应用登录等身份认证场景。 +## 用户认证模块的定义 -当前用户认证能力提供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。 -- 要求设备上具有TEE安全环境,人脸特征信息高强度加密保存在TEE中。 +- 当前版本提供的用户认证能力包含人脸识别和指纹识别,且只支持本地认证,不提供认证界面。 +- 要求设备上具备相应的生物特征采集器,且对于人脸识别要求人脸图像分辨率大于100*100。 +- 要求设备上具有TEE安全环境,人脸和指纹等生物特征信息高强度加密保存在TEE中。 - 对于面部特征相似的人、面部特征不断发育的儿童,人脸特征匹配率有所不同。如果对此担忧,可考虑其他认证方式。 \ No newline at end of file diff --git a/zh-cn/application-dev/task-management/efficiency-resources-apply-dev-guide.md b/zh-cn/application-dev/task-management/efficiency-resources-apply-dev-guide.md index 8a9d02013b63f48b970ff23fdace1e5735b29af7..885dacbcd1e2ccef1e082f398f270385b22c9cd3 100644 --- a/zh-cn/application-dev/task-management/efficiency-resources-apply-dev-guide.md +++ b/zh-cn/application-dev/task-management/efficiency-resources-apply-dev-guide.md @@ -1,12 +1,12 @@ -## 申请能效资源 +# 申请能效资源 -### 场景说明 +## 场景说明 在实际的系统中,存在一些重要性高的系统应用,虽然此类应用相比普通应用具有一定的特权,但为了进一步平衡系统的功耗开销,这些应用同样需要支持在后台可被挂起。但对于系统特权应用,为了避免挂起后重要功能受到影响,提供了独立的能效资源申请接口,使这些特权应用可以在后台执行一些特殊的任务和使用特定的系统资源,例如在被挂起期间如果仍然希望能够收到系统公共事件,可以使用能效资源接口向系统申请使用公共事件资源。 对于需要升级为特权应用的,开发者需要合理评估自己的业务诉求,向应用中心提出申请。 -### 接口说明 +## 接口说明 **表1** 申请能效资源主要接口 @@ -16,7 +16,7 @@ | resetAllEfficiencyResources():void | 释放申请的能效资源。 | -### 开发步骤 +## 开发步骤 1、当特权应用需要在后台使用特殊资源时。向系统申请目标资源。 diff --git a/zh-cn/application-dev/ui/Readme-CN.md b/zh-cn/application-dev/ui/Readme-CN.md index 78f5e05588a6d86a06b3b6f9c7bdfcce9fed1d36..45fe37d4d80aaf4de83651583b059e049a85a31e 100755 --- a/zh-cn/application-dev/ui/Readme-CN.md +++ b/zh-cn/application-dev/ui/Readme-CN.md @@ -2,100 +2,100 @@ - [方舟开发框架(ArkUI)概述](arkui-overview.md) - UI开发(基于ArkTS的声明式开发范式) - - [概述](ui-ts-overview.md) - - [声明式UI开发指导](ui-ts-developing-intro.md) - - 声明式UI开发实例 - - [创建简单视图](ui-ts-creating-simple-page.md) - - 构建完整实例 - - [构建食物数据模型](ui-ts-building-data-model.md) - - [构建食物列表List布局](ui-ts-building-category-list-layout.md) - - [构建食物分类Grid布局](ui-ts-building-category-grid-layout.md) - - [页面跳转与数据传递](ui-ts-page-redirection-data-transmission.md) - - 添加闪屏动画 - - [绘制图像](ui-ts-drawing-feature.md) - - [添加动画效果](ui-ts-animation-feature.md) - - [常用组件说明](ui-ts-components-intro.md) - - 常见布局开发指导 - - 自适应布局 - - [线性布局](ui-ts-layout-linear.md) - - [层叠布局](ui-ts-layout-stack.md) - - [弹性布局](ui-ts-layout-flex.md) - - [网格布局](ui-ts-layout-grid.md) - - 响应式布局 - - [栅格布局](ui-ts-layout-grid-container-new.md) - - [媒体查询](ui-ts-layout-mediaquery.md) - - [自定义组件的生命周期](ui-ts-custom-component-lifecycle-callbacks.md) - - [Web组件开发指导](ui-ts-components-web.md) - - [性能提升的推荐方法](ui-ts-performance-improvement-recommendation.md) + - [概述](ui-ts-overview.md) + - [声明式UI开发指导](ui-ts-developing-intro.md) + - 声明式UI开发实例 + - [创建简单视图](ui-ts-creating-simple-page.md) + - 构建完整实例 + - [构建食物数据模型](ui-ts-building-data-model.md) + - [构建食物列表List布局](ui-ts-building-category-list-layout.md) + - [构建食物分类Grid布局](ui-ts-building-category-grid-layout.md) + - [页面跳转与数据传递](ui-ts-page-redirection-data-transmission.md) + - 添加闪屏动画 + - [绘制图像](ui-ts-drawing-feature.md) + - [添加动画效果](ui-ts-animation-feature.md) + - [常用组件说明](ui-ts-components-intro.md) + - 常见布局开发指导 + - 自适应布局 + - [线性布局](ui-ts-layout-linear.md) + - [层叠布局](ui-ts-layout-stack.md) + - [弹性布局](ui-ts-layout-flex.md) + - [网格布局](ui-ts-layout-grid.md) + - 响应式布局 + - [栅格布局](ui-ts-layout-grid-container-new.md) + - [媒体查询](ui-ts-layout-mediaquery.md) + - [自定义组件的生命周期](ui-ts-custom-component-lifecycle-callbacks.md) + - [Web组件开发指导](ui-ts-components-web.md) + - [性能提升的推荐方法](ui-ts-performance-improvement-recommendation.md) - UI开发(兼容JS的类Web开发范式) - - [概述](ui-js-overview.md) - - 框架说明 - - [文件组织](js-framework-file.md) - - [js标签配置](js-framework-js-tag.md) - - [app.js](js-framework-js-file.md) - - 语法 - - [HML语法参考](js-framework-syntax-hml.md) - - [CSS语法参考](js-framework-syntax-css.md) - - [JS语法参考](js-framework-syntax-js.md) - - [生命周期](js-framework-lifecycle.md) - - [资源限定与访问](js-framework-resource-restriction.md) - - [多语言支持](js-framework-multiple-languages.md) - - 构建用户界面 - - [组件介绍](ui-js-building-ui-component.md) - - 构建布局 - - [布局说明](ui-js-building-ui-layout-intro.md) - - [添加标题行和文本区域](ui-js-building-ui-layout-text.md) - - [添加图片区域](ui-js-building-ui-layout-image.md) - - [添加留言区域](ui-js-building-ui-layout-comment.md) - - [添加容器](ui-js-building-ui-layout-external-container.md) - - [添加交互](ui-js-building-ui-interactions.md) - - [动画](ui-js-building-ui-animation.md) - - [手势事件](ui-js-building-ui-event.md) - - [页面路由](ui-js-building-ui-routes.md) - - 常见组件开发指导 - - 容器组件 - - [List开发指导](ui-js-components-list.md) - - [Dialog开发指导](ui-js-components-dialog.md) - - [Form开发指导](ui-js-components-form.md) - - [Stepper开发指导](ui-js-components-stepper.md) - - [Tabs开发指导](ui-js-component-tabs.md) - - [Swiper开发指导](ui-js-components-swiper.md) - - 基础组件 - - [Text开发指导](ui-js-components-text.md) - - [Input开发指导](ui-js-components-input.md) - - [Button开发指导](ui-js-components-button.md) - - [Picker开发指导](ui-js-components-picker.md) - - [Image开发指导](ui-js-components-images.md) - - [Image-animator开发指导](ui-js-components-image-animator.md) - - [Rating开发指导](ui-js-components-rating.md) - - [Slider开发指导](ui-js-components-slider.md) - - [Chart开发指导](ui-js-components-chart.md) - - [Switch开发指导](ui-js-components-switch.md) - - [Toolbar开发指导](ui-js-components-toolbar.md) - - [Menu开发指导](ui-js-components-menu.md) - - [Marquee开发指导](ui-js-components-marquee.md) - - [Qrcode开发指导](ui-js-components-qrcode.md) - - [Search开发指导](ui-js-components-search.md) - - Canvas开发指导 - - [Canvas对象](ui-js-components-canvas.md) - - [CanvasRenderingContext2D对象](ui-js-components-canvasrenderingcontext2d.md) - - [Path2D对象](ui-js-components-path2d.md) - - [OffscreenCanvas对象](ui-js-components-offscreencanvas.md) - - [栅格布局](ui-js-components-grid.md) - - Svg开发指导 - - [基础知识](ui-js-components-svg-overview.md) - - [绘制图形](ui-js-components-svg-graphics.md) - - [绘制路径](ui-js-components-svg-path.md) - - [绘制文本](ui-js-components-svg-text.md) - - 动效开发指导 - - CSS动画 - - [属性样式动画](ui-js-animate-attribute-style.md) - - [transform样式动画](ui-js-animate-transform.md) - - [background-position样式动画](ui-js-animate-background-position-style.md) - - [svg动画](ui-js-animate-svg.md) - - JS动画 - - [组件动画](ui-js-animate-component.md) - - 插值器动画 - - [动画动效](ui-js-animate-dynamic-effects.md) - - [动画帧](ui-js-animate-frame.md) - - [自定义组件](ui-js-custom-components.md) \ No newline at end of file + - [概述](ui-js-overview.md) + - 框架说明 + - [文件组织](js-framework-file.md) + - [js标签配置](js-framework-js-tag.md) + - [app.js](js-framework-js-file.md) + - 语法 + - [HML语法参考](js-framework-syntax-hml.md) + - [CSS语法参考](js-framework-syntax-css.md) + - [JS语法参考](js-framework-syntax-js.md) + - [生命周期](js-framework-lifecycle.md) + - [资源限定与访问](js-framework-resource-restriction.md) + - [多语言支持](js-framework-multiple-languages.md) + - 构建用户界面 + - [组件介绍](ui-js-building-ui-component.md) + - 构建布局 + - [布局说明](ui-js-building-ui-layout-intro.md) + - [添加标题行和文本区域](ui-js-building-ui-layout-text.md) + - [添加图片区域](ui-js-building-ui-layout-image.md) + - [添加留言区域](ui-js-building-ui-layout-comment.md) + - [添加容器](ui-js-building-ui-layout-external-container.md) + - [添加交互](ui-js-building-ui-interactions.md) + - [动画](ui-js-building-ui-animation.md) + - [手势事件](ui-js-building-ui-event.md) + - [页面路由](ui-js-building-ui-routes.md) + - 常见组件开发指导 + - 容器组件 + - [List开发指导](ui-js-components-list.md) + - [Dialog开发指导](ui-js-components-dialog.md) + - [Form开发指导](ui-js-components-form.md) + - [Stepper开发指导](ui-js-components-stepper.md) + - [Tabs开发指导](ui-js-component-tabs.md) + - [Swiper开发指导](ui-js-components-swiper.md) + - 基础组件 + - [Text开发指导](ui-js-components-text.md) + - [Input开发指导](ui-js-components-input.md) + - [Button开发指导](ui-js-components-button.md) + - [Picker开发指导](ui-js-components-picker.md) + - [Image开发指导](ui-js-components-images.md) + - [Image-animator开发指导](ui-js-components-image-animator.md) + - [Rating开发指导](ui-js-components-rating.md) + - [Slider开发指导](ui-js-components-slider.md) + - [Chart开发指导](ui-js-components-chart.md) + - [Switch开发指导](ui-js-components-switch.md) + - [Toolbar开发指导](ui-js-components-toolbar.md) + - [Menu开发指导](ui-js-components-menu.md) + - [Marquee开发指导](ui-js-components-marquee.md) + - [Qrcode开发指导](ui-js-components-qrcode.md) + - [Search开发指导](ui-js-components-search.md) + - Canvas开发指导 + - [Canvas对象](ui-js-components-canvas.md) + - [CanvasRenderingContext2D对象](ui-js-components-canvasrenderingcontext2d.md) + - [Path2D对象](ui-js-components-path2d.md) + - [OffscreenCanvas对象](ui-js-components-offscreencanvas.md) + - [栅格布局](ui-js-components-grid.md) + - Svg开发指导 + - [基础知识](ui-js-components-svg-overview.md) + - [绘制图形](ui-js-components-svg-graphics.md) + - [绘制路径](ui-js-components-svg-path.md) + - [绘制文本](ui-js-components-svg-text.md) + - 动效开发指导 + - CSS动画 + - [属性样式动画](ui-js-animate-attribute-style.md) + - [transform样式动画](ui-js-animate-transform.md) + - [background-position样式动画](ui-js-animate-background-position-style.md) + - [svg动画](ui-js-animate-svg.md) + - JS动画 + - [组件动画](ui-js-animate-component.md) + - 插值器动画 + - [动画动效](ui-js-animate-dynamic-effects.md) + - [动画帧](ui-js-animate-frame.md) + - [自定义组件](ui-js-custom-components.md) diff --git a/zh-cn/application-dev/ui/ui-ts-components-web.md b/zh-cn/application-dev/ui/ui-ts-components-web.md index 6f4acc31caca52b4bab2e97e9913922dd86904fa..884066df04728957cacc39ab5c1263d003519ced 100644 --- a/zh-cn/application-dev/ui/ui-ts-components-web.md +++ b/zh-cn/application-dev/ui/ui-ts-components-web.md @@ -151,6 +151,38 @@ struct WebComponent { ``` + +## 开启网页调试 +在PC上启用端口转发,以及设置Web组件属性webDebuggingAccess为true后,便可以在PC上调试通过USB连接的开发设备上的Web组件里的网页。 + +设置步骤如下: + +1、首先设置Web组件属性webDebuggingAccess为true。 + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController() + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .webDebuggingAccess(true) // true表示启用调试功能 + } + } + } + ``` + +2、PC上启用端口转发功能,添加TCP端口9222映射。 + ```ts + hdc fport tcp:9222 tcp:9222 + ``` + 添加是否成功可以通过如下命令来查看已存在的映射关系表。 + ```ts + hdc fport ls + ``` +如上设置完成后,首先打开应用Web组件、访问要调试的网页,然后在PC上使用chrome浏览器访问:http://localhost:9222, 就可以在PC上调试开发设备刚才访问的网页。 + ## 场景示例 该场景实现了Web组件中视频的动态播放。首先在HTML页面内嵌入视频资源,再使用Web组件的控制器调用onActive和onInactive方法激活和暂停页面渲染。点击onInactive按钮,Web页面停止渲染,视频暂停播放;点击onActive按钮,激活Web组件,视频继续播放。 diff --git a/zh-cn/application-dev/ui/ui-ts-developing-intro.md b/zh-cn/application-dev/ui/ui-ts-developing-intro.md index 62f4538cbe834025650e252f413ec7934b171cd4..fafdbc8f99c11bfda427b12d979ec35ef68e4d3e 100644 --- a/zh-cn/application-dev/ui/ui-ts-developing-intro.md +++ b/zh-cn/application-dev/ui/ui-ts-developing-intro.md @@ -6,7 +6,7 @@ | ---------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | 准备开发环境 | 了解声明式UI的工程结构。
了解资源分类与访问。 | [OpenHarmony工程介绍](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650)
[资源分类与访问](../quick-start/resource-categories-and-access.md) | | 学习ArkTS语言 | ArkTS是HarmonyOS优选的主力应用开发语言,当前,ArkTS在TS基础上主要扩展了声明式UI能力。 | [学习ArkTS语言](../quick-start/arkts-get-started.md) | -| 开发页面 | 根据页面的使用场景,选择合适的布局。
根据页面需要实现的内容,添加系统内置组件,并修改组件样式。
更新页面内容,丰富页面展现形式。 | [创建页面](#创建页面)
[常见布局开发指导](ui-ts-layout-linear.md)
[常见组件说明](ui-ts-components-intro.md)
[修改组件样式](#修改组件样式)
[更新页面内容](#更新页面内容) | +| 开发页面 | 根据页面的使用场景,选择合适的布局。
根据页面需要实现的内容,添加系统内置组件,并修改组件样式。
更新页面内容,丰富页面展现形式。 | [创建页面](#创建页面)
  [常见布局开发指导](ui-ts-layout-linear.md)
  [常见组件说明](ui-ts-components-intro.md)
[修改组件样式](#修改组件样式)
[更新页面内容](#更新页面内容) | | (可选)页面多样化 | 绘图和动画。 | [绘图组件](../reference/arkui-ts/ts-drawing-components-circle.md)
[画布组件](../reference/arkui-ts/ts-components-canvas-canvas.md)
[动画](../reference/arkui-ts/ts-animatorproperty.md) | | (可选)页面之间的跳转 | 使用页面路由实现多个页面之前的跳转。 | [页面路由](../reference/apis/js-apis-router.md) | | (可选)性能提升 | 避免低性能代码对应用的性能造成负面影响。 | [性能提升的推荐方法](ui-ts-performance-improvement-recommendation.md) | diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index 96e02fdd8648a52265c6357090a4159af16f4ff9..b43c02c8ddd4c18f29b4abe9a5a8fc5976c80a1b 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -8,10 +8,10 @@ - [使用ArkTS语言开发(FA模型)](quick-start/start-with-ets-fa.md) - [使用JS语言开发(FA模型)](quick-start/start-with-js-fa.md) - 开发基础知识 - - [应用包结构说明(FA模型)](quick-start/package-structure.md) - - [应用包结构说明(Stage模型)](quick-start/stage-structure.md) + - [应用包结构配置文件的说明(FA模型)](quick-start/package-structure.md) + - [应用包结构配置文件的说明(Stage模型)](quick-start/stage-structure.md) - [SysCap说明](quick-start/syscap.md) - - [HarmonyAppProvision配置文件](quick-start/app-provision-structure.md) + - [资源分类与访问](quick-start/resource-categories-and-access.md) - 学习ArkTS语言 - [初识ArkTS语言](quick-start/arkts-get-started.md) - ArkTS语法(声明式UI) @@ -49,35 +49,30 @@ - [方舟开发框架(ArkUI)概述](ui/arkui-overview.md) - 基于ArkTS的声明式开发范式 - [概述](ui/ui-ts-overview.md) - - 框架说明 - - 文件组织 - - [目录结构](ui/ts-framework-directory.md) - - [应用代码文件访问规则](ui/ts-framework-file-access-rules.md) - - 资源管理 - - [资源文件的分类](ui/ui-ts-basic-resource-file-categories.md) - - [资源访问](ui/ts-resource-access.md) - - [像素单位](ui/ts-pixel-units.md) - - 深入理解组件化 - - [自定义组件初始化](ui/ts-custom-component-initialization.md) - - [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md) - - [组件创建和重新初始化示例](ui/ts-component-creation-re-initialization.md) - - 常见组件开发指导 - - [Button开发指导](ui/ui-ts-basic-components-button.md) - - [Web开发指导](ui/ui-ts-components-web.md) - - 常见布局开发指导 - - [弹性布局](ui/ui-ts-layout-flex.md) - - [栅格布局](ui/ui-ts-layout-grid-container.md) - - [媒体查询](ui/ui-ts-layout-mediaquery.md) - - 体验声明式UI - - [创建声明式UI工程](ui/ui-ts-creating-project.md) - - [初识Component](ui/ui-ts-components.md) + - [声明式UI开发指导](ui/ui-ts-developing-intro.md) + - 声明式UI开发实例 - [创建简单视图](ui/ui-ts-creating-simple-page.md) - - 页面布局与连接 - - [构建食物数据模型](ui/ui-ts-building-data-model.md) - - [构建食物列表List布局](ui/ui-ts-building-category-list-layout.md) - - [构建食物分类Grid布局](ui/ui-ts-building-category-grid-layout.md) - - [页面跳转与数据传递](ui/ui-ts-page-redirection-data-transmission.md) - - [性能提升的推荐方法](ui/ts-performance-improvement-recommendation.md) + - 构建完整实例 + - [构建食物数据模型](ui/ui-ts-building-data-model.md) + - [构建食物列表List布局](ui/ui-ts-building-category-list-layout.md) + - [构建食物分类Grid布局](ui/ui-ts-building-category-grid-layout.md) + - [页面跳转与数据传递](ui/ui-ts-page-redirection-data-transmission.md) + - 添加闪屏动画 + - [绘制图像](ui/ui-ts-drawing-feature.md) + - [添加动画效果](ui/ui-ts-animation-feature.md) + - [常用组件说明](ui/ui-ts-components-intro.md) + - 常见布局开发指导 + - 自适应布局 + - [线性布局](ui/ui-ts-layout-linear.md) + - [层叠布局](ui/ui-ts-layout-stack.md) + - [弹性布局](ui/ui-ts-layout-flex.md) + - [网格布局](ui/ui-ts-layout-grid.md) + - 响应式布局 + - [栅格布局](ui/ui-ts-layout-grid-container-new.md) + - [媒体查询](ui/ui-ts-layout-mediaquery.md) + - [自定义组件的生命周期](ui/ui-ts-custom-component-lifecycle-callbacks.md) + - [Web组件开发指导](ui/ui-ts-components-web.md) + - [性能提升的推荐方法](ui/ui-ts-performance-improvement-recommendation.md) - 兼容JS的类Web开发范式 - [概述](ui/ui-js-overview.md) - 框架说明 @@ -174,9 +169,14 @@ - [OpenSL ES播放开发指导](media/opensles-playback.md) - [OpenSL ES录音开发指导](media/opensles-capture.md) - [音频焦点模式开发指导](media/audio-interruptmode.md) + - [音量管理开发指导](media/audio-volume-manager.md) + - [路由、设备管理开发指导](media/audio-routing-manager.md) - 视频 - [视频播放开发指导](media/video-playback.md) - [视频录制开发指导](media/video-recorder.md) + - 媒体会话 + - [AVSession开发概述](media/avsession-overview.md) + - [AVSession开发指导](media/avsession-guidelines.md) - 图片 - [图片开发指导](media/image.md) - 相机 @@ -200,6 +200,7 @@ - Hap包签名工具 - [Hap包签名工具概述](security/hapsigntool-overview.md) - [Hap包签名工具指导](security/hapsigntool-guidelines.md) + - [HarmonyAppProvision配置文件](security/app-provision-structure.md) - 网络与连接 - 网络管理 - [网络管理开发概述](connectivity/net-mgmt-overview.md) @@ -230,6 +231,12 @@ - 数据共享 - [数据共享概述](database/database-datashare-overview.md) - [数据共享开发指导](database/database-datashare-guidelines.md) + - 文件管理 + - 媒体库管理 + - [媒体库开发概述](file-management/medialibrary-overview.md) + - [媒体资源使用指导](file-management/medialibrary-resource-guidelines.md) + - [文件路径使用指导](file-management/medialibrary-filepath-guidelines.md) + - [相册资源使用指导](file-management/medialibrary-album-guidelines.md) - 任务管理 - 后台任务 - [后台任务概述](task-management/background-task-overview.md) @@ -254,12 +261,15 @@ - 振动 - [振动开发概述](device/vibrator-overview.md) - [振动开发指导](device/vibrator-guidelines.md) + - 多模输入 + - [输入设备开发指导](device/inputdevice-guidelines.md) + - [鼠标光标开发指导](device/pointerstyle-guidelines.md) - 升级服务 - [示例服务器开发概述](device/sample-server-overview.md) - [示例服务器开发指导](device/sample-server-guidelines.md) - 设备使用信息统计 - [设备使用信息统计概述](device-usage-statistics/device-usage-statistics-overview.md) - - [设备使用信息统计开发指导](device-usage-statistics/device-usage-statistics-dev-guide.md) + - [设备使用信息统计开发指导](device-usage-statistics/device-usage-statistics-use-guide.md) - DFX - 应用事件打点 - [应用事件打点概述](dfx/hiappevent-overview.md) @@ -272,10 +282,15 @@ - [分布式跟踪开发指导](dfx/hitracechain-guidelines.md) - 错误管理 - [错误管理开发指导](dfx/errormanager-guidelines.md) + - [应用恢复开发指导](dfx/apprecovery-guidelines.md) - 国际化 - [国际化开发概述](internationalization/international-overview.md) - [Intl开发指导](internationalization/intl-guidelines.md) - [I18n开发指导](internationalization/i18n-guidelines.md) + - 应用测试 + - [自动化测试框架使用指导](application-test/arkxtest-guidelines.md) + - [SmartPerf性能工具使用指导](application-test/smartperf-guidelines.md) + - [wukong稳定性工具使用指导](application-test/wukong-guidelines.md) - 一次开发,多端部署 - [前言](key-features/multi-device-app-dev/foreword.md) - [简介](key-features/multi-device-app-dev/introduction.md) @@ -329,6 +344,7 @@ - [Rawfile开发指导](napi/rawfile-guidelines.md) - [Window开发指导](napi/native-window-guidelines.md) - [使用MindSpore Lite引擎进行模型推理](napi/mindspore-lite-guidelines.md) + - [Neural Network Runtime对接AI推理框架开发指导](napi/neural-network-runtime-guidelines.md) - 工具 - [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) - 示例教程 @@ -337,6 +353,7 @@ - API参考 - [Syscap列表](reference/syscap-list.md) - 组件参考(基于ArkTS的声明式开发范式) + - [组件导读](reference/arkui-ts/ts-components-summary.md) - 组件通用信息 - 通用事件 - [点击事件](reference/arkui-ts/ts-universal-events-click.md) @@ -402,6 +419,8 @@ - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) + - [NavRouter](reference/arkui-ts/ts-basic-components-navrouter.md) + - [NavDestination](reference/arkui-ts/ts-basic-components-navdestination.md) - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) - [Progress](reference/arkui-ts/ts-basic-components-progress.md) @@ -435,6 +454,7 @@ - [ColumnSplit](reference/arkui-ts/ts-container-columnsplit.md) - [Counter](reference/arkui-ts/ts-container-counter.md) - [Flex](reference/arkui-ts/ts-container-flex.md) + - [FlowItem](reference/arkui-ts/ts-container-flowitem.md) - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) - [GridCol](reference/arkui-ts/ts-container-gridcol.md) - [GridRow](reference/arkui-ts/ts-container-gridrow.md) @@ -455,6 +475,7 @@ - [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Tabs](reference/arkui-ts/ts-container-tabs.md) - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) + - [WaterFlow](reference/arkui-ts/ts-container-waterflow.md) - 媒体组件 - [Video](reference/arkui-ts/ts-media-components-video.md) - 绘制组件 @@ -483,7 +504,6 @@ - [组件内转场](reference/arkui-ts/ts-transition-animation-component.md) - [共享元素转场](reference/arkui-ts/ts-transition-animation-shared-elements.md) - [路径动画](reference/arkui-ts/ts-motion-path-animation.md) - - 全局UI方法 - 弹窗 - [警告弹窗](reference/arkui-ts/ts-methods-alert-dialog-box.md) @@ -493,8 +513,12 @@ - [时间选择弹窗](reference/arkui-ts/ts-methods-timepicker-dialog.md) - [文本选择弹窗](reference/arkui-ts/ts-methods-textpicker-dialog.md) - [菜单](reference/arkui-ts/ts-methods-menu.md) + - [应用级变量的状态管理](reference/arkui-ts/ts-state-management.md) + - [像素单位](reference/arkui-ts/ts-pixel-units.md) - [枚举说明](reference/arkui-ts/ts-appendix-enums.md) - [类型说明](reference/arkui-ts/ts-types.md) + - 已停止维护的组件 + - [GridContainer(栅格)](reference/arkui-ts/ts-container-gridcontainer.md) - 组件参考(兼容JS的类Web开发范式) - 组件通用信息 - [通用属性](reference/arkui-js/js-components-common-attributes.md) @@ -590,12 +614,11 @@ - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) - 自定义组件 - [基本用法](reference/arkui-js/js-components-custom-basic-usage.md) + - [数据传递与处理](reference/arkui-js/js-components-custom-props.md) - [继承样式](reference/arkui-js/js-components-custom-style.md) - - [自定义事件](reference/arkui-js/js-components-custom-events.md) - - [Props](reference/arkui-js/js-components-custom-props.md) - - [事件参数](reference/arkui-js/js-components-custom-event-parameter.md) - [slot插槽](reference/arkui-js/js-components-custom-slot.md) - [生命周期定义](reference/arkui-js/js-components-custom-lifecycle.md) + - [动态创建组件](reference/arkui-js/js-components-create-elements.md) - [数据类型说明](reference/arkui-js/js-appendix-types.md) - JS服务卡片UI组件参考 - JS服务卡片UI框架说明 @@ -603,9 +626,9 @@ - 语法 - [HML语法参考](reference/js-service-widget-ui/js-service-widget-syntax-hml.md) - [CSS语法参考](reference/js-service-widget-ui/js-service-widget-syntax-css.md) - - [配置数据和事件](reference/js-service-widget-ui/js-service-widget-configuration.md) - [多语言支持](reference/js-service-widget-ui/js-service-widget-multiple-languages.md) - - [低版本兼容](reference/js-service-widget-ui/js-service-widget-version-compatibility.md) + - [版本兼容适配](reference/js-service-widget-ui/js-service-widget-version-compatibility.md) + - [设置主题样式](reference/js-service-widget-ui/js-service-widget-theme.md) - 组件 - 通用 - [通用属性](reference/js-service-widget-ui/js-service-widget-common-attributes.md) @@ -617,6 +640,7 @@ - [无障碍](reference/js-service-widget-ui/js-service-widget-common-accessibility.md) - [原子布局](reference/js-service-widget-ui/js-service-widget-common-atomic-layout.md) - 容器组件 + - [badge](reference/js-service-widget-ui/js-service-widget-container-badge.md) - [div](reference/js-service-widget-ui/js-service-widget-container-div.md) - [list](reference/js-service-widget-ui/js-service-widget-container-list.md) - [list-item](reference/js-service-widget-ui/js-service-widget-container-list-item.md) @@ -633,15 +657,13 @@ - [progress](reference/js-service-widget-ui/js-service-widget-basic-progress.md) - [span](reference/js-service-widget-ui/js-service-widget-basic-span.md) - [text](reference/js-service-widget-ui/js-service-widget-basic-text.md) - - 自定义组件 - - [自定义组件基本用法](reference/js-service-widget-ui/js-service-widget-custom-basic-usage.md) - - [自定义事件](reference/js-service-widget-ui/js-service-widget-custom-events.md) - - [Props](reference/js-service-widget-ui/js-service-widget-custom-props.md) + - [自定义组件使用说明](reference/js-service-widget-ui/js-service-widget-custom-basic-usage.md) - [数据类型说明](reference/js-service-widget-ui/js-service-widget-appendix-types.md) - 接口参考(JS及TS API) - [开发说明](reference/apis/development-intro.md) - Ability框架 - FA模型 + - [@ohos.ability.ability (Ability)](reference/apis/js-apis-ability-ability.md) - [@ohos.ability.featureAbility (FeatureAbility模块)](reference/apis/js-apis-featureAbility.md) - [@ohos.ability.particleAbility (particleAbility模块)](reference/apis/js-apis-particleAbility.md) - [dataAbilityHelper (DataAbilityHelper模块)](reference/apis/js-apis-dataAbilityHelper.md) @@ -652,6 +674,7 @@ - [@ohos.application.AbilityStage (AbilityStage)](reference/apis/js-apis-application-abilitystage.md) - [@ohos.application.abilityLifecycleCallback (AbilityLifecycleCallback)](reference/apis/js-apis-application-abilityLifecycleCallback.md) - [@ohos.application.DataShareExtensionAbility (数据共享扩展能力)](reference/apis/js-apis-application-DataShareExtensionAbility.md) + - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](reference/apis/js-apis-application-EnvironmentCallback.md) - [@ohos.application.FormExtension (FormExtension)](reference/apis/js-apis-formextension.md) - [@ohos.application.ServiceExtensionAbility (ServiceExtensionAbility)](reference/apis/js-apis-service-extension-ability.md) - [@ohos.application.StartOptions (StartOptions)](reference/apis/js-apis-application-StartOptions.md) @@ -664,19 +687,17 @@ - [ExtensionContext (ExtensionContext)](reference/apis/js-apis-extension-context.md) - [FormExtensionContext (FormExtensionContext)](reference/apis/js-apis-formextensioncontext.md) - [PermissionRequestResult (PermissionRequestResult)](reference/apis/js-apis-permissionrequestresult.md) - - [ServiceExtensionContext (ServiceExtensionContext)](reference/apis/js-apis-service-extension-context.md) + - [ServiceExtensionContext (ServiceExtensionContext)](reference/apis/js-apis-service-extension-context.md) - 通用 - [@ohos.ability.dataUriUtils (DataUriUtils模块)](reference/apis/js-apis-DataUriUtils.md) - [@ohos.ability.errorCode (ErrorCode)](reference/apis/js-apis-ability-errorCode.md) - [@ohos.ability.wantConstant (wantConstant)](reference/apis/js-apis-ability-wantConstant.md) + - [@ohos.app.ability.appRecovery (appRecovery)](reference/apis/js-apis-app-ability-appRecovery.md) - [@ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](reference/apis/js-apis-abilityDelegatorRegistry.md) - [@ohos.application.abilityManager (AbilityManager)](reference/apis/js-apis-application-abilityManager.md) - - [@ohos.application.AccessibilityExtensionAbility (AccessibilityExtensionContext)](reference/apis/js-apis-accessibility-extension-context.md) - - [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](reference/apis/js-apis-application-AccessibilityExtensionAbility.md) - [@ohos.application.appManager (appManager)](reference/apis/js-apis-appmanager.md) - - [@ohos.application.Configuration (Configuration)](reference/apis/js-apis-configuration.md) - - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](reference/apis/js-apis-configurationconstant.md) - - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](reference/apis/js-apis-application-EnvironmentCallback.md) + - [@ohos.application.Configuration (Configuration)](reference/apis/js-apis-application-configuration.md) + - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](reference/apis/js-apis-application-configurationConstant.md) - [@ohos.application.errorManager (ErrorManager)](reference/apis/js-apis-errorManager.md) - [@ohos.application.formBindingData (卡片数据绑定类)](reference/apis/js-apis-formbindingdata.md) - [@ohos.application.formError (FormError)](reference/apis/js-apis-formerror.md) @@ -686,55 +707,55 @@ - [@ohos.application.missionManager (missionManager)](reference/apis/js-apis-missionManager.md) - [@ohos.application.quickFixManager (quickFixManager)](reference/apis/js-apis-application-quickFixManager.md) - [@ohos.application.Want (Want)](reference/apis/js-apis-application-Want.md) - - [@ohos.continuation.continuationManager (ContinuationExtraParams)](reference/apis/js-apis-continuation-continuationExtraParams.md) - [@ohos.continuation.continuationManager (continuationManager)](reference/apis/js-apis-continuation-continuationManager.md) - [@ohos.wantAgent (WantAgent模块)](reference/apis/js-apis-wantAgent.md) + - [abilityResult (AbilityResult)](reference/apis/js-apis-ability-abilityResult.md) + - [Want (Want)](reference/apis/js-apis-ability-Want.md) - [abilityDelegator (AbilityDelegator)](reference/apis/js-apis-application-abilityDelegator.md) - [abilityDelegatorArgs (AbilityDelegatorArgs)](reference/apis/js-apis-application-abilityDelegatorArgs.md) - [abilityMonitor (AbilityMonitor)](reference/apis/js-apis-application-abilityMonitor.md) - [AbilityRunningInfo (AbilityRunningInfo)](reference/apis/js-apis-abilityrunninginfo.md) - [ExtensionRunningInfo (ExtensionRunningInfo)](reference/apis/js-apis-extensionrunninginfo.md) - [MissionSnapshot (MissionSnapshot)](reference/apis/js-apis-application-MissionSnapshot.md) - - [ProcessRunningInfo (ProcessRunningInfo)](reference/apis/js-apis-processrunninginfo.md) - [ProcessRunningInformation (ProcessRunningInformation)](reference/apis/js-apis-processrunninginformation.md) - [shellCmdResult (ShellCmdResult)](reference/apis/js-apis-application-shellCmdResult.md) - - continuation/[ContinuationResult (ContinuationResult)](reference/apis/js-apis-continuation-continuationResult.md) + - [continuationExtraParams (ContinuationExtraParams)](reference/apis/js-apis-continuation-continuationExtraParams.md) + - [continuationResult (ContinuationResult)](reference/apis/js-apis-continuation-continuationResult.md) - 公共事件与通知 - - [@ohos.commonEvent (公共事件模块)](reference/apis/js-apis-commonEvent.md) + - [@ohos.commonEventManager (公共事件模块)](reference/apis/js-apis-commonEventManager.md) - [@ohos.events.emitter (Emitter)](reference/apis/js-apis-emitter.md) - [@ohos.notification (Notification模块)](reference/apis/js-apis-notification.md) - - [@ohos.reminderAgent (后台代理提醒)](reference/apis/js-apis-reminderAgent.md) - [EventHub (EventHub)](reference/apis/js-apis-eventhub.md) - - 应用程序包管理 - - [@ohos.bundle (Bundle模块)](reference/apis/js-apis-Bundle.md) - - [@ohos.bundle.defaultAppManager (Bundle模块)](reference/apis/js-apis-bundle-defaultAppManager.md) - - [@ohos.bundle.innerBundleManager (innerBundleManager模块(JS端SDK接口))](reference/apis/js-apis-Bundle-InnerBundleManager.md) - - [@ohos.bundleState (设备使用信息统计)](reference/apis/js-apis-deviceUsageStatistics.md) - - [@ohos.distributedBundle (distributedBundle模块(JS端SDK接口))](reference/apis/js-apis-Bundle-distributedBundle.md) + - 包管理 + - [@ohos.bundle.appControl(appControl模块)](reference/apis/js-apis-appControl.md) + - [@ohos.bundle.bundleManager (bundleManager模块)](reference/apis/js-apis-bundleManager.md) + - [@ohos.bundle.bundleMonitor (bundleMonitor模块)](reference/apis/js-apis-bundleMonitor.md) + - [@ohos.bundle.defaultAppManager (默认应用管理)](reference/apis/js-apis-defaultAppManager.md) + - [@ohos.bundle.distributedBundle (distributedBundle模块)](reference/apis/js-apis-distributedBundle.md) + - [@ohos.bundle.freeInstall (freeInstall模块)](reference/apis/js-apis-freeInstall.md) + - [@ohos.bundle.installer (installer模块)](reference/apis/js-apis-installer.md) + - [@ohos.bundle.launcherBundleManager (launcherBundleManager模块)](reference/apis/js-apis-launcherBundleManager.md) - [@ohos.zlib (Zip模块)](reference/apis/js-apis-zlib.md) - - [AbilityInfo (AbilityInfo)](reference/apis/js-apis-bundle-AbilityInfo.md) - - [ApplicationInfo (ApplicationInfo)](reference/apis/js-apis-bundle-ApplicationInfo.md) - - [BundleInfo (BundleInfo)](reference/apis/js-apis-bundle-BundleInfo.md) - - [BundleInstaller (BundleInstaller)](reference/apis/js-apis-bundle-BundleInstaller.md) - - [BundleStatusCallback (BundleStatusCallback)](reference/apis/js-apis-Bundle-BundleStatusCallback.md) - - [CustomizeData (CustomizeData)](reference/apis/js-apis-bundle-CustomizeData.md) - - [DispatchInfo (DispatchInfo)](reference/apis/js-apis-dispatchInfo.md) - - [ElementName (ElementName)](reference/apis/js-apis-bundle-ElementName.md) - - [ExtensionAbilityInfo (ExtensionAbilityInfo)](reference/apis/js-apis-bundle-ExtensionAbilityInfo.md) - - [HapModuleInfo (HapModuleInfo)](reference/apis/js-apis-bundle-HapModuleInfo.md) - - [LauncherAbilityInfo (LauncherAbilityInfo)](reference/apis/js-apis-bundle-LauncherAbilityInfo.md) - - [Metadata (Metadata)](reference/apis/js-apis-bundle-Metadata.md) - - [ModuleInfo (ModuleInfo)](reference/apis/js-apis-bundle-ModuleInfo.md) - - [PackInfo (PackInfo)](reference/apis/js-apis-bundle-PackInfo.md) - - [PermissionDef (PermissionDef)](reference/apis/js-apis-bundle-PermissionDef.md) - - [RemoteAbilityInfo (RemoteAbilityInfo)](reference/apis/js-apis-bundle-remoteAbilityInfo.md) - - [ShortcutInfo (ShortcutInfo)](reference/apis/js-apis-bundle-ShortcutInfo.md) + - [abilityInfo (AbilityInfo)](reference/apis/js-apis-bundleManager-abilityInfo.md) + - [applicationInfo (ApplicationInfo)](reference/apis/js-apis-bundleManager-applicationInfo.md) + - [bundleInfo (BundleInfo)](reference/apis/js-apis-bundleManager-bundleInfo.md) + - [dispatchInfo (DispatchInfo)](reference/apis/js-apis-bundleManager-dispatchInfo.md) + - [elementName (ElementName)](reference/apis/js-apis-bundleManager-elementName.md) + - [extensionAbilityInfo (ExtensionAbilityInfo)](reference/apis/js-apis-bundleManager-extensionAbilityInfo.md) + - [hapModuleInfo (HapModuleInfo)](reference/apis/js-apis-bundleManager-hapModuleInfo.md) + - [launcherAbilityInfo (LauncherAbilityInfo)](reference/apis/js-apis-bundleManager-launcherAbilityInfo.md) + - [metadata (Metadata)](reference/apis/js-apis-bundleManager-metadata.md) + - [packInfo (PackInfo)](reference/apis/js-apis-bundleManager-packInfo.md) + - [permissionDef (PermissionDef)](reference/apis/js-apis-bundleManager-permissionDef.md) + - [remoteAbilityInfo (RemoteAbilityInfo)](reference/apis/js-apis-bundleManager-remoteAbilityInfo.md) + - [shortcutInfo (ShortcutInfo)](reference/apis/js-apis-bundleManager-shortcutInfo.md) - UI界面 - [@ohos.animator (动画)](reference/apis/js-apis-animator.md) + - [@ohos.curves (插值计算)](reference/apis/js-apis-curve.md) + - [@ohos.matrix4 (矩阵变换)](reference/apis/js-apis-matrix4.md) - [@ohos.mediaquery (媒体查询)](reference/apis/js-apis-mediaquery.md) - - [@ohos.prompt (弹窗)](reference/apis/js-apis-prompt.md) + - [@ohos.promptAction (弹窗)](reference/apis/js-apis-promptAction.md) - [@ohos.router (页面路由)](reference/apis/js-apis-router.md) - - [@ohos.uiAppearance(用户界面外观)](reference/apis/js-apis-uiappearance.md) - 图形图像 - [@ohos.animation.windowAnimationManager (窗口动画管理)](reference/apis/js-apis-windowAnimationManager.md) - [@ohos.display (屏幕属性)](reference/apis/js-apis-display.md) @@ -747,6 +768,7 @@ - [webgl2 (WebGL2)](reference/apis/js-apis-webgl2.md) - 媒体 - [@ohos.multimedia.audio (音频管理)](reference/apis/js-apis-audio.md) + - [@ohos.multimedia.avsession (媒体会话管理)](reference/apis/js-apis-avsession.md) - [@ohos.multimedia.camera (相机管理)](reference/apis/js-apis-camera.md) - [@ohos.multimedia.image (图片处理)](reference/apis/js-apis-image.md) - [@ohos.multimedia.media (媒体服务)](reference/apis/js-apis-media.md) @@ -755,19 +777,16 @@ - [@ohos.intl (国际化-Intl)](reference/apis/js-apis-intl.md) - [@ohos.resourceManager (资源管理)](reference/apis/js-apis-resource-manager.md) - 资源调度 - - [@ohos.backgroundTaskManager (后台任务管理)](reference/apis/js-apis-backgroundTaskManager.md) - [@ohos.distributedMissionManager (分布式任务管理)](reference/apis/js-apis-distributedMissionManager.md) - - [@ohos.workScheduler (延迟任务调度)](reference/apis/js-apis-workScheduler.md) + - [@ohos.reminderAgentManager (后台代理提醒)](reference/apis/js-apis-reminderAgentManager.md) + - [@ohos.resourceschedule.backgroundTaskManager (后台任务管理)](reference/apis/js-apis-resourceschedule-backgroundTaskManager.md) + - [@ohos.resourceschedule.workScheduler (延迟任务调度)](reference/apis/js-apis-resourceschedule-workScheduler.md) + - [@ohos.resourceschedule.usageStatistics (设备使用信息统计)](reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md) - [@ohos.WorkSchedulerExtensionAbility (延迟任务调度回调)](reference/apis/js-apis-WorkSchedulerExtensionAbility.md) - - 定制管理 - - [@ohos.configPolicy (配置策略)](reference/apis/js-apis-config-policy.md) - - [@ohos.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](reference/apis/js-apis-EnterpriseAdminExtensionAbility.md) - - [@ohos.enterpriseDeviceManager (企业设备管理)](reference/apis/js-apis-enterprise-device-manager.md) - - [DeviceSettingsManager(设备设置管理)](reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md) - 安全 - - [@ohos.abilityAccessCtrl (访问控制管理)](reference/apis/js-apis-abilityAccessCtrl.md) + - [@ohos.abilityAccessCtrl (程序访问控制管理)](reference/apis/js-apis-abilityAccessCtrl.md) - [@ohos.privacyManager (隐私管理)](reference/apis/js-apis-privacyManager.md) - - [@ohos.security.cryptoFramework (加密算法库框架)](reference/apis/js-apis-cryptoFramework.md) + - [@ohos.security.cryptoFramework (加解密算法库框架)](reference/apis/js-apis-cryptoFramework.md) - [@ohos.security.huks (通用密钥库系统)](reference/apis/js-apis-huks.md) - [@ohos.userIAM.faceAuth (人脸认证)](reference/apis/js-apis-useriam-faceauth.md) - [@ohos.userIAM.userAuth (用户认证)](reference/apis/js-apis-useriam-userauth.md) @@ -777,19 +796,18 @@ - [@ohos.data.dataShare (数据共享)](reference/apis/js-apis-data-dataShare.md) - [@ohos.data.dataSharePredicates (数据共享谓词)](reference/apis/js-apis-data-dataSharePredicates.md) - [@ohos.data.dataShareResultSet (数据共享结果集)](reference/apis/js-apis-data-DataShareResultSet.md) - - [@ohos.data.distributedData (分布式数据管理)](reference/apis/js-apis-distributed-data.md) - [@ohos.data.distributedDataObject (分布式数据对象)](reference/apis/js-apis-data-distributedobject.md) + - [@ohos.data.distributedKVStore (分布式键值数据库)](reference/apis/js-apis-distributedKVStore.md) - [@ohos.data.preferences (首选项)](reference/apis/js-apis-data-preferences.md) - [@ohos.data.rdb (关系型数据库)](reference/apis/js-apis-data-rdb.md) - [@ohos.data.ValuesBucket (数据集)](reference/apis/js-apis-data-ValuesBucket.md) - [resultSet (结果集)](reference/apis/js-apis-data-resultset.md) - 文件管理 - - [@ohos.data.fileAccess (公共文件访问与管理)](reference/apis/js-apis-fileAccess.md) - - [@ohos.document (文件交互)](reference/apis/js-apis-document.md) - [@ohos.environment (目录环境能力)](reference/apis/js-apis-environment.md) + - [@ohos.data.fileAccess (公共文件访问与管理)](reference/apis/js-apis-fileAccess.md) - [@ohos.fileExtensionInfo (公共文件访问与管理属性信息)](reference/apis/js-apis-fileExtensionInfo.md) - [@ohos.fileio (文件管理)](reference/apis/js-apis-fileio.md) - - [@ohos.filemanagement.userfile_manager (用户数据管理)](reference/apis/js-apis-userfilemanager.md) + - [@ohos.filemanagement.userFileManager (用户数据管理)](reference/apis/js-apis-userFileManager.md) - [@ohos.multimedia.medialibrary (媒体库管理)](reference/apis/js-apis-medialibrary.md) - [@ohos.securityLabel (数据标签)](reference/apis/js-apis-securityLabel.md) - [@ohos.statfs (statfs)](reference/apis/js-apis-statfs.md) @@ -807,11 +825,8 @@ - [@ohos.net.connection (网络连接管理)](reference/apis/js-apis-net-connection.md) - [@ohos.net.ethernet (以太网连接管理)](reference/apis/js-apis-net-ethernet.md) - [@ohos.net.http (数据请求)](reference/apis/js-apis-http.md) - - [@ohos.net.policy (网络策略管理)](reference/apis/js-apis-net-policy.md) - [@ohos.net.sharing (网络共享管理)](reference/apis/js-apis-net-sharing.md) - [@ohos.net.socket (Socket连接)](reference/apis/js-apis-socket.md) - - [@ohos.net.statistics (网络流量管理)](reference/apis/js-apis-net-statistics.md) - - [@ohos.net.tlsSocket (TLSSocket连接)](reference/apis/js-apis-tlsSocket.md) - [@ohos.net.webSocket (WebSocket连接)](reference/apis/js-apis-webSocket.md) - [@ohos.request (上传下载)](reference/apis/js-apis-request.md) - 通信与连接 @@ -822,40 +837,49 @@ - [@ohos.nfc.tag (标准NFC-Tag)](reference/apis/js-apis-nfcTag.md) - [@ohos.rpc (RPC通信)](reference/apis/js-apis-rpc.md) - [@ohos.wifi (WLAN)](reference/apis/js-apis-wifi.md) - - [@ohos.wifiext (WLAN)](reference/apis/js-apis-wifiext.md) + - [@ohos.wifiext (WLAN扩展接口)](reference/apis/js-apis-wifiext.md) - [nfctech (标准NFC-Tag Nfc 技术)](reference/apis/js-apis-nfctech.md) - [tagSession (标准NFC-Tag TagSession)](reference/apis/js-apis-tagSession.md) - 系统基础能力 - [@ohos.accessibility (辅助功能)](reference/apis/js-apis-accessibility.md) - [@ohos.accessibility.config (系统辅助功能配置)](reference/apis/js-apis-accessibility-config.md) + - [@ohos.accessibility.GesturePath (手势路径)](reference/apis/js-apis-accessibility-GesturePath.md) + - [@ohos.accessibility.GesturePoint (手势触摸点)](reference/apis/js-apis-accessibility-GesturePoint.md) + - [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](reference/apis/js-apis-application-AccessibilityExtensionAbility.md) - [@ohos.faultLogger (故障日志获取)](reference/apis/js-apis-faultLogger.md) - - [@ohos.hiAppEvent (应用打点)](reference/apis/js-apis-hiappevent.md) - [@ohos.hichecker (检测模式)](reference/apis/js-apis-hichecker.md) - [@ohos.hidebug (Debug调试)](reference/apis/js-apis-hidebug.md) - - [@ohos.hilog (日志打印)](reference/apis/js-apis-hilog.md) + - [@ohos.hilog (HiLog日志打印)](reference/apis/js-apis-hilog.md) - [@ohos.hiSysEvent (系统事件打点)](reference/apis/js-apis-hisysevent.md) - [@ohos.hiTraceChain (分布式跟踪)](reference/apis/js-apis-hitracechain.md) - [@ohos.hiTraceMeter (性能打点)](reference/apis/js-apis-hitracemeter.md) + - [@ohos.hiviewdfx.hiAppEvent (应用事件打点)](reference/apis/js-apis-hiviewdfx-hiappevent.md) - [@ohos.inputmethod (输入法框架)](reference/apis/js-apis-inputmethod.md) - [@ohos.inputmethodengine (输入法服务)](reference/apis/js-apis-inputmethodengine.md) - [@ohos.inputmethodextensionability (InputMethodExtensionAbility)](reference/apis/js-apis-inputmethod-extension-ability.md) - [@ohos.inputmethodextensioncontext (InputMethodExtensionContext)](reference/apis/js-apis-inputmethod-extension-context.md) + - [@ohos.inputmethodsubtype(输入法子类型)](reference/apis/js-apis-inputmethod-subtype.md) - [@ohos.pasteboard (剪贴板)](reference/apis/js-apis-pasteboard.md) - [@ohos.screenLock (锁屏管理)](reference/apis/js-apis-screen-lock.md) - [@ohos.systemTime (系统时间、时区)](reference/apis/js-apis-system-time.md) - [@ohos.systemTimer(系统定时器)](reference/apis/js-apis-system-timer.md) - [@ohos.wallpaper (壁纸)](reference/apis/js-apis-wallpaper.md) + - [@ohos.web.webview(Web)](reference/apis/js-apis-webview.md) + - [console (日志打印)](reference/apis/js-apis-logs.md) - [Timer (定时器)](reference/apis/js-apis-timer.md) + - [AccessibilityExtensionContext (辅助功能扩展上下文)](reference/apis/js-apis-accessibility-extension-context.md) - 设备管理 - [@ohos.batteryInfo (电量信息)](reference/apis/js-apis-battery-info.md) + - [@ohos.batteryStatistics (耗电统计)](reference/apis/js-apis-batteryStatistics.md) - [@ohos.brightness (屏幕亮度)](reference/apis/js-apis-brightness.md) - [@ohos.deviceInfo (设备信息)](reference/apis/js-apis-device-info.md) - [@ohos.distributedHardware.deviceManager (设备管理)](reference/apis/js-apis-device-manager.md) - - [@ohos.geolocation (位置服务)](reference/apis/js-apis-geolocation.md) + - [@ohos.geoLocationManager (位置服务)](reference/apis/js-apis-geoLocationManager.md) - [@ohos.multimodalInput.inputConsumer (组合按键)](reference/apis/js-apis-inputconsumer.md) - [@ohos.multimodalInput.inputDevice (输入设备)](reference/apis/js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputDeviceCooperate (键鼠穿越)](reference/apis/js-apis-cooperate.md) - [@ohos.multimodalInput.inputEvent (输入事件)](reference/apis/js-apis-inputevent.md) - - [@ohos.multimodalInput.inputEventClient (注入按键)](reference/apis/js-apis-inputeventclient.md) + - [@ohos.multimodalInput.inputEventClient (按键注入)](reference/apis/js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputMonitor (输入监听)](reference/apis/js-apis-inputmonitor.md) - [@ohos.multimodalInput.keyCode (键值)](reference/apis/js-apis-keycode.md) - [@ohos.multimodalInput.keyEvent (按键输入事件)](reference/apis/js-apis-keyevent.md) @@ -866,15 +890,21 @@ - [@ohos.runningLock (Runninglock锁)](reference/apis/js-apis-runninglock.md) - [@ohos.sensor (传感器)](reference/apis/js-apis-sensor.md) - [@ohos.settings (设置数据项名称)](reference/apis/js-apis-settings.md) - - [@ohos.systemParameter (系统属性)](reference/apis/js-apis-system-parameter.md) + - [@ohos.systemCapability (系统能力)](reference/apis/js-apis-system-capability.md) + - [@ohos.systemParameterV9 (系统属性)](reference/apis/js-apis-system-parameterV9.md) - [@ohos.thermal (热管理)](reference/apis/js-apis-thermal.md) - [@ohos.update (升级)](reference/apis/js-apis-update.md) - - [@ohos.usb (USB管理)](reference/apis/js-apis-usb.md) + - [@ohos.usbV9 (USB管理)](reference/apis/js-apis-usb.md) - [@ohos.vibrator (振动)](reference/apis/js-apis-vibrator.md) - 帐号管理 - [@ohos.account.appAccount (应用帐号管理)](reference/apis/js-apis-appAccount.md) - [@ohos.account.distributedAccount (分布式帐号管理)](reference/apis/js-apis-distributed-account.md) - [@ohos.account.osAccount (系统帐号管理)](reference/apis/js-apis-osAccount.md) + - 定制管理 + - [@ohos.configPolicy (配置策略)](reference/apis/js-apis-configPolicy.md) + - [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](reference/apis/js-apis-EnterpriseAdminExtensionAbility.md) + - [@ohos.enterprise.adminManager (企业设备管理)](reference/apis/js-apis-enterprise-adminManager.md) + - [@ohos.enterprise.dateTimeManager(系统时间管理)](reference/apis/js-apis-enterprise-dateTimeManager.md) - 语言基础类库 - [@ohos.buffer (Buffer)](reference/apis/js-apis-buffer.md) - [@ohos.convertxml (xml转换JavaScript)](reference/apis/js-apis-convertxml.md) @@ -902,8 +932,22 @@ - [@ohos.application.testRunner (TestRunner)](reference/apis/js-apis-testRunner.md) - [@ohos.uitest (UiTest)](reference/apis/js-apis-uitest.md) - 已停止维护的接口 + - [@ohos.backgroundTaskManager (后台任务管理)](reference/apis/js-apis-backgroundTaskManager.md) + - [@ohos.bundle (Bundle模块)](reference/apis/js-apis-Bundle.md) + - [@ohos.bundle.innerBundleManager (innerBundleManager模块)](reference/apis/js-apis-Bundle-InnerBundleManager.md) + - [@ohos.bundleState (设备使用信息统计)](reference/apis/js-apis-deviceUsageStatistics.md) - [@ohos.bytrace (性能打点)](reference/apis/js-apis-bytrace.md) + - [@ohos.commonEvent (公共事件模块)](reference/apis/js-apis-commonEvent.md) - [@ohos.data.storage (轻量级存储)](reference/apis/js-apis-data-storage.md) + - [@ohos.data.distributedData (分布式数据管理)](reference/apis/js-apis-distributed-data.md) + - [@ohos.distributedBundle (分布式包管理)](reference/apis/js-apis-Bundle-distributedBundle.md) + - [@ohos.document (文件交互)](reference/apis/js-apis-document.md) + - [@ohos.geolocation (位置服务)](reference/apis/js-apis-geolocation.md) + - [@ohos.hiAppEvent (应用打点)](reference/apis/js-apis-hiappevent.md) + - [@ohos.prompt (弹窗)](reference/apis/js-apis-prompt.md) + - [@ohos.reminderAgent (后台代理提醒)](reference/apis/js-apis-reminderAgent.md) + - [@ohos.systemParameter (系统属性)](reference/apis/js-apis-system-parameter.md) + - [@ohos.usb (USB管理)](reference/apis/js-apis-usb-deprecated.md) - [@system.app (应用上下文)](reference/apis/js-apis-system-app.md) - [@system.battery (电量信息)](reference/apis/js-apis-system-battery.md) - [@system.bluetooth (蓝牙)](reference/apis/js-apis-system-bluetooth.md) @@ -923,8 +967,100 @@ - [@system.sensor (传感器)](reference/apis/js-apis-system-sensor.md) - [@system.storage (数据存储)](reference/apis/js-apis-system-storage.md) - [@system.vibrator (振动)](reference/apis/js-apis-system-vibrate.md) - - [console (日志打印)](reference/apis/js-apis-logs.md) - + - [ProcessRunningInfo (ProcessRunningInfo)](reference/apis/js-apis-processrunninginfo.md) + - [abilityInfo (AbilityInfo)](reference/apis/js-apis-bundle-AbilityInfo.md) + - [applicationInfo (ApplicationInfo)](reference/apis/js-apis-bundle-ApplicationInfo.md) + - [bundleInfo (BundleInfo)](reference/apis/js-apis-bundle-BundleInfo.md) + - [bundleInstaller (BundleInstaller)](reference/apis/js-apis-bundle-BundleInstaller.md) + - [bundleStatusCallback (BundleStatusCallback)](reference/apis/js-apis-Bundle-BundleStatusCallback.md) + - [customizeData (CustomizeData)](reference/apis/js-apis-bundle-CustomizeData.md) + - [elementName (ElementName)](reference/apis/js-apis-bundle-ElementName.md) + - [hapModuleInfo (HapModuleInfo)](reference/apis/js-apis-bundle-HapModuleInfo.md) + - [launcherAbilityInfo (LauncherAbilityInfo)](reference/apis/js-apis-bundle-LauncherAbilityInfo.md) + - [moduleInfo (ModuleInfo)](reference/apis/js-apis-bundle-ModuleInfo.md) + - [PermissionDef (PermissionDef)](reference/apis/js-apis-bundle-PermissionDef.md) + - [remoteAbilityInfo (RemoteAbilityInfo)](reference/apis/js-apis-bundle-remoteAbilityInfo.md) + - [shortcutInfo (shortcutInfo)](reference/apis/js-apis-bundle-ShortcutInfo.md) + - 错误码参考 + - [通用错误码](reference/errorcodes/errorcode-universal.md) + - Ability框架 + - [元能力子系统错误码](reference/errorcodes/errorcode-ability.md) + - [DistributedSchedule错误码](reference/errorcodes/errorcode-DistributedSchedule.md) + - 包管理 + - [包管理子系统通用错误码](reference/errorcodes/errorcode-bundle.md) + - [zlib子系统错误码](reference/errorcodes/errorcode-zlib.md) + - 公共事件与通知 + - [事件错误码](reference/errorcodes/errorcode-CommonEventService.md) + - [DistributedNotificationService错误码](reference/errorcodes/errorcode-DistributedNotificationService.md) + - UI界面 + - [动画错误码](reference/errorcodes/errorcode-animator.md) + - [弹窗错误码](reference/errorcodes/errorcode-promptAction.md) + - [页面路由错误码](reference/errorcodes/errorcode-router.md) + - 图形图像 + - [色彩管理错误码](reference/errorcodes/errorcode-colorspace-manager.md) + - [屏幕错误码](reference/errorcodes/errorcode-display.md) + - [窗口错误码](reference/errorcodes/errorcode-window.md) + - 媒体 + - [Audio错误码](reference/errorcodes/errorcode-audio.md) + - [媒体会话管理错误码](reference/errorcodes/errorcode-avsession.md) + - 资源管理 + - [I18n错误码](reference/errorcodes/errorcode-i18n.md) + - [资源管理错误码](reference/errorcodes/errorcode-resource-manager.md) + - 资源调度 + - [backgroundTaskManager错误码](reference/errorcodes/errorcode-backgroundTaskMgr.md) + - [DeviceUsageStatistics错误码](reference/errorcodes/errorcode-DeviceUsageStatistics.md) + - [reminderAgentManager错误码](reference/errorcodes/errorcode-reminderAgentManager.md) + - [workScheduler错误码](reference/errorcodes/errorcode-workScheduler.md) + - 安全 + - [AccessToken错误码](reference/errorcodes/errorcode-access-token.md) + - [HUKS错误码](reference/errorcodes/errorcode-huks.md) + - [用户认证错误码](reference/errorcodes/errorcode-useriam.md) + - 数据管理 + - [关系型数据库错误码](reference/errorcodes/errorcode-data-rdb.md) + - [数据共享错误码](reference/errorcodes/errorcode-datashare.md) + - [分布式数据对象错误码](reference/errorcodes/errorcode-distributed-dataObject.md) + - [分布式键值数据库错误码](reference/errorcodes/errorcode-distributedKVStore.md) + - [首选项错误码](reference/errorcodes/errorcode-preferences.md) + - 文件管理 + - [文件管理子系统错误码](reference/errorcodes/errorcode-filemanagement.md) + - 网络管理 + - [上传下载错误码](reference/errorcodes/errorcode-request.md) + - 通信与连接 + - [NFC错误码](reference/errorcodes/errorcode-nfc.md) + - [RPC错误码](reference/errorcodes/errorcode-rpc.md) + - 系统基础能力 + - [无障碍子系统错误码](reference/errorcodes/errorcode-accessibility.md) + - [Faultlogger错误码](reference/errorcodes/errorcode-faultlogger.md) + - [应用事件打点错误码](reference/errorcodes/errorcode-hiappevent.md) + - [系统事件错误码](reference/errorcodes/errorcode-hisysevent.md) + - [Hidebug错误码](reference/errorcodes/errorcode-hiviewdfx-hidebug.md) + - [输入法框架错误码](reference/errorcodes/errorcode-inputmethod-framework.md) + - [剪贴板错误码](reference/errorcodes/errorcode-pasteboard.md) + - [Webview错误码](reference/errorcodes/errorcode-webview.md) + - 帐号管理 + - [Account错误码](reference/errorcodes/errorcode-account.md) + - [应用帐号错误码](reference/errorcodes/errorcode-app-account.md) + - 设备管理 + - [耗电统计错误码](reference/errorcodes/errorcode-batteryStatistics.md) + - [屏幕亮度错误码](reference/errorcodes/errorcode-brightness.md) + - [系统电源管理错误码](reference/errorcodes/errorcode-power.md) + - [RunningLock锁错误码](reference/errorcodes/errorcode-runninglock.md) + - [热管理错误码](reference/errorcodes/errorcode-thermal.md) + - [设备管理错误码](reference/errorcodes/errorcode-device-manager.md) + - [位置服务子系统错误码](reference/errorcodes/errorcode-geoLocationManager.md) + - [键鼠穿越管理错误码](reference/errorcodes/errorcode-multimodalinput.md) + - [传感器错误码](reference/errorcodes/errorcode-sensor.md) + - [振动错误码](reference/errorcodes/errorcode-vibrator.md) + - [系统参数错误码](reference/errorcodes/errorcode-system-parameterV9.md) + - [USB服务错误码](reference/errorcodes/errorcode-usb.md) + - [升级错误码](reference/errorcodes/errorcode-update.md) + - 定制管理 + - [企业设备管理错误码](reference/errorcodes/errorcode-enterpriseDeviceManager.md) + - 语言基础类库 + - [buffer错误码](reference/errorcodes/errorcode-buffer.md) + - [containers错误码](reference/errorcodes/errorcode-containers.md) + - 测试 + - [uitest错误码](reference/errorcodes/errorcode-uitest.md) - 接口参考(Native API) - 模块 - [Native XComponent](reference/native-apis/_o_h___native_x_component.md) @@ -937,6 +1073,7 @@ - [Image](reference/native-apis/image.md) - [Rawfile](reference/native-apis/rawfile.md) - [MindSpore](reference/native-apis/_mind_spore.md) + - [NeuralNeworkRuntime](reference/native-apis/_neural_nework_runtime.md) - 头文件 - [drawing_bitmap.h](reference/native-apis/drawing__bitmap_8h.md) - [drawing_brush.h](reference/native-apis/drawing__brush_8h.md) @@ -965,6 +1102,8 @@ - [status.h](reference/native-apis/status_8h.md) - [tensor.h](reference/native-apis/tensor_8h.md) - [types.h](reference/native-apis/types_8h.md) + - [neural_network_runtime_type.h](reference/native-apis/neural__network__runtime__type_8h.md) + - [neural_network_runtime.h](reference/native-apis/neural__network__runtime_8h.md) - 结构体 - [OH_Drawing_BitmapFormat](reference/native-apis/_o_h___drawing___bitmap_format.md) - [OH_NativeBuffer_Config](reference/native-apis/_o_h___native_buffer___config.md) @@ -982,6 +1121,10 @@ - [OH_AI_CallBackParam](reference/native-apis/_o_h___a_i___call_back_param.md) - [OH_AI_ShapeInfo](reference/native-apis/_o_h___a_i___shape_info.md) - [OH_AI_TensorHandleArray](reference/native-apis/_o_h___a_i___tensor_handle_array.md) + - [OH_NN_Memory](reference/native-apis/_o_h___n_n___memory.md) + - [OH_NN_QuantParam](reference/native-apis/_o_h___n_n___quant_param.md) + - [OH_NN_Tensor](reference/native-apis/_o_h___n_n___tensor.md) + - [OH_NN_UInt32Array](reference/native-apis/_o_h___n_n___u_int32_array.md) - 标准库 - [Node_API](reference/native-lib/third_party_napi/napi.md) - [libuv](reference/native-lib/third_party_libuv/libuv.md) @@ -992,14 +1135,21 @@ - [Native api中导出的OpenGL ES 3.0符号列表](reference/native-lib/third_party_opengl/openglesv3-symbol.md) - 常见问题 - [full-SDK替换指南](quick-start/full-sdk-switch-guide.md) + - [开发语言常见问题](faqs/faqs-language.md) - [Ability框架开发常见问题](faqs/faqs-ability.md) + - [应用程序包管理开发常见问题](faqs/faqs-bundle.md) + - [ArkUI组件(ArkTS)开发常见问题](faqs/faqs-ui-ets.md) + - [ArkUI Web组件(ArkTS)开发常见问题](faqs/faqs-web-arkts.md) - [UI框架(JS)开发常见问题](faqs/faqs-ui-js.md) - - [UI框架(ArkTS)开发常见问题](faqs/faqs-ui-ets.md) + - [公共事件与通知开发常见问题](faqs/faqs-event-notification.md) - [图形图像开发常见问题](faqs/faqs-graphics.md) - [文件管理开发常见问题](faqs/faqs-file-management.md) + - [媒体开发常见问题](faqs/faqs-media.md) - [网络与连接开发常见问题](faqs/faqs-connectivity.md) - [数据管理开发常见问题](faqs/faqs-data-management.md) - [设备管理开发常见问题](faqs/faqs-device-management.md) + - [DFX开发常见问题](faqs/faqs-dfx.md) + - [国际化开发常见问题](faqs/faqs-international.md) - [Native API使用常见问题](faqs/faqs-native.md) - [三四方库使用常见问题](faqs/faqs-third-party-library.md) - [IDE使用常见问题](faqs/faqs-ide.md) diff --git a/zh-cn/contribute/OpenHarmony-security-test-guide.md b/zh-cn/contribute/OpenHarmony-security-test-guide.md index 2ef9bd4f8bbce5ab95a5100098077b68b16ef5c8..baea8ed9d108a6a673813a8260aa2d418f052a96 100644 --- a/zh-cn/contribute/OpenHarmony-security-test-guide.md +++ b/zh-cn/contribute/OpenHarmony-security-test-guide.md @@ -1,27 +1,41 @@ -# OpenHarmony安全测试规范 +# OpenHarmony安全测试规范 + 本文档主要参考业界安全测试标准和最佳实践,提供OpenHarmony安全测试规范,用于指导开发人员/测试人员进行安全测试。 +## 1 安全测试内容 + +1、各模块依据[OpenHarmony C&C++安全编程指南](OpenHarmony-c-cpp-secure-coding-guide.md),进行代码安全检视,检视问题均需要修复。 + +2、通过OpenHarmony代码门禁安全扫描工具测试,扫描告警结果清零。 + +3、依据[OpenHarmony编译规范](https://gitee.com/openharmony/community/blob/master/sig/sig-buildsystem/编译规范.md),使用编译选项扫描工具检查二进制文件编译选项开启情况,二进制文件编译选项均需要符合规范要求。 + +4、针对接收并处理用户态参数模块,开发人员需依据[Fuzz测试框架](https://gitee.com/openharmony/test_developertest/tree/master/libs/fuzzlib)开发灰白盒Fuzz测试套,并完成灰白盒Fuzz测试验证。 +5、针对开源组件使用业界漏洞扫描工具扫描,开源组件漏洞均已按照社区漏洞管理流程修复。 -## 安全编码测试 +6、针对发布版本进行一致性验证,在[版本发布网站](../release-notes/Readme.md)中检查版本镜像是否提供SAH256校验码。 -1、各模块依据[OpenHarmony安全编码规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md),进行代码安全检视。 +7、各模块依据[OpenHarmony安全设计规范](OpenHarmony-security-design-guide.md),结合业务完成安全设计自检验证,自检设计问题均需要修复。 -2、使用安全编码扫描工具扫描测试,扫描告警结果清零。OpenHarmony代码门禁已集成安全编码扫描工具。 +8、使用主流病毒扫描软件扫描软件包,病毒扫描结果均修复或确认为工具误报。 +9、在代码中搜索“.cer”、“.pem”等证书秘钥格式或者“PRIVATE KEY”等证书秘钥证书关键词找到证书秘钥,检查证书秘钥是否在有效期内,加密算法是否符合[加密算法要求](OpenHarmony-security-design-guide.md#3加密),证书秘钥问题均需要修复。 -## 安全设计验证 +10、针对暴露用户态接口进行黑盒Fuzz,包括但不限于系统服务接口、内核驱动接口、socket网络接口。 -1、各模块依据[OpenHarmony安全设计规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-security-design-guide.md),结合业务完成安全设计自检验证。 +>说明:上述要求不区分继承特性及新需求。 +## 2 安全测试完成要求 +版本发布前需进行安全测试,安全测试完成标准如下: -## 安全测试工具扫描 +1、上述章节中各项安全测试内容执行完成。 -1、针对高风险模块,开发人员需要依据[Fuzz测试框架](https://gitee.com/openharmony/test_developertest/tree/master/libs/fuzzlib)开发灰白盒Fuzz测试套,并完成灰白盒Fuzz测试。 +2、安全问题均已关闭。 -2、针对暴露用户态接口进行黑盒Fuzz,包括但不限于系统服务接口、内核驱动接口、socket网络接口。 +## 3 安全测试报告模板 -3、依据[OpenHarmony编译规范](https://gitee.com/openharmony/community/blob/master/sig/sig-buildsystem/%E7%BC%96%E8%AF%91%E8%A7%84%E8%8C%83.md),使用编译选项扫描工具检查文件编译选项开启情况。 +1、安全测试报告需包含第1章节安全测试各项结果,需包含未关闭安全问题情况。 -4、针对开源组件使用业界漏洞扫描工具扫描,开源组件漏洞均已按照社区漏洞管理流程修复。 \ No newline at end of file +2、版本安全测试报告无需单独发布和归档,随版本整体测试报告发布。 \ No newline at end of file diff --git "a/zh-cn/contribute/\350\264\241\347\214\256\344\273\243\347\240\201.md" "b/zh-cn/contribute/\350\264\241\347\214\256\344\273\243\347\240\201.md" index ae8a73e9c771c7a42ce662c325c43d4990f82182..7c88515d1be29f7211403c4ead878da940d6755f 100755 --- "a/zh-cn/contribute/\350\264\241\347\214\256\344\273\243\347\240\201.md" +++ "b/zh-cn/contribute/\350\264\241\347\214\256\344\273\243\347\240\201.md" @@ -30,6 +30,10 @@ 若要引入新的第三方开源软件到OpenHarmony项目中,请参考[第三方开源软件引入指导](第三方开源软件引入指导.md) +### 测试规范 + +[OpenHarmony安全测试规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-security-test-guide.md) + ## 贡献工作流
有关详细信息,请参考[贡献流程](贡献流程.md)。 @@ -45,4 +49,3 @@ - [安全问题处理和发布流程](https://gitee.com/openharmony/security/blob/master/zh/security-process/README.md) - [安全和披露说明](https://gitee.com/openharmony/security/blob/master/zh/security-process/security-disclosure.md) - diff --git a/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md b/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md index 15f4c4e15ee145b2df316976f781a00884ad0763..48ffbf0f5263bd9d898e07ec03a5f096778628ec 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md @@ -6,7 +6,7 @@ 人脸识别功能是端侧设备不可或缺的一部分,为设备提供一种用户认证能力,可应用于设备解锁、支付、应用登录等身份认证场景。它是基于人的脸部特征信息进行身份识别的一种生物特征识别技术,用摄像机或摄像头采集含有人脸的图像或视频流,并自动在图像中检测和跟踪人脸,进而对检测到的人脸进行脸部识别,通常也叫做人像识别、面部识别、人脸认证。人脸识别功能整体框架如图1。 -基于HDF(Hardware Driver Foundation)驱动框架开发的Face_auth驱动,能够屏蔽硬件器件差异,为上层用户认证框架和Face_auth服务提供稳定的人脸识别基础能力接口,包括人脸识别执行器列表查询、执行器信息查询、指定人脸模板ID查询模板信息、用户认证框架和执行器间的人脸模板信息对账、人脸的录入,删除,认证和识别等。 +基于HDF(Hardware Driver Foundation)驱动框架开发的Face_auth驱动,能够屏蔽硬件器件差异,为上层用户认证框架和Face_auth服务提供稳定的人脸识别基础能力接口,包括人脸识别执行器列表查询、执行器信息查询、指定人脸模板ID查询模板信息、用户认证框架和执行器间的人脸模板信息对账、人脸录入、删除、认证和识别等。 **图1** 人脸识别功能整体框架 @@ -21,7 +21,7 @@ - 执行器安全等级 - 执行器提供能力时运行环境所达到的安全级别。 + 执行器提供能力时所在运行环境达到的安全级别。 - 执行器角色 @@ -51,6 +51,22 @@ 用户认证框架统一管理用户身份和凭据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服务提供稳定的人脸识别基础能力,保证设备上人脸识别功能可以正常运行。 @@ -74,24 +90,28 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务 ### 接口说明 +注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/face_auth/v1_0/)。 + +在本文中,人脸凭据的录入、认证、识别和删除相关的HDI接口如表1所示,表2中的回调函数分别用于人脸执行器返回操作结果给框架和返回操作过程中的提示信息给上层应用。 + **表1** 接口功能介绍 -| 接口名 | 功能介绍 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | -| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 | -| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定人脸模板ID的模板信息。 | +| 接口名称 | 功能介绍 | +| ----------------------------------- | ---------------------------------- | +| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | +| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 | +| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定人脸模板ID的模板信息。 | | OnRegisterFinish(const std::vector& templateIdList,
const std::vector& frameworkPublicKey, const std::vector& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的人脸模板列表用于对账。 | -| Enroll(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 录入人脸模板。 | -| Authenticate(uint64_t scheduleId, const std::vector& templateIdList,
const std::vector& extraInfo, const sptr& callbackObj) | 认证人脸模板。 | +| Enroll(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 录入人脸模板。 | +| Authenticate(uint64_t scheduleId, const std::vector& templateIdList,
const std::vector& extraInfo, const sptr& callbackObj) | 认证人脸模板。 | | Identify(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 识别人脸模板。 | -| Delete(const std::vector& templateIdList) | 删除人脸模板。 | -| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定录入、认证、识别操作。 | +| Delete(const std::vector& templateIdList) | 删除人脸模板。 | +| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定录入、认证、识别操作。 | | SendCommand(int32_t commandId, const std::vector& extraInfo,
const sptr& callbackObj) | 人脸认证服务向Face_auth驱动传递参数的通用接口。 | **表2** 回调函数介绍 -| 接口名 | 功能介绍 | +| 接口名称 | 功能介绍 | | ------------------------------------------------------------ | ------------------------ | | IExecutorCallback::OnResult(int32_t code, const std::vector& extraInfo) | 返回操作的最终结果。 | | IExecutorCallback::OnTip(int32_t code, const std::vector& extraInfo) | 返回操作的过程交互信息。 | @@ -102,15 +122,15 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务 ```undefined // drivers/peripheral/face_auth -├── BUILD.gn # 编译脚本 -├── bundle.json # 组件描述文件 -└── hdi_service # Face_auth驱动实现 - ├── BUILD.gn # 编译脚本 - ├── include # 头文件 - └── src - ├── executor_impl.cpp # 认证、录入等功能接口实现 - ├── face_auth_interface_driver.cpp # Face_auth驱动入口 - └── face_auth_interface_service.cpp # 获取执行器列表接口实现 +├── BUILD.gn # 编译脚本 +├── bundle.json # 组件描述文件 +└── hdi_service # Face_auth驱动实现 + ├── BUILD.gn # 编译脚本 + ├── include # 头文件 + └── src # 源文件 + ├── executor_impl.cpp # 认证、录入等功能接口实现 + ├── face_auth_interface_driver.cpp # Face_auth驱动入口 + └── face_auth_interface_service.cpp # 获取执行器列表接口实现 ``` 下面结合DEMO实例介绍驱动开发的具体步骤。 @@ -423,66 +443,59 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务 驱动开发完成后,通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,基于Hi3516DV300平台验证。认证和取消功能验证的JS测试代码如下: -```js -// API version 8 -import userIAM_userAuth from '@ohos.userIAM.userAuth'; -let auth = new userIAM_userAuth.UserAuth(); - -export default { - getVersion() { - console.info("start get version"); - let version = this.auth.getVersion(); - console.info("auth version = " + version); - }, - - startAuth() { - console.info("start auth"); - this.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); - } - } - }); - }, - - cancelAuth() { - 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); + ```js + // API version 9 + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + 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 { + 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); } }); - let cancelCode = this.auth.cancel(contextId); - if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { - console.info("cancel auth success"); - } else { - console.error("cancel auth fail"); - } + 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); + } + ``` diff --git a/zh-cn/device-dev/driver/driver-peripherals-fingerprint_auth-des.md b/zh-cn/device-dev/driver/driver-peripherals-fingerprint_auth-des.md index 17e0a1dccd809db2818c2da321c766d86e648d96..0f593ed75d8056df216db4837681c86934b2e7a9 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-fingerprint_auth-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-fingerprint_auth-des.md @@ -21,7 +21,7 @@ - 执行器安全等级 - 执行器提供能力时运行环境所达到的安全级别。 + 执行器提供能力时所在运行环境达到的安全级别。 - 执行器角色 @@ -53,15 +53,19 @@ - HAPs - HAPs(OpenHarmony Ability Packages),本章节中仅代表Fingerprint_auth驱动的上层应用。 + HAPs(OpenHarmony Ability Packages),广义上指可以安装在OpenHarmony上的应用包,本章节中仅代表Fingerprint_auth驱动的上层应用。 - 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(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,24 +88,27 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin ### 接口说明 +注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/fingerprint_auth/v1_0/)。 +在本文中,指纹凭据的录入、认证、识别和删除相关的HDI接口如表1所示,表2中的回调函数分别用于指纹执行器返回操作结果给框架和返回操作过程中的提示信息给上层应用。 + **表1** 接口功能介绍 -| 接口名 | 功能介绍 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | +| 接口名称 | 功能介绍 | +| -------------------------------- | ----------------------------------- | +| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | | GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 | -| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定模板ID的模板信息。 | +| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定模板ID的模板信息。 | | OnRegisterFinish(const std::vector& templateIdList,
const std::vector& frameworkPublicKey, const std::vector& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的模板列表用于对账。 | | Enroll(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 录入指纹模板。 | -| Authenticate(uint64_t scheduleId, const std::vector& templateIdList,
const std::vector& extraInfo, const sptr& callbackObj) | 认证指纹模板。 | -| Identify(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 识别指纹模板。 | -| Delete(const std::vector& templateIdList) | 删除指纹模板。 | -| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定录入、认证、识别操作。 | +| Authenticate(uint64_t scheduleId, const std::vector& templateIdList,
const std::vector& extraInfo, const sptr& callbackObj) | 认证指纹模板。 | +| Identify(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 识别指纹模板。 | +| Delete(const std::vector& templateIdList) | 删除指纹模板。 | +| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定录入、认证、识别操作。 | | SendCommand(int32_t commandId, const std::vector& extraInfo,
const sptr& callbackObj) | 指纹认证服务向Fingerprint_auth驱动传递参数的通用接口。 | **表2** 回调函数介绍 -| 接口名 | 功能介绍 | +| 接口名称 | 功能介绍 | | ------------------------------------------------------------ | ------------------------ | | IExecutorCallback::OnResult(int32_t code, const std::vector& extraInfo) | 返回操作的最终结果。 | | IExecutorCallback::OnTip(int32_t code, const std::vector& extraInfo) | 返回操作的过程交互信息。 | @@ -112,15 +119,15 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin ```undefined // drivers/peripheral/fingerprint_auth -├── BUILD.gn # 编译脚本 -├── bundle.json # 组件描述文件 -└── hdi_service # Fingerprint_auth驱动实现 - ├── BUILD.gn # 编译脚本 - ├── include # 头文件 - └── src - ├── executor_impl.cpp # 认证、录入等功能接口实现 - ├── fingerprint_auth_interface_driver.cpp # Fingerprint_auth驱动入口 - └── fingerprint_auth_interface_service.cpp # 获取执行器列表接口实现 +├── BUILD.gn # 编译脚本 +├── bundle.json # 组件描述文件 +└── hdi_service # Fingerprint_auth驱动实现 + ├── BUILD.gn # 编译脚本 + ├── include # 头文件 + └── src # 源文件 + ├── executor_impl.cpp # 认证、录入等功能接口实现 + ├── fingerprint_auth_interface_driver.cpp # Fingerprint_auth驱动入口 + └── fingerprint_auth_interface_service.cpp # 获取执行器列表接口实现 ``` 下面结合DEMO实例介绍驱动开发的具体步骤。 @@ -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测试代码如下: -```js -// API version 8 -import userIAM_userAuth from '@ohos.userIAM.userAuth'; -let auth = new userIAM_userAuth.UserAuth(); - -export default { - getVersion() { - console.info("start get version"); - let version = this.auth.getVersion(); - console.info("auth version = " + version); - }, - - 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 { - 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); - } + ```js + // API version 9 + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FINGERPRINT; + 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 { + 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.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); + } + ``` diff --git a/zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md b/zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md index 3722339fa368d07543929fdb6f9f8da33f3b06d7..d7fb9533461155f43ad86d78425756746164cf94 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md @@ -21,7 +21,7 @@ - 执行器安全等级 - 执行器提供能力时运行环境所达到的安全级别。 + 执行器提供能力时所在运行环境达到的安全级别。 - 执行器角色 @@ -52,6 +52,18 @@ 用户认证框架统一管理用户身份和凭据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层接口的调用。 @@ -61,7 +73,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提 ![image](figures/pin_auth服务与驱动交互.png "pin_auth服务与驱动交互") ### 约束与限制 -口令认证的实现需要在TEE安全环境中实现,口令凭据等数据的保密信息需要在安全环境中存储。 +口令认证的实现需要在TEE安全环境中实现,口令凭据等数据的加密信息需要在安全环境中存储。 ## 开发指导 ### 场景介绍 @@ -69,24 +81,27 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提 ### 接口说明 +注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/pin_auth/v1_0/)。 +在本文中,口令凭据的录入、认证和删除相关的HDI接口如表1所示,表2中的回调函数分别用于口令执行器返回操作结果给框架和获取用户输入的口令信息。 + **表1** 接口功能介绍 -| 接口名 | 功能介绍 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | -| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息。 | -| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定templateId的模板信息。 | +| 接口名称 | 功能介绍 | +| ------------------------------- | ------------------------------------------- | +| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | +| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息。 | +| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定templateId的模板信息。 | | OnRegisterFinish(const std::vector& templateIdList,
const std::vector& frameworkPublicKey,
const std::vector& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的template 列表用于对账。 | -| OnSetData(uint64_t scheduleId, uint64_t authSubType,
const std::vector &data) | 用于回调传pin码认证的子类型和脱敏数据。 | -| Enroll(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 录入pin码。 | -| Authenticate(uint64_t scheduleId, uint64_t templateId, const std::vector& extraInfo, const sptr& callbackObj) | pin码认证。 | -| Delete(uint64_t templateId) | 删除pin码模板。 | -| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定操作。 | -| SendCommand(int32_t commandId, const std::vector& extraInfo,
const sptr& callbackObj) | 预留接口。 | +| OnSetData(uint64_t scheduleId, uint64_t authSubType,
const std::vector &data) | 回调函数,返回用户录入的口令子类型和录入的口令脱敏数据。 | +| Enroll(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 录入pin码。 | +| Authenticate(uint64_t scheduleId, uint64_t templateId, const std::vector& extraInfo, const sptr& callbackObj) | pin码认证。 | +| Delete(uint64_t templateId) | 删除pin码模板。 | +| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定操作。 | +| SendCommand(int32_t commandId, const std::vector& extraInfo,
const sptr& callbackObj) | 预留接口。 | **表2** 回调函数介绍 -| 接口名 | 功能介绍 | +| 接口名称 | 功能介绍 | | ------------------------------------------------------------ | -------------------- | | IExecutorCallback::OnResult(int32_t code, const std::vector& extraInfo) | 返回操作的最终结果。 | | IExecutorCallback::OnGetData(uint64_t scheduleId, const std::vector& salt,
uint64_t authSubType)| 返回获取pin码数据信息。 | @@ -97,21 +112,21 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提 ```text // drivers/peripheral/pin_auth -├── BUILD.gn # 编译脚本 -├── bundle.json # 组件描述文件 -├── test # 测试用例 -└── hdi_service # Pin_auth驱动实现 - ├── BUILD.gn # 编译脚本 - ├── adaptor # 相关算法实现 - ├── common # 公共接口实现 - ├── database # 数据库实现 - ├── main # 口令相关功能实现入口 - └── service # Pin_auth驱动实现入口 - ├── inc # 头文件 - └── src - ├── executor_impl.cpp # 认证、录入等功能接口实现 - ├── pin_auth_interface_driver.cpp # Pin_auth驱动入口 - └── pin_auth_interface_service.cpp # 获取执行器列表接口实现 +├── BUILD.gn # 编译脚本 +├── bundle.json # 组件描述文件 +├── test # 测试用例 +└── hdi_service # Pin_auth驱动实现 + ├── BUILD.gn # 编译脚本 + ├── adaptor # 相关算法实现 + ├── common # 公共接口实现 + ├── database # 数据库实现 + ├── main # 口令相关功能实现入口 + └── service # Pin_auth驱动实现入口 + ├── inc # 头文件 + └── src # 源文件 + ├── executor_impl.cpp # 认证、录入等功能接口实现 + ├── pin_auth_interface_driver.cpp # Pin_auth驱动入口 + └── pin_auth_interface_service.cpp # 获取执行器列表接口实现 ``` 下面结合DEMO实例介绍驱动开发的具体步骤。 diff --git a/zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md b/zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md index e3da0d9c7387c838e710e79c58ca9562101a1ccc..57c11bc60473b958dd3421f13e04700c3655d0db 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md @@ -21,7 +21,7 @@ - 认证凭据模板 - 认证凭据模板在用户设置认证凭据时由认证服务产生并存储。每个模板有一个ID,用于索引模板信息文件。在认证时,读取模板信息并用和当次认证过程中产生的认证数据做对比,完成身份认证。 + 认证凭据模板在用户设置认证凭据时由认证服务产生并存储。每个模板有一个ID,用于索引模板信息文件。在认证时,读取模板信息并和当次认证过程中产生的认证数据做对比,完成身份认证。 - 执行器 @@ -41,11 +41,11 @@ - 执行器安全等级 - 执行器提供能力时运行环境所达到的安全级别,如操作运行在无访问控制安全等级低于操作运行硬件可信执行环境的安全等级。 + 执行器提供能力时所在运行环境达到的安全级别。 - 用户认证框架公钥 & 执行器公钥 - 用户身份认证处理需要保证用户数据安全以及认证结果的准确性,用户认证框架与基础认证服务间的关键交互信息需要做数据完整性保护,各基础认证服务将提供的执行器能力对接到用户认证框架时,需要交互各自的公钥,其中: + 用户身份认证处理需要保证用户数据安全以及认证结果的准确性,用户认证框架与基础认证服务间的关键交互信息需要做数据完整性保护,各基础认证服务将提供的执行器能力对接到用户认证框架时,需要交换各自的公钥,其中: - 执行器通过用户认证框架公钥校验调度指令的准确性,如锁定一个人脸模板,这种情况导致无法使用人脸功能,属于敏感操作,需要确保指令准确,才可处理。 @@ -76,6 +76,18 @@ 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服务提供认证执行器管理、认证凭据管理和认证方案生成管理等能力。 @@ -97,31 +109,34 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ### 接口说明 +注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/user_auth/v1_0/)。 +在本文中,执行器注册、凭据录入、凭据删除、用户认证和用户识别相关的HDI接口如表1所示。 + **表1** 接口功能介绍 -| 接口名 | 功能介绍 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| Init() | 初始化缓存信息。 | -| AddExecutor(const ExecutorRegisterInfo& info, uint64_t& index, std::vector& publicKey,
std::vector& templateIds) | 添加认证执行器,获得此认证能力。 | -| DeleteExecutor(uint64_t index) | 根据索引值index删除认证执行器。 | -| OpenSession(int32_t userId, std::vector& challenge) | 开启认证凭据管理Session。 | -| CloseSession(int32_t userId) | 关闭认证凭据管理Session。 | +| 接口名称 | 功能介绍 | +| --------------------------- | --------------------------- | +| Init() | 初始化缓存信息。 | +| AddExecutor(const ExecutorRegisterInfo& info, uint64_t& index, std::vector& publicKey,
std::vector& templateIds) | 添加认证执行器,获得此认证能力。 | +| DeleteExecutor(uint64_t index) | 根据索引值index删除认证执行器。 | +| OpenSession(int32_t userId, std::vector& challenge) | 开启认证凭据管理Session。 | +| CloseSession(int32_t userId) | 关闭认证凭据管理Session。 | | BeginEnrollment(int32_t userId, const std::vector& authToken, const EnrollParam& param,
ScheduleInfo& info) | 发起用户的认证凭据的录入,当录入类型为PIN码且当前用户已录入PIN码的情况下会更新PIN码。 | -| UpdateEnrollmentResult(int32_t userId, const std::vector& scheduleResult, uint64_t& credentialId,
CredentialInfo& oldInfo) | 更新录入结果,完成此次录入。 | -| CancelEnrollment(int32_t userId) | 取消此次录入。 | +| UpdateEnrollmentResult(int32_t userId, const std::vector& scheduleResult, uint64_t& credentialId,
CredentialInfo& oldInfo) | 更新录入结果,完成此次录入。 | +| CancelEnrollment(int32_t userId) | 取消此次录入。 | | DeleteCredential(int32_t userId, uint64_t credentialId, const std::vector& authToken,
CredentialInfo& info) | 根据credentialId删除凭据信息。 | | DeleteUser(int32_t userId, const std::vector& authToken,
std::vector& deletedInfos) | 删除PIN码即在用户认证框架中删除用户。 | | EnforceDeleteUser(int32_t userId, std::vector& deletedInfos) | 强制删除用户,当系统内此用户被删除时强制调用。 | -| GetCredential(int32_t userId, AuthType authType, std::vector& infos) | 查询用户某种认证类型下的凭据信息。 | +| GetCredential(int32_t userId, AuthType authType, std::vector& infos) | 查询用户某种认证类型下的凭据信息。 | | GetSecureInfo(int32_t userId, uint64_t& secureUid, std::vector& infos) | 查询用户的安全用户Id和每种认证类型的录入标记Id。 | | BeginAuthentication(uint64_t contextId, const AuthSolution& param,
std::vector& scheduleInfos) | 发起认证,生成认证方案和调度信息。 | | UpdateAuthenticationResult(uint64_t contextId, const std::vector& scheduleResult,
AuthResultInfo& info) | 更新认证结果,进行此次认证方案结果的评估。 | -| CancelAuthentication(uint64_t contextId) | 取消此次认证。 | +| CancelAuthentication(uint64_t contextId) | 取消此次认证。 | | BeginIdentification(uint64_t contextId, AuthType authType, const std::vector& challenge,
uint32_t executorId, ScheduleInfo& scheduleInfo) | 发起识别,生成识别方案和调度信息。 | | UpdateIdentificationResult(uint64_t contextId, const std::vector& scheduleResult,
IdentifyResultInfo& info) | 更新识别结果,进行此次识别方案结果的评估。 | -| CancelIdentification(uint64_t contextId) | 取消此次识别。 | -| GetAuthTrustLevel(int32_t userId, AuthType authType, uint32_t& authTrustLevel) | 获取此用户当前认证类型的认证可信等级。 | -| GetValidSolution(int32_t userId, const std::vector& authTypes, uint32_t authTrustLevel,
std::vector& validTypes) | 筛选此用户当前认证可信等级下可用认证方式。 | +| CancelIdentification(uint64_t contextId) | 取消此次识别。 | +| GetAuthTrustLevel(int32_t userId, AuthType authType, uint32_t& authTrustLevel) | 获取此用户当前认证类型的认证可信等级。 | +| GetValidSolution(int32_t userId, const std::vector& authTypes, uint32_t authTrustLevel,
std::vector& validTypes) | 筛选此用户当前认证可信等级下可用的认证方式。 | ### 开发步骤 @@ -129,14 +144,14 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ```undefined // drivers/peripheral/user_auth -├── BUILD.gn # 编译脚本 -├── bundle.json # 组件描述文件 -└── hdi_service # User_auth驱动实现 - ├── BUILD.gn # 编译脚本 - ├── module # 功能实现 +├── BUILD.gn # 编译脚本 +├── bundle.json # 组件描述文件 +└── hdi_service # User_auth驱动实现 + ├── BUILD.gn # 编译脚本 + ├── module # 功能实现 └── service - ├── user_auth_interface_driver.cpp # User_auth驱动入口 - └── user_auth_interface_service.cpp # 获取执行器列表接口实现 + ├── user_auth_interface_driver.cpp # User_auth驱动入口 + └── user_auth_interface_service.cpp # 获取执行器列表接口实现 ``` 下面结合DEMO实例介绍驱动开发的具体步骤。 @@ -494,66 +509,59 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 驱动开发完成后,通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,基于Hi3516DV300平台验证。认证和取消功能验证的JS测试代码如下: -```js -// API version 8 -import userIAM_userAuth from '@ohos.userIAM.userAuth'; -let auth = new userIAM_userAuth.UserAuth(); - -export default { - getVersion() { - console.info("start get version"); - let version = this.auth.getVersion(); - console.info("auth version = " + version); - }, - - startAuth() { - console.info("start auth"); - this.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 == '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); - } - } - }); - }, - - cancelAuth() { - 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); + ```js + // API version 9 + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + 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 { + 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); } }); - let cancelCode = this.auth.cancel(contextId); - if (cancelCode == userIAM_userAuth.Result.SUCCESS) { - console.info("cancel auth success"); - } else { - console.error("cancel auth fail"); - } + 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); + } + ``` diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20220915140627223.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220915140627223.png index 0555592c3d2e17c7b2b9a25faca5a830a2ac026c..8e87d1fd2a3a399d90e93186557cf810825b5175 100644 Binary files a/zh-cn/device-dev/kernel/figures/zh-cn_image-20220915140627223.png and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220915140627223.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930141628922.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930141628922.png index f4c4e437a0089ac5ba3371f531694daac4b36703..fe945b422010efd214d82a0ccc4bfafd2cefd860 100644 Binary files a/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930141628922.png and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930141628922.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001160018656.png b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001160018656.png index d5693bd916ea4f009687af8233054baedf06ddf3..6635920e71a8c2f978ebcdf03e17c13674222e89 100644 Binary files a/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001160018656.png and b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001160018656.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001199351155.png b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001199351155.png index aab178cde608403d259af3cd10c11188e213de08..463d88f332966f2389daf5b7d83b6ec626ebfc73 100644 Binary files a/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001199351155.png and b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001199351155.png differ diff --git a/zh-cn/device-dev/kernel/kernel-standard-newip.md b/zh-cn/device-dev/kernel/kernel-standard-newip.md index caf9c0bb4cd638c0dbf5346d7559a71814c530ec..895a1b2551e066e4f7ec0c954dd4c1cd0d3407af 100644 --- a/zh-cn/device-dev/kernel/kernel-standard-newip.md +++ b/zh-cn/device-dev/kernel/kernel-standard-newip.md @@ -1,9 +1,9 @@ -# NewIP内核协议栈介绍 +# New IP内核协议栈介绍 ## 基本概念 -NewIP在现有IP能力的基础上,以灵活轻量级报头和可变长多语义地址为基础,通过二三层协议融合,对协议去冗和压缩,减少冗余字节,实现高能效比,高净吞吐,提升通信效率。打造终端之间高效的横向通信,支撑超级终端的体验,实现异构网络的端到端互联。 +New IP在现有IP能力的基础上,以灵活轻量级报头和可变长多语义地址为基础,通过二三层协议融合,对协议去冗和压缩,减少冗余字节,实现高能效比,高净吞吐,提升通信效率。打造终端之间高效的横向通信,支撑超级终端的体验,实现异构网络的端到端互联。 目前WiFi协议报文,三层报头和地址开销使得报文开销大,传输效率较低。 @@ -14,21 +14,21 @@ IPv4地址长度固定4字节,IPv6地址长度固定16字节。 IPv4网络层报头长度20~60字节,IPv6网络层报头长度40字节。 ``` -NewIP支持**可变长多语义地址(最短1字节)**,**可变长定制化报头封装(最短5字节)**,通过精简报文头开销,提升数据传输效率。 +New IP支持**可变长多语义地址(最短1字节)**,**可变长定制化报头封装(最短5字节)**,通过精简报文头开销,提升数据传输效率。 -NewIP报头开销,相比IPv4节省25.9%,相比IPv6节省44.9%。 +New IP报头开销,相比IPv4节省25.9%,相比IPv6节省44.9%。 -NewIP载荷传输效率,相比IPv4提高最少1%,相比IPv6提高最少2.33%。 +New IP载荷传输效率,相比IPv4提高最少1%,相比IPv6提高最少2.33%。 -| 对比场景 | 报头开销 | 载荷传输效率(WiFi MTU=1500B,BT MTU=255B) | -| -------------- | ------------ | ------------------------------------------- | -| IPv4 for WiFi | 30+8+20=58 B | (1500-58)/1500=96.13% | -| IPv6 for WiFi | 30+8+40=78 B | (1500-78)/1500=94.8% | -| NewIP for WiFi | 30+8+5=43 B | (1500-43)/1500=97.13% | +| 对比场景 | 报头开销 | 载荷传输效率(WiFi MTU=1500B,BT MTU=255B) | +| --------------- | ------------ | ------------------------------------------- | +| IPv4 for WiFi | 30+8+20=58 B | (1500-58)/1500=96.13% | +| IPv6 for WiFi | 30+8+40=78 B | (1500-78)/1500=94.8% | +| New IP for WiFi | 30+8+5=43 B | (1500-43)/1500=97.13% | ## 可变长报头格式 -NewIP WiFi灵活极简报文头如下图所示,通过LLC Header中的EtherType = 0xEADD标识NewIP灵活极简报文。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) @@ -39,34 +39,34 @@ NewIP WiFi灵活极简报文头如下图所示,通过LLC Header中的EtherType **Bitmap字段定义如下:** -| 极简Bitmap标识 | Bitops | 字段长度 | 置位策略 | 备注 | -| -------------------------- | ------ | ---------------- | -------------- | --------------------------------------- | -| Bitmap 1st Byte: | - | - | - | - | -| 标记位Dispatch | 0 | 不表示具体字段 | 置0 | 0:极简帧,1:普通帧。 | -| TTL | 1 | 1 Byte | 置1 | 剩余跳数。 | -| Total Length | 2 | 2 Byte | UDP置0,TCP置1 | NewIP报文总长度(包含报头长度)。 | -| Next Header | 3 | 1 Byte | 置1 | 协议类型。 | -| Reserve | 4 | 保留 | 置0 | 保留字段。 | -| Dest Address | 5 | 变长(1~8 Byte) | 置1 | 目的地址。 | -| Source Address | 6 | 变长(1~8 Byte) | 由协议自行确定 | 源地址。 | -| 标记位,标志是否有2nd Byte | 7 | 不表示具体字段 | - | 0:bitmap结束,1:后跟另外8bit bitmap。 | -| Bitmap 2nd Byte: | - | - | - | - | -| Header Length | 0 | 1 Byte | - | NewIP报头长度。 | -| Reserve | 1 | 保留 | 置0 | - | -| Reserve | 2 | 保留 | 置0 | - | -| Reserve | 3 | 保留 | 置0 | - | -| Reserve | 4 | 保留 | 置0 | - | -| Reserve | 5 | 保留 | 置0 | - | -| Reserve | 6 | 保留 | 置0 | - | -| 标记位,标志是否有3rd Byte | 7 | 不表示具体字段 | 置0 | 0:bitmap结束,1:后跟另外8bit bitmap。 | - -NewIP数据报头(极简模式)解析遇到新bitmap字段时的处理方法: +| 极简Bitmap标识 | Bitops | 携带字段的长度 | 置位策略 | 备注 | +| ---------------------------- | ------ | ---------------- | -------------- | --------------------------------------- | +| Bitmap 1st Byte: | - | - | - | 下面8bit是从高位到低位排列。 | +| 标记位Dispatch | 0 | - | 置0 | 0:极简封装报头,1:非极简封装报头。 | +| 报文头是否携带TTL | 1 | 1 Byte | 置1 | 剩余跳数。 | +| 报文头是否携带Total Length | 2 | 2 Byte | UDP置0,TCP置1 | New IP报文总长度(包含报头长度)。 | +| 报文头是否携带Next Header | 3 | 1 Byte | 置1 | 协议类型。 | +| Reserve | 4 | 保留 | 置0 | 保留字段。 | +| 报文头是否携带Dest Address | 5 | 变长(1~8 Byte) | 置1 | 目的地址。 | +| 报文头是否携带Source Address | 6 | 变长(1~8 Byte) | 由协议自行确定 | 源地址。 | +| 标记位,标志是否有2nd Byte | 7 | - | - | 0:bitmap结束,1:后跟另外8bit bitmap。 | +| Bitmap 2nd Byte: | - | - | - | 下面8bit是从高位到低位排列。 | +| 报文头是否携带Header Length | 0 | 1 Byte | - | New IP报头长度。 | +| Reserve | 1 | 保留 | 置0 | - | +| Reserve | 2 | 保留 | 置0 | - | +| Reserve | 3 | 保留 | 置0 | - | +| Reserve | 4 | 保留 | 置0 | - | +| Reserve | 5 | 保留 | 置0 | - | +| Reserve | 6 | 保留 | 置0 | - | +| 标记位,标志是否有3rd Byte | 7 | - | - | 0:bitmap结束,1:后跟另外8bit bitmap。 | + +New IP报头(极简封装)解析遇到新bitmap字段时的处理方法: 仅解析当前版本协议中已定义的bitmap字段,从第一个未知语义的bitmap字段开始,跳过后面的所有bitmap字段,直接通过header length定位到报文开始位置并解析报文。如果报头中携带了未知语义的bitmap字段,且未携带header length字段,则丢弃该数据包。 ## 可变长地址格式 -NewIP采用自解释编码,编码格式如下所示: +New IP支持可变长地址(IPv4/IPv6地址长度固定),支持自解析地址长度,报文头中可以不携带地址长度字段,New IP地址编码格式如下所示: | First Byte | Semantics | 地址段有效范围 | | ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ | @@ -87,32 +87,40 @@ NewIP采用自解释编码,编码格式如下所示: -## NewIP配置指导 +## New IP配置指导 -启用NewIP,需要通过编译内核时打开相应的配置项及依赖,NewIP相关CONFIG如下: +### New IP使能 + +目前只有rk3568开发板Linux 5.10内核上支持New IP内核协议栈,在rk3568开发板内核模块配置文件中搜索NEWIP,将其修改成“CONFIG_XXX=y”即可,New IP相关CONFIG如下。 -```c -CONFIG_NEWIP=y // 使能NewIP内核协议栈 -CONFIG_NEWIP_HOOKS=y // 使能NewIP内核侵入式修改插桩函数注册,使能NewIP的同时必须使用NewIP插桩功能 +``` +# kernel/linux/config/linux-5.10/arch/arm64/configs/rk3568_standard_defconfig +CONFIG_NEWIP=y // 使能New IP内核协议栈 +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 +... ``` -备注: - -1. 只在Linux 5.10内核上支持NewIP内核协议栈。 -2. OpenHarmony linux内核要求所有原生内核代码侵入式修改,都要修改成插桩方式。 +备注:OpenHarmony linux内核要求所有原生内核代码侵入式修改,都要修改成插桩方式。例如下面IPv4,IPv6协议栈公共流程中增加New IP处理时,不能直接调用New IP函数,需要在公共流程中增加插桩点,New IP使能后在模块初始化时将xx功能函数注册到对应的函数指针上,下面公共流程就可以通过函数指针的形式调用到New IP的函数。 ```c -/* 将NewIP ehash函数注册到内核 */ +/* 将New IP ehash函数注册到内核 */ register_trace_ninet_ehashfn_hook(&ninet_ehashfn_hook, NULL); -/* 下面是IPv4,IPv6协议栈总入口函数,在总入口函数内新增NewIP协议栈相关处理 */ +/* 下面是IPv4,IPv6协议栈总入口函数,在总入口函数内新增New IP协议栈相关处理 */ static u32 sk_ehashfn(const struct sock *sk) { /* IPv6 */ @@ -128,7 +136,7 @@ static u32 sk_ehashfn(const struct sock *sk) if (sk->sk_family == AF_NINET) { u32 ret = 0; - /* NewIP注册的ehash函数 */ + /* New IP注册的ehash函数 */ trace_ninet_ehashfn_hook(sock_net(sk), &sk->sk_nip_rcv_saddr, sk->sk_num, &sk->sk_nip_daddr, sk->sk_dport, &ret); return ret; @@ -142,47 +150,35 @@ static u32 sk_ehashfn(const struct sock *sk) } ``` +### New IP禁用 +在rk3568开发板内核模块配置文件中搜索NEWIP,将其“CONFIG_NEWIP=y”和“CONFIG_NEWIP_HOOKS=y”删除或使用#注释掉即可。 -代码编译完成后,通过下面命令可以确认newip协议栈代码是否使能成功。 - -```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 -... ``` - -禁用NewIP内核协议栈,删除CONFIG_NEWIP使能开关,删除out/kernel目录后重新编译。 - -```c +# kernel/linux/config/linux-5.10/arch/arm64/configs/rk3568_standard_defconfig # CONFIG_NEWIP is not set # CONFIG_NEWIP_HOOKS is not set ``` -## NewIP相关接口 +## New IP相关接口 -用户态应用程序调用Socket API创建NewIP socket,采用NewIP极简帧头封装进行收发包,NewIP协议socket接口列表如下: +用户态应用程序调用Socket API创建New IP socket,采用New IP极简封装进行收发包,New IP协议socket接口列表如下: | 函数 | 输入 | 输出 | 返回值 | 接口具体描述 | | -------- | ------------------------------------------------------------ | ---------------------------------------------- | ---------------- | ------------------------------------------------------------ | -| socket | int **domain**, int type, int **protocol** | NA | Socket句柄sockfd | 创建NewIP 协议类型socket,并返回socket实例所对应的句柄。**domain参数填写 AF_NINET,表示创建NewIP协议类型socket。protocol参数填写IPPROTO_TCP或IPPROTO_UDP**。 | +| socket | int **domain**, int type, int **protocol** | NA | Socket句柄sockfd | 创建New IP 协议类型socket,并返回socket实例所对应的句柄。**domain参数填写 AF_NINET,表示创建New IP协议类型socket。protocol参数填写IPPROTO_TCP或IPPROTO_UDP**。 | | bind | int sockfd, const **struct sockaddr_nin** *myaddr, socklen_t addrlen | NA | int,返回错误码 | 将创建的socket绑定到指定的IP地址和端口上。**myaddr->sin_family填写AF_NINET**。 | -| listen | int socket, int backlog | NA | int,返回错误码 | 服务端监听NewIP地址和端口。 | +| listen | int socket, int backlog | NA | int,返回错误码 | 服务端监听New IP地址和端口。 | | connect | int sockfd, const **struct sockaddr_nin** *addr, aocklen_t addrlen | NA | int,返回错误码 | 客户端创建至服务端的连接。 | | accept | int sockfd, **struct sockaddr_nin** *address, socklen_t *address_len | NA | 返回socket的fd | 服务端返回已建链成功的socket。 | -| send | int sockfd, const void *msg, int len, unsigned int flags, const **struct sockaddr_nin** *dst_addr, int addrlen | NA | int,返回错误码 | 用于socket已连接的NewIP类型数据发送。 | -| recv | int sockfd, size_t len, int flags, **struct sockaddr_nin** *src_addr, | void **buf, int* *fromlen | int,返回错误码 | 用于socket已连接的NewIP类型数据接收。 | +| send | int sockfd, const void *msg, int len, unsigned int flags, const **struct sockaddr_nin** *dst_addr, int addrlen | NA | int,返回错误码 | 用于socket已连接的New IP类型数据发送。 | +| recv | int sockfd, size_t len, int flags, **struct sockaddr_nin** *src_addr, | void **buf, int* *fromlen | int,返回错误码 | 用于socket已连接的New IP类型数据接收。 | | close | int sockfd | NA | int,返回错误码 | 关闭socket,释放资源。 | -| ioctl | int sockfd, unsigned long cmd, ... | NA | int,返回错误码 | 对NewIP协议栈相关信息进行查询或更改。 | -| sendto | int sockfd, const void *msg, int len, unsigned int flags, const **struct sockaddr** *dst_addr, int addrlen | NA | int,返回错误码 | 用于socket无连接的NewIP类型数据发送。 | -| recvfrom | int sockfd, size_t len, int flags, | void *buf, struct sockaddr *from, int *fromlen | int,返回错误码 | 用于socket无连接的NewIP类型数据接收。 | +| ioctl | int sockfd, unsigned long cmd, ... | NA | int,返回错误码 | 对New IP协议栈相关信息进行查询或更改。 | +| sendto | int sockfd, const void *msg, int len, unsigned int flags, const **struct sockaddr** *dst_addr, int addrlen | NA | int,返回错误码 | 用于socket无连接的New IP类型数据发送。 | +| recvfrom | int sockfd, size_t len, int flags, | void *buf, struct sockaddr *from, int *fromlen | int,返回错误码 | 用于socket无连接的New IP类型数据接收。 | -NewIP短地址结构如下: +New IP短地址结构如下: ```c enum nip_8bit_addr_index { @@ -244,21 +240,21 @@ struct sockaddr_nin { }; ``` -## NewIP开发说明 +## New IP开发说明 -目前只在OpenHarmony Linux-5.10内核支持NewIP内核协议栈,只能在用户态人工配置NewIP地址和路由到内核,两台设备通过路由器WiFi连接。如果想配置NewIP地址和路由后自动切换到NewIP内核协议栈通信,应用可以参考下面蓝框中描述。 +目前只在OpenHarmony Linux-5.10内核支持New IP内核协议栈,只能在用户态人工配置New IP地址和路由到内核,两台设备通过路由器WiFi连接。如果想配置New IP地址和路由后自动切换到New IP内核协议栈通信,应用可以参考下面蓝框中描述。 ![zh-cn_image-20221009112548444](figures/zh-cn_image-20221009112548444.png) -上图中NewIP地址,路由配置程序可以参考[代码仓examples代码](https://gitee.com/openharmony/communication_sfc_newip/tree/master/examples),根据CPU硬件差异更改Makefile中CC定义编译成二级制文件后推送到开发板,参考上图命令给设备配置NewIP地址和路由。 +上图中New IP地址,路由配置程序可以参考[代码仓examples代码](https://gitee.com/openharmony/kernel_common_modules_newip/tree/master/examples),根据CPU硬件差异更改Makefile中CC定义编译成二级制文件后推送到开发板,参考上图命令给设备配置New IP地址和路由。 -| 文件名 | 功能 | -| ------------------ | ------------------------------------------------------ | -| nip_addr.c | NewIP可变长地址配置demo代码(可配置任意有效NewIP地址) | -| nip_route.c | NewIP路由配置demo代码(可配置任意有效NewIP地址) | -| check_nip_enable.c | 获取本机NewIP能力 | +| 文件名 | 功能 | +| ------------------ | -------------------------------------------------------- | +| nip_addr.c | New IP可变长地址配置demo代码(可配置任意有效New IP地址) | +| nip_route.c | New IP路由配置demo代码(可配置任意有效New IP地址) | +| check_nip_enable.c | 获取本机New IP能力 | -设备1上查看NewIP地址和路由: +设备1上查看New IP地址和路由: ```sh # cat /proc/net/nip_addr @@ -268,7 +264,7 @@ struct sockaddr_nin { 01 01 2149580801 wlan0 # 本机自发自收路由 ``` -设备2上查看NewIP地址和路由: +设备2上查看New IP地址和路由: ```sh # cat /proc/net/nip_addr @@ -278,19 +274,19 @@ struct sockaddr_nin { 02 02 2149580801 wlan0 # 本机自发自收路由 ``` -## NewIP收发包代码示例 +## New IP收发包代码示例 -NewIP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如下,NewIP协议栈用户态接口使用方法可以参考[代码仓examples代码](https://gitee.com/openharmony/communication_sfc_newip/tree/master/examples)。demo代码内配置固定地址和路由,执行编译后二进制程序时不需要人工指定地址和路由。 +New IP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如下,New IP协议栈用户态接口使用方法可以参考[代码仓examples代码](https://gitee.com/openharmony/kernel_common_modules_newip/tree/master/examples)。demo代码内配置固定地址和路由,执行编译后二进制程序时不需要人工指定地址和路由。 -| 文件名 | 功能 | -| --------------------- | ----------------------------- | -| nip_addr_cfg_demo.c | NewIP可变长地址配置demo代码 | -| nip_route_cfg_demo.c | NewIP路由配置demo代码 | -| nip_udp_server_demo.c | NewIP UDP收发包服务端demo代码 | -| nip_udp_client_demo.c | NewIP UDP收发包客户端demo代码 | -| nip_tcp_server_demo.c | NewIP TCP收发包服务端demo代码 | -| nip_tcp_client_demo.c | NewIP TCP收发包客户端demo代码 | -| nip_lib.c | 接口索引获取等API接口demo代码 | +| 文件名 | 功能 | +| --------------------- | ------------------------------ | +| nip_addr_cfg_demo.c | New IP可变长地址配置demo代码 | +| nip_route_cfg_demo.c | New IP路由配置demo代码 | +| nip_udp_server_demo.c | New IP UDP收发包服务端demo代码 | +| nip_udp_client_demo.c | New IP UDP收发包客户端demo代码 | +| nip_tcp_server_demo.c | New IP TCP收发包服务端demo代码 | +| nip_tcp_client_demo.c | New IP TCP收发包客户端demo代码 | +| nip_lib.c | 接口索引获取等API接口demo代码 | **基础操作步骤:** @@ -302,9 +298,9 @@ NewIP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如 3. 执行“ifconfig wlan0 up”开启网卡设备。 -4. 在设备1的sh下执行“./nip_addr_cfg_demo server”给服务端配置0xDE00(2字节)变长地址,在设备2的sh下执。行“./nip_addr_cfg_demo client”给客户端配置0x50(1字节)变长地址,通过“cat /proc/net/nip_addr”查看内核地址配置结果。 +4. 在设备1的shell下执行“./nip_addr_cfg_demo server”给服务端配置0xDE00(2字节)变长地址,在设备2的shell下执。行“./nip_addr_cfg_demo client”给客户端配置0x50(1字节)变长地址,通过“cat /proc/net/nip_addr”查看内核地址配置结果。 -5. 在设备1的sh下执行“./nip_route_cfg_demo server”给服务端配置路由,在设备2的sh下执行“./nip_route_cfg_demo client”给客户端配置路由,通过“cat /proc/net/nip_route”查看内核路由配置结果。 +5. 在设备1的shell下执行“./nip_route_cfg_demo server”给服务端配置路由,在设备2的shell下执行“./nip_route_cfg_demo client”给客户端配置路由,通过“cat /proc/net/nip_route”查看内核路由配置结果。 以上步骤操作完成后,可以进行UDP/TCP收发包,收发包demo默认使用上面步骤中配置的地址和路由。 @@ -312,10 +308,10 @@ NewIP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如 **UDP收发包操作步骤:** -先在服务端执行“./nip_udp_server_demo”,然后再在客户端执行“./nip_udp_client_demo”,客户端会发送10个NewIP报文,客户端收到报文后再发送给服务端。 +先在服务端执行“./nip_udp_server_demo”,然后再在客户端执行“./nip_udp_client_demo”,客户端会发送10个New IP报文,服务端收到报文后再发送给客户端。 ``` -服务端sh窗口打印内容: +服务端shell窗口打印内容: Received -- 1661826989 498038 NIP_UDP # 0 -- from 0x50:57605 Sending -- 1661826989 498038 NIP_UDP # 0 -- to 0x50:57605 Received -- 1661826990 14641 NIP_UDP # 1 -- from 0x50:57605 @@ -338,10 +334,10 @@ Received --1661827011 590576 NIP_UDP # 9 sock 3 success: 10/ 10/no= **TCP收发包操作步骤:** -先在服务端执行“./nip_tcp_server_demo”,然后再在客户端执行“./nip_tcp_client_demo”,客户端会发送10个NewIP报文,客户端收到报文后再发送给服务端。 +先在服务端执行“./nip_tcp_server_demo”,然后再在客户端执行“./nip_tcp_client_demo”,客户端会发送10个New IP报文,服务端收到报文后再发送给客户端。 ``` -服务端sh窗口打印内容: +服务端shell窗口打印内容: Received -- 1661760202 560605 NIP_TCP # 0 --:1024 Sending -- 1661760202 560605 NIP_TCP # 0 --:1024 Received -- 1661760203 69254 NIP_TCP # 1 --:1024 @@ -352,7 +348,7 @@ Sending -- 1661760203 571604 NIP_TCP # 2 --:1024 Received -- 1661760207 86544 NIP_TCP # 9 --:1024 Sending -- 1661760207 86544 NIP_TCP # 9 --:1024 -客户端sh窗口打印内容: +客户端shell窗口打印内容: Received --1661760202 560605 NIP_TCP # 0 sock 3 success: 1/ 1/no= 0 Received --1661760203 69254 NIP_TCP # 1 sock 3 success: 2/ 2/no= 1 ... @@ -361,7 +357,7 @@ Received --1661760207 86544 NIP_TCP # 9 sock 3 success: 10/ 10/no= ## selinux规则说明 -用户态进程操作NewIP socket需要添加selinux policy,否则操作会被拦截。 +用户态进程操作New IP socket需要添加selinux policy,否则操作会被拦截。 ```sh # base\security\selinux\sepolicy\ohos_policy\xxx\xxx.te @@ -379,18 +375,18 @@ allowxperm thread_xxx thread_xxx:socket ioctl { 0x8933 0x8916 0x890B }; ## WireShark报文解析模板 -Wireshark默认报文解析规则无法解析NewIP报文,在WireShark配置中添加NewIP报文解析模板可以实现NewIP报文解析,[NewIP报文解析模板](https://gitee.com/openharmony/communication_sfc_newip/blob/master/tools/wireshark_cfg_for_newip.lua)详见代码仓。 +Wireshark默认报文解析规则无法解析New IP报文,在WireShark配置中添加New IP报文解析模板可以实现New IP报文解析,[New IP报文解析模板](https://gitee.com/openharmony/kernel_common_modules_newip/blob/master/tools/wireshark_cfg_for_newip.lua)详见代码仓。 报文解析模板配置文件的方法: -依次单击 Help -> About Wireshark -> Folders,打开Global Configuration目录,编辑init.lua文件。在末尾添加dofile(DATA_DIR..”newip.lua”),其中DATA_DIR即为newip.lua插件所在路径。 +依次单击 Help -> About Wireshark -> Folders,打开Global Configuration目录,编辑init.lua文件。在末尾添加dofile(DATA_DIR..”newip.lua”),其中DATA_DIR即为newip.lua报文解析模板所在路径。 ![zh-cn_image-20220930141628922](figures/zh-cn_image-20220930141628922.png) -NewIP报文解析模板添加样例: +New IP报文解析模板添加样例: ``` -NewIP报文解析模板存放路径: +New IP报文解析模板存放路径: D:\tools\WireShark\wireshark_cfg_for_newip.lua WireShark配置文件路径: @@ -404,7 +400,9 @@ dofile("D:\\tools\\WireShark\\wireshark_cfg_for_newip.lua") #### ND请求 -NewIP邻居发现请求报文格式如下,NewIP极简报文头包含1字节的bitmap(0x76),bitmap标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。NewIP ND请求报文包含报文类型,操作码,校验和和请求地址。 +New IP邻居发现(Neighbor Discovery)请求报文格式如下,New IP极简报文头包含1字节的bitmap(0x76),bitmap标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。New IP ND请求报文包含报文类型,操作码,校验和和请求地址。 + +备注:New IP支持变长地址(1字节~8字节),下图中1字节地址仅表示当前报文头中携带的地址是1字节。 ![zh-cn_image-20221011144901470](figures/zh-cn_image-20221011144901470.png) @@ -412,7 +410,9 @@ NewIP邻居发现请求报文格式如下,NewIP极简报文头包含1字节的 #### ND应答 -NewIP邻居发现应答报文格式如下,NewIP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。NewIP ND应答报文包含报文类型,操作码,校验和和邻居MAC地址长度,邻居MAC地址。 +New IP邻居发现(Neighbor Discovery)应答报文格式如下,New IP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。New IP ND应答报文包含报文类型,操作码,校验和和邻居MAC地址长度,邻居MAC地址。 + +备注:New IP支持变长地址(1字节~8字节),下图中1字节地址仅表示当前报文头中携带的地址是1字节。 ![zh-cn_image-20221011145157288](figures/zh-cn_image-20221011145157288.png) @@ -420,7 +420,9 @@ NewIP邻居发现应答报文格式如下,NewIP极简报文头包含2字节的 #### TCP握手 -TCP三次握手SYN报文格式如下,NewIP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。 +TCP三次握手SYN报文格式如下,New IP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。 + +备注:New IP支持变长地址(1字节~8字节),下图中1字节地址仅表示当前报文头中携带的地址是1字节。 ![image-20221011150018915](figures/zh-cn_image-20221011150018915.png) @@ -428,7 +430,9 @@ TCP三次握手SYN报文格式如下,NewIP极简报文头包含2字节的bitma #### TCP数据包 -TCP数据格式如下,NewIP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。 +TCP数据格式如下,New IP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。 + +备注:New IP支持变长地址(1字节~8字节),下图中1字节地址仅表示当前报文头中携带的地址是1字节。 ![image-20221011150215316](figures/zh-cn_image-20221011150215316.png) diff --git "a/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" index 123e8b3acb357954dac6cb1c00e7db9ad3a90df6..0331ee8fc60602fc1424baf03c58bfccb9093056 100644 --- "a/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" @@ -2,7 +2,7 @@ ## 简介 -用户身份和访问管理子系统,下称用户IAM(Identity and Access Management),旨在为OpenHarmony提供统一用户身份凭据信息管理和用户身份认证框架能力,支持多用户分别设置认证凭据信息,并根据用户设置的认证凭据信息提供用户身份认证功能,支撑锁屏等安全场景。同时,用户IAM子系统也提供API,支持三方开发者调用系统提供的身份认证能力来实现业务对用户的访问控制要求。 +用户身份和访问管理子系统,下称用户IAM(Identity and Access Management),旨在为OpenHarmony提供统一用户身份凭据管理和身份认证的能力,支持多用户分别设置凭据信息,并根据用户设置的凭据信息提供用户身份认证功能,支撑锁屏和支付等安全场景。同时,用户IAM子系统也提供对外的接口供三方应用调用,实现业务对用户的访问控制要求。 **图1** 子系统架构图 @@ -14,16 +14,15 @@ - **用户身份凭据管理:** 向上提供系统内统一的用户身份凭据信息管理接口,向下通过认证执行器管理模块,调用系统内的认证资源,完成用户身份凭据的生命周期管理和安全存储。 - **认证执行器管理:** 提供认证资源管理和认证会话管理功能,支持系统内身份认证相关**执行器**统一管理和协同调度,支持不同类型的身份认证执行器灵活对接。 -基于统一用户认证框架,系统可以扩展支持多种认证能力。OpenHarmony框架当前已经支持的**认证执行器**包含口令认证和人脸认证,开发者如果想实现新的认证执行器,只需要在新的部件内实现认证相关功能,并且按照执行器管理模块定义的接口与统一用户认证框架对接即可。 +基于统一用户认证框架,系统可以扩展支持多种认证能力。OpenHarmony框架当前已经支持的**认证执行器**包含口令执行器和人脸执行器,开发者如果想实现新的认证执行器,只需要在新的部件内实现认证相关功能,并且按照执行器管理模块定义的接口与统一用户认证框架对接即可。 -*注:在用户IAM子系统内,将一个用户身份认证操作的最小执行单元称为**执行器**,如一个口令认证模块,处理口令采集、口令处理和比对、口令安全存储的全过程,因此可以抽象为一个口令认证的全功能执行器。* +*注:在用户IAM子系统内,将一个用户身份认证操作的最小执行单元称为**执行器**,如一个口令认证模块,包含口令采集、处理、安全存储和口令比对的全过程,因此可以抽象为一个口令认证的全功能执行器。* ## 目录 - ```undefined -//base/user_iam -├── user_auth_framework # 用户认证框架,包括用户认证、凭据管理和执行器管理 +//base/useriam +├── user_auth_framework # 用户认证框架,包括用户认证、凭据管理和执行器管理 ├── face_auth # 人脸认证部件,与认证执行器管理对接,支持人脸录入、删除和人脸认证功能 ├── pin_auth # 口令认证部件,与认证执行器管理对接,支持口令录入、删除和口令认证功能 @@ -31,7 +30,7 @@ ## 约束 -1. 用户身份凭据信息管理类操作,是系统内的关键操作,相关接口只支持系统基础应用调用。 +1. 用户身份凭据信息管理类操作,是系统内的关键操作,相关接口只支持系统基础应用的调用。 2. 执行器内部真正完成用户凭据信息的处理,因此只支持系统服务实现执行器的功能,与认证执行器管理模块对接。 ## 说明 @@ -39,7 +38,7 @@ ### 使用说明 1. 统一用户认证框架必须配合一个认证执行器才可以使用。 -2. 系统内默认存在的第一个认证执行器应该是口令执行器。 +2. 系统内默认存在的第一个认证执行器是口令执行器。 ## 相关仓 diff --git a/zh-cn/release-notes/changelogs/weekly-20221025/changelogs-ability.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.8.3/changelogs-ability.md similarity index 100% rename from zh-cn/release-notes/changelogs/weekly-20221025/changelogs-ability.md rename to zh-cn/release-notes/changelogs/OpenHarmony 3.2.8.3/changelogs-ability.md diff --git a/zh-cn/release-notes/changelogs/weekly-20221025/changelogs-account_os_account.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.8.3/changelogs-account_os_account.md similarity index 96% rename from zh-cn/release-notes/changelogs/weekly-20221025/changelogs-account_os_account.md rename to zh-cn/release-notes/changelogs/OpenHarmony 3.2.8.3/changelogs-account_os_account.md index ebccab58a73f1a18f25a158b9a7d165c306f91b1..216a2b4f3e158dd8246200a2a039b25f09027b7f 100644 --- a/zh-cn/release-notes/changelogs/weekly-20221025/changelogs-account_os_account.md +++ b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.8.3/changelogs-account_os_account.md @@ -1,124 +1,124 @@ -# 帐号子系统ChangeLog - -## cl.account_os_account.1 帐号SystemAPI错误信息返回方式变更 - -已发布的部分帐号SystemAPI使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更: - -异步接口:通过AsyncCallback或Promise的error对象返回错误信息。 - -同步接口:通过抛出异常的方式返回错误信息。 - -**变更影响** - -基于此前版本开发的应用,需适配变更接口的错误信息返回方式,否则会影响原有业务逻辑。 - -**关键接口/组件变更** - -变更前: - - class UserAuth - - setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void; - - setProperty(request: SetPropertyRequest): Promise<number>; - - cancelAuth(contextID: Uint8Array): number; - - class PINAuth - - registerInputer(inputer: Inputer): boolean; - - UserIdentityManager - - cancel(challenge: Uint8Array): number; - -变更后: - - class UserAuth - - setProperty(request: SetPropertyRequest, callback: AsyncCallback<void>): void; - - setProperty(request: SetPropertyRequest): Promise<void>; - - cancelAuth(contextID: Uint8Array): void; - - class PINAuth - - registerInputer(inputer: Inputer): void; - - UserIdentityManager - - cancel(challenge: Uint8Array): void; - -**适配指导** - -异步接口以setProperty为例,示例代码如下: - -``` -import account_osAccount from "@ohos.account.osAccount" -userAuth.setProperty({ - authType: account_osAccount.AuthType.PIN, - key: account_osAccount.SetPropertyType.INIT_ALGORITHM, - setInfo: new Uint8Array([0]) -}, (err) => { - if (err) { - console.log("setProperty failed, error: " + JSON.stringify(err)); - } else { - console.log("setProperty successfully"); - } -}); - -userAuth.setProperty({ - authType: account_osAccount.AuthType.PIN, - key: account_osAccount.SetPropertyType.INIT_ALGORITHM, - setInfo: new Uint8Array([0]) -}).catch((err) => { - if (err) { - console.log("setProperty failed, error: " + JSON.stringify(err)); - } else { - console.log("setProperty successfully"); - } -}); -``` - -同步接口以registerInputer为例,示例代码如下: - -``` -import account_osAccount from "@ohos.account.osAccount" -let pinAuth = new account_osAccount.PINAuth() -let inputer = { - onGetData: (authType, passwordRecipient) => { - let password = new Uint8Array([0]); - passwordRecipient.onSetData(authType, password); - } -} -try { - pinAuth.registerInputer(inputer); -} catch (err) { - console.log("registerInputer failed, error: " + JSON.stringify(err)); -} -``` - -## cl.account_os_account.2 应用帐号鉴权服务ACTION定义变更 - -**变更影响** - -基于此前版本开发的应用,需适配修改应用配置文件(FA模型为config.json或Stage模型为module.json5)中的ACTION才能正常对外提供应用鉴权服务。 - -**关键接口/组件变更** - -涉及的常量: - -@ohos.ability.wantConstant.ACTION_APP_ACCOUNT_AUTH - -变更前: - -ACTION_APP_ACCOUNT_AUTH = "account.appAccount.action.auth" - -变更后: - -ACTION_APP_ACCOUNT_AUTH = "ohos.appAccount.action.auth" - -**适配指导** - -提供应用帐号鉴权服务的三方应用,需要在相关ServiceAbility的配置文件(FA模型为config.json或Stage模型为module.json5)中适配变更后的应用帐号认证ACTION,示例如下: -``` -"abilities": [ - { - "name": "ServiceAbility", - "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", - ... - "visible": true, - "skills": { - { - "actions": [ - "ohos.appAccount.action.auth" - ] - } - } - }] -} +# 帐号子系统ChangeLog + +## cl.account_os_account.1 帐号SystemAPI错误信息返回方式变更 + +已发布的部分帐号SystemAPI使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更: + +异步接口:通过AsyncCallback或Promise的error对象返回错误信息。 + +同步接口:通过抛出异常的方式返回错误信息。 + +**变更影响** + +基于此前版本开发的应用,需适配变更接口的错误信息返回方式,否则会影响原有业务逻辑。 + +**关键接口/组件变更** + +变更前: + - class UserAuth + - setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void; + - setProperty(request: SetPropertyRequest): Promise<number>; + - cancelAuth(contextID: Uint8Array): number; + - class PINAuth + - registerInputer(inputer: Inputer): boolean; + - UserIdentityManager + - cancel(challenge: Uint8Array): number; + +变更后: + - class UserAuth + - setProperty(request: SetPropertyRequest, callback: AsyncCallback<void>): void; + - setProperty(request: SetPropertyRequest): Promise<void>; + - cancelAuth(contextID: Uint8Array): void; + - class PINAuth + - registerInputer(inputer: Inputer): void; + - UserIdentityManager + - cancel(challenge: Uint8Array): void; + +**适配指导** + +异步接口以setProperty为例,示例代码如下: + +``` +import account_osAccount from "@ohos.account.osAccount" +userAuth.setProperty({ + authType: account_osAccount.AuthType.PIN, + key: account_osAccount.SetPropertyType.INIT_ALGORITHM, + setInfo: new Uint8Array([0]) +}, (err) => { + if (err) { + console.log("setProperty failed, error: " + JSON.stringify(err)); + } else { + console.log("setProperty successfully"); + } +}); + +userAuth.setProperty({ + authType: account_osAccount.AuthType.PIN, + key: account_osAccount.SetPropertyType.INIT_ALGORITHM, + setInfo: new Uint8Array([0]) +}).catch((err) => { + if (err) { + console.log("setProperty failed, error: " + JSON.stringify(err)); + } else { + console.log("setProperty successfully"); + } +}); +``` + +同步接口以registerInputer为例,示例代码如下: + +``` +import account_osAccount from "@ohos.account.osAccount" +let pinAuth = new account_osAccount.PINAuth() +let inputer = { + onGetData: (authType, passwordRecipient) => { + let password = new Uint8Array([0]); + passwordRecipient.onSetData(authType, password); + } +} +try { + pinAuth.registerInputer(inputer); +} catch (err) { + console.log("registerInputer failed, error: " + JSON.stringify(err)); +} +``` + +## cl.account_os_account.2 应用帐号鉴权服务ACTION定义变更 + +**变更影响** + +基于此前版本开发的应用,需适配修改应用配置文件(FA模型为config.json或Stage模型为module.json5)中的ACTION才能正常对外提供应用鉴权服务。 + +**关键接口/组件变更** + +涉及的常量: + +@ohos.ability.wantConstant.ACTION_APP_ACCOUNT_AUTH + +变更前: + +ACTION_APP_ACCOUNT_AUTH = "account.appAccount.action.auth" + +变更后: + +ACTION_APP_ACCOUNT_AUTH = "ohos.appAccount.action.auth" + +**适配指导** + +提供应用帐号鉴权服务的三方应用,需要在相关ServiceAbility的配置文件(FA模型为config.json或Stage模型为module.json5)中适配变更后的应用帐号认证ACTION,示例如下: +``` +"abilities": [ + { + "name": "ServiceAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + ... + "visible": true, + "skills": { + { + "actions": [ + "ohos.appAccount.action.auth" + ] + } + } + }] +} diff --git a/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.1/changelog-x-x.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.1/changelog-x-x.md new file mode 100644 index 0000000000000000000000000000000000000000..b20dbfc1fc13ba0dc94a8044119ac0ae2473cfb7 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.1/changelog-x-x.md @@ -0,0 +1,31 @@ +# xxx子系统ChangeLog + +相比最近一个发布版本(包括不限于LTS、Release、Beta、monthly版本)发生了影响契约兼容性(契约兼容:也称语义兼容,指版本演进后,开发者原有程序行为不发生变化)的变更(包括不限于接口名、参数、返回值、所需要的权限、调用顺序、枚举值、配置参数、路径等),则需要在ChangeLog中对变更进行阐述。 + +## cl.subsystemname.x xxx功能变更, 例:DeviceType属性变更、相机权限变更(尽量概括,不要超过15个字) + +每个变更标题前需要附加编号:cl.subsystemname.x。cl为ChangeLog首字母缩写,subsystemname请填写子系统英文标准名称,x表示变更序号(从低到高逐位增加,起始为1)。 +以功能维度对变更点进行概括描述。例如:xxx功能的xxx、xxx等发生了xxx变化,开发者需要根据以下说明对应用进行适配。 +如果有此变更有对应的需求或设计文档,可以在描述中附上对应的设计文档编号。 + +**变更影响** + +是否影响已发布的接口或者接口行为发生变更,影响的是JS接口还是Native接口。 +是否影响在此前版本已开发的应用,即应用是否需要进行适配动才可以在新版本SDK环境正常编译通过。 + +**关键的接口/组件变更** + +列举此功能变更涉及的接口/组件变更。 + +**适配指导(可选,不涉及则可以删除)** + +提供指导,帮助开发者针对相关变更进行适配,使应用可以与新版本兼容。 +例: +在xxx文件中将xxx参数修改为xxx。 + +``` +sample code +``` + + + diff --git a/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.2/changelog-x-x.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.2/changelog-x-x.md new file mode 100644 index 0000000000000000000000000000000000000000..b20dbfc1fc13ba0dc94a8044119ac0ae2473cfb7 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.2/changelog-x-x.md @@ -0,0 +1,31 @@ +# xxx子系统ChangeLog + +相比最近一个发布版本(包括不限于LTS、Release、Beta、monthly版本)发生了影响契约兼容性(契约兼容:也称语义兼容,指版本演进后,开发者原有程序行为不发生变化)的变更(包括不限于接口名、参数、返回值、所需要的权限、调用顺序、枚举值、配置参数、路径等),则需要在ChangeLog中对变更进行阐述。 + +## cl.subsystemname.x xxx功能变更, 例:DeviceType属性变更、相机权限变更(尽量概括,不要超过15个字) + +每个变更标题前需要附加编号:cl.subsystemname.x。cl为ChangeLog首字母缩写,subsystemname请填写子系统英文标准名称,x表示变更序号(从低到高逐位增加,起始为1)。 +以功能维度对变更点进行概括描述。例如:xxx功能的xxx、xxx等发生了xxx变化,开发者需要根据以下说明对应用进行适配。 +如果有此变更有对应的需求或设计文档,可以在描述中附上对应的设计文档编号。 + +**变更影响** + +是否影响已发布的接口或者接口行为发生变更,影响的是JS接口还是Native接口。 +是否影响在此前版本已开发的应用,即应用是否需要进行适配动才可以在新版本SDK环境正常编译通过。 + +**关键的接口/组件变更** + +列举此功能变更涉及的接口/组件变更。 + +**适配指导(可选,不涉及则可以删除)** + +提供指导,帮助开发者针对相关变更进行适配,使应用可以与新版本兼容。 +例: +在xxx文件中将xxx参数修改为xxx。 + +``` +sample code +``` + + + diff --git a/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.3/changelog-x-x.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.3/changelog-x-x.md new file mode 100644 index 0000000000000000000000000000000000000000..b20dbfc1fc13ba0dc94a8044119ac0ae2473cfb7 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.3/changelog-x-x.md @@ -0,0 +1,31 @@ +# xxx子系统ChangeLog + +相比最近一个发布版本(包括不限于LTS、Release、Beta、monthly版本)发生了影响契约兼容性(契约兼容:也称语义兼容,指版本演进后,开发者原有程序行为不发生变化)的变更(包括不限于接口名、参数、返回值、所需要的权限、调用顺序、枚举值、配置参数、路径等),则需要在ChangeLog中对变更进行阐述。 + +## cl.subsystemname.x xxx功能变更, 例:DeviceType属性变更、相机权限变更(尽量概括,不要超过15个字) + +每个变更标题前需要附加编号:cl.subsystemname.x。cl为ChangeLog首字母缩写,subsystemname请填写子系统英文标准名称,x表示变更序号(从低到高逐位增加,起始为1)。 +以功能维度对变更点进行概括描述。例如:xxx功能的xxx、xxx等发生了xxx变化,开发者需要根据以下说明对应用进行适配。 +如果有此变更有对应的需求或设计文档,可以在描述中附上对应的设计文档编号。 + +**变更影响** + +是否影响已发布的接口或者接口行为发生变更,影响的是JS接口还是Native接口。 +是否影响在此前版本已开发的应用,即应用是否需要进行适配动才可以在新版本SDK环境正常编译通过。 + +**关键的接口/组件变更** + +列举此功能变更涉及的接口/组件变更。 + +**适配指导(可选,不涉及则可以删除)** + +提供指导,帮助开发者针对相关变更进行适配,使应用可以与新版本兼容。 +例: +在xxx文件中将xxx参数修改为xxx。 + +``` +sample code +``` + + +