提交 cd811c56 编写于 作者: Y yuyaozhi

Merge branch 'monthly_20221018' of https://gitee.com/yuyaozhi/docs into monthly_20221018

...@@ -108,7 +108,7 @@ You write a UI test script based on the unit test framework, adding the invoking ...@@ -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: 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 ```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. 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() { ...@@ -131,16 +131,16 @@ export default function abilityTest() {
expect(Ability.context.abilityInfo.name).assertEqual('MainAbility'); expect(Ability.context.abilityInfo.name).assertEqual('MainAbility');
}) })
//ui test code //ui test code
//init uidriver //init driver
var driver = await UiDriver.create(); var driver = await Driver.create();
await driver.delayMs(1000); await driver.delayMs(1000);
//find button by text 'Next' //find button by text 'Next'
var button = await driver.findComponent(BY.text('Next')); var button = await driver.findComponent(ON.text('Next'));
//click button //click button
await button.click(); await button.click();
await driver.delayMs(1000); await driver.delayMs(1000);
//check text //check text
await driver.assertComponentExist(BY.text('after click')); await driver.assertComponentExist(ON.text('after click'));
await driver.pressBack(); await driver.pressBack();
done(); done();
}) })
......
# Device # Device Management
- USB Service - USB Service
- [USB Service Overview](usb-overview.md) - [USB Service Overview](usb-overview.md)
...@@ -17,3 +17,5 @@ ...@@ -17,3 +17,5 @@
- Update Service - Update Service
- [Sample Server Overview](sample-server-overview.md) - [Sample Server Overview](sample-server-overview.md)
- [Sample Server Development](sample-server-guidelines.md) - [Sample Server Development](sample-server-guidelines.md)
- Stationary
- [stationary Development](stationary-guidelines.md)
# 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);
}
```
...@@ -35,7 +35,7 @@ resources ...@@ -35,7 +35,7 @@ resources
| Category | base Subdirectory | Qualifiers Subdirectory | rawfile Subdirectory | | 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.<br>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).<br>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.<br>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.<br>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).<br>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.<br>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. | | 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. | | 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 ...@@ -81,9 +81,9 @@ You can create resource group subdirectories (including element, media, and prof
| Resource Group Subdirectory | Description | Resource File | | 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:<br>- **boolean**: boolean data<br>- **color**: color data<br>- **float**: floating-point data<br>- **intarray**: array of integers<br>- **integer**: integer data<br>- **pattern**: pattern data<br>- **plural**: plural form data<br>- **strarray**: array of strings<br>- **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:<br>- boolean.json<br>- color.json<br>- float.json<br>- intarray.json<br>- integer.json<br>- pattern.json<br>- plural.json<br>- strarray.json<br>- string.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:<br>- **boolean**: boolean data<br>- **color**: color data<br>- **float**: floating-point data<br>- **intarray**: array of integers<br>- **integer**: integer data<br>- **pattern**: pattern data<br>- **plural**: plural form data<br>- **strarray**: array of strings<br>- **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:<br>- boolean.json<br>- color.json<br>- float.json<br>- intarray.json<br>- integer.json<br>- pattern.json<br>- plural.json<br>- strarray.json<br>- 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**. | | 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 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**. | | 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. | | 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** **Media Resource Types**
...@@ -229,7 +229,7 @@ When referencing resources in the **rawfile** subdirectory, use the **"$rawfile( ...@@ -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. > 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): 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")) ...@@ -252,7 +252,6 @@ Text($r('app.string.message_arrive', "five'o clock"))
Text($r('app.plural.eat_apple', 5, 5)) Text($r('app.plural.eat_apple', 5, 5))
.fontColor($r('app.color.color_world')) .fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world')) .fontSize($r('app.float.font_world'))
}
Image($r('app.media.my_background_image')) // Reference media resources. Image($r('app.media.my_background_image')) // Reference media resources.
......
...@@ -156,7 +156,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => { ...@@ -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. > 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<Array\<BundleInfo>> getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise\<Array\<BundleInfo\>\>
Obtains the information of all bundles of the specified user. This API uses a promise to return the result. 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) ...@@ -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. > 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<Array\<BundleInfo>>): void getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback\<Array\<BundleInfo\>\>): void
Obtains the information of all bundles of the current user. This API uses an asynchronous callback to return the result. 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) => { ...@@ -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. > 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<Array\<BundleInfo>>): void getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback\<Array\<BundleInfo\>\>): void
Obtains the information of all bundles of the specified user. This API uses an asynchronous callback to return the result. 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) => { ...@@ -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. > 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<Array\<ApplicationInfo>> getAllApplicationInfo(bundleFlags: number, userId?: number): Promise\<Array\<ApplicationInfo\>\>
Obtains the information about all applications of the specified user. This API uses a promise to return the result. 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) ...@@ -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. > 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<Array\<ApplicationInfo>>): void getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback\<Array\<ApplicationInfo\>\>): void
Obtains the information about all applications. This API uses an asynchronous callback to return the result. 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) => { ...@@ -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. > 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<Array\<AbilityInfo>> queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise\<Array\<AbilityInfo\>\>
Obtains the ability information based on given Want. This API uses a promise to return the result. 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) ...@@ -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. > 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<Array\<AbilityInfo>>): void queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback\<Array\<AbilityInfo\>\>): void
Obtains the ability information of the specified user based on given Want. This API uses an asynchronous callback to return the result. 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) => { ...@@ -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. > 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<Array\<AbilityInfo>>): void; queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback\<Array\<AbilityInfo\>\>): void;
Obtains the ability information based on given Want. This API uses an asynchronous callback to return the result. Obtains the ability information based on given Want. This API uses an asynchronous callback to return the result.
......
...@@ -2215,7 +2215,7 @@ try { ...@@ -2215,7 +2215,7 @@ try {
### bundleManager.getProfileByAbility ### bundleManager.getProfileByAbility
getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback<Array\<string>>): void; getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): 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. 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 { ...@@ -2266,7 +2266,7 @@ try {
### bundleManager.getProfileByAbility ### bundleManager.getProfileByAbility
getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise<Array\<string>>; getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string\>\>;
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. 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 { ...@@ -2336,7 +2336,7 @@ try {
### bundleManager.getProfileByExtensionAbility ### bundleManager.getProfileByExtensionAbility
getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback<Array\<string>>): void; getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string\>\>): 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. 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 { ...@@ -2386,7 +2386,7 @@ try {
### bundleManager.getProfileByExtensionAbility ### bundleManager.getProfileByExtensionAbility
getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise<Array\<string>>; getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string\>\>;
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. 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 { ...@@ -2658,7 +2658,6 @@ try {
### bundleManager.getApplicationInfoSync ### bundleManager.getApplicationInfoSync
getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md); 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. Synchronously obtains the application information based on the given bundle name, application flags, and user ID.
...@@ -2709,6 +2708,42 @@ try { ...@@ -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 ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
...@@ -2726,7 +2761,6 @@ try { ...@@ -2726,7 +2761,6 @@ try {
### bundleManager.getBundleInfoSync ### bundleManager.getBundleInfoSync
getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId: number): [BundleInfo](js-apis-bundleManager-bundleInfo.md); 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. 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 ...@@ -2742,7 +2776,7 @@ Synchronously obtains the bundle information based on the given bundle name, bun
| ----------- | ------ | ---- | -------------------------------------------------------- | | ----------- | ------ | ---- | -------------------------------------------------------- |
| bundleName | string | Yes | Bundle name. | | bundleName | string | Yes | Bundle name. |
| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.| | bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.|
| userId | number | No | User ID. | | userId | number | Yes | User ID. |
**Return value** **Return value**
...@@ -2777,6 +2811,42 @@ try { ...@@ -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 ```ts
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
...@@ -2789,3 +2859,37 @@ try { ...@@ -2789,3 +2859,37 @@ try {
hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', err.message); 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.|
...@@ -33,7 +33,7 @@ For details, see [Permission Levels](../../security/accesstoken-overview.md). ...@@ -33,7 +33,7 @@ For details, see [Permission Levels](../../security/accesstoken-overview.md).
## bundleMonitor.on ## bundleMonitor.on
on(type: BundleChangedEvent, callback: callback\<BundleChangedInfo>): void; on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void;
Subscribes to bundle installation, uninstall, and update events. Subscribes to bundle installation, uninstall, and update events.
...@@ -66,7 +66,7 @@ try { ...@@ -66,7 +66,7 @@ try {
## bundleMonitor.off ## bundleMonitor.off
off(type: BundleChangedEvent, callback?: callback\<BundleChangedInfo>): void; off(type: BundleChangedEvent, callback?: Callback\<BundleChangedInfo>): void;
Unsubscribes from bundle installation, uninstall, and update events. Unsubscribes from bundle installation, uninstall, and update events.
......
...@@ -477,10 +477,10 @@ Listens for camera status changes. This API uses an asynchronous callback to ret ...@@ -477,10 +477,10 @@ Listens for camera status changes. This API uses an asynchronous callback to ret
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | 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.| | 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. | | callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change.| |
**Example** **Example**
...@@ -505,8 +505,8 @@ This is a system API. ...@@ -505,8 +505,8 @@ This is a system API.
| Name | Type | Mandatory| Description | | 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.| | 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\<boolean> | Yes | Callback used to return the camera mute status. | | callback | AsyncCallback\<boolean> | 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** **Example**
...@@ -728,7 +728,7 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul ...@@ -728,7 +728,7 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul
| Name | Type | Mandatory| Description | | 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.| | cameraDevice | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.|
| callback | ErrorCallback<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | ErrorCallback<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
...@@ -1392,7 +1392,7 @@ try { ...@@ -1392,7 +1392,7 @@ try {
setMeteringPoint(point: Point): void 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 **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -1449,7 +1449,7 @@ try { ...@@ -1449,7 +1449,7 @@ try {
setExposureBias(exposureBias: number): void 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. Before the setting, you are advised to use **[getExposureBiasRange](#getexposurebiasrange)** to obtain the supported values.
...@@ -1591,7 +1591,7 @@ try { ...@@ -1591,7 +1591,7 @@ try {
setFocusPoint(point: Point): void setFocusPoint(point: Point): void
Sets a focal point for the device. Sets the focal point.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -1698,7 +1698,7 @@ try { ...@@ -1698,7 +1698,7 @@ try {
setZoomRatio(zoomRatio: number): void setZoomRatio(zoomRatio: number): void
Sets a zoom ratio for the device. Sets a zoom ratio.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -1850,7 +1850,7 @@ Listens for focus state changes. This API uses an asynchronous callback to retur ...@@ -1850,7 +1850,7 @@ Listens for focus state changes. This API uses an asynchronous callback to retur
| Name | Type | Mandatory| Description | | 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. | | callback | AsyncCallback<[FocusState](#focusstate)\> | Yes | Callback used to return the focus state change. |
**Example** **Example**
...@@ -1873,7 +1873,7 @@ Listens for **CaptureSession** errors. This API uses a callback to return the er ...@@ -1873,7 +1873,7 @@ Listens for **CaptureSession** errors. This API uses a callback to return the er
| Name | Type | Mandatory| Description | | 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<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | ErrorCallback<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
...@@ -2054,8 +2054,8 @@ Listens for preview frame start events. This API uses an asynchronous callback t ...@@ -2054,8 +2054,8 @@ Listens for preview frame start events. This API uses an asynchronous callback t
| Name | Type | Mandatory| Description | | 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.| | 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<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback<void\> | Yes | Callback used to return the result. The preview starts as long as this event is returned. |
**Example** **Example**
...@@ -2077,8 +2077,8 @@ Listens for preview frame end events. This API uses an asynchronous callback to ...@@ -2077,8 +2077,8 @@ Listens for preview frame end events. This API uses an asynchronous callback to
| Name | Type | Mandatory| Description | | 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.| | 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<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback<void\> | Yes | Callback used to return the result. The preview ends as long as this event is returned. |
**Example** **Example**
...@@ -2098,9 +2098,9 @@ Listens for **PreviewOutput** errors. This API uses a callback to return the err ...@@ -2098,9 +2098,9 @@ Listens for **PreviewOutput** errors. This API uses a callback to return the err
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | 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()**.| | 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<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | ErrorCallback<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
...@@ -2367,7 +2367,7 @@ Listens for shooting start events. This API uses an asynchronous callback to ret ...@@ -2367,7 +2367,7 @@ Listens for shooting start events. This API uses an asynchronous callback to ret
| Name | Type | Mandatory| Description | | 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<number\> | Yes | Callback used to return the capture ID. | | callback | AsyncCallback<number\> | Yes | Callback used to return the capture ID. |
**Example** **Example**
...@@ -2388,10 +2388,10 @@ Listens for frame shutter events. This API uses an asynchronous callback to retu ...@@ -2388,10 +2388,10 @@ Listens for frame shutter events. This API uses an asynchronous callback to retu
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | 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).| | 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. | | 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** **Example**
...@@ -2412,9 +2412,9 @@ Listens for shooting end events. This API uses an asynchronous callback to retur ...@@ -2412,9 +2412,9 @@ Listens for shooting end events. This API uses an asynchronous callback to retur
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ---------------------------------------- | | -------- | --------------- | ---- | ---------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'captureEnd'**. The callback function returns the shooting end event.| | 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. | | callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -2436,9 +2436,9 @@ Listens for **PhotoOutput** errors. This API uses a callback to return the error ...@@ -2436,9 +2436,9 @@ Listens for **PhotoOutput** errors. This API uses a callback to return the error
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | 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.| | 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<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | ErrorCallback<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
...@@ -2638,8 +2638,8 @@ Listens for video recording start events. This API uses an asynchronous callback ...@@ -2638,8 +2638,8 @@ Listens for video recording start events. This API uses an asynchronous callback
| Name | Type | Mandatory| Description | | 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.| | 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<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback<void\> | Yes | Callback used to return the result. The recording starts as long as this event is returned. |
**Example** **Example**
...@@ -2661,8 +2661,8 @@ Listens for video recording stop events. This API uses an asynchronous callback ...@@ -2661,8 +2661,8 @@ Listens for video recording stop events. This API uses an asynchronous callback
| Name | Type | Mandatory| Description | | 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.| | 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<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback<void\> | Yes | Callback used to return the result. The recording ends as long as this event is returned. |
**Example** **Example**
...@@ -2682,9 +2682,9 @@ Listens for errors that occur during video recording. This API uses a callback t ...@@ -2682,9 +2682,9 @@ Listens for errors that occur during video recording. This API uses a callback t
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | 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()**.| | 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<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | Callback<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
...@@ -2809,9 +2809,9 @@ Listens for metadata objects. This API uses an asynchronous callback to return t ...@@ -2809,9 +2809,9 @@ Listens for metadata objects. This API uses an asynchronous callback to return t
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | 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.| | 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<Array<[MetadataObject](#metadataobject)\>\> | Yes | Callback used to return the metadata.| | callback | Callback<Array<[MetadataObject](#metadataobject)\>\> | Yes | Callback used to return the metadata.|
**Example** **Example**
...@@ -2832,9 +2832,9 @@ Listens for metadata errors. This API uses an asynchronous callback to return th ...@@ -2832,9 +2832,9 @@ Listens for metadata errors. This API uses an asynchronous callback to return th
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | 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()**.| | 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<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). | | callback | Callback<BusinessError\> | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example** **Example**
......
...@@ -174,7 +174,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -174,7 +174,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| -------- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ |
| 17700004 | The specified user ID is not found. | | 17700004 | The specified user ID is not found. |
| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | | 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. |
| 17700101 | The system service is excepted. |
**Example** **Example**
...@@ -283,7 +282,7 @@ Defines the parameters that need to be specified for bundle installation, uninst ...@@ -283,7 +282,7 @@ Defines the parameters that need to be specified for bundle installation, uninst
| Name | Type | Mandatory | Description | | 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.| | 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.| | isKeepData | boolean | Yes | Whether to retain the data directory during bundle uninstall.|
| hashParams | Array<[HashParam](#hashparam)> | Yes| Hash parameters. | | hashParams | Array<[HashParam](#hashparam)> | Yes| Hash parameters. |
......
...@@ -23,8 +23,6 @@ hasInstalled(options: CheckPackageHasInstalledOptions): void ...@@ -23,8 +23,6 @@ hasInstalled(options: CheckPackageHasInstalledOptions): void
Checks whether an application exists, or whether a native application has been installed. Checks whether an application exists, or whether a native application has been installed.
**Required permissions**: none
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
......
...@@ -585,7 +585,7 @@ Fills a rectangle on the canvas. ...@@ -585,7 +585,7 @@ Fills a rectangle on the canvas.
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div> <div>
<canvas ref="canvas" style="width: 500px; height: 500px; "></canvas> <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div> </div>
``` ```
...@@ -621,7 +621,7 @@ Clears the content in a rectangle on the canvas. ...@@ -621,7 +621,7 @@ Clears the content in a rectangle on the canvas.
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div> <div>
<canvas ref="canvas" style="width: 500px; height: 500px;"></canvas> <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div> </div>
``` ```
...@@ -1735,9 +1735,9 @@ Creates a radial gradient and returns a **CanvasGradient** object. ...@@ -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) // Radial gradient: inner circle(200,200,r:50) outer circle(200,200,r:200)
var gradient = ctx.createRadialGradient(200,200,50, 200,200,200); var gradient = ctx.createRadialGradient(200,200,50, 200,200,200);
// Add three color stops // Add three color stops
gradient.addColorStop(0.0, 'red'); gradient.addColorStop(0.0, '#ff0000');
gradient.addColorStop(0.5, 'white'); gradient.addColorStop(0.5, '#ffffff');
gradient.addColorStop(1.0, 'green'); gradient.addColorStop(1.0, '#00ff00');
// Set the fill style and draw a rectangle // Set the fill style and draw a rectangle
ctx.fillStyle = gradient; ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 500, 500); ctx.fillRect(0, 0, 500, 500);
......
...@@ -95,12 +95,36 @@ Checks whether a specified point is in the path area. ...@@ -95,12 +95,36 @@ Checks whether a specified point is in the path area.
**Example** **Example**
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div style="width: 500px; height: 500px;"> <div class="container" style="width: 500px; height: 500px;">
<text>In path:{{textValue}}</text> <text class="textsize">In path:{{textValue}}</text>
<canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas> <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div> </div>
``` ```
```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 ```js
// xxx.js // xxx.js
export default { export default {
...@@ -145,12 +169,36 @@ Checks whether a specified point is on the edge line of a path. ...@@ -145,12 +169,36 @@ Checks whether a specified point is on the edge line of a path.
**Example** **Example**
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div style="width: 500px; height: 500px;"> <div class="container" style="width: 500px; height: 500px;">
<text>In path:{{textValue}}</text> <text class="textsize">In stroke:{{textValue}}</text>
<canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas> <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div> </div>
``` ```
```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 ```js
// xxx.js // xxx.js
export default { export default {
...@@ -181,12 +229,36 @@ resetTransform(): void ...@@ -181,12 +229,36 @@ resetTransform(): void
**Example** **Example**
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div style="width: 500px; height: 500px;"> <div class="container" style="width: 500px; height: 500px;">
<text>In path:{{textValue}}</text> <text class="textsize">In path:{{textValue}}</text>
<canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas> <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div> </div>
``` ```
```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 ```js
// xxx.js // xxx.js
export default { export default {
......
...@@ -36,7 +36,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -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.<br>Default value: **TextAlign.Start**| | textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Horizontal alignment of the text.<br>Default value: **TextAlign.Start**|
| caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box. | | caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box. |
| inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) => void<br>} | 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.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.| | inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) => void<br>} | 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.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.|
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.| | copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.|
## Events ## Events
......
...@@ -38,7 +38,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -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. | | caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box. |
| maxLength | number | Maximum number of characters in the text input. | | maxLength | number | Maximum number of characters in the text input. |
| inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) =&gt; void<br>} | 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.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.| | inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) =&gt; void<br>} | 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.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.|
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.| | copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.|
| showPasswordIcon<sup>9+</sup> | boolean | Whether to display the show password icon at the end of the password text box.<br>Default value: **true**| | showPasswordIcon<sup>9+</sup> | boolean | Whether to display the show password icon at the end of the password text box.<br>Default value: **true**|
| style<sup>9+</sup> | TextInputStyle | Text input style.<br>Default value: **TextInputStyle.Default**| | style<sup>9+</sup> | TextInputStyle | Text input style.<br>Default value: **TextInputStyle.Default**|
| textAlign<sup>9+</sup> | [TextAlign](ts-appendix-enums.md#textalign) | Alignment mode of the text in the text box.<br>Default value: **TextAlign.Start** | | textAlign<sup>9+</sup> | [TextAlign](ts-appendix-enums.md#textalign) | Alignment mode of the text in the text box.<br>Default value: **TextAlign.Start** |
...@@ -53,7 +53,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -53,7 +53,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Next | The Enter key is labeled "Next."| | Next | The Enter key is labeled "Next."|
| Done | The Enter key is labeled "Done." | | Done | The Enter key is labeled "Done." |
## InputType enums ## InputType
| Name | Description | | Name | Description |
| ------------------ | ------------- | | ------------------ | ------------- |
...@@ -70,7 +70,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -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. | | 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. | | 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. In addition to the [universal events](ts-universal-events-click.md), the following events are supported.
......
...@@ -683,7 +683,7 @@ Fills a rectangle on the canvas. ...@@ -683,7 +683,7 @@ Fills a rectangle on the canvas.
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.fillRect(0,30,100,100) this.context.fillRect(30,30,100,100)
}) })
} }
.width('100%') .width('100%')
...@@ -769,7 +769,7 @@ Clears the content in a rectangle on the canvas. ...@@ -769,7 +769,7 @@ Clears the content in a rectangle on the canvas.
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffffff') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.fillStyle = 'rgb(0,0,255)' this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(20,20,200,200) this.context.fillRect(20,20,200,200)
...@@ -1579,7 +1579,7 @@ struct Fill { ...@@ -1579,7 +1579,7 @@ struct Fill {
region.lineTo(270, 90) region.lineTo(270, 90)
region.closePath() region.closePath()
// Fill path // Fill path
this.context.fillStyle = 'green' this.context.fillStyle = '#00ff00'
this.context.fill(region, "evenodd") this.context.fill(region, "evenodd")
}) })
} }
...@@ -1666,10 +1666,15 @@ struct Clip { ...@@ -1666,10 +1666,15 @@ struct Clip {
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
let region = new Path2D() let region = new Path2D()
region.rect(80,10,20,130) region.moveTo(30, 90)
region.rect(40,50,100,50) 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.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) this.context.fillRect(0, 0, this.context.width, this.context.height)
}) })
} }
...@@ -1745,7 +1750,7 @@ Rotates a canvas clockwise around its coordinate axes. ...@@ -1745,7 +1750,7 @@ Rotates a canvas clockwise around its coordinate axes.
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .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) this.context.fillRect(70, 20, 50, 50)
}) })
} }
...@@ -1918,6 +1923,8 @@ setTransform(transform?: Matrix2D): void ...@@ -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. 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 ### translate
...@@ -2413,7 +2420,7 @@ Restores the saved drawing context. ...@@ -2413,7 +2420,7 @@ Restores the saved drawing context.
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.save() // save the default state this.context.save() // save the default state
this.context.fillStyle = "green" this.context.fillStyle = "#00ff00"
this.context.fillRect(20, 20, 100, 100) this.context.fillRect(20, 20, 100, 100)
this.context.restore() // restore to the default state this.context.restore() // restore to the default state
this.context.fillRect(150, 75, 100, 100) 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 ...@@ -2451,7 +2458,7 @@ Saves all states of the canvas in the stack. This API is usually called when the
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.save() // save the default state this.context.save() // save the default state
this.context.fillStyle = "green" this.context.fillStyle = "#00ff00"
this.context.fillRect(20, 20, 100, 100) this.context.fillRect(20, 20, 100, 100)
this.context.restore() // restore to the default state this.context.restore() // restore to the default state
this.context.fillRect(150, 75, 100, 100) this.context.fillRect(150, 75, 100, 100)
...@@ -2498,9 +2505,9 @@ Creates a linear gradient. ...@@ -2498,9 +2505,9 @@ Creates a linear gradient.
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var grad = this.context.createLinearGradient(50,0, 300,100) var grad = this.context.createLinearGradient(50,0, 300,100)
grad.addColorStop(0.0, 'red') grad.addColorStop(0.0, '#ff0000')
grad.addColorStop(0.5, 'white') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, 'green') grad.addColorStop(1.0, '#00ff00')
this.context.fillStyle = grad this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500) this.context.fillRect(0, 0, 500, 500)
}) })
...@@ -2549,9 +2556,9 @@ Creates a linear gradient. ...@@ -2549,9 +2556,9 @@ Creates a linear gradient.
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var grad = this.context.createRadialGradient(200,200,50, 200,200,200) var grad = this.context.createRadialGradient(200,200,50, 200,200,200)
grad.addColorStop(0.0, 'red') grad.addColorStop(0.0, '#ff0000')
grad.addColorStop(0.5, 'white') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, 'green') grad.addColorStop(1.0, '#00ff00')
this.context.fillStyle = grad this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500) this.context.fillRect(0, 0, 500, 500)
}) })
......
...@@ -27,9 +27,9 @@ Navigator(value?: {target: string, type?: NavigationType}) ...@@ -27,9 +27,9 @@ Navigator(value?: {target: string, type?: NavigationType})
| Name | Description | | 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.| | 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 ## Attributes
......
...@@ -727,7 +727,7 @@ Fills a rectangle on the canvas. ...@@ -727,7 +727,7 @@ Fills a rectangle on the canvas.
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.offContext.fillRect(0,30,100,100) this.offContext.fillRect(30,30,100,100)
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
}) })
...@@ -1767,10 +1767,15 @@ struct Clip { ...@@ -1767,10 +1767,15 @@ struct Clip {
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
let region = new Path2D() let region = new Path2D()
region.rect(80,10,20,130) region.moveTo(30, 90)
region.rect(40,50,100,50) 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.clip(region,"evenodd")
this.offContext.fillStyle = "rgb(255,0,0)" this.offContext.fillStyle = "rgb(0,255,0)"
this.offContext.fillRect(0, 0, 600, 600) this.offContext.fillRect(0, 0, 600, 600)
var image = this.offContext.transferToImageBitmap() var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image) this.context.transferFromImageBitmap(image)
......
...@@ -36,8 +36,6 @@ canvas { ...@@ -36,8 +36,6 @@ canvas {
```js ```js
// xxx.js // xxx.js
import promptAction from '@ohos.promptAction';
export default { export default {
onShow() { onShow() {
let ctx = this.$refs.canvas.getContext('2d', { let ctx = this.$refs.canvas.getContext('2d', {
...@@ -60,7 +58,7 @@ export default { ...@@ -60,7 +58,7 @@ export default {
path.closePath(); path.closePath();
// Door // Door
path.moveTo(250, 450); path.moveTo(250, 450);
path.rect(250, 450, 350, 600); path.rect(250, 450, 100, 600);
path.closePath(); path.closePath();
// Chimney // Chimney
path.moveTo(365, 250); path.moveTo(365, 250);
...@@ -139,8 +137,6 @@ text { ...@@ -139,8 +137,6 @@ text {
```js ```js
// xxx.js // xxx.js
import promptAction from '@ohos.promptAction';
export default { export default {
data: { data: {
ctx: null, ctx: null,
......
...@@ -596,7 +596,7 @@ struct GridRowSample6 { ...@@ -596,7 +596,7 @@ struct GridRowSample6 {
**示例7:** **示例7:**
通过order属性,控制GridCol的顺序。在sm和md断点下,按照至6的顺序排列显示;在lg断点下,按照6至1的顺序排列显示。 通过order属性,控制GridCol的顺序。在sm和md断点下,按照1至6的顺序排列显示;在lg断点下,按照6至1的顺序排列显示。
| sm | md | lg | | sm | md | lg |
......
...@@ -21,38 +21,48 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ...@@ -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) 详细API含义可参考:[音频管理API文档AudioCapturer](../reference/apis/js-apis-audio.md#audiocapturer8)
1. 使用createAudioCapturer()创建一个AudioCapturer实例。 1. 使用createAudioCapturer()创建一个全局的AudioCapturer实例。
在audioCapturerOptions中设置音频采集器的相关参数。该实例可用于音频采集、控制和获取采集状态,以及注册通知回调。 在audioCapturerOptions中设置音频采集器的相关参数。该实例可用于音频采集、控制和获取采集状态,以及注册通知回调。
```js ```js
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
import fs from '@ohos.file.fs'; //便于步骤3 read函数调用
let audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, //音频渲染相关接口自测试
channels: audio.AudioChannel.CHANNEL_1, @Entry
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, @Component
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW struct AudioRenderer {
} @State message: string = 'Hello World'
private audioCapturer : audio.AudioCapturer; //供全局调用
let audioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC, async initAudioCapturer(){
capturerFlags: 0 // 0是音频采集器的扩展标志位,默认为0 let audioStreamInfo = {
} samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_1,
let audioCapturerOptions = { sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
streamInfo: audioStreamInfo, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
capturerInfo: audioCapturerInfo }
}
let audioCapturerInfo = {
let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); source: audio.SourceType.SOURCE_TYPE_MIC,
console.log('AudioRecLog: Create audio capturer success.'); 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()方法来启动/恢复采集任务。 2. 调用start()方法来启动/恢复采集任务。
...@@ -60,23 +70,18 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ...@@ -60,23 +70,18 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以
启动完成后,采集器状态将变更为STATE_RUNNING,然后应用可以开始读取缓冲区。 启动完成后,采集器状态将变更为STATE_RUNNING,然后应用可以开始读取缓冲区。
```js ```js
import audio from '@ohos.multimedia.audio'; async startCapturer() {
let state = this.audioCapturer.state;
async function startCapturer() {
let state = audioCapturer.state;
// Capturer start时的状态应该是STATE_PREPARED、STATE_PAUSED和STATE_STOPPED之一. // Capturer start时的状态应该是STATE_PREPARED、STATE_PAUSED和STATE_STOPPED之一.
if (state != audio.AudioState.STATE_PREPARED || state != audio.AudioState.STATE_PAUSED || if (state == audio.AudioState.STATE_PREPARED || state == audio.AudioState.STATE_PAUSED ||
state != audio.AudioState.STATE_STOPPED) { state == audio.AudioState.STATE_STOPPED) {
console.info('Capturer is not in a correct state to start'); await this.audioCapturer.start();
return; state = this.audioCapturer.state;
} if (state == audio.AudioState.STATE_RUNNING) {
await audioCapturer.start(); console.info('AudioRecLog: Capturer started');
} else {
state = audioCapturer.state; console.error('AudioRecLog: Capturer start failed');
if (state == audio.AudioState.STATE_RUNNING) { }
console.info('AudioRecLog: Capturer started');
} else {
console.error('AudioRecLog: Capturer start failed');
} }
} }
``` ```
...@@ -86,91 +91,88 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ...@@ -86,91 +91,88 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以
参考以下示例,将采集到的数据写入文件。 参考以下示例,将采集到的数据写入文件。
```js ```js
import fs from '@ohos.file.fs'; async readData(){
let state = this.audioCapturer.state;
let state = audioCapturer.state; // 只有状态为STATE_RUNNING的时候才可以read.
// 只有状态为STATE_RUNNING的时候才可以read. if (state != audio.AudioState.STATE_RUNNING) {
if (state != audio.AudioState.STATE_RUNNING) { console.info('Capturer is not in a correct state to read');
console.info('Capturer is not in a correct state to read'); return;
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
} }
if (typeof(buffer) == undefined) { const path = '/data/data/.pulse_dir/capture_js.wav'; // 采集到的音频文件存储路径
console.info('AudioRecLog: read buffer failed'); let file = fs.openSync(path, 0o2);
let fd = file.fd;
if (file !== null) {
console.info('AudioRecLog: file created');
} else { } else {
let number = fs.writeSync(fd, buffer, options); console.info('AudioRecLog: file create : FAILED');
console.info(`AudioRecLog: data written: ${number}`); return;
} }
numBuffersToCapture--; if (fd !== null) {
count++; 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方法,停止录制。 4. 采集完成后,调用stop方法,停止录制。
```js ```js
async function StopCapturer() { async StopCapturer() {
let state = audioCapturer.state; let state = this.audioCapturer.state;
// 只有采集器状态为STATE_RUNNING或STATE_PAUSED的时候才可以停止 // 只有采集器状态为STATE_RUNNING或STATE_PAUSED的时候才可以停止
if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) { if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) {
console.info('AudioRecLog: Capturer is not running or paused'); console.info('AudioRecLog: Capturer is not running or paused');
return; return;
} }
await audioCapturer.stop(); await this.audioCapturer.stop();
state = audioCapturer.state; state = this.audioCapturer.state;
if (state == audio.AudioState.STATE_STOPPED) { if (state == audio.AudioState.STATE_STOPPED) {
console.info('AudioRecLog: Capturer stopped'); console.info('AudioRecLog: Capturer stopped');
} else { } else {
console.error('AudioRecLog: Capturer stop failed'); console.error('AudioRecLog: Capturer stop failed');
} }
} }
``` ```
5. 任务结束,调用release()方法释放相关资源。 5. 任务结束,调用release()方法释放相关资源。
```js ```js
async function releaseCapturer() { async releaseCapturer() {
let state = audioCapturer.state; let state = this.audioCapturer.state;
// 采集器状态不是STATE_RELEASED或STATE_NEW状态,才能release // 采集器状态不是STATE_RELEASED或STATE_NEW状态,才能release
if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) { if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) {
console.info('AudioRecLog: Capturer already released'); console.info('AudioRecLog: Capturer already released');
return; return;
} }
await audioCapturer.release(); await this.audioCapturer.release();
state = audioCapturer.state; state = this.audioCapturer.state;
if (state == audio.AudioState.STATE_RELEASED) { if (state == audio.AudioState.STATE_RELEASED) {
console.info('AudioRecLog: Capturer released'); console.info('AudioRecLog: Capturer released');
} else { } else {
console.info('AudioRecLog: Capturer release failed'); console.info('AudioRecLog: Capturer release failed');
} }
} }
``` ```
6. (可选)获取采集器相关信息 6. (可选)获取采集器相关信息
...@@ -178,23 +180,20 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ...@@ -178,23 +180,20 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以
通过以下代码,可以获取采集器的相关信息。 通过以下代码,可以获取采集器的相关信息。
```js ```js
// 获取当前采集器状态 async getAudioCapturerInfo(){
let state = audioCapturer.state; // 获取当前采集器状态
let state = this.audioCapturer.state;
// 获取采集器信息 // 获取采集器信息
let audioCapturerInfo : audio.AuduioCapturerInfo = await audioCapturer.getCapturerInfo(); let audioCapturerInfo : audio.AudioCapturerInfo = await this.audioCapturer.getCapturerInfo();
// 获取音频流信息
// 获取音频流信息 let audioStreamInfo : audio.AudioStreamInfo = await this.audioCapturer.getStreamInfo();
let audioStreamInfo : audio.AudioStreamInfo = await audioCapturer.getStreamInfo(); // 获取音频流ID
let audioStreamId : number = await this.audioCapturer.getAudioStreamId();
// 获取音频流ID // 获取纳秒形式的Unix时间戳
let audioStreamId : number = await audioCapturer.getAudioStreamId(); let audioTime : number = await this.audioCapturer.getAudioTime();
// 获取合理的最小缓冲区大小
// 获取纳秒形式的Unix时间戳 let bufferSize : number = await this.audioCapturer.getBufferSize();
let audioTime : number = await audioCapturer.getAudioTime(); }
// 获取合理的最小缓冲区大小
let bufferSize : number = await audioCapturer.getBufferSize();
``` ```
7. (可选)使用on('markReach')方法订阅采集器标记到达事件,使用off('markReach')取消订阅事件。 7. (可选)使用on('markReach')方法订阅采集器标记到达事件,使用off('markReach')取消订阅事件。
...@@ -202,12 +201,13 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ...@@ -202,12 +201,13 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以
注册markReach监听后,当采集器采集的帧数到达设定值时,会触发回调并返回设定的值。 注册markReach监听后,当采集器采集的帧数到达设定值时,会触发回调并返回设定的值。
```js ```js
audioCapturer.on('markReach', (reachNumber) => { async markReach(){
console.info('Mark reach event Received'); this.audioCapturer.on('markReach', 10, (reachNumber) => {
console.info(`The Capturer reached frame: ${reachNumber}`); console.info('Mark reach event Received');
}); console.info(`The Capturer reached frame: ${reachNumber}`);
});
audioCapturer.off('markReach'); // 取消markReach事件的订阅,后续将无法监听到“标记到达”事件 this.audioCapturer.off('markReach'); // 取消markReach事件的订阅,后续将无法监听到“标记到达”事件
}
``` ```
8. (可选)使用on('periodReach')方法订阅采集器区间标记到达事件,使用off('periodReach')取消订阅事件。 8. (可选)使用on('periodReach')方法订阅采集器区间标记到达事件,使用off('periodReach')取消订阅事件。
...@@ -215,40 +215,43 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ...@@ -215,40 +215,43 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以
注册periodReach监听后,**每当**采集器采集的帧数到达设定值时,会触发回调并返回设定的值。 注册periodReach监听后,**每当**采集器采集的帧数到达设定值时,会触发回调并返回设定的值。
```js ```js
audioCapturer.on('periodReach', (reachNumber) => { async periodReach(){
console.info('Period reach event Received'); this.audioCapturer.on('periodReach', 10, (reachNumber) => {
console.info(`In this period, the Capturer reached frame: ${reachNumber}`); console.info('Period reach event Received');
}); console.info(`In this period, the Capturer reached frame: ${reachNumber}`);
});
audioCapturer.off('periodReach'); // 取消periodReach事件的订阅,后续将无法监听到“区间标记到达”事件 this.audioCapturer.off('periodReach'); // 取消periodReach事件的订阅,后续将无法监听到“区间标记到达”事件
}
``` ```
9. 如果应用需要在采集器状态更新时进行一些操作,可以订阅该事件,当采集器状态更新时,会受到一个包含有事件类型的回调。 9. 如果应用需要在采集器状态更新时进行一些操作,可以订阅该事件,当采集器状态更新时,会受到一个包含有事件类型的回调。
```js ```js
audioCapturer.on('stateChange', (state) => { async stateChange(){
console.info(`AudioCapturerLog: Changed State to : ${state}`) this.audioCapturer.on('stateChange', (state) => {
switch (state) { console.info(`AudioCapturerLog: Changed State to : ${state}`)
case audio.AudioState.STATE_PREPARED: switch (state) {
console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------'); case audio.AudioState.STATE_PREPARED:
console.info('Audio State is : Prepared'); console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------');
break; console.info('Audio State is : Prepared');
case audio.AudioState.STATE_RUNNING: break;
console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------'); case audio.AudioState.STATE_RUNNING:
console.info('Audio State is : Running'); console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------');
break; console.info('Audio State is : Running');
case audio.AudioState.STATE_STOPPED: break;
console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------'); case audio.AudioState.STATE_STOPPED:
console.info('Audio State is : stopped'); console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------');
break; console.info('Audio State is : stopped');
case audio.AudioState.STATE_RELEASED: break;
console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------'); case audio.AudioState.STATE_RELEASED:
console.info('Audio State is : released'); console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------');
break; console.info('Audio State is : released');
default: break;
console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------'); default:
console.info('Audio State is : invalid'); console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------');
break; console.info('Audio State is : invalid');
} break;
}); }
});
}
``` ```
\ No newline at end of file
...@@ -126,7 +126,11 @@ ...@@ -126,7 +126,11 @@
- [@ohos.notification (Notification模块)(待停用)](js-apis-notification.md) - [@ohos.notification (Notification模块)(待停用)](js-apis-notification.md)
- application - application
- [EventHub](js-apis-inner-application-eventHub.md) - [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.appControl (appControl模块)](js-apis-appControl.md)
- [@ohos.bundle.bundleManager (bundleManager模块)](js-apis-bundleManager.md) - [@ohos.bundle.bundleManager (bundleManager模块)](js-apis-bundleManager.md)
......
...@@ -4533,15 +4533,15 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav'; ...@@ -4533,15 +4533,15 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
let stat = await fs.stat(path); let stat = await fs.stat(path);
let buf = new ArrayBuffer(bufferSize); 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++) { for (let i = 0;i < len; i++) {
let options = { let options = {
offset: i * this.bufferSize, offset: i * bufferSize,
length: this.bufferSize length: bufferSize
} }
let readsize = await fs.read(file.fd, buf, options) let readsize = await fs.read(file.fd, buf, options)
let writeSize = await new Promise((resolve,reject)=>{ let writeSize = await new Promise((resolve,reject)=>{
this.audioRenderer.write(buf,(err,writeSize)=>{ audioRenderer.write(buf,(err,writeSize)=>{
if(err){ if(err){
reject(err) reject(err)
}else{ }else{
...@@ -4586,15 +4586,15 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav'; ...@@ -4586,15 +4586,15 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
let stat = await fs.stat(path); let stat = await fs.stat(path);
let buf = new ArrayBuffer(bufferSize); 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++) { for (let i = 0;i < len; i++) {
let options = { let options = {
offset: i * this.bufferSize, offset: i * bufferSize,
length: this.bufferSize length: bufferSize
} }
let readsize = await fs.read(file.fd, buf, options) let readsize = await fs.read(file.fd, buf, options)
try{ try{
let writeSize = await this.audioRenderer.write(buf); let writeSize = await audioRenderer.write(buf);
} catch(err) { } catch(err) {
console.error(`audioRenderer.write err: ${err}`); console.error(`audioRenderer.write err: ${err}`);
} }
......
...@@ -188,8 +188,8 @@ bundle.getBundleInstaller().then(installer => { ...@@ -188,8 +188,8 @@ bundle.getBundleInstaller().then(installer => {
**示例:** **示例:**
``` ts ``` ts
// Stage模型 // Stage模型
import Ability from '@ohos.application.Ability'; import UIAbility from '@ohos.app.ability.UIAbility';
class MainAbility extends Ability { export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
let context = this.context; let context = this.context;
let pathDir = context.filesDir; let pathDir = context.filesDir;
......
...@@ -16,31 +16,37 @@ import cardEmulation from '@ohos.nfc.cardEmulation'; ...@@ -16,31 +16,37 @@ import cardEmulation from '@ohos.nfc.cardEmulation';
定义不同的NFC卡模拟类型。 定义不同的NFC卡模拟类型。
> **说明:**
> 从 API version 6 开始支持,从 API version 9 开始废弃,建议使用[hasHceCapability](#hashcecapability9)替代。
**系统能力:** SystemCapability.Communication.NFC.CardEmulation **系统能力:** SystemCapability.Communication.NFC.CardEmulation
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| HCE | 0 | HCE 卡模拟。 | | HCE | 0 | HCE 卡模拟。 |
| UICC | 1 | SIM 卡模拟。 | | UICC | 1 | SIM 卡模拟。 |
| ESE | 2 | ESE卡模拟。 | | ESE | 2 | ESE卡模拟。 |
## CardType ## CardType<sup>9+</sup>
定义卡模拟应用是支付类型,还是非支付类型。 定义卡模拟应用所使用的业务类型,是支付类型,还是其他类型。
**系统能力:** SystemCapability.Communication.NFC.CardEmulation **系统能力:** SystemCapability.Communication.NFC.CardEmulation
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| PAYMENT | "payment" | 卡模拟应用是支付类型。 | | PAYMENT | "payment" | 卡模拟应用所使用的业务是支付类型。 |
| OTHER | "other" | 卡模拟应用是非支付类型。 | | OTHER | "other" | 卡模拟应用所使用的业务是其他类型。 |
## cardEmulation.isSupported ## isSupported
isSupported(feature: number): boolean isSupported(feature: number): boolean
是否支持某种类型的卡模拟。 是否支持某种类型的卡模拟。
> **说明:**
> 从 API version 6 开始支持,从 API version 9 开始废弃,建议使用[hasHceCapability](#hashcecapability9)替代。
**系统能力:** SystemCapability.Communication.NFC.CardEmulation **系统能力:** SystemCapability.Communication.NFC.CardEmulation
**参数:** **参数:**
...@@ -55,89 +61,44 @@ isSupported(feature: number): boolean ...@@ -55,89 +61,44 @@ isSupported(feature: number): boolean
| -------- | -------- | | -------- | -------- |
| boolean | true: 支持该类型卡模拟,&nbsp;false: 不支持该类型卡模拟。| | boolean | true: 支持该类型卡模拟,&nbsp;false: 不支持该类型卡模拟。|
## cardEmulation.isDefaultService ## hasHceCapability<sup>9+</sup>
isDefaultService(elementName: ElementName, type: CardType): boolean hasHceCapability(): boolean
判断指定的应用是否为默认支付应用 判断是否支持HCE功能
**系统能力:** SystemCapability.Communication.NFC.CardEmulation **系统能力:** SystemCapability.Communication.NFC.CardEmulation
**参数:** **需要权限:** ohos.permission.NFC_CARD_EMULATION
| 参数名 | 类型 | 必填 | 说明 |
| ------- | -------- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | 是 | 应用的描述,由包名和组件名组成。 |
| type | [CardType](#cardtype) | 是 | 应用的描述,由包名和组件名组成。 |
**返回值:** **返回值:**
| **类型** | **说明** | | **类型** | **说明** |
| -------- | -------- | | -------- | -------- |
| boolean | true: 是默认支付应用,&nbsp;false: 不是默认支付应用。| | boolean | true: 支持HCE,&nbsp;false: 不支持HCE。|
## HceService<sup>8+</sup>
提供HCE卡模拟的实现,主要包括接收对端读卡设备的APDU数据,并响应APDU数据到对端读卡设备。使用HCE相关接口前,必须先判断设备是否支持HCE卡模拟能力。 ## isDefaultService<sup>9+</sup>
### startHCE<sup>8+</sup> isDefaultService(elementName: ElementName, type: CardType): boolean
startHCE(aidList: string[]): boolean 判断指定的应用是否为指定业务类型的默认应用。
启动HCE业务功能。包括设置当前应用为前台优先,动态注册AID列表。 **系统能力:** SystemCapability.Communication.NFC.CardEmulation
**需要权限:** ohos.permission.NFC_CARD_EMULATION **需要权限:** ohos.permission.NFC_CARD_EMULATION
**系统能力:** SystemCapability.Communication.NFC.CardEmulation
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | -------- | ---- | ----------------------- | | ------- | -------- | ---- | ----------------------- |
| aidList | string[] | 是 | 动态注册卡模拟的AID列表。 | | elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | 是 | 应用的描述,由Bundle名称和组件名称组成。 |
| type | [CardType](#cardtype9) | 是 | 卡模拟业务类型。 |
### stopHCE<sup>8+</sup>
stopHCE(): boolean
停止HCE业务功能。包括退出当前应用前台优先,释放动态注册的AID列表。
**需要权限:** ohos.permission.NFC_CARD_EMULATION
**系统能力:** SystemCapability.Communication.NFC.CardEmulation
### on<sup>8+</sup>
on(type: "hceCmd", callback: AsyncCallback<number[]>): void;
订阅回调,用于接收对端读卡设备发送的APDU数据。 **返回值:**
**需要权限:** ohos.permission.NFC_CARD_EMULATION
**系统能力:** SystemCapability.Communication.NFC.CardEmulation
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | -------------------------------------------- |
| type | string | 是 | 固定填"hceCmd"字符串。 |
| callback | AsyncCallback<number[]> | 是 | 订阅的事件回调,入参是符合APDU协议的数据,每个number十六进制表示,范围是0x00~0xFF。 |
### sendResponse<sup>8+</sup>
sendResponse(responseApdu: number[]): void;
发送APDU数据到对端读卡设备。
**需要权限:** ohos.permission.NFC_CARD_EMULATION
**系统能力:** SystemCapability.Communication.NFC.CardEmulation
**参数:**
| 参数名 | 类型 | 必填 | 说明 | | **类型** | **说明** |
| ------------ | -------- | ---- | -------------------------------------------------- | | -------- | -------- |
| responseApdu | number[] | 是 | 发送到对端读卡设备的符合APDU协议的数据,每个number十六进制表示,范围是0x00~0xFF。 | | boolean | true: 是默认支付应用,&nbsp;false: 不是默认支付应用。|
**示例:** **示例:**
...@@ -150,31 +111,17 @@ if (!isHceSupported) { ...@@ -150,31 +111,17 @@ if (!isHceSupported) {
return; return;
} }
var hasHceCap = cardEmulation.hasHceCapability();
if (!hasHceCap) {
console.log('this device hasHceCapability false, ignore it.');
return;
}
var elementName = { var elementName = {
"bundleName": "com.test.cardemulation", "bundleName": "com.test.cardemulation",
"abilityName": "com.test.cardemulation.MainAbility", "abilityName": "com.test.cardemulation.MainAbility",
}; };
var isDefaultService = cardEmulation.isDefaultService(elementName, cardEmulation.CardType.PAYMENT); var isDefaultService = cardEmulation.isDefaultService(elementName, cardEmulation.CardType.PAYMENT);
console.log('is the app is default service for this card type: ' + isDefaultService); 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();
``` ```
...@@ -171,7 +171,7 @@ CommonEvent模块支持的事件类型。名称指的是系统公共事件宏; ...@@ -171,7 +171,7 @@ CommonEvent模块支持的事件类型。名称指的是系统公共事件宏;
| COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | 表示通知通道更新的动作。 | | COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | 表示通知通道更新的动作。 |
| COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | 无 | 表示spn显示信息已更新的公共事件的动作。 | | COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | 无 | 表示spn显示信息已更新的公共事件的动作。 |
| COMMON_EVENT_QUICK_FIX_APPLY_RESULT <sup>9+<sup> | usual.event.QUICK_FIX_APPLY_RESULT | 无 | 指示快速修复应用的动作。 | | COMMON_EVENT_QUICK_FIX_APPLY_RESULT <sup>9+<sup> | usual.event.QUICK_FIX_APPLY_RESULT | 无 | 指示快速修复应用的动作。 |
| COMMON_EVENT_USER_INFO_UPDATED<sup>9+<sup> | usual.event.USER_INFO_UPDATED | 无 | 表示用户信息已更新。|
## CommonEvent.publish ## CommonEvent.publish
...@@ -219,7 +219,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ ...@@ -219,7 +219,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ---------------------- | | -------- | ---------------------- | ---- | ---------------------- |
| event | string | 是 | 表示要发布的公共事件。 | | event | string | 是 | 表示要发布的公共事件。 |
| options | [CommonEventPublishData](#commoneventpublishdata) | 是 | 表示发布公共事件的属性。 | | options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 |
| callback | syncCallback\<void> | 是 | 表示被指定的回调方法。 | | callback | syncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:** **示例:**
...@@ -303,7 +303,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca ...@@ -303,7 +303,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca
| -------- | ---------------------- | ---- | ---------------------- | | -------- | ---------------------- | ---- | ---------------------- |
| event | string | 是 | 表示要发布的公共事件。 | | event | string | 是 | 表示要发布的公共事件。 |
| userId | number | 是 | 表示指定向该用户ID发送此公共事件。 | | userId | number | 是 | 表示指定向该用户ID发送此公共事件。 |
| options | [CommonEventPublishData](#commoneventpublishdata) | 是 | 表示发布公共事件的属性。 | | options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:** **示例:**
...@@ -346,8 +346,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac ...@@ -346,8 +346,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------------------------------------ | ---- | -------------------------- | | ------------- | ------------------------------------------------------------ | ---- | -------------------------- |
| subscribeInfo | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | 是 | 表示订阅信息。 | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 |
| callback | AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | 是 | 表示创建订阅者的回调方法。 | | callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 是 | 表示创建订阅者的回调方法。 |
**示例:** **示例:**
...@@ -388,12 +388,12 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS ...@@ -388,12 +388,12 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | ----------------------------------------------------- | ---- | -------------- | | ------------- | ----------------------------------------------------- | ---- | -------------- |
| subscribeInfo | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | 是 | 表示订阅信息。 | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| --------------------------------------------------------- | ---------------- | | --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](#commoneventsubscriber)> | 返回订阅者对象。 | | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 返回订阅者对象。 |
**示例:** **示例:**
...@@ -428,8 +428,8 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven ...@@ -428,8 +428,8 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------------------- | ---- | -------------------------------- | | ---------- | ---------------------------------------------------- | ---- | -------------------------------- |
| subscriber | [CommonEventSubscriber](#commoneventsubscriber) | 是 | 表示订阅者对象。 | | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 |
| callback | AsyncCallback\<[CommonEventData](#commoneventdata)> | 是 | 表示接收公共事件数据的回调函数。 | | callback | AsyncCallback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | 是 | 表示接收公共事件数据的回调函数。 |
**示例:** **示例:**
...@@ -480,7 +480,7 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): ...@@ -480,7 +480,7 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ----------------------------------------------- | ---- | ------------------------ | | ---------- | ----------------------------------------------- | ---- | ------------------------ |
| subscriber | [CommonEventSubscriber](#commoneventsubscriber) | 是 | 表示订阅者对象。 | | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 |
| callback | AsyncCallback\<void> | 否 | 表示取消订阅的回调方法。 | | callback | AsyncCallback\<void> | 否 | 表示取消订阅的回调方法。 |
**示例:** **示例:**
...@@ -526,6 +526,7 @@ function unsubscribeCallBack(err) { ...@@ -526,6 +526,7 @@ function unsubscribeCallBack(err) {
//创建订阅者 //创建订阅者
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
<<<<<<< HEAD
//取消订阅公共事件 //取消订阅公共事件
CommonEvent.unsubscribe(subscriber, unsubscribeCallBack); CommonEvent.unsubscribe(subscriber, unsubscribeCallBack);
``` ```
...@@ -1278,4 +1279,9 @@ subscriber.finishCommonEvent().then(() => { ...@@ -1278,4 +1279,9 @@ subscriber.finishCommonEvent().then(() => {
| publisherPermission | string | 是 | 否 | 表示发布者的权限。 | | publisherPermission | string | 是 | 否 | 表示发布者的权限。 |
| publisherDeviceId | string | 是 | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID。 | | publisherDeviceId | string | 是 | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID。 |
| userId | number | 是 | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 | | userId | number | 是 | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 |
| priority | number | 是 | 否 | 表示订阅者的优先级。值的范围是-100到1000。 | | priority | number | 是 | 否 | 表示订阅者的优先级。值的范围是-100到1000。 |
\ No newline at end of file =======
// 取消订阅公共事件
CommonEvent.unsubscribe(subscriber, unsubscribeCB);
```
>>>>>>> a6c9265cd... common event docs fix
...@@ -235,7 +235,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ ...@@ -235,7 +235,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ---------------------- | | -------- | ---------------------- | ---- | ---------------------- |
| event | string | 是 | 表示要发布的公共事件。 | | event | string | 是 | 表示要发布的公共事件。 |
| options | [CommonEventPublishData](#commoneventpublishdata) | 是 | 表示发布公共事件的属性。 | | options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 |
| callback | syncCallback\<void> | 是 | 表示被指定的回调方法。 | | callback | syncCallback\<void> | 是 | 表示被指定的回调方法。 |
**错误码:** **错误码:**
...@@ -344,7 +344,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca ...@@ -344,7 +344,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca
| -------- | ---------------------- | ---- | ---------------------- | | -------- | ---------------------- | ---- | ---------------------- |
| event | string | 是 | 表示要发布的公共事件。 | | event | string | 是 | 表示要发布的公共事件。 |
| userId | number | 是 | 表示指定向该用户ID发送此公共事件。 | | userId | number | 是 | 表示指定向该用户ID发送此公共事件。 |
| options | [CommonEventPublishData](#commoneventpublishdata) | 是 | 表示发布公共事件的属性。 | | options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**错误码:** **错误码:**
...@@ -399,8 +399,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac ...@@ -399,8 +399,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------------------------------------ | ---- | -------------------------- | | ------------- | ------------------------------------------------------------ | ---- | -------------------------- |
| subscribeInfo | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | 是 | 表示订阅信息。 | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 |
| callback | AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | 是 | 表示创建订阅者的回调方法。 | | callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 是 | 表示创建订阅者的回调方法。 |
**示例:** **示例:**
...@@ -445,12 +445,12 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS ...@@ -445,12 +445,12 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | ----------------------------------------------------- | ---- | -------------- | | ------------- | ----------------------------------------------------- | ---- | -------------- |
| subscribeInfo | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | 是 | 表示订阅信息。 | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| --------------------------------------------------------- | ---------------- | | --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](#commoneventsubscriber)> | 返回订阅者对象。 | | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 返回订阅者对象。 |
**示例:** **示例:**
...@@ -490,8 +490,8 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven ...@@ -490,8 +490,8 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------------------- | ---- | -------------------------------- | | ---------- | ---------------------------------------------------- | ---- | -------------------------------- |
| subscriber | [CommonEventSubscriber](#commoneventsubscriber) | 是 | 表示订阅者对象。 | | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 |
| callback | AsyncCallback\<[CommonEventData](#commoneventdata)> | 是 | 表示接收公共事件数据的回调函数。 | | callback | AsyncCallback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | 是 | 表示接收公共事件数据的回调函数。 |
**示例:** **示例:**
...@@ -551,7 +551,7 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): ...@@ -551,7 +551,7 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ----------------------------------------------- | ---- | ------------------------ | | ---------- | ----------------------------------------------- | ---- | ------------------------ |
| subscriber | [CommonEventSubscriber](#commoneventsubscriber) | 是 | 表示订阅者对象。 | | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 |
| callback | AsyncCallback\<void> | 否 | 表示取消订阅的回调方法。 | | callback | AsyncCallback\<void> | 否 | 表示取消订阅的回调方法。 |
**示例:** **示例:**
...@@ -606,6 +606,7 @@ try { ...@@ -606,6 +606,7 @@ try {
} catch (err) { } catch (err) {
console.info("unsubscribe failed " + JSON.stringify(err)); console.info("unsubscribe failed " + JSON.stringify(err));
} }
<<<<<<< HEAD
``` ```
## CommonEventSubscriber ## CommonEventSubscriber
...@@ -1350,4 +1351,7 @@ subscriber.finishCommonEvent().then(() => { ...@@ -1350,4 +1351,7 @@ subscriber.finishCommonEvent().then(() => {
| publisherPermission | string | 是 | 否 | 表示发布者的权限。 | | publisherPermission | string | 是 | 否 | 表示发布者的权限。 |
| publisherDeviceId | string | 是 | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID。 | | publisherDeviceId | string | 是 | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID。 |
| userId | number | 是 | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 | | userId | number | 是 | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 |
| priority | number | 是 | 否 | 表示订阅者的优先级。值的范围是-100到1000。 | | priority | number | 是 | 否 | 表示订阅者的优先级。值的范围是-100到1000。 |
\ No newline at end of file =======
```
>>>>>>> a6c9265cd... common event docs fix
...@@ -30,7 +30,7 @@ getRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback&lt;Rd ...@@ -30,7 +30,7 @@ getRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback&lt;Rd
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ |
| context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | | context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 |
| config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | | config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 |
| callback | AsyncCallback&lt;[RdbStore](#rdbstore)&gt; | 是 | 指定callback回调函数,返回RdbStore对象。 | | callback | AsyncCallback&lt;[RdbStore](#rdbstore)&gt; | 是 | 指定callback回调函数,返回RdbStore对象。 |
...@@ -108,7 +108,7 @@ getRdbStore(context: Context, config: StoreConfig): Promise&lt;RdbStore&gt; ...@@ -108,7 +108,7 @@ getRdbStore(context: Context, config: StoreConfig): Promise&lt;RdbStore&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | -------------------------------- | ---- | ------------------------------------------------------------ | | ------- | -------------------------------- | ---- | ------------------------------------------------------------ |
| context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | | context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 |
| config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | | config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 |
**返回值** **返回值**
...@@ -188,7 +188,7 @@ deleteRdbStore(context: Context, name: string, callback: AsyncCallback&lt;void&g ...@@ -188,7 +188,7 @@ deleteRdbStore(context: Context, name: string, callback: AsyncCallback&lt;void&g
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | | context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 |
| name | string | 是 | 数据库名称。 | | name | string | 是 | 数据库名称。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 指定callback回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 指定callback回调函数。 |
...@@ -249,7 +249,7 @@ deleteRdbStore(context: Context, name: string): Promise&lt;void&gt; ...@@ -249,7 +249,7 @@ deleteRdbStore(context: Context, name: string): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ------- | ---- | ------------------------------------------------------------ | | ------- | ------- | ---- | ------------------------------------------------------------ |
| context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | | context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 |
| name | string | 是 | 数据库名称。 | | name | string | 是 | 数据库名称。 |
**返回值** **返回值**
...@@ -363,6 +363,8 @@ class EntryAbility extends UIAbility { ...@@ -363,6 +363,8 @@ class EntryAbility extends UIAbility {
描述订阅类型。 描述订阅类型。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
...@@ -2430,9 +2432,9 @@ store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, r ...@@ -2430,9 +2432,9 @@ store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, r
let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
predicates.inDevices(['12345678abcde']); predicates.inDevices(['12345678abcde']);
let promise = store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates); let promise = store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates);
promise.then((resultSet) =>{ promise.then((result) =>{
console.info(`Sync done.`); 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]}`); console.info(`device= ${result[i][0]}, status= ${result[i][1]}`);
} }
}).catch((err) => { }).catch((err) => {
...@@ -2511,10 +2513,12 @@ try { ...@@ -2511,10 +2513,12 @@ try {
首先需要获取resultSet对象。 首先需要获取resultSet对象。
```js ```js
let resultSet = null;
let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
predicates.equalTo("AGE", 18); predicates.equalTo("AGE", 18);
let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); 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 columnNames: ${resultSet.columnNames}`);
console.info(`resultSet columnCount: ${resultSet.columnCount}`); console.info(`resultSet columnCount: ${resultSet.columnCount}`);
}); });
...@@ -2685,7 +2689,7 @@ goToRow(position: number): boolean ...@@ -2685,7 +2689,7 @@ goToRow(position: number): boolean
let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promise.then((resultSet) => { promise.then((resultSet) => {
resultSet.(5); resultSet.goToRow(5);
resultSet.close(); resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`query failed, err: ${err}`); console.error(`query failed, err: ${err}`);
......
...@@ -6,6 +6,7 @@ fileAccess模块是基于extension机制实现的一个对公共文件访问和 ...@@ -6,6 +6,7 @@ fileAccess模块是基于extension机制实现的一个对公共文件访问和
> >
>- 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 >- 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>- 本模块接口为系统接口,三方应用不支持调用,当前只支持filepicker、文件管理器调用。 >- 本模块接口为系统接口,三方应用不支持调用,当前只支持filepicker、文件管理器调用。
>- 本模块支持对错误码进行处理,错误码及其适配方式[参考文档](../errorcodes/errorcode-filemanagement.md#错误码适配指导)。
## 导入模块 ## 导入模块
......
...@@ -1059,7 +1059,7 @@ constructor(country: string, options?: PhoneNumberFormatOptions) ...@@ -1059,7 +1059,7 @@ constructor(country: string, options?: PhoneNumberFormatOptions)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ---------------------------------------- | ---- | ---------------- | | ------- | ---------------------------------------- | ---- | ---------------- |
| country | string | 是 | 表示电话号码所属国家或地区代码。 | | country | string | 是 | 表示电话号码所属国家或地区代码。 |
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | 否 | 电话号码格式化对象的相关选项。 | | options | [PhoneNumberFormatOptions](#phonenumberformatoptions9) | 否 | 电话号码格式化对象的相关选项。 |
**示例:** **示例:**
```js ```js
...@@ -1149,7 +1149,7 @@ getLocationName(number: string, locale: string): string ...@@ -1149,7 +1149,7 @@ getLocationName(number: string, locale: string): string
``` ```
## PhoneNumberFormatOptions<sup>8+</sup> ## PhoneNumberFormatOptions<sup>9+</sup>
表示电话号码格式化对象可设置的属性。 表示电话号码格式化对象可设置的属性。
......
# CommonEventData
**系统能力:** `SystemCapability.Notification.CommonEvent`
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------- |-------------------- | ---- | ---- | ------------------------------------------------------- |
| event | string | 是 | 否 | 表示当前接收的公共事件名称。 |
| bundleName | string | 是 | 否 | 表示包名称。 |
| code | number | 是 | 否 | 表示公共事件的结果代码,用于传递int类型的数据。 |
| data | string | 是 | 否 | 表示公共事件的自定义结果数据,用于传递string类型的数据。 |
| parameters | {[key: string]: any} | 是 | 否 | 表示公共事件的附加信息。 |
\ No newline at end of file
# CommonEventPublishData
**系统能力:** `SystemCapability.Notification.CommonEvent`
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------------- | -------------------- | ---- | ---- | ---------------------------- |
| bundleName | string | 是 | 否 | 表示包名称。 |
| code | number | 是 | 否 | 表示公共事件的结果代码。 |
| data | string | 是 | 否 | 表示公共事件的自定义结果数据。 |
| subscriberPermissions | Array\<string> | 是 | 否 | 表示订阅者的权限。 |
| isOrdered | boolean | 是 | 否 | 表示是否是有序事件。 |
| isSticky | boolean | 是 | 否 | 表示是否是粘性事件。仅系统应用或系统服务允许发送粘性事件。 |
| parameters | {[key: string]: any} | 是 | 否 | 表示公共事件的附加信息。 |
\ No newline at end of file
# CommonEventSubscribeInfo
**系统能力:** `SystemCapability.Notification.CommonEvent`
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| events | Array\<string> | 是 | 否 | 表示要发送的公共事件。 |
| publisherPermission | string | 是 | 否 | 表示发布者的权限。 |
| publisherDeviceId | string | 是 | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID。 |
| userId | number | 是 | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 |
| priority | number | 是 | 否 | 表示订阅者的优先级。值的范围是-100到1000。 |
\ No newline at end of file
# CommonEventSubscriber
## getCode
```ts
getCode(callback: AsyncCallback<number>): void
```
以回调形式获取公共事件代码。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------------ |
| callback | AsyncCallback\<number\> | 是 | 公共事件代码。 |
**示例:**
```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<number>
```
以Promise形式获取公共事件代码。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<number> | 公共事件代码。 |
**示例:**
```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>): void
```
以回调形式设置公共事件的代码。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ---------------------- |
| code | number | 是 | 公共事件的代码。 |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:**
```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<void>
```
以Promise形式设置公共事件的代码。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------ |
| code | number | 是 | 公共事件的代码。 |
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个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<string>): void
```
以回调形式获取公共事件的数据。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | 是 | 公共事件的数据。 |
**示例:**
```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<string>
```
以Promise形式获取公共事件的数据。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ---------------- | ------------------ |
| Promise\<string> | 公共事件的数据。 |
**示例:**
```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>): void
以回调形式设置公共事件的数据。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------- |
| data | string | 是 | 公共事件的数据。 |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:**
```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<void>
```
以Promise形式设置公共事件的果数据。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------- |
| data | string | 是 | 公共事件的数据。 |
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个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>): void
```
以回调形式设置公共事件代码和数据。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ---------------------- |
| code | number | 是 | 公共事件的代码。 |
| data | string | 是 | 公共事件的数据。 |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:**
```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<void>
```
以Promise形式设置公共事件的代码和数据。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------- |
| code | number | 是 | 公共事件的代码。 |
| data | string | 是 | 公共事件的数据。 |
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个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<boolean>): void
```
以回调形式查询当前公共事件的是否为有序公共事件。
返回true代表是有序公共事件,false代表不是有序公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | 是 | 当前公共事件的是否为有序公共事件。 |
**示例:**
```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<boolean>
```
以Promise形式查询当前公共事件的是否为有序公共事件。
返回true代表是有序公共事件,false代表不是有序公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ----------------- | -------------------------------- |
| Promise\<boolean> | 当前公共事件的是否为有序公共事件。 |
**示例:**
```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<boolean>): void
```
以回调形式检查当前公共事件是否为一个粘性事件。
返回true代表是粘性公共事件,false代表不是粘性公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | 是 | 当前公共事件的是否为粘性公共事件。 |
**示例:**
```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<boolean>
```
以Promise形式检查当前公共事件是否为一个粘性事件。
返回true代表是粘性公共事件,false代表不是粘性公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ----------------- | -------------------------------- |
| Promise\<boolean> | 当前公共事件的是否为粘性公共事件。 |
**示例:**
```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>): void
```
以回调形式取消当前的有序公共事件,取消后,有序公共事件不再向下一个订阅者传递。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | 是 | 取消当前的有序公共事件。 |
**示例:**
```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<void>
```
以Promise形式取消当前的有序公共事件,取消后,公共事件不再向下一个订阅者传递。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个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>): void
```
以回调形式清除当前有序公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:**
```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<void>
```
以Promise形式清除当前有序公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个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<boolean>): void
```
以回调形式获取当前有序公共事件是否取消的状态。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | 是 | 表示当前有序公共事件是否取消的状态。 |
**示例:**
```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<boolean>
```
以Promise形式获取当前有序公共事件是否取消的状态。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ----------------- | ---------------------------------- |
| Promise\<boolean> | 表示当前有序公共事件是否取消的状态。 |
**示例:**
```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<CommonEventSubscribeInfo>): 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<CommonEventSubscribeInfo>
```
以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}`);
});
```
## finishCommonEvent<sup>9+</sup>
```ts
finishCommonEvent(callback: AsyncCallback<void>): void
```
以回调形式结束当前有序公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------------------- |
| callback | AsyncCallback\<void> | 是 | 表示有序公共事件结束后的回调函数。 |
**示例:**
```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);
```
## finishCommonEvent<sup>9+</sup>
```ts
finishCommonEvent(): Promise<void\>
```
以Promise形式结束当前有序公共事件。
**系统能力**`SystemCapability.Notification.CommonEvent`
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个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
# BundleOption
BundleOption模块为指定应用的包信息。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 必填 | 说明 |
| ------ | ------ |---- | ------ |
| bundle | string | 是 | 应用的包信息。 |
| uid | number | 否 | 用户ID。 |
# NotificationActionButton
描述通知中显示的操作按钮。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | string | 是 | 是 | 按钮标题。 |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 点击按钮时触发的WantAgent。 |
| extras | { [key: string]: any } | 是 | 是 | 按钮扩展信息。 |
| userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | 是 | 是 | 用户输入对象实例。 |
# 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\<string\> | 是 | 是 | 通知的多行文本。 |
## NotificationPictureContent
描述附有图片的通知。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | -------------- | ---- | --- | -------------------------------- |
| title | string | 是 | 是 | 通知标题。 |
| text | string | 是 | 是 | 通知内容。 |
| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 |
| expandedTitle | string | 是 | 是 | 通知展开时的标题。 |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知的图片内容。 |
# 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 | 通知标志关闭。 |
# 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 | 是 | 否 | 创建通知的包名。 |
| creatorUid<sup>8+<sup> | number | 是 | 否 | 创建通知的UID。 |
| creatorPid | number | 是 | 否 | 创建通知的PID。 |
| creatorUserId| number | 是 | 否 | 创建通知的UserId。 |
| hashCode | string | 是 | 否 | 通知唯一标识。 |
| classification | string | 是 | 是 | 通知分类。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| groupName<sup>8+<sup> | string | 是 | 是 | 组通知名称。 |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | 是 | 是 | 通知模板。 |
| isRemoveAllowed<sup>8+<sup> | boolean | 是 | 否 | 通知是否能被移除。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| source<sup>8+<sup> | number | 是 | 否 | 通知源。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | 是 | 是 | 分布式通知的选项。 |
| deviceId<sup>8+<sup> | string | 是 | 否 | 通知源的deviceId。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationflags#notificationFlags) | 是 | 否 | 获取NotificationFlags。 |
| removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 当移除通知时,通知将被重定向到的WantAgent实例。 |
| badgeNumber<sup>9+<sup> | number | 是 | 是 | 应用程序图标上显示的通知数。 |
## DistributedOptions
描述分布式选项。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed<sup>8+<sup> | boolean | 是 | 是 | 是否为分布式通知。 |
| supportDisplayDevices<sup>8+<sup> | Array\<string> | 是 | 是 | 可以同步通知到的设备列表。 |
| supportOperateDevices<sup>8+<sup> | Array\<string> | 是 | 是 | 可以打开通知的设备列表。 |
| remindType<sup>8+<sup> | number | 是 | 否 | 通知的提醒方式。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
# 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\<number\> | 是 | 是 | 通知振动样式。 |
| enabled<sup>9+</sup> | boolean | 是 | 否 | 此通知插槽中的启停状态。 |
# NotificationTemplate
通知模板。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | 是 | 是 | 模板名称。 |
| data | {[key:string]: Object} | 是 | 是 | 模板数据。 |
# NotificationUserInput
保存用户输入的通知消息。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | 是 | 是 | 用户输入时用于标识此输入的key。 |
...@@ -51,7 +51,7 @@ this.context.destroy((err) => { ...@@ -51,7 +51,7 @@ this.context.destroy((err) => {
## InputMethodExtensionContext.destroy ## InputMethodExtensionContext.destroy
destroy(): Promise<void&gt; destroy(): Promise\<void>;
停止输入法应用自身。通过Promise异步回调。 停止输入法应用自身。通过Promise异步回调。
...@@ -61,7 +61,7 @@ destroy(): Promise<void&gt; ...@@ -61,7 +61,7 @@ destroy(): Promise<void&gt;
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise<void&gt; | 无返回结果的Promise对象。 | | Promise\<void>; | 无返回结果的Promise对象。 |
**示例:** **示例:**
......
...@@ -1149,8 +1149,6 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1149,8 +1149,6 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
显示输入法选择对话框。使用callback异步回调。 显示输入法选择对话框。使用callback异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
...@@ -1189,8 +1187,6 @@ showOptionalInputMethods(): Promise&lt;boolean&gt; ...@@ -1189,8 +1187,6 @@ showOptionalInputMethods(): Promise&lt;boolean&gt;
显示输入法选择对话框。使用promise异步回调。 显示输入法选择对话框。使用promise异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**返回值:** **返回值:**
......
...@@ -708,7 +708,7 @@ hide(callback: AsyncCallback&lt;void&gt;): void ...@@ -708,7 +708,7 @@ hide(callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -742,7 +742,7 @@ hide(): Promise&lt;void&gt; ...@@ -742,7 +742,7 @@ hide(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -837,7 +837,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -837,7 +837,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -886,7 +886,7 @@ sendKeyFunction(action: number): Promise&lt;boolean&gt; ...@@ -886,7 +886,7 @@ sendKeyFunction(action: number): Promise&lt;boolean&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -928,7 +928,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -928,7 +928,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------ | | -------- | ------------------------------ |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
| 12800006 | Input method controller error. | | 12800006 | Input method controller error. |
**示例:** **示例:**
...@@ -974,7 +974,7 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -974,7 +974,7 @@ getForward(length:number): Promise&lt;string&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------ | | -------- | ------------------------------ |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
| 12800006 | Input method controller error. | | 12800006 | Input method controller error. |
**示例:** **示例:**
...@@ -1013,7 +1013,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -1013,7 +1013,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------ | | -------- | ------------------------------ |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
| 12800006 | Input method controller error. | | 12800006 | Input method controller error. |
**示例:** **示例:**
...@@ -1059,7 +1059,7 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -1059,7 +1059,7 @@ getBackward(length:number): Promise&lt;string&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | ------------------------------ | | -------- | ------------------------------ |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
| 12800006 | Input method controller error. | | 12800006 | Input method controller error. |
**示例:** **示例:**
...@@ -1099,7 +1099,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1099,7 +1099,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800002 | Input method engine error. | | 12800002 | Input method engine error. |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -1149,7 +1149,7 @@ deleteForward(length:number): Promise&lt;boolean&gt; ...@@ -1149,7 +1149,7 @@ deleteForward(length:number): Promise&lt;boolean&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800002 | Input method engine error. | | 12800002 | Input method engine error. |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -1192,7 +1192,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1192,7 +1192,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800002 | Input method engine error. | | 12800002 | Input method engine error. |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -1242,7 +1242,7 @@ deleteBackward(length:number): Promise&lt;boolean&gt; ...@@ -1242,7 +1242,7 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800002 | Input method engine error. | | 12800002 | Input method engine error. |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -1281,7 +1281,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1281,7 +1281,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800002 | Input method engine error. | | 12800002 | Input method engine error. |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -1326,7 +1326,7 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -1326,7 +1326,7 @@ insertText(text:string): Promise&lt;boolean&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800002 | Input method engine error. | | 12800002 | Input method engine error. |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -1366,7 +1366,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -1366,7 +1366,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -1401,7 +1401,7 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -1401,7 +1401,7 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -1435,7 +1435,7 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1435,7 +1435,7 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
...@@ -1479,7 +1479,7 @@ moveCursor(direction: number): Promise&lt;void&gt; ...@@ -1479,7 +1479,7 @@ moveCursor(direction: number): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------- | | -------- | -------------------------- |
| 12800003 | Input method client error. | | 12800003 | input method client error. |
**示例:** **示例:**
......
...@@ -67,7 +67,7 @@ constructor(locale: string, options?: LocaleOptions) ...@@ -67,7 +67,7 @@ constructor(locale: string, options?: LocaleOptions)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | -------------------------------- | ---- | ---------------------------- | | -------------------- | -------------------------------- | ---- | ---------------------------- |
| locale | string | 是 | 包含区域信息的字符串,包括语言以、脚本、国家或地区。语言、脚本、国家或地区的国际标准及组合方式请见[Intl开发指导](../../internationalization/intl-guidelines.md#设置区域信息) | | locale | string | 是 | 包含区域信息的字符串,包括语言以、脚本、国家或地区。语言、脚本、国家或地区的国际标准及组合方式请见[Intl开发指导](../../internationalization/intl-guidelines.md#设置区域信息) |
| options<sup>9+</sup> | [LocaleOptions](#localeoptions6) | 否 | 用于创建区域对象的选项。 | | options<sup>9+</sup> | [LocaleOptions](#localeoptions9) | 否 | 用于创建区域对象的选项。 |
**示例:** **示例:**
```js ```js
...@@ -159,7 +159,7 @@ minimize(): Locale ...@@ -159,7 +159,7 @@ minimize(): Locale
``` ```
## LocaleOptions<sup>6+</sup> ## LocaleOptions<sup>9+</sup>
表示区域初始化选项。 表示区域初始化选项。
...@@ -206,7 +206,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: DateTimeOptions) ...@@ -206,7 +206,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: DateTimeOptions)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------------------------------------ | ---- | ---------------------------- | | -------------------- | ------------------------------------ | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string \| Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options<sup>9+</sup> | [DateTimeOptions](#datetimeoptions6) | 否 | 用于创建时间日期格式化的选项。 | | options<sup>9+</sup> | [DateTimeOptions](#datetimeoptions9) | 否 | 用于创建时间日期格式化的选项。 |
**示例:** **示例:**
```js ```js
...@@ -298,7 +298,7 @@ resolvedOptions(): DateTimeOptions ...@@ -298,7 +298,7 @@ resolvedOptions(): DateTimeOptions
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------ | ----------------------------- | | ------------------------------------ | ----------------------------- |
| [DateTimeOptions](#datetimeoptions6) | DateTimeFormat&nbsp;对象的格式化选项。 | | [DateTimeOptions](#datetimeoptions9) | DateTimeFormat&nbsp;对象的格式化选项。 |
**示例:** **示例:**
```js ```js
...@@ -310,7 +310,7 @@ resolvedOptions(): DateTimeOptions ...@@ -310,7 +310,7 @@ resolvedOptions(): DateTimeOptions
``` ```
## DateTimeOptions<sup>6+</sup> ## DateTimeOptions<sup>9+</sup>
表示时间日期格式化选项。 表示时间日期格式化选项。
...@@ -370,7 +370,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: NumberOptions) ...@@ -370,7 +370,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: NumberOptions)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | -------------------------------- | ---- | ---------------------------- | | -------------------- | -------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string \| Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options<sup>9+</sup> | [NumberOptions](#numberoptions6) | 否 | 用于创建数字格式化的选项。 | | options<sup>9+</sup> | [NumberOptions](#numberoptions9) | 否 | 用于创建数字格式化的选项。 |
**示例:** **示例:**
```js ```js
...@@ -420,7 +420,7 @@ resolvedOptions(): NumberOptions ...@@ -420,7 +420,7 @@ resolvedOptions(): NumberOptions
| 类型 | 说明 | | 类型 | 说明 |
| -------------------------------- | --------------------------- | | -------------------------------- | --------------------------- |
| [NumberOptions](#numberoptions6) | NumberFormat&nbsp;对象的格式化选项。 | | [NumberOptions](#numberoptions9) | NumberFormat&nbsp;对象的格式化选项。 |
**示例:** **示例:**
...@@ -433,7 +433,7 @@ resolvedOptions(): NumberOptions ...@@ -433,7 +433,7 @@ resolvedOptions(): NumberOptions
``` ```
## NumberOptions<sup>6+</sup> ## NumberOptions<sup>9+</sup>
表示设备支持的能力。 表示设备支持的能力。
...@@ -493,7 +493,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: CollatorOptions) ...@@ -493,7 +493,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: CollatorOptions)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------------------------------------ | ---- | ---------------------------- | | -------------------- | ------------------------------------ | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string \| Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options<sup>9+</sup> | [CollatorOptions](#collatoroptions8) | 否 | 用于创建排序对象的选项。 | | options<sup>9+</sup> | [CollatorOptions](#collatoroptions9) | 否 | 用于创建排序对象的选项。 |
**示例:** **示例:**
```js ```js
...@@ -544,7 +544,7 @@ resolvedOptions(): CollatorOptions ...@@ -544,7 +544,7 @@ resolvedOptions(): CollatorOptions
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------ | ----------------- | | ------------------------------------ | ----------------- |
| [CollatorOptions](#collatoroptions8) | 返回的Collator对象的属性。 | | [CollatorOptions](#collatoroptions9) | 返回的Collator对象的属性。 |
**示例:** **示例:**
```js ```js
...@@ -556,7 +556,7 @@ resolvedOptions(): CollatorOptions ...@@ -556,7 +556,7 @@ resolvedOptions(): CollatorOptions
``` ```
## CollatorOptions<sup>8+</sup> ## CollatorOptions<sup>9+</sup>
表示Collator可设置的属性。 表示Collator可设置的属性。
...@@ -604,7 +604,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: PluralRulesOptions) ...@@ -604,7 +604,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: PluralRulesOptions)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ---------------------------------------- | ---- | ---------------------------- | | -------------------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string \| Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options<sup>9+</sup> | [PluralRulesOptions](#pluralrulesoptions8) | 否 | 用于创建单复数对象的选项。 | | options<sup>9+</sup> | [PluralRulesOptions](#pluralrulesoptions9) | 否 | 用于创建单复数对象的选项。 |
**示例:** **示例:**
```js ```js
...@@ -647,7 +647,7 @@ select(n: number): string ...@@ -647,7 +647,7 @@ select(n: number): string
``` ```
## PluralRulesOptions<sup>8+</sup> ## PluralRulesOptions<sup>9+</sup>
表示PluralRules对象可设置的属性。 表示PluralRules对象可设置的属性。
...@@ -695,7 +695,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: RelativeTimeFormatIn ...@@ -695,7 +695,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: RelativeTimeFormatIn
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ---------------------------------------- | ---- | ---------------------------- | | -------------------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string \| Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options<sup>9+</sup> | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions8) | 否 | 用于创建相对时间格式化对象的选项。 | | options<sup>9+</sup> | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions9) | 否 | 用于创建相对时间格式化对象的选项。 |
**示例:** **示例:**
```js ```js
...@@ -787,7 +787,7 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions ...@@ -787,7 +787,7 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions
``` ```
## RelativeTimeFormatInputOptions<sup>8+</sup> ## RelativeTimeFormatInputOptions<sup>9+</sup>
表示RelativeTimeFormat对象可设置的属性。 表示RelativeTimeFormat对象可设置的属性。
......
...@@ -31,6 +31,9 @@ isNfcAvailable(): boolean ...@@ -31,6 +31,9 @@ isNfcAvailable(): boolean
查询设备是否有NFC能力。 查询设备是否有NFC能力。
> **说明:**
> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用canIUse("SystemCapability.Communication.NFC.Core")替代。
**系统能力:** SystemCapability.Communication.NFC.Core **系统能力:** SystemCapability.Communication.NFC.Core
**返回值:** **返回值:**
...@@ -46,6 +49,9 @@ openNfc(): boolean ...@@ -46,6 +49,9 @@ openNfc(): boolean
打开NFC开关。 打开NFC开关。
> **说明:**
> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[enableNfc](#controllerenablenfc9)替代。
**需要权限:** ohos.permission.MANAGE_SECURE_SETTINGS **需要权限:** ohos.permission.MANAGE_SECURE_SETTINGS
**系统能力:** SystemCapability.Communication.NFC.Core **系统能力:** SystemCapability.Communication.NFC.Core
...@@ -56,12 +62,33 @@ openNfc(): boolean ...@@ -56,12 +62,33 @@ openNfc(): boolean
| -------- | -------- | | -------- | -------- |
| boolean | true: 打开NFC成功,&nbsp;false: 打开NFC失败。 | | boolean | true: 打开NFC成功,&nbsp;false: 打开NFC失败。 |
## controller.enableNfc<sup>9+</sup>
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 ## controller.closeNfc
closeNfc(): boolean closeNfc(): boolean
关闭NFC开关。 关闭NFC开关。
> **说明:**
> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[disableNfc](#controllerdisablenfc9)替代。
**需要权限:** ohos.permission.MANAGE_SECURE_SETTINGS **需要权限:** ohos.permission.MANAGE_SECURE_SETTINGS
**系统能力:** SystemCapability.Communication.NFC.Core **系统能力:** SystemCapability.Communication.NFC.Core
...@@ -72,6 +99,24 @@ closeNfc(): boolean ...@@ -72,6 +99,24 @@ closeNfc(): boolean
| -------- | ------------------------------------------- | | -------- | ------------------------------------------- |
| boolean | true: 关闭NFC成功,&nbsp;false: 关闭NFC失败。 | | boolean | true: 关闭NFC成功,&nbsp;false: 关闭NFC失败。 |
## controller.disableNfc<sup>9+</sup>
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 ## controller.isNfcOpen
isNfcOpen(): boolean isNfcOpen(): boolean
...@@ -150,12 +195,28 @@ if (!controller.isNfcOpen()) { ...@@ -150,12 +195,28 @@ if (!controller.isNfcOpen()) {
console.log("controller openNfc ret: " + ret); 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 // close nfc, require permission: ohos.permission.MANAGE_SECURE_SETTINGS
if (controller.isNfcOpen()) { if (controller.isNfcOpen()) {
var ret = controller.closeNfc(); var ret = controller.closeNfc();
console.log("controller closeNfc ret: " + ret); 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 // unregister callback
controller.off("nfcStateChange"); controller.off("nfcStateChange");
``` ```
...@@ -126,64 +126,204 @@ getNfcATag(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag) ...@@ -126,64 +126,204 @@ getNfcATag(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag)
获取NFC A类型Tag对象,通过该对象可访问NfcA技术类型的Tag。 获取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.getNfcA<sup>9+</sup>
getNfcA(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag)
获取NFC A类型Tag对象,通过该对象可访问NfcA技术类型的Tag。
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
**返回值:** **返回值:**
| **类型** | **说明** | | **类型** | **说明** |
| -------- | -------- | | -------- | -------- |
| [NfcATag](js-apis-nfctech.md#nfcatag) | NFC A类型Tag对象。 | | [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 ## tag.getNfcBTag
getNfcBTag(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag) getNfcBTag(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag)
获取NFC B类型Tag对象,通过该对象可访问NfcB技术类型的Tag。 获取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.getNfcB<sup>9+</sup>
getNfcB(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag)
获取NFC B类型Tag对象,通过该对象可访问NfcB技术类型的Tag。
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
**返回值:** **返回值:**
| **类型** | **说明** | | **类型** | **说明** |
| -------- | ---------------- | | -------- | ---------------- |
| [NfcBTag](js-apis-nfctech.md#nfcbtag) | NFC B类型Tag对象。 | | [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 ## tag.getNfcFTag
getNfcFTag(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag) getNfcFTag(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag)
获取NFC F类型Tag对象,通过该对象可访问NfcF技术类型的Tag。 获取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.getNfcF<sup>9+</sup>
getNfcF(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag)
获取NFC F类型Tag对象,通过该对象可访问NfcF技术类型的Tag。
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
**返回值:** **返回值:**
| **类型** | **说明** | | **类型** | **说明** |
| -------- | ---------------- | | -------- | ---------------- |
| [NfcFTag](js-apis-nfctech.md#nfcftag) | NFC F类型Tag对象。 | | [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 ## tag.getNfcVTag
getNfcVTag(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag) getNfcVTag(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag)
获取NFC V类型Tag对象,通过该对象可访问NfcV技术类型的Tag。 获取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.getNfcV<sup>9+</sup>
getNfcV(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag)
获取NFC V类型Tag对象,通过该对象可访问NfcV技术类型的Tag。
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
**返回值:** **返回值:**
| **类型** | **说明** | | **类型** | **说明** |
| -------- | ---------------- | | -------- | ---------------- |
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | NFC V类型Tag对象。 | | [NfcVTag](js-apis-nfctech.md#nfcvtag) | NFC V类型Tag对象。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
## tag.getIsoDep<sup>9+</sup> ## tag.getIsoDep<sup>9+</sup>
getIsoDep(tagInfo: [TagInfo](#taginfo)): [IsoDepTag](js-apis-nfctech.md#isoDepTag9 ) getIsoDep(tagInfo: [TagInfo](#taginfo)): [IsoDepTag](js-apis-nfctech.md#isoDepTag9 )
......
...@@ -26,8 +26,6 @@ getSak(): number ...@@ -26,8 +26,6 @@ getSak(): number
获取NFC-A标签的SAK值。 获取NFC-A标签的SAK值。
**需要权限:** ohos.permission.NFC_TAG
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**返回值:** **返回值:**
...@@ -52,8 +50,6 @@ getAtqa(): number[] ...@@ -52,8 +50,6 @@ getAtqa(): number[]
获取NFC-A标签的Atqa值。 获取NFC-A标签的Atqa值。
**需要权限:** ohos.permission.NFC_TAG
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**返回值:** **返回值:**
...@@ -86,8 +82,6 @@ getRespAppData(): number[] ...@@ -86,8 +82,6 @@ getRespAppData(): number[]
获取标签的应用程序数据。 获取标签的应用程序数据。
**需要权限:** ohos.permission.NFC_TAG
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**返回值:** **返回值:**
...@@ -112,8 +106,6 @@ getRespProtocol(): number[] ...@@ -112,8 +106,6 @@ getRespProtocol(): number[]
获取标签的协议信息。 获取标签的协议信息。
**需要权限:** ohos.permission.NFC_TAG
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**返回值:** **返回值:**
...@@ -146,8 +138,6 @@ getSystemCode(): number[] ...@@ -146,8 +138,6 @@ getSystemCode(): number[]
从标签实例获取系统代码。 从标签实例获取系统代码。
**需要权限:** ohos.permission.NFC_TAG
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**返回值:** **返回值:**
...@@ -172,8 +162,6 @@ getPmm(): number[] ...@@ -172,8 +162,6 @@ getPmm(): number[]
从标签实例获取PMm(由IC代码和制造商参数组成)。 从标签实例获取PMm(由IC代码和制造商参数组成)。
**需要权限:** ohos.permission.NFC_TAG
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**返回值:** **返回值:**
...@@ -206,8 +194,6 @@ getResponseFlags(): number ...@@ -206,8 +194,6 @@ getResponseFlags(): number
从标签实例实例获取响应标志。 从标签实例实例获取响应标志。
**需要权限:** ohos.permission.NFC_TAG
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**返回值:** **返回值:**
...@@ -232,8 +218,6 @@ getDsfId(): number ...@@ -232,8 +218,6 @@ getDsfId(): number
从标签实例实例获取数据存储格式标识符(DSFID)。 从标签实例实例获取数据存储格式标识符(DSFID)。
**需要权限:** ohos.permission.NFC_TAG
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**返回值:** **返回值:**
......
...@@ -19,8 +19,9 @@ import resourceManager from '@ohos.resourceManager'; ...@@ -19,8 +19,9 @@ import resourceManager from '@ohos.resourceManager';
Stage模型下Context的引用方法请参考[Stage模型的Context详细介绍](../..//application-models/application-context-stage.md) Stage模型下Context的引用方法请参考[Stage模型的Context详细介绍](../..//application-models/application-context-stage.md)
```ts ```ts
import Ability from '@ohos.application.Ability'; import UIAbility from '@ohos.app.ability.UIAbility';
class MainAbility extends Ability {
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
let context = this.context; let context = this.context;
let resourceManager = context.resourceManager; let resourceManager = context.resourceManager;
......
...@@ -596,7 +596,7 @@ export default { ...@@ -596,7 +596,7 @@ export default {
// 在detail页面中 // 在detail页面中
export default { export default {
onInit() { onInit() {
console.info('showData1:' + router.getParams()[data1]); console.info('showData1:' + router.getParams()['data1']);
} }
} }
``` ```
......
...@@ -2036,7 +2036,7 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); ...@@ -2036,7 +2036,7 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate);
| WAITING_INSTALL | 30 | 待安装。 | | WAITING_INSTALL | 30 | 待安装。 |
| UPDATING | 31 | 更新中。 | | UPDATING | 31 | 更新中。 |
| WAITING_APPLY | 40 | 待生效。 | | WAITING_APPLY | 40 | 待生效。 |
| APPLYING | 21 | 生效中。 | | APPLYING | 41 | 生效中。 |
| UPGRADE_SUCCESS | 50 | 升级成功。 | | UPGRADE_SUCCESS | 50 | 升级成功。 |
| UPGRADE_FAIL | 51 | 升级失败。 | | UPGRADE_FAIL | 51 | 升级失败。 |
...@@ -2058,7 +2058,7 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); ...@@ -2058,7 +2058,7 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate);
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ---------------------- | ---------- | ------ | | ---------------------- | ---------- | ------ |
| EVENT_TASK_BASE | 0x01000000 | 任务事件。 | | EVENT_TASK_BASE | EventClassify.TASK | 任务事件。 |
| EVENT_TASK_RECEIVE | 0x01000001 | 收到任务。 | | EVENT_TASK_RECEIVE | 0x01000001 | 收到任务。 |
| EVENT_TASK_CANCEL | 0x01000010 | 取消任务。 | | EVENT_TASK_CANCEL | 0x01000010 | 取消任务。 |
| EVENT_DOWNLOAD_WAIT | 0x01000011 | 待下载。 | | EVENT_DOWNLOAD_WAIT | 0x01000011 | 待下载。 |
......
...@@ -22,8 +22,8 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth'; ...@@ -22,8 +22,8 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth';
| ------------ | ---------- | ---- | -------------------- | | ------------ | ---------- | ---- | -------------------- |
| result | number | 是 | 认证结果。 | | result | number | 是 | 认证结果。 |
| token | Uint8Array | 否 | 用户身份认证通过的凭证。 | | token | Uint8Array | 否 | 用户身份认证通过的凭证。 |
| remainAttempts | number | 否 | 剩余的认证操作次数。 | | remainAttempts | number | 否 | 剩余的认证尝试次数。 |
| lockoutDuration | number | 否 | 认证操作的冻结时间。 | | lockoutDuration | number | 否 | 认证操作的锁定时长,时间单位为毫秒ms。 |
## TipInfo<sup>9+</sup> ## TipInfo<sup>9+</sup>
......
...@@ -108,7 +108,7 @@ struct CardExample { ...@@ -108,7 +108,7 @@ struct CardExample {
.visibility(Visibility.Visible) .visibility(Visibility.Visible)
.onAcquired((form)=>{ .onAcquired((form)=>{
console.log(`form info : ${JSON.stringify(form)}`); console.log(`form info : ${JSON.stringify(form)}`);
this.fomId = form.id; this.formId = form.id;
}) })
.onError((err)=>{ .onError((err)=>{
console.log(`fail to add form, err: ${JSON.stringify(err)}`); console.log(`fail to add form, err: ${JSON.stringify(err)}`);
......
# Web # Web
提供具有网页显示能力的Web组件。 提供具有网页显示能力的Web组件[@ohos.web.webview](../apis/js-apis-webview.md)提供web控制能力
> **说明:** > **说明:**
> >
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册