diff --git a/en/application-dev/application-test/arkxtest-guidelines.md b/en/application-dev/application-test/arkxtest-guidelines.md index ce7a28154635b724d127a50af801c74f84607402..5f4f36e78850272bc5101fa1b86e76f6e91d5f37 100644 --- a/en/application-dev/application-test/arkxtest-guidelines.md +++ b/en/application-dev/application-test/arkxtest-guidelines.md @@ -108,7 +108,7 @@ You write a UI test script based on the unit test framework, adding the invoking In this example, the UI test script is written based on the preceding unit test script. First, add the dependency package, as shown below: ```js -import {UiDriver,BY,UiComponent,MatchPattern} from '@ohos.uitest' +import {Driver,ON,Component,MatchPattern} from '@ohos.uitest' ``` Then, write specific test code. Specifically, implement the click action on the started application page and add checkpoint check cases. @@ -131,16 +131,16 @@ export default function abilityTest() { expect(Ability.context.abilityInfo.name).assertEqual('MainAbility'); }) //ui test code - //init uidriver - var driver = await UiDriver.create(); + //init driver + var driver = await Driver.create(); await driver.delayMs(1000); //find button by text 'Next' - var button = await driver.findComponent(BY.text('Next')); + var button = await driver.findComponent(ON.text('Next')); //click button await button.click(); await driver.delayMs(1000); //check text - await driver.assertComponentExist(BY.text('after click')); + await driver.assertComponentExist(ON.text('after click')); await driver.pressBack(); done(); }) diff --git a/en/application-dev/application-test/figures/Execute.PNG b/en/application-dev/application-test/figures/Execute.PNG index 90dcb55338ad473d29557e4c761801b16c770d45..0260b7983a13851dc1ef8e45928f952eb509a7d8 100644 Binary files a/en/application-dev/application-test/figures/Execute.PNG and b/en/application-dev/application-test/figures/Execute.PNG differ diff --git a/en/application-dev/device/Readme-EN.md b/en/application-dev/device/Readme-EN.md index 6e7fd27fd4506a487faeac457371c7c015a6b771..e3b30cb70e0cfb49e53391f497ae24727e959bee 100644 --- a/en/application-dev/device/Readme-EN.md +++ b/en/application-dev/device/Readme-EN.md @@ -1,4 +1,4 @@ -# Device +# Device Management - USB Service - [USB Service Overview](usb-overview.md) @@ -17,3 +17,5 @@ - Update Service - [Sample Server Overview](sample-server-overview.md) - [Sample Server Development](sample-server-guidelines.md) +- Stationary + - [stationary Development](stationary-guidelines.md) diff --git a/en/application-dev/device/stationary-guidelines.md b/en/application-dev/device/stationary-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..9f6693027a29f48c2c434b842df74beb5209f319 --- /dev/null +++ b/en/application-dev/device/stationary-guidelines.md @@ -0,0 +1,84 @@ +# Stationary Development + + +## When to Use + +An application can call the **Stationary** module to obtain the device status, for example, whether the device is absolutely or relatively still. + +For details about the APIs, see [Stationary](../reference/apis/js-apis-stationary.md). + +## Device Status Type Parameters + +| Name| Description| +| -------- | -------- | +| still | Absolutely still.| +| relativeStill | Relatively still.| + +## Parameters for Subscribing to Device Status events + +| Name | Value | Description | +| ------------------------------ | ---- | ---------------------------------------- | +| ENTER | 1 | Event indicating entering device status. | +| EXIT | 2 | Event indicating exiting device status.| +| ENTER_EXIT | 3 | Event indicating entering and exiting device status.| + +## Returned Device Status Parameters + +| Name | Value | Description | +| ------------------------------ | ---- | ---------------------------------------- | +| ENTER | 1 | Entering device status. | +| EXIT | 2 | Exiting device status.| + +## Available APIs + +| Module | Name | Description | +| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| ohos.stationary | on(activity: ActivityType, event: ActivityEvent, reportLatencyNs: number, callback: Callback<ActivityResponse>): void | Subscribes to the device status. This API uses an asynchronous callback to return the result.| +| ohos.stationary | once(activity: ActivityType, callback: Callback<ActivityResponse>): void | Obtains the device status. This API uses an asynchronous callback to return the result.| +| ohos.stationary | off(activity: ActivityType, event: ActivityEvent, callback?: Callback<ActivityResponse>): void | Unsubscribes from the device status. | + +## Constraints + +The device must support the acceleration sensor. + +## How to Develop + +1. Subscribe to the event indicating entering the absolute still state, and the event is reported every 1 second. + + ```js + import stationary from '@ohos.stationary'; + var reportLatencyNs = 1000000000; + try { + stationary.on('still', stationary.ActivityEvent.ENTER, reportLatencyNs, (data) => { + console.log('data='+ JSON.stringify(data)); + }) + } catch (err) { + console.error('errCode: ' + err.code + ' ,msg: ' + err.message); + } + ``` + +2. Obtain the event indicating entering the absolute still state. + + ```js + import stationary from '@ohos.stationary'; + try { + stationary.once('still', (data) => { + console.log('data='+ JSON.stringify(data)); + }) + } catch (err) { + console.error('errCode: ' + err.code + ' ,msg: ' + err.message); + } + ``` + +3. Unsubscribe from the event indicating entering the absolute still state. + + ```js + import stationary from '@ohos.stationary'; + try { + stationary.off('still', stationary.ActivityEvent.ENTER, (data) => { + console.log('data='+ JSON.stringify(data)); + }) + } catch (err) { + console.error('errCode: ' + err.code + ' ,msg: ' + err.message); + } + ``` diff --git a/en/application-dev/quick-start/resource-categories-and-access.md b/en/application-dev/quick-start/resource-categories-and-access.md index 56e8209a5c19e353a21b80ff8b34dd51885db310..aa5e53ae90c1794125f5b6ae8a8f7a5115128743 100644 --- a/en/application-dev/quick-start/resource-categories-and-access.md +++ b/en/application-dev/quick-start/resource-categories-and-access.md @@ -35,7 +35,7 @@ resources | Category | base Subdirectory | Qualifiers Subdirectory | rawfile Subdirectory | | ---- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | -| Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You need to create qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectories](#qualifiers-subdirectories).
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories). | You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** subdirectory will not be matched based on the device status.| +| Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You need to create qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectories](#qualifiers-subdirectories).
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** subdirectory will not be matched based on the device status.| | Compilation| Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | | Reference| Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the file path and file name. | @@ -81,9 +81,9 @@ You can create resource group subdirectories (including element, media, and prof | Resource Group Subdirectory | Description | Resource File | | ------- | ---------------------------------------- | ---------------------------------------- | -| element | Indicates element resources. Each type of data is represented by a JSON file. The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integers
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | -| media | Indicates media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. | -| profile | Indicates a user-defined configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. | The file name can be customized, for example, **test_profile.json**. | +| element | Indicates element resources. Each type of data is represented by a JSON file. (Only files are supported in this directory.) The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integers
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | +| media | Indicates media resources, including non-text files such as images, audios, and videos. (Only files are supported in this directory.) | The file name can be customized, for example, **icon.png**. | +| profile | Indicates a custom configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. (Only files are supported in this directory.) | The file name can be customized, for example, **test_profile.json**. | | rawfile | Indicates other types of files, which are stored in their raw formats after the application is built as an HAP file. They will not be integrated into the **resources.index** file.| The file name can be customized. | **Media Resource Types** @@ -229,7 +229,7 @@ When referencing resources in the **rawfile** subdirectory, use the **"$rawfile( > > Resource descriptors accept only strings, such as **'app.type.name'**, and cannot be combined. > -> The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md) API. +> The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md#getstringvalue9) API. In the **.ets** file, you can use the resources defined in the **resources** directory. The following is a resource usage example based on the resource file examples in [Resource Group Sub-directories](#resource-group-subdirectories): @@ -252,7 +252,6 @@ Text($r('app.string.message_arrive', "five'o clock")) Text($r('app.plural.eat_apple', 5, 5)) .fontColor($r('app.color.color_world')) .fontSize($r('app.float.font_world')) -} Image($r('app.media.my_background_image')) // Reference media resources. diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md index e3f7e1a1d16c11594e5652512617daa62f22588b..8c9e825557ee1d899e7004fb9109ff7b7ea7a5da 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle.md +++ b/en/application-dev/reference/apis/js-apis-Bundle.md @@ -156,7 +156,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => { > This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead. -getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise> +getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise\\> Obtains the information of all bundles of the specified user. This API uses a promise to return the result. @@ -199,7 +199,7 @@ bundle.getAllBundleInfo(bundleFlag, userId) > This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead. -getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback>): void +getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback\\>): void Obtains the information of all bundles of the current user. This API uses an asynchronous callback to return the result. @@ -236,7 +236,7 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => { > This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead. -getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void +getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback\\>): void Obtains the information of all bundles of the specified user. This API uses an asynchronous callback to return the result. @@ -822,7 +822,7 @@ bundle.getPermissionDef(permissionName).then((data) => { > This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead. -getAllApplicationInfo(bundleFlags: number, userId?: number): Promise> +getAllApplicationInfo(bundleFlags: number, userId?: number): Promise\\> Obtains the information about all applications of the specified user. This API uses a promise to return the result. @@ -864,7 +864,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId) > This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead. -getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback>): void +getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback\\>): void Obtains the information about all applications. This API uses an asynchronous callback to return the result. @@ -1320,7 +1320,7 @@ bundle.isApplicationEnabled(bundleName, (err, data) => { > This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead. -queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise> +queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise\\> Obtains the ability information based on given Want. This API uses a promise to return the result. @@ -1371,7 +1371,7 @@ bundle.queryAbilityByWant(want, bundleFlags, userId) > This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead. -queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback>): void +queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback\\>): void Obtains the ability information of the specified user based on given Want. This API uses an asynchronous callback to return the result. @@ -1416,7 +1416,7 @@ bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => { > This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead. -queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback>): void; +queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback\\>): void; Obtains the ability information based on given Want. This API uses an asynchronous callback to return the result. diff --git a/en/application-dev/reference/apis/js-apis-bundleManager.md b/en/application-dev/reference/apis/js-apis-bundleManager.md index cac8e51923b2baf6f18f409f3538199b0bbef86d..1cef53613b8993c775bcaa6f7cef1c927bd43ee3 100644 --- a/en/application-dev/reference/apis/js-apis-bundleManager.md +++ b/en/application-dev/reference/apis/js-apis-bundleManager.md @@ -2215,7 +2215,7 @@ try { ### bundleManager.getProfileByAbility -getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback>): void; +getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\\>): void; Obtains the JSON strings of the configuration file based on the given module ame, ability name, and metadata name. This API uses an asynchronous callback to return the result. @@ -2266,7 +2266,7 @@ try { ### bundleManager.getProfileByAbility -getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise>; +getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\\>; Obtains the JSON strings of the configuration file based on the given module ame, ability name, and metadata name. This API uses a promise to return the result. @@ -2336,7 +2336,7 @@ try { ### bundleManager.getProfileByExtensionAbility -getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback>): void; +getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\\>): void; Obtains the JSON strings of the configuration file based on the given module ame, Extension ability name, and metadata name. This API uses an asynchronous callback to return the result. @@ -2386,7 +2386,7 @@ try { ### bundleManager.getProfileByExtensionAbility -getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise>; +getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\\>; Obtains the JSON strings of the configuration file based on the given module ame, Extension ability name, and metadata name. This API uses a promise to return the result. @@ -2658,7 +2658,6 @@ try { ### bundleManager.getApplicationInfoSync getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md); -getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md); Synchronously obtains the application information based on the given bundle name, application flags, and user ID. @@ -2709,6 +2708,42 @@ try { } ``` +### bundleManager.getApplicationInfoSync + +getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md); + +Synchronously obtains the application information based on the given bundle name and application flags. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------------- | -------------------------- | ---- | ----------------------------------------------------- | +| bundleName | string | Yes | Bundle name. | +| applicationFlags | [number](#applicationflag) | Yes | Type of the application information to obtain.| + +**Return value** + +| Type | Description | +| ----------------------------------------------------------- | ------------------------- | +| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + ```ts import bundleManager from '@ohos.bundle.bundleManager'; import hilog from '@ohos.hilog'; @@ -2726,7 +2761,6 @@ try { ### bundleManager.getBundleInfoSync getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId: number): [BundleInfo](js-apis-bundleManager-bundleInfo.md); -getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md); Synchronously obtains the bundle information based on the given bundle name, bundle flags, and user ID. @@ -2742,7 +2776,7 @@ Synchronously obtains the bundle information based on the given bundle name, bun | ----------- | ------ | ---- | -------------------------------------------------------- | | bundleName | string | Yes | Bundle name. | | bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.| -| userId | number | No | User ID. | +| userId | number | Yes | User ID. | **Return value** @@ -2777,6 +2811,42 @@ try { } ``` +### bundleManager.getBundleInfoSync + +getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md); + +Synchronously obtains the bundle information based on the given bundle name and bundle flags. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | --------------------- | ---- | ------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.| + +**Return value** + +| Type | Description | +| ------------------------------------------------- | -------------------- | +| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + ```ts import bundleManager from '@ohos.bundle.bundleManager'; import hilog from '@ohos.hilog'; @@ -2789,3 +2859,37 @@ try { hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', err.message); } ``` + +## ModuleType + +Enumerates the module types. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Value | Description | +| ------- | ---- | -------------------- | +| ENTRY | 1 | Main module of the application. | +| FEATURE | 2 | Dynamic feature module of the application.| +| SHARED | 3 | Dynamic shared library module of the application. | + +## BundleType + +Enumerates the bundle types. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Value | Description | +| -------------- | ---- | --------------- | +| APP | 0 | The bundle is a common application. | +| ATOMIC_SERVICE | 1 | The bundle is an atomic service.| + +## AtomicServiceModuleType + +Enumerates the module types of an atomic service. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Value | Description | +| ------ | ---- | --------------------------- | +| NORMAL | 0 | Page package in the atomic service. | +| MAIN | 1 | Landing page package in the atomic service.| diff --git a/en/application-dev/reference/apis/js-apis-bundleMonitor.md b/en/application-dev/reference/apis/js-apis-bundleMonitor.md index 11f54832d6556e24f35cd1baedee0d9abfe39079..b1601cfc665bc6b96364d9c9508b197137e52746 100644 --- a/en/application-dev/reference/apis/js-apis-bundleMonitor.md +++ b/en/application-dev/reference/apis/js-apis-bundleMonitor.md @@ -33,7 +33,7 @@ For details, see [Permission Levels](../../security/accesstoken-overview.md). ## bundleMonitor.on -on(type: BundleChangedEvent, callback: callback\): void; +on(type: BundleChangedEvent, callback: Callback\): void; Subscribes to bundle installation, uninstall, and update events. @@ -66,7 +66,7 @@ try { ## bundleMonitor.off -off(type: BundleChangedEvent, callback?: callback\): void; +off(type: BundleChangedEvent, callback?: Callback\): void; Unsubscribes from bundle installation, uninstall, and update events. diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index 67ab51ad1c84efd92125858cef5c1009b5b2392d..b2f7c32c5a1c513c7b910c3e61c612be7ea31731 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -477,10 +477,10 @@ Listens for camera status changes. This API uses an asynchronous callback to ret **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------------------- | ---- | --------- | -| type | string | Yes | Event type. The value is fixed at **'cameraStatus'**. The callback function returns the camera information, including the device and device status (available or unavailable). The event can be listened for only when a **CameraManager** instance is obtained.| -| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change. | +| Name | Type | Mandatory| Description | +| -------- | -----------------| ---- | --------- | +| type | string | Yes | Event type. The value is fixed at **'cameraStatus'**. The event can be listened for when a **CameraManager** instance is obtained. This event is triggered and the corresponding information is returned only when the device is enabled or disabled.| +| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change.| | **Example** @@ -505,8 +505,8 @@ This is a system API. | Name | Type | Mandatory| Description | | -------- | --------------- | ---- | --------- | -| type | string | Yes | Event type. The value is fixed at **'cameraMute'**. The callback function returns the mute status changes. The event can be listened for only when a **CameraManager** instance is obtained.| -| callback | AsyncCallback\ | Yes | Callback used to return the camera mute status. | +| type | string | Yes | Event type. The value is fixed at **'cameraMute'**, indicating the camera mute status. The event can be listened for when a **CameraManager** instance is obtained. This event is triggered and the status is returned when the camera is enabled or disabled.| +| callback | AsyncCallback\ | Yes | Callback used to return the mute status. The value **true** means that the camera is enabled, and **false** means that the camera is disabled. | **Example** @@ -728,7 +728,7 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul | Name | Type | Mandatory| Description | | -------- | -------------------------------- | --- | ------------------------------------------- | -| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns an error code, for example, an error code indicating that the device is unavailable or a conflict occurs. The event can be listened for only when a **CameraInput** instance is obtained.| +| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **CameraInput** instance is created. This event is triggered and the result is returned when an error occurs on the camera. For example, if the device is unavailable or a conflict occurs, the error information is returned.| | cameraDevice | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.| | callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | @@ -1392,7 +1392,7 @@ try { setMeteringPoint(point: Point): void -Sets the metering point for the device. +Sets the metering point, which is the center point of the metering rectangle. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1449,7 +1449,7 @@ try { setExposureBias(exposureBias: number): void -Sets an exposure compensation value for the device. +Sets an exposure compensation value (EV). Before the setting, you are advised to use **[getExposureBiasRange](#getexposurebiasrange)** to obtain the supported values. @@ -1591,7 +1591,7 @@ try { setFocusPoint(point: Point): void -Sets a focal point for the device. +Sets the focal point. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1698,7 +1698,7 @@ try { setZoomRatio(zoomRatio: number): void -Sets a zoom ratio for the device. +Sets a zoom ratio. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1850,7 +1850,7 @@ Listens for focus state changes. This API uses an asynchronous callback to retur | Name | Type | Mandatory| Description | | -------- | ----------------------------------------- | ---- | ------------------------ | -| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The callback function returns the focus state change. The event can be listened for only when the session is created.| +| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.| | callback | AsyncCallback<[FocusState](#focusstate)\> | Yes | Callback used to return the focus state change. | **Example** @@ -1873,7 +1873,7 @@ Listens for **CaptureSession** errors. This API uses a callback to return the er | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------------- | ---- | ------------------------------ | -| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns the error code corresponding to an error that occurs during the call of a **CaptureSession** API, for example, **beginConfig()**, **commitConfig()**, or **addInput()**.| +| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as **beginConfig()**, **commitConfig()**, and **addInput**.| | callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | **Example** @@ -2054,8 +2054,8 @@ Listens for preview frame start events. This API uses an asynchronous callback t | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | --------------------------------------- | -| type | string | Yes | Event type. The value is fixed at **'frameStart'**. The callback is invoked when the preview on the first frame starts. This event can be listened for only when a **previewOutput** instance is created.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| type | string | Yes | Event type. The value is fixed at **'frameStart'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and returned when the bottom layer starts exposure for the first time.| +| callback | AsyncCallback | Yes | Callback used to return the result. The preview starts as long as this event is returned. | **Example** @@ -2077,8 +2077,8 @@ Listens for preview frame end events. This API uses an asynchronous callback to | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------------------- | -| type | string | Yes | Event type. The value is fixed at **'frameEnd'**. The callback is invoked when the preview on the last frame ends. This event can be listened for only when a **previewOutput** instance is created.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| type | string | Yes | Event type. The value is fixed at **'frameEnd'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and returned when the last frame of preview ends.| +| callback | AsyncCallback | Yes | Callback used to return the result. The preview ends as long as this event is returned. | **Example** @@ -2098,9 +2098,9 @@ Listens for **PreviewOutput** errors. This API uses a callback to return the err **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------------------------------- | ---- | ------------------------ | -| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns the error code corresponding to an error that occurs during the call of a **PreviewOutput** API, for example, **start()** or **release()**.| +| Name | Type | Mandatory| Description | +| -------- | --------------| ---- | ------------------------ | +| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the use of a preview-related API such as **start()** or **release()**.| | callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | **Example** @@ -2367,7 +2367,7 @@ Listens for shooting start events. This API uses an asynchronous callback to ret | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **'captureStart'**. The callback function returns the shooting start event.| +| type | string | Yes | Event type. The value is fixed at **'captureStart'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and returned when the bottom layer starts exposure each time a photo is taken.| | callback | AsyncCallback | Yes | Callback used to return the capture ID. | **Example** @@ -2388,10 +2388,10 @@ Listens for frame shutter events. This API uses an asynchronous callback to retu **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------------------- | --- | ------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **'frameShutter'**. The callback function returns the captured frame information (captureId and time).| -| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | ---------- | --- | ------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **'frameShutter'**. The event can be listened for when a **photoOutput** instance is created.| +| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | Yes | Callback used to return the result. A new photographing request can be delivered as long as this event is returned. | **Example** @@ -2412,9 +2412,9 @@ Listens for shooting end events. This API uses an asynchronous callback to retur **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------- | ---- | ---------------------------------------- | -| type | string | Yes | Event type. The value is fixed at **'captureEnd'**. The callback function returns the shooting end event.| +| Name | Type | Mandatory| Description | +| -------- | --------------- | ---- | ---------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'captureEnd'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and the corresponding information is returned when the photographing is complete.| | callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | Yes | Callback used to return the result. | **Example** @@ -2436,9 +2436,9 @@ Listens for **PhotoOutput** errors. This API uses a callback to return the error **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------------------- | ---- | ----------------------------------- | -| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns an error code when an API call fails.| +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | ----------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a photographing-related API.| | callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | **Example** @@ -2638,8 +2638,8 @@ Listens for video recording start events. This API uses an asynchronous callback | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ----------------------------------------- | -| type | string | Yes | Event type. The value is fixed at **'frameStart'**. The callback is invoked when the recording on the first frame of an image starts.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| type | string | Yes | Event type. The value is fixed at **'frameStart'**. The event can be listened for when a **videoOutput** instance is created. The event is triggered and the corresponding information is returned when the bottom layer starts exposure for the first time.| +| callback | AsyncCallback | Yes | Callback used to return the result. The recording starts as long as this event is returned. | **Example** @@ -2661,8 +2661,8 @@ Listens for video recording stop events. This API uses an asynchronous callback | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **'frameEnd'**. The callback is invoked when the recording on the last frame of an image stops.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| type | string | Yes | Event type. The value is fixed at **'frameEnd'**. The event can be listened for when a **videoOutput** instance is created. This event is triggered and returned when the last frame of recording is complete.| +| callback | AsyncCallback | Yes | Callback used to return the result. The recording ends as long as this event is returned. | **Example** @@ -2682,9 +2682,9 @@ Listens for errors that occur during video recording. This API uses a callback t **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------ | ---- | -------------------------------------- | -| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns the error code corresponding to an error that occurs during the call of a **VideoOutput** API, for example, **start()** or **release()**.| +| Name | Type | Mandatory| Description | +| -------- | ----------- | ---- | -------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **videoOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a recording-related API such as **start()** and **release()**.| | callback | Callback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | **Example** @@ -2809,9 +2809,9 @@ Listens for metadata objects. This API uses an asynchronous callback to return t **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------ | ---- | ------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **'metadataObjectsAvailable'**. The callback function returns the valid metadata. This event can be listened for only when a **MetadataOutput** instance is created.| +| Name | Type | Mandatory| Description | +| -------- | -------------- | ---- | ------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **'metadataObjectsAvailable'**. The event can be listened for when a **metadataOutput** instance is created. This event is triggered and the corresponding metadata is returned when valid metadata is detected.| | callback | Callback\> | Yes | Callback used to return the metadata.| **Example** @@ -2832,9 +2832,9 @@ Listens for metadata errors. This API uses an asynchronous callback to return th **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------ | ---- | --------------------------------------- | -| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns the error code corresponding to an error that occurs during the call of a **MetadataOutput** instance API, for example, **start()** or **release()**.| +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | --------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **metadataOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a metadata-related API such as **start()** and **release()**.| | callback | Callback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | **Example** diff --git a/en/application-dev/reference/apis/js-apis-installer.md b/en/application-dev/reference/apis/js-apis-installer.md index 4478dff76f73867213cc679f06fe5b574c6bccb4..bd6f57d3dc6e36f318a757c57aceae1b417b0f41 100644 --- a/en/application-dev/reference/apis/js-apis-installer.md +++ b/en/application-dev/reference/apis/js-apis-installer.md @@ -174,7 +174,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc | -------- | ------------------------------------------------------------ | | 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. | **Example** @@ -283,7 +282,7 @@ Defines the parameters that need to be specified for bundle installation, uninst | Name | Type | Mandatory | Description | | ------------------------------ | ------------------------------ | ------------------ | ------------------ | -| userId | number | Yes | User ID. You can use [queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#queryosaccountlocalidfromprocess9) to obtain the user of the current process.| +| userId | number | Yes | User ID. You can use [queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#getOsAccountLocalId) to obtain the user of the current process.| | installFlag | number | Yes | Installation flag. The value **0** means initial installation and **1** means overwrite installation.| | isKeepData | boolean | Yes | Whether to retain the data directory during bundle uninstall.| | hashParams | Array<[HashParam](#hashparam)> | Yes| Hash parameters. | diff --git a/en/application-dev/reference/apis/js-apis-system-package.md b/en/application-dev/reference/apis/js-apis-system-package.md index 5c562892d8f5d5a99423cb79a19478609612aed6..9644d0fa26cda69a6b035c0ba1e2bcbbc9f933dc 100644 --- a/en/application-dev/reference/apis/js-apis-system-package.md +++ b/en/application-dev/reference/apis/js-apis-system-package.md @@ -23,8 +23,6 @@ hasInstalled(options: CheckPackageHasInstalledOptions): void Checks whether an application exists, or whether a native application has been installed. -**Required permissions**: none - **System capability**: SystemCapability.BundleManager.BundleFramework **Parameters** diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001167001464.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001167001464.png index 5113bc6bad4f88bc2558aae304394e00e107ce88..8f997a0b5c76b206acacaf8f689e55f73bbaf20a 100644 Binary files a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001167001464.png and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001167001464.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001178875308.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001178875308.png index c085790c6651bf041b772f58f5665d442caf6f4a..ff15fe644562b95b868829af17e7be0068097a75 100644 Binary files a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001178875308.png and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001178875308.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001179035242.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001179035242.png index c7311ac9226ca3c0a04cef9a51961424daf8a47a..2c2f496c7af6589057af1ed24d69f22dc8b7e2d2 100644 Binary files a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001179035242.png and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001179035242.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001224354967.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001224354967.png index 7469c1e329fc86f0ca7eec9374be7c2c03ae2d6b..ad3d9f57521f89bdcbab75649447319bee650fa1 100644 Binary files a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001224354967.png and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001224354967.png differ diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md b/en/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md index 8df65d142a4129699c45f44b69c1c5f1fbe96829..ceefb977f290e2f59c5234c8e2eb99b61f0b9cd2 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md @@ -585,7 +585,7 @@ Fills a rectangle on the canvas. ```html
- +
``` @@ -621,7 +621,7 @@ Clears the content in a rectangle on the canvas. ```html
- +
``` @@ -1735,9 +1735,9 @@ Creates a radial gradient and returns a **CanvasGradient** object. // Radial gradient: inner circle(200,200,r:50) outer circle(200,200,r:200) var gradient = ctx.createRadialGradient(200,200,50, 200,200,200); // Add three color stops - gradient.addColorStop(0.0, 'red'); - gradient.addColorStop(0.5, 'white'); - gradient.addColorStop(1.0, 'green'); + gradient.addColorStop(0.0, '#ff0000'); + gradient.addColorStop(0.5, '#ffffff'); + gradient.addColorStop(1.0, '#00ff00'); // Set the fill style and draw a rectangle ctx.fillStyle = gradient; ctx.fillRect(0, 0, 500, 500); diff --git a/en/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md b/en/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md index 8eebde2cacb7dc2e2409a8c1f6a8274ac4e38390..4a5af8ca23f34f15e617c39f9a23b2024155b7d0 100644 --- a/en/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md @@ -95,12 +95,36 @@ Checks whether a specified point is in the path area. **Example** ```html -
- In path:{{textValue}} - +
+ In path:{{textValue}} +
``` +```css +/* xxx.css */ +.container { + display: flex; + flex-direction: column; + background-color: #F1F3F5; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; +} + +canvas { + width: 600px; + height: 600px; + background-color: #fdfdfd; + border: none; +} + +.textsize { + font-size: 40px; +} +``` + ```js // xxx.js export default { @@ -145,12 +169,36 @@ Checks whether a specified point is on the edge line of a path. **Example** ```html -
- In path:{{textValue}} - +
+ In stroke:{{textValue}} +
``` +```css +/* xxx.css */ +.container { + display: flex; + flex-direction: column; + background-color: #F1F3F5; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; +} + +canvas { + width: 600px; + height: 600px; + background-color: #fdfdfd; + border: none; +} + +.textsize { + font-size: 40px; +} +``` + ```js // xxx.js export default { @@ -181,12 +229,36 @@ resetTransform(): void **Example** ```html -
- In path:{{textValue}} - +
+ In path:{{textValue}} +
``` +```css +/* xxx.css */ +.container { + display: flex; + flex-direction: column; + background-color: #F1F3F5; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; +} + +canvas { + width: 600px; + height: 600px; + background-color: #fdfdfd; + border: none; +} + +.textsize { + font-size: 40px; +} +``` + ```js // xxx.js export default { diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777774.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777774.png index 60f430b646b45a3e3b16a9bb024e4a14e48bf4d3..24edbed60b52947c5effbba951a6523582603f30 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777774.png and b/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777774.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777775.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777775.png index 60f430b646b45a3e3b16a9bb024e4a14e48bf4d3..24edbed60b52947c5effbba951a6523582603f30 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777775.png and b/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777775.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777779.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777779.png index 4558b332925757d97d70ee57182c260804629346..24edbed60b52947c5effbba951a6523582603f30 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777779.png and b/en/application-dev/reference/arkui-ts/figures/en-us_image_000000127777779.png differ diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index bc16a8dd1638b0ad7e1538891707422c60d7ad2b..e4b6ba1ad47c9e06f3f26e6b47f4afd505b6aa36 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -36,7 +36,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Horizontal alignment of the text.
Default value: **TextAlign.Start**| | caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box. | | inputFilter8+ | {
value: [ResourceStr](ts-types.md#resourcestr),
error?: (value: string) => void
} | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The specified regular expression can match single characters, but not strings.
- **value**: regular expression to set.
- **error**: filtered-out content to return when regular expression matching fails.| -| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.| +| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.
If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.| ## Events diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index 8b4448a11cd29d2cc44f9b70a650f8a195e18bdd..aef50da2fed1f32ad0ceb82aecbf7006fcbae009 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -38,7 +38,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box. | | maxLength | number | Maximum number of characters in the text input. | | inputFilter8+ | {
value: [ResourceStr](ts-types.md#resourcestr),
error?: (value: string) => void
} | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The specified regular expression can match single characters, but not strings.
- **value**: regular expression to set.
- **error**: filtered-out content to return when regular expression matching fails.| -| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.| +| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.
If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.| | showPasswordIcon9+ | boolean | Whether to display the show password icon at the end of the password text box.
Default value: **true**| | style9+ | TextInputStyle | Text input style.
Default value: **TextInputStyle.Default**| | textAlign9+ | [TextAlign](ts-appendix-enums.md#textalign) | Alignment mode of the text in the text box.
Default value: **TextAlign.Start** | @@ -53,7 +53,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Next | The Enter key is labeled "Next."| | Done | The Enter key is labeled "Done." | -## InputType enums +## InputType | Name | Description | | ------------------ | ------------- | @@ -70,7 +70,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Default | Default style. The caret width is fixed at 1.5 vp, and the caret height is subject to the background height and font size of the selected text. | | Inline | Inline input style. The background height of the selected text is the same as the height of the text box. | -## Event +## Events In addition to the [universal events](ts-universal-events-click.md), the following events are supported. diff --git a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index b198676b1136bc19ff1c4bb0b266162478180339..f0fa614ed3781273928998927cf1bccd4c965efc 100644 --- a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -683,7 +683,7 @@ Fills a rectangle on the canvas. .height('100%') .backgroundColor('#ffff00') .onReady(() =>{ - this.context.fillRect(0,30,100,100) + this.context.fillRect(30,30,100,100) }) } .width('100%') @@ -769,7 +769,7 @@ Clears the content in a rectangle on the canvas. Canvas(this.context) .width('100%') .height('100%') - .backgroundColor('#ffffff') + .backgroundColor('#ffff00') .onReady(() =>{ this.context.fillStyle = 'rgb(0,0,255)' this.context.fillRect(20,20,200,200) @@ -1579,7 +1579,7 @@ struct Fill { region.lineTo(270, 90) region.closePath() // Fill path - this.context.fillStyle = 'green' + this.context.fillStyle = '#00ff00' this.context.fill(region, "evenodd") }) } @@ -1666,10 +1666,15 @@ struct Clip { .backgroundColor('#ffff00') .onReady(() =>{ let region = new Path2D() - region.rect(80,10,20,130) - region.rect(40,50,100,50) + region.moveTo(30, 90) + region.lineTo(110, 20) + region.lineTo(240, 130) + region.lineTo(60, 130) + region.lineTo(190, 20) + region.lineTo(270, 90) + region.closePath() this.context.clip(region,"evenodd") - this.context.fillStyle = "rgb(255,0,0)" + this.context.fillStyle = "rgb(0,255,0)" this.context.fillRect(0, 0, this.context.width, this.context.height) }) } @@ -1745,7 +1750,7 @@ Rotates a canvas clockwise around its coordinate axes. .height('100%') .backgroundColor('#ffff00') .onReady(() =>{ - this.context.rotate(45 * Math.PI / 180) // Rotate the rectangle 45 degrees + this.context.rotate(45 * Math.PI / 180) this.context.fillRect(70, 20, 50, 50) }) } @@ -1918,6 +1923,8 @@ setTransform(transform?: Matrix2D): void Resets the current transformation to the identity matrix, and then creates a new transformation matrix based on the specified **Matrix2D** object. This API is a void API. +Since API version 9, this API can be used for ArkTS widgets. + ### translate @@ -2413,7 +2420,7 @@ Restores the saved drawing context. .backgroundColor('#ffff00') .onReady(() =>{ this.context.save() // save the default state - this.context.fillStyle = "green" + this.context.fillStyle = "#00ff00" this.context.fillRect(20, 20, 100, 100) this.context.restore() // restore to the default state this.context.fillRect(150, 75, 100, 100) @@ -2451,7 +2458,7 @@ Saves all states of the canvas in the stack. This API is usually called when the .backgroundColor('#ffff00') .onReady(() =>{ this.context.save() // save the default state - this.context.fillStyle = "green" + this.context.fillStyle = "#00ff00" this.context.fillRect(20, 20, 100, 100) this.context.restore() // restore to the default state this.context.fillRect(150, 75, 100, 100) @@ -2498,9 +2505,9 @@ Creates a linear gradient. .backgroundColor('#ffff00') .onReady(() =>{ var grad = this.context.createLinearGradient(50,0, 300,100) - grad.addColorStop(0.0, 'red') - grad.addColorStop(0.5, 'white') - grad.addColorStop(1.0, 'green') + grad.addColorStop(0.0, '#ff0000') + grad.addColorStop(0.5, '#ffffff') + grad.addColorStop(1.0, '#00ff00') this.context.fillStyle = grad this.context.fillRect(0, 0, 500, 500) }) @@ -2549,9 +2556,9 @@ Creates a linear gradient. .backgroundColor('#ffff00') .onReady(() =>{ var grad = this.context.createRadialGradient(200,200,50, 200,200,200) - grad.addColorStop(0.0, 'red') - grad.addColorStop(0.5, 'white') - grad.addColorStop(1.0, 'green') + grad.addColorStop(0.0, '#ff0000') + grad.addColorStop(0.5, '#ffffff') + grad.addColorStop(1.0, '#00ff00') this.context.fillStyle = grad this.context.fillRect(0, 0, 500, 500) }) diff --git a/en/application-dev/reference/arkui-ts/ts-container-navigator.md b/en/application-dev/reference/arkui-ts/ts-container-navigator.md index e1d2c00f81527d3303b45031d858b76f9537099b..f5c24ce3043f17193050c767bcd8a55ee647779b 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-navigator.md +++ b/en/application-dev/reference/arkui-ts/ts-container-navigator.md @@ -27,9 +27,9 @@ Navigator(value?: {target: string, type?: NavigationType}) | Name | Description | | ------- | -------------------------- | -| Push | Navigates to a specified page in the application. | +| Push | Navigates to the specified page in the application. | | Replace | Replaces the current page with another one in the application and destroys the current page.| -| Back | Returns to the previous page or a specified page. | +| Back | Returns to the specified page. If the specified page does not exist in the stack, no response is returned. If no page is specified, the previous page is returned to.| ## Attributes diff --git a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index 0f7d462061595e1d78647dd6e93dbd0b18f6585e..452637137c4c6794b019eec436bf686af72394b1 100644 --- a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -727,7 +727,7 @@ Fills a rectangle on the canvas. .height('100%') .backgroundColor('#ffff00') .onReady(() =>{ - this.offContext.fillRect(0,30,100,100) + this.offContext.fillRect(30,30,100,100) var image = this.offContext.transferToImageBitmap() this.context.transferFromImageBitmap(image) }) @@ -1767,10 +1767,15 @@ struct Clip { .backgroundColor('#ffff00') .onReady(() =>{ let region = new Path2D() - region.rect(80,10,20,130) - region.rect(40,50,100,50) + region.moveTo(30, 90) + region.lineTo(110, 20) + region.lineTo(240, 130) + region.lineTo(60, 130) + region.lineTo(190, 20) + region.lineTo(270, 90) + region.closePath() this.offContext.clip(region,"evenodd") - this.offContext.fillStyle = "rgb(255,0,0)" + this.offContext.fillStyle = "rgb(0,255,0)" this.offContext.fillRect(0, 0, 600, 600) var image = this.offContext.transferToImageBitmap() this.context.transferFromImageBitmap(image) diff --git a/en/application-dev/ui/ui-js-components-path2d.md b/en/application-dev/ui/ui-js-components-path2d.md index 1684f70db7739dbfc6cfe68344a8b3972fad2d37..b6455c4ff2905c2a93e6ba6efffd7360a3872010 100644 --- a/en/application-dev/ui/ui-js-components-path2d.md +++ b/en/application-dev/ui/ui-js-components-path2d.md @@ -36,8 +36,6 @@ canvas { ```js // xxx.js -import promptAction from '@ohos.promptAction'; - export default { onShow() { let ctx = this.$refs.canvas.getContext('2d', { @@ -60,7 +58,7 @@ export default { path.closePath(); // Door path.moveTo(250, 450); - path.rect(250, 450, 350, 600); + path.rect(250, 450, 100, 600); path.closePath(); // Chimney path.moveTo(365, 250); @@ -139,8 +137,6 @@ text { ```js // xxx.js -import promptAction from '@ohos.promptAction'; - export default { data: { ctx: null, diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md b/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md index 625cdf71496ca71147a8501130de051f315416ce..cc4fd0d13fd0a7177018194c994dd376b50d2272 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md @@ -596,7 +596,7 @@ struct GridRowSample6 { **示例7:** -通过order属性,控制GridCol的顺序。在sm和md断点下,按照至6的顺序排列显示;在lg断点下,按照6至1的顺序排列显示。 +通过order属性,控制GridCol的顺序。在sm和md断点下,按照1至6的顺序排列显示;在lg断点下,按照6至1的顺序排列显示。 | sm | md | lg | diff --git a/zh-cn/application-dev/media/audio-capturer.md b/zh-cn/application-dev/media/audio-capturer.md index 74e09bf19f2d5e75acab07a2132bdf11a87556a6..451362be0bc16f24039f8aabea0c1bc7e12eb15f 100644 --- a/zh-cn/application-dev/media/audio-capturer.md +++ b/zh-cn/application-dev/media/audio-capturer.md @@ -21,38 +21,48 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ## 约束与限制 -开发者在进行音频数据采集功能开发前,需要先对所开发的应用配置麦克风权限(ohos.permission.MICROPHONE),权限配置相关内容可参考:[访问控制授权申请指导](../security/accesstoken-guidelines.md) +开发者在进行音频数据采集功能开发前,需要先对所开发的应用配置麦克风权限(ohos.permission.MICROPHONE),配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。 ## 开发指导 详细API含义可参考:[音频管理API文档AudioCapturer](../reference/apis/js-apis-audio.md#audiocapturer8) -1. 使用createAudioCapturer()创建一个AudioCapturer实例。 +1. 使用createAudioCapturer()创建一个全局的AudioCapturer实例。 在audioCapturerOptions中设置音频采集器的相关参数。该实例可用于音频采集、控制和获取采集状态,以及注册通知回调。 ```js - import audio from '@ohos.multimedia.audio'; - - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 // 0是音频采集器的扩展标志位,默认为0 - } - - let audioCapturerOptions = { - streamInfo: audioStreamInfo, - capturerInfo: audioCapturerInfo - } - - let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); - console.log('AudioRecLog: Create audio capturer success.'); + import audio from '@ohos.multimedia.audio'; + import fs from '@ohos.file.fs'; //便于步骤3 read函数调用 + + //音频渲染相关接口自测试 + @Entry + @Component + struct AudioRenderer { + @State message: string = 'Hello World' + private audioCapturer : audio.AudioCapturer; //供全局调用 + + async initAudioCapturer(){ + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 // 0是音频采集器的扩展标志位,默认为0 + } + + let audioCapturerOptions = { + streamInfo: audioStreamInfo, + capturerInfo: audioCapturerInfo + } + + this.audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); + console.log('AudioRecLog: Create audio capturer success.'); + } ``` 2. 调用start()方法来启动/恢复采集任务。 @@ -60,23 +70,18 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 启动完成后,采集器状态将变更为STATE_RUNNING,然后应用可以开始读取缓冲区。 ```js - import audio from '@ohos.multimedia.audio'; - - async function startCapturer() { - let state = audioCapturer.state; + async startCapturer() { + let state = this.audioCapturer.state; // Capturer start时的状态应该是STATE_PREPARED、STATE_PAUSED和STATE_STOPPED之一. - if (state != audio.AudioState.STATE_PREPARED || state != audio.AudioState.STATE_PAUSED || - state != audio.AudioState.STATE_STOPPED) { - console.info('Capturer is not in a correct state to start'); - return; - } - await audioCapturer.start(); - - state = audioCapturer.state; - if (state == audio.AudioState.STATE_RUNNING) { - console.info('AudioRecLog: Capturer started'); - } else { - console.error('AudioRecLog: Capturer start failed'); + if (state == audio.AudioState.STATE_PREPARED || state == audio.AudioState.STATE_PAUSED || + state == audio.AudioState.STATE_STOPPED) { + await this.audioCapturer.start(); + state = this.audioCapturer.state; + if (state == audio.AudioState.STATE_RUNNING) { + console.info('AudioRecLog: Capturer started'); + } else { + console.error('AudioRecLog: Capturer start failed'); + } } } ``` @@ -86,91 +91,88 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 参考以下示例,将采集到的数据写入文件。 ```js - import fs from '@ohos.file.fs'; - - let state = audioCapturer.state; - // 只有状态为STATE_RUNNING的时候才可以read. - if (state != audio.AudioState.STATE_RUNNING) { - console.info('Capturer is not in a correct state to read'); - return; - } - - const path = '/data/data/.pulse_dir/capture_js.wav'; // 采集到的音频文件存储路径 - let file = fs.openSync(filePath, 0o2); - let fd = file.fd; - if (file !== null) { - console.info('AudioRecLog: file created'); - } else { - console.info('AudioRecLog: file create : FAILED'); - return; - } - - if (fd !== null) { - console.info('AudioRecLog: file fd opened in append mode'); - } - - let numBuffersToCapture = 150; // 循环写入150次 - let count = 0; - while (numBuffersToCapture) { - let bufferSize = await audioCapturer.getBufferSize(); - let buffer = await audioCapturer.read(bufferSize, true); - let options = { - offset: count * this.bufferSize, - length: this.bufferSize + async readData(){ + let state = this.audioCapturer.state; + // 只有状态为STATE_RUNNING的时候才可以read. + if (state != audio.AudioState.STATE_RUNNING) { + console.info('Capturer is not in a correct state to read'); + return; } - if (typeof(buffer) == undefined) { - console.info('AudioRecLog: read buffer failed'); + const path = '/data/data/.pulse_dir/capture_js.wav'; // 采集到的音频文件存储路径 + let file = fs.openSync(path, 0o2); + let fd = file.fd; + if (file !== null) { + console.info('AudioRecLog: file created'); } else { - let number = fs.writeSync(fd, buffer, options); - console.info(`AudioRecLog: data written: ${number}`); - } - numBuffersToCapture--; - count++; + console.info('AudioRecLog: file create : FAILED'); + return; + } + if (fd !== null) { + console.info('AudioRecLog: file fd opened in append mode'); + } + let numBuffersToCapture = 150; // 循环写入150次 + let count = 0; + while (numBuffersToCapture) { + this.bufferSize = await this.audioCapturer.getBufferSize(); + let buffer = await this.audioCapturer.read(this.bufferSize, true); + let options = { + offset: count * this.bufferSize, + length: this.bufferSize + } + if (typeof(buffer) == undefined) { + console.info('AudioRecLog: read buffer failed'); + } else { + let number = fs.writeSync(fd, buffer, options); + console.info(`AudioRecLog: data written: ${number}`); + } + numBuffersToCapture--; + count++; + } } ``` 4. 采集完成后,调用stop方法,停止录制。 ```js - async function StopCapturer() { - let state = audioCapturer.state; - // 只有采集器状态为STATE_RUNNING或STATE_PAUSED的时候才可以停止 - if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) { - console.info('AudioRecLog: Capturer is not running or paused'); - return; - } - - await audioCapturer.stop(); - - state = audioCapturer.state; - if (state == audio.AudioState.STATE_STOPPED) { - console.info('AudioRecLog: Capturer stopped'); - } else { - console.error('AudioRecLog: Capturer stop failed'); - } - } + async StopCapturer() { + let state = this.audioCapturer.state; + // 只有采集器状态为STATE_RUNNING或STATE_PAUSED的时候才可以停止 + if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) { + console.info('AudioRecLog: Capturer is not running or paused'); + return; + } + + await this.audioCapturer.stop(); + + state = this.audioCapturer.state; + if (state == audio.AudioState.STATE_STOPPED) { + console.info('AudioRecLog: Capturer stopped'); + } else { + console.error('AudioRecLog: Capturer stop failed'); + } + } ``` 5. 任务结束,调用release()方法释放相关资源。 ```js - async function releaseCapturer() { - let state = audioCapturer.state; - // 采集器状态不是STATE_RELEASED或STATE_NEW状态,才能release - if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) { - console.info('AudioRecLog: Capturer already released'); - return; - } - - await audioCapturer.release(); - - state = audioCapturer.state; - if (state == audio.AudioState.STATE_RELEASED) { - console.info('AudioRecLog: Capturer released'); - } else { - console.info('AudioRecLog: Capturer release failed'); - } - } + async releaseCapturer() { + let state = this.audioCapturer.state; + // 采集器状态不是STATE_RELEASED或STATE_NEW状态,才能release + if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) { + console.info('AudioRecLog: Capturer already released'); + return; + } + + await this.audioCapturer.release(); + + state = this.audioCapturer.state; + if (state == audio.AudioState.STATE_RELEASED) { + console.info('AudioRecLog: Capturer released'); + } else { + console.info('AudioRecLog: Capturer release failed'); + } + } ``` 6. (可选)获取采集器相关信息 @@ -178,23 +180,20 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 通过以下代码,可以获取采集器的相关信息。 ```js - // 获取当前采集器状态 - let state = audioCapturer.state; - - // 获取采集器信息 - let audioCapturerInfo : audio.AuduioCapturerInfo = await audioCapturer.getCapturerInfo(); - - // 获取音频流信息 - let audioStreamInfo : audio.AudioStreamInfo = await audioCapturer.getStreamInfo(); - - // 获取音频流ID - let audioStreamId : number = await audioCapturer.getAudioStreamId(); - - // 获取纳秒形式的Unix时间戳 - let audioTime : number = await audioCapturer.getAudioTime(); - - // 获取合理的最小缓冲区大小 - let bufferSize : number = await audioCapturer.getBufferSize(); + async getAudioCapturerInfo(){ + // 获取当前采集器状态 + let state = this.audioCapturer.state; + // 获取采集器信息 + let audioCapturerInfo : audio.AudioCapturerInfo = await this.audioCapturer.getCapturerInfo(); + // 获取音频流信息 + let audioStreamInfo : audio.AudioStreamInfo = await this.audioCapturer.getStreamInfo(); + // 获取音频流ID + let audioStreamId : number = await this.audioCapturer.getAudioStreamId(); + // 获取纳秒形式的Unix时间戳 + let audioTime : number = await this.audioCapturer.getAudioTime(); + // 获取合理的最小缓冲区大小 + let bufferSize : number = await this.audioCapturer.getBufferSize(); + } ``` 7. (可选)使用on('markReach')方法订阅采集器标记到达事件,使用off('markReach')取消订阅事件。 @@ -202,12 +201,13 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 注册markReach监听后,当采集器采集的帧数到达设定值时,会触发回调并返回设定的值。 ```js - audioCapturer.on('markReach', (reachNumber) => { - console.info('Mark reach event Received'); - console.info(`The Capturer reached frame: ${reachNumber}`); - }); - - audioCapturer.off('markReach'); // 取消markReach事件的订阅,后续将无法监听到“标记到达”事件 + async markReach(){ + this.audioCapturer.on('markReach', 10, (reachNumber) => { + console.info('Mark reach event Received'); + console.info(`The Capturer reached frame: ${reachNumber}`); + }); + this.audioCapturer.off('markReach'); // 取消markReach事件的订阅,后续将无法监听到“标记到达”事件 + } ``` 8. (可选)使用on('periodReach')方法订阅采集器区间标记到达事件,使用off('periodReach')取消订阅事件。 @@ -215,40 +215,43 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 注册periodReach监听后,**每当**采集器采集的帧数到达设定值时,会触发回调并返回设定的值。 ```js - audioCapturer.on('periodReach', (reachNumber) => { - console.info('Period reach event Received'); - console.info(`In this period, the Capturer reached frame: ${reachNumber}`); - }); - - audioCapturer.off('periodReach'); // 取消periodReach事件的订阅,后续将无法监听到“区间标记到达”事件 + async periodReach(){ + this.audioCapturer.on('periodReach', 10, (reachNumber) => { + console.info('Period reach event Received'); + console.info(`In this period, the Capturer reached frame: ${reachNumber}`); + }); + this.audioCapturer.off('periodReach'); // 取消periodReach事件的订阅,后续将无法监听到“区间标记到达”事件 + } ``` 9. 如果应用需要在采集器状态更新时进行一些操作,可以订阅该事件,当采集器状态更新时,会受到一个包含有事件类型的回调。 ```js - audioCapturer.on('stateChange', (state) => { - console.info(`AudioCapturerLog: Changed State to : ${state}`) - switch (state) { - case audio.AudioState.STATE_PREPARED: - console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------'); - console.info('Audio State is : Prepared'); - break; - case audio.AudioState.STATE_RUNNING: - console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------'); - console.info('Audio State is : Running'); - break; - case audio.AudioState.STATE_STOPPED: - console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------'); - console.info('Audio State is : stopped'); - break; - case audio.AudioState.STATE_RELEASED: - console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------'); - console.info('Audio State is : released'); - break; - default: - console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------'); - console.info('Audio State is : invalid'); - break; - } - }); + async stateChange(){ + this.audioCapturer.on('stateChange', (state) => { + console.info(`AudioCapturerLog: Changed State to : ${state}`) + switch (state) { + case audio.AudioState.STATE_PREPARED: + console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------'); + console.info('Audio State is : Prepared'); + break; + case audio.AudioState.STATE_RUNNING: + console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------'); + console.info('Audio State is : Running'); + break; + case audio.AudioState.STATE_STOPPED: + console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------'); + console.info('Audio State is : stopped'); + break; + case audio.AudioState.STATE_RELEASED: + console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------'); + console.info('Audio State is : released'); + break; + default: + console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------'); + console.info('Audio State is : invalid'); + break; + } + }); + } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/media/audio-renderer.md b/zh-cn/application-dev/media/audio-renderer.md index 0599b33ab787febb7bfb7f3a38c0312d6cb35ba7..0f9436fc3b7d9e015d71869dc9739e7f5124e154 100644 --- a/zh-cn/application-dev/media/audio-renderer.md +++ b/zh-cn/application-dev/media/audio-renderer.md @@ -28,47 +28,59 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 详细API含义可参考:[音频管理API文档AudioRenderer](../reference/apis/js-apis-audio.md#audiorenderer8) -1. 使用createAudioRenderer()创建一个AudioRenderer实例。 +1. 使用createAudioRenderer()创建一个全局的AudioRenderer实例,以便后续步骤使用。 在audioRendererOptions中设置相关参数。该实例可用于音频渲染、控制和获取渲染状态,以及注册通知回调。 ```js - import audio from '@ohos.multimedia.audio'; - - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 // 0是音频渲染器的扩展标志位,默认为0 - } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - console.log("Create audio renderer success."); + import audio from '@ohos.multimedia.audio'; + import fs from '@ohos.file.fs'; + + //音频渲染相关接口自测试 + @Entry + @Component + struct AudioRenderer1129 { + private audioRenderer: audio.AudioRenderer; + private bufferSize;//便于步骤3 write函数调用使用 + private audioRenderer1: audio.AudioRenderer; //便于步骤14 完整示例调用使用 + private audioRenderer2: audio.AudioRenderer; //便于步骤14 完整示例调用使用 + + async initAudioRender(){ + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 // 0是音频渲染器的扩展标志位,默认为0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + this.audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + console.log("Create audio renderer success."); + } + } ``` 2. 调用start()方法来启动/恢复播放任务。 ```js - async function startRenderer() { - let state = audioRenderer.state; + async startRenderer() { + let state = this.audioRenderer.state; // Renderer start时的状态应该是STATE_PREPARED、STATE_PAUSED和STATE_STOPPED之一. if (state != audio.AudioState.STATE_PREPARED && state != audio.AudioState.STATE_PAUSED && - state != audio.AudioState.STATE_STOPPED) { + state != audio.AudioState.STATE_STOPPED) { console.info('Renderer is not in a correct state to start'); return; } - - await audioRenderer.start(); - - state = audioRenderer.state; + + await this.audioRenderer.start(); + + state = this.audioRenderer.state; if (state == audio.AudioState.STATE_RUNNING) { console.info('Renderer started'); } else { @@ -81,112 +93,97 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 3. 调用write()方法向缓冲区写入数据。 - 将需要播放的音频数据读入缓冲区,重复调用write()方法写入。 + 将需要播放的音频数据读入缓冲区,重复调用write()方法写入。请注意引入“import fs from '@ohos.file.fs';”,具体请参考步骤1。 ```js - import fs from '@ohos.file.fs'; - import audio from '@ohos.multimedia.audio'; - - async function writeBuffer(buf) { - // 写入数据时,渲染器的状态必须为STATE_RUNNING - if (audioRenderer.state != audio.AudioState.STATE_RUNNING) { - console.error('Renderer is not running, do not write'); - return; - } - let writtenbytes = await audioRenderer.write(buf); - console.info(`Actual written bytes: ${writtenbytes} `); - if (writtenbytes < 0) { - console.error('Write buffer failed. check the state of renderer'); - } - } - - // 此处是渲染器的合理的最小缓冲区大小(也可以选择其它大小的缓冲区) - const bufferSize = await audioRenderer.getBufferSize(); - let dir = globalThis.fileDir; //不可直接访问,没权限,切记!!!一定要使用沙箱路径 - const filePath = dir + '/file_example_WAV_2MG.wav'; // 需要渲染的音乐文件 实际路径为:/data/storage/el2/base/haps/entry/files/file_example_WAV_2MG.wav - console.info(`file filePath: ${ filePath}`); - - let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); - let stat = await fs.stat(filePath); //音乐文件信息 - let buf = new ArrayBuffer(bufferSize); - let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1); - for (let i = 0;i < len; i++) { - let options = { - offset: i * this.bufferSize, - length: this.bufferSize - } - let readsize = await fs.read(file.fd, buf, options) - let writeSize = await new Promise((resolve,reject)=>{ - this.audioRenderer.write(buf,(err,writeSize)=>{ - if(err){ - reject(err) - }else{ - resolve(writeSize) - } + async writeData(){ + // 此处是渲染器的合理的最小缓冲区大小(也可以选择其它大小的缓冲区) + this.bufferSize = await this.audioRenderer.getBufferSize(); + let dir = globalThis.fileDir; //不可直接访问,没权限,切记!!!一定要使用沙箱路径 + const filePath = dir + '/file_example_WAV_2MG.wav'; // 需要渲染的音乐文件 实际路径为:/data/storage/el2/base/haps/entry/files/file_example_WAV_2MG.wav + console.info(`file filePath: ${ filePath}`); + + let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); + let stat = await fs.stat(filePath); //音乐文件信息 + let buf = new ArrayBuffer(this.bufferSize); + let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1); + for (let i = 0;i < len; i++) { + let options = { + offset: i * this.bufferSize, + length: this.bufferSize + } + let readsize = await fs.read(file.fd, buf, options) + let writeSize = await new Promise((resolve,reject)=>{ + this.audioRenderer.write(buf,(err,writeSize)=>{ + if(err){ + reject(err) + }else{ + resolve(writeSize) + } + }) }) - }) + } + + fs.close(file) + await this.audioRenderer.stop(); //停止渲染 + await this.audioRenderer.release(); //释放资源 } - - fs.close(file) - await audioRenderer.stop(); //停止渲染 - await audioRenderer.release(); //释放资源 ``` 4. (可选)调用pause()方法或stop()方法暂停/停止渲染音频数据。 ```js - async function pauseRenderer() { - let state = audioRenderer.state; - // 只有渲染器状态为STATE_RUNNING的时候才能暂停 - if (state != audio.AudioState.STATE_RUNNING) { - console.info('Renderer is not running'); - return; - } - - await audioRenderer.pause(); - - state = audioRenderer.state; - if (state == audio.AudioState.STATE_PAUSED) { - console.info('Renderer paused'); - } else { - console.error('Renderer pause failed'); - } - } - - async function stopRenderer() { - let state = audioRenderer.state; - // 只有渲染器状态为STATE_RUNNING或STATE_PAUSED的时候才可以停止 - if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) { - console.info('Renderer is not running or paused'); - return; - } - - await audioRenderer.stop(); - - state = audioRenderer.state; - if (state == audio.AudioState.STATE_STOPPED) { - console.info('Renderer stopped'); - } else { - console.error('Renderer stop failed'); - } - } + async pauseRenderer() { + let state = this.audioRenderer.state; + // 只有渲染器状态为STATE_RUNNING的时候才能暂停 + if (state != audio.AudioState.STATE_RUNNING) { + console.info('Renderer is not running'); + return; + } + + await this.audioRenderer.pause(); + + state = this.audioRenderer.state; + if (state == audio.AudioState.STATE_PAUSED) { + console.info('Renderer paused'); + } else { + console.error('Renderer pause failed'); + } + } + + async stopRenderer() { + let state = this.audioRenderer.state; + // 只有渲染器状态为STATE_RUNNING或STATE_PAUSED的时候才可以停止 + if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) { + console.info('Renderer is not running or paused'); + return; + } + + await this.audioRenderer.stop(); + + state = this.audioRenderer.state; + if (state == audio.AudioState.STATE_STOPPED) { + console.info('Renderer stopped'); + } else { + console.error('Renderer stop failed'); + } + } ``` 5. (可选)调用drain()方法清空缓冲区。 ```js - async function drainRenderer() { - let state = audioRenderer.state; - // 只有渲染器状态为STATE_RUNNING的时候才能使用drain() - if (state != audio.AudioState.STATE_RUNNING) { - console.info('Renderer is not running'); - return; - } - - await audioRenderer.drain(); - - state = audioRenderer.state; + async drainRenderer() { + let state = this.audioRenderer.state; + // 只有渲染器状态为STATE_RUNNING的时候才能使用drain() + if (state != audio.AudioState.STATE_RUNNING) { + console.info('Renderer is not running'); + return; } + + await this.audioRenderer.drain(); + state = this.audioRenderer.state; + } ``` 6. 任务完成,调用release()方法释放相关资源。 @@ -194,23 +191,22 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 AudioRenderer会使用大量的系统资源,所以请确保完成相关任务后,进行资源释放。 ```js - async function releaseRenderer() { - let state = audioRenderer.state; - // 渲染器状态不是STATE_RELEASED或STATE_NEW状态,才能release - if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) { - console.info('Renderer already released'); - return; - } - - await audioRenderer.release(); + async releaseRenderer() { + let state = this.audioRenderer.state; + // 渲染器状态不是STATE_RELEASED或STATE_NEW状态,才能release + if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) { + console.info('Renderer already released'); + return; + } + await this.audioRenderer.release(); - state = audioRenderer.state; - if (state == audio.AudioState.STATE_RELEASED) { - console.info('Renderer released'); - } else { - console.info('Renderer release failed'); - } + state = this.audioRenderer.state; + if (state == audio.AudioState.STATE_RELEASED) { + console.info('Renderer released'); + } else { + console.info('Renderer release failed'); } + } ``` 7. (可选)获取渲染器相关信息 @@ -218,26 +214,22 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 通过以下代码,可以获取渲染器的相关信息。 ```js - // 获取当前渲染器状态 - let state = audioRenderer.state; - - // 获取渲染器信息 - let audioRendererInfo : audio.AudioRendererInfo = await audioRenderer.getRendererInfo(); - - // 获取音频流信息 - let audioStreamInfo : audio.AudioStreamInfo = await audioRenderer.getStreamInfo(); - - // 获取音频流ID - let audioStreamId : number = await audioRenderer.getAudioStreamId(); - - // 获取纳秒形式的Unix时间戳 - let audioTime : number = await audioRenderer.getAudioTime(); - - // 获取合理的最小缓冲区大小 - let bufferSize : number = await audioRenderer.getBufferSize(); - - // 获取渲染速率 - let renderRate : audio.AudioRendererRate = await audioRenderer.getRenderRate(); + async getRenderInfo(){ + // 获取当前渲染器状态 + let state = this.audioRenderer.state; + // 获取渲染器信息 + let audioRendererInfo : audio.AudioRendererInfo = await this.audioRenderer.getRendererInfo(); + // 获取音频流信息 + let audioStreamInfo : audio.AudioStreamInfo = await this.audioRenderer.getStreamInfo(); + // 获取音频流ID + let audioStreamId : number = await this.audioRenderer.getAudioStreamId(); + // 获取纳秒形式的Unix时间戳 + let audioTime : number = await this.audioRenderer.getAudioTime(); + // 获取合理的最小缓冲区大小 + let bufferSize : number = await this.audioRenderer.getBufferSize(); + // 获取渲染速率 + let renderRate : audio.AudioRendererRate = await this.audioRenderer.getRenderRate(); + } ``` 8. (可选)设置渲染器相关信息 @@ -245,17 +237,17 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 通过以下代码,可以设置渲染器的相关信息。 ```js - // 设置渲染速率为正常速度 - let renderRate : audio.AudioRendererRate = audio.AudioRendererRate.RENDER_RATE_NORMAL; - await audioRenderer.setRenderRate(renderRate); - - // 设置渲染器音频中断模式为SHARE_MODE - let interruptMode : audio.InterruptMode = audio.InterruptMode.SHARE_MODE; - await audioRenderer.setInterruptMode(interruptMode); - - // 设置一个流的音量为0.5 - let volume : number = 0.5; - await audioRenderer.setVolume(volume); + async setAudioRenderInfo(){ + // 设置渲染速率为正常速度 + let renderRate : audio.AudioRendererRate = audio.AudioRendererRate.RENDER_RATE_NORMAL; + await this.audioRenderer.setRenderRate(renderRate); + // 设置渲染器音频中断模式为SHARE_MODE + let interruptMode : audio.InterruptMode = audio.InterruptMode.SHARE_MODE; + await this.audioRenderer.setInterruptMode(interruptMode); + // 设置一个流的音量为0.5 + let volume : number = 0.5; + await this.audioRenderer.setVolume(volume); + } ``` 9. (可选)使用on('audioInterrupt')方法订阅渲染器音频中断事件,使用off('audioInterrupt')取消订阅事件。 @@ -269,45 +261,45 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 需要说明的是,本模块的订阅音频中断事件与[AudioManager](../reference/apis/js-apis-audio.md#audiomanager)模块中的on('interrupt')稍有不同。自api9以来,on('interrupt')和off('interrupt')均被废弃。在AudioRenderer模块,当开发者需要监听焦点变化事件时,只需要调用on('audioInterrupt')函数,当应用内部的AudioRenderer对象在start\stop\pause等动作发生时,会主动请求焦点,从而发生焦点转移,相关的AudioRenderer对象即可获取到对应的回调信息。但对除AudioRenderer的其他对象,例如FM、语音唤醒等,应用不会创建对象,此时可调用AudioManager中的on('interrupt')获取焦点变化通知。 ```js - audioRenderer.on('audioInterrupt', (interruptEvent) => { - console.info('InterruptEvent Received'); - console.info(`InterruptType: ${interruptEvent.eventType}`); - console.info(`InterruptForceType: ${interruptEvent.forceType}`); - console.info(`AInterruptHint: ${interruptEvent.hintType}`); - - if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { - switch (interruptEvent.hintType) { + async subscribeAudioRender(){ + this.audioRenderer.on('audioInterrupt', (interruptEvent) => { + console.info('InterruptEvent Received'); + console.info(`InterruptType: ${interruptEvent.eventType}`); + console.info(`InterruptForceType: ${interruptEvent.forceType}`); + console.info(`AInterruptHint: ${interruptEvent.hintType}`); + + if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { + switch (interruptEvent.hintType) { // 音频框架发起的强制暂停操作,为防止数据丢失,此时应该停止数据的写操作 - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - isPlay = false; - break; + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.info('isPlay is false'); + break; // 音频框架发起的强制停止操作,为防止数据丢失,此时应该停止数据的写操作 - case audio.InterruptHint.INTERRUPT_HINT_STOP: - isPlay = false; - break; + case audio.InterruptHint.INTERRUPT_HINT_STOP: + console.info('isPlay is false'); + break; // 音频框架发起的强制降低音量操作 - case audio.InterruptHint.INTERRUPT_HINT_DUCK: - break; + case audio.InterruptHint.INTERRUPT_HINT_DUCK: + break; // 音频框架发起的恢复音量操作 - case audio.InterruptHint.INTERRUPT_HINT_UNDUCK: - break; - } - } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { - switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_UNDUCK: + break; + } + } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { + switch (interruptEvent.hintType) { // 提醒App开始渲染 - case audio.InterruptHint.INTERRUPT_HINT_RESUME: - startRenderer(); - break; + case audio.InterruptHint.INTERRUPT_HINT_RESUME: + this.startRenderer(); + break; // 提醒App音频流被中断,由App自主决定是否继续(此处选择暂停) - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - isPlay = false; - pauseRenderer(); - break; + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.info('isPlay is false'); + this.pauseRenderer(); + break; + } } - } - }); - - audioRenderer.off('audioInterrupt'); // 取消音频中断事件的订阅,后续将无法监听到音频中断事件 + }); + } ``` 10. (可选)使用on('markReach')方法订阅渲染器标记到达事件,使用off('markReach')取消订阅事件。 @@ -315,12 +307,14 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 注册markReach监听后,当渲染器渲染的帧数到达设定值时,会触发回调并返回设定的值。 ```js - audioRenderer.on('markReach', (reachNumber) => { - console.info('Mark reach event Received'); - console.info(`The renderer reached frame: ${reachNumber}`); - }); - - audioRenderer.off('markReach'); // 取消markReach事件的订阅,后续将无法监听到“标记到达”事件 + async markReach(){ + this.audioRenderer.on('markReach', 50, (position) => { + if (position == 50) { + console.info('ON Triggered successfully'); + } + }); + this.audioRenderer.off('markReach'); // 取消markReach事件的订阅,后续将无法监听到“标记到达”事件 + } ``` 11. (可选)使用on('periodReach')方法订阅渲染器区间标记到达事件,使用off('periodReach')取消订阅事件。 @@ -328,12 +322,13 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 注册periodReach监听后,**每当**渲染器渲染的帧数到达设定值时,会触发回调并返回设定的值。 ```js - audioRenderer.on('periodReach', (reachNumber) => { - console.info('Period reach event Received'); - console.info(`In this period, the renderer reached frame: ${reachNumber} `); - }); - - audioRenderer.off('periodReach'); // 取消periodReach事件的订阅,后续将无法监听到“区间标记到达”事件 + async periodReach(){ + this.audioRenderer.on('periodReach',10, (reachNumber) => { + console.info(`In this period, the renderer reached frame: ${reachNumber} `); + }); + + this.audioRenderer.off('periodReach'); // 取消periodReach事件的订阅,后续将无法监听到“区间标记到达”事件 + } ``` 12. (可选)使用on('stateChange')方法订阅渲染器音频状态变化事件。 @@ -341,10 +336,12 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 注册stateChange监听后,当渲染器的状态发生改变时,会触发回调并返回当前渲染器的状态。 ```js - audioRenderer.on('stateChange', (audioState) => { - console.info('State change event Received'); - console.info(`Current renderer state is: ${audioState}`); - }); + async stateChange(){ + this.audioRenderer.on('stateChange', (audioState) => { + console.info('State change event Received'); + console.info(`Current renderer state is: ${audioState}`); + }); + } ``` 13. (可选)对on()方法的异常处理。 @@ -352,21 +349,24 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 在使用on()方法时,如果传入的字符串错误或传入的参数类型错误,程序会抛出异常,需要用try catch来捕获。 ```js - try { - audioRenderer.on('invalidInput', () => { // 字符串不匹配 - }) - } catch (err) { - console.info(`Call on function error, ${err}`); // 程序抛出401异常 - } - try { - audioRenderer.on(1, () => { // 入参类型错误 - }) - } catch (err) { - console.info(`Call on function error, ${err}`); // 程序抛出6800101异常 + async errorCall(){ + try { + this.audioRenderer.on('invalidInput', () => { // 字符串不匹配 + }) + } catch (err) { + console.info(`Call on function error, ${err}`); // 程序抛出401异常 + } + try { + this.audioRenderer.on(1, () => { // 入参类型错误 + }) + } catch (err) { + console.info(`Call on function error, ${err}`); // 程序抛出6800101异常 + } } ``` 14. (可选)on('audioInterrupt')方法完整示例。 + 请注意:在调用前声明audioRenderer1与audioRenderer2对象,具体请参考步骤1。 同一个应用中的AudioRender1和AudioRender2在创建时均设置了焦点模式为独立,并且调用on('audioInterrupt')监听焦点变化。刚开始AudioRender1拥有焦点,当AudioRender2获取到焦点时,audioRenderer1将收到焦点转移的通知,打印相关日志。如果AudioRender1和AudioRender2不将焦点模式设置为独立,则监听处理中的日志在应用运行过程中永远不会被打印。 ```js async runningAudioRender1(){ @@ -385,31 +385,31 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 streamInfo: audioStreamInfo, rendererInfo: audioRendererInfo } - + //1.1 创建对象 - audioRenderer1 = await audio.createAudioRenderer(audioRendererOptions); + this.audioRenderer1 = await audio.createAudioRenderer(audioRendererOptions); console.info("Create audio renderer 1 success."); - + //1.2 设置焦点模式为独立模式 :1 - audioRenderer1.setInterruptMode(1).then( data => { + this.audioRenderer1.setInterruptMode(1).then( data => { console.info('audioRenderer1 setInterruptMode Success!'); }).catch((err) => { console.error(`audioRenderer1 setInterruptMode Fail: ${err}`); }); - + //1.3 设置监听 - audioRenderer1.on('audioInterrupt', async(interruptEvent) => { + this.audioRenderer1.on('audioInterrupt', async(interruptEvent) => { console.info(`audioRenderer1 on audioInterrupt : ${JSON.stringify(interruptEvent)}`) }); - + //1.4 启动渲染 - await audioRenderer1.start(); + await this.audioRenderer1.start(); console.info('startAudioRender1 success'); - + //1.5 获取缓存区大小,此处是渲染器的合理的最小缓冲区大小(也可以选择其它大小的缓冲区) - const bufferSize = await audioRenderer1.getBufferSize(); + const bufferSize = await this.audioRenderer1.getBufferSize(); console.info(`audio bufferSize: ${bufferSize}`); - + //1.6 获取原始音频数据文件 let dir = globalThis.fileDir; //不可直接访问,没权限,切记!!!一定要使用沙箱路径 const path1 = dir + '/music001_48000_32_1.wav'; // 需要渲染的音乐文件 实际路径为:/data/storage/el2/base/haps/entry/files/music001_48000_32_1.wav @@ -418,14 +418,14 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 let stat = await fs.stat(path1); //音乐文件信息 let buf = new ArrayBuffer(bufferSize); let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1); - + //1.7 通过audioRender对缓存区的原始音频数据进行渲染 for (let i = 0;i < len; i++) { let options = { offset: i * this.bufferSize, length: this.bufferSize } - let readsize = await fs.read(file.fd, buf, options) + let readsize = await fs.read(file1.fd, buf, options) let writeSize = await new Promise((resolve,reject)=>{ this.audioRenderer1.write(buf,(err,writeSize)=>{ if(err){ @@ -434,13 +434,13 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 resolve(writeSize) } }) - }) + }) } fs.close(file1) - await audioRenderer1.stop(); //停止渲染 - await audioRenderer1.release(); //释放资源 + await this.audioRenderer1.stop(); //停止渲染 + await this.audioRenderer1.release(); //释放资源 } - + async runningAudioRender2(){ let audioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, @@ -457,31 +457,31 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 streamInfo: audioStreamInfo, rendererInfo: audioRendererInfo } - + //2.1 创建对象 - audioRenderer2 = await audio.createAudioRenderer(audioRendererOptions); + this.audioRenderer2 = await audio.createAudioRenderer(audioRendererOptions); console.info("Create audio renderer 2 success."); - + //2.2 设置焦点模式为独立模式 :1 - audioRenderer2.setInterruptMode(1).then( data => { + this.audioRenderer2.setInterruptMode(1).then( data => { console.info('audioRenderer2 setInterruptMode Success!'); }).catch((err) => { console.error(`audioRenderer2 setInterruptMode Fail: ${err}`); }); - + //2.3 设置监听 - audioRenderer2.on('audioInterrupt', async(interruptEvent) => { + this.audioRenderer2.on('audioInterrupt', async(interruptEvent) => { console.info(`audioRenderer2 on audioInterrupt : ${JSON.stringify(interruptEvent)}`) }); - + //2.4 启动渲染 - await audioRenderer2.start(); + await this.audioRenderer2.start(); console.info('startAudioRender2 success'); - + //2.5 获取缓存区大小 - const bufferSize = await audioRenderer2.getBufferSize(); + const bufferSize = await this.audioRenderer2.getBufferSize(); console.info(`audio bufferSize: ${bufferSize}`); - + //2.6 获取原始音频数据文件 let dir = globalThis.fileDir; //不可直接访问,没权限,切记!!!一定要使用沙箱路径 const path2 = dir + '/music002_48000_32_1.wav'; // 需要渲染的音乐文件 实际路径为:/data/storage/el2/base/haps/entry/files/music002_48000_32_1.wav @@ -490,14 +490,14 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 let stat = await fs.stat(path2); //音乐文件信息 let buf = new ArrayBuffer(bufferSize); let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1); - + //2.7 通过audioRender对缓存区的原始音频数据进行渲染 for (let i = 0;i < len; i++) { let options = { offset: i * this.bufferSize, length: this.bufferSize } - let readsize = await fs.read(file.fd, buf, options) + let readsize = await fs.read(file2.fd, buf, options) let writeSize = await new Promise((resolve,reject)=>{ this.audioRenderer2.write(buf,(err,writeSize)=>{ if(err){ @@ -506,28 +506,17 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 resolve(writeSize) } }) - }) + }) } fs.close(file2) - await audioRenderer2.stop(); //停止渲染 - await audioRenderer2.release(); //释放资源 + await this.audioRenderer2.stop(); //停止渲染 + await this.audioRenderer2.release(); //释放资源 } - - async writeBuffer(buf, audioRender) { - let writtenbytes; - await audioRender.write(buf).then((value) => { - writtenbytes = value; - console.info(`Actual written bytes: ${writtenbytes} `); - }); - if (typeof(writtenbytes) != 'number' || writtenbytes < 0) { - console.error('get Write buffer failed. check the state of renderer'); - } - } - + //综合调用入口 async test(){ - await runningAudioRender1(); - await runningAudioRender2(); + await this.runningAudioRender1(); + await this.runningAudioRender2(); } - + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index d32b9130b137ef42bedee53ba4bd476e1c5e0c9e..1be5984acb3886e647ebf709c03f2e3824dcdabb 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -126,7 +126,11 @@ - [@ohos.notification (Notification模块)(待停用)](js-apis-notification.md) - application - [EventHub](js-apis-inner-application-eventHub.md) - + - commonEvent + - [CommonEventData](js-apis-inner-commonEvent-commonEventData.md) + - [CommonEventPublishData](js-apis-inner-commonEvent-commonEventPublishData.md) + - [CommonEventSubscriber](js-apis-inner-commonEvent-commonEventSubscriber.md) + - [CommonEventSubscribeInfo](js-apis-inner-commonEvent-commonEventSubscribeInfo.md) - 包管理 - [@ohos.bundle.appControl (appControl模块)](js-apis-appControl.md) - [@ohos.bundle.bundleManager (bundleManager模块)](js-apis-bundleManager.md) 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 a147cdf9888d5fb9f2a864fc3745302c8bc04beb..da9ebd7910c30838f31cfa03dd995549846759cb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -4533,15 +4533,15 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav'; let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); let stat = await fs.stat(path); let buf = new ArrayBuffer(bufferSize); -let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1); +let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1); for (let i = 0;i < len; i++) { let options = { - offset: i * this.bufferSize, - length: this.bufferSize + offset: i * bufferSize, + length: bufferSize } let readsize = await fs.read(file.fd, buf, options) let writeSize = await new Promise((resolve,reject)=>{ - this.audioRenderer.write(buf,(err,writeSize)=>{ + audioRenderer.write(buf,(err,writeSize)=>{ if(err){ reject(err) }else{ @@ -4586,15 +4586,15 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav'; let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); let stat = await fs.stat(path); let buf = new ArrayBuffer(bufferSize); -let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1); +let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1); for (let i = 0;i < len; i++) { let options = { - offset: i * this.bufferSize, - length: this.bufferSize + offset: i * bufferSize, + length: bufferSize } let readsize = await fs.read(file.fd, buf, options) try{ - let writeSize = await this.audioRenderer.write(buf); + let writeSize = await audioRenderer.write(buf); } catch(err) { console.error(`audioRenderer.write err: ${err}`); } diff --git a/zh-cn/application-dev/reference/apis/js-apis-avsession.md b/zh-cn/application-dev/reference/apis/js-apis-avsession.md index 2c34a0244668b9b6bd9df550d095a47218f93f2d..c66da322f6c62a2e6746b440a60f29d18d80bfdc 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-avsession.md +++ b/zh-cn/application-dev/reference/apis/js-apis-avsession.md @@ -24,6 +24,8 @@ createAVSession(context: Context, tag: string, type: AVSessionType): Promise\ void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -531,6 +537,8 @@ off(type: 'sessionServiceDie', callback?: () => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -763,6 +771,8 @@ avSession.sendSystemControlCommand(avcommand, function (err) { **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + | 名称 | 类型 | 可读 | 可写 | 说明 | | :-------- | :----- | :--- | :--- | :---------------------------- | @@ -782,6 +792,8 @@ setAVMetadata(data: AVMetadata): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -836,6 +848,8 @@ setAVMetadata(data: AVMetadata, callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -887,6 +901,8 @@ setAVPlaybackState(state: AVPlaybackState): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -933,6 +949,8 @@ setAVPlaybackState(state: AVPlaybackState, callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -976,6 +994,8 @@ setLaunchAbility(ability: WantAgent): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1046,6 +1066,8 @@ setLaunchAbility(ability: WantAgent, callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1113,6 +1135,8 @@ getController(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -1147,6 +1171,8 @@ getController(callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1183,6 +1209,8 @@ getOutputDevice(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -1215,6 +1243,8 @@ getOutputDevice(callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1249,6 +1279,8 @@ activate(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -1281,6 +1313,8 @@ activate(callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1315,6 +1349,8 @@ deactivate(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -1349,6 +1385,8 @@ deactivate(callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1383,6 +1421,8 @@ destroy(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -1413,9 +1453,10 @@ destroy(callback: AsyncCallback\): void 销毁当前会话,使当前会话完全失效。结果通过callback异步回调方式返回。 - **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1450,6 +1491,8 @@ on(type: 'play'|'pause'|'stop'|'playNext'|'playPrevious'|'fastForward'|'rewind', **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1499,6 +1542,8 @@ on(type: 'seek', callback: (time: number) => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1530,6 +1575,8 @@ on(type: 'setSpeed', callback: (speed: number) => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1561,6 +1608,8 @@ on(type: 'setLoopMode', callback: (mode: LoopMode) => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1592,6 +1641,8 @@ on(type: 'toggleFavorite', callback: (assetId: string) => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1623,6 +1674,8 @@ on(type: 'handleKeyEvent', callback: (event: KeyEvent) => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1654,6 +1707,8 @@ on(type: 'outputDeviceChange', callback: (device: OutputDeviceInfo) => void): vo **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1685,6 +1740,8 @@ off(type: 'play' | 'pause' | 'stop' | 'playNext' | 'playPrevious' | 'fastForward **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1720,6 +1777,8 @@ off(type: 'seek', callback?: (time: number) => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1749,6 +1808,8 @@ off(type: 'setSpeed', callback?: (speed: number) => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1778,6 +1839,8 @@ off(type: 'setLoopMode', callback?: (mode: LoopMode) => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1807,6 +1870,8 @@ off(type: 'toggleFavorite', callback?: (assetId: string) => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1836,6 +1901,8 @@ off(type: 'handleKeyEvent', callback?: (event: KeyEvent) => void): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1865,6 +1932,8 @@ off(type: 'outputDeviceChange', callback?: (device: OutputDeviceInfo) => void): **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1896,6 +1965,7 @@ session.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 | 名称 | 类型 | 可读 | 可写 | 说明 | | :-------- | :----- | :--- | :--- | :-------------------------------------- | @@ -1920,6 +1990,8 @@ getAVPlaybackState(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -1952,6 +2024,8 @@ getAVPlaybackState(callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1986,6 +2060,8 @@ getAVMetadata(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -2018,6 +2094,8 @@ getAVMetadata(callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2052,6 +2130,8 @@ getOutputDevice(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -2083,6 +2163,8 @@ getOutputDevice(callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2117,6 +2199,8 @@ sendAVKeyEvent(event: KeyEvent): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2161,6 +2245,8 @@ sendAVKeyEvent(event: KeyEvent, callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2202,6 +2288,8 @@ getLaunchAbility(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -2237,6 +2325,8 @@ getLaunchAbility(callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2274,6 +2364,8 @@ getRealPlaybackPositionSync(): number **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -2302,6 +2394,8 @@ isActive(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -2335,6 +2429,8 @@ isActive(callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2370,6 +2466,8 @@ destroy(): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -2402,6 +2500,8 @@ destroy(callback: AsyncCallback\): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2436,6 +2536,8 @@ getValidCommands(): Promise\> **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **返回值:** | 类型 | 说明 | @@ -2469,6 +2571,8 @@ getValidCommands(callback: AsyncCallback\>): void **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2504,6 +2608,8 @@ sendControlCommand(command: AVControlCommand): Promise\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2557,6 +2663,8 @@ sendControlCommand(command: AVControlCommand, callback: AsyncCallback\): v **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2607,6 +2715,8 @@ on(type: 'metadataChange', filter: Array\ | 'all', callback: ( **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2644,6 +2754,8 @@ on(type: 'playbackStateChange', filter: Array\ | 'all', c **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2681,6 +2793,8 @@ on(type: 'sessionDestroy', callback: () => void) **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2712,6 +2826,8 @@ on(type: 'activeStateChange', callback: (isActive: boolean) => void) **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2743,6 +2859,8 @@ on(type: 'validCommandChange', callback: (commands: Array\ **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2775,6 +2893,8 @@ on(type: 'outputDeviceChange', callback: (device: OutputDeviceInfo) => void): vo **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2806,6 +2926,8 @@ off(type: 'metadataChange', callback?: (data: AVMetadata) => void) **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2834,6 +2956,8 @@ off(type: 'playbackStateChange', callback?: (state: AVPlaybackState) => void) **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2862,6 +2986,8 @@ off(type: 'sessionDestroy', callback?: () => void) **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2890,6 +3016,8 @@ off(type: 'activeStateChange', callback?: (isActive: boolean) => void) **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2918,6 +3046,8 @@ off(type: 'validCommandChange', callback?: (commands: Array\ void): **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2987,6 +3119,8 @@ controller.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口。 + | 名称 | 类型 | 说明 | | ----- | ------ | ---- | | audio | string | 音频 | @@ -3016,6 +3150,8 @@ controller.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + | 名称 | 类型 | 说明 | | -------------- | ------ | ------------ | | play | string | 播放 | @@ -3036,6 +3172,8 @@ controller.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + | 名称 | 类型 | 必填 | 说明 | | --------- | ------------------------------------------------- | ---- | -------------- | | command | [AVControlCommandType](#avcontrolcommandtype) | 是 | 命令 | @@ -3047,6 +3185,8 @@ controller.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + | 名称 | 类型 | 必填 | 说明 | | --------------- |-------------------------| ---- |---------------------------------------------------------------------| | assetId | string | 是 | 媒体ID。 | @@ -3071,6 +3211,8 @@ controller.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + | 名称 | 类型 | 必填 | 说明 | | ------------ | ------------------------------------- | ---- | ------- | | state | [PlaybackState](#playbackstate) | 否 | 播放状态 | @@ -3086,6 +3228,8 @@ controller.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + | 名称 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ------------------ | | elapsedTime | number | 是 | 已用时间,单位毫秒(ms)。 | @@ -3097,6 +3241,8 @@ controller.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + | 名称 | 类型 | 必填 | 说明 | | ---------- | -------------- | ---- | ---------------------- | | isRemote | boolean | 是 | 设备是否连接。 | @@ -3109,6 +3255,8 @@ controller.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + | 名称 | 值 | 说明 | | --------------------------- | ---- | ----------- | | PLAYBACK_STATE_INITIAL | 0 | 初始状态 | @@ -3126,6 +3274,8 @@ controller.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + | 名称 | 值 | 说明 | | ------------------ | ---- | -------- | | LOOP_MODE_SEQUENCE | 0 | 顺序播放 | @@ -3139,6 +3289,8 @@ controller.off('outputDeviceChange'); **系统能力:** SystemCapability.Multimedia.AVSession.Core +**系统接口:** 该接口为系统接口 + | 名称 | 值 | 说明 | | ------------------------------ | ------- | ------------------------------- | | ERR_CODE_SERVICE_EXCEPTION | 6600101 | Session service exception. | 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 c0d953dfd155000f859be1ad24b5d2fc1ecf1a5b..15103ae6cd763d2b54bb4c11955df34ad1be5325 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 @@ -188,8 +188,8 @@ bundle.getBundleInstaller().then(installer => { **示例:** ``` ts // Stage模型 -import Ability from '@ohos.application.Ability'; -class MainAbility extends Ability { +import UIAbility from '@ohos.app.ability.UIAbility'; +export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage) { let context = this.context; let pathDir = context.filesDir; 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 55635168340b262a37f109b58395a2280ea42293..e6f45e0b61932ac8decda26b0537c33b5f8724b4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md @@ -16,31 +16,37 @@ import cardEmulation from '@ohos.nfc.cardEmulation'; 定义不同的NFC卡模拟类型。 +> **说明:** +> 从 API version 6 开始支持,从 API version 9 开始废弃,建议使用[hasHceCapability](#hashcecapability9)替代。 + **系统能力:** SystemCapability.Communication.NFC.CardEmulation | 名称 | 值 | 说明 | | -------- | -------- | -------- | | HCE | 0 | HCE 卡模拟。 | | UICC | 1 | SIM 卡模拟。 | -| ESE | 2 | ESE卡模拟。 | +| ESE | 2 | ESE卡模拟。 | -## CardType +## CardType9+ -定义卡模拟应用是支付类型,还是非支付类型。 +定义卡模拟应用所使用的业务类型,是支付类型,还是其他类型。 **系统能力:** SystemCapability.Communication.NFC.CardEmulation | 名称 | 值 | 说明 | | -------- | -------- | -------- | -| PAYMENT | "payment" | 卡模拟应用是支付类型。 | -| OTHER | "other" | 卡模拟应用是非支付类型。 | +| PAYMENT | "payment" | 卡模拟应用所使用的业务是支付类型。 | +| OTHER | "other" | 卡模拟应用所使用的业务是其他类型。 | -## cardEmulation.isSupported +## isSupported isSupported(feature: number): boolean 是否支持某种类型的卡模拟。 +> **说明:** +> 从 API version 6 开始支持,从 API version 9 开始废弃,建议使用[hasHceCapability](#hashcecapability9)替代。 + **系统能力:** SystemCapability.Communication.NFC.CardEmulation **参数:** @@ -55,89 +61,44 @@ isSupported(feature: number): boolean | -------- | -------- | | boolean | true: 支持该类型卡模拟, false: 不支持该类型卡模拟。| -## cardEmulation.isDefaultService +## hasHceCapability9+ -isDefaultService(elementName: ElementName, type: CardType): boolean +hasHceCapability(): boolean -判断指定的应用是否为默认支付应用。 +判断是否支持HCE功能。 **系统能力:** SystemCapability.Communication.NFC.CardEmulation -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------- | -------- | ---- | ----------------------- | -| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | 是 | 应用的描述,由包名和组件名组成。 | -| type | [CardType](#cardtype) | 是 | 应用的描述,由包名和组件名组成。 | +**需要权限:** ohos.permission.NFC_CARD_EMULATION **返回值:** | **类型** | **说明** | | -------- | -------- | -| boolean | true: 是默认支付应用, false: 不是默认支付应用。| - -## HceService8+ +| boolean | true: 支持HCE, false: 不支持HCE。| -提供HCE卡模拟的实现,主要包括接收对端读卡设备的APDU数据,并响应APDU数据到对端读卡设备。使用HCE相关接口前,必须先判断设备是否支持HCE卡模拟能力。 +## isDefaultService9+ -### startHCE8+ +isDefaultService(elementName: ElementName, type: CardType): boolean -startHCE(aidList: string[]): boolean +判断指定的应用是否为指定业务类型的默认应用。 -启动HCE业务功能。包括设置当前应用为前台优先,动态注册AID列表。 +**系统能力:** SystemCapability.Communication.NFC.CardEmulation **需要权限:** ohos.permission.NFC_CARD_EMULATION -**系统能力:** SystemCapability.Communication.NFC.CardEmulation - **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------- | -------- | ---- | ----------------------- | -| aidList | string[] | 是 | 动态注册卡模拟的AID列表。 | - -### stopHCE8+ - -stopHCE(): boolean - -停止HCE业务功能。包括退出当前应用前台优先,释放动态注册的AID列表。 - -**需要权限:** ohos.permission.NFC_CARD_EMULATION - -**系统能力:** SystemCapability.Communication.NFC.CardEmulation - -### on8+ - -on(type: "hceCmd", callback: AsyncCallback): void; +| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | 是 | 应用的描述,由Bundle名称和组件名称组成。 | +| type | [CardType](#cardtype9) | 是 | 卡模拟业务类型。 | -订阅回调,用于接收对端读卡设备发送的APDU数据。 - -**需要权限:** ohos.permission.NFC_CARD_EMULATION - -**系统能力:** SystemCapability.Communication.NFC.CardEmulation - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------------- | -| type | string | 是 | 固定填"hceCmd"字符串。 | -| callback | AsyncCallback | 是 | 订阅的事件回调,入参是符合APDU协议的数据,每个number十六进制表示,范围是0x00~0xFF。 | - -### sendResponse8+ - -sendResponse(responseApdu: number[]): void; - -发送APDU数据到对端读卡设备。 - -**需要权限:** ohos.permission.NFC_CARD_EMULATION - -**系统能力:** SystemCapability.Communication.NFC.CardEmulation - -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | -------- | ---- | -------------------------------------------------- | -| responseApdu | number[] | 是 | 发送到对端读卡设备的符合APDU协议的数据,每个number十六进制表示,范围是0x00~0xFF。 | +| **类型** | **说明** | +| -------- | -------- | +| boolean | true: 是默认支付应用, false: 不是默认支付应用。| **示例:** @@ -150,31 +111,17 @@ if (!isHceSupported) { return; } +var hasHceCap = cardEmulation.hasHceCapability(); +if (!hasHceCap) { + console.log('this device hasHceCapability false, ignore it.'); + return; +} + var elementName = { "bundleName": "com.test.cardemulation", "abilityName": "com.test.cardemulation.MainAbility", }; var isDefaultService = cardEmulation.isDefaultService(elementName, cardEmulation.CardType.PAYMENT); console.log('is the app is default service for this card type: ' + isDefaultService); - -// device supports HCE, transimit APDU with remote nfc reader. -var hceService = new cardEmulation.HceService(); -hceService.startHCE([ - "F0010203040506", "A0000000041010" -]); - -hceService.on("hceCmd", (err, res) => { - if(err.data === 0) { - console.log('callback => Operation hceCmd succeeded. Data: ' + JSON.stringify(res)); - hceService.sendResponse([0x00,0xa4,0x04,0x00, - 0x0e,0x32,0x50,0x41,0x59,0x2e,0x53,0x59,0x53,0x2e,0x44,0x44, - 0x46,0x30,0x31,0x00]); - } else { - console.log('callback => Operation hceCmd failed. Cause: ' + err.data); - } -}) - -// stop HCE when the application exit the nfc card emulation. -hceService.stopHCE(); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md index 9941ef38f7e3690cb0d898a136b76c9227411708..0f40c6b4470077461507bc03429f739432627ca6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @@ -171,7 +171,7 @@ CommonEvent模块支持的事件类型。名称指的是系统公共事件宏; | COMMON_EVENT_SLOT_CHANGE9+ | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | 表示通知通道更新的动作。 | | COMMON_EVENT_SPN_INFO_CHANGED 9+ | usual.event.SPN_INFO_CHANGED | 无 | 表示spn显示信息已更新的公共事件的动作。 | | COMMON_EVENT_QUICK_FIX_APPLY_RESULT 9+ | usual.event.QUICK_FIX_APPLY_RESULT | 无 | 指示快速修复应用的动作。 | - +| COMMON_EVENT_USER_INFO_UPDATED9+ | usual.event.USER_INFO_UPDATED | 无 | 表示用户信息已更新。| ## CommonEvent.publish @@ -219,7 +219,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---------------------- | | event | string | 是 | 表示要发布的公共事件。 | -| options | [CommonEventPublishData](#commoneventpublishdata) | 是 | 表示发布公共事件的属性。 | +| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 | | callback | syncCallback\ | 是 | 表示被指定的回调方法。 | **示例:** @@ -303,7 +303,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca | -------- | ---------------------- | ---- | ---------------------- | | event | string | 是 | 表示要发布的公共事件。 | | userId | number | 是 | 表示指定向该用户ID发送此公共事件。 | -| options | [CommonEventPublishData](#commoneventpublishdata) | 是 | 表示发布公共事件的属性。 | +| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | **示例:** @@ -346,8 +346,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac | 参数名 | 类型 | 必填 | 说明 | | ------------- | ------------------------------------------------------------ | ---- | -------------------------- | -| subscribeInfo | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | 是 | 表示订阅信息。 | -| callback | AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | 是 | 表示创建订阅者的回调方法。 | +| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 | +| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 是 | 表示创建订阅者的回调方法。 | **示例:** @@ -388,12 +388,12 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\ | 返回订阅者对象。 | +| Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 返回订阅者对象。 | **示例:** @@ -428,8 +428,8 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\ | 是 | 表示接收公共事件数据的回调函数。 | +| subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 | +| callback | AsyncCallback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | 是 | 表示接收公共事件数据的回调函数。 | **示例:** @@ -480,7 +480,7 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): | 参数名 | 类型 | 必填 | 说明 | | ---------- | ----------------------------------------------- | ---- | ------------------------ | -| subscriber | [CommonEventSubscriber](#commoneventsubscriber) | 是 | 表示订阅者对象。 | +| subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 | | callback | AsyncCallback\ | 否 | 表示取消订阅的回调方法。 | **示例:** @@ -526,6 +526,7 @@ function unsubscribeCallBack(err) { //创建订阅者 CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack); +<<<<<<< HEAD //取消订阅公共事件 CommonEvent.unsubscribe(subscriber, unsubscribeCallBack); ``` @@ -1278,4 +1279,9 @@ subscriber.finishCommonEvent().then(() => { | publisherPermission | string | 是 | 否 | 表示发布者的权限。 | | publisherDeviceId | string | 是 | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID。 | | userId | number | 是 | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 | -| priority | number | 是 | 否 | 表示订阅者的优先级。值的范围是-100到1000。 | \ No newline at end of file +| priority | number | 是 | 否 | 表示订阅者的优先级。值的范围是-100到1000。 | +======= +// 取消订阅公共事件 +CommonEvent.unsubscribe(subscriber, unsubscribeCB); +``` +>>>>>>> a6c9265cd... common event docs fix diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md b/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md index dd47e484e156504cf2e276cdfa7dbc0590f31621..c7059bfaab20ed3baa1d049f7e98329e2e4fc088 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md @@ -235,7 +235,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---------------------- | | event | string | 是 | 表示要发布的公共事件。 | -| options | [CommonEventPublishData](#commoneventpublishdata) | 是 | 表示发布公共事件的属性。 | +| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 | | callback | syncCallback\ | 是 | 表示被指定的回调方法。 | **错误码:** @@ -344,7 +344,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca | -------- | ---------------------- | ---- | ---------------------- | | event | string | 是 | 表示要发布的公共事件。 | | userId | number | 是 | 表示指定向该用户ID发送此公共事件。 | -| options | [CommonEventPublishData](#commoneventpublishdata) | 是 | 表示发布公共事件的属性。 | +| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | **错误码:** @@ -399,8 +399,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac | 参数名 | 类型 | 必填 | 说明 | | ------------- | ------------------------------------------------------------ | ---- | -------------------------- | -| subscribeInfo | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | 是 | 表示订阅信息。 | -| callback | AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | 是 | 表示创建订阅者的回调方法。 | +| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 | +| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 是 | 表示创建订阅者的回调方法。 | **示例:** @@ -445,12 +445,12 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\ | 返回订阅者对象。 | +| Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 返回订阅者对象。 | **示例:** @@ -490,8 +490,8 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\ | 是 | 表示接收公共事件数据的回调函数。 | +| subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 | +| callback | AsyncCallback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | 是 | 表示接收公共事件数据的回调函数。 | **示例:** @@ -551,7 +551,7 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): | 参数名 | 类型 | 必填 | 说明 | | ---------- | ----------------------------------------------- | ---- | ------------------------ | -| subscriber | [CommonEventSubscriber](#commoneventsubscriber) | 是 | 表示订阅者对象。 | +| subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 | | callback | AsyncCallback\ | 否 | 表示取消订阅的回调方法。 | **示例:** @@ -606,6 +606,7 @@ try { } catch (err) { console.info("unsubscribe failed " + JSON.stringify(err)); } +<<<<<<< HEAD ``` ## CommonEventSubscriber @@ -1350,4 +1351,7 @@ subscriber.finishCommonEvent().then(() => { | publisherPermission | string | 是 | 否 | 表示发布者的权限。 | | publisherDeviceId | string | 是 | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID。 | | userId | number | 是 | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 | -| priority | number | 是 | 否 | 表示订阅者的优先级。值的范围是-100到1000。 | \ No newline at end of file +| priority | number | 是 | 否 | 表示订阅者的优先级。值的范围是-100到1000。 | +======= +``` +>>>>>>> a6c9265cd... common event docs fix diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md b/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md index bb8dd19192f6374d0f7026f3071d9db408386b5c..810e9c33f1153ef408bd1a5a1d21ddde10161503 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md @@ -30,7 +30,7 @@ getRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback<Rd | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | | config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | | callback | AsyncCallback<[RdbStore](#rdbstore)> | 是 | 指定callback回调函数,返回RdbStore对象。 | @@ -108,7 +108,7 @@ getRdbStore(context: Context, config: StoreConfig): Promise<RdbStore> | 参数名 | 类型 | 必填 | 说明 | | ------- | -------------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | | config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | **返回值**: @@ -188,7 +188,7 @@ deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void&g | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | | name | string | 是 | 数据库名称。 | | callback | AsyncCallback<void> | 是 | 指定callback回调函数。 | @@ -249,7 +249,7 @@ deleteRdbStore(context: Context, name: string): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------- | ------- | ---- | ------------------------------------------------------------ | -| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | | name | string | 是 | 数据库名称。 | **返回值**: @@ -363,6 +363,8 @@ class EntryAbility extends UIAbility { 描述订阅类型。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC + **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core | 名称 | 值 | 说明 | @@ -2430,9 +2432,9 @@ store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, r let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); predicates.inDevices(['12345678abcde']); let promise = store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates); -promise.then((resultSet) =>{ +promise.then((result) =>{ console.info(`Sync done.`); - for (let i = 0; i < resultSet.length; i++) { + for (let i = 0; i < result.length; i++) { console.info(`device= ${result[i][0]}, status= ${result[i][1]}`); } }).catch((err) => { @@ -2511,10 +2513,12 @@ try { 首先需要获取resultSet对象。 ```js +let resultSet = null; let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("AGE", 18); let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); -promise.then((resultSet) => { +promise.then((result) => { + resultSet = result; console.info(`resultSet columnNames: ${resultSet.columnNames}`); console.info(`resultSet columnCount: ${resultSet.columnCount}`); }); @@ -2685,7 +2689,7 @@ goToRow(position: number): boolean let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); promise.then((resultSet) => { - resultSet.(5); + resultSet.goToRow(5); resultSet.close(); }).catch((err) => { console.error(`query failed, err: ${err}`); diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md b/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md index 2f66868a47a28345d007b1320abbd349800f41d8..5c4b961d21119ad1d1870403730be3619a6d48fe 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md @@ -6,6 +6,7 @@ fileAccess模块是基于extension机制实现的一个对公共文件访问和 > >- 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 >- 本模块接口为系统接口,三方应用不支持调用,当前只支持filepicker、文件管理器调用。 +>- 本模块支持对错误码进行处理,错误码及其适配方式[参考文档](../errorcodes/errorcode-filemanagement.md#错误码适配指导)。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-i18n.md b/zh-cn/application-dev/reference/apis/js-apis-i18n.md index 44256b9542e9a4ce38a6b11475e6dcba71bb4f71..027ec927950fbb6f3193140966935dffdf41373e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-i18n.md +++ b/zh-cn/application-dev/reference/apis/js-apis-i18n.md @@ -1059,7 +1059,7 @@ constructor(country: string, options?: PhoneNumberFormatOptions) | 参数名 | 类型 | 必填 | 说明 | | ------- | ---------------------------------------- | ---- | ---------------- | | country | string | 是 | 表示电话号码所属国家或地区代码。 | -| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | 否 | 电话号码格式化对象的相关选项。 | +| options | [PhoneNumberFormatOptions](#phonenumberformatoptions9) | 否 | 电话号码格式化对象的相关选项。 | **示例:** ```js @@ -1149,7 +1149,7 @@ getLocationName(number: string, locale: string): string ``` -## PhoneNumberFormatOptions8+ +## PhoneNumberFormatOptions9+ 表示电话号码格式化对象可设置的属性。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md b/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md new file mode 100644 index 0000000000000000000000000000000000000000..e84f3b4abffbb032a8a79c489a780ad252158737 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md @@ -0,0 +1,11 @@ +# CommonEventData + +**系统能力:** `SystemCapability.Notification.CommonEvent` + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------- |-------------------- | ---- | ---- | ------------------------------------------------------- | +| event | string | 是 | 否 | 表示当前接收的公共事件名称。 | +| bundleName | string | 是 | 否 | 表示包名称。 | +| code | number | 是 | 否 | 表示公共事件的结果代码,用于传递int类型的数据。 | +| data | string | 是 | 否 | 表示公共事件的自定义结果数据,用于传递string类型的数据。 | +| parameters | {[key: string]: any} | 是 | 否 | 表示公共事件的附加信息。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md b/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md new file mode 100644 index 0000000000000000000000000000000000000000..9d5fe786465e99ce4e85c49310943df600ccb8e6 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md @@ -0,0 +1,13 @@ +# CommonEventPublishData + +**系统能力:** `SystemCapability.Notification.CommonEvent` + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------------- | -------------------- | ---- | ---- | ---------------------------- | +| bundleName | string | 是 | 否 | 表示包名称。 | +| code | number | 是 | 否 | 表示公共事件的结果代码。 | +| data | string | 是 | 否 | 表示公共事件的自定义结果数据。 | +| subscriberPermissions | Array\ | 是 | 否 | 表示订阅者的权限。 | +| isOrdered | boolean | 是 | 否 | 表示是否是有序事件。 | +| isSticky | boolean | 是 | 否 | 表示是否是粘性事件。仅系统应用或系统服务允许发送粘性事件。 | +| parameters | {[key: string]: any} | 是 | 否 | 表示公共事件的附加信息。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md b/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..6938b5351b61ab96cf8d87cc78fc3333af21cfa6 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md @@ -0,0 +1,11 @@ +# CommonEventSubscribeInfo + +**系统能力:** `SystemCapability.Notification.CommonEvent` + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | +| events | Array\ | 是 | 否 | 表示要发送的公共事件。 | +| publisherPermission | string | 是 | 否 | 表示发布者的权限。 | +| publisherDeviceId | string | 是 | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID。 | +| userId | number | 是 | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 | +| priority | number | 是 | 否 | 表示订阅者的优先级。值的范围是-100到1000。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md b/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md new file mode 100644 index 0000000000000000000000000000000000000000..411b63e250403b1f5ee916d273f5306c88cda65c --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md @@ -0,0 +1,750 @@ +# CommonEventSubscriber + +## getCode + +```ts +getCode(callback: AsyncCallback): void +``` + +以回调形式获取公共事件代码。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------ | +| callback | AsyncCallback\ | 是 | 公共事件代码。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//获取有序公共事件代码回调 +function getCodeCB(err, code) { + if (err.code) { + console.error(`getCode failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("getCode " + JSON.stringify(code)); + } +} +subscriber.getCode(getCodeCB); +``` + +## getCode + +```ts +getCode(): Promise +``` + +以Promise形式获取公共事件代码。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 公共事件代码。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.getCode().then((code) => { + console.info("getCode " + JSON.stringify(code)); +}).catch((err) => { + console.error(`getCode failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## setCode + +```ts +setCode(code: number, callback: AsyncCallback): void +``` + +以回调形式设置公共事件的代码。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------------- | +| code | number | 是 | 公共事件的代码。 | +| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的代码回调 +function setCodeCB(err) { + if (err.code) { + console.error(`setCode failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("setCode"); + } +} +subscriber.setCode(1, setCodeCB); +``` + +## setCode + +```ts +setCode(code: number): Promise +``` + +以Promise形式设置公共事件的代码。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| code | number | 是 | 公共事件的代码。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.setCode(1).then(() => { + console.info("setCode"); +}).catch((err) => { + console.error(`setCode failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## getData + +```ts +getData(callback: AsyncCallback): void +``` + +以回调形式获取公共事件的数据。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | -------------------- | +| callback | AsyncCallback\ | 是 | 公共事件的数据。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//获取有序公共事件代码数据回调 +function getDataCB(err, data) { + if (err.code) { + console.error(`getData failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("getData " + JSON.stringify(data)); + } +} +subscriber.getData(getDataCB); +``` + +## getData + +```ts +getData(): Promise +``` + +以Promise形式获取公共事件的数据。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------ | +| Promise\ | 公共事件的数据。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.getData().then((data) => { + console.info("getData " + JSON.stringify(data)); +}).catch((err) => { + console.error(`getData failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## setData + +setData(data: string, callback: AsyncCallback\): void + +以回调形式设置公共事件的数据。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| data | string | 是 | 公共事件的数据。 | +| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function setDataCB(err) { + if (err.code) { + console.error(`setCode failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("setData"); + } +} +subscriber.setData("publish_data_changed", setDataCB); +``` + +## setData + +```ts +setData(data: string): Promise +``` + +以Promise形式设置公共事件的果数据。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------- | +| data | string | 是 | 公共事件的数据。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.setData("publish_data_changed").then(() => { + console.info("setData"); +}).catch((err) => { + console.error(`setCode failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## setCodeAndData + +```ts +setCodeAndData(code: number, data: string, callback:AsyncCallback): void +``` + +以回调形式设置公共事件代码和数据。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------------- | +| code | number | 是 | 公共事件的代码。 | +| data | string | 是 | 公共事件的数据。 | +| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的代码和数据回调 +function setCodeDataCB(err) { + if (err.code) { + console.error(`setCodeAndData failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("setCodeDataCallback"); + } +} +subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB); +``` + +## setCodeAndData + +```ts +setCodeAndData(code: number, data: string): Promise +``` + +以Promise形式设置公共事件的代码和数据。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------- | +| code | number | 是 | 公共事件的代码。 | +| data | string | 是 | 公共事件的数据。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.setCodeAndData(1, "publish_data_changed").then(() => { + console.info("setCodeAndData"); +}).catch((err) => { + console.error(`setCodeAndData failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## isOrderedCommonEvent + +```ts +isOrderedCommonEvent(callback: AsyncCallback): void +``` + +以回调形式查询当前公共事件的是否为有序公共事件。 + +返回true代表是有序公共事件,false代表不是有序公共事件。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ---------------------------------- | +| callback | AsyncCallback\ | 是 | 当前公共事件的是否为有序公共事件。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//获取当前公共事件是否为有序事件的回调 +function isOrderedCB(err, isOrdered) { + if (err.code) { + console.error(`isOrderedCommonEvent failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("isOrdered " + JSON.stringify(isOrdered)); + } +} +subscriber.isOrderedCommonEvent(isOrderedCB); +``` + +## isOrderedCommonEvent + +```ts +isOrderedCommonEvent(): Promise +``` + +以Promise形式查询当前公共事件的是否为有序公共事件。 + +返回true代表是有序公共事件,false代表不是有序公共事件。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**返回值:** + +| 类型 | 说明 | +| ----------------- | -------------------------------- | +| Promise\ | 当前公共事件的是否为有序公共事件。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.isOrderedCommonEvent().then((isOrdered) => { + console.info("isOrdered " + JSON.stringify(isOrdered)); +}).catch((err) => { + console.error(`isOrdered failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## isStickyCommonEvent + +```ts +isStickyCommonEvent(callback: AsyncCallback): void +``` + +以回调形式检查当前公共事件是否为一个粘性事件。 + +返回true代表是粘性公共事件,false代表不是粘性公共事件。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ---------------------------------- | +| callback | AsyncCallback\ | 是 | 当前公共事件的是否为粘性公共事件。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//获取当前公共事件是否为粘性事件的回调 +function isStickyCB(err, isSticky) { + if (err.code) { + console.error(`isStickyCommonEvent failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("isSticky " + JSON.stringify(isSticky)); + } +} +subscriber.isStickyCommonEvent(isStickyCB); +``` + +## isStickyCommonEvent + +```ts +isStickyCommonEvent(): Promise +``` + +以Promise形式检查当前公共事件是否为一个粘性事件。 + +返回true代表是粘性公共事件,false代表不是粘性公共事件。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**返回值:** + +| 类型 | 说明 | +| ----------------- | -------------------------------- | +| Promise\ | 当前公共事件的是否为粘性公共事件。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.isStickyCommonEvent().then((isSticky) => { + console.info("isSticky " + JSON.stringify(isSticky)); +}).catch((err) => { + console.error(`isSticky failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## abortCommonEvent + +```ts +abortCommonEvent(callback: AsyncCallback): void +``` + +以回调形式取消当前的有序公共事件,取消后,有序公共事件不再向下一个订阅者传递。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback\ | 是 | 取消当前的有序公共事件。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//取消当前有序公共事件的回调 +function abortCB(err) { + if (err.code) { + console.error(`abortCommonEvent failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("abortCommonEvent"); + } +} +subscriber.abortCommonEvent(abortCB); +``` + +## abortCommonEvent + +```ts +abortCommonEvent(): Promise +``` + +以Promise形式取消当前的有序公共事件,取消后,公共事件不再向下一个订阅者传递。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.abortCommonEvent().then(() => { + console.info("abortCommonEvent"); +}).catch((err) => { + console.error(`abortCommonEvent failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## clearAbortCommonEvent + +```ts +clearAbortCommonEvent(callback: AsyncCallback): void +``` + +以回调形式清除当前有序公共事件。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//清除当前公共事件取消状态的回调 +function clearAbortCB(err) { + if (err.code) { + console.error(`clearAbortCommonEvent failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("clearAbortCommonEvent"); + } +} +subscriber.clearAbortCommonEvent(clearAbortCB); +``` + +## clearAbortCommonEvent + +```ts +clearAbortCommonEvent(): Promise +``` + +以Promise形式清除当前有序公共事件。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.clearAbortCommonEvent().then(() => { + console.info("clearAbortCommonEvent"); +}).catch((err) => { + console.error(`clearAbortCommonEvent failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## getAbortCommonEvent + +```ts +getAbortCommonEvent(callback: AsyncCallback): void +``` + +以回调形式获取当前有序公共事件是否取消的状态。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ---------------------------------- | +| callback | AsyncCallback\ | 是 | 表示当前有序公共事件是否取消的状态。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//获取当前有序公共事件是否取消的回调 +function getAbortCB(err, abortEvent) { + if (err.code) { + console.error(`getAbortCommonEvent failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("abortCommonEvent " + abortEvent) + } +} +subscriber.getAbortCommonEvent(getAbortCB); +``` + +## getAbortCommonEvent + +```ts +getAbortCommonEvent(): Promise +``` + +以Promise形式获取当前有序公共事件是否取消的状态。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ---------------------------------- | +| Promise\ | 表示当前有序公共事件是否取消的状态。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.getAbortCommonEvent().then((abortEvent) => { + console.info("abortCommonEvent " + JSON.stringify(abortEvent)); +}).catch((err) => { + console.error(`getAbortCommonEvent failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## getSubscribeInfo + +```ts +getSubscribeInfo(callback: AsyncCallback): void +``` + +以回调形式获取订阅者的订阅信息。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ---------------------- | +| callback | AsyncCallback\<[CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md)> | 是 | 表示订阅者的订阅信息。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//获取订阅者信息回调 +function getCB(err, subscribeInfo) { + if (err.code) { + console.error(`getSubscribeInfo failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("subscribeInfo " + JSON.stringify(subscribeInfo)); + } +} +subscriber.getSubscribeInfo(getCB); +``` + +## getSubscribeInfo + +```ts +getSubscribeInfo(): Promise +``` + +以Promise形式获取订阅者的订阅信息。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | ---------------------- | +| Promise\<[CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md)> | 表示订阅者的订阅信息。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.getSubscribeInfo().then((subscribeInfo) => { + console.info("subscribeInfo " + JSON.stringify(subscribeInfo)); +}).catch((err) => { + console.error(`getSubscribeInfo failed, code is ${err.code}, message is ${err.message}`); +}); +``` + +## finishCommonEvent9+ + +```ts +finishCommonEvent(callback: AsyncCallback): void +``` + +以回调形式结束当前有序公共事件。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------------------- | +| callback | AsyncCallback\ | 是 | 表示有序公共事件结束后的回调函数。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +//结束当前有序公共事件的回调 +function finishCB(err) { + if (err.code) { + console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`); +} else { + console.info("FinishCommonEvent"); +} + +subscriber.finishCommonEvent(finishCB); +``` + +## finishCommonEvent9+ + +```ts +finishCommonEvent(): Promise +``` + +以Promise形式结束当前有序公共事件。 + +**系统能力**:`SystemCapability.Notification.CommonEvent` + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```ts +let subscriber; //创建成功的订阅者对象 + +subscriber.finishCommonEvent().then(() => { + console.info("FinishCommonEvent"); +}).catch((err) => { + console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`); +}); +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-bundleOption.md b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-bundleOption.md new file mode 100644 index 0000000000000000000000000000000000000000..960e0e6957fbfb931ce0628c9c808041b045bc46 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-bundleOption.md @@ -0,0 +1,14 @@ +# BundleOption + +BundleOption模块为指定应用的包信息。 + +> **说明:** +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ------ |---- | ------ | +| bundle | string | 是 | 应用的包信息。 | +| uid | number | 否 | 用户ID。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md new file mode 100644 index 0000000000000000000000000000000000000000..d822600d6939bf2c981a1ddbd611d2d6672816ca --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md @@ -0,0 +1,16 @@ +# NotificationActionButton + +描述通知中显示的操作按钮。 + +> **说明:** +> +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ----------------------------------------------- | --- | ---- | ------------------------- | +| title | string | 是 | 是 | 按钮标题。 | +| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 点击按钮时触发的WantAgent。 | +| extras | { [key: string]: any } | 是 | 是 | 按钮扩展信息。 | +| userInput8+ | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | 是 | 是 | 用户输入对象实例。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md new file mode 100644 index 0000000000000000000000000000000000000000..be8496b25a4909e2c7f2796e7e98c1381b50dfe1 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md @@ -0,0 +1,77 @@ +# NotificationContent + +描述通知类型。 + +> **说明:** +> +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ | +| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | 是 | 是 | 通知内容类型。 | +| normal | [NotificationBasicContent](#notificationbasiccontent) | 是 | 是 | 基本类型通知内容。 | +| longText | [NotificationLongTextContent](#notificationlongtextcontent) | 是 | 是 | 长文本类型通知内容。 | +| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | 是 | 是 | 多行类型通知内容。 | +| picture | [NotificationPictureContent](#notificationpicturecontent) | 是 | 是 | 图片类型通知内容。 | + +## NotificationBasicContent + +描述普通文本通知。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | ------ | ---- | ---- | ---------------------------------- | +| title | string | 是 | 是 | 通知标题。 | +| text | string | 是 | 是 | 通知内容。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | + + +## NotificationLongTextContent + +描述长文本通知。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | ------ | ---- | --- | -------------------------------- | +| title | string | 是 | 是 | 通知标题。 | +| text | string | 是 | 是 | 通知内容。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | +| longText | string | 是 | 是 | 通知的长文本。 | +| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | +| expandedTitle | string | 是 | 是 | 通知展开时的标题。 | + + +## NotificationMultiLineContent + +描述多行文本通知。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | --------------- | --- | --- | -------------------------------- | +| title | string | 是 | 是 | 通知标题。 | +| text | string | 是 | 是 | 通知内容。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | +| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | +| longTitle | string | 是 | 是 | 通知展开时的标题。 | +| lines | Array\ | 是 | 是 | 通知的多行文本。 | + + +## NotificationPictureContent + +描述附有图片的通知。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | -------------- | ---- | --- | -------------------------------- | +| title | string | 是 | 是 | 通知标题。 | +| text | string | 是 | 是 | 通知内容。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | +| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | +| expandedTitle | string | 是 | 是 | 通知展开时的标题。 | +| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知的图片内容。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md new file mode 100644 index 0000000000000000000000000000000000000000..1dfc0990395386c786064be441c7c413d2fc744c --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md @@ -0,0 +1,29 @@ +# NotificationFlags + +描述通知标志的实例。 + +> **说明:** +> +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------------- | ---------------------- | ---- | ---- | --------------------------------- | +| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | 是 | 否 | 是否启用声音提示。 | +| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | 是 | 否 | 是否启用振动提醒功能。 | + + +## NotificationFlagStatus + +描述通知标志状态。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +**系统接口**:此接口为系统接口,三方应用不支持调用。 + +| 名称 | 值 | 说明 | +| -------------- | --- | --------------------------------- | +| TYPE_NONE | 0 | 默认标志。 | +| TYPE_OPEN | 1 | 通知标志打开。 | +| TYPE_CLOSE | 2 | 通知标志关闭。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md new file mode 100644 index 0000000000000000000000000000000000000000..9c37ecd7a7fa595eb456796051157c62cf30ae68 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md @@ -0,0 +1,63 @@ +# NotificationRequest + +描述通知的请求。 + +> **说明:** +> +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- | +| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | 是 | 是 | 通知内容。 | +| id | number | 是 | 是 | 通知ID。 | +| slotType | [SlotType](js-apis-notificationManager.md#slottype) | 是 | 是 | 通道类型。 | +| isOngoing | boolean | 是 | 是 | 是否进行时通知。 | +| isUnremovable | boolean | 是 | 是 | 是否可移除。 | +| deliveryTime | number | 是 | 是 | 通知发送时间。 | +| tapDismissed | boolean | 是 | 是 | 通知是否自动清除。 | +| autoDeletedTime | number | 是 | 是 | 自动清除的时间。 | +| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | WantAgent封装了应用的行为意图,点击通知时触发该行为。 | +| extraInfo | {[key: string]: any} | 是 | 是 | 扩展参数。 | +| color | number | 是 | 是 | 通知背景颜色。预留能力,暂未支持。 | +| colorEnabled | boolean | 是 | 是 | 通知背景颜色是否使能。预留能力,暂未支持。 | +| isAlertOnce | boolean | 是 | 是 | 设置是否仅有一次此通知提醒。 | +| isStopwatch | boolean | 是 | 是 | 是否显示已用时间。 | +| isCountDown | boolean | 是 | 是 | 是否显示倒计时时间。 | +| isFloatingIcon | boolean | 是 | 是 | 是否显示状态栏图标。 | +| label | string | 是 | 是 | 通知标签。 | +| badgeIconStyle | number | 是 | 是 | 通知角标类型。 | +| showDeliveryTime | boolean | 是 | 是 | 是否显示分发时间。 | +| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | 是 | 是 | 通知按钮,最多三个按钮。 | +| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知小图标。可选字段,大小不超过30KB。 | +| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知大图标。可选字段,大小不超过30KB。 | +| creatorBundleName | string | 是 | 否 | 创建通知的包名。 | +| creatorUid8+ | number | 是 | 否 | 创建通知的UID。 | +| creatorPid | number | 是 | 否 | 创建通知的PID。 | +| creatorUserId| number | 是 | 否 | 创建通知的UserId。 | +| hashCode | string | 是 | 否 | 通知唯一标识。 | +| classification | string | 是 | 是 | 通知分类。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| groupName8+ | string | 是 | 是 | 组通知名称。 | +| template8+ | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | 是 | 是 | 通知模板。 | +| isRemoveAllowed8+ | boolean | 是 | 否 | 通知是否能被移除。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| source8+ | number | 是 | 否 | 通知源。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| distributedOption8+ | [DistributedOptions](#distributedoptions) | 是 | 是 | 分布式通知的选项。 | +| deviceId8+ | string | 是 | 否 | 通知源的deviceId。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| notificationFlags8+ | [NotificationFlags](js-apis-inner-notification-notificationflags#notificationFlags) | 是 | 否 | 获取NotificationFlags。 | +| removalWantAgent9+ | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 当移除通知时,通知将被重定向到的WantAgent实例。 | +| badgeNumber9+ | number | 是 | 是 | 应用程序图标上显示的通知数。 | + + +## DistributedOptions + +描述分布式选项。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------------------- | -------------- | ---- | ---- | ---------------------------------- | +| isDistributed8+ | boolean | 是 | 是 | 是否为分布式通知。 | +| supportDisplayDevices8+ | Array\ | 是 | 是 | 可以同步通知到的设备列表。 | +| supportOperateDevices8+ | Array\ | 是 | 是 | 可以打开通知的设备列表。 | +| remindType8+ | number | 是 | 否 | 通知的提醒方式。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md new file mode 100644 index 0000000000000000000000000000000000000000..27d5aec3672ee7caa0eefd640153f3ee70514a3a --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md @@ -0,0 +1,24 @@ +# NotificationSlot + +描述通知槽 + +> **说明:** +> +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------------- | --------------------- | ---- | --- | ------------------------------------------ | +| type | [SlotType](js-apis-notificationManager.md#slottype) | 是 | 是 | 通道类型。 | +| level | number | 是 | 是 | 通知级别,不设置则根据通知渠道类型有默认值。 | +| desc | string | 是 | 是 | 通知渠道描述信息。 | +| badgeFlag | boolean | 是 | 是 | 是否显示角标。 | +| bypassDnd | boolean | 是 | 是 | 置是否在系统中绕过免打扰模式。 | +| lockscreenVisibility | number | 是 | 是 | 在锁定屏幕上显示通知的模式。 | +| vibrationEnabled | boolean | 是 | 是 | 是否可振动。 | +| sound | string | 是 | 是 | 通知提示音。 | +| lightEnabled | boolean | 是 | 是 | 是否闪灯。 | +| lightColor | number | 是 | 是 | 通知灯颜色。 | +| vibrationValues | Array\ | 是 | 是 | 通知振动样式。 | +| enabled9+ | boolean | 是 | 否 | 此通知插槽中的启停状态。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md new file mode 100644 index 0000000000000000000000000000000000000000..58e9d4442712e965f56d6837de8d9cbfef010544 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md @@ -0,0 +1,14 @@ +# NotificationTemplate + +通知模板。 + +> **说明:** +> +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---- | ---------------------- | ---- | ---- | ---------- | +| name | string | 是 | 是 | 模板名称。 | +| data | {[key:string]: Object} | 是 | 是 | 模板数据。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md new file mode 100644 index 0000000000000000000000000000000000000000..bc60f868ba6d787cbacf2b79e50102b7f06cb103 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md @@ -0,0 +1,13 @@ +# NotificationUserInput + +保存用户输入的通知消息。 + +> **说明:** +> +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +**系统能力**:SystemCapability.Notification.Notification + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ------ | --- | ---- | ----------------------------- | +| inputKey | string | 是 | 是 | 用户输入时用于标识此输入的key。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md index 3172154aacf3db947647566612a1d5e6736f1af0..a309cd10dc40f03482b744b2ee54b0df710d9be5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md @@ -51,7 +51,7 @@ this.context.destroy((err) => { ## InputMethodExtensionContext.destroy -destroy(): Promise; 停止输入法应用自身。通过Promise异步回调。 @@ -61,7 +61,7 @@ destroy(): Promise; | 无返回结果的Promise对象。 | **示例:** 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 6a36a1ef096a9c61f584a3dec9e6838a8971b1a2..2d4b2df2972a032f88224b7c96ded371fc3e843f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -1149,8 +1149,6 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void 显示输入法选择对话框。使用callback异步回调。 -**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。 - **系统能力:** SystemCapability.MiscServices.InputMethodFramework **参数:** @@ -1189,8 +1187,6 @@ showOptionalInputMethods(): Promise<boolean> 显示输入法选择对话框。使用promise异步回调。 -**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。 - **系统能力:** SystemCapability.MiscServices.InputMethodFramework **返回值:** 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 72f116c900e3921315385e2dab0d54dd277e6bec..2e1eab7f697c4dcb9a987819e88332fd0afabc80 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -708,7 +708,7 @@ hide(callback: AsyncCallback<void>): void | 错误码ID | 错误信息 | | -------- | -------------------------- | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -742,7 +742,7 @@ hide(): Promise<void> | 错误码ID | 错误信息 | | -------- | -------------------------- | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -837,7 +837,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void | 错误码ID | 错误信息 | | -------- | -------------------------- | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -886,7 +886,7 @@ sendKeyFunction(action: number): Promise<boolean> | 错误码ID | 错误信息 | | -------- | -------------------------- | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -928,7 +928,7 @@ getForward(length:number, callback: AsyncCallback<string>): void | 错误码ID | 错误信息 | | -------- | ------------------------------ | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | | 12800006 | Input method controller error. | **示例:** @@ -974,7 +974,7 @@ getForward(length:number): Promise<string> | 错误码ID | 错误信息 | | -------- | ------------------------------ | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | | 12800006 | Input method controller error. | **示例:** @@ -1013,7 +1013,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void | 错误码ID | 错误信息 | | -------- | ------------------------------ | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | | 12800006 | Input method controller error. | **示例:** @@ -1059,7 +1059,7 @@ getBackward(length:number): Promise<string> | 错误码ID | 错误信息 | | -------- | ------------------------------ | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | | 12800006 | Input method controller error. | **示例:** @@ -1099,7 +1099,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void | 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -1149,7 +1149,7 @@ deleteForward(length:number): Promise<boolean> | 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -1192,7 +1192,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void | 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -1242,7 +1242,7 @@ deleteBackward(length:number): Promise<boolean> | 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -1281,7 +1281,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void | 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -1326,7 +1326,7 @@ insertText(text:string): Promise<boolean> | 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -1366,7 +1366,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void | 错误码ID | 错误信息 | | -------- | -------------------------- | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -1401,7 +1401,7 @@ getEditorAttribute(): Promise<EditorAttribute> | 错误码ID | 错误信息 | | -------- | -------------------------- | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -1435,7 +1435,7 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void | 错误码ID | 错误信息 | | -------- | -------------------------- | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** @@ -1479,7 +1479,7 @@ moveCursor(direction: number): Promise<void> | 错误码ID | 错误信息 | | -------- | -------------------------- | -| 12800003 | Input method client error. | +| 12800003 | input method client error. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-intl.md b/zh-cn/application-dev/reference/apis/js-apis-intl.md index 584bd5b433ad8435b4c5067b4ec71823219bad56..1065a275779112f4950ce0c8316c02699444c798 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-intl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-intl.md @@ -67,7 +67,7 @@ constructor(locale: string, options?: LocaleOptions) | 参数名 | 类型 | 必填 | 说明 | | -------------------- | -------------------------------- | ---- | ---------------------------- | | locale | string | 是 | 包含区域信息的字符串,包括语言以、脚本、国家或地区。语言、脚本、国家或地区的国际标准及组合方式请见[Intl开发指导](../../internationalization/intl-guidelines.md#设置区域信息) | -| options9+ | [LocaleOptions](#localeoptions6) | 否 | 用于创建区域对象的选项。 | +| options9+ | [LocaleOptions](#localeoptions9) | 否 | 用于创建区域对象的选项。 | **示例:** ```js @@ -159,7 +159,7 @@ minimize(): Locale ``` -## LocaleOptions6+ +## LocaleOptions9+ 表示区域初始化选项。 @@ -206,7 +206,7 @@ constructor(locale: string | Array<string>, options?: DateTimeOptions) | 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------------------------------------ | ---- | ---------------------------- | | locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -| options9+ | [DateTimeOptions](#datetimeoptions6) | 否 | 用于创建时间日期格式化的选项。 | +| options9+ | [DateTimeOptions](#datetimeoptions9) | 否 | 用于创建时间日期格式化的选项。 | **示例:** ```js @@ -298,7 +298,7 @@ resolvedOptions(): DateTimeOptions | 类型 | 说明 | | ------------------------------------ | ----------------------------- | -| [DateTimeOptions](#datetimeoptions6) | DateTimeFormat 对象的格式化选项。 | +| [DateTimeOptions](#datetimeoptions9) | DateTimeFormat 对象的格式化选项。 | **示例:** ```js @@ -310,7 +310,7 @@ resolvedOptions(): DateTimeOptions ``` -## DateTimeOptions6+ +## DateTimeOptions9+ 表示时间日期格式化选项。 @@ -370,7 +370,7 @@ constructor(locale: string | Array<string>, options?: NumberOptions) | 参数名 | 类型 | 必填 | 说明 | | -------------------- | -------------------------------- | ---- | ---------------------------- | | locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -| options9+ | [NumberOptions](#numberoptions6) | 否 | 用于创建数字格式化的选项。 | +| options9+ | [NumberOptions](#numberoptions9) | 否 | 用于创建数字格式化的选项。 | **示例:** ```js @@ -420,7 +420,7 @@ resolvedOptions(): NumberOptions | 类型 | 说明 | | -------------------------------- | --------------------------- | -| [NumberOptions](#numberoptions6) | NumberFormat 对象的格式化选项。 | +| [NumberOptions](#numberoptions9) | NumberFormat 对象的格式化选项。 | **示例:** @@ -433,7 +433,7 @@ resolvedOptions(): NumberOptions ``` -## NumberOptions6+ +## NumberOptions9+ 表示设备支持的能力。 @@ -493,7 +493,7 @@ constructor(locale: string | Array<string>, options?: CollatorOptions) | 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------------------------------------ | ---- | ---------------------------- | | locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -| options9+ | [CollatorOptions](#collatoroptions8) | 否 | 用于创建排序对象的选项。 | +| options9+ | [CollatorOptions](#collatoroptions9) | 否 | 用于创建排序对象的选项。 | **示例:** ```js @@ -544,7 +544,7 @@ resolvedOptions(): CollatorOptions | 类型 | 说明 | | ------------------------------------ | ----------------- | -| [CollatorOptions](#collatoroptions8) | 返回的Collator对象的属性。 | +| [CollatorOptions](#collatoroptions9) | 返回的Collator对象的属性。 | **示例:** ```js @@ -556,7 +556,7 @@ resolvedOptions(): CollatorOptions ``` -## CollatorOptions8+ +## CollatorOptions9+ 表示Collator可设置的属性。 @@ -604,7 +604,7 @@ constructor(locale: string | Array<string>, options?: PluralRulesOptions) | 参数名 | 类型 | 必填 | 说明 | | -------------------- | ---------------------------------------- | ---- | ---------------------------- | | locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -| options9+ | [PluralRulesOptions](#pluralrulesoptions8) | 否 | 用于创建单复数对象的选项。 | +| options9+ | [PluralRulesOptions](#pluralrulesoptions9) | 否 | 用于创建单复数对象的选项。 | **示例:** ```js @@ -647,7 +647,7 @@ select(n: number): string ``` -## PluralRulesOptions8+ +## PluralRulesOptions9+ 表示PluralRules对象可设置的属性。 @@ -695,7 +695,7 @@ constructor(locale: string | Array<string>, options?: RelativeTimeFormatIn | 参数名 | 类型 | 必填 | 说明 | | -------------------- | ---------------------------------------- | ---- | ---------------------------- | | locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -| options9+ | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions8) | 否 | 用于创建相对时间格式化对象的选项。 | +| options9+ | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions9) | 否 | 用于创建相对时间格式化对象的选项。 | **示例:** ```js @@ -787,7 +787,7 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions ``` -## RelativeTimeFormatInputOptions8+ +## RelativeTimeFormatInputOptions9+ 表示RelativeTimeFormat对象可设置的属性。 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 a82e48c76e80342f10ce9ee42bfcd2852fc09d34..b46c3e52c46c256fad4ca33851398ed62e7aad52 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcController.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcController.md @@ -31,6 +31,9 @@ isNfcAvailable(): boolean 查询设备是否有NFC能力。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用canIUse("SystemCapability.Communication.NFC.Core")替代。 + **系统能力:** SystemCapability.Communication.NFC.Core **返回值:** @@ -46,6 +49,9 @@ openNfc(): boolean 打开NFC开关。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[enableNfc](#controllerenablenfc9)替代。 + **需要权限:** ohos.permission.MANAGE_SECURE_SETTINGS **系统能力:** SystemCapability.Communication.NFC.Core @@ -56,12 +62,33 @@ openNfc(): boolean | -------- | -------- | | boolean | true: 打开NFC成功, false: 打开NFC失败。 | +## controller.enableNfc9+ + +enableNfc(): boolean + +打开NFC开关。 + +**需要权限:** ohos.permission.MANAGE_SECURE_SETTINGS + +**系统能力:** SystemCapability.Communication.NFC.Core + +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100101 | NFC state is abnormal in service. | + ## controller.closeNfc closeNfc(): boolean 关闭NFC开关。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[disableNfc](#controllerdisablenfc9)替代。 + **需要权限:** ohos.permission.MANAGE_SECURE_SETTINGS **系统能力:** SystemCapability.Communication.NFC.Core @@ -72,6 +99,24 @@ closeNfc(): boolean | -------- | ------------------------------------------- | | boolean | true: 关闭NFC成功, false: 关闭NFC失败。 | +## controller.disableNfc9+ + +disableNfc(): boolean + +关闭NFC开关。 + +**需要权限:** ohos.permission.MANAGE_SECURE_SETTINGS + +**系统能力:** SystemCapability.Communication.NFC.Core + +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100101 | NFC state is abnormal in service. | + ## controller.isNfcOpen isNfcOpen(): boolean @@ -150,12 +195,28 @@ if (!controller.isNfcOpen()) { console.log("controller openNfc ret: " + ret); } +// from api9, use 'enableNfc' to open nfc. +try { + controller.enableNfc(); + console.log("controller enableNfc success"); +} catch (busiError) { + console.log("controller enableNfc busiError: " + busiError); +} + // close nfc, require permission: ohos.permission.MANAGE_SECURE_SETTINGS if (controller.isNfcOpen()) { var ret = controller.closeNfc(); console.log("controller closeNfc ret: " + ret); } +// from api9, use 'disableNfc' to close nfc. +try { + controller.disableNfc(); + console.log("controller disableNfc success"); +} catch (busiError) { + console.log("controller disableNfc busiError: " + busiError); +} + // 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 3c1f33040ca9c792e42256b083dbecaa9ec4ee44..d7ebd70b23d8889b5d04fda6832cda2f340f55da 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @@ -126,64 +126,204 @@ getNfcATag(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag) 获取NFC A类型Tag对象,通过该对象可访问NfcA技术类型的Tag。 -**需要权限:** ohos.permission.NFC_TAG +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tag.getNfcA](#taggetnfca9)替代。 + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 + +**返回值:** + +| **类型** | **说明** | +| -------- | -------- | +| [NfcATag](js-apis-nfctech.md#nfcatag) | NFC A类型Tag对象。 | + +## tag.getNfcA9+ + +getNfcA(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag) + +获取NFC A类型Tag对象,通过该对象可访问NfcA技术类型的Tag。 **系统能力:** SystemCapability.Communication.NFC.Tag +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 + **返回值:** | **类型** | **说明** | | -------- | -------- | | [NfcATag](js-apis-nfctech.md#nfcatag) | NFC A类型Tag对象。 | +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + ## tag.getNfcBTag getNfcBTag(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag) 获取NFC B类型Tag对象,通过该对象可访问NfcB技术类型的Tag。 -**需要权限:** ohos.permission.NFC_TAG +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tag.getNfcB](#taggetnfcb9)替代。 + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 + +**返回值:** + +| **类型** | **说明** | +| -------- | ---------------- | +| [NfcBTag](js-apis-nfctech.md#nfcbtag) | NFC B类型Tag对象。 | + +## tag.getNfcB9+ + +getNfcB(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag) + +获取NFC B类型Tag对象,通过该对象可访问NfcB技术类型的Tag。 **系统能力:** SystemCapability.Communication.NFC.Tag +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 + **返回值:** | **类型** | **说明** | | -------- | ---------------- | | [NfcBTag](js-apis-nfctech.md#nfcbtag) | NFC B类型Tag对象。 | +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + ## tag.getNfcFTag getNfcFTag(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag) 获取NFC F类型Tag对象,通过该对象可访问NfcF技术类型的Tag。 -**需要权限:** ohos.permission.NFC_TAG +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tag.getNfcF](#taggetnfcf9)替代。 + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 + +**返回值:** + +| **类型** | **说明** | +| -------- | ---------------- | +| [NfcFTag](js-apis-nfctech.md#nfcftag) | NFC F类型Tag对象。 | + +## tag.getNfcF9+ + +getNfcF(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag) + +获取NFC F类型Tag对象,通过该对象可访问NfcF技术类型的Tag。 **系统能力:** SystemCapability.Communication.NFC.Tag +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 + **返回值:** | **类型** | **说明** | | -------- | ---------------- | | [NfcFTag](js-apis-nfctech.md#nfcftag) | NFC F类型Tag对象。 | +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + ## tag.getNfcVTag getNfcVTag(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag) 获取NFC V类型Tag对象,通过该对象可访问NfcV技术类型的Tag。 -**需要权限:** ohos.permission.NFC_TAG +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tag.getNfcV](#taggetnfcv9)替代。 + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 + +**返回值:** + +| **类型** | **说明** | +| -------- | ---------------- | +| [NfcVTag](js-apis-nfctech.md#nfcvtag) | NFC V类型Tag对象。 | + +## tag.getNfcV9+ + +getNfcV(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag) + +获取NFC V类型Tag对象,通过该对象可访问NfcV技术类型的Tag。 **系统能力:** SystemCapability.Communication.NFC.Tag +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 + **返回值:** | **类型** | **说明** | | -------- | ---------------- | | [NfcVTag](js-apis-nfctech.md#nfcvtag) | NFC V类型Tag对象。 | +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + ## tag.getIsoDep9+ getIsoDep(tagInfo: [TagInfo](#taginfo)): [IsoDepTag](js-apis-nfctech.md#isoDepTag9 ) 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 fc5241358c6f5e76f43833d7aef8b059b663fe58..122d4992bf1b5b2e2c5ac7d431ad970d345443d2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfctech.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfctech.md @@ -26,8 +26,6 @@ getSak(): number 获取NFC-A标签的SAK值。 -**需要权限:** ohos.permission.NFC_TAG - **系统能力:** SystemCapability.Communication.NFC.Tag **返回值:** @@ -52,8 +50,6 @@ getAtqa(): number[] 获取NFC-A标签的Atqa值。 -**需要权限:** ohos.permission.NFC_TAG - **系统能力:** SystemCapability.Communication.NFC.Tag **返回值:** @@ -86,8 +82,6 @@ getRespAppData(): number[] 获取标签的应用程序数据。 -**需要权限:** ohos.permission.NFC_TAG - **系统能力:** SystemCapability.Communication.NFC.Tag **返回值:** @@ -112,8 +106,6 @@ getRespProtocol(): number[] 获取标签的协议信息。 -**需要权限:** ohos.permission.NFC_TAG - **系统能力:** SystemCapability.Communication.NFC.Tag **返回值:** @@ -146,8 +138,6 @@ getSystemCode(): number[] 从标签实例获取系统代码。 -**需要权限:** ohos.permission.NFC_TAG - **系统能力:** SystemCapability.Communication.NFC.Tag **返回值:** @@ -172,8 +162,6 @@ getPmm(): number[] 从标签实例获取PMm(由IC代码和制造商参数组成)。 -**需要权限:** ohos.permission.NFC_TAG - **系统能力:** SystemCapability.Communication.NFC.Tag **返回值:** @@ -206,8 +194,6 @@ getResponseFlags(): number 从标签实例实例获取响应标志。 -**需要权限:** ohos.permission.NFC_TAG - **系统能力:** SystemCapability.Communication.NFC.Tag **返回值:** @@ -232,8 +218,6 @@ getDsfId(): number 从标签实例实例获取数据存储格式标识符(DSFID)。 -**需要权限:** ohos.permission.NFC_TAG - **系统能力:** SystemCapability.Communication.NFC.Tag **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md b/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md index 082c541329f95275d81f93e69c4db19cced495da..d62aeac46128137a43229dde1175b05966b805d3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md @@ -24,7 +24,7 @@ publish(request: NotificationRequest, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------- | ---- | ------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | | callback | AsyncCallback\ | 是 | 发布通知的回调方法。 | **错误码:** @@ -80,7 +80,7 @@ publish(request: NotificationRequest): Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------- | ---- | ------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | **错误码:** @@ -132,7 +132,7 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\ | 是 | 被指定的回调方法。 | @@ -194,7 +194,7 @@ publish(request: NotificationRequest, userId: number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------- | ---- | ------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | | userId | number | 是 | 用户ID。 | **错误码:** @@ -439,7 +439,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | -| slot | [NotificationSlot](#notificationslot) | 是 | 要创建的通知通道对象。 | +| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是 | 要创建的通知通道对象。 | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | **错误码:** @@ -488,7 +488,7 @@ addSlot(slot: NotificationSlot): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ---- | ---------------- | ---- | -------------------- | -| slot | [NotificationSlot](#notificationslot) | 是 | 要创建的通知通道对象。 | +| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是 | 要创建的通知通道对象。 | **错误码:** @@ -605,7 +605,7 @@ addSlots(slots: Array\, callback: AsyncCallback\): voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------ | -| slots | Array\<[NotificationSlot](#notificationslot)\> | 是 | 要创建的通知通道对象数组。 | +| slots | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | 是 | 要创建的通知通道对象数组。 | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | **错误码:** @@ -658,7 +658,7 @@ addSlots(slots: Array\): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ----- | ------------------------- | ---- | ------------------------ | -| slots | Array\<[NotificationSlot](#notificationslot)\> | 是 | 要创建的通知通道对象数组。 | +| slots | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | 是 | 要创建的通知通道对象数组。 | **错误码:** @@ -701,7 +701,7 @@ getSlot(slotType: SlotType, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ----------------------------------------------------------- | | slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | -| callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是 | 表示被指定的回调方法。 | +| callback | AsyncCallback\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | 是 | 表示被指定的回调方法。 | **错误码:** @@ -783,7 +783,7 @@ getSlots(callback: AsyncCallback>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | -------------------- | -| callback | AsyncCallback\\> | 是 | 以callback形式返回获取此应用程序的所有通知通道的结果。 | +| callback | AsyncCallback\\> | 是 | 以callback形式返回获取此应用程序的所有通知通道的结果。 | **错误码:** @@ -823,7 +823,7 @@ getSlots(): Promise\> | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\\> | 以Promise形式返回获取此应用程序的所有通知通道的结果。 | +| Promise\\> | 以Promise形式返回获取此应用程序的所有通知通道的结果。 | **错误码:** @@ -1005,7 +1005,7 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | | enable | boolean | 是 | 使能状态。 | | callback | AsyncCallback\ | 是 | 设定通知使能回调函数。 | @@ -1054,7 +1054,7 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | | enable | boolean | 是 | 使能状态。 | **错误码:** @@ -1097,7 +1097,7 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\): | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ------------------------ | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | | callback | AsyncCallback\ | 是 | 获取通知使能状态回调函数。 | **错误码:** @@ -1145,7 +1145,7 @@ isNotificationEnabled(bundle: BundleOption): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | **返回值:** @@ -1237,7 +1237,7 @@ isNotificationEnabled(): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | **返回值:** @@ -1282,7 +1282,7 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\ | 是 | 设定角标使能回调函数。 | @@ -1331,7 +1331,7 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | | enable | boolean | 是 | 使能状态。 | **错误码:** @@ -1374,7 +1374,7 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ------------------------ | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | | callback | AsyncCallback\ | 是 | 获取角标使能状态回调函数。 | **错误码:** @@ -1422,7 +1422,7 @@ isBadgeDisplayed(bundle: BundleOption): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | **返回值:** @@ -1470,8 +1470,8 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | -| slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | +| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是 | 通知通道。 | | callback | AsyncCallback\ | 是 | 设定通知通道回调函数。 | **错误码:** @@ -1524,8 +1524,8 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | -| slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | +| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是 | 通知通道。 | **错误码:** @@ -1570,8 +1570,8 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback> | 是 | 获取通知通道回调函数。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | +| callback | AsyncCallback> | 是 | 获取通知通道回调函数。 | **错误码:** @@ -1618,13 +1618,13 @@ getSlotsByBundle(bundle: BundleOption): Promise> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | **返回值:** | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise> | 以Promise形式返回获取指定应用的通知通道。 | +| Promise> | 以Promise形式返回获取指定应用的通知通道。 | **错误码:** @@ -1666,7 +1666,7 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\): voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | | callback | AsyncCallback\ | 是 | 获取通知通道数量回调函数。 | **错误码:** @@ -1714,7 +1714,7 @@ getSlotNumByBundle(bundle: BundleOption): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 指定应用的包信息。 | **返回值:** @@ -1763,7 +1763,7 @@ getAllActiveNotifications(callback: AsyncCallback>) | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | -------------------- | -| callback | AsyncCallback> | 是 | 获取活动通知回调函数。 | +| callback | AsyncCallback> | 是 | 获取活动通知回调函数。 | **错误码:** @@ -1793,7 +1793,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); ## Notification.getAllActiveNotifications -getAllActiveNotifications(): Promise\\> +getAllActiveNotifications(): Promise\\> 获取当前未删除的所有通知(Promise形式)。 @@ -1807,7 +1807,7 @@ getAllActiveNotifications(): Promise\\> | 以Promise形式返回获取活动通知。 | +| Promise\\> | 以Promise形式返回获取活动通知。 | **错误码:** @@ -1915,7 +1915,7 @@ getActiveNotifications(callback: AsyncCallback>): v | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ | -| callback | AsyncCallback> | 是 | 获取当前应用通知列表回调函数。 | +| callback | AsyncCallback> | 是 | 获取当前应用通知列表回调函数。 | **错误码:** @@ -1945,7 +1945,7 @@ Notification.getActiveNotifications(getActiveNotificationsCallback); ## Notification.getActiveNotifications -getActiveNotifications(): Promise\\> +getActiveNotifications(): Promise\\> 获取当前应用未删除的通知列表(Promise形式)。 @@ -1955,7 +1955,7 @@ getActiveNotifications(): Promise\\> | 以Promise形式返回获取当前应用通知列表。 | +| Promise\\> | 以Promise形式返回获取当前应用通知列表。 | **错误码:** @@ -1989,7 +1989,7 @@ cancelGroup(groupName: string, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | --------- | --------------------- | ---- | ---------------------------- | -| groupName | string | 是 | 通知组名称,此名称需要在发布通知时通过[NotificationRequest](#notificationrequest)对象指定。 | +| groupName | string | 是 | 通知组名称,此名称需要在发布通知时通过[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)对象指定。 | | callback | AsyncCallback\ | 是 | 取消本应用指定组下通知的回调函数。 | **错误码:** @@ -2071,7 +2071,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall | 参数名 | 类型 | 必填 | 说明 | | --------- | --------------------- | ---- | ---------------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 应用的包信息。 | | groupName | string | 是 | 通知组名称。 | | callback | AsyncCallback\ | 是 | 删除指定应用指定组下通知的回调函数。 | @@ -2121,7 +2121,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\ | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------ | ---- | -------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 应用的包信息。 | | groupName | string | 是 | 通知组名称。 | **错误码:** @@ -2786,7 +2786,7 @@ setDistributedEnable(enable: boolean, callback: AsyncCallback\): void **示例:** ```javascript -function setDistributedEnableCallback() { +function setDistributedEnableCallback(err) { if (err) { console.info("setDistributedEnable failed " + JSON.stringify(err)); } else { @@ -2933,7 +2933,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 应用的包信息。 | | enable | boolean | 是 | 是否支持。 | | callback | AsyncCallback\ | 是 | 应用程序是否支持分布式通知的回调函数。 | @@ -2987,7 +2987,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\ | 是 | 查询指定应用是否支持分布式通知的回调函数。 | **错误码:** @@ -3050,7 +3050,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 应用的包。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 应用的包。 | **返回值:** @@ -3213,7 +3213,7 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user | 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------------------------------------------- | ---- | ---------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | | representativeBundle | string | 是 | 被代理应用的包名。 | | userId | number | 是 | 用户ID。 | | callback | AsyncCallback | 是 | 发布代理通知的回调方法。 | @@ -3280,7 +3280,7 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user | 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | | representativeBundle | string | 是 | 被代理应用的包名。 | | userId | number | 是 | 用户ID。 | @@ -3440,7 +3440,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 应用的包信息。 | | type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | enable | boolean | 是 | 使能状态。 | | callback | AsyncCallback\ | 是 | 设置渠道使能回调函数。 | @@ -3491,7 +3491,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean) | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------- | ---- | -------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 应用的包信息。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 | | enable | boolean | 是 | 使能状态。 | @@ -3534,7 +3534,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| bundle | [BundleOption](./js-apis-inner-notification-bundleOption.md) | 是 | 应用的包信息。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 | | callback | AsyncCallback\ | 是 | 获取渠道使能状态回调函数。 | @@ -3583,7 +3583,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\ { | LEVEL_HIGH | 4 | 表示通知功能已启用,状态栏中显示通知图标,有横幅和提示音。 | -## BundleOption - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------ | ------ |---- | --- | ------ | -| bundle | string | 是 | 是 | 应用的包信息。 | -| uid | number | 是 | 是 | 用户ID。 | - - ## SlotType **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification @@ -3888,227 +3878,6 @@ Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => { | OTHER_TYPES | 0xFFFF | 其他类型。 | -## NotificationActionButton - -描述通知中显示的操作按钮。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| --------- | ----------------------------------------------- | --- | ---- | ------------------------- | -| title | string | 是 | 是 | 按钮标题。 | -| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 点击按钮时触发的WantAgent。 | -| extras | { [key: string]: any } | 是 | 是 | 按钮扩展信息。 | -| userInput | [NotificationUserInput](#notificationuserinput) | 是 | 是 | 用户输入对象实例。 | - - -## NotificationBasicContent - -描述普通文本通知。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------------- | ------ | ---- | ---- | ---------------------------------- | -| title | string | 是 | 是 | 通知标题。 | -| text | string | 是 | 是 | 通知内容。 | -| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | - - -## NotificationLongTextContent - -描述长文本通知。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------------- | ------ | ---- | --- | -------------------------------- | -| title | string | 是 | 是 | 通知标题。 | -| text | string | 是 | 是 | 通知内容。 | -| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | -| longText | string | 是 | 是 | 通知的长文本。 | -| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | -| expandedTitle | string | 是 | 是 | 通知展开时的标题。 | - - -## NotificationMultiLineContent - -描述多行文本通知。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------------- | --------------- | --- | --- | -------------------------------- | -| title | string | 是 | 是 | 通知标题。 | -| text | string | 是 | 是 | 通知内容。 | -| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | -| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | -| longTitle | string | 是 | 是 | 通知展开时的标题。 | -| lines | Array\ | 是 | 是 | 通知的多行文本。 | - - -## NotificationPictureContent - -描述附有图片的通知。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------------- | -------------- | ---- | --- | -------------------------------- | -| title | string | 是 | 是 | 通知标题。 | -| text | string | 是 | 是 | 通知内容。 | -| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | -| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | -| expandedTitle | string | 是 | 是 | 通知展开时的标题。 | -| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知的图片内容。 | - - -## NotificationContent - -描述通知类型。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ | -| contentType | [ContentType](#contenttype) | 是 | 是 | 通知内容类型。 | -| normal | [NotificationBasicContent](#notificationbasiccontent) | 是 | 是 | 基本类型通知内容。 | -| longText | [NotificationLongTextContent](#notificationlongtextcontent) | 是 | 是 | 长文本类型通知内容。 | -| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | 是 | 是 | 多行类型通知内容。 | -| picture | [NotificationPictureContent](#notificationpicturecontent) | 是 | 是 | 图片类型通知内容。 | - - -## NotificationFlagStatus - -描述通知标志状态。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -**系统接口**:此接口为系统接口,三方应用不支持调用。 - -| 名称 | 值 | 说明 | -| -------------- | --- | --------------------------------- | -| TYPE_NONE | 0 | 默认标志。 | -| TYPE_OPEN | 1 | 通知标志打开。 | -| TYPE_CLOSE | 2 | 通知标志关闭。 | - - -## NotificationFlags - -描述通知标志的实例。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ---------------- | ---------------------- | ---- | ---- | --------------------------------- | -| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | 是 | 否 | 是否启用声音提示。 | -| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | 是 | 否 | 是否启用振动提醒功能。 | - - -## NotificationRequest - -描述通知的请求。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- | -| content | [NotificationContent](#notificationcontent) | 是 | 是 | 通知内容。 | -| id | number | 是 | 是 | 通知ID。 | -| slotType | [SlotType](#slottype) | 是 | 是 | 通道类型。 | -| isOngoing | boolean | 是 | 是 | 是否进行时通知。 | -| isUnremovable | boolean | 是 | 是 | 是否可移除。 | -| deliveryTime | number | 是 | 是 | 通知发送时间。 | -| tapDismissed | boolean | 是 | 是 | 通知是否自动清除。 | -| autoDeletedTime | number | 是 | 是 | 自动清除的时间。 | -| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | WantAgent封装了应用的行为意图,点击通知时触发该行为。 | -| extraInfo | {[key: string]: any} | 是 | 是 | 扩展参数。 | -| color | number | 是 | 是 | 通知背景颜色。预留能力,暂未支持。 | -| colorEnabled | boolean | 是 | 是 | 通知背景颜色是否使能。预留能力,暂未支持。 | -| isAlertOnce | boolean | 是 | 是 | 设置是否仅有一次此通知提醒。 | -| isStopwatch | boolean | 是 | 是 | 是否显示已用时间。 | -| isCountDown | boolean | 是 | 是 | 是否显示倒计时时间。 | -| isFloatingIcon | boolean | 是 | 是 | 是否显示状态栏图标。 | -| label | string | 是 | 是 | 通知标签。 | -| badgeIconStyle | number | 是 | 是 | 通知角标类型。 | -| showDeliveryTime | boolean | 是 | 是 | 是否显示分发时间。 | -| actionButtons | Array\<[NotificationActionButton](#notificationactionbutton)\> | 是 | 是 | 通知按钮,最多三个按钮。 | -| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知小图标。可选字段,大小不超过30KB。 | -| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知大图标。可选字段,大小不超过30KB。 | -| creatorBundleName | string | 是 | 否 | 创建通知的包名。 | -| creatorUid | number | 是 | 否 | 创建通知的UID。 | -| creatorPid | number | 是 | 否 | 创建通知的PID。 | -| creatorUserId| number | 是 | 否 | 创建通知的UserId。 | -| hashCode | string | 是 | 否 | 通知唯一标识。 | -| classification | string | 是 | 是 | 通知分类。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | -| groupName| string | 是 | 是 | 组通知名称。 | -| template | [NotificationTemplate](#notificationtemplate) | 是 | 是 | 通知模板。 | -| isRemoveAllowed | boolean | 是 | 否 | 通知是否能被移除。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | -| source | number | 是 | 否 | 通知源。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | -| distributedOption | [DistributedOptions](#distributedoptions) | 是 | 是 | 分布式通知的选项。 | -| deviceId | string | 是 | 否 | 通知源的deviceId。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | -| notificationFlags | [NotificationFlags](#notificationflags) | 是 | 否 | 获取NotificationFlags。 | -| removalWantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 当移除通知时,通知将被重定向到的WantAgent实例。 | -| badgeNumber | number | 是 | 是 | 应用程序图标上显示的通知数。 | - - -## DistributedOptions - -描述分布式选项。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ---------------------- | -------------- | ---- | ---- | ---------------------------------- | -| isDistributed | boolean | 是 | 是 | 是否为分布式通知。 | -| supportDisplayDevices | Array\ | 是 | 是 | 可以同步通知到的设备列表。 | -| supportOperateDevices | Array\ | 是 | 是 | 可以打开通知的设备列表。 | -| remindType | number | 是 | 否 | 通知的提醒方式。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | - - -## NotificationSlot - -描述通知槽 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------------------- | --------------------- | ---- | --- | ------------------------------------------ | -| type | [SlotType](#slottype) | 是 | 是 | 通道类型。 | -| level | number | 是 | 是 | 通知级别,不设置则根据通知渠道类型有默认值。 | -| desc | string | 是 | 是 | 通知渠道描述信息。 | -| badgeFlag | boolean | 是 | 是 | 是否显示角标。 | -| bypassDnd | boolean | 是 | 是 | 置是否在系统中绕过免打扰模式。 | -| lockscreenVisibility | number | 是 | 是 | 在锁定屏幕上显示通知的模式。 | -| vibrationEnabled | boolean | 是 | 是 | 是否可振动。 | -| sound | string | 是 | 是 | 通知提示音。 | -| lightEnabled | boolean | 是 | 是 | 是否闪灯。 | -| lightColor | number | 是 | 是 | 通知灯颜色。 | -| vibrationValues | Array\ | 是 | 是 | 通知振动样式。 | -| enabled9+ | boolean | 是 | 否 | 此通知插槽中的启停状态。 | - - -## NotificationTemplate - -通知模板。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ---- | ---------------------- | ---- | ---- | ---------- | -| name | string | 是 | 是 | 模板名称。 | -| data | {[key:string]: Object} | 是 | 是 | 模板数据。 | - - -## NotificationUserInput - -保存用户输入的通知消息。 - -**系统能力**:SystemCapability.Notification.Notification - -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------- | ------ | --- | ---- | ----------------------------- | -| inputKey | string | 是 | 是 | 用户输入时用于标识此输入的key。 | ## DeviceRemindType 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 e959b5c021035b4bef999fd8b78ecca9fc14b008..ad04193189eddfe65a2f6c3bd86650d6dc4f6c2a 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 @@ -19,8 +19,9 @@ import resourceManager from '@ohos.resourceManager'; Stage模型下Context的引用方法请参考[Stage模型的Context详细介绍](../..//application-models/application-context-stage.md)。 ```ts -import Ability from '@ohos.application.Ability'; -class MainAbility extends Ability { +import UIAbility from '@ohos.app.ability.UIAbility'; + +export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage) { let context = this.context; let resourceManager = context.resourceManager; 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 4cd9ccf699f3f119698f291a20e9858b346f2edb..9c4f2642f11e9519ce50bd98b3a4339c9c18dc7e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-router.md @@ -596,7 +596,7 @@ export default { // 在detail页面中 export default { onInit() { - console.info('showData1:' + router.getParams()[data1]); + console.info('showData1:' + router.getParams()['data1']); } } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md b/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md index c2489044571a00f59297c578f4e29c381857954b..2f2768c1d8203b5e2dc056d40a124dc037d1cdef 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @@ -12,12 +12,14 @@ import screenlock from '@ohos.screenLock'; ``` -## EventType +## EventType9+ 定义系统事件类型。 **系统能力:** SystemCapability.MiscServices.ScreenLock +**系统接口**:此接口为系统接口。 + | 事件类型 | 说明 | | ------------------ | ------------------------ | | beginWakeUp | 表示设备开始唤醒。 | @@ -35,15 +37,17 @@ import screenlock from '@ohos.screenLock'; | screenlockEnabled | 表示锁屏是否启用。 | | serviceRestart | 表示锁屏服务进行重启。 | -## SystemEvent +## SystemEvent9+ 定义系统事件回调参数结构。 **系统能力:** SystemCapability.MiscServices.ScreenLock +**系统接口**:此接口为系统接口。 + | 名称 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ------------- | -| eventType | [EventType](#eventtype) | 是 | 系统事件类型。 | +| eventType | [EventType](#eventtype9) | 是 | 系统事件类型。 | | params | string | 是 | 系统事件参数。 | ## screenlock.isLocked9+ @@ -204,7 +208,7 @@ onSystemEvent(callback: Callback<SystemEvent>): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ----------------- | -| callback | Callback\<[SystemEvent](#systemevent)> | 是 | 锁屏相关的系统事件回调函数。 | +| callback | Callback\<[SystemEvent](#systemevent9)> | 是 | 锁屏相关的系统事件回调函数。 | **返回值:** @@ -226,7 +230,7 @@ try { ## screenlock.sendScreenLockEvent9+ -sendScreenLockEvent(event: string, parameter: number, callback: AsyncCallback<boolean>): void +sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback<boolean>): void 应用发送事件到锁屏服务。使用callback异步回调。 @@ -238,7 +242,7 @@ sendScreenLockEvent(event: string, parameter: number, callback: AsyncCallback< | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------ | ---- | -------------------- | -| event | string | 是 | 事件类型,支持如下取值:
- "unlockScreenResult",表示解锁结果。
- "lockScreenResult",表示锁屏结果。
- "screenDrawDone",表示屏幕绘制完成。 | +| event | String | 是 | 事件类型,支持如下取值:
- "unlockScreenResult",表示解锁结果。
- "lockScreenResult",表示锁屏结果。
- "screenDrawDone",表示屏幕绘制完成。 | | parameter | number | 是 | 事件结果。
- parameter为0,表示成功。例如解锁成功或锁屏成功。
- parameter为1,表示失败。例如解锁失败或锁屏失败。
- parameter为2,表示取消。例如锁屏取消或解锁取消。 | | callback | AsyncCallback\ | 是 | 回调函数。返回true表示发送事件成功;返回false表示发送事件失败。 | @@ -256,7 +260,7 @@ screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { ## screenlock.sendScreenLockEvent9+ -sendScreenLockEvent(event: string, parameter: number): Promise<boolean> +sendScreenLockEvent(event: String, parameter: number): Promise<boolean> 应用发送事件到锁屏服务。使用Promise异步回调。 @@ -268,7 +272,7 @@ sendScreenLockEvent(event: string, parameter: number): Promise<boolean> | 参数名 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | --------------------------------------- | -| event | string | 是 | 事件类型,支持如下取值:
- "unlockScreenResult",表示解锁结果。
- "lockScreenResult",表示锁屏结果。
- "screenDrawDone",表示屏幕绘制完成。 | +| event | String | 是 | 事件类型,支持如下取值:
- "unlockScreenResult",表示解锁结果。
- "lockScreenResult",表示锁屏结果。
- "screenDrawDone",表示屏幕绘制完成。 | | parameter | number | 是 | 事件结果。
- parameter为0,表示成功。例如解锁成功或锁屏成功。
- parameter为1,表示失败。例如解锁失败或锁屏失败。
- parameter为2,表示取消。例如锁屏取消或解锁取消。 | **返回值:** 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 73b75b5381307ae355769a5426e3beb67cd6db52..efc9e2fd88f27e7ee23637fa2e7895b839e3f329 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md @@ -2660,7 +2660,7 @@ try { ## sensor.getAngleVariation9+ getAngleVariation(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>, - callback: AsyncCallback): void + callback: AsyncCallback<Array<number>>): void 计算两个旋转矩阵之间的角度变化。 @@ -2716,7 +2716,7 @@ try { ## sensor.getAngleVariation9+ -getAngleVariation(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>): Promise +getAngleVariation(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>): Promise<Array<number>> 得到两个旋转矩阵之间的角度变化。 @@ -2776,7 +2776,7 @@ try { ## sensor.getRotationMatrix9+ -getRotationMatrix(rotationVector: Array<number>, callback: AsyncCallback): void +getRotationMatrix(rotationVector: Array<number>, callback: AsyncCallback<Array<number>>): void 根据旋转矢量获取旋转矩阵。 @@ -2818,7 +2818,7 @@ try { ## sensor.getRotationMatrix9+ -getRotationMatrix(rotationVector: Array<number>): Promise +getRotationMatrix(rotationVector: Array<number>): Promise<Array<number>> 根据旋转矢量获取旋转矩阵。 @@ -2865,7 +2865,7 @@ try { ## sensor.transformRotationMatrix9+ transformRotationMatrix(inRotationVector: Array<number>, coordinates: CoordinatesOptions, - callback: AsyncCallback): void + callback: AsyncCallback<Array<number>>): void 根据指定坐标系映射旋转矩阵。 @@ -2912,7 +2912,7 @@ try { ## sensor.transformRotationMatrix9+ -transformRotationMatrix(inRotationVector: Array<number>, coordinates: CoordinatesOptions): Promise +transformRotationMatrix(inRotationVector: Array<number>, coordinates: CoordinatesOptions): Promise<Array<number>> 根据指定坐标系映射旋转矩阵。 @@ -2963,7 +2963,7 @@ try { ## sensor.getQuaternion9+ -getQuaternion(rotationVector: Array<number>, callback: AsyncCallback): void +getQuaternion(rotationVector: Array<number>, callback: AsyncCallback<Array<number>>): void 根据旋转向量计算归一化四元数。 @@ -3005,7 +3005,7 @@ try { ## sensor.getQuaternion9+ -getQuaternion(rotationVector: Array<number>): Promise +getQuaternion(rotationVector: Array<number>): Promise<Array<number>> 根据旋转向量计算归一化四元数。 @@ -3051,7 +3051,7 @@ try { ## sensor.getOrientation9+ -getOrientation(rotationMatrix: Array<number>, callback: AsyncCallback): void +getOrientation(rotationMatrix: Array<number>, callback: AsyncCallback<Array<number>>): void 根据旋转矩阵计算设备方向。 @@ -3100,7 +3100,7 @@ try { ## sensor.getOrientation9+ -getOrientation(rotationMatrix: Array<number>): Promise +getOrientation(rotationMatrix: Array<number>): Promise<Array<number>> 根据旋转矩阵计算设备的方向。 @@ -3192,7 +3192,7 @@ try { ## sensor.getRotationMatrix9+ -getRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>,): Promise<RotationMatrixResponse> +getRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>): Promise<RotationMatrixResponse> 根据重力矢量和地磁矢量计算旋转矩阵。 @@ -3238,7 +3238,7 @@ try { ## sensor.getSensorList9+ -getSensorList(callback: AsyncCallback): void +getSensorList(callback: AsyncCallback<Array<Sensor>>): void 获取设备上的所有传感器信息。 @@ -3248,7 +3248,7 @@ getSensorList(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------- | ---- | ---------------- | -| callback | AsyncCallback | 是 | 回调函数,返回传感器属性列表。 | +| callback | AsyncCallback<Array<[Sensor](#sensor9)>> | 是 | 回调函数,返回传感器属性列表。 | **错误码**: @@ -3278,7 +3278,7 @@ try { ## sensor.getSensorList9+ - getSensorList(): Promise< Array<Sensor>> + getSensorList(): Promise<Array<Sensor>> 获取设备上的所有传感器信息。 @@ -3288,7 +3288,7 @@ try { | 参数名 | 类型 | 必填 | 说明 | | ------- | ---------------------------------------- | ---- | ---------------- | -| promise | Promise | 是 | Promise对象,返回传感器属性列表。 | +| promise | Promise<Array<[Sensor](#sensor9)>> | 是 | Promise对象,返回传感器属性列表。 | **错误码**: 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 8677dd02863676b4bf8296bd75396eab7bc096eb..32b66bd40eecb8b10ef4313dbd7325c80cf8162e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-tagSession.md +++ b/zh-cn/application-dev/reference/apis/js-apis-tagSession.md @@ -26,6 +26,9 @@ getTagInfo(): tag.TagInfo 获取该Tag被分发时,NFC服务所提供的Tag数据对象。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tag.getTagInfo](js-apis-nfcTag.md#taggettaginfo9)替代。 + **需要权限:** ohos.permission.NFC_TAG **系统能力:** SystemCapability.Communication.NFC.Tag @@ -54,6 +57,9 @@ connectTag(): boolean; 和标签建立连接。在从标签读取数据或将数据写入标签之前,必须调用此方法。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tagSession.connect](#tagsessionconnect9)替代。 + **需要权限:** ohos.permission.NFC_TAG **系统能力:** SystemCapability.Communication.NFC.Tag @@ -76,12 +82,49 @@ let connectStatus = tag.getIsoDep(tagInfo).connectTag(); console.log("connectStatus: " + connectStatus); ``` +### tagSession.connect9+ + +connect(): void; + +和标签建立连接。在从标签读取数据或将数据写入标签之前,必须调用此方法。 + +**需要权限:** ohos.permission.NFC_TAG + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + +**示例:** + +```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, ... + +try { + tag.getIsoDep(tagInfo).connect(); + console.log("tag connect success"); +} catch (busiError) { + console.log("tag connect busiError: " + busiError); +} +``` + ### tagSession.reset() reset(): void 重置与标签的连接。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tagSession.resetConnection](#tagsessionresetconnection9)替代。 + **需要权限:** ohos.permission.NFC_TAG **系统能力:** SystemCapability.Communication.NFC.Tag @@ -97,12 +140,49 @@ import tag from '@ohos.nfc.tag'; tag.getIsoDep(tagInfo).reset(); ``` +### tagSession.resetConnection()9+ + +resetConnection(): void + +重置与标签的连接。 + +**需要权限:** ohos.permission.NFC_TAG + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + +**示例:** + +```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, ... + +try { + tag.getIsoDep(tagInfo).resetConnection(); + console.log("tag resetConnection success"); +} catch (busiError) { + console.log("tag resetConnection busiError: " + busiError); +} +``` + ### tagSession.isTagConnected isTagConnected(): boolean 检查是否已与标签建立连接。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tagSession.isConnected](#tagsessionisconnected9)替代。 + **需要权限:** ohos.permission.NFC_TAG **系统能力:** SystemCapability.Communication.NFC.Tag @@ -125,12 +205,47 @@ let isTagConnected = tag.getIsoDep(tagInfo).isTagConnected(); console.log("isTagConnected: " + isTagConnected); ``` +### tagSession.isConnected9+ + +isConnected(): boolean + +检查是否已与标签建立连接。 + +**需要权限:** ohos.permission.NFC_TAG + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**返回值:** + +| **类型** | **说明** | +| ------------------ | --------------------------| +| 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, ... + +try { + var isConnected = tag.getIsoDep(tagInfo).isConnected(); + console.log("tag isConnected = " + isConnected); +} catch (busiError) { + console.log("tag isConnected busiError: " + busiError); +} +``` + ### tagSession.getMaxSendLength getMaxSendLength(): number 查询可以发送到标签的最大数据长度。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tagSession.getMaxTransmitSize](#tagsessiongetmaxtransmitsize9)替代。 + **需要权限:** ohos.permission.NFC_TAG **系统能力:** SystemCapability.Communication.NFC.Tag @@ -152,12 +267,54 @@ let maxSendLen = tag.getIsoDep(tagInfo).getMaxSendLength(); console.log("tag maxSendLen: " + maxSendLen); ``` +### tagSession.getMaxTransmitSize9+ + +getMaxTransmitSize(): number + +查询可以发送到标签的最大数据长度。 + +**需要权限:** ohos.permission.NFC_TAG + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**返回值:** + +| **类型** | **说明** | +| ------------------ | --------------------------| +| number | 可以发送到标签的最大数据长度,非负数。 | + +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + +**示例:** +```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, ... + +try { + var maxTransmitSize = tag.getIsoDep(tagInfo).getMaxTransmitSize(); + console.log("tag maxTransmitSize = " + maxTransmitSize); +} catch (busiError) { + console.log("tag getMaxTransmitSize busiError: " + busiError); +} +``` + ### tagSession.getSendDataTimeout getSendDataTimeout(): number 查询发送数据到Tag的等待超时时间,单位是毫秒。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tagSession.getTimeout](#tagsessiongettimeout9)替代。 + **需要权限:** ohos.permission.NFC_TAG **系统能力:** SystemCapability.Communication.NFC.Tag @@ -180,12 +337,55 @@ let sendDataTimeout = tag.getIsoDep(tagInfo).getSendDataTimeout(); console.log("tag sendDataTimeout: " + sendDataTimeout); ``` +### tagSession.getTimeout9+ + +getTimeout(): number + +查询发送数据到Tag的等待超时时间,单位是毫秒。 + +**需要权限:** ohos.permission.NFC_TAG + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**返回值:** + +| **类型** | **说明** | +| ------------------ | --------------------------| +| number | 发送数据到Tag的等待超时时间,单位是毫秒,非负数。 | + +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + +**示例:** + +```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, ... + +try { + var timeout = tag.getIsoDep(tagInfo).getTimeout(); + console.log("tag timeout = " + timeout); +} catch (busiError) { + console.log("tag getTimeout busiError: " + busiError); +} +``` + ### tagSession.setSendDataTimeout setSendDataTimeout(timeout: number): boolean 查询发送数据到Tag的等待超时时间,单位是毫秒。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tagSession.setTimeout](#tagsessionsettimeout9)替代。 + **需要权限:** ohos.permission.NFC_TAG **系统能力:** SystemCapability.Communication.NFC.Tag @@ -215,12 +415,56 @@ let setStatus = tag.getIsoDep(tagInfo).setSendDataTimeout(timeoutMs); console.log("tag setSendDataTimeout setStatus: " + setStatus); ``` +### tagSession.setTimeout9+ + +setTimeout(timeout: number): void + +查询发送数据到Tag的等待超时时间,单位是毫秒。 + +**需要权限:** ohos.permission.NFC_TAG + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| timeout | number | 是 | 超时时间,单位毫秒,非负值。 | + +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + +**示例:** + +```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 timeoutMs = 700; // change it to be correct. +try { + tag.getIsoDep(tagInfo).setTimeout(timeoutMs); + console.log("tag setTimeout success"); +} catch (busiError) { + console.log("tag setTimeout busiError: " + busiError); +} +``` + ### tagSession.sendData sendData(data: number[]): Promise 发送指令到Tag上,使用Promise方式作为异步方法。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tagSession.transmit](#tagsessiontransmit9)替代。 + **需要权限:** ohos.permission.NFC_TAG **系统能力:** SystemCapability.Communication.NFC.Tag @@ -267,6 +511,9 @@ sendData(data: number[], callback: AsyncCallback): void 发送指令到Tag上,使用AsyncCallback方式作为异步方法。 +> **说明:** +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tagSession.transmit](#tagsessiontransmit9-1)替代。 + **需要权限:** ohos.permission.NFC_TAG **系统能力:** SystemCapability.Communication.NFC.Tag @@ -303,3 +550,123 @@ tag.getIsoDep(tagInfo).sendData(cmdData, (err, response)=> { } }); ``` + +### tagSession.transmit9+ + +transmit(data: number[]): Promise + +发送指令到Tag上,使用Promise方式作为异步方法。 + +**需要权限:** ohos.permission.NFC_TAG + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| data | number[] | 是 | 要发送的指令。每个number十六进制表示,范围是0x00~0xFF。 | + +**返回值:** + +| **类型** | **说明** | +| ------------------ | --------------------------| +| Promise | 对端Tag对指令的响应数据。每个number十六进制表示,范围是0x00~0xFF。| + +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + +**示例:** + +```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, ... + +// connect the tag at first if not connected. +try { + if (!tag.getIsoDep(tagInfo).isConnected()) { + tag.getIsoDep(tagInfo).connect(); + } +} catch (busiError) { + console.log("tag connect busiError: " + busiError); + return; +} + +let cmdData = [0x01, 0x02, 0x03, 0x04]; // change the raw data to be correct. +try { + tag.getIsoDep(tagInfo).transmit(cmdData).then((response) => { + console.log("tagSession transmit Promise response: " + response); + }).catch((err)=> { + console.log("tagSession transmit Promise err: " + err); + }); +} catch (busiError) { + console.log("tag transmit busiError: " + busiError); + return; +} +``` + +### tagSession.transmit9+ + +transmit(data: number[], callback: AsyncCallback): void + +发送指令到Tag上,使用AsyncCallback方式作为异步方法。 + +**需要权限:** ohos.permission.NFC_TAG + +**系统能力:** SystemCapability.Communication.NFC.Tag + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| data | number[] | 是 | 要发送的指令。每个number十六进制表示,范围是0x00~0xFF。 | +| callback | AsyncCallback | 是 | 回调函数,返回响应数据。每个number十六进制表示,范围是0x00~0xFF。 | + +**错误码:** + +以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 + +| 错误码ID | 错误信息| +| ------- | -------| +| 3100201 | Tag running state is abnormal in service. | + +**示例:** + +```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, ... + +// connect the tag at first if not connected. +try { + if (!tag.getIsoDep(tagInfo).isConnected()) { + tag.getIsoDep(tagInfo).connect(); + } +} catch (busiError) { + console.log("tag connect busiError: " + busiError); + return; +} + +let cmdData = [0x01, 0x02, 0x03, 0x04]; // change the raw data to be correct. +try { + tag.getIsoDep(tagInfo).transmit(cmdData, (err, response)=> { + if (err) { + console.log("tagSession transmit AsyncCallback err: " + err); + } else { + console.log("tagSession transmit AsyncCallback response: " + response); + } + }); +} catch (busiError) { + console.log("tag transmit busiError: " + busiError); + return; +} + +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-update.md b/zh-cn/application-dev/reference/apis/js-apis-update.md index 144bb69c2bbef40ef5605b4ab7883475b3eb8970..e2aa8974228692c77c455a1276bfa002f3b8b61c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-update.md +++ b/zh-cn/application-dev/reference/apis/js-apis-update.md @@ -2036,7 +2036,7 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); | WAITING_INSTALL | 30 | 待安装。 | | UPDATING | 31 | 更新中。 | | WAITING_APPLY | 40 | 待生效。 | -| APPLYING | 21 | 生效中。 | +| APPLYING | 41 | 生效中。 | | UPGRADE_SUCCESS | 50 | 升级成功。 | | UPGRADE_FAIL | 51 | 升级失败。 | @@ -2058,7 +2058,7 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); | 名称 | 值 | 说明 | | ---------------------- | ---------- | ------ | -| EVENT_TASK_BASE | 0x01000000 | 任务事件。 | +| EVENT_TASK_BASE | EventClassify.TASK | 任务事件。 | | EVENT_TASK_RECEIVE | 0x01000001 | 收到任务。 | | EVENT_TASK_CANCEL | 0x01000010 | 取消任务。 | | EVENT_DOWNLOAD_WAIT | 0x01000011 | 待下载。 | 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 251d446bdb9f8250d97fb8e57ef3821f40248522..ecc881616acbdece068111001a82daa64a93c14c 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 @@ -22,8 +22,8 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth'; | ------------ | ---------- | ---- | -------------------- | | result | number | 是 | 认证结果。 | | token | Uint8Array | 否 | 用户身份认证通过的凭证。 | -| remainAttempts | number | 否 | 剩余的认证操作次数。 | -| lockoutDuration | number | 否 | 认证操作的冻结时间。 | +| remainAttempts | number | 否 | 剩余的认证尝试次数。 | +| lockoutDuration | number | 否 | 认证操作的锁定时长,时间单位为毫秒ms。 | ## TipInfo9+ 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 66c9844cd14d5577a3d13bb1dc79d80fb214ea3c..7e99b7ef998884e63d9d0b54b9ce60bb3311d477 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webview.md @@ -2,7 +2,7 @@ # @ohos.web.webview (Webview) -提供web控制能力。 +@ohos.web.webview提供web控制能力,[web](../arkui-ts/ts-basic-components-web.md)组件提供具有网页显示能力。 > **说明:** > @@ -232,15 +232,15 @@ static initializeWebEngine(): void ```ts // xxx.ts -import Ability from '@ohos.application.Ability' -import web_webview from '@ohos.web.webview' +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; -export default class MainAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { - console.log("MainAbility onCreate") + console.log("EntryAbility onCreate") web_webview.WebviewController.initializeWebEngine() globalThis.abilityWant = want - console.log("MainAbility onCreate done") + console.log("EntryAbility onCreate done") } } ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md index bbd00b8c1bf389bc026f2f3617fc3cc70e93cdd4..18cf415472a1b896c485b35bea6dfe5fe0583695 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md @@ -3,7 +3,7 @@ 自定义组件是用户根据业务需求,将已有的组件组合,封装成的新组件,可以在工程中多次调用,从而提高代码的可读性。自定义组件通过element引入到宿主页面,使用方法如下: ```html - +
@@ -12,8 +12,8 @@ 结合if-else使用自定义组件的示例,showComp1为true时显示自定义组件comp1,否则显示comp2: ```html - - + +
@@ -76,7 +76,7 @@ export default { ```html - +
@@ -125,7 +125,7 @@ export default { ```html - +
父组件:{{text}} diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md index a384d0cce0f98cbb715089815d29acc5285db440..882d732f5a7e097dcfb573c49b67101a85f2dfcd 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md @@ -21,7 +21,7 @@ export default { ```html - +
@@ -57,7 +57,7 @@ export default { ```html - +
diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md index f5bceca1a24068409268c4e600872f24afafcba3..b3d541c6c8473b6a6da0d74348f0f98d97ef39cc 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md @@ -20,7 +20,7 @@ 引用该自定义组件方式如下: ```html - +
父组件中定义的内容 @@ -45,7 +45,7 @@ 引用该自定义组件方式如下: ```html - +
插入第二个插槽中 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-formcomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-formcomponent.md index d451d3fd941f47c54577fc54125255a713e35ea7..c8737ca8a0712ae7f8025b17fa46c1f4762c38f4 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-formcomponent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-formcomponent.md @@ -108,7 +108,7 @@ struct CardExample { .visibility(Visibility.Visible) .onAcquired((form)=>{ console.log(`form info : ${JSON.stringify(form)}`); - this.fomId = form.id; + this.formId = form.id; }) .onError((err)=>{ console.log(`fail to add form, err: ${JSON.stringify(err)}`); diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md index 575d33a19a14e4e6f4ec24e8866b99e2848aacfb..4b75b65ca53169850c7732be1bbe9594a600cf4d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -359,20 +359,16 @@ struct ImageExample3 { ### 渲染沙箱路径图片 ```ts -import fileio from '@ohos.fileio' -import fs from '@ohos.file.fs' -import context from '@ohos.application.context' +import fileio from '@ohos.fileio'; +import fs from '@ohos.file.fs'; +import context from '@ohos.app.ability.common'; @Entry @Component struct LoadImageExample { @State resourcesPath: string = '' @State sandboxPath: string = '' - context: context.AbilityContext - - aboutToAppear() { - this.context = getContext(this) as context.AbilityContext - } + context: context.UIAbility = getContext(this) as context.UIAbilityContext build() { Column() { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md index 0bad69d7c539028e0e165cc3e16a27ca93575876..f4d92ad423e1a47497d5673b2ce8dea3a587f09d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md @@ -46,7 +46,7 @@ PluginComponent(value: { template: PluginComponentTemplate, data: KVObject}) ```ts //PluginUserExample.ets -import plugin from "plugin_component.js" +import plugin from "./plugin_component.js" @Entry @Component @@ -102,7 +102,7 @@ struct PluginUserExample { ```ts //PluginProviderExample.ets -import plugin from "plugin_component.js" +import plugin from "./plugin_component.js" @Entry @Component diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md index 091f31fbd61fcddd2be1304a411eed32bef53bbe..43b806a70ab65e26ebf56bee4121b8355d48d674 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -1,6 +1,6 @@ # Web -提供具有网页显示能力的Web组件。 +提供具有网页显示能力的Web组件,[@ohos.web.webview](../apis/js-apis-webview.md)提供web控制能力。 > **说明:** > 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 827c1aba855ee99df5e9e1c22bf263e23bd4dfa0..a86cdf2dd1f92cdcd8ef75c4db6f1f840b1ae747 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
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| divider | {
strokeWidth: [Length](ts-types.md#length),
color?:[ResourceColor](ts-types.md),
startMargin?: Length,
endMargin?: Length
} \| null | 设置ListItem分割线样式,默认无分割线。
- strokeWidth: 分割线的线宽。
- color: 分割线的颜色。
- startMargin: 分割线与列表侧边起始端的距离。
- endMargin: 分割线与列表侧边结束端的距离。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| divider | {
strokeWidth: [Length](ts-types.md#length),
color?:[ResourceColor](ts-types.md#resourcecolor),
startMargin?: Length,
endMargin?: Length
} \| null | 设置ListItem分割线样式,默认无分割线。
- strokeWidth: 分割线的线宽。
- color: 分割线的颜色。
- startMargin: 分割线与列表侧边起始端的距离。
- endMargin: 分割线与列表侧边结束端的距离。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。
默认值:BarState.Off
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | cachedCount | number | 设置列表中ListItem/ListItemGroup的预加载数量,其中ListItemGroup将作为一个整体进行计算,ListItemGroup中的所有ListItem会一次性全部加载出来。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)。
默认值:1
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | editMode | boolean | 声明当前List组件是否处于可编辑模式。
默认值:false | @@ -76,9 +76,9 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | onScrollIndex(event: (start: number, end: number) => void) | 列表滑动时触发。
计算索引值时,ListItemGroup作为一个整体占一个索引值,不计算ListItemGroup内部ListItem的索引值。
- start: 滑动起始位置索引值。
- end: 滑动结束位置索引值。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | onReachStart(event: () => void) | 列表到达起始位置时触发。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | onReachEnd(event: () => void) | 列表到底末尾位置时触发。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| onScrollFrameBegin9+(event: (offset: number, state: ScrollState) => { offsetRemain }) | 列表开始滑动时触发,事件参数传入即将发生的滑动量,事件处理函数中可根据应用场景计算实际需要的滑动量并作为事件处理函数的返回值返回,列表将按照返回值的实际滑动量进行滑动。
\- offset:即将发生的滑动量。
\- state:当前滑动状态。
- offsetRemain:水平方向实际滑动量。
该接口支持在ArkTS卡片中使用。 | -| onScrollStart9+(event: () => void) | 列表滑动开始时触发。手指拖动列表或列表的滚动条触发的滑动开始时,会触发该事件。使用[Scroller](ts-container-scroll.md#scroller)滑动控制器触发的滑动,不会触发该事件。 | -| onScrollStop(event: () => void) | 列表滑动停止时触发。手拖动列表或列表的滚动条触发的滑动,手离开屏幕并且滑动停止时会触发该事件;使用[Scroller](ts-container-scroll.md#scroller)滑动控制器触发的滑动,不会触发该事件。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| onScrollFrameBegin9+(event: (offset: number, state: ScrollState) => { offsetRemain }) | 列表开始滑动时触发,事件参数传入即将发生的滑动量,事件处理函数中可根据应用场景计算实际需要的滑动量并作为事件处理函数的返回值返回,列表将按照返回值的实际滑动量进行滑动。
\- offset:即将发生的滑动量。
\- state:当前滑动状态。
- offsetRemain:实际滑动量。
该接口支持在ArkTS卡片中使用。 | +| onScrollStart9+(event: () => void) | 列表滑动开始时触发。手指拖动列表或列表的滚动条触发的滑动开始时,会触发该事件。使用[Scroller](ts-container-scroll.md#scroller)滑动控制器触发的带动画的滑动,动画开始时会触发该事件。 | +| onScrollStop(event: () => void) | 列表滑动停止时触发。手拖动列表或列表的滚动条触发的滑动,手离开屏幕并且滑动停止时会触发该事件;使用[Scroller](ts-container-scroll.md#scroller)滑动控制器触发的带动画的滑动,动画停止会触发该事件。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | 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对象说明)。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md index 9996564d394d9c646f255a0d132d8c601638c3e3..53803a4425e2c592b4f70e3dda1a2670d6e6ae71 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -18,6 +18,12 @@ Scroll(scroller?: Scroller) +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| scroller | [Scroller](#scroller) | 否 | 可滚动组件的控制器。用于与可滚动组件进行绑定。 | + ## 属性 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: @@ -42,12 +48,12 @@ Scroll(scroller?: Scroller) | 名称 | 功能描述 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| onScrollFrameBegin9+(event: (offset: number, state: ScrollState) => { offsetRemain }) | 每帧开始滚动时触发,事件参数传入即将发生的滚动量,事件处理函数中可根据应用场景计算实际需要的滚动量并作为事件处理函数的返回值返回,Scroll将按照返回值的实际滚动量进行滚动。
\- offset:即将发生的滚动量。
\- state:当前滚动状态。
- offsetRemain:水平方向实际滚动量。 | +| onScrollFrameBegin9+(event: (offset: number, state: ScrollState) => { offsetRemain }) | 每帧开始滚动时触发,事件参数传入即将发生的滚动量,事件处理函数中可根据应用场景计算实际需要的滚动量并作为事件处理函数的返回值返回,Scroll将按照返回值的实际滚动量进行滚动。
\- offset:即将发生的滚动量。
\- state:当前滚动状态。
- offsetRemain:实际滚动量。 | | onScroll(event: (xOffset: number, yOffset: number) => void) | 滚动事件回调, 返回滚动时水平、竖直方向偏移量。 | | onScrollEdge(event: (side: Edge) => void) | 滚动到边缘事件回调。 | -| onScrollEnd(event: () => void) | 滚动停止事件回调。
该事件从API9开始废弃,使用onScrollStop事件替代。 | -| onScrollStart9+(event: () => void) | 滚动开始时触发。手指拖动Scroll或拖动Scroll的滚动条触发的滚动开始时,会触发该事件。使用[Scroller](#scroller)滚动控制器触发的滚动,不会触发该事件。 | -| onScrollStop9+(event: () => void) | 滚动停止时触发。手拖动Scroll或拖动Scroll的滚动条触发的滚动,手离开屏幕并且滚动停止时会触发该事件;使用[Scroller](#scroller)滚动控制器触发的滚动,不会触发该事件。 | +| onScrollEnd(deprecated) (event: () => void) | 滚动停止事件回调。
该事件从API9开始废弃,使用onScrollStop事件替代。 | +| onScrollStart9+(event: () => void) | 滚动开始时触发。手指拖动Scroll或拖动Scroll的滚动条触发的滚动开始时,会触发该事件。使用[Scroller](#scroller)滚动控制器触发的带动画的滚动,动画开始时会触发该事件。 | +| onScrollStop9+(event: () => void) | 滚动停止时触发。手拖动Scroll或拖动Scroll的滚动条触发的滚动,手离开屏幕并且滚动停止时会触发该事件。使用[Scroller](#scroller)滚动控制器触发的带动画的滚动,动画停止时会触发该事件。 | > **说明:** > @@ -111,7 +117,7 @@ scrollPage(value: { next: boolean, direction?: Axis }): void ### currentOffset -currentOffset() +currentOffset(): { xOffset: number, yOffset: number } 返回当前的滚动偏移量。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md b/zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md index d6763eebdda0b57f0090abfd2da966f7d31dc40e..9c73fdd1a51dc669768f88c0488d5d92d60f3ac3 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md @@ -4,7 +4,7 @@ **错误信息** -NFC opening or closing state is abnormal in service. +NFC state is abnormal in service. **错误描述** @@ -12,11 +12,13 @@ NFC服务内部执行NFC打开或关闭异常。 **可能原因** -和NFC服务建立通信异常。 +1. 和NFC服务建立通信异常。 +2. NFC芯片通信异常。 **处理步骤** -重新执行打开或关闭NFC。 +1. 重新执行打开或关闭NFC。 +2. 重新执行打开或关闭NFC,或重启设备尝试。 ## 3100201 diff --git a/zh-cn/application-dev/reference/syscap-list.md b/zh-cn/application-dev/reference/syscap-list.md index e804c0fe96aee8e94f5987424630bc24d6eda966..33f6ac5f09f4578a8d9b6414b4047854e23303d4 100644 --- a/zh-cn/application-dev/reference/syscap-list.md +++ b/zh-cn/application-dev/reference/syscap-list.md @@ -1394,3 +1394,267 @@ VAID管理服务 | Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | + +## SystemCapability.Security.CertificateManager + +证书管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Security.CryptoFramework + +加解密算法库框架-加解密基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleFramework.Core + +包管理核心业务,包含包信息查询、安装卸载的核心能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleFramework.FreeInstall + +包管理提供的免安装特性 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleFramework.Resource + +包管理提供的获取图标和label的特性 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleFramework.DefaultApp + +包管理提供的默认应用管理特性 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleFramework.Launcher + +包管理提供给Launcher的查询特性 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleFramework.SandboxApp + +包管理提供的沙箱应用的特性 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleFramework.QuickFix + +包管理提供的快速修复的特性 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleFramework.AppControl + +包管理提供的拦截特性 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Graphic.Graphic2D.ColorManager.Core + +富设备广色域管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + +能效资源申请接口 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.AVPlayer + +媒体音视频播放引擎能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.AVRecorder + +媒体音视频录制引擎能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Security.Cert + +加解密算法库框架-证书能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Security.DataLossPrevention + +数据防泄漏 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.Communication.NFC.Tag + +NFC标签服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | + +## SystemCapability.Communication.NFC.CardEmulation + +NFC卡模拟服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | + +## SystemCapability.Multimedia.Image.ImageCreator + +图像创建能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Developtools.Syscap + +系统能力编解码 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 否 | + +## SystemCapability.Communication.NetManager.Ethernet + +以太网连接 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.NetManager.NetSharing + +网络共享 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.Communication.NetManager.MDNS + +mDNS服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.NetManager.Vpn + +VPN + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.XTS.DeviceAttest + +设备证明 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.XTS.DeviceAttestLite + +轻量设备证明 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 是 | 否 | 否 | 否 | 否 | 是 | 是 | + +## SystemCapability.FileManagement.UserFileManager.Core + +公共用户文件管理基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.FileManagement.UserFileManager.DistributedCore + +公共用户文件管理分布式能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.DistributedDataManager.UDMF.Core + +分布式数据管理--统一数据管理框架(UDMF)核心能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleFramework.Overlay + +包管理overlay特性 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Cloud.Push + +推送管理服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 是 | 否 | + +## SystemCapability.Multimedia.SystemSound.Core + +系统声音管理,如铃声,通知,闹钟等 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Ability.AbilityRuntime.QuickFix + +快速修复 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | \ No newline at end of file diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index d0c9322bb8c18e83359c920f605e013bd3ad4a8f..0d05ae997835b7961d866799d89db29b5f19d7d6 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -928,6 +928,11 @@ - [@ohos.notification (Notification模块)(待停用)](reference/apis/js-apis-notification.md) - application - [EventHub](reference/apis/js-apis-inner-application-eventHub.md) + - commonEvent + - [CommonEventData](reference/apis/js-apis-inner-commonEvent-commonEventData.md) + - [CommonEventPublishData](reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md) + - [CommonEventSubscriber](reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md) + - [CommonEventSubscribeInfo](reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md) - 包管理 - [@ohos.bundle.appControl (appControl模块)](reference/apis/js-apis-appControl.md) - [@ohos.bundle.bundleManager (bundleManager模块)](reference/apis/js-apis-bundleManager.md) diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-nfc.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-nfc.md new file mode 100644 index 0000000000000000000000000000000000000000..506de8014aa3d4ea26c6a36c63e51eaa133e1499 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-nfc.md @@ -0,0 +1,61 @@ +# 公共通信子系统NFC JS API变更Changelog + +OpenHarmony 3.2.10.2(Mr)版本相较于OpenHarmony 3.2.beta4版本,分布式数据管理子系统的API变更如下 + +## cl.nfc.1 接口变更 +NFC部分API6到API8部分JS接口不支持抛出错误码,需要删除废弃,然后使用新的API9替换。 + +开发者需要根据以下说明对应用进行适配。 + + **变更影响** + +影响部分API6到API8部分JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。 + +**关键的接口/组件变更** + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- | +| api/@ohos.nfc.cardEmulation.d.ts | cardEmulation | FeatureType | 废弃 | +| api/@ohos.nfc.cardEmulation.d.ts | cardEmulation | isSupported | 废弃 | +| api/@ohos.nfc.cardEmulation.d.ts | cardEmulation | hasHceCapability | 新增 | +| api/@ohos.nfc.controller.d.ts | nfcController | isNfcAvailable | 废弃 | +| api/@ohos.nfc.controller.d.ts | nfcController | openNfc | 废弃 | +| api/@ohos.nfc.controller.d.ts | nfcController | closeNfc | 废弃 | +| api/@ohos.nfc.controller.d.ts | nfcController | enableNfc | 新增 | +| api/@ohos.nfc.controller.d.ts | nfcController | disableNfc | 新增 | +| api/@ohos.nfc.tag.d.ts | tag | getNfcATag | 废弃 | +| api/@ohos.nfc.tag.d.ts | tag | getNfcBTag | 废弃 | +| api/@ohos.nfc.tag.d.ts | tag | getNfcFTag | 废弃 | +| api/@ohos.nfc.tag.d.ts | tag | getNfcVTag | 废弃 | +| api/@ohos.nfc.tag.d.ts | tag | getNfcA | 新增 | +| api/@ohos.nfc.tag.d.ts | tag | getNfcB | 新增 | +| api/@ohos.nfc.tag.d.ts | tag | getNfcF | 新增 | +| api/@ohos.nfc.tag.d.ts | tag | getNfcV | 新增 | +| api/tag/tagSession.d.ts | TagSession | getTagInfo | 废弃 | +| api/tag/tagSession.d.ts | TagSession | connectTag | 废弃 | +| api/tag/tagSession.d.ts | TagSession | reset | 废弃 | +| api/tag/tagSession.d.ts | TagSession | isTagConnected | 废弃 | +| api/tag/tagSession.d.ts | TagSession | setSendDataTimeout | 废弃 | +| api/tag/tagSession.d.ts | TagSession | getSendDataTimeout | 废弃 | +| api/tag/tagSession.d.ts | TagSession | sendData | 废弃 | +| api/tag/tagSession.d.ts | TagSession | getMaxSendLength | 废弃 | +| api/tag/tagSession.d.ts | TagSession | connect | 新增 | +| api/tag/tagSession.d.ts | TagSession | resetConnection | 新增 | +| api/tag/tagSession.d.ts | TagSession | isConnected | 新增 | +| api/tag/tagSession.d.ts | TagSession | setTimeout | 新增 | +| api/tag/tagSession.d.ts | TagSession | getTimeout | 新增 | +| api/tag/tagSession.d.ts | TagSession | transmit | 新增 | +| api/tag/tagSession.d.ts | TagSession | getMaxTransmitSize | 新增 | + +**适配指导** + +查看API开发指南: +[cardEmulation-API参考](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md) + +[nfcController-API参考](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-nfcController.md) + +[tag-API参考](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md) + +[TagSession-API参考](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-tagSession.md) +``` +