提交 a4d2aa41 编写于 作者: X xuzhihao

Merge branch 'master' of gitee.com:openharmony/docs into master

Signed-off-by: Nxuzhihao <xuzhihao16@huawei.com>
...@@ -31,3 +31,16 @@ This repository stores device and application development documents provided by ...@@ -31,3 +31,16 @@ This repository stores device and application development documents provided by
OpenHarmony_v1.x_release: OpenHarmony v1.1.4 LTS. [Learn more](en/release-notes/OpenHarmony-v1-1-4-LTS.md) OpenHarmony_v1.x_release: OpenHarmony v1.1.4 LTS. [Learn more](en/release-notes/OpenHarmony-v1-1-4-LTS.md)
[More versions](en/release-notes/) [More versions](en/release-notes/)
## Third-Party Open-Source Software and License Notice
3rd-Party-License: [Third-Party Open-Source Software and License Notice](en/contribute/third-party-open-source-software-and-license-notice.md)
## How to Contribute
A great open-source project wouldn't be possible without the hard work of many contributors. We'd like to invite anyone from around the world to [participate](contribute/contribution.md) in this exciting journey, and we're grateful for your time, passion, and efforts!
You can evaluate available documents, make simple modifications, provide feedback on document quality, and contribute your original content. For details, see [Documentation Contribution](contribute/documentation-contribution.md).
Excellent contributors will be awarded and the contributions will be publicized in the developer community.
# OpenHarmony<a name="EN-US_TOPIC_0000001158661243"></a> # OpenHarmony
## Introduction<a name="section1270210396435"></a> ## Introduction<a name="section1270210396435"></a>
...@@ -331,7 +331,8 @@ The following table describes the subsystems of OpenHarmony. For details about t ...@@ -331,7 +331,8 @@ The following table describes the subsystems of OpenHarmony. For details about t
## Getting Started<a name="section44681652104210"></a> ## Getting Started<a name="section44681652104210"></a>
For details, see [device-dev/quick-start/Readme-EN.md](device-dev/quick-start/Readme-EN.md). - Device development: [device-dev/quick-start/Readme.md](device-dev/quick-start/Readme-EN.md)
- Application development: [application-dev/quick-start/Readme.md](application-dev/quick-start/Readme-EN.md)
- [Getting Started for Device Development](device-dev/quick-start/quickstart-lite-overview.md) - [Getting Started for Device Development](device-dev/quick-start/quickstart-lite-overview.md)
- [Getting Started for Application Development](application-dev/quick-start/start-overview.md) - [Getting Started for Application Development](application-dev/quick-start/start-overview.md)
...@@ -377,4 +378,3 @@ Website: ...@@ -377,4 +378,3 @@ Website:
Email: Email:
contact@openharmony.io contact@openharmony.io
...@@ -2,18 +2,30 @@ ...@@ -2,18 +2,30 @@
An ability is an abstraction of a functionality that an application can provide. It is the minimum unit for the system to schedule applications. An application can contain one or more **Ability** instances. An ability is an abstraction of a functionality that an application can provide. It is the minimum unit for the system to schedule applications. An application can contain one or more **Ability** instances.
The ability framework model has two forms. The first form is the FA model, which applies to application development using API 8 and earlier versions. In the FA model, there are Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service and Data abilities. The stage model is introduced since API 9. In the stage model, there are Page abilities and Extension abilities. The Extension ability is further extended to Service Extension, Form Extension, Data Share Extension, and more. The ability framework model has two forms.
The stage model is designed to make complex application development easier in a distributed environment. The two models have differences in the following aspects: - FA model, which applies to application development using API 8 and earlier versions. In the FA model, there are Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service, Data, and Form abilities.
- Stage model, which is introduced since API 9. In the stage model, there are Ability and ExtensionAbility. The ExtensionAbility is further extended to ServiceExtensionAbility, FormExtensionAbility, DataShareExtensionAbility, and more.
* Ability type and API usage The stage model is designed to make it easier to develop complex applications in the distributed environment. The table below lists the design differences between the two models.
| Item | FA Model | Stage Model |
| -------------- | ------------------------------------------------------------ | -------------------------------------------------------- |
| Development mode | Web-like APIs are provided. The UI development is the same as that of the stage model. | Object-oriented development mode is provided. The UI development is the same as that of the FA model. |
| Engine instance | Each ability in a process exclusively uses a JS VM engine instance. | Multiple abilities in a process share one JS VM engine instance. |
| Intra-process object sharing| Not supported. | Supported. |
| Bundle description file | The **config.json** file is used to describe the HAP and component information. The component must use a fixed file name.| The **module.json** file is used to describe the HAP and component information. The entry file name can be specified.|
| Component | Four types of components are provided: Page ability (used for UI page display), Service ability (used to provide services), Data ability (used for data sharing), and Form ability (used to provide widgets).| Two types of components are provided: Ability (used for UI page display) and Extension (scenario-based service extension). |
In addition, the following differences are available in the development process:
* Different ability types
![favsstage](figures/favsstage.png) ![favsstage](figures/favsstage.png)
* Ability lifecycle * Different ability lifecycles
![lifecycle](figures/lifecycle.png) ![lifecycle](figures/lifecycle.png)
* Application configuration files and application package structure (The differences are reflected in the application packages generated by the IDE.)
For details about the two models, see [FA Model Overview](fa-brief.md) and [Stage Model Overview](stage-brief.md). For details about the two models, see [FA Model Overview](fa-brief.md) and [Stage Model Overview](stage-brief.md).
# Data Ability Development # Data Ability Development
## When to Use
## Basic Concepts
A Data ability helps applications manage access to data stored by themselves and other applications. It also provides APIs for sharing data with other applications either on the same device or across devices. A Data ability helps applications manage access to data stored by themselves and other applications. It also provides APIs for sharing data with other applications either on the same device or across devices.
Data ability providers can customize data access-related APIs such as data inserting, deleting, updating, and querying, as well as file opening, and share data with other applications through these open APIs. Data ability providers can customize data access-related APIs such as data inserting, deleting, updating, and querying, as well as file opening, and share data with other applications through these open APIs.
## Creating a Data Ability ## Available APIs
### 1. Implementation of the Data Subsystem
1. To meet the basic requirements of the database storage service, implement the **Insert**, **Query**, **Update**, and **Delete** APIs in the **Data** class to provide batch data processing. The traversal logic has been implemented by the **BatchInsert** and **ExecuteBatch** APIs. **Table 1** Data ability lifecycle callbacks
2. The APIs used in the lifecycle of the Data ability are as follows: |API|Description|
|:------|:------|
- onInitialized |onInitialized|Called during ability initialization to initialize the relational database (RDB).|
|update|Updates data in the database.|
Called during ability initialization to initialize the relational database (RDB). |query|Queries data in the database.|
|delete|Deletes one or multiple data records from the database.|
- update |normalizeUri|Normalizes the URI. A normalized URI applies to cross-device use, persistence, backup, and restore. When the context changes, it ensures that the same data item can be referenced.|
|batchInsert|Inserts multiple data records into the database.|
Updates data in the database. |denormalizeUri|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.|
|insert|Inserts a data record into the database.|
- query |openFile|Opens a file.|
|getFileTypes|Obtains the MIME type of a file.|
Queries data in the database. |getType|Obtains the MIME type matching the data specified by the URI.|
|executeBatch|Operates data in the database in batches.|
- delete |call|A customized API.|
Deletes one or multiple data records from the database.
## How to Develop
- normalizeUri ### Creating a Data Ability
Normalizes the URI. A normalized URI applies to cross-device use, persistence, backup, and restore. When the context changes, it ensures that the same data item can be referenced.
- batchInsert
Inserts multiple data records into the database.
- denormalizeUri
Converts a normalized URI generated by **normalizeUri** into a denormalized URI.
- insert
Inserts a data record into the database.
- openFile
Opens a file.
- getFileTypes
Obtains the MIME type of a file.
- getType
Obtains the MIME type matching the data specified by the URI.
- executeBatch
Operates data in the database in batches.
- call
A customized API.
1. To meet the basic requirements of the database storage service, implement the **Insert**, **Query**, **Update**, and **Delete** APIs in the **Data** class to provide batch data processing. The traversal logic has been implemented by the **BatchInsert** and **ExecuteBatch** APIs.
The following code snippet shows how to create a Data ability: The following code snippet shows how to create a Data ability:
```javascript ```javascript
import dataAbility from '@ohos.data.dataability'
import dataRdb from '@ohos.data.rdb'
const TABLE_NAME = 'book'
const STORE_CONFIG = { name: 'book.db', encryptKey: new Uint8Array([]) }
const SQL_CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS book(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, age INTEGER, introduction TEXT NOT NULL)'
let rdbStore = undefined
export default { export default {
onInitialized(abilityInfo) { onInitialized(abilityInfo) {
console.info('DataAbility onInitialized, abilityInfo:' + abilityInfo.bundleName) console.info('DataAbility onInitialized, abilityInfo:' + abilityInfo.bundleName)
...@@ -116,23 +74,21 @@ Data ability providers can customize data access-related APIs such as data inser ...@@ -116,23 +74,21 @@ Data ability providers can customize data access-related APIs such as data inser
rdbStore.delete(rdbPredicates, callback) rdbStore.delete(rdbPredicates, callback)
} }
}; };
``` ```
2. Submodule Configuration
### 2. Subsystem Configuration | JSON Field| Description |
| ------------ | ------------------------------------------------------------ |
| "name" | Ability name, corresponding to the **Data** class name derived from **Ability**. |
| "type" | Ability type, which is **Data** for a Data ability. |
| "uri" | URI used for communication. |
| "visible" | Whether the Data ability is visible to other applications. When this parameter is set to **true**, the Data ability can communicate with other applications.|
| JSON Field | Description | **config.json configuration example**
| ------------- | ------------------------------------------------------------ |
| "name" | Ability name, corresponding to the **Data** class name derived from **Ability**. |
| "type" | Ability type, which is **Data** for a Data ability. |
| "uri" | URI used for communication. |
| "visible" | Whether the Data ability is visible to other applications. When this parameter is set to **true**, the Data ability can communicate with other applications.|
**config.json configuration example** ```json
"abilities":[{
```json
"abilities":[{
"srcPath": "DataAbility", "srcPath": "DataAbility",
"name": ".DataAbility", "name": ".DataAbility",
"icon": "$media:icon", "icon": "$media:icon",
...@@ -141,121 +97,142 @@ Data ability providers can customize data access-related APIs such as data inser ...@@ -141,121 +97,142 @@ Data ability providers can customize data access-related APIs such as data inser
"type": "data", "type": "data",
"visible": true, "visible": true,
"uri": "dataability://ohos.samples.etsdataability.DataAbility" "uri": "dataability://ohos.samples.etsdataability.DataAbility"
}] }]
``` ```
### Accessing a Data ability
#### Development Preparations
Import the basic dependency packages and obtain the URI string for communicating with the Data submodule.
The basic dependency packages include:
- @ohos.ability.featureAbility
- @ohos.data.dataability
- @ohos.data.rdb
#### Data Ability API Development
## Accessing a Data ability
### 1. Preparing for JS Application Development
Basic dependency packages:
1. @ohos.ability.featureAbility
2. @ohos.data.dataability
3. @ohos.data.rdb
URI string used for communication with the Data ability.
### 2. JS Application Development APIs 1. Create a Data ability helper.
Create a utility API object.
```js For details about the APIs provided by **DataAbilityHelper**, see [DataAbilityHelper Module](../reference/apis/js-apis-dataAbilityHelper.md).
// Different from the URI defined in the config.json file, the URI passed in the parameter has an extra slash (/), because there is a DeviceID parameter between the second and the third slash (/). ```js
var urivar = "dataability:///com.ix.DataAbility" // Different from the URI defined in the config.json file, the URI passed in the parameter has an extra slash (/), because there is a DeviceID parameter between the second and the third slash (/).
var DAHelper = featureAbility.acquireDataAbilityHelper( var urivar = "dataability:///com.ix.DataAbility"
var DAHelper = featureAbility.acquireDataAbilityHelper(
urivar urivar
); );
``` ```
Construct RDB data. 2. Construct RDB data.
```js ```js
var valuesBucket = {"name": "gaolu"} var valuesBucket = {"name": "gaolu"}
var da = new ohos_data_ability.DataAbilityPredicates() var da = new ohos_data_ability.DataAbilityPredicates()
var valArray =new Array("value1"); var valArray =new Array("value1");
var cars = new Array({"batchInsert1" : "value1",}); var cars = new Array({"batchInsert1" : "value1",});
``` ```
Use **insert** to insert data to the Data subsystem. 3. Use **insert** to insert data to the Data submodule.
```js ```js
// Callback mode: // Callback mode:
DAHelper.insert( DAHelper.insert(
urivar, urivar,
valuesBucket, valuesBucket,
(error, data) => { (error, data) => {
expect(typeof(data)).assertEqual("number") expect(typeof(data)).assertEqual("number")
} }
); );
// Promise mode: ```
var datainsert = await DAHelper.insert(
```js
// Promise mode:
var datainsert = await DAHelper.insert(
urivar, urivar,
valuesBucket valuesBucket
); );
``` ```
Use **delete** to delete data from the Data subsystem. 4. Use **delete** to delete data from the Data submodule.
```js ```js
// Callback mode: // Callback mode:
DAHelper.delete( DAHelper.delete(
urivar, urivar,
da, da,
(error, data) => { (error, data) => {
expect(typeof(data)).assertEqual("number") expect(typeof(data)).assertEqual("number")
} }
); );
// Promise mode: ```
var datadelete = await DAHelper.delete(
```js
// Promise mode:
var datadelete = await DAHelper.delete(
urivar, urivar,
da, da,
); );
``` ```
Use **update** to update data in the Data subsystem. 5. Use **update** to update data in the Data submodule.
```js ```js
// Callback mode: // Callback mode:
DAHelper.update( DAHelper.update(
urivar urivar
valuesBucket, valuesBucket,
da, da,
(error, data) => { (error, data) => {
expect(typeof(data)).assertEqual("number") expect(typeof(data)).assertEqual("number")
} }
); );
// Promise mode: ```
var dataupdate = await DAHelper.update(
```js
// Promise mode:
var dataupdate = await DAHelper.update(
urivar, urivar,
valuesBucket, valuesBucket,
da, da,
); );
``` ```
Use **query** to query data in the Data subsystem. 6. Use **query** to query data in the Data submodule.
```js ```js
// Callback mode: // Callback mode:
DAHelper.query( DAHelper.query(
urivar, urivar,
valArray, valArray,
da, da,
(error, data) => { (error, data) => {
expect(typeof(data)).assertEqual("object") expect(typeof(data)).assertEqual("object")
} }
); );
// Promise mode: ```
var dataquery = await DAHelper.query(
```js
// Promise mode:
var dataquery = await DAHelper.query(
urivar, urivar,
valArray, valArray,
da da
); );
``` ```
Use **batchInsert** to insert data in batches to the Data subsystem. 7. Use **batchInsert** to insert data in batches to the Data submodule.
```js ```js
// Callback mode: // Callback mode:
DAHelper.batchInsert( DAHelper.batchInsert(
urivar, urivar,
cars, cars,
(error, data) => { (error, data) => {
expect(typeof(data)).assertEqual("number") expect(typeof(data)).assertEqual("number")
} }
); );
// Promise mode: ```
var databatchInsert = await DAHelper.batchInsert(
```js
// Promise mode:
var databatchInsert = await DAHelper.batchInsert(
urivar, urivar,
cars cars
); );
``` ```
Use **executeBatch** to process data in batches in the Data subsystem. 8. Use **executeBatch** to process data in batches in the Data submodule.
```js ```js
// Callback mode: // Callback mode:
DAHelper.executeBatch( DAHelper.executeBatch(
urivar, urivar,
[ [
{ {
...@@ -271,9 +248,12 @@ DAHelper.executeBatch( ...@@ -271,9 +248,12 @@ DAHelper.executeBatch(
(error, data) => { (error, data) => {
expect(typeof(data)).assertEqual("object") expect(typeof(data)).assertEqual("object")
} }
); );
// Promise mode: ```
var dataexecuteBatch = await DAHelper.executeBatch(
```js
// Promise mode:
var dataexecuteBatch = await DAHelper.executeBatch(
urivar, urivar,
[ [
{ {
...@@ -289,8 +269,8 @@ var dataexecuteBatch = await DAHelper.executeBatch( ...@@ -289,8 +269,8 @@ var dataexecuteBatch = await DAHelper.executeBatch(
interrupted:true, interrupted:true,
} }
] ]
); );
``` ```
## Development Example ## Development Example
......
...@@ -3,20 +3,20 @@ ...@@ -3,20 +3,20 @@
## Widget Overview ## Widget Overview
A widget is a set of UI components used to display important information or operations for an application. It provides users with direct access to a desired application service, without requiring them to open the application. A widget is a set of UI components used to display important information or operations for an application. It provides users with direct access to a desired application service, without requiring them to open the application.
A widget displays brief information about an application on the UI of another application (host application, currently system applications only) and provides basic interactive features such as opening a UI page or sending a message. The widget client is responsible for displaying the widget. A widget displays brief information about an application on the UI of another application (host application, currently system applications only) and provides basic interactive features such as opening a UI page or sending a message. The widget host is responsible for displaying the widget.
Basic concepts: Basic concepts:
- Widget provider - Widget provider
The widget provider is an atomic service that provides the content to be displayed. It controls the display content, component layout, and component click events of a widget. The widget provider is an atomic service that provides the content to be displayed. It controls the display content, component layout, and component click events of a widget.
- Widget client - Widget host
The widget client is an application that displays the widget content and controls the position where the widget is displayed in the host application. The widget host is an application that displays the widget content and controls the position where the widget is displayed in the host application.
- Widget Manager - Widget Manager
The Widget Manager is a resident agent that manages widgets added to the system and provides functions such as periodic widget update. The Widget Manager is a resident agent that manages widgets added to the system and provides functions such as periodic widget update.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The widget client and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated. > The widget host and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated.
You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget client and Widget Manager. You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget host and Widget Manager.
The widget provider controls the widget content to display, component layout, and click events bound to components. The widget provider controls the widget content to display, component layout, and click events bound to components.
...@@ -85,11 +85,11 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li ...@@ -85,11 +85,11 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li
return formData; return formData;
}, },
onCastToNormal(formId) { onCastToNormal(formId) {
// Called when the widget client converts the temporary widget into a normal one. The widget provider should do something to respond to the conversion. // Called when the widget host converts the temporary widget into a normal one. The widget provider should do something to respond to the conversion.
console.log('FormAbility onCastToNormal'); console.log('FormAbility onCastToNormal');
}, },
onUpdate(formId) { onUpdate(formId) {
// To support scheduled update, periodic update, or update requested by the widget client for a widget, override this method for data update. // To support scheduled update, periodic update, or update requested by the widget host for a widget, override this method for data update.
console.log('FormAbility onUpdate'); console.log('FormAbility onUpdate');
let obj = { let obj = {
"title": "titleOnUpdate", "title": "titleOnUpdate",
...@@ -101,7 +101,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li ...@@ -101,7 +101,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li
}); });
}, },
onVisibilityChange(newStatus) { onVisibilityChange(newStatus) {
// Called when the widget client initiates an event about visibility changes. The widget provider should do something to respond to the notification. // Called when the widget host initiates an event about visibility changes. The widget provider should do something to respond to the notification.
console.log('FormAbility onVisibilityChange'); console.log('FormAbility onVisibilityChange');
}, },
onEvent(formId, message) { onEvent(formId, message) {
...@@ -233,13 +233,13 @@ You should override **onDestroy** to delete widget data. ...@@ -233,13 +233,13 @@ You should override **onDestroy** to delete widget data.
For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md). For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md).
Note that the **Want** passed by the widget client to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one. Note that the **Want** passed by the widget host to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one.
Normal widget: a widget that will be persistently used by the widget client Normal widget: a widget that will be persistently used by the widget host
Temporary widget: a widget that is temporarily used by the widget client Temporary widget: a widget that is temporarily used by the widget host
Data of a temporary widget is not persistently stored. If the widget framework is killed and restarted, data of a temporary widget will be deleted. However, the widget provider is not notified of which widget is deleted, and still keeps the data. Therefore, the widget provider should implement data clearing. In addition, the widget client may convert a temporary widget into a normal one. If the conversion is successful, the widget provider should process the widget ID and store the data persistently. This prevents the widget provider from deleting persistent data when clearing temporary widgets. Data of a temporary widget is not persistently stored. If the widget framework is killed and restarted, data of a temporary widget will be deleted. However, the widget provider is not notified of which widget is deleted, and still keeps the data. Therefore, the widget provider should implement data clearing. In addition, the widget host may convert a temporary widget into a normal one. If the conversion is successful, the widget provider should process the widget ID and store the data persistently. This prevents the widget provider from deleting persistent data when clearing temporary widgets.
### Developing the Widget UI Page ### Developing the Widget UI Page
You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programmed widget. You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programmed widget.
......
...@@ -4,21 +4,21 @@ ...@@ -4,21 +4,21 @@
A widget is a set of UI components used to display important information or operations for an application. It provides users with direct access to a desired application service, without requiring them to open the application. A widget is a set of UI components used to display important information or operations for an application. It provides users with direct access to a desired application service, without requiring them to open the application.
A widget displays brief information about an application on the UI of another application (host application, currently system applications only) and provides basic interactive features such as opening a UI page or sending a message. The widget client is responsible for displaying the service widget. A widget displays brief information about an application on the UI of another application (host application, currently system applications only) and provides basic interactive features such as opening a UI page or sending a message. The widget host is responsible for displaying the service widget.
Basic concepts: Basic concepts:
- Widget provider - Widget provider
The widget provider is an atomic service that provides the content to be displayed. It controls the display content, component layout, and component click events of a widget. The widget provider is an atomic service that provides the content to be displayed. It controls the display content, component layout, and component click events of a widget.
- Widget client - Widget host
The widget client is an application that displays the widget content and controls the position where the widget is displayed in the host application. The widget host is an application that displays the widget content and controls the position where the widget is displayed in the host application.
- Widget Manager - Widget Manager
The Widget Manager is a resident agent that manages widgets added to the system and provides functions such as periodic widget update. The Widget Manager is a resident agent that manages widgets added to the system and provides functions such as periodic widget update.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The widget client and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated. > The widget host and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated.
You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget client and Widget Manager. You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget host and Widget Manager.
The widget provider controls the widget content to display, component layout, and click events bound to components. The widget provider controls the widget content to display, component layout, and click events bound to components.
...@@ -97,11 +97,11 @@ To create a widget in the stage model, you need to implement the lifecycle callb ...@@ -97,11 +97,11 @@ To create a widget in the stage model, you need to implement the lifecycle callb
return formData; return formData;
} }
onCastToNormal(formId) { onCastToNormal(formId) {
// Called when the widget client converts the temporary widget into a normal one. The widget provider should do something to respond to the conversion. // Called when the widget host converts the temporary widget into a normal one. The widget provider should do something to respond to the conversion.
console.log('FormAbility onCastToNormal'); console.log('FormAbility onCastToNormal');
} }
onUpdate(formId) { onUpdate(formId) {
// To support scheduled update, periodic update, or update requested by the widget client for a widget, override this method for data update. // To support scheduled update, periodic update, or update requested by the widget host for a widget, override this method for data update.
console.log('FormAbility onUpdate'); console.log('FormAbility onUpdate');
let obj = { let obj = {
"title": "titleOnUpdate", "title": "titleOnUpdate",
...@@ -113,7 +113,7 @@ To create a widget in the stage model, you need to implement the lifecycle callb ...@@ -113,7 +113,7 @@ To create a widget in the stage model, you need to implement the lifecycle callb
}); });
} }
onVisibilityChange(newStatus) { onVisibilityChange(newStatus) {
// Called when the widget client initiates an event about visibility changes. The widget provider should do something to respond to the notification. // Called when the widget host initiates an event about visibility changes. The widget provider should do something to respond to the notification.
console.log('FormAbility onVisibilityChange'); console.log('FormAbility onVisibilityChange');
} }
onEvent(formId, message) { onEvent(formId, message) {
...@@ -246,13 +246,13 @@ You should override **onDestroy** to delete widget data. ...@@ -246,13 +246,13 @@ You should override **onDestroy** to delete widget data.
For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md). For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md).
Note that the **Want** passed by the widget client to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one. Note that the **Want** passed by the widget host to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one.
Normal widget: a widget that will be persistently used by the widget client Normal widget: a widget that will be persistently used by the widget host
Temporary widget: a widget that is temporarily used by the widget client Temporary widget: a widget that is temporarily used by the widget host
Data of a temporary widget is not persistently stored. If the widget framework is killed and restarted, data of a temporary widget will be deleted. However, the widget provider is not notified of which widget is deleted, and still keeps the data. Therefore, the widget provider should implement data clearing. In addition, the widget client may convert a temporary widget into a normal one. If the conversion is successful, the widget provider should process the widget ID and store the data persistently. This prevents the widget provider from deleting persistent data when clearing temporary widgets. Data of a temporary widget is not persistently stored. If the widget framework is killed and restarted, data of a temporary widget will be deleted. However, the widget provider is not notified of which widget is deleted, and still keeps the data. Therefore, the widget provider should implement data clearing. In addition, the widget host may convert a temporary widget into a normal one. If the conversion is successful, the widget provider should process the widget ID and store the data persistently. This prevents the widget provider from deleting persistent data when clearing temporary widgets.
### Developing the Widget UI Page ### Developing the Widget UI Page
You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programmed widget. You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programmed widget.
......
...@@ -378,6 +378,7 @@ ...@@ -378,6 +378,7 @@
- [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md)
- [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md)
- [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md)
- [Navigation](reference/arkui-ts/ts-basic-components-navigation.md)
- [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md)
- [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md)
- [Progress](reference/arkui-ts/ts-basic-components-progress.md) - [Progress](reference/arkui-ts/ts-basic-components-progress.md)
...@@ -385,6 +386,7 @@ ...@@ -385,6 +386,7 @@
- [Radio](reference/arkui-ts/ts-basic-components-radio.md) - [Radio](reference/arkui-ts/ts-basic-components-radio.md)
- [Rating](reference/arkui-ts/ts-basic-components-rating.md) - [Rating](reference/arkui-ts/ts-basic-components-rating.md)
- [RichText](reference/arkui-ts/ts-basic-components-richtext.md) - [RichText](reference/arkui-ts/ts-basic-components-richtext.md)
- [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md)
- [Search](reference/arkui-ts/ts-basic-components-search.md) - [Search](reference/arkui-ts/ts-basic-components-search.md)
- [Select](reference/arkui-ts/ts-basic-components-select.md) - [Select](reference/arkui-ts/ts-basic-components-select.md)
- [Slider](reference/arkui-ts/ts-basic-components-slider.md) - [Slider](reference/arkui-ts/ts-basic-components-slider.md)
...@@ -414,13 +416,11 @@ ...@@ -414,13 +416,11 @@
- [List](reference/arkui-ts/ts-container-list.md) - [List](reference/arkui-ts/ts-container-list.md)
- [ListItem](reference/arkui-ts/ts-container-listitem.md) - [ListItem](reference/arkui-ts/ts-container-listitem.md)
- [Navigator](reference/arkui-ts/ts-container-navigator.md) - [Navigator](reference/arkui-ts/ts-container-navigator.md)
- [Navigation](reference/arkui-ts/ts-basic-components-navigation.md)
- [Panel](reference/arkui-ts/ts-container-panel.md) - [Panel](reference/arkui-ts/ts-container-panel.md)
- [Refresh](reference/arkui-ts/ts-container-refresh.md) - [Refresh](reference/arkui-ts/ts-container-refresh.md)
- [Row](reference/arkui-ts/ts-container-row.md) - [Row](reference/arkui-ts/ts-container-row.md)
- [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md)
- [Scroll](reference/arkui-ts/ts-container-scroll.md) - [Scroll](reference/arkui-ts/ts-container-scroll.md)
- [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md)
- [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md)
- [Stack](reference/arkui-ts/ts-container-stack.md) - [Stack](reference/arkui-ts/ts-container-stack.md)
- [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Swiper](reference/arkui-ts/ts-container-swiper.md)
......
...@@ -170,9 +170,9 @@ You can set a USB device as a host to connect to a device for data transfer. The ...@@ -170,9 +170,9 @@ You can set a USB device as a host to connect to a device for data transfer. The
var pipe = usb.connectDevice(deviceList[0]); var pipe = usb.connectDevice(deviceList[0]);
/* /*
Claim the corresponding interface from deviceList. Claim the corresponding interface from deviceList.
interface must be one present in the device configuration. interface1 must be one present in the device configuration.
*/ */
usb.claimInterface(pipe , interface, true); usb.claimInterface(pipe , interface1, true);
``` ```
4. Perform data transfer. 4. Perform data transfer.
......
...@@ -55,7 +55,6 @@ In this example, an application event is logged after the application startup ex ...@@ -55,7 +55,6 @@ In this example, an application event is logged after the application startup ex
}).catch((err) => { }).catch((err) => {
console.error(`failed to write event because ${err.code}`); console.error(`failed to write event because ${err.code}`);
}); });
});
// 3. Set the application event logging switch. // 3. Set the application event logging switch.
hiAppEvent.configure({ hiAppEvent.configure({
......
...@@ -6,9 +6,7 @@ HiAppEvent provides event logging APIs for applications to log the fault, statis ...@@ -6,9 +6,7 @@ HiAppEvent provides event logging APIs for applications to log the fault, statis
The HiAppEvent module of OpenHarmony can be used to develop application event services and provide functions related to application events, including flushing application events to a disk and querying historical application event data. The HiAppEvent module of OpenHarmony can be used to develop application event services and provide functions related to application events, including flushing application events to a disk and querying historical application event data.
- **Logging** **Logging**: Logs changes caused by user operations to provide service data for development, product, and O&M analysis.
Logs changes caused by user operations to provide service data for development, product, and O&M analysis.
## Event Verification Result Codes ## Event Verification Result Codes
......
...@@ -15,17 +15,17 @@ SystemCapability.BundleManager.BundleFramework ...@@ -15,17 +15,17 @@ SystemCapability.BundleManager.BundleFramework
## Required Permissions ## Required Permissions
| Required Permissions| Permission Level| Description| | Required Permissions | Permission Level | Description |
|-------| --------- | ---- | | ---------------------------------------- | ------------ | --------- |
| ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about the current application.| | ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about the current application.|
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all applications.| | ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all applications.|
| ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall applications.| | ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall applications. |
## bundle.getApplicationInfo ## bundle.getApplicationInfo
getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<ApplicationInfo> getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\<ApplicationInfo>
Obtains the application information based on a given bundle name. This method uses a promise to return the result. Obtains the application information based on a given bundle name. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -37,16 +37,16 @@ SystemCapability.BundleManager.BundleFramework ...@@ -37,16 +37,16 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | ------------------------------------------------------------ | | ----------- | ------ | ---- | --------------------------------------- |
| bundleName | string | Yes | Bundle name of the application. | | bundleName | string | Yes | Bundle name of the application. |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value** **Return value**
| Type | Description| | Type | Description |
| ----------- | -------- | | ------------------------- | ------------------ |
| Promise\<ApplicationInfo> | Promise used to return the application information.| | Promise\<ApplicationInfo> | Promise used to return the application information.|
**Example** **Example**
...@@ -69,7 +69,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId) ...@@ -69,7 +69,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId)
getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<ApplicationInfo>): void getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<ApplicationInfo>): void
Obtains the application information based on a given bundle name. This method uses an asynchronous callback to return the result. Obtains the application information based on a given bundle name. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -81,8 +81,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -81,8 +81,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------------------------------- | ---- | ------------------------------------------------------------ | | ----------- | ------------------------------- | ---- | --------------------------------------- |
| bundleName | string | Yes | Bundle name of the application. | | bundleName | string | Yes | Bundle name of the application. |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
...@@ -108,7 +108,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => { ...@@ -108,7 +108,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => {
getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<ApplicationInfo>): void getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<ApplicationInfo>): void
Obtains the application information based on a given bundle name. This method uses an asynchronous callback to return the result. Obtains the application information based on a given bundle name. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -120,8 +120,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -120,8 +120,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------------------------------- | ---- | ------------------------------------------------------------ | | ----------- | ------------------------------- | ---- | --------------------------------------- |
| bundleName | string | Yes | Bundle name of the application. | | bundleName | string | Yes | Bundle name of the application. |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback | AsyncCallback\<ApplicationInfo> | Yes | Callback used to return the application information. | | callback | AsyncCallback\<ApplicationInfo> | Yes | Callback used to return the application information. |
...@@ -145,7 +145,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => { ...@@ -145,7 +145,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise<Array\<BundleInfo>> getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise<Array\<BundleInfo>>
Obtains the information of all available bundles of a specified user in the system. This method uses a promise to return the result. Obtains the information of all available bundles of a specified user in the system. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -157,15 +157,15 @@ SystemCapability.BundleManager.BundleFramework ...@@ -157,15 +157,15 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ---------- | ---- | ----------------------------------------------------------- | | ---------- | ---------- | ---- | --------------------------------------- |
| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------- | ----------------------------------- | | --------------------------- | -------------------------- |
| Promise<Array\<BundleInfo>> | Promise used to return the information of all available bundles.| | Promise<Array\<BundleInfo>> | Promise used to return the information of all available bundles.|
**Example** **Example**
...@@ -187,7 +187,7 @@ bundle.getAllBundleInfo(bundleFlag, userId) ...@@ -187,7 +187,7 @@ bundle.getAllBundleInfo(bundleFlag, userId)
getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback<Array\<BundleInfo>>): void getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback<Array\<BundleInfo>>): void
Obtains the information of all available bundles in the system. This method uses an asynchronous callback to return the result. Obtains the information of all available bundles in the system. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -199,8 +199,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -199,8 +199,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | --------------------------------- | ---- | ------------------------------------------------------------ | | ---------- | --------------------------------- | ---- | --------------------------------------- |
| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback | AsyncCallback<Array\<BundleInfo>> | Yes | Callback used to return the information of all available bundles. | | callback | AsyncCallback<Array\<BundleInfo>> | Yes | Callback used to return the information of all available bundles. |
...@@ -222,7 +222,7 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => { ...@@ -222,7 +222,7 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => {
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 available bundles in the system. This method uses an asynchronous callback to return the result. Obtains the information of all available bundles in the system. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -234,8 +234,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -234,8 +234,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | --------------------------------- | ---- | ------------------------------------------------------------ | | ---------- | --------------------------------- | ---- | --------------------------------------- |
| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
| callback | AsyncCallback<Array\<BundleInfo>> | Yes | Callback used to return the information of all available bundles. | | callback | AsyncCallback<Array\<BundleInfo>> | Yes | Callback used to return the information of all available bundles. |
...@@ -260,7 +260,7 @@ bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => { ...@@ -260,7 +260,7 @@ bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => {
getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\<BundleInfo> getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\<BundleInfo>
Obtains the bundle information based on a given bundle name. This method uses a promise to return the result. Obtains the bundle information based on a given bundle name. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -272,8 +272,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -272,8 +272,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | ------------------------------------------------------------ | | ----------- | ------------- | ---- | --------------------------------------- |
| bundleName | string | Yes | Bundle name. | | bundleName | string | Yes | Bundle name. |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| options | BundleOptions | No | Includes **userId**. | | options | BundleOptions | No | Includes **userId**. |
...@@ -281,7 +281,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -281,7 +281,7 @@ SystemCapability.BundleManager.BundleFramework
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------- | ------------------------------------------ | | -------------------- | ---------------------------- |
| Promise\<BundleInfo> | Promise used to return the bundle information.| | Promise\<BundleInfo> | Promise used to return the bundle information.|
**Example** **Example**
...@@ -306,7 +306,7 @@ bundle.getBundleInfo(bundleName, bundleFlags, options) ...@@ -306,7 +306,7 @@ bundle.getBundleInfo(bundleName, bundleFlags, options)
getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void
Obtains the bundle information based on a given bundle name. This method uses an asynchronous callback to return the result. Obtains the bundle information based on a given bundle name. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -318,8 +318,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -318,8 +318,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | -------------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------------------------- | ---- | --------------------------------------- |
| bundleName | string | Yes | Bundle name. | | bundleName | string | Yes | Bundle name. |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback | AsyncCallback\<BundleInfo> | Yes | Callback used to return the bundle information. | | callback | AsyncCallback\<BundleInfo> | Yes | Callback used to return the bundle information. |
...@@ -343,7 +343,7 @@ bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => { ...@@ -343,7 +343,7 @@ bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => {
getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\<BundleInfo>): void getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\<BundleInfo>): void
Obtains the bundle information based on a given bundle name. This method uses an asynchronous callback to return the result. Obtains the bundle information based on a given bundle name. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -355,8 +355,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -355,8 +355,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | -------------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------------------------- | ---- | --------------------------------------- |
| bundleName | string | Yes | Bundle name. | | bundleName | string | Yes | Bundle name. |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| options | BundleOptions | Yes | Includes **userId**. | | options | BundleOptions | Yes | Includes **userId**. |
...@@ -384,7 +384,7 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => { ...@@ -384,7 +384,7 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => {
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 method 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.
**Required permissions** **Required permissions**
...@@ -396,15 +396,15 @@ SystemCapability.BundleManager.BundleFramework ...@@ -396,15 +396,15 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | ------------------------------------------------------ | | ----------- | ------ | ---- | --------------------------------------- |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | ------------------------------------------------ | | -------------------------------- | ------------------------------- |
| Promise<Array\<ApplicationInfo>> | Promise used to return the application information.| | Promise<Array\<ApplicationInfo>> | Promise used to return the application information.|
**Example** **Example**
...@@ -426,7 +426,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId) ...@@ -426,7 +426,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId)
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 of the specified user. This method uses an asynchronous callback to return the result. Obtains the information about all applications of the specified user. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -438,8 +438,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -438,8 +438,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | -------------------------------------- | ---- | ------------------------------------------------------ | | ----------- | -------------------------------------- | ---- | --------------------------------------- |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
| callback | AsyncCallback<Array\<ApplicationInfo>> | Yes | Callback used to return the application information. | | callback | AsyncCallback<Array\<ApplicationInfo>> | Yes | Callback used to return the application information. |
...@@ -461,9 +461,9 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { ...@@ -461,9 +461,9 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
## bundle.getAllApplicationInfo ## bundle.getAllApplicationInfo
function getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback<Array\<ApplicationInfo>>) : void; getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback<Array\<ApplicationInfo>>) : void;
Obtains the information about all applications. This method uses an asynchronous callback to return the result. Obtains the information about all applications of the specified user. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -475,8 +475,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -475,8 +475,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | -------------------------------------- | ---- | ------------------------------------------------------ | | ----------- | -------------------------------------- | ---- | --------------------------------------- |
| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback | AsyncCallback<Array\<ApplicationInfo>> | Yes | Callback used to return the application information. | | callback | AsyncCallback<Array\<ApplicationInfo>> | Yes | Callback used to return the application information. |
...@@ -497,7 +497,7 @@ bundle.getAllApplicationInfo(bundleFlags, (err, data) => { ...@@ -497,7 +497,7 @@ bundle.getAllApplicationInfo(bundleFlags, (err, data) => {
getAbilityInfo(bundleName: string, abilityName: string): Promise\<AbilityInfo> getAbilityInfo(bundleName: string, abilityName: string): Promise\<AbilityInfo>
Obtains the ability information based on a given want. This method uses a promise to return the result. Obtains the ability information based on a given bundle name and ability name. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -509,15 +509,15 @@ SystemCapability.BundleManager.BundleFramework ...@@ -509,15 +509,15 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | -------------------------------------------------------- | | ----------- | ------ | ---- | ---------------- |
| bundleName | string | Yes | Bundle name of the application. | | bundleName | string | Yes | Bundle name of the application. |
| abilityName | string | Yes | Name of the ability.| | abilityName | string | Yes | Ability name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------------------------- | | --------------------- | --------------------- |
| Promise\<AbilityInfo> | Promise used to return the ability information.| | Promise\<AbilityInfo> | Promise used to return the ability information.|
**Example** **Example**
...@@ -535,10 +535,9 @@ bundle.getAbilityInfo(bundleName, abilityName) ...@@ -535,10 +535,9 @@ bundle.getAbilityInfo(bundleName, abilityName)
## bundle.getAbilityInfo ## bundle.getAbilityInfo
getAbilityInfo(bundleName: string, abilityName: string): callback : getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\<AbilityInfo>): void;
AsyncCallback\<AbilityInfo>: void
Obtains the ability information based on a given want. This method uses an asynchronous callback to return the result. Obtains the ability information based on a given bundle name and ability name. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -550,11 +549,11 @@ SystemCapability.BundleManager.BundleFramework ...@@ -550,11 +549,11 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------------------------------------------------------- | | ----------- | ------------ | ---- | ---------------- |
| bundleName | string | Yes | Bundle name of the application. | | bundleName | string | Yes | Bundle name of the application. |
| abilityName | string | Yes | Name of the ability.| | abilityName | string | Yes | Ability name.|
| callback | AsyncCallback\<AbilityInfo> | Yes| Callback used to return the ability information.| | callback | AsyncCallback\<AbilityInfo> | Yes | Callback used to return the ability information.|
**Example** **Example**
...@@ -574,7 +573,7 @@ bundle.getAbilityInfo(bundleName, abilityName, (err, data) => { ...@@ -574,7 +573,7 @@ bundle.getAbilityInfo(bundleName, abilityName, (err, data) => {
getAbilityLabel(bundleName: string, abilityName: string): Promise\<string> getAbilityLabel(bundleName: string, abilityName: string): Promise\<string>
Obtains the application name based on a given want. This method uses a promise to return the result. Obtains the application name based on a given bundle name and ability name. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -586,15 +585,15 @@ SystemCapability.BundleManager.BundleFramework ...@@ -586,15 +585,15 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | -------------------------------------------------------- | | ----------- | ------ | ---- | ---------------- |
| bundleName | string | Yes | Bundle name of the application. | | bundleName | string | Yes | Bundle name of the application. |
| abilityName | string | Yes | Name of the ability.| | abilityName | string | Yes | Ability name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------------------------- | | ---------------- | ------------------ |
| Promise\<string> | Promise used to return the application name.| | Promise\<string> | Promise used to return the application name.|
**Example** **Example**
...@@ -614,7 +613,7 @@ bundle.getAbilityLabel(bundleName, abilityName) ...@@ -614,7 +613,7 @@ bundle.getAbilityLabel(bundleName, abilityName)
getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\<string>): void getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\<string>): void
Obtains the application name based on a given want. This method uses an asynchronous callback to return the result. Obtains the application name based on a given bundle name and ability name. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -626,11 +625,11 @@ SystemCapability.BundleManager.BundleFramework ...@@ -626,11 +625,11 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------------------------------------------------------- | | ----------- | ---------------------- | ---- | ---------------- |
| bundleName | string | Yes | Bundle name of the application. | | bundleName | string | Yes | Bundle name of the application. |
| abilityName | string | Yes | Name of the ability.| | abilityName | string | Yes | Ability name.|
| callback | AsyncCallback\<string> | Yes| Callback used to return the application name.| | callback | AsyncCallback\<string> | Yes | Callback used to return the application name. |
**Example** **Example**
...@@ -650,7 +649,7 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => { ...@@ -650,7 +649,7 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => {
isAbilityEnabled(info: AbilityInfo): Promise\<boolean> isAbilityEnabled(info: AbilityInfo): Promise\<boolean>
Checks whether an ability is enabled based on a given want. This method uses a promise to return the result. Checks whether an ability is enabled based on a given want. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -662,14 +661,14 @@ SystemCapability.BundleManager.BundleFramework ...@@ -662,14 +661,14 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | ------------ | | ---- | ----------- | ---- | ------------ |
| info | AbilityInfo | Yes | Ability information. | | info | AbilityInfo | Yes | Ability information.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ------------------------| | ----------------- | ------------------------- |
| Promise\<boolean> | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.| | Promise\<boolean> | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -691,7 +690,7 @@ bundle.isAbilityEnabled(Info) ...@@ -691,7 +690,7 @@ bundle.isAbilityEnabled(Info)
isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\<boolean>): void isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\<boolean>): void
Checks whether an ability is enabled based on a given want. This method uses an asynchronous callback to return the result. Checks whether an ability is enabled based on a given want. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -703,10 +702,10 @@ SystemCapability.BundleManager.BundleFramework ...@@ -703,10 +702,10 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------------------------------------------------------- | | -------- | ----------------------- | ---- | --------------- |
| info | AbilityInfo | Yes | Ability information. | | info | AbilityInfo | Yes | Ability information. |
| callback | AsyncCallback\<boolean> | Yes| Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.| | callback | AsyncCallback\<boolean> | Yes | Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -728,7 +727,7 @@ bundle.isAbilityEnabled(Info, (err, data) => { ...@@ -728,7 +727,7 @@ bundle.isAbilityEnabled(Info, (err, data) => {
isApplicationEnabled(bundleName: string): Promise\<boolean> isApplicationEnabled(bundleName: string): Promise\<boolean>
Checks whether an application is enabled based on a given want. This method uses a promise to return the result. Checks whether an application is enabled based on a given want. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -740,15 +739,15 @@ SystemCapability.BundleManager.BundleFramework ...@@ -740,15 +739,15 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | -------------------------------------------------------- | | ---------- | ------ | ---- | ------------ |
| bundleName | string | Yes | Bundle name of the application. | | bundleName | string | Yes | Bundle name of the application.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ------------------------| | ----------------- | ------------------------- |
| Promise\<boolean> | Promise used to return whether the application is enabled. If the application is enabled, **true** will be returned; otherwise, **false** will be returned.| | Promise\<boolean> | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -766,7 +765,7 @@ bundle.isApplicationEnabled(bundleName) ...@@ -766,7 +765,7 @@ bundle.isApplicationEnabled(bundleName)
isApplicationEnabled(bundleName: string, callback : AsyncCallback\<boolean>): void isApplicationEnabled(bundleName: string, callback : AsyncCallback\<boolean>): void
Checks whether an application is enabled based on a given want. This method uses an asynchronous callback to return the result. Checks whether an application is enabled based on a given want. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -778,15 +777,15 @@ SystemCapability.BundleManager.BundleFramework ...@@ -778,15 +777,15 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------------------------------------------------------- | | ---------- | ----------------------- | ---- | --------------- |
| bundleName | string | Yes | Bundle name of the application. | | bundleName | string | Yes | Bundle name of the application. |
| callback | AsyncCallback\<boolean> | Yes| Callback used to return whether the application is enabled. If the application is enabled, **true** will be returned; otherwise, **false** will be returned.| | callback | AsyncCallback\<boolean> | Yes | Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
```js ```js
let bundleName : "com.example.myapplication"; let bundleName = "com.example.myapplication";
bundle.isApplicationEnabled(bundleName, (err, data) => { bundle.isApplicationEnabled(bundleName, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
...@@ -800,7 +799,7 @@ bundle.isApplicationEnabled(bundleName, (err, data) => { ...@@ -800,7 +799,7 @@ bundle.isApplicationEnabled(bundleName, (err, data) => {
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 a given want. This method uses a promise to return the result. Obtains the ability information based on a given want. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -812,8 +811,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -812,8 +811,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | ------------------------------------------------------------ | | ----------- | ------ | ---- | ------------------------------------- |
| want | Want | Yes | Want that contains the bundle name. | | want | Want | Yes | Want that contains the bundle name. |
| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
...@@ -821,7 +820,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -821,7 +820,7 @@ SystemCapability.BundleManager.BundleFramework
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------------------------- | | ---------------------------- | --------------------- |
| Promise\<Array\<AbilityInfo>>| Promise used to return the ability information.| | Promise\<Array\<AbilityInfo>>| Promise used to return the ability information.|
**Example** **Example**
...@@ -847,7 +846,7 @@ bundle.queryAbilityByWant(want, bundleFlags, userId) ...@@ -847,7 +846,7 @@ bundle.queryAbilityByWant(want, bundleFlags, userId)
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 based on a given want. This method uses an asynchronous callback to return the result. Obtains the ability information based on a given want. This API uses an asynchronous callback to return the result.
**System capability** **System capability**
...@@ -855,8 +854,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -855,8 +854,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ | | ----------- | ---------------------------------- | ---- | ------------------------------------- |
| want | Want | Yes | Want that contains the bundle name. | | want | Want | Yes | Want that contains the bundle name. |
| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
...@@ -882,9 +881,9 @@ bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => { ...@@ -882,9 +881,9 @@ bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => {
## bundle.queryAbilityByWant ## bundle.queryAbilityByWant
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 a given want. This method uses an asynchronous callback to return the result. Obtains the ability information based on a given want. This API uses an asynchronous callback to return the result.
**System capability** **System capability**
...@@ -892,8 +891,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -892,8 +891,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ | | ----------- | ---------------------------------- | ---- | ------------------------------------- |
| want | Want | Yes | Want that contains the bundle name. | | want | Want | Yes | Want that contains the bundle name. |
| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| | bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback | AsyncCallback<Array\<AbilityInfo>> | Yes | Callback used to return the ability information. | | callback | AsyncCallback<Array\<AbilityInfo>> | Yes | Callback used to return the ability information. |
...@@ -915,98 +914,13 @@ bundle.queryAbilityByWant(want, bundleFlags, (err, data) => { ...@@ -915,98 +914,13 @@ bundle.queryAbilityByWant(want, bundleFlags, (err, data) => {
}) })
``` ```
## bundle.getBundleInstaller
getBundleInstaller(): Promise\<BundleInstaller>
Obtains the bundle installer. This method uses a promise to return the result.
**Required permissions**
ohos.permission.INSTALL_BUNDLE
**System capability**
SystemCapability.BundleManager.BundleFramework
**Return value**
| Type | Description |
| ------------------------ | --------------------------------------------------- |
| Promise\<BundleInstaller> | Promise used to return the bundle installer.|
**Example**
```js
let bundleFilePaths = ['/data/test.hap'];
let param = {
userId : 100,
installFlag : 1,
isKeepData : false
};
bundle.getBundleInstaller()
.then((installerObject) => {
console.info('Operation successful. ');
installerObject.install(bundleFilePaths, param)
.then((data) => {
console.info('Operation successful. Data:' + JSON.stringify(data));
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
```
## bundle.getBundleInstaller
getBundleInstaller(callback: AsyncCallback\<BundleInstaller>): void;
Obtains the bundle installer. This method uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.INSTALL_BUNDLE
**System capability**
SystemCapability.BundleManager.BundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------ | ---- | ------------------------------------------------- |
| callback | AsyncCallback\<BundleInstaller> | Yes | Callback used to return the bundle installer.|
**Example**
```js
let bundleFilePaths = ['/data/test.hap'];
let param = {
userId : 100,
installFlag : 1,
isKeepData : false
};
bundle.getBundleInstaller((err, installerObject) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
}
console.info('Operation successful. Data:' + JSON.stringify(installerObject));
installerObject.install(bundleFilePaths, param, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
}
console.info('Operation successful. Data:' + JSON.stringify(data));
})
})
```
## bundle.getLaunchWantForBundle ## bundle.getLaunchWantForBundle
getLaunchWantForBundle(bundleName: string): Promise\<Want> getLaunchWantForBundle(bundleName: string): Promise\<Want>
Obtains the **Want** object that launches the specified application. This method uses a promise to return the result. Obtains the **Want** object that launches the specified application. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -1018,13 +932,13 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1018,13 +932,13 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | -------- | | ---------- | ------ | ---- | ------------ |
| bundleName | string | Yes | Bundle name of the application.| | bundleName | string | Yes | Bundle name of the application.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------------------------ | | -------------- | -------------------------------------- |
| Promise\<Want> | Promise used to return the **Want** object.| | Promise\<Want> | Promise used to return the **Want** object.|
**Example** **Example**
...@@ -1043,7 +957,7 @@ bundle.getLaunchWantForBundle(bundleName) ...@@ -1043,7 +957,7 @@ bundle.getLaunchWantForBundle(bundleName)
getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void; getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\<Want>): void;
Obtains the **Want** object that launches the specified application. This method uses an asynchronous callback to return the result. Obtains the **Want** object that launches the specified application. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -1055,9 +969,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1055,9 +969,9 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | -------- | | ---------- | -------------------- | ---- | ------------------------------ |
| bundleName | string | Yes | Bundle name of the application.| | bundleName | string | Yes | Bundle name of the application. |
| callback | AsyncCallback\<Want> | Yes | Callback used to return the **Want** object.| | callback | AsyncCallback\<Want> | Yes | Callback used to return the **Want** object.|
**Example** **Example**
...@@ -1078,7 +992,7 @@ bundle.getLaunchWantForBundle(bundleName, (err, data) => { ...@@ -1078,7 +992,7 @@ bundle.getLaunchWantForBundle(bundleName, (err, data) => {
getNameForUid(uid: number): Promise\<string> getNameForUid(uid: number): Promise\<string>
Obtains the bundle name based on a UID. This method uses a promise to return the result. Obtains the bundle name based on a UID. This API uses a promise to return the result.
**System capability** **System capability**
...@@ -1086,13 +1000,13 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1086,13 +1000,13 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | -------- | | ---- | ------ | ---- | -------- |
| uid | number | Yes | UID based on which the bundle name is to obtain.| | uid | number | Yes | UID based on which the bundle name is to obtain.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------------------------ | | ---------------- | --------------------------------- |
| Promise\<string> | Promise used to return the bundle name.| | Promise\<string> | Promise used to return the bundle name.|
**Example** **Example**
...@@ -1109,9 +1023,9 @@ bundle.getNameForUid(uid) ...@@ -1109,9 +1023,9 @@ bundle.getNameForUid(uid)
## bundle.getNameForUid<sup>8+</sup> ## bundle.getNameForUid<sup>8+</sup>
getNameForUid(uid: number, callback: AsyncCallback\<string>): void; getNameForUid(uid: number, callback: AsyncCallback\<string>) : void
Obtains the bundle name based on a UID. This method uses an asynchronous callback to return the result. Obtains the bundle name based on a UID. This API uses an asynchronous callback to return the result.
**System capability** **System capability**
...@@ -1119,9 +1033,9 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1119,9 +1033,9 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | -------- | | -------- | ---------------------- | ---- | ------------------------- |
| uid | number | Yes | UID based on which the bundle name is to obtain.| | uid | number | Yes | UID based on which the bundle name is to obtain. |
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.| | callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.|
**Example** **Example**
...@@ -1140,9 +1054,9 @@ bundle.getNameForUid(uid, (err, data) => { ...@@ -1140,9 +1054,9 @@ bundle.getNameForUid(uid, (err, data) => {
## bundle.getAbilityIcon<sup>8+</sup> ## bundle.getAbilityIcon<sup>8+</sup>
getAbilityIcon(bundleName: string, abilityName: string): Promise\<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)>; getAbilityIcon(bundleName: string, abilityName: string): Promise\<image.PixelMap>;
Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the corresponding icon based on a given bundle name and ability name. This method uses a promise to return the result. Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the corresponding icon based on a given bundle name and ability name. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -1154,15 +1068,15 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1154,15 +1068,15 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | -------- | | ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| bundleName | string | Yes | Bundle name based on which the pixel map is to obtain.| | bundleName | string | Yes | Bundle name based on which the pixel map is to obtain. |
| abilityName | string | Yes | Ability name based on which the pixel map is to obtain.| | abilityName | string | Yes | Ability name based on which the pixel map is to obtain. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------------------------ | | --------------------- | ------------------------------------------------------------ |
| Promise\<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)> | Promise used to return the <[PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md)>.| | Promise\<image.PixelMap> | Promise used to return the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md)>.|
**Example** **Example**
...@@ -1179,9 +1093,9 @@ bundle.getAbilityIcon(bundleName, abilityName) ...@@ -1179,9 +1093,9 @@ bundle.getAbilityIcon(bundleName, abilityName)
## bundle.getAbilityIcon<sup>8+</sup> ## bundle.getAbilityIcon<sup>8+</sup>
getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)>): void; getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void;
Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the corresponding icon based on a given bundle name and ability name. This method uses an asynchronous callback to return the result. Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the corresponding icon based on a given bundle name and ability name. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -1193,11 +1107,11 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1193,11 +1107,11 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | -------- | | ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| bundleName | string | Yes | Bundle name based on which the pixel map is to obtain.| | bundleName | string | Yes | Bundle name based on which the pixel map is to obtain. |
| abilityName | string | Yes | Ability name based on which the pixel map is to obtain.| | abilityName | string | Yes | Ability name based on which the pixel map is to obtain. |
| callback | AsyncCallback\<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)> | Yes | Callback used to return the <[PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md)>.| | callback | AsyncCallback\<image.PixelMap> | Yes | Callback used to return the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md)>.|
**Example** **Example**
...@@ -1218,7 +1132,7 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { ...@@ -1218,7 +1132,7 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => {
queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId?: number): Promise<Array\<ExtensionAbilityInfo>> queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId?: number): Promise<Array\<ExtensionAbilityInfo>>
Obtains the extension ability information based on a given want. This method uses a promise to return the result. Obtains the Extension ability information based on a given want. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -1230,8 +1144,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1230,8 +1144,8 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | ------------------------------------------------------------ | | -------------- | ------ | ---- | ---------------------------------------- |
| want | Want | Yes | Want that contains the bundle name. | | want | Want | Yes | Want that contains the bundle name. |
| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| | extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
...@@ -1239,8 +1153,8 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1239,8 +1153,8 @@ SystemCapability.BundleManager.BundleFramework
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------------------------- | | ------------------------------------- | ------------------------------ |
| Promise<Array\<ExtensionAbilityInfo>> | Promise used to return the extension ability information.| | Promise<Array\<ExtensionAbilityInfo>> | Promise used to return the Extension ability information.|
**Example** **Example**
...@@ -1265,7 +1179,7 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, userId) ...@@ -1265,7 +1179,7 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, userId)
queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void
Obtains the extension ability information based on a given want. This method uses an asynchronous callback to return the result. Obtains the Extension ability information based on a given want. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -1277,12 +1191,12 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1277,12 +1191,12 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ | | -------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| want | Want | Yes | Want that contains the bundle name. | | want | Want | Yes | Want that contains the bundle name. |
| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| | extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
| callback | AsyncCallback<Array\<ExtensionAbilityInfo>> | Yes | Callback used to return the extension ability information. | | callback | AsyncCallback<Array\<ExtensionAbilityInfo>> | Yes | Callback used to return the Extension ability information. |
**Example** **Example**
...@@ -1306,7 +1220,7 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, userId, (err, data ...@@ -1306,7 +1220,7 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, userId, (err, data
queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void; queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, callback: AsyncCallback<Array\<ExtensionAbilityInfo>>): void;
Obtains the extension ability information based on a given want. This method uses an asynchronous callback to return the result. Obtains the Extension ability information based on a given want. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -1318,11 +1232,11 @@ SystemCapability.BundleManager.BundleFramework ...@@ -1318,11 +1232,11 @@ SystemCapability.BundleManager.BundleFramework
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ | | -------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| want | Want | Yes | Want that contains the bundle name. | | want | Want | Yes | Want that contains the bundle name. |
| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| | extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback | AsyncCallback<Array\<ExtensionAbilityInfo>> | Yes | Callback used to return the extension ability information. | | callback | AsyncCallback<Array\<ExtensionAbilityInfo>> | Yes | Callback used to return the Extension ability information. |
**Example** **Example**
...@@ -1345,40 +1259,40 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { ...@@ -1345,40 +1259,40 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => {
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory | Description |
| ----------- | -------- | ------ | ---- | ------------------------------------------------------------ | | ----------- | ---- | ------ | ---- | ---------------------------------------- |
| deviceId | Read-only | string | No | ID of the device that runs the ability. | | deviceId | Read-only | string | No | ID of the device that runs the ability. |
| bundleName | Read-only | string | Yes | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| | bundleName | Read-only | string | Yes | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.|
| abilityName | Read-only | string | Yes | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| | abilityName | Read-only | string | Yes | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.|
| uri | Read-only | string | No | Resource ID.| | uri | Read-only | string | No | Resource ID. |
| shortName | Read-only | string | No | Short name of the **ElementName**.| | shortName | Read-only | string | No | Short name of the **ElementName**. |
## InstallErrorCode ## InstallErrorCode
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Default Value| Description | | Name | Default Value | Description |
| ------ | ------ | ------ | | ---------------------------------------- | ---- | ------------------------- |
| SUCCESS | 0 | Installation succeeded.| | SUCCESS | 0 | Installation succeeded. |
| STATUS_INSTALL_FAILURE | 1 | Installation failed. (The application to be installed does not exist.)| | STATUS_INSTALL_FAILURE | 1 | Installation failed. (The application to be installed does not exist.) |
| STATUS_INSTALL_FAILURE_ABORTED | 2 | Installation aborted.| | STATUS_INSTALL_FAILURE_ABORTED | 2 | Installation aborted. |
| STATUS_INSTALL_FAILURE_INVALID | 3 | Invalid installation parameter.| | STATUS_INSTALL_FAILURE_INVALID | 3 | Invalid installation parameter. |
| STATUS_INSTALL_FAILURE_CONFLICT | 4 | Installation conflict. (The basic information about the application to upgrade is inconsistent with that of the existing application.)| | STATUS_INSTALL_FAILURE_CONFLICT | 4 | Installation conflict. (The basic information about the application to upgrade is inconsistent with that of the existing application.) |
| STATUS_INSTALL_FAILURE_STORAGE | 5 | Failed to store the bundle information.| | STATUS_INSTALL_FAILURE_STORAGE | 5 | Failed to store the bundle information. |
| STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | Installation incompatible. (A downgrade occurs or the signature information is incorrect.)| | STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | Installation incompatible. (A downgrade occurs or the signature information is incorrect.) |
| STATUS_UNINSTALL_FAILURE | 7 | Uninstallation failed. (The application to be uninstalled does not exist.)| | STATUS_UNINSTALL_FAILURE | 7 | Uninstallation failed. (The application to be uninstalled does not exist.) |
| STATUS_UNINSTALL_FAILURE_BLOCKED | 8 | Uninstallation aborted. (This error code is not in use.)| | STATUS_UNINSTALL_FAILURE_BLOCKED | 8 | Uninstallation aborted. (This error code is not in use.) |
| STATUS_UNINSTALL_FAILURE_ABORTED | 9 | Uninstallation aborted. (Invalid parameters.)| | STATUS_UNINSTALL_FAILURE_ABORTED | 9 | Uninstallation aborted. (Invalid parameters.) |
| STATUS_UNINSTALL_FAILURE_CONFLICT | 10 | Uninstallation conflict. (Failed to uninstall a system application or end the application process.)| | STATUS_UNINSTALL_FAILURE_CONFLICT | 10 | Uninstallation conflict. (Failed to uninstall a system application or end the application process.)|
| STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT | 0x0B | Installation failed. (Download timed out.)| | STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT | 0x0B | Installation failed. (Download timed out.) |
| STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED | 0x0C | Installation failed. (Download failed.)| | STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED | 0x0C | Installation failed. (Download failed.) |
| STATUS_RECOVER_FAILURE_INVALID<sup>8+</sup> | 0x0D | Failed to restore the pre-installed application.| | STATUS_RECOVER_FAILURE_INVALID<sup>8+</sup> | 0x0D | Failed to restore the pre-installed application. |
| STATUS_ABILITY_NOT_FOUND | 0x40 | Ability not found.| | STATUS_ABILITY_NOT_FOUND | 0x40 | Ability not found. |
| STATUS_BMS_SERVICE_ERROR | 0x41 | BMS service error.| | STATUS_BMS_SERVICE_ERROR | 0x41 | BMS service error. |
| STATUS_FAILED_NO_SPACE_LEFT<sup>8+</sup> | 0x42 | Insufficient device space.| | STATUS_FAILED_NO_SPACE_LEFT<sup>8+</sup> | 0x42 | Insufficient device space. |
| STATUS_GRANT_REQUEST_PERMISSIONS_FAILED<sup>8+</sup> | 0x43 | Application authorization failed.| | STATUS_GRANT_REQUEST_PERMISSIONS_FAILED<sup>8+</sup> | 0x43 | Application authorization failed. |
| STATUS_INSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x44 | Installation permission denied.| | STATUS_INSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x44 | Installation permission denied. |
| STATUS_UNINSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x45 | Uninstallation permission denied.| | STATUS_UNINSTALL_PERMISSION_DENIED<sup>8+</sup> | 0x45 | Uninstallation permission denied. |
## BundleFlag ## BundleFlag
...@@ -1386,21 +1300,21 @@ Enumerates bundle flags. ...@@ -1386,21 +1300,21 @@ Enumerates bundle flags.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Default Value| Description | | Name | Default Value | Description |
| ------ | ------ | ------ | | ---------------------------------------- | ---------- | ------------------- |
| GET_BUNDLE_DEFAULT | 0x00000000 | Obtains the default application information.| | GET_BUNDLE_DEFAULT | 0x00000000 | Obtains the default application information. |
| GET_BUNDLE_WITH_ABILITIES | 0x00000001 | Obtains the bundle information with the ability information.| | GET_BUNDLE_WITH_ABILITIES | 0x00000001 | Obtains the bundle information with the ability information. |
| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000002 | Obtains the ability information with the permission information.| | GET_ABILITY_INFO_WITH_PERMISSION | 0x00000002 | Obtains the ability information with the permission information. |
| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | Obtains the ability information with the application information.| | GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | Obtains the ability information with the application information. |
| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | Obtains the application information with the permission information.| | GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | Obtains the application information with the permission information. |
| GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | Obtains the bundle information with the information about the required permissions.| | GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | Obtains the bundle information with the information about the required permissions. |
| GET_ABILITY_INFO_WITH_METADATA<sup>8+</sup> | 0x00000020 | Obtains the ability metadata information.| | GET_ABILITY_INFO_WITH_METADATA<sup>8+</sup> | 0x00000020 | Obtains the ability metadata information. |
| GET_BUNDLE_WITH_EXTENSION_ABILITY<sup>9+</sup> | 0x00000020 | Obtains the bundle information with the extension ability information.| | GET_BUNDLE_WITH_EXTENSION_ABILITY<sup>9+</sup> | 0x00000020 | Obtains the bundle information with the Extension ability information.|
| GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | Obtains the application metadata information.| | GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | Obtains the application metadata information. |
| GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup> | 0x00000080 | Obtains the ability information with information about system applications.| | GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup> | 0x00000080 | Obtains the ability information with information about system applications.|
| GET_ABILITY_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000100 | Obtains information about disabled abilities.| | GET_ABILITY_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000100 | Obtains information about disabled abilities. |
| GET_APPLICATION_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000200 | Obtains information about disabled applications.| | GET_APPLICATION_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000200 | Obtains information about disabled applications. |
| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information.| | GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information. |
## BundleOptions ## BundleOptions
...@@ -1408,9 +1322,9 @@ Describes the bundle options. ...@@ -1408,9 +1322,9 @@ Describes the bundle options.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| ------ | ------ | ------ | ------ | ------ | | ------ | ------ | ---- | ---- | ---------------------------- |
| userId | number | Yes| Yes| User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| | userId | number | Yes | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
## BundleInfo ## BundleInfo
...@@ -1418,8 +1332,8 @@ Describes the application bundle information. ...@@ -1418,8 +1332,8 @@ Describes the application bundle information.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| ------ | ------ | ------ | ------ | ------ | | --------------------------------- | ---------------------------- | ---- | ---- | --------------------- |
| name | string | Yes | No | Bundle name. | | name | string | Yes | No | Bundle name. |
| type | string | Yes | No | Bundle type. | | type | string | Yes | No | Bundle type. |
| appId | string | Yes | No | ID of the application to which the bundle belongs. | | appId | string | Yes | No | ID of the application to which the bundle belongs. |
...@@ -1441,9 +1355,9 @@ Describes the application bundle information. ...@@ -1441,9 +1355,9 @@ Describes the application bundle information.
| cpuAbi | string | Yes | No | cpuAbi information of the bundle. | | cpuAbi | string | Yes | No | cpuAbi information of the bundle. |
| isSilentInstallation | string | Yes | No | Whether to install the bundle in silent mode. | | isSilentInstallation | string | Yes | No | Whether to install the bundle in silent mode. |
| minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. | | minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. |
| entryInstallationFree | boolean | Yes| No| Whether installation-free is supported for the entry.| | entryInstallationFree | boolean | Yes | No | Whether installation-free is supported for the entry. |
| reqPermissionStates<sup>8+</sup> | Array\<number> | Yes| No| Permission grant state.| | reqPermissionStates<sup>8+</sup> | Array\<number> | Yes | No | Permission grant state. |
| extensionAbilityInfo<sup>9+</sup> | Array\<ExtensionAbilityInfo> | Yes| No| Extended information of the ability.| | extensionAbilityInfo<sup>9+</sup> | Array\<ExtensionAbilityInfo> | Yes | No | Extended information of the ability. |
## ApplicationInfo ## ApplicationInfo
...@@ -1451,8 +1365,8 @@ Describes the application information. ...@@ -1451,8 +1365,8 @@ Describes the application information.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| ------ | ------ | ------ | ------ | ------ | | -------------------------- | ---------------------------------- | ---- | ---- | --------------------- |
| name | string | Yes | No | Application name. | | name | string | Yes | No | Application name. |
| description | string | Yes | No | Application description. | | description | string | Yes | No | Application description. |
| descriptionId | number | Yes | No | Application description ID. | | descriptionId | number | Yes | No | Application description ID. |
...@@ -1468,14 +1382,13 @@ Describes the application information. ...@@ -1468,14 +1382,13 @@ Describes the application information.
| permissions | Array\<string> | Yes | No | Permissions required for accessing the application. | | permissions | Array\<string> | Yes | No | Permissions required for accessing the application. |
| moduleInfos | Array\<ModuleInfo> | Yes | No | Application module information. | | moduleInfos | Array\<ModuleInfo> | Yes | No | Application module information. |
| entryDir | string | Yes | No | Path for storing application files. | | entryDir | string | Yes | No | Path for storing application files. |
| customizeData | Map<string, Array\<CustomizeData>> | Yes | Yes | Custom data of the application. | | codePath<sup>8+</sup> | string | Yes | No | Installation directory of the application. |
| codePath<sup>8+</sup> | string | Yes| No| Installation directory of the application.| | metaData<sup>8+</sup> | Map<string, Array\<CustomizeData>> | Yes | No | Custom metadata of the application. |
| metaData<sup>8+</sup> | Map<string, Array\<CustomizeData>> | Yes| No| Custom metadata of the application.| | metaData<sup>9+</sup> | Map<string, Array\<Metadata>> | Yes | No | Metadata of the application. |
| metaData<sup>9+</sup> | Map<string, Array\<Metadata>> | Yes| No| Metadata of the application.| | removable<sup>8+</sup> | boolean | Yes | No | Whether the application is removable. |
| removable<sup>8+</sup> | boolean | Yes| No| Whether the application is removable.| | accessTokenId<sup>8+</sup> | number | Yes | No | Access token ID of the application. |
| accessTokenId<sup>8+</sup> | number | Yes| No| Access token ID of the application.| | uid<sup>8+</sup> | number | Yes | No | UID of the application. |
| uid<sup>8+</sup> | number | Yes| No| UID of the application.| | entityType<sup>9+</sup> | string | Yes | No | Entity type of the application. |
| entityType<sup>9+</sup> | string | Yes| No| Entity type of the application.|
## ModuleInfo ## ModuleInfo
...@@ -1483,8 +1396,8 @@ Describes the module information of the application. ...@@ -1483,8 +1396,8 @@ Describes the module information of the application.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| ------ | ------ | ------ | ------ | ------ | | --------------- | ------ | ---- | ---- | ---- |
| moduleName | string | Yes | No | Module name.| | moduleName | string | Yes | No | Module name.|
| moduleSourceDir | string | Yes | No | Installation directory.| | moduleSourceDir | string | Yes | No | Installation directory.|
...@@ -1494,8 +1407,8 @@ Describes the custom metadata. ...@@ -1494,8 +1407,8 @@ Describes the custom metadata.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description | | Name | Type | Readable | Writable | Description |
| ----- | ------ | ---- | ---- | ---------------- | | ------------------ | ------ | ---- | ---- | -------- |
| name | string | Yes | Yes | Custom metadata name.| | name | string | Yes | Yes | Custom metadata name.|
| value | string | Yes | Yes | Custom metadata value. | | value | string | Yes | Yes | Custom metadata value. |
| extra<sup>8+</sup> | string | Yes | Yes | Custom resources. | | extra<sup>8+</sup> | string | Yes | Yes | Custom resources. |
...@@ -1507,8 +1420,8 @@ Describes the HAP module information. ...@@ -1507,8 +1420,8 @@ Describes the HAP module information.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| ------ | ------ | ------ | ------ | ------ | | --------------------------------- | ---------------------------- | ---- | ---- | ------------------ |
| name | string | Yes | No | Module name. | | name | string | Yes | No | Module name. |
| description | string | Yes | No | Module description. | | description | string | Yes | No | Module description. |
| descriptionId | number | Yes | No | Module description ID. | | descriptionId | number | Yes | No | Module description ID. |
...@@ -1518,15 +1431,15 @@ Describes the HAP module information. ...@@ -1518,15 +1431,15 @@ Describes the HAP module information.
| iconId | number | Yes | No | Module icon ID. | | iconId | number | Yes | No | Module icon ID. |
| backgroundImg | string | Yes | No | Module background image. | | backgroundImg | string | Yes | No | Module background image. |
| supportedModes | number | Yes | No | Modes supported by the module. | | supportedModes | number | Yes | No | Modes supported by the module. |
| reqCapabilities | Array\<string> | Yes | No | Capabilities required for module running.| | reqCapabilities | Array\<string> | Yes | No | Capabilities required for module running. |
| deviceTypes | Array\<string> | Yes | No | An array of supported device types.| | deviceTypes | Array\<string> | Yes | No | An array of supported device types. |
| abilityInfo | Array\<AbilityInfo> | Yes | No | Ability information. | | abilityInfo | Array\<AbilityInfo> | Yes | No | Ability information. |
| moduleName | string | Yes | No | Module name. | | moduleName | string | Yes | No | Module name. |
| mainAbilityName | string | Yes | No | Name of the entry ability. | | mainAbilityName | string | Yes | No | Name of the entry ability. |
| installationFree | boolean | Yes | No | Whether installation-free is supported. | | installationFree | boolean | Yes | No | Whether installation-free is supported. |
| mainElementName<sup>8+</sup> | string | Yes| No| Information about the entry ability.| | mainElementName<sup>9+</sup> | string | Yes | No | Information about the entry ability. |
| extensionAbilityInfo<sup>9+</sup> | Array\<ExtensionAbilityInfo> | Yes| No| Extension ability information.| | extensionAbilityInfo<sup>9+</sup> | Array\<ExtensionAbilityInfo> | Yes | No | Extension ability information.|
| metadata<sup>9+</sup> | Array\<Metadata> | Yes| No| Metadata of the ability.| | metadata<sup>9+</sup> | Array\<Metadata> | Yes | No | Metadata of the ability. |
## ReqPermissionDetail ## ReqPermissionDetail
...@@ -1534,11 +1447,11 @@ Describes the detailed information of the permissions to request from the system ...@@ -1534,11 +1447,11 @@ Describes the detailed information of the permissions to request from the system
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| ------ | ------ | ------ | ------ | ------ | | --------- | --------- | ---- | ---- | ---------- |
| name | string | Yes | Yes | Name of the permission to request. | | name | string | Yes | Yes | Name of the permission to request. |
| reason | string | Yes | Yes | Reason for requesting the permission. | | reason | string | Yes | Yes | Reason for requesting the permission. |
| usedScene | UsedScene | Yes| Yes| Application scenario and timing for using the permission.| | usedScene | UsedScene | Yes | Yes | Application scenario and timing for using the permission.|
## UsedScene ## UsedScene
...@@ -1546,8 +1459,8 @@ Describes the application scenario and timing for using the permission. ...@@ -1546,8 +1459,8 @@ Describes the application scenario and timing for using the permission.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| ------ | ------ | ------ | ------ | ------ | | --------- | -------------- | ---- | ---- | ---------------- |
| abilities | Array\<string> | Yes | Yes | Abilities that use the permission.| | abilities | Array\<string> | Yes | Yes | Abilities that use the permission.|
| when | string | Yes | Yes | Time when the permission is used. | | when | string | Yes | Yes | Time when the permission is used. |
...@@ -1558,8 +1471,8 @@ Describes the ability information. ...@@ -1558,8 +1471,8 @@ Describes the ability information.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| ------ | ------ | ------ | ------ | ------ | | --------------------- | --------------------- | ---- | ---- | ------------------------ |
| bundleName | string | Yes | No | Application bundle name. | | bundleName | string | Yes | No | Application bundle name. |
| name | string | Yes | No | Ability name. | | name | string | Yes | No | Ability name. |
| label | string | Yes | No | Ability name visible to users. | | label | string | Yes | No | Ability name visible to users. |
...@@ -1585,9 +1498,9 @@ Describes the ability information. ...@@ -1585,9 +1498,9 @@ Describes the ability information.
| uri | string | Yes | No | URI of the ability. | | uri | string | Yes | No | URI of the ability. |
| labelId | number | Yes | No | Ability label ID. | | labelId | number | Yes | No | Ability label ID. |
| subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability. | | subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability. |
| metaData<sup>8+</sup> | Array\<CustomizeData> | Yes| No| Custom information of the ability.| | metaData<sup>8+</sup> | Array\<CustomizeData> | Yes | No | Custom information of the ability. |
| metaData<sup>9+</sup> | Array\<Metadata> | Yes| No| Metadata of the ability.| | metaData<sup>9+</sup> | Array\<Metadata> | Yes | No | Metadata of the ability. |
| enabled<sup>8+</sup> | boolean | Yes| No| Whether the ability is enabled.| | enabled<sup>8+</sup> | boolean | Yes | No | Whether the ability is enabled. |
## AbilityType ## AbilityType
...@@ -1595,8 +1508,8 @@ Enumerates ability types. ...@@ -1595,8 +1508,8 @@ Enumerates ability types.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description | | Name | Type | Description |
| ------- | ---- | --------------------------- | | ------- | ---- | ----------------- |
| UNKNOWN | None | Unknown ability type. | | UNKNOWN | None | Unknown ability type. |
| PAGE | None | Ability that has a UI. | | PAGE | None | Ability that has a UI. |
| SERVICE | None | Ability that does not have a UI. | | SERVICE | None | Ability that does not have a UI. |
...@@ -1608,8 +1521,8 @@ Enumerates display orientations. ...@@ -1608,8 +1521,8 @@ Enumerates display orientations.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description | | Name | Type | Description |
| ------------- | ---- | ------------------------ | | ------------- | ---- | ------------- |
| UNSPECIFIED | None | The system automatically determines the display orientation. | | UNSPECIFIED | None | The system automatically determines the display orientation. |
| LANDSCAPE | None | Landscape orientation. | | LANDSCAPE | None | Landscape orientation. |
| PORTRAIT | None | Portrait orientation. | | PORTRAIT | None | Portrait orientation. |
...@@ -1621,8 +1534,8 @@ Enumerates launch modes. ...@@ -1621,8 +1534,8 @@ Enumerates launch modes.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description | | Name | Type | Description |
| ----------- | ---- | ------------------- | | --------- | ---- | ------------- |
| SINGLETON | 0 | The ability has only one instance.| | SINGLETON | 0 | The ability has only one instance.|
| STANDARD | 1 | The ability can have multiple instances. | | STANDARD | 1 | The ability can have multiple instances. |
...@@ -1632,20 +1545,20 @@ Enumerates ability subtypes. ...@@ -1632,20 +1545,20 @@ Enumerates ability subtypes.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description | | Name | Type | Description |
| ----------- | ---- | ----------------------------- | | ----------- | ---- | -------------------- |
| UNSPECIFIED | 0 | Undefined ability subtype. | | UNSPECIFIED | 0 | Undefined ability subtype. |
| CA | 1 | Ability that has a UI.| | CA | 1 | Ability that has a UI.|
## ExtensionAbilityType<sup>9+</sup> ## ExtensionAbilityType<sup>9+</sup>
Enumerates extension ability types. Enumerates Extension ability types.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description | | Name | Type | Description |
| -------------------- | ---- | ----------------------------- | | ------------------------------ | ---- | ------------------------- |
| FORM<sup>9+</sup> | 0 | Form included. | | FORM<sup>9+</sup> | 0 | Form included. |
| WORK_SCHEDULER<sup>9+</sup> | 1 | Work scheduler included.| | WORK_SCHEDULER<sup>9+</sup> | 1 | Work scheduler included.|
| INPUT_METHOD<sup>9+</sup> | 2 | Input method included. | | INPUT_METHOD<sup>9+</sup> | 2 | Input method included. |
...@@ -1659,16 +1572,16 @@ Enumerates extension ability types. ...@@ -1659,16 +1572,16 @@ Enumerates extension ability types.
## ExtensionFlag<sup>9+</sup> ## ExtensionFlag<sup>9+</sup>
Enumerates extension flags. Enumerates Extension flags.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Default Value| Description | | Name | Default Value | Description |
| ------ | ------ | ------ | | ---------------------------------------- | ---------- | ------------------------------ |
| GET_EXTENSION_INFO_DEFAULT<sup>9+</sup> | 0x00000000 | Obtains the default extension ability information.| | GET_EXTENSION_INFO_DEFAULT<sup>9+</sup> | 0x00000000 | Obtains the default Extension ability information. |
| GET_EXTENSION_INFO_WITH_PERMISSION<sup>9+</sup> | 0x00000002 | Obtains the extension ability information that carries permission information.| | GET_EXTENSION_INFO_WITH_PERMISSION<sup>9+</sup> | 0x00000002 | Obtains the Extension ability information that carries permission information. |
| GET_EXTENSION_INFO_WITH_APPLICATION<sup>9+</sup> | 0x00000004 | Obtains the extension ability information that carries application information.| | GET_EXTENSION_INFO_WITH_APPLICATION<sup>9+</sup> | 0x00000004 | Obtains the Extension ability information that carries application information. |
| GET_EXTENSION_INFO_WITH_METADATA<sup>9+</sup> | 0x00000020 | Obtains the extension ability information that carries metadata information.| | GET_EXTENSION_INFO_WITH_METADATA<sup>9+</sup> | 0x00000020 | Obtains the Extension ability information that carries metadata information.|
## ColorMode ## ColorMode
...@@ -1677,11 +1590,11 @@ Enumerates color modes. ...@@ -1677,11 +1590,11 @@ Enumerates color modes.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description | | Name | Type | Description |
| ----------- | ---- | ------------------- | | ---------- | ---- | ---- |
| AUTO_MODE | -1 | Automatic mode.| | AUTO_MODE | -1 | Automatic mode.|
| DARK_MODE | 0 | Dark mode. | | DARK_MODE | 0 | Dark mode.|
| LIGHT_MODE | 1 | Light mode. | | LIGHT_MODE | 1 | Light mode.|
## GrantStatus ## GrantStatus
...@@ -1690,34 +1603,34 @@ Enumerates permission grant statuses. ...@@ -1690,34 +1603,34 @@ Enumerates permission grant statuses.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description | | Name | Type | Description |
| ----------- | ---- | ------------------- | | ------------------ | ---- | ---- |
| PERMISSION_DENIED | -1 | Permission denied.| | PERMISSION_DENIED | -1 | Permission denied.|
| PERMISSION_GRANTED | 0 | Permission granted. | | PERMISSION_GRANTED | 0 | Permission granted. |
## ExtensionAbilityInfo<sup>9+</sup> ## ExtensionAbilityInfo<sup>9+</sup>
Describes the extension ability information. Describes the Extension ability information.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| ------ | ------ | ------ | ------ | ------ | | --------------------------------- | --------------------------- | ---- | ---- | --------------------------------- |
| bundleName<sup>9+</sup> | string | Yes | No | Application bundle name. | | bundleName<sup>9+</sup> | string | Yes | No | Application bundle name. |
| moduleName<sup>9+</sup> | string | Yes | No | Name of the HAP file to which the extension ability belongs. | | moduleName<sup>9+</sup> | string | Yes | No | Name of the HAP file to which the Extension ability belongs. |
| name<sup>9+</sup> | string | Yes | No | Name of the extension ability. | | name<sup>9+</sup> | string | Yes | No | Name of the Extension ability. |
| labelId<sup>9+</sup> | number | Yes | No | Label ID of the extension ability. | | labelId<sup>9+</sup> | number | Yes | No | Label ID of the Extension ability. |
| descriptionId<sup>9+</sup> | number | Yes | No | Description ID of the extension ability. | | descriptionId<sup>9+</sup> | number | Yes | No | Description ID of the Extension ability. |
| iconId<sup>9+</sup> | number | Yes | No | Icon ID of the extension ability. | | iconId<sup>9+</sup> | number | Yes | No | Icon ID of the Extension ability. |
| isVisible<sup>9+</sup> | boolean | Yes | No | Whether the extension ability can be called by other applications. | | isVisible<sup>9+</sup> | boolean | Yes | No | Whether the Extension ability can be called by other applications. |
| extensionAbilityType<sup>9+</sup> | bundle.ExtensionAbilityType | Yes | No | Type of the extension ability. | | extensionAbilityType<sup>9+</sup> | bundle.ExtensionAbilityType | Yes | No | Type of the Extension ability. |
| permissions<sup>9+</sup> | Array\<string> | Yes | No | Permissions required for other applications to call the extension ability.| | permissions<sup>9+</sup> | Array\<string> | Yes | No | Permissions required for other applications to call the Extension ability.|
| applicationInfo<sup>9+</sup> | ApplicationInfo | Yes | No | Application configuration information. | | applicationInfo<sup>9+</sup> | ApplicationInfo | Yes | No | Application configuration information. |
| metaData<sup>9+</sup> | Array\<Metadata> | Yes| No| Metadata of the extension ability.| | metaData<sup>9+</sup> | Array\<Metadata> | Yes | No | Metadata of the Extension ability. |
| enabled<sup>9+</sup> | boolean | Yes| No| Whether the extension ability is enabled.| | enabled<sup>9+</sup> | boolean | Yes | No | Whether the Extension ability is enabled. |
| readPermission<sup>9+</sup> | string | Yes | No | Permission required for reading the extension ability data. | | readPermission<sup>9+</sup> | string | Yes | No | Permission required for reading the Extension ability data. |
| writePermission<sup>9+</sup> | string | Yes | No | Permission required for writing data to the extension ability. | | writePermission<sup>9+</sup> | string | Yes | No | Permission required for writing data to the Extension ability. |
## Metadata<sup>9+</sup> ## Metadata<sup>9+</sup>
...@@ -1726,8 +1639,8 @@ Describes the metadata information. ...@@ -1726,8 +1639,8 @@ Describes the metadata information.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description | | Name | Type | Readable | Writable | Description |
| ----- | ------ | ---- | ---- | ---------------- | | --------------------- | ------ | ---- | ---- | ----- |
| name<sup>9+</sup> | string | Yes | Yes | Metadata name.| | name<sup>9+</sup> | string | Yes | Yes | Metadata name.|
| value<sup>9+</sup> | string | Yes | Yes | Metadata value. | | value<sup>9+</sup> | string | Yes | Yes | Metadata value. |
| resource<sup>9+</sup> | string | Yes | Yes | Metadata resource. | | resource<sup>9+</sup> | string | Yes | Yes | Metadata resource.|
# Want
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**Want** is the basic communication component of the system.
## Modules to Import
```
import Want from '@ohos.application.Want';
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId | Read only | string | No | ID of the device running the ability. |
| bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| abilityName | Read only | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. |
| flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags).|
| action | Read only | string | No | Action option. |
| parameters | Read only | {[key: string]: any} | No | List of parameters in the **Want** object. |
| entities | Read only | Array\<string> | No | List of entities. | |
# appManager # appManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements application management. Implements application management.
...@@ -77,18 +77,16 @@ Checks whether this application is running in a RAM constrained device. This API ...@@ -77,18 +77,16 @@ Checks whether this application is running in a RAM constrained device. This API
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the the application is running in a RAM constrained device. If the the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| | Promise&lt;boolean&gt; | Promise used to return whether the application is running in a RAM constrained device. If the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
```js ```js
IsRamConstrainedDevicePromise(){
app.isRamConstrainedDevicePromise().then((data) => { app.isRamConstrainedDevicePromise().then((data) => {
console.log('success:' + JSON.stringify(data)); console.log('success:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('failed:' + JSON.stringify(error)); console.log('failed:' + JSON.stringify(error));
}); });
}
``` ```
## appManager.isRamConstrainedDevice ## appManager.isRamConstrainedDevice
...@@ -103,17 +101,15 @@ Checks whether this application is running in a RAM constrained device. This API ...@@ -103,17 +101,15 @@ Checks whether this application is running in a RAM constrained device. This API
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the the application is running in a RAM constrained device. If the the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| | callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running in a RAM constrained device. If the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
```js ```js
IsRamConstrainedDeviceCallBack(){
app.isRamConstrainedDevicePromise((err, data) => { app.isRamConstrainedDevicePromise((err, data) => {
console.log('startAbility result failed:' + JSON.stringify(err)); console.log('startAbility result failed:' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data)); console.log('startAbility result success:' + JSON.stringify(data));
}) })
}
``` ```
## appManager.getAppMemorySize ## appManager.getAppMemorySize
...@@ -133,13 +129,11 @@ Obtains the memory size of this application. This API uses a promise to return t ...@@ -133,13 +129,11 @@ Obtains the memory size of this application. This API uses a promise to return t
**Example** **Example**
```js ```js
GetAppMemorySize(){
app.getAppMemorySize().then((data) => { app.getAppMemorySize().then((data) => {
console.log('success:' + JSON.stringify(data)); console.log('success:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('failed:' + JSON.stringify(error)); console.log('failed:' + JSON.stringify(error));
}); });
}
``` ```
## appManager.getAppMemorySize ## appManager.getAppMemorySize
...@@ -159,10 +153,65 @@ Obtains the memory size of this application. This API uses an asynchronous callb ...@@ -159,10 +153,65 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Example** **Example**
```js ```js
GetAppMemorySizeCallBack(){
app.getAppMemorySize((err, data) => { app.getAppMemorySize((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err)); console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data)); console.log('startAbility result success:' + JSON.stringify(data));
}) })
}
``` ```
## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(): Promise<Array<ProcessRunningInfo>>;
Obtains information about the running processes. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<Array\<ProcessRunningInfo>> | Promise used to return the process information.|
**Example**
```js
app.GetProcessRunningInfos().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
```
## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(callback: AsyncCallback<Array<ProcessRunningInfo>>): void;
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<Array\<ProcessRunningInfo>> | No| Callback used to return the process information.|
**Example**
```js
app.GetProcessRunningInfos((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
```
## ProcessRunningInfo
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| pid<sup>8+</sup> | Read only | number | No | Process ID. |
| uid<sup>8+</sup> | Read only | number | No | User ID.|
| processName<sup>8+</sup> | Read only | string | No | Process name.|
| bundleNames<sup>8+</sup> | Read only | Array\<string> | No | **bundleName** array in the running process.|
...@@ -56,6 +56,7 @@ Obtains the remaining duration before the application is suspended. This API use ...@@ -56,6 +56,7 @@ Obtains the remaining duration before the application is suspended. This API use
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the remaining duration before the application is suspended, in milliseconds.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the remaining duration before the application is suspended, in milliseconds.|
**Example** **Example**
```js ```js
let id = 1; let id = 1;
backgroundTaskManager.getRemainingDelayTime(id, (err, res) => { backgroundTaskManager.getRemainingDelayTime(id, (err, res) => {
...@@ -127,12 +128,12 @@ Requests a continuous task from the system. This API uses an asynchronous callba ...@@ -127,12 +128,12 @@ Requests a continuous task from the system. This API uses an asynchronous callba
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Application context.| | context | [Context](js-apis-Context.md) | Yes| Application context.|
| bgMode | [BackgroundMode](#backgroundmode8) | Yes| Background mode requested.| | bgMode | [BackgroundMode](#backgroundmode8) | Yes| Background mode requested.|
| wantAgent | [WantAgent](js-apis-notification.md#WantAgent)| Yes| Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked.| | wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes| Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```js ```js
...@@ -179,11 +180,11 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -179,11 +180,11 @@ Requests a continuous task from the system. This API uses a promise to return th
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Application context.| | context | [Context](js-apis-Context.md) | Yes| Application context.|
| bgMode | [BackgroundMode](#backgroundmode8) | Yes| Background mode requested.| | bgMode | [BackgroundMode](#backgroundmode8) | Yes| Background mode requested.|
| wantAgent | [WantAgent](js-apis-notification.md#WantAgent)| Yes| Notification parameter, which is used to specify the target page when a continuous task notification is clicked.| | wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes| Notification parameter, which is used to specify the target page when a continuous task notification is clicked.|
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -225,8 +226,6 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback&lt;void&gt;): vo ...@@ -225,8 +226,6 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback&lt;void&gt;): vo
Requests to cancel a continuous task. This API uses an asynchronous callback to return the result. Requests to cancel a continuous task. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
**Parameters** **Parameters**
...@@ -258,8 +257,6 @@ stopBackgroundRunning(context: Context): Promise&lt;void&gt; ...@@ -258,8 +257,6 @@ stopBackgroundRunning(context: Context): Promise&lt;void&gt;
Requests to cancel a continuous task. This API uses a promise to return the result. Requests to cancel a continuous task. This API uses a promise to return the result.
**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
**Parameters** **Parameters**
......
# CommonEvent # CommonEvent
> **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
...@@ -9,62 +9,63 @@ ...@@ -9,62 +9,63 @@
| ------------ | ------------------ | ---------------------- | | ------------ | ------------------ | ---------------------- |
| COMMON_EVENT_BOOT_COMPLETED | usual.event.BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED | | COMMON_EVENT_BOOT_COMPLETED | usual.event.BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED |
| COMMON_EVENT_LOCKED_BOOT_COMPLETED | usual.event.LOCKED_BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED | | COMMON_EVENT_LOCKED_BOOT_COMPLETED | usual.event.LOCKED_BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED |
| COMMON_EVENT_SHUTDOWN | usual.event.SHUTDOWN | N/A | | COMMON_EVENT_SHUTDOWN | usual.event.SHUTDOWN | - |
| COMMON_EVENT_BATTERY_CHANGED | usual.event.BATTERY_CHANGED | N/A | | COMMON_EVENT_BATTERY_CHANGED | usual.event.BATTERY_CHANGED | - |
| COMMON_EVENT_BATTERY_LOW | usual.event.BATTERY_LOW | N/A | | COMMON_EVENT_BATTERY_LOW | usual.event.BATTERY_LOW | - |
| COMMON_EVENT_BATTERY_OKAY | usual.event.BATTERY_OKAY | N/A | | COMMON_EVENT_BATTERY_OKAY | usual.event.BATTERY_OKAY | - |
| COMMON_EVENT_POWER_CONNECTED | usual.event.POWER_CONNECTED | N/A | | COMMON_EVENT_POWER_CONNECTED | usual.event.POWER_CONNECTED | - |
| COMMON_EVENT_POWER_DISCONNECTED | usual.event.POWER_DISCONNECTED | N/A | | COMMON_EVENT_POWER_DISCONNECTED | usual.event.POWER_DISCONNECTED | - |
| COMMON_EVENT_SCREEN_OFF | usual.event.SCREEN_OFF | N/A | | COMMON_EVENT_SCREEN_OFF | usual.event.SCREEN_OFF | - |
| COMMON_EVENT_SCREEN_ON | usual.event.SCREEN_ON | N/A | | COMMON_EVENT_SCREEN_ON | usual.event.SCREEN_ON | - |
| COMMON_EVENT_THERMAL_LEVEL_CHANGED | usual.event.THERMAL_LEVEL_CHANGED | N/A | | COMMON_EVENT_THERMAL_LEVEL_CHANGED | usual.event.THERMAL_LEVEL_CHANGED | - |
| COMMON_EVENT_USER_PRESENT | usual.event.USER_PRESENT | N/A | | COMMON_EVENT_USER_PRESENT | usual.event.USER_PRESENT | - |
| COMMON_EVENT_TIME_TICK | usual.event.TIME_TICK | N/A | | COMMON_EVENT_TIME_TICK | usual.event.TIME_TICK | - |
| COMMON_EVENT_TIME_CHANGED | usual.event.TIME_CHANGED | N/A | | COMMON_EVENT_TIME_CHANGED | usual.event.TIME_CHANGED | - |
| COMMON_EVENT_DATE_CHANGED | usual.event.DATE_CHANGED | N/A | | COMMON_EVENT_DATE_CHANGED | usual.event.DATE_CHANGED | - |
| COMMON_EVENT_TIMEZONE_CHANGED | usual.event.TIMEZONE_CHANGED | N/A | | COMMON_EVENT_TIMEZONE_CHANGED | usual.event.TIMEZONE_CHANGED | - |
| COMMON_EVENT_CLOSE_SYSTEM_DIALOGS | usual.event.CLOSE_SYSTEM_DIALOGS | N/A | | COMMON_EVENT_CLOSE_SYSTEM_DIALOGS | usual.event.CLOSE_SYSTEM_DIALOGS | - |
| COMMON_EVENT_PACKAGE_ADDED | usual.event.PACKAGE_ADDED | N/A | | COMMON_EVENT_PACKAGE_ADDED | usual.event.PACKAGE_ADDED | - |
| COMMON_EVENT_PACKAGE_REPLACED | usual.event.PACKAGE_REPLACED | N/A | | COMMON_EVENT_PACKAGE_REPLACED | usual.event.PACKAGE_REPLACED | - |
| COMMON_EVENT_MY_PACKAGE_REPLACED | usual.event.MY_PACKAGE_REPLACED | N/A | | COMMON_EVENT_MY_PACKAGE_REPLACED | usual.event.MY_PACKAGE_REPLACED | - |
| COMMON_EVENT_PACKAGE_REMOVED | usual.event.PACKAGE_REMOVED | N/A | | COMMON_EVENT_PACKAGE_REMOVED | usual.event.PACKAGE_REMOVED | - |
| COMMON_EVENT_PACKAGE_FULLY_REMOVED | usual.event.PACKAGE_FULLY_REMOVED | N/A | | COMMON_EVENT_BUNDLE_REMOVED | usual.event.BUNDLE_REMOVED | - |
| COMMON_EVENT_PACKAGE_CHANGED | usual.event.PACKAGE_CHANGED | N/A | | COMMON_EVENT_PACKAGE_FULLY_REMOVED | usual.event.PACKAGE_FULLY_REMOVED | - |
| COMMON_EVENT_PACKAGE_RESTARTED | usual.event.PACKAGE_RESTARTED | N/A | | COMMON_EVENT_PACKAGE_CHANGED | usual.event.PACKAGE_CHANGED | - |
| COMMON_EVENT_PACKAGE_DATA_CLEARED | usual.event.PACKAGE_DATA_CLEARED | N/A | | COMMON_EVENT_PACKAGE_RESTARTED | usual.event.PACKAGE_RESTARTED | - |
| COMMON_EVENT_PACKAGES_SUSPENDED | usual.event.PACKAGES_SUSPENDED | N/A | | COMMON_EVENT_PACKAGE_DATA_CLEARED | usual.event.PACKAGE_DATA_CLEARED | - |
| COMMON_EVENT_PACKAGES_UNSUSPENDED | usual.event.PACKAGES_UNSUSPENDED | N/A | | COMMON_EVENT_PACKAGES_SUSPENDED | usual.event.PACKAGES_SUSPENDED | - |
| COMMON_EVENT_MY_PACKAGE_SUSPENDED | usual.event.MY_PACKAGE_SUSPENDED | N/A | | COMMON_EVENT_PACKAGES_UNSUSPENDED | usual.event.PACKAGES_UNSUSPENDED | - |
| COMMON_EVENT_MY_PACKAGE_UNSUSPENDED | usual.event.MY_PACKAGE_UNSUSPENDED | N/A | | COMMON_EVENT_MY_PACKAGE_SUSPENDED | usual.event.MY_PACKAGE_SUSPENDED | - |
| COMMON_EVENT_UID_REMOVED | usual.event.UID_REMOVED | N/A | | COMMON_EVENT_MY_PACKAGE_UNSUSPENDED | usual.event.MY_PACKAGE_UNSUSPENDED | - |
| COMMON_EVENT_PACKAGE_FIRST_LAUNCH | usual.event.PACKAGE_FIRST_LAUNCH | N/A | | COMMON_EVENT_UID_REMOVED | usual.event.UID_REMOVED | - |
| COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION | usual.event.PACKAGE_NEEDS_VERIFICATION | N/A | | COMMON_EVENT_PACKAGE_FIRST_LAUNCH | usual.event.PACKAGE_FIRST_LAUNCH | - |
| COMMON_EVENT_PACKAGE_VERIFIED | usual.event.PACKAGE_VERIFIED | N/A | | COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION | usual.event.PACKAGE_NEEDS_VERIFICATION | - |
| COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE | usual.event.EXTERNAL_APPLICATIONS_AVAILABLE | N/A | | COMMON_EVENT_PACKAGE_VERIFIED | usual.event.PACKAGE_VERIFIED | - |
| COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE | usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE | N/A | | COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE | usual.event.EXTERNAL_APPLICATIONS_AVAILABLE | - |
| COMMON_EVENT_CONFIGURATION_CHANGED | usual.event.CONFIGURATION_CHANGED | N/A | | COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE | usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE | - |
| COMMON_EVENT_LOCALE_CHANGED | usual.event.LOCALE_CHANGED | N/A | | COMMON_EVENT_CONFIGURATION_CHANGED | usual.event.CONFIGURATION_CHANGED | - |
| COMMON_EVENT_MANAGE_PACKAGE_STORAGE | usual.event.MANAGE_PACKAGE_STORAGE | N/A | | COMMON_EVENT_LOCALE_CHANGED | usual.event.LOCALE_CHANGED | - |
| COMMON_EVENT_DRIVE_MODE | common.event.DRIVE_MODE | N/A | | COMMON_EVENT_MANAGE_PACKAGE_STORAGE | usual.event.MANAGE_PACKAGE_STORAGE | - |
| COMMON_EVENT_HOME_MODE | common.event.HOME_MODE | N/A | | COMMON_EVENT_DRIVE_MODE | common.event.DRIVE_MODE | - |
| COMMON_EVENT_OFFICE_MODE | common.event.OFFICE_MODE | N/A | | COMMON_EVENT_HOME_MODE | common.event.HOME_MODE | - |
| COMMON_EVENT_USER_STARTED | usual.event.USER_STARTED | N/A | | COMMON_EVENT_OFFICE_MODE | common.event.OFFICE_MODE | - |
| COMMON_EVENT_USER_BACKGROUND | usual.event.USER_BACKGROUND | N/A | | COMMON_EVENT_USER_STARTED | usual.event.USER_STARTED | - |
| COMMON_EVENT_USER_FOREGROUND | usual.event.USER_FOREGROUND | N/A | | COMMON_EVENT_USER_BACKGROUND | usual.event.USER_BACKGROUND | - |
| COMMON_EVENT_USER_FOREGROUND | usual.event.USER_FOREGROUND | - |
| COMMON_EVENT_USER_SWITCHED | usual.event.USER_SWITCHED | ohos.permission.MANAGE_USERS | | COMMON_EVENT_USER_SWITCHED | usual.event.USER_SWITCHED | ohos.permission.MANAGE_USERS |
| COMMON_EVENT_USER_STARTING | usual.event.USER_STARTING | ohos.permission.INTERACT_ACROSS_USERS | | COMMON_EVENT_USER_STARTING | usual.event.USER_STARTING | ohos.permission.INTERACT_ACROSS_USERS |
| COMMON_EVENT_USER_UNLOCKED | usual.event.USER_UNLOCKED | N/A | | COMMON_EVENT_USER_UNLOCKED | usual.event.USER_UNLOCKED | - |
| COMMON_EVENT_USER_STOPPING | usual.event.USER_STOPPING | ohos.permission.INTERACT_ACROSS_USERS | | COMMON_EVENT_USER_STOPPING | usual.event.USER_STOPPING | ohos.permission.INTERACT_ACROSS_USERS |
| COMMON_EVENT_USER_STOPPED | usual.event.USER_STOPPED | N/A | | COMMON_EVENT_USER_STOPPED | usual.event.USER_STOPPED | - |
| COMMON_EVENT_HWID_LOGIN | common.event.HWID_LOGIN | N/A | | COMMON_EVENT_HWID_LOGIN | common.event.HWID_LOGIN | - |
| COMMON_EVENT_HWID_LOGOUT | common.event.HWID_LOGOUT | N/A | | COMMON_EVENT_HWID_LOGOUT | common.event.HWID_LOGOUT | - |
| COMMON_EVENT_HWID_TOKEN_INVALID | common.event.HWID_TOKEN_INVALID | N/A | | COMMON_EVENT_HWID_TOKEN_INVALID | common.event.HWID_TOKEN_INVALID | - |
| COMMON_EVENT_HWID_LOGOFF | common.event.HWID_LOGOFF | N/A | | COMMON_EVENT_HWID_LOGOFF | common.event.HWID_LOGOFF | - |
| COMMON_EVENT_WIFI_POWER_STATE | usual.event.wifi.POWER_STATE | N/A | | COMMON_EVENT_WIFI_POWER_STATE | usual.event.wifi.POWER_STATE | - |
| COMMON_EVENT_WIFI_SCAN_FINISHED | usual.event.wifi.SCAN_FINISHED | ohos.permission.LOCATION | | COMMON_EVENT_WIFI_SCAN_FINISHED | usual.event.wifi.SCAN_FINISHED | ohos.permission.LOCATION |
| COMMON_EVENT_WIFI_RSSI_VALUE | usual.event.wifi.RSSI_VALUE | ohos.permission.GET_WIFI_INFO | | COMMON_EVENT_WIFI_RSSI_VALUE | usual.event.wifi.RSSI_VALUE | ohos.permission.GET_WIFI_INFO |
| COMMON_EVENT_WIFI_CONN_STATE | usual.event.wifi.CONN_STATE | N/A | | COMMON_EVENT_WIFI_CONN_STATE | usual.event.wifi.CONN_STATE | - |
| COMMON_EVENT_WIFI_HOTSPOT_STATE | usual.event.wifi.HOTSPOT_STATE | N/A | | COMMON_EVENT_WIFI_HOTSPOT_STATE | usual.event.wifi.HOTSPOT_STATE | - |
| COMMON_EVENT_WIFI_AP_STA_JOIN | usual.event.wifi.WIFI_HS_STA_JOIN | ohos.permission.GET_WIFI_INFO | | COMMON_EVENT_WIFI_AP_STA_JOIN | usual.event.wifi.WIFI_HS_STA_JOIN | ohos.permission.GET_WIFI_INFO |
| COMMON_EVENT_WIFI_AP_STA_LEAVE | usual.event.wifi.WIFI_HS_STA_LEAVE | ohos.permission.GET_WIFI_INFO | | COMMON_EVENT_WIFI_AP_STA_LEAVE | usual.event.wifi.WIFI_HS_STA_LEAVE | ohos.permission.GET_WIFI_INFO |
| COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE | usual.event.wifi.mplink.STATE_CHANGE | ohos.permission.MPLINK_CHANGE_STATE | | COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE | usual.event.wifi.mplink.STATE_CHANGE | ohos.permission.MPLINK_CHANGE_STATE |
...@@ -82,26 +83,26 @@ ...@@ -82,26 +83,26 @@
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_PLAYING_STATE_UPDATE | usual.event.bluetooth.a2dpsource.PLAYING_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_A2DPSOURCE_PLAYING_STATE_UPDATE | usual.event.bluetooth.a2dpsource.PLAYING_STATE_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CODEC_VALUE_UPDATE | usual.event.bluetooth.a2dpsource.CODEC_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CODEC_VALUE_UPDATE | usual.event.bluetooth.a2dpsource.CODEC_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_DISCOVERED | usual.event.bluetooth.remotedevice.DISCOVERED | ohos.permission.LOCATION | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_DISCOVERED | usual.event.bluetooth.remotedevice.DISCOVERED | ohos.permission.LOCATION and ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CLASS_VALUE_UPDATE | usual.event.bluetooth.remotedevice.CLASS_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CLASS_VALUE_UPDATE | usual.event.bluetooth.remotedevice.CLASS_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_CONNECTED | usual.event.bluetooth.remotedevice.ACL_CONNECTED | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_CONNECTED | usual.event.bluetooth.remotedevice.ACL_CONNECTED | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_DISCONNECTED | usual.event.bluetooth.remotedevice.ACL_DISCONNECTED | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_DISCONNECTED | usual.event.bluetooth.remotedevice.ACL_DISCONNECTED | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE | usual.event.bluetooth.remotedevice.NAME_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE | usual.event.bluetooth.remotedevice.NAME_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIR_STATE | usual.event.bluetooth.remotedevice.PAIR_STATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIR_STATE | usual.event.bluetooth.remotedevice.PAIR_STATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_BATTERY_VALUE_UPDATE | usual.event.bluetooth.remotedevice.BATTERY_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_BATTERY_VALUE_UPDATE | usual.event.bluetooth.remotedevice.BATTERY_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT | usual.event.bluetooth.remotedevice.SDP_RESULT | N/A | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT | usual.event.bluetooth.remotedevice.SDP_RESULT | - |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_UUID_VALUE | usual.event.bluetooth.remotedevice.UUID_VALUE | ohos.permission.DISCOVER_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_UUID_VALUE | usual.event.bluetooth.remotedevice.UUID_VALUE | ohos.permission.DISCOVER_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_REQ | usual.event.bluetooth.remotedevice.PAIRING_REQ | ohos.permission.DISCOVER_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_REQ | usual.event.bluetooth.remotedevice.PAIRING_REQ | ohos.permission.DISCOVER_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL | usual.event.bluetooth.remotedevice.PAIRING_CANCEL | N/A | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL | usual.event.bluetooth.remotedevice.PAIRING_CANCEL | - |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ | usual.event.bluetooth.remotedevice.CONNECT_REQ | N/A | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ | usual.event.bluetooth.remotedevice.CONNECT_REQ | - |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY | usual.event.bluetooth.remotedevice.CONNECT_REPLY | N/A | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY | usual.event.bluetooth.remotedevice.CONNECT_REPLY | - |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL | usual.event.bluetooth.remotedevice.CONNECT_CANCEL | N/A | | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL | usual.event.bluetooth.remotedevice.CONNECT_CANCEL | - |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE | N/A | | COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE | - |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE | N/A | | COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE | - |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT | usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT | N/A | | COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT | usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT | - |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE | N/A | | COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE | - |
| COMMON_EVENT_BLUETOOTH_HOST_STATE_UPDATE | usual.event.bluetooth.host.STATE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_HOST_STATE_UPDATE | usual.event.bluetooth.host.STATE_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE | usual.event.bluetooth.host.REQ_DISCOVERABLE | N/A | | COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE | usual.event.bluetooth.host.REQ_DISCOVERABLE | - |
| COMMON_EVENT_BLUETOOTH_HOST_REQ_ENABLE | usual.event.bluetooth.host.REQ_ENABLE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_HOST_REQ_ENABLE | usual.event.bluetooth.host.REQ_ENABLE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_HOST_REQ_DISABLE | usual.event.bluetooth.host.REQ_DISABLE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_HOST_REQ_DISABLE | usual.event.bluetooth.host.REQ_DISABLE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_HOST_SCAN_MODE_UPDATE | usual.event.bluetooth.host.SCAN_MODE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_HOST_SCAN_MODE_UPDATE | usual.event.bluetooth.host.SCAN_MODE_UPDATE | ohos.permission.USE_BLUETOOTH |
...@@ -111,34 +112,34 @@ ...@@ -111,34 +112,34 @@
| COMMON_EVENT_BLUETOOTH_A2DPSINK_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsink.CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_A2DPSINK_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsink.CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_A2DPSINK_PLAYING_STATE_UPDATE | usual.event.bluetooth.a2dpsink.PLAYING_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_A2DPSINK_PLAYING_STATE_UPDATE | usual.event.bluetooth.a2dpsink.PLAYING_STATE_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_A2DPSINK_AUDIO_STATE_UPDATE | usual.event.bluetooth.a2dpsink.AUDIO_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_A2DPSINK_AUDIO_STATE_UPDATE | usual.event.bluetooth.a2dpsink.AUDIO_STATE_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED | usual.event.nfc.action.ADAPTER_STATE_CHANGED | N/A | | COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED | usual.event.nfc.action.ADAPTER_STATE_CHANGED | - |
| COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED | usual.event.nfc.action.RF_FIELD_ON_DETECTED | ohos.permission.MANAGE_SECURE_SETTINGS | | COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED | usual.event.nfc.action.RF_FIELD_ON_DETECTED | ohos.permission.MANAGE_SECURE_SETTINGS |
| COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED | usual.event.nfc.action.RF_FIELD_OFF_DETECTED | ohos.permission.MANAGE_SECURE_SETTINGS | | COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED | usual.event.nfc.action.RF_FIELD_OFF_DETECTED | ohos.permission.MANAGE_SECURE_SETTINGS |
| COMMON_EVENT_DISCHARGING | usual.event.DISCHARGING | N/A | | COMMON_EVENT_DISCHARGING | usual.event.DISCHARGING | - |
| COMMON_EVENT_CHARGING | usual.event.CHARGING | N/A | | COMMON_EVENT_CHARGING | usual.event.CHARGING | - |
| COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED | usual.event.DEVICE_IDLE_MODE_CHANGED | N/A | | COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED | usual.event.DEVICE_IDLE_MODE_CHANGED | - |
| COMMON_EVENT_POWER_SAVE_MODE_CHANGED | usual.event.POWER_SAVE_MODE_CHANGED | N/A | | COMMON_EVENT_POWER_SAVE_MODE_CHANGED | usual.event.POWER_SAVE_MODE_CHANGED | - |
| COMMON_EVENT_USER_ADDED | usual.event.USER_ADDED | ohos.permission.MANAGE_USERS | | COMMON_EVENT_USER_ADDED | usual.event.USER_ADDED | ohos.permission.MANAGE_USERS |
| COMMON_EVENT_USER_REMOVED | usual.event.USER_REMOVED | ohos.permission.MANAGE_USERS | | COMMON_EVENT_USER_REMOVED | usual.event.USER_REMOVED | ohos.permission.MANAGE_USERS |
| COMMON_EVENT_ABILITY_ADDED | usual.event.ABILITY_ADDED | ohos.permission.LISTEN_BUNDLE_CHANGE | | COMMON_EVENT_ABILITY_ADDED | usual.event.ABILITY_ADDED | ohos.permission.LISTEN_BUNDLE_CHANGE |
| COMMON_EVENT_ABILITY_REMOVED | usual.event.ABILITY_REMOVED | ohos.permission.LISTEN_BUNDLE_CHANGE | | COMMON_EVENT_ABILITY_REMOVED | usual.event.ABILITY_REMOVED | ohos.permission.LISTEN_BUNDLE_CHANGE |
| COMMON_EVENT_ABILITY_UPDATED | usual.event.ABILITY_UPDATED | ohos.permission.LISTEN_BUNDLE_CHANGE | | COMMON_EVENT_ABILITY_UPDATED | usual.event.ABILITY_UPDATED | ohos.permission.LISTEN_BUNDLE_CHANGE |
| COMMON_EVENT_LOCATION_MODE_STATE_CHANGED | usual.event.location.MODE_STATE_CHANGED | N/A | | COMMON_EVENT_LOCATION_MODE_STATE_CHANGED | usual.event.location.MODE_STATE_CHANGED | - |
| COMMON_EVENT_IVI_SLEEP | common.event.IVI_SLEEP | N/A | | COMMON_EVENT_IVI_SLEEP | common.event.IVI_SLEEP | - |
| COMMON_EVENT_IVI_PAUSE | common.event.IVI_PAUSE | N/A | | COMMON_EVENT_IVI_PAUSE | common.event.IVI_PAUSE | - |
| COMMON_EVENT_IVI_STANDBY | common.event.IVI_STANDBY | N/A | | COMMON_EVENT_IVI_STANDBY | common.event.IVI_STANDBY | - |
| COMMON_EVENT_IVI_LASTMODE_SAVE | common.event.IVI_LASTMODE_SAVE | N/A | | COMMON_EVENT_IVI_LASTMODE_SAVE | common.event.IVI_LASTMODE_SAVE | - |
| COMMON_EVENT_IVI_VOLTAGE_ABNORMAL | common.event.IVI_VOLTAGE_ABNORMAL | N/A | | COMMON_EVENT_IVI_VOLTAGE_ABNORMAL | common.event.IVI_VOLTAGE_ABNORMAL | - |
| COMMON_EVENT_IVI_HIGH_TEMPERATURE | common.event.IVI_HIGH_TEMPERATURE | N/A | | COMMON_EVENT_IVI_HIGH_TEMPERATURE | common.event.IVI_HIGH_TEMPERATURE | - |
| COMMON_EVENT_IVI_EXTREME_TEMPERATURE | common.event.IVI_EXTREME_TEMPERATURE | N/A | | COMMON_EVENT_IVI_EXTREME_TEMPERATURE | common.event.IVI_EXTREME_TEMPERATURE | - |
| COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL | common.event.IVI_TEMPERATURE_ABNORMAL | N/A | | COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL | common.event.IVI_TEMPERATURE_ABNORMAL | - |
| COMMON_EVENT_IVI_VOLTAGE_RECOVERY | common.event.IVI_VOLTAGE_RECOVERY | N/A | | COMMON_EVENT_IVI_VOLTAGE_RECOVERY | common.event.IVI_VOLTAGE_RECOVERY | - |
| COMMON_EVENT_IVI_TEMPERATURE_RECOVERY | common.event.IVI_TEMPERATURE_RECOVERY | N/A | | COMMON_EVENT_IVI_TEMPERATURE_RECOVERY | common.event.IVI_TEMPERATURE_RECOVERY | - |
| COMMON_EVENT_IVI_ACTIVE | common.event.IVI_ACTIVE | N/A | | COMMON_EVENT_IVI_ACTIVE | common.event.IVI_ACTIVE | - |
| COMMON_EVENT_USB_DEVICE_ATTACHED | usual.event.hardware.usb.action.USB_DEVICE_ATTACHED | N/A | | COMMON_EVENT_USB_DEVICE_ATTACHED | usual.event.hardware.usb.action.USB_DEVICE_ATTACHED | - |
| COMMON_EVENT_USB_DEVICE_DETACHED | usual.event.hardware.usb.action.USB_DEVICE_DETACHED | N/A | | COMMON_EVENT_USB_DEVICE_DETACHED | usual.event.hardware.usb.action.USB_DEVICE_DETACHED | - |
| COMMON_EVENT_USB_ACCESSORY_ATTACHED | usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED | N/A | | COMMON_EVENT_USB_ACCESSORY_ATTACHED | usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED | - |
| COMMON_EVENT_USB_ACCESSORY_DETACHED | usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED | N/A | | COMMON_EVENT_USB_ACCESSORY_DETACHED | usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED | - |
| COMMON_EVENT_DISK_REMOVED | usual.event.data.DISK_REMOVED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE| | COMMON_EVENT_DISK_REMOVED | usual.event.data.DISK_REMOVED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_DISK_UNMOUNTED | usual.event.data.DISK_UNMOUNTED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE| | COMMON_EVENT_DISK_UNMOUNTED | usual.event.data.DISK_UNMOUNTED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_DISK_MOUNTED | usual.event.data.DISK_MOUNTED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE| | COMMON_EVENT_DISK_MOUNTED | usual.event.data.DISK_MOUNTED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
...@@ -153,7 +154,7 @@ ...@@ -153,7 +154,7 @@
| COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED | usual.event.data.VISIBLE_ACCOUNTS_UPDATED | ohos.permission.GET_APP_ACCOUNTS | | COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED | usual.event.data.VISIBLE_ACCOUNTS_UPDATED | ohos.permission.GET_APP_ACCOUNTS |
| COMMON_EVENT_ACCOUNT_DELETED | usual.event.data.ACCOUNT_DELETED | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | | COMMON_EVENT_ACCOUNT_DELETED | usual.event.data.ACCOUNT_DELETED | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS |
| COMMON_EVENT_FOUNDATION_READY | usual.event.data.FOUNDATION_READY | ohos.permission.RECEIVER_STARTUP_COMPLETED | | COMMON_EVENT_FOUNDATION_READY | usual.event.data.FOUNDATION_READY | ohos.permission.RECEIVER_STARTUP_COMPLETED |
| COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | N/A | | COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | - |
| COMMON_EVENT_SPLIT_SCREEN | usual.event.SPLIT_SCREEN | ohos.permission.RECEIVER_SPLIT_SCREEN | | COMMON_EVENT_SPLIT_SCREEN | usual.event.SPLIT_SCREEN | ohos.permission.RECEIVER_SPLIT_SCREEN |
## Modules to Import ## Modules to Import
...@@ -174,8 +175,8 @@ Publishes a common event. This API uses a callback to return the result. ...@@ -174,8 +175,8 @@ Publishes a common event. This API uses a callback to return the result.
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory| Description |
| -------- | -------- | -------------------- | ---- | ---------------------- | | -------- | -------- | -------------------- | ---- | ---------------------- |
| event | Read-only | string | Yes | Name of the common event to publish.| | event | Read only | string | Yes | Name of the common event to publish.|
| callback | Read-only | AsyncCallback\<void> | Yes | Callback used to return the result.| | callback | Read only | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -207,9 +208,9 @@ Publishes a common event with given attributes. This API uses a callback to retu ...@@ -207,9 +208,9 @@ Publishes a common event with given attributes. This API uses a callback to retu
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory| Description |
| -------- | -------- | ---------------------- | ---- | ---------------------- | | -------- | -------- | ---------------------- | ---- | ---------------------- |
| event | Read-only | string | Yes | Name of the common event to publish. | | event | Read only | string | Yes | Name of the common event to publish. |
| options | Read-only | [CommonEventPublishData](#commoneventpublishdata) | Yes | Attributes of the common event to publish.| | options | Read only | [CommonEventPublishData](#commoneventpublishdata) | Yes | Attributes of the common event to publish.|
| callback | Read-only | AsyncCallback\<void> | Yes | Callback used to return the result. | | callback | Read only | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -249,9 +250,9 @@ Publishes a common event to a specific user. This API uses a callback to return ...@@ -249,9 +250,9 @@ Publishes a common event to a specific user. This API uses a callback to return
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory| Description |
| -------- | -------- | -------------------- | ---- | ---------------------------------- | | -------- | -------- | -------------------- | ---- | ---------------------------------- |
| event | Read-only | string | Yes | Name of the common event to publish. | | event | Read only | string | Yes | Name of the common event to publish. |
| userId | Read-only | number | Yes | User ID.| | userId | Read only | number | Yes | User ID.|
| callback | Read-only | AsyncCallback\<void> | Yes | Callback used to return the result. | | callback | Read only | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -286,10 +287,10 @@ Publishes a common event with given attributes to a specific user. This API uses ...@@ -286,10 +287,10 @@ Publishes a common event with given attributes to a specific user. This API uses
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory| Description |
| -------- | -------- | ---------------------- | ---- | ---------------------- | | -------- | -------- | ---------------------- | ---- | ---------------------- |
| event | Read-only | string | Yes | Name of the common event to publish. | | event | Read only | string | Yes | Name of the common event to publish. |
| userId | Read-only| number | Yes| User ID.| | userId | Read only| number | Yes| User ID.|
| options | Read-only | [CommonEventPublishData](#commoneventpublishdata) | Yes | Attributes of the common event to publish.| | options | Read only | [CommonEventPublishData](#commoneventpublishdata) | Yes | Attributes of the common event to publish.|
| callback | Read-only | AsyncCallback\<void> | Yes | Callback used to return the result. | | callback | Read only | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -331,8 +332,8 @@ Creates a subscriber. This API uses a callback to return the result. ...@@ -331,8 +332,8 @@ Creates a subscriber. This API uses a callback to return the result.
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory| Description |
| ------------- | -------- | ------------------------------------------------------------ | ---- | -------------------------- | | ------------- | -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| subscribeInfo | Read-only | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes | Subscriber information. | | subscribeInfo | Read only | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes | Subscriber information. |
| callback | Read-only | AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | Yes | Callback used to return the result.| | callback | Read only | AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -373,7 +374,7 @@ Creates a subscriber. This API uses a promise to return the result. ...@@ -373,7 +374,7 @@ Creates a subscriber. This API uses a promise to return the result.
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory| Description |
| ------------- | -------- | ----------------------------------------------------- | ---- | -------------- | | ------------- | -------- | ----------------------------------------------------- | ---- | -------------- |
| subscribeInfo | Read-only | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes | Subscriber information.| | subscribeInfo | Read only | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes | Subscriber information.|
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -413,8 +414,8 @@ Subscribes to common events. This API uses a callback to return the result. ...@@ -413,8 +414,8 @@ Subscribes to common events. This API uses a callback to return the result.
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory| Description |
| ---------- | -------- | --------------------------------------------------- | ---- | -------------------------------- | | ---------- | -------- | --------------------------------------------------- | ---- | -------------------------------- |
| subscriber | Read-only | [CommonEventSubscriber](#commoneventsubscriber) | Yes | Subscriber object. | | subscriber | Read only | [CommonEventSubscriber](#commoneventsubscriber) | Yes | Subscriber object. |
| callback | Read-only | AsyncCallback\<[CommonEventData](#commoneventdata)> | Yes | Callback used to return the result.| | callback | Read only | AsyncCallback\<[CommonEventData](#commoneventdata)> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -464,9 +465,9 @@ Unsubscribes from common events. This API uses a callback to return the result. ...@@ -464,9 +465,9 @@ Unsubscribes from common events. This API uses a callback to return the result.
**Parameters** **Parameters**
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory| Description |
| ---------- | -------- | --------------------- | ---- | ------------------------ | | ---------- | -------- | ----------------------------------------------- | ---- | ------------------------ |
| subscriber | Read-only | CommonEventSubscriber | Yes | Subscriber object. | | subscriber | Read only | [CommonEventSubscriber](#commoneventsubscriber) | Yes | Subscriber object. |
| callback | Read-only | AsyncCallback\<void> | Yes | Callback used to return the result.| | callback | Read only | AsyncCallback\<void> | No | Callback used to return the result.|
**Example** **Example**
...@@ -515,43 +516,6 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ...@@ -515,43 +516,6 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack);
``` ```
## CommonEventPublishData
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable/Writable| Type | Mandatory| Description |
| --------------------- | -------- | -------------------- | ---- | ---------------------------- |
| bundleName | Read-only | string | No | Bundle name. |
| code | Read-only | number | No | Result code of the common event. |
| data | Read-only | string | No | Custom result data of the common event.|
| subscriberPermissions | Read-only | Array\<string> | No | Permissions required for subscribers to receive the common event. |
| isOrdered | Read-only | boolean | No | Whether the common event is an ordered one. |
| parameters | Read-only | {[key: string]: any} | No | Additional information about the common event. |
## CommonEventSubscribeInfo
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable/Writable| Type | Mandatory| Description |
| ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ |
| events | Read-only | Array\<string> | Yes | Common events to subscribe to. |
| publisherPermission | Read-only | string | No | Permission required for the publisher. |
| publisherDeviceId | Read-only | string | No | Device ID. The value must be the ID of an existing device on the same network. |
| userId | Read-only | number | No | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | Read-only | number | No | Subscriber priority. The value ranges from -100 to 1000. |
## CommonEventData
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable/Writable| Type | Mandatory| Description |
| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------- |
| event | Read-only | string | Yes | Name of the common event to subscribe to. |
| bundleName | Read-only | string | No | Bundle name. |
| code | Read-only | number | No | Result code of the common event, which is used to transfer data of the int type. |
| data | Read-only | string | No | Custom result data of the common event, which is used to transfer data of the string type.|
| parameters | Read-only | {[key: string]: any} | No | Additional information about the common event. |
## CommonEventSubscriber ## CommonEventSubscriber
### getCode ### getCode
...@@ -574,7 +538,6 @@ Obtains the result code of this common event. This API uses a callback to return ...@@ -574,7 +538,6 @@ Obtains the result code of this common event. This API uses a callback to return
var subscriber; // Subscriber object successfully created. var subscriber; // Subscriber object successfully created.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
getCode() {
function getCodeCallback(err, Code) { function getCodeCallback(err, Code) {
if (err.code) { if (err.code) {
console.error("getCode failed " + JSON.stringify(err)); console.error("getCode failed " + JSON.stringify(err));
...@@ -654,7 +617,13 @@ Sets the result code for this common event. This API uses a promise to return th ...@@ -654,7 +617,13 @@ Sets the result code for this common event. This API uses a promise to return th
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| code | number | Yes | Callback used to return the result code.| | code | number | Yes | Result code of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result code.|
**Example** **Example**
...@@ -680,7 +649,7 @@ Obtains the result data of this common event. This API uses a callback to return ...@@ -680,7 +649,7 @@ Obtains the result data of this common event. This API uses a callback to return
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------- | | -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the result data.| | callback | AsyncCallback\<string> | Yes | Result data of the common event.|
**Example** **Example**
...@@ -710,7 +679,7 @@ Obtains the result data of this common event. This API uses a promise to return ...@@ -710,7 +679,7 @@ Obtains the result data of this common event. This API uses a promise to return
| Type | Description | | Type | Description |
| ---------------- | ------------------ | | ---------------- | ------------------ |
| Promise\<string> | Promise used to return the result data.| | Promise\<string> | Result data of the common event.|
**Example** **Example**
...@@ -767,7 +736,13 @@ Sets the result data for this common event. This API uses a promise to return th ...@@ -767,7 +736,13 @@ Sets the result data for this common event. This API uses a promise to return th
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------- | | ------ | ------ | ---- | -------------------- |
| data | string | Yes | Callback used to return the result data.| | data | string | Yes | Result data of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -826,7 +801,13 @@ Sets the result code and result data for this common event. This API uses a prom ...@@ -826,7 +801,13 @@ Sets the result code and result data for this common event. This API uses a prom
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------- | | ------ | ------ | ---- | -------------------- |
| code | number | Yes | Result code of the common event.| | code | number | Yes | Result code of the common event.|
| data | string | Yes | Callback used to return the result data.| | data | string | Yes | Result data of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -896,6 +877,62 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => { ...@@ -896,6 +877,62 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => {
}); });
``` ```
### isStickyCommonEvent
isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is a sticky one. This API uses a callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Returns **true** if the common event is a sticky one; returns **false** otherwise.|
**Example**
```js
var subscriber; // Subscriber object successfully created.
// Callback for result data setting of an ordered common event
function isStickyCallback(err, isSticky) {
if (err.code) {
console.error("isStickyCommonEvent failed " + JSON.stringify(err));
} else {
console.info("isSticky " + JSON.stringify(isSticky));
}
}
subscriber.isStickyCommonEvent(isStickyCallback);
```
### isStickyCommonEvent
isStickyCommonEvent(): Promise\<boolean>
Checks whether this common event is a sticky one. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ----------------- | -------------------------------- |
| Promise\<boolean> | Returns **true** if the common event is a sticky one; returns **false** otherwise.|
**Example**
```js
var subscriber; // Subscriber object successfully created.
subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky));
}).catch((err) => {
console.error("isSticky failed " + JSON.stringify(err));
});
```
### abortCommonEvent ### abortCommonEvent
abortCommonEvent(callback: AsyncCallback\<void>): void abortCommonEvent(callback: AsyncCallback\<void>): void
...@@ -934,6 +971,12 @@ Aborts this common event. After the abort, the common event is not sent to the n ...@@ -934,6 +971,12 @@ Aborts this common event. After the abort, the common event is not sent to the n
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example** **Example**
```js ```js
...@@ -984,6 +1027,12 @@ Clears the aborted state of this common event. This API takes effect only for or ...@@ -984,6 +1027,12 @@ Clears the aborted state of this common event. This API takes effect only for or
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example** **Example**
```js ```js
...@@ -1028,7 +1077,7 @@ subscriber.getAbortCommonEvent(getAbortCallback); ...@@ -1028,7 +1077,7 @@ subscriber.getAbortCommonEvent(getAbortCallback);
### getAbortCommonEvent ### getAbortCommonEvent
getAbortCommonEvent(): Promise\<void> getAbortCommonEvent(): Promise\<boolean>
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result. Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -1064,7 +1113,7 @@ Obtains the subscriber information. This API uses a callback to return the resul ...@@ -1064,7 +1113,7 @@ Obtains the subscriber information. This API uses a callback to return the resul
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ---------------------- | | -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Yes | Callback used to return the subscriber information.| | callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Yes | Promise used to return the subscriber information.|
**Example** **Example**
...@@ -1107,3 +1156,93 @@ subscriber.getSubscribeInfo().then((SubscribeInfo) => { ...@@ -1107,3 +1156,93 @@ subscriber.getSubscribeInfo().then((SubscribeInfo) => {
console.error("getSubscribeInfo failed " + JSON.stringify(err)); console.error("getSubscribeInfo failed " + JSON.stringify(err));
}); });
``` ```
### finishCommonEvent
finishCommonEvent(callback: AsyncCallback\<void\>): void
Ends the sorted common events. This API uses a callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```js
var subscriber; // Subscriber object successfully created.
function finishCommonEventCallback() {
console.log("--------- finishCommonEventCallback ----------");
}
subscriber.finishCommonEvent(finishCommonEventCallback);
```
### finishCommonEvent
finishCommonEvent(): Promise\<void\>
Ends the sorted common events. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
var subscriber; // Subscriber object successfully created.
subscriber.finishCommonEvent()
.then(() => {
console.info("--------- finishCommonEventCallback ----------");
})
```
## CommonEventData
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable/Writable| Type | Mandatory| Description |
| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------- |
| event | Read only | string | Yes | Name of the common event that is being received. |
| bundleName | Read only | string | No | Bundle name. |
| code | Read only | number | No | Result code of the common event, which is used to transfer data of the int type. |
| data | Read only | string | No | Custom result data of the common event, which is used to transfer data of the string type.|
| parameters | Read only | {[key: string]: any} | No | Additional information about the common event. |
## CommonEventPublishData
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable/Writable| Type | Mandatory| Description |
| --------------------- | -------- | -------------------- | ---- | ---------------------------- |
| bundleName | Read only | string | No | Bundle name. |
| code | Read only | number | No | Result code of the common event. |
| data | Read only | string | No | Custom result data of the common event.|
| subscriberPermissions | Read only | Array\<string> | No | Permissions required for subscribers to receive the common event. |
| isOrdered | Read only | boolean | No | Whether the common event is an ordered one. |
| isSticky | Read only | boolean | No | Whether the common event is a sticky one. |
| parameters | Read only | {[key: string]: any} | No | Additional information about the common event. |
## CommonEventSubscribeInfo
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable/Writable| Type | Mandatory| Description |
| ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ |
| events | Read only | Array\<string> | Yes | Name of the common event to publish. |
| publisherPermission | Read only | string | No | Permissions required for publishers to publish the common event. |
| publisherDeviceId | Read only | string | No | Device ID. The value must be the ID of an existing device on the same network. |
| userId | Read only | number | No | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | Read only | number | No | Subscriber priority. The value ranges from -100 to 1000. |
...@@ -49,7 +49,7 @@ Inserts an entry at the front of this container. ...@@ -49,7 +49,7 @@ Inserts an entry at the front of this container.
**Example** **Example**
``` ```
let deque = new Deque; let deque = new Deque();
deque.insertFront("a"); deque.insertFront("a");
deque.insertFront(1); deque.insertFront(1);
let b = [1, 2, 3]; let b = [1, 2, 3];
...@@ -73,7 +73,7 @@ Inserts an entry at the end of this container. ...@@ -73,7 +73,7 @@ Inserts an entry at the end of this container.
**Example** **Example**
``` ```
let deque = new Deque; let deque = new Deque();
deque.insertEnd("a"); deque.insertEnd("a");
deque.insertEnd(1); deque.insertEnd(1);
let b = [1, 2, 3]; let b = [1, 2, 3];
......
...@@ -23,8 +23,8 @@ Starts an ability. This method uses a callback to return the result. ...@@ -23,8 +23,8 @@ Starts an ability. This method uses a callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------- | --------------------- | ---- | ------------------- | | --------- | ---------------------------------------- | ---- | -------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| | parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. | | callback | AsyncCallback\<number> | Yes | Callback used to return the result. |
...@@ -62,8 +62,8 @@ Starts an ability. This method uses a promise to return the result. ...@@ -62,8 +62,8 @@ Starts an ability. This method uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------- | ----------------------------------------------- | ---- | --------------------- | | --------- | ---------------------------------------- | ---- | -------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| | parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
**Example** **Example**
...@@ -100,14 +100,14 @@ Obtains a **dataAbilityHelper** object. ...@@ -100,14 +100,14 @@ Obtains a **dataAbilityHelper** object.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------------------ | | ---- | ------ | ---- | ------------ |
| uri | string | Yes | URI of the file to open.| | uri | string | Yes | URI of the file to open.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | -------------------------------------------- | | ----------------- | ------------------------------- |
| DataAbilityHelper | A utility class used to help other abilities access the Data ability.| | DataAbilityHelper | A utility class used to help other abilities access the Data ability.|
**Example** **Example**
...@@ -129,8 +129,8 @@ Starts an ability. This method uses a callback to return the execution result wh ...@@ -129,8 +129,8 @@ Starts an ability. This method uses a callback to return the execution result wh
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------- | ----------------------------------------------- | ---- | --------------------- | | --------- | ---------------------------------------- | ---- | -------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| | parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes | Callback used to return the result. |
...@@ -166,14 +166,14 @@ Starts an ability. This method uses a promise to return the execution result whe ...@@ -166,14 +166,14 @@ Starts an ability. This method uses a promise to return the execution result whe
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------- | ----------------------------------------------- | ---- | ------------------- | | --------- | ---------------------------------------- | ---- | ------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| | parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------- | -------------- | | ---------------------------------------- | ------- |
| Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.| | Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.|
**Example** **Example**
...@@ -222,8 +222,8 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -222,8 +222,8 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------- | ------------- | ---- | ------------------- | | --------- | ------------------------------- | ---- | -------------- |
| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.| | parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
...@@ -270,14 +270,14 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -270,14 +270,14 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------- | ------------------------------- | ---- | ------------------- | | --------- | ------------------------------- | ---- | ------------- |
| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.| | parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ----------------------- | | -------------- | --------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -327,8 +327,8 @@ Checks whether the main window of this ability has the focus. This method uses a ...@@ -327,8 +327,8 @@ Checks whether the main window of this ability has the focus. This method uses a
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------- | ---- | ------------------------------------------------------------ | | -------- | ----------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>Returns **true** if the main window of this ability has the focus; returns **false** otherwise.| | callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
**Example** **Example**
...@@ -351,7 +351,7 @@ Checks whether the main window of this ability has the focus. This method uses a ...@@ -351,7 +351,7 @@ Checks whether the main window of this ability has the focus. This method uses a
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ---------------------------------------------------------- | | ----------------- | ------------------------------------- |
| Promise\<boolean> | Returns **true** if the main window of this ability has the focus; returns **false** otherwise.| | Promise\<boolean> | Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
**Example** **Example**
...@@ -375,8 +375,8 @@ Obtains the **Want** object sent from this ability. This method uses a callback ...@@ -375,8 +375,8 @@ Obtains the **Want** object sent from this ability. This method uses a callback
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------- | ---- | ------------------ | | -------- | ----------------------------- | ---- | --------- |
| callback | AsyncCallback\<[Want](#want)> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[Want](#want)> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -399,7 +399,7 @@ Obtains the **Want** object sent from this ability. This method uses a promise t ...@@ -399,7 +399,7 @@ Obtains the **Want** object sent from this ability. This method uses a promise t
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------- | ------------------------- | | ----------------------- | ---------------- |
| Promise\<[Want](#want)> | Promise used to return the result.| | Promise\<[Want](#want)> | Promise used to return the result.|
**Example** **Example**
...@@ -422,7 +422,7 @@ Obtains the application context. ...@@ -422,7 +422,7 @@ Obtains the application context.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | -------------------- | | ------- | ---------- |
| Context | Application context returned.| | Context | Application context returned.|
**Example** **Example**
...@@ -445,8 +445,8 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -445,8 +445,8 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ---------------- | | -------- | -------------------- | ---- | -------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -469,7 +469,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -469,7 +469,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------- | | -------------- | ---------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -490,8 +490,8 @@ Connects this ability to a specific Service ability. This method uses a callback ...@@ -490,8 +490,8 @@ Connects this ability to a specific Service ability. This method uses a callback
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------- | -------------- | ---- | ---------------------------- | | ------- | -------------- | ---- | --------------------- |
| request | [Want](#want) | Yes | Service ability to connect.| | request | [Want](#want) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. | | options | ConnectOptions | Yes | Callback used to return the result. |
...@@ -499,8 +499,8 @@ Want ...@@ -499,8 +499,8 @@ Want
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable/Writable | Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory | Description |
| ------------ | -------- | -------- | ---- | ---------------------------------- | | ----------- | ---- | ------ | ---- | ---------------------------------------- |
| deviceId | Read-only | string | No | Device ID of the Service ability to connect. The default value is the local device ID.| | deviceId | Read-only | string | No | Device ID of the Service ability to connect. The default value is the local device ID.|
| bundleName | Read-only | string | Yes | Bundle name of the Service ability to connect. | | bundleName | Read-only | string | Yes | Bundle name of the Service ability to connect. |
| abilityName | Read-only | string | Yes | Class name of the Service ability to connect. | | abilityName | Read-only | string | Yes | Class name of the Service ability to connect. |
...@@ -509,8 +509,8 @@ ConnectOptions ...@@ -509,8 +509,8 @@ ConnectOptions
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory | Description |
| ------------ | -------- | -------- | ---- | ---------------------------------- | | ------------ | ---- | -------- | ---- | ------------------------- |
| onConnect | Read-only | function | Yes | Callback invoked when the connection is successful. | | onConnect | Read-only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read-only | function | Yes | Callback invoked when the connection fails. | | onDisconnect | Read-only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.| | onFailed | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
...@@ -518,7 +518,7 @@ ConnectOptions ...@@ -518,7 +518,7 @@ ConnectOptions
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------ | | ------ | -------------------- |
| number | Returns the ID of the Service ability connected.| | number | Returns the ID of the Service ability connected.|
**Example** **Example**
...@@ -559,8 +559,8 @@ Disconnects this ability from a specific Service ability. This method uses a cal ...@@ -559,8 +559,8 @@ Disconnects this ability from a specific Service ability. This method uses a cal
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ------------- | ---- | ------------------------------ | | ---------- | -------------------- | ---- | ----------------------- |
| connection | number | Yes | ID of the Service ability to disconnect.| | connection | number | Yes | ID of the Service ability to disconnect.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
...@@ -606,14 +606,14 @@ Disconnects this ability from a specific Service ability. This method uses a pro ...@@ -606,14 +606,14 @@ Disconnects this ability from a specific Service ability. This method uses a pro
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ------------------------------ | | ---------- | ------ | ---- | ----------------------- |
| connection | number | Yes | ID of the Service ability to disconnect.| | connection | number | Yes | ID of the Service ability to disconnect.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ----------------------- | | -------------- | --------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -659,15 +659,13 @@ Obtains the window corresponding to this ability. This method uses a callback to ...@@ -659,15 +659,13 @@ Obtains the window corresponding to this ability. This method uses a callback to
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------------------------ | | -------- | ----------------------------- | ---- | ----------------------------- |
| callback | AsyncCallback\<window.Window> | Yes | Callback used to return the window.| | callback | AsyncCallback\<window.Window> | Yes | Callback used to return the window.|
**Example** **Example**
```javascript ```javascript
GetWindow(){ featureAbility.getWindow()
featureAbility.getWindow()
}
``` ```
## featureAbility.getWindow<sup>7+</sup> ## featureAbility.getWindow<sup>7+</sup>
...@@ -681,19 +679,147 @@ Obtains the window corresponding to this ability. This method uses a promise to ...@@ -681,19 +679,147 @@ Obtains the window corresponding to this ability. This method uses a promise to
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ---------------------------------------------------------- | | ----------------------- | ----------------------------- |
| Promise\<window.Window> | Promise used to return the window.| | Promise\<window.Window> | Promise used to return the window.|
**Example** **Example**
```javascript ```javascript
GetWindowPromise(){ featureAbility.getWindow().then((data) => {
featureAbility.getWindow().then((data) => {
console.info("=============getWindowPromise========== " + JSON.stringify(data)); console.info("=============getWindowPromise========== " + JSON.stringify(data));
}); });
} ```
## ConnectOptions.onConnect<sup>7+</sup>
onConnect(elementName: ElementName, remote: rpc.IRemoteObject): void;
Callback invoked when the connection is successful.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | ----------------- | ---- | -------- |
| elementName | ElementName | Yes | Element name. |
| remote | rpc.IRemoteObject | Yes | RPC remote object.|
**Example**
```javascript
import rpc from '@ohos.rpc'
import featureAbility from '@ohos.ability.featureAbility'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
```
## ConnectOptions.onDisconnect<sup>7+</sup>
onDisconnect(elementName: ElementName): void;
Callback invoked when the connection fails.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | ----------- | ---- | ---- |
| elementName | ElementName | Yes | Element name.|
**Example**
```javascript
import rpc from '@ohos.rpc'
import featureAbility from '@ohos.ability.featureAbility'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
``` ```
## ConnectOptions.onFailed<sup>7+</sup>
onFailed(code: number): void;
Callback invoked when **connectAbility** fails to be called.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | --------- |
| code | number | Yes | Number type.|
**Example**
```javascript
import rpc from '@ohos.rpc'
import featureAbility from '@ohos.ability.featureAbility'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
```
## AbilityWindowConfiguration ## AbilityWindowConfiguration
...@@ -705,13 +831,15 @@ The value is obtained through the **featureAbility.AbilityWindowConfiguration** ...@@ -705,13 +831,15 @@ The value is obtained through the **featureAbility.AbilityWindowConfiguration**
featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED
``` ```
| Name | Name| Description | **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| --------------------------- | ---- | ---------- |
| WINDOW_MODE_UNDEFINED<sup>7+</sup> | 0 | The Page ability is in an undefined window display mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel | | Name | Name | Description |
| WINDOW_MODE_FULLSCREEN<sup>7+</sup> | 1 | The Page ability is in full screen mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel | | ---------------------------------------- | ---- | ---------------------------------------- |
| WINDOW_MODE_SPLIT_PRIMARY<sup>7+</sup> | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | WINDOW_MODE_UNDEFINED<sup>7+</sup> | 0 | The Page ability is in an undefined window display mode.|
| WINDOW_MODE_SPLIT_SECONDARY<sup>7+</sup> | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | WINDOW_MODE_FULLSCREEN<sup>7+</sup> | 1 | The Page ability is in full screen mode. |
| WINDOW_MODE_FLOATING<sup>7+</sup> | 102 | The Page ability is displayed in floating window mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel | | WINDOW_MODE_SPLIT_PRIMARY<sup>7+</sup> | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.|
| WINDOW_MODE_SPLIT_SECONDARY<sup>7+</sup> | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.|
| WINDOW_MODE_FLOATING<sup>7+</sup> | 102 | The Page ability is displayed in floating window mode.|
## AbilityStartSetting ## AbilityStartSetting
...@@ -726,34 +854,40 @@ The value is obtained through the **featureAbility.AbilityStartSetting** API. ...@@ -726,34 +854,40 @@ The value is obtained through the **featureAbility.AbilityStartSetting** API.
featureAbility.AbilityStartSetting.BOUNDS_KEY featureAbility.AbilityStartSetting.BOUNDS_KEY
``` ```
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Name | Description | | Name | Name | Description |
| --------------- | --------------- | -------------------------- | | ---------------------------- | --------------- | ---------------------------------------- |
| BOUNDS_KEY<sup>7+</sup> | "abilityBounds" | Ability window size.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel | | BOUNDS_KEY<sup>7+</sup> | "abilityBounds" | Ability window size.|
| WINDOW_MODE_KEY<sup>7+</sup> | "windowMode" | Ability window display mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel | | WINDOW_MODE_KEY<sup>7+</sup> | "windowMode" | Ability window display mode.|
| DISPLAY_ID_KEY<sup>7+</sup> | "displayId" | Display device ID.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | DISPLAY_ID_KEY<sup>7+</sup> | "displayId" | Display device ID.|
## ErrorCode ## ErrorCode
Enumerates error codes. Enumerates error codes.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Variable | Value | Description | | Variable | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ | | ------------------------------ | ---- | ---------------------------------------- |
| NO_ERROR<sup>7+</sup> | 0 | No error occurs.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | NO_ERROR<sup>7+</sup> | 0 | No error occurs.|
| INVALID_PARAMETER<sup>7+</sup> | -1 | Invalid parameter.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | INVALID_PARAMETER<sup>7+</sup> | -1 | Invalid parameter.|
| ABILITY_NOT_FOUND<sup>7+</sup> | -2 | The ability is not found.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | ABILITY_NOT_FOUND<sup>7+</sup> | -2 | The ability is not found.|
| PERMISSION_DENY<sup>7+</sup> | -3 | The request is denied.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | PERMISSION_DENY<sup>7+</sup> | -3 | The request is denied.|
## DataAbilityOperationType ## DataAbilityOperationType
Enumerates operation types of the Data ability. Enumerates operation types of the Data ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Variable | Value | Description | | Variable | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ | | ------------------------ | ---- | ---------------------------------------- |
| TYPE_INSERT<sup>7+</sup> | 1 | Insert operation.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | TYPE_INSERT<sup>7+</sup> | 1 | Insert operation.|
| TYPE_UPDATE<sup>7+</sup> | 2 | Update operation.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | TYPE_UPDATE<sup>7+</sup> | 2 | Update operation.|
| TYPE_DELETE<sup>7+</sup> | 3 | Deletion operation.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | TYPE_DELETE<sup>7+</sup> | 3 | Deletion operation.|
| TYPE_ASSERT<sup>7+</sup> | 4 | Assert operation.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | TYPE_ASSERT<sup>7+</sup> | 4 | Assert operation.|
...@@ -761,8 +895,8 @@ Enumerates operation types of the Data ability. ...@@ -761,8 +895,8 @@ Enumerates operation types of the Data ability.
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory | Description |
| ---------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | | ----------------------- | ---- | ------------- | ---- | ------------------------------------- |
| resultCode<sup>7+</sup> | Read-only | number | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.| | resultCode<sup>7+</sup> | Read-only | number | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.|
| want<sup>7+</sup> | Read-only | [Want](#want) | No | Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**. | | want<sup>7+</sup> | Read-only | [Want](#want) | No | Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**. |
...@@ -770,8 +904,8 @@ Enumerates operation types of the Data ability. ...@@ -770,8 +904,8 @@ Enumerates operation types of the Data ability.
**System capability**: SystemCapability.AbilityRuntime.FAModel **System capability**: SystemCapability.AbilityRuntime.FAModel
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory | Description |
| ------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | | ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| want | Read-only | [Want](#want) | Yes | Information about the ability to start. | | want | Read-only | [Want](#want) | Yes | Information about the ability to start. |
| abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.| | abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.|
...@@ -781,23 +915,25 @@ Enumerates operation types of the Data ability. ...@@ -781,23 +915,25 @@ Enumerates operation types of the Data ability.
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | | -------------------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId<sup>8+</sup> | Read-only | string | No | ID of the device that runs the ability. | | deviceId | Read-only | string | No | ID of the device that runs the ability. |
| bundleName<sup>8+</sup> | Read-only | string | No | Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| | bundleName | Read-only | string | No | Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| abilityName<sup>8+</sup> | Read-only | string | No | Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| | abilityName | Read-only | string | No | Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| uri<sup>8+</sup> | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| | uri | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type<sup>8+</sup> | Read-only | string | No | MIME type, for example, text/plain or image/*. | | type | Read-only | string | No | MIME type, for example, text/plain or image/*. |
| flags<sup>8+</sup> | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).| | flags | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).|
| action<sup>8+</sup> | Read-only | string | No | Action option. | | action | Read-only | string | No | Action option. |
| parameters<sup>8+</sup> | Read-only | {[key: string]: any} | No | List of parameters in a **Want** object. | | parameters | Read-only | {[key: string]: any} | No | List of parameters in the **Want** object. |
| entities<sup>8+</sup> | Read-only | Array\<string> | No | List of entities. | | entities | Read-only | Array\<string> | No | List of entities. |
| extensionAbilityName<sup>9+<sup> | Read-only | string | No | Description of the Extension ability name in the **Want** object. |
| extensionAbilityType<sup>9+<sup> | Read-only | number | No | Description of the Extension ability type in the **Want** object. |
## flags ## flags
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
| Name | Name | Description | | Name | Name | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ | | ------------------------------------ | ---------- | ---------------------------------------- |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. | | FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. | | FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. | | FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
...@@ -811,6 +947,6 @@ Enumerates operation types of the Data ability. ...@@ -811,6 +947,6 @@ Enumerates operation types of the Data ability.
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. | | FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. | | FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. | | FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.| | FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack. | | FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack. |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.| | FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.|
# FormInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides widget information.
## Modules to Import
```
import formInfo from '@ohos.application.formInfo';
```
## Required Permissions
None.
## FormInfo
Describes widget information.
**System capability**
SystemCapability.Ability.Form
| Name | Readable/Writable| Type | Description |
| ----------- | -------- | -------------------- | ------------------------------------------------------------ |
| bundleName | Read only | string | Name of the bundle to which the widget belongs. |
| moduleName | Read only | string | Name of the module to which the widget belongs. |
| abilityName | Read only | string | Name of the ability to which the widget belongs. |
| name | Read only | string | Widget name. |
| description | Read only | string | Description of the widget. |
| type | Read only | [FormType](#formtype) | Widget type. Currently, only JS widgets are supported.|
| jsComponentName | Read only | string | Component name of the JS widget. |
| colorMode | Read only | [ColorMode](#colormode) | Color mode of the widget. |
| isDefault | Read only | boolean | Whether the widget is the default one. |
| updateEnabled | Read only | boolean | Whether the widget is updatable. |
| formVisibleNotify | Read only | string | Whether to send a notification when the widget is visible. |
| relatedBundleName | Read only | string | Name of the associated bundle to which the widget belongs. |
| scheduledUpdateTime | Read only | string | Time when the widget was updated. |
| formConfigAbility | Read only | string | Configuration ability of the widget. |
| updateDuration | Read only | string | Widget update period.|
| defaultDimension | Read only | number | Default dimension of the widget. |
| supportDimensions | Read only | Array&lt;number&gt; | Dimensions supported by the widget. |
| customizeData | Read only | {[key: string]: [value: string]} | Custom data of the widget. |
## FormType
Enumerates the widget types.
**System capability**
SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| JS | 1 | JS widget. |
## ColorMode
Enumerates the color modes supported by the widget.
**System capability**
SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| MODE_AUTO | -1 | Automatic mode. |
| MODE_DARK | 0 | Dark mode. |
| MODE_LIGHT | 1 | Light mode. |
## FormStateInfo
Describes the widget state information.
**System capability**
SystemCapability.Ability.Form
| Name | Readable/Writable| Type | Description |
| ----------- | -------- | -------------------- | ------------------------------------------------------------ |
| formState | Read only | [FormState](#formstate) | Widget state. |
| want | Read only | Want | Want text. |
## FormState
Enumerates the widget states.
**System capability**
SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| UNKNOWN | -1 | Unknown state. |
| DEFAULT | 0 | Default state. |
| READY | 1 | Ready state. |
## FormParam
Enumerates the widget parameters.
**System capability**
SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | ID of a widget. |
| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | Widget dimension. |
| NAME_KEY | "ohos.extra.param.key.form_name" | Widget name. |
| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | Name of the module to which the widget belongs. |
| WIDTH_KEY | "ohos.extra.param.key.form_width" | Widget width. |
| HEIGHT_KEY | "ohos.extra.param.key.form_height" | Widget height. |
| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | Temporary widget. |
...@@ -25,7 +25,7 @@ Creates a **FormBindingData** object. ...@@ -25,7 +25,7 @@ Creates a **FormBindingData** object.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ | | ------ | -------------- | ---- | ------------------------------------------------------------ |
| obj | Object or string| No | Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format.| | obj | Object or string| No | Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.|
**Return value** **Return value**
...@@ -38,20 +38,20 @@ Creates a **FormBindingData** object. ...@@ -38,20 +38,20 @@ Creates a **FormBindingData** object.
**Example** **Example**
```js ```js
let obj = {"temperature": "21°"}; let fd = fileio.openSync(path);
let obj = {
"temperature": "21°",
"formImages": {"image": fd}
};
let formBindingDataObj = formBindingData.createFormBindingData(obj); let formBindingDataObj = formBindingData.createFormBindingData(obj);
``` ```
## formBindingData.FormBindingData ## Attributes
data: Object
Describes a **FormBindingData** object. Describes a **FormBindingData** object.
**System capability**: SystemCapability.Ability.Form **System capability**: SystemCapability.Ability.Form
**Parameters** | Name| Readable| Writable| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
| Name| Type | Description | | data | Yes| No| Object | Yes| Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
| ---- | -------------- | ------------------------------------------------------------ |
| data | Object or string| Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
# FormError
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides widget-related error codes.
## Modules to Import
```
import formError from '@ohos.application.formError';
```
## Required Permissions
None.
## enum FormError
Enumerates the available error codes.
**System capability**
SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| ERR_COMMON | 1 | Default error code. |
| ERR_PERMISSION_DENY | 2 | No permission to perform the operation. |
| ERR_GET_INFO_FAILED | 4 | Failed to query widget information. |
| ERR_GET_BUNDLE_FAILED | 5 | Failed to query the bundle information. |
| ERR_GET_LAYOUT_FAILED | 6 | Failed to query the layout information. |
| ERR_ADD_INVALID_PARAM | 7 | Invalid parameter. |
| ERR_CFG_NOT_MATCH_ID | 8 | The widget ID does not match. |
| ERR_NOT_EXIST_ID | 9 | The widget ID does not exist. |
| ERR_BIND_PROVIDER_FAILED | 10 | Failed to bind to the widget provider. |
| ERR_MAX_SYSTEM_FORMS | 11 | The number of system widgets exceeds the upper limit. |
| ERR_MAX_INSTANCES_PER_FORM | 12 | The number of instances per widget exceeds the upper limit. |
| ERR_OPERATION_FORM_NOT_SELF | 13 | The application is not allowed to operate widgets applied by other applications. |
| ERR_PROVIDER_DEL_FAIL | 14 | The widget provider failed to delete the widget. |
| ERR_MAX_FORMS_PER_CLIENT | 15 | The number of widgets applied for by the widget host exceeds the upper limit. |
| ERR_MAX_SYSTEM_TEMP_FORMS | 16 | The number of temporary widgets exceeds the upper limit. |
| ERR_FORM_NO_SUCH_MODULE | 17 | The module does not exist. |
| ERR_FORM_NO_SUCH_ABILITY | 18 | The ability component does not exist. |
| ERR_FORM_NO_SUCH_DIMENSION | 19 | The widget dimension does not exist. |
| ERR_FORM_FA_NOT_INSTALLED | 20 | The FA where the widget is located is not installed. |
| ERR_SYSTEM_RESPONSES_FAILED | 30 | The system service failed to respond. |
| ERR_FORM_DUPLICATE_ADDED | 31 | The widget has been added. |
| ERR_IN_RECOVERY | 36 | Failed to overwrite the widget data. |
# FormHost
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to the widget host.
## Modules to Import
```
import formHost from '@ohos.application.formHost';
```
## Required Permissions
ohos.permission.REQUIRE_FORM
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
## deleteForm
deleteForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Deletes a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.deleteForm(formId, (error, data) => {
if (error) {
console.log('formHost deleteForm, error:' + error.code);
}
});
```
## deleteForm
deleteForm(formId: string): Promise&lt;void&gt;;
Deletes a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
**System capability**:
SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
formHost.deleteForm(formId).catch((error) => {
console.log('formProvider deleteForm, error:' + JSON.stringify(error));
});
```
## releaseForm
releaseForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager still retains the widget cache and storage information.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.releaseForm(formId, (error, data) => {
if (error) {
console.log('formHost releaseForm, error:' + error.code);
}
});
```
## releaseForm
releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback&lt;void&gt;): void;
Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and determines whether to retain the cache information based on the setting.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | ----------- |
| formId | string | Yes | ID of a widget. |
| isReleaseCache | boolean | Yes | Whether to release the cache.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.releaseForm(formId, true, (error, data) => {
if (error) {
console.log('formHost releaseForm, error:' + error.code);
}
});
```
## releaseForm
releaseForm(formId: string, isReleaseCache?: boolean): Promise&lt;void&gt;;
Releases a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and determines whether to retain the cache information based on the setting.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | ----------- |
| formId | string | Yes | ID of a widget. |
| isReleaseCache | boolean | No | Whether to release the cache.|
**Example**
```js
var formId = "12400633174999288";
formHost.releaseForm(formId, true).catch((error) => {
console.log('formProvider releaseForm, error:' + JSON.stringify(error));
});
```
## requestForm
requestForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Requests a widget update. This API uses an asynchronous callback to return the result.
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.requestForm(formId, (error, data) => {
if (error) {
console.log('formHost requestForm, error:' + error.code);
}
});
```
## requestForm
requestForm(formId: string): Promise&lt;void&gt;;
Requests a widget update. This API uses a promise to return the result.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
**System capability**:
SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
formHost.requestForm(formId).catch((error) => {
console.log('formProvider requestForm, error:' + JSON.stringify(error));
});
```
## castTempForm
castTempForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Converts a temporary widget to a normal one. This API uses an asynchronous callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.castTempForm(formId, (error, data) => {
if (error) {
console.log('formHost castTempForm, error:' + error.code);
}
});
```
## castTempForm
castTempForm(formId: string): Promise&lt;void&gt;;
Converts a temporary widget to a normal one. This API uses a promise to return the result.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
**System capability**:
SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
formHost.castTempForm(formId).catch((error) => {
console.log('formProvider castTempForm, error:' + JSON.stringify(error));
});
```
## notifyVisibleForms
notifyVisibleForms(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widget framework to make a widget visible. This API uses an asynchronous callback to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.notifyVisibleForms(formId, (error, data) => {
if (error) {
console.log('formHost notifyVisibleForms, error:' + error.code);
}
});
```
## notifyVisibleForms
notifyVisibleForms(formId: string): Promise&lt;void&gt;;
Instructs the widget framework to make a widget visible. This API uses a promise to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
**System capability**:
SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
formHost.notifyVisibleForms(formId).catch((error) => {
console.log('formProvider notifyVisibleForms, error:' + JSON.stringify(error));
});
```
## notifyInvisibleForms
notifyInvisibleForms(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widget framework to make a widget invisible. This API uses an asynchronous callback to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.notifyInvisibleForms(formId, (error, data) => {
if (error) {
console.log('formHost notifyInvisibleForms, error:' + error.code);
}
});
```
## notifyInvisibleForms
notifyInvisibleForms(formId: string): Promise&lt;void&gt;;
Instructs the widget framework to make a widget invisible. This API uses a promise to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
**System capability**:
SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
formHost.notifyInvisibleForms(formId).catch((error) => {
console.log('formProvider notifyInvisibleForms, error:' + JSON.stringify(error));
});
```
## enableFormsUpdate
enableFormsUpdate(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widget framework to make a widget to be updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.enableFormsUpdate(formId, (error, data) => {
if (error) {
console.log('formHost enableFormsUpdate, error:' + error.code);
}
});
```
## enableFormsUpdate
enableFormsUpdate(formId: string): Promise&lt;void&gt;;
Instructs the widget framework to make a widget to be updatable. This API uses a promise to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
**System capability**:
SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
formHost.enableFormsUpdate(formId).catch((error) => {
console.log('formProvider enableFormsUpdate, error:' + JSON.stringify(error));
});
```
## disableFormsUpdate
disableFormsUpdate(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widget framework to make a widget not to be updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget is in the disabled state and cannot receive updates from the widget provider.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.disableFormsUpdate(formId, (error, data) => {
if (error) {
console.log('formHost disableFormsUpdate, error:' + error.code);
}
});
```
## disableFormsUpdate
disableFormsUpdate(formId: string): Promise&lt;void&gt;;
Instructs the widget framework to make a widget not to be updatable. This API uses a promise to return the result. After this API is called, the widget is in the disabled state and cannot receive updates from the widget provider.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
**System capability**:
SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
formHost.disableFormsUpdate(formId).catch((error) => {
console.log('formProvider disableFormsUpdate, error:' + JSON.stringify(error));
});
```
## isSystemReady
isSystemReady(callback: AsyncCallback&lt;void&gt;): void;
Checks whether the system is ready. This API uses an asynchronous callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.isSystemReady((error, data) => {
if (error) {
console.log('formHost isSystemReady, error:' + error.code);
}
});
```
## isSystemReady
isSystemReady(): Promise&lt;void&gt;;
Checks whether the system is ready. This API uses a promise to return the result.
**System capability**:
SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
formHost.isSystemReady().catch((error) => {
console.log('formProvider isSystemReady, error:' + JSON.stringify(error));
});
```
## getAllFormsInfo
getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;FormInfo&gt;&gt;): void;
Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example**
```js
formHost.getAllFormsInfo((error, data) => {
if (error) {
console.log('formHost getAllFormsInfo, error:' + error.code);
}
});
```
## getAllFormsInfo
getAllFormsInfo(): Promise&lt;Array&lt;FormInfo&gt;&gt;;
Obtains the widget information provided by all applications on the device. This API uses a promise to return the result.
**System capability**:
SystemCapability.Ability.Form
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Promise used to return the widget information.|
**Example**
```js
formHost.getAllFormsInfo().catch((error) => {
console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error));
});
```
## getFormsInfo
getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;FormInfo&gt;&gt;): void;
Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the target application.|
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example**
```js
formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => {
if (error) {
console.log('formHost getFormsInfo, error:' + error.code);
}
});
```
## getFormsInfo
getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt;Array&lt;FormInfo&gt;&gt;): void;
Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the target application.|
| moduleName | string | Yes| Module name.|
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example**
```js
formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => {
if (error) {
console.log('formHost getFormsInfo, error:' + error.code);
}
});
```
## getFormsInfo
getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;FormInfo&gt;&gt;;
Obtains the widget information provided by a given application on the device. This API uses a promise to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the target application.|
| moduleName | string | No| Module name.|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Promise used to return the widget information.|
**Example**
```js
formHost.getAllFormsInfo().catch((error) => {
console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error));
});
```
## deleteInvalidForms
deleteInvalidForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;number&gt;): void;
Deletes invalid widgets from the list. This API uses an asynchronous callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the number of widgets deleted.|
**Example**
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.deleteInvalidForms(formIds, (error, data) => {
if (error) {
console.log('formHost deleteInvalidForms, error:' + error.code);
}
});
```
## deleteInvalidForms
function deleteInvalidForms(formIds: Array&ltstring&gt): Promise&lt;number&gt;;
Deletes invalid widgets from the list. This API uses a promise to return the result.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the number of widgets deleted.|
**System capability**:
SystemCapability.Ability.Form
**Example**
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.deleteInvalidForms(formIds).catch((error) => {
console.log('formProvider deleteInvalidForms, error:' + JSON.stringify(error));
});
```
## acquireFormState
acquireFormState(want: Want, callback: AsyncCallback&lt;FormStateInfo&gt;): void;
Obtains the widget state. This API uses an asynchronous callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| want | [Want](js-apis-featureAbility.md#want) | Yes | **Want** information carried to query the widget state.|
| callback | AsyncCallback&lt;[FormStateInfo](js-apis-formInfo.md#formstateinfo)&gt; | Yes| Callback used to return the widget state.|
**Example**
```js
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
"abilityName": "com.extreme.test.MainAbility"
};
formHost.acquireFormState(want, (error, data) => {
if (error) {
console.log('formHost acquireFormState, error:' + error.code);
}
});
```
## acquireFormState
function acquireFormState(formIds: Array&ltstring&gt): Promise&lt;formInfo.FormStateInfo&gt;;
Obtains the widget state. This API uses a promise to return the result.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;[FormStateInfo](js-apis-formInfo.md#formstateinfo)&gt; | Promise used to return the widget state.|
**System capability**:
SystemCapability.Ability.Form
**Example**
```js
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
"abilityName": "com.extreme.test.MainAbility"
};
formHost.acquireFormState(want).catch((error) => {
console.log('formProvider acquireFormState, error:' + JSON.stringify(error));
});
```
## on("formUninstall")
on(type: "formUninstall", callback: Callback&lt;string&gt;): void;
Subscribes to the widget state changes. This API uses a callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Type of event to subscribe to. The value **formUninstall** indicates a widget uninstallation event.|
| callback | Callback&lt;string&gt; | Yes| Callback used to return the result.|
**Example**
```js
formHost.on("formUninstall", (error, data) => {
if (error) {
console.log('formHost on formUninstall, error:' + error.code);
}
});
```
## off("formUninstall")
off(type: "formUninstall", callback: Callback&lt;string&gt;): void;
Unsubscribes from the widget state changes. This API uses a callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Type of event to unsubscribe from. The value **formUninstall** indicates a widget uninstallation event.|
| callback | Callback&lt;string&gt; | Yes| Callback used to return the result.|
**Example**
```js
formHost.off("formUninstall", (error, data) => {
if (error) {
console.log('formHost off formUninstall, error:' + error.code);
}
});
```
## notifyFormsVisible
notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widgets to make themselves visible. This API uses an asynchronous callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isVisible | boolean | Yes | Whether to be visible.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.notifyFormsVisible(formIds, true, (error, data) => {
if (error) {
console.log('formHost notifyFormsVisible, error:' + error.code);
}
});
```
## notifyFormsVisible
notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean): Promise&lt;void&gt;;
Instructs the widgets to make themselves visible. This API uses a promise to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isVisible | boolean | Yes | Whether to be visible.|
**Example**
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.notifyFormsVisible(formIds, true).catch((error) => {
console.log('formProvider notifyFormsVisible, error:' + JSON.stringify(error));
});
```
## notifyFormsEnableUpdate
notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widgets to enable or disable update. This API uses an asynchronous callback to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isEnableUpdate | boolean | Yes | Whether to enable update.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => {
if (error) {
console.log('formHost notifyFormsEnableUpdate, error:' + error.code);
}
});
```
## notifyFormsEnableUpdate
notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean): Promise&lt;void&gt;;
Instructs the widgets to enable or disable update. This API uses a promise to return the result.
**System capability**:
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isEnableUpdate | boolean | Yes | Whether to enable update.|
**Example**
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.notifyFormsEnableUpdate(formIds, true).catch((error) => {
console.log('formProvider notifyFormsEnableUpdate, error:' + JSON.stringify(error));
});
```
...@@ -61,6 +61,12 @@ SystemCapability.Ability.Form ...@@ -61,6 +61,12 @@ SystemCapability.Ability.Form
| formId | string | Yes | ID of a widget. | | formId | string | Yes | ID of a widget. |
| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | | minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
**Return value**
| Type | Description |
| ------------- | ---------------------------------- |
| Promise\<void> |Promise used to return the result. |
**Example** **Example**
```js ```js
...@@ -118,6 +124,12 @@ SystemCapability.Ability.Form ...@@ -118,6 +124,12 @@ SystemCapability.Ability.Form
| formId | string | Yes | ID of the widget to update.| | formId | string | Yes | ID of the widget to update.|
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. | | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
**Return value**
| Type | Description |
| -------------- | ----------------------------------- |
| Promise\<void> | Promise used to return the result.|
**Example** **Example**
```js ```js
......
# Geolocation - New # Geolocation
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -12,26 +12,23 @@ ...@@ -12,26 +12,23 @@
import geolocation from '@ohos.geolocation'; import geolocation from '@ohos.geolocation';
``` ```
## Required Permissions
ohos.permission.LOCATION
ohos.permission.LOCATION_IN_BACKGROUND
## geolocation.on('locationChange') ## geolocation.on('locationChange')
on(type: 'locationChange', request: LocationRequest, callback: Callback&lt;Location&gt;) : void on(type: 'locationChange', request: LocationRequest, callback: Callback&lt;Location&gt;) : void
Registers a listener for location changes with a location request initiated. Registers a listener for location changes with a location request initiated.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**locationChange**&nbsp;indicates&nbsp;a&nbsp;location&nbsp;change&nbsp;event. | | type | string | Yes| Event type. The value **locationChange** indicates a location change event.|
| request | LocationRequest | Yes | Location&nbsp;request. | | request | LocationRequest | Yes| Location request.|
| callback | Callback&lt;[Location](#location)&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;location&nbsp;change&nbsp;event. | | callback | Callback&lt;[Location](#location)&gt; | Yes| Callback used to return the location change event.|
- Example - Example
...@@ -50,11 +47,16 @@ off(type: 'locationChange', callback?: Callback&lt;Location&gt;) : void ...@@ -50,11 +47,16 @@ off(type: 'locationChange', callback?: Callback&lt;Location&gt;) : void
Unregisters the listener for location changes with the corresponding location request deleted. Unregisters the listener for location changes with the corresponding location request deleted.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**locationChange**&nbsp;indicates&nbsp;a&nbsp;location&nbsp;change&nbsp;event. | | type | string | Yes| Event type. The value **locationChange** indicates a location change event.|
| callback | Callback&lt;[Location](#location)&gt; | No | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;location&nbsp;change&nbsp;event. | | callback | Callback&lt;[Location](#location)&gt; | No| Callback used to return the location change event.|
- Example - Example
...@@ -74,11 +76,16 @@ on(type: 'locationServiceState', callback: Callback&lt;boolean&gt;) : void ...@@ -74,11 +76,16 @@ on(type: 'locationServiceState', callback: Callback&lt;boolean&gt;) : void
Registers a listener for location service status change events. Registers a listener for location service status change events.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**locationServiceState**&nbsp;indicates&nbsp;a&nbsp;location&nbsp;service&nbsp;status&nbsp;change&nbsp;event. | | type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.|
| callback | Callback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;location&nbsp;service&nbsp;status&nbsp;change&nbsp;event. | | callback | Callback&lt;boolean&gt; | Yes| Callback used to return the location service status change event.|
- Example - Example
...@@ -96,11 +103,16 @@ off(type: 'locationServiceState', callback?: Callback&lt;boolean&gt;) : void; ...@@ -96,11 +103,16 @@ off(type: 'locationServiceState', callback?: Callback&lt;boolean&gt;) : void;
Unregisters the listener for location service status change events. Unregisters the listener for location service status change events.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**locationServiceState**&nbsp;indicates&nbsp;a&nbsp;location&nbsp;service&nbsp;status&nbsp;change&nbsp;event. | | type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.|
| callback | Callback&lt;boolean&gt; | No | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;location&nbsp;service&nbsp;status&nbsp;change&nbsp;event. | | callback | Callback&lt;boolean&gt; | No| Callback used to return the location service status change event.|
- Example - Example
...@@ -113,18 +125,23 @@ Unregisters the listener for location service status change events. ...@@ -113,18 +125,23 @@ Unregisters the listener for location service status change events.
``` ```
## geolocation.on('cachedGnssLocationsReporting') ## geolocation.on('cachedGnssLocationsReporting')<sup>8+</sup>
on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback&lt;Array&lt;Location&gt;&gt;) : void; on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback&lt;Array&lt;Location&gt;&gt;) : void;
Registers a listener for cached GNSS location reports. Registers a listener for cached GNSS location reports.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Gnss
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**cachedGnssLocationsReporting**&nbsp;indicates&nbsp;reporting&nbsp;of&nbsp;cached&nbsp;GNSS&nbsp;locations. | | type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.|
| request | CachedGnssLocationsRequest | Yes | Request&nbsp;for&nbsp;reporting&nbsp;cached&nbsp;GNSS&nbsp;location. | | request | CachedGnssLocationsRequest | Yes| Request for reporting cached GNSS location.|
| callback | Callback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;cached&nbsp;GNSS&nbsp;locations. | | callback | Callback&lt;boolean&gt; | Yes| Callback used to return cached GNSS locations.|
- Example - Example
...@@ -137,17 +154,22 @@ Registers a listener for cached GNSS location reports. ...@@ -137,17 +154,22 @@ Registers a listener for cached GNSS location reports.
``` ```
## geolocation.off('cachedGnssLocationsReporting') ## geolocation.off('cachedGnssLocationsReporting')<sup>8+</sup>
off(type: 'cachedGnssLocationsReporting', callback?: Callback&lt;Array&lt;Location&gt;&gt;) : void; off(type: 'cachedGnssLocationsReporting', callback?: Callback&lt;Array&lt;Location&gt;&gt;) : void;
Unregisters the listener for cached GNSS location reports. Unregisters the listener for cached GNSS location reports.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Gnss
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**cachedGnssLocationsReporting**&nbsp;indicates&nbsp;reporting&nbsp;of&nbsp;cached&nbsp;GNSS&nbsp;locations. | | type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.|
| callback | Callback&lt;boolean&gt; | No | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;cached&nbsp;GNSS&nbsp;locations. | | callback | Callback&lt;boolean&gt; | No| Callback used to return cached GNSS locations.|
- Example - Example
...@@ -161,17 +183,22 @@ Unregisters the listener for cached GNSS location reports. ...@@ -161,17 +183,22 @@ Unregisters the listener for cached GNSS location reports.
``` ```
## geolocation.on('gnssStatusChange') ## geolocation.on('gnssStatusChange')<sup>8+</sup>
on(type: 'gnssStatusChange', callback: Callback&lt;SatelliteStatusInfo&gt;) : void; on(type: 'gnssStatusChange', callback: Callback&lt;SatelliteStatusInfo&gt;) : void;
Registers a listener for GNSS satellite status change events. Registers a listener for GNSS satellite status change events.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Gnss
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**gnssStatusChange**&nbsp;indicates&nbsp;a&nbsp;GNSS&nbsp;satellite&nbsp;status&nbsp;change. | | type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.|
| callback | Callback&lt;SatelliteStatusInfo&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;GNSS&nbsp;satellite&nbsp;status&nbsp;changes. | | callback | Callback&lt;SatelliteStatusInfo&gt; | Yes| Callback used to return GNSS satellite status changes.|
- Example - Example
...@@ -183,17 +210,21 @@ Registers a listener for GNSS satellite status change events. ...@@ -183,17 +210,21 @@ Registers a listener for GNSS satellite status change events.
``` ```
## geolocation.off('gnssStatusChange') ## geolocation.off('gnssStatusChange')<sup>8+</sup>
off(type: 'gnssStatusChange', callback?: Callback&lt;SatelliteStatusInfo&gt;) : void; off(type: 'gnssStatusChange', callback?: Callback&lt;SatelliteStatusInfo&gt;) : void;
Unregisters the listener for GNSS satellite status change events. Unregisters the listener for GNSS satellite status change events.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Gnss
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**gnssStatusChange**&nbsp;indicates&nbsp;a&nbsp;GNSS&nbsp;satellite&nbsp;status&nbsp;change. | | type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.|
| callback | Callback&lt;SatelliteStatusInfo&gt; | No | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;GNSS&nbsp;satellite&nbsp;status&nbsp;changes. | | callback | Callback&lt;SatelliteStatusInfo&gt; | No| Callback used to return GNSS satellite status changes.|
- Example - Example
...@@ -206,17 +237,22 @@ Unregisters the listener for GNSS satellite status change events. ...@@ -206,17 +237,22 @@ Unregisters the listener for GNSS satellite status change events.
``` ```
## geolocation.on('nmeaMessageChange') ## geolocation.on('nmeaMessageChange')<sup>8+</sup>
on(type: 'nmeaMessageChange', callback: Callback&lt;string&gt;) : void; on(type: 'nmeaMessageChange', callback: Callback&lt;string&gt;) : void;
Registers a listener for GNSS NMEA message change events. Registers a listener for GNSS NMEA message change events.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Gnss
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**nmeaMessageChange**&nbsp;indicates&nbsp;a&nbsp;GNSS&nbsp;NMEA&nbsp;message&nbsp;change. | | type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.|
| callback | Callback&lt;string&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;GNSS&nbsp;NMEA&nbsp;message&nbsp;changes. | | callback | Callback&lt;string&gt; | Yes| Callback used to return GNSS NMEA message changes.|
- Example - Example
...@@ -228,17 +264,22 @@ Registers a listener for GNSS NMEA message change events. ...@@ -228,17 +264,22 @@ Registers a listener for GNSS NMEA message change events.
``` ```
## geolocation.off('nmeaMessageChange') ## geolocation.off('nmeaMessageChange')<sup>8+</sup>
off(type: 'nmeaMessageChange', callback?: Callback&lt;string&gt;) : void; off(type: 'nmeaMessageChange', callback?: Callback&lt;string&gt;) : void;
Unregisters the listener for GNSS NMEA message change events. Unregisters the listener for GNSS NMEA message change events.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Gnss
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**nmeaMessageChange**&nbsp;indicates&nbsp;a&nbsp;GNSS&nbsp;NMEA&nbsp;message&nbsp;change. | | type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.|
| callback | Callback&lt;string&gt; | No | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;GNSS&nbsp;NMEA&nbsp;message&nbsp;changes. | | callback | Callback&lt;string&gt; | No| Callback used to return GNSS NMEA message changes.|
- Example - Example
...@@ -251,18 +292,23 @@ Unregisters the listener for GNSS NMEA message change events. ...@@ -251,18 +292,23 @@ Unregisters the listener for GNSS NMEA message change events.
``` ```
## geolocation.on('fenceStatusChange') ## geolocation.on('fenceStatusChange')<sup>8+</sup>
on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void;
Registers a listener for status change events of the specified geofence. Registers a listener for status change events of the specified geofence.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geofence
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**fenceStatusChange**&nbsp;indicates&nbsp;a&nbsp;geofence&nbsp;status&nbsp;change. | | type | string | Yes| Event type. The value **fenceStatusChange** indicates a geofence status change.|
| request | GeofenceRequest | Yes | Geofencing&nbsp;request. | | request | GeofenceRequest | Yes| Geofencing request.|
| want | WantAgent | Yes | **WantAgent**&nbsp;used&nbsp;to&nbsp;return&nbsp;geofence&nbsp;(entrance&nbsp;or&nbsp;exit)&nbsp;events. | | want | WantAgent | Yes| **WantAgent** used to return geofence (entrance or exit) events.|
- Example - Example
...@@ -313,18 +359,22 @@ Registers a listener for status change events of the specified geofence. ...@@ -313,18 +359,22 @@ Registers a listener for status change events of the specified geofence.
``` ```
## geolocation.off('fenceStatusChange') ## geolocation.off('fenceStatusChange')<sup>8+</sup>
off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void;
Unregisters the listener for status change events of the specified geofence. Unregisters the listener for status change events of the specified geofence.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geofence
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.&nbsp;The&nbsp;value&nbsp;**fenceStatusChange**&nbsp;indicates&nbsp;a&nbsp;geofence&nbsp;status&nbsp;change. | | type | string | Yes| Event type. The value **fenceStatusChange** indicates a geofence status change.|
| request | GeofenceRequest | Yes | Geofencing&nbsp;request. | | request | GeofenceRequest | Yes| Geofencing request.|
| want | WantAgent | Yes | **WantAgent**&nbsp;used&nbsp;to&nbsp;return&nbsp;geofence&nbsp;(entrance&nbsp;or&nbsp;exit)&nbsp;events. | | want | WantAgent | Yes| **WantAgent** used to return geofence (entrance or exit) events.|
- Example - Example
...@@ -381,14 +431,17 @@ Unregisters the listener for status change events of the specified geofence. ...@@ -381,14 +431,17 @@ Unregisters the listener for status change events of the specified geofence.
getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback&lt;Location&gt;) : void getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback&lt;Location&gt;) : void
Obtains the current location. This method uses an asynchronous callback to return the result. Obtains the current location. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| request | [CurrentLocationRequest](#currentlocationrequest) | No | Location&nbsp;request. | | request | [CurrentLocationRequest](#currentlocationrequest) | No| Location request.|
| callback | AsyncCallback&lt;[Location](#location)&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;current&nbsp;location. | | callback | AsyncCallback&lt;[Location](#location)&gt; | Yes| Callback used to return the current location.|
- Example - Example
...@@ -407,18 +460,22 @@ Obtains the current location. This method uses an asynchronous callback to retur ...@@ -407,18 +460,22 @@ Obtains the current location. This method uses an asynchronous callback to retur
getCurrentLocation(request?: CurrentLocationRequest) : Promise&lt;Location&gt; getCurrentLocation(request?: CurrentLocationRequest) : Promise&lt;Location&gt;
Obtains the current location. This method uses a promise to return the result. Obtains the current location. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| request | [CurrentLocationRequest](#currentlocationrequest) | No | Location&nbsp;request. | | request | [CurrentLocationRequest](#currentlocationrequest) | No| Location request.|
- Return values - Return value
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[Location](#location)&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;current&nbsp;location. | | Promise&lt;[Location](#location)&gt; | Promise used to return the current location.|
- Example - Example
...@@ -434,12 +491,17 @@ Obtains the current location. This method uses a promise to return the result. ...@@ -434,12 +491,17 @@ Obtains the current location. This method uses a promise to return the result.
getLastLocation(callback: AsyncCallback&lt;Location&gt;) : void getLastLocation(callback: AsyncCallback&lt;Location&gt;) : void
Obtains the previous location. This method uses an asynchronous callback to return the result. Obtains the previous location. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[Location](#location)&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;previous&nbsp;location. | | callback | AsyncCallback&lt;[Location](#location)&gt; | Yes| Callback used to return the previous location.|
- Example - Example
...@@ -454,12 +516,17 @@ Obtains the previous location. This method uses an asynchronous callback to retu ...@@ -454,12 +516,17 @@ Obtains the previous location. This method uses an asynchronous callback to retu
getLastLocation() : Promise&lt;Location&gt; getLastLocation() : Promise&lt;Location&gt;
Obtains the previous location. This method uses a promise to return the result. Obtains the previous location. This API uses a promise to return the result.
- Return values **Permission required**: ohos.permission.LOCATION
| Name | Description |
**System capability**: SystemCapability.Location.Location.Core
- Return value
| Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[Location](#location)&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;previous&nbsp;location. | | Promise&lt;[Location](#location)&gt; | Promise used to return the previous location.|
- Example - Example
...@@ -475,13 +542,17 @@ Obtains the previous location. This method uses a promise to return the result. ...@@ -475,13 +542,17 @@ Obtains the previous location. This method uses a promise to return the result.
isLocationEnabled(callback: AsyncCallback&lt;boolean&gt;) : void isLocationEnabled(callback: AsyncCallback&lt;boolean&gt;) : void
Checks whether the location service is enabled. This method uses an asynchronous callback to return the result. Checks whether the location service is enabled. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;location&nbsp;service&nbsp;status. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the location service status.|
- Example - Example
...@@ -496,12 +567,16 @@ Checks whether the location service is enabled. This method uses an asynchronous ...@@ -496,12 +567,16 @@ Checks whether the location service is enabled. This method uses an asynchronous
isLocationEnabled() : Promise&lt;boolean&gt; isLocationEnabled() : Promise&lt;boolean&gt;
Checks whether the location service is enabled. This method uses a promise to return the result. Checks whether the location service is enabled. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
- Return values **System capability**: SystemCapability.Location.Location.Core
| Name | Description |
- Return value
| Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;location&nbsp;service&nbsp;status. | | Promise&lt;boolean&gt; | Promise used to return the location service status.|
- Example - Example
...@@ -517,13 +592,17 @@ Checks whether the location service is enabled. This method uses a promise to re ...@@ -517,13 +592,17 @@ Checks whether the location service is enabled. This method uses a promise to re
requestEnableLocation(callback: AsyncCallback&lt;boolean&gt;) : void requestEnableLocation(callback: AsyncCallback&lt;boolean&gt;) : void
Requests to enable the location service. This method uses an asynchronous callback to return the result. Requests to enable the location service. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;location&nbsp;service&nbsp;status. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the location service status.|
- Example - Example
...@@ -538,12 +617,17 @@ Requests to enable the location service. This method uses an asynchronous callba ...@@ -538,12 +617,17 @@ Requests to enable the location service. This method uses an asynchronous callba
requestEnableLocation() : Promise&lt;boolean&gt; requestEnableLocation() : Promise&lt;boolean&gt;
Requests to enable the location service. This method uses a promise to return the result. Requests to enable the location service. This API uses a promise to return the result.
- Return values **Permission required**: ohos.permission.LOCATION
| Name | Description |
**System capability**: SystemCapability.Location.Location.Core
- Return value
| Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;location&nbsp;service&nbsp;status. | | Promise&lt;boolean&gt; | Promise used to return the location service status.|
- Example - Example
...@@ -554,16 +638,127 @@ Requests to enable the location service. This method uses a promise to return th ...@@ -554,16 +638,127 @@ Requests to enable the location service. This method uses a promise to return th
``` ```
## geolocation.enableLocation
enableLocation(callback: AsyncCallback&lt;boolean&gt;) : void;
Enables the location service. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the location service status.|
- Example
```
geolocation.enableLocation((err, data) => {
console.log('enableLocation: ' + err + " data: " + data);
});
```
## geolocation.enableLocation
enableLocation() : Promise&lt;boolean&gt;
Enables the location service. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Return value
| Name| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the location service status.|
- Example
```
geolocation.enableLocation().then((result) => {
console.log('promise, enableLocation: ' + result);
});
```
## geolocation.disableLocation
disableLocation(callback: AsyncCallback&lt;boolean&gt;) : void;
Enables the location service. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the location service status.|
- Example
```
geolocation.disableLocation((err, data) => {
console.log('disableLocation: ' + err + " data: " + data);
});
```
## geolocation.disableLocation
disableLocation() : Promise&lt;boolean&gt;
Enables the location service. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Return value
| Name| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the location service status.|
- Example
```
geolocation.disableLocation().then((result) => {
console.log('promise, disableLocation: ' + result);
});
```
## geolocation.isGeoServiceAvailable ## geolocation.isGeoServiceAvailable
isGeoServiceAvailable(callback: AsyncCallback&lt;boolean&gt;) : void isGeoServiceAvailable(callback: AsyncCallback&lt;boolean&gt;) : void
Checks whether the (reverse) geocoding service is available. This method uses an asynchronous callback to return the result. Checks whether the (reverse) geocoding service is available. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geocoder
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;(reverse)&nbsp;geocoding&nbsp;service&nbsp;status. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the (reverse) geocoding service status.|
- Example - Example
...@@ -578,12 +773,17 @@ Checks whether the (reverse) geocoding service is available. This method uses an ...@@ -578,12 +773,17 @@ Checks whether the (reverse) geocoding service is available. This method uses an
isGeoServiceAvailable() : Promise&lt;boolean&gt; isGeoServiceAvailable() : Promise&lt;boolean&gt;
Checks whether the (reverse) geocoding service is available. This method uses a promise to return the result. Checks whether the (reverse) geocoding service is available. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geocoder
- Return values - Return value
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;(reverse)&nbsp;geocoding&nbsp;service&nbsp;status. | | Promise&lt;boolean&gt; | Promise used to return the (reverse) geocoding service status.|
- Example - Example
...@@ -599,13 +799,17 @@ Checks whether the (reverse) geocoding service is available. This method uses a ...@@ -599,13 +799,17 @@ Checks whether the (reverse) geocoding service is available. This method uses a
getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;) : void getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;) : void
Converts coordinates into geographic description through reverse geocoding. This method uses an asynchronous callback to return the result. Converts coordinates into geographic description through reverse geocoding. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geocoder
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes | Reverse&nbsp;geocoding&nbsp;request. | | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Reverse geocoding request.|
| callback | AsyncCallback&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;reverse&nbsp;geocoding&nbsp;result. | | callback | AsyncCallback&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Yes| Callback used to return the reverse geocoding result.|
- Example - Example
...@@ -621,17 +825,21 @@ Converts coordinates into geographic description through reverse geocoding. This ...@@ -621,17 +825,21 @@ Converts coordinates into geographic description through reverse geocoding. This
getAddressesFromLocation(request: ReverseGeoCodeRequest) : Promise&lt;Array&lt;GeoAddress&gt;&gt;; getAddressesFromLocation(request: ReverseGeoCodeRequest) : Promise&lt;Array&lt;GeoAddress&gt;&gt;;
Converts coordinates into geographic description through reverse geocoding. This method uses a promise to return the result. Converts coordinates into geographic description through reverse geocoding. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geocoder
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes | Reverse&nbsp;geocoding&nbsp;request. | | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Reverse geocoding request.|
- Return values - Return value
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;reverse&nbsp;geocoding&nbsp;result. | | Promise&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Promise used to return the reverse geocoding result.|
- Example - Example
...@@ -647,13 +855,18 @@ Converts coordinates into geographic description through reverse geocoding. This ...@@ -647,13 +855,18 @@ Converts coordinates into geographic description through reverse geocoding. This
getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;) : void getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;) : void
Converts geographic description into coordinates through geocoding. This method uses an asynchronous callback to return the result. Converts geographic description into coordinates through geocoding. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geocoder
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| request | [GeoCodeRequest](#geocoderequest) | Yes | Geocoding&nbsp;request. | | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.|
| callback | AsyncCallback&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;geocoding&nbsp;result. | | callback | AsyncCallback&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Yes| Callback used to return the geocoding result.|
- Example - Example
...@@ -669,17 +882,21 @@ Converts geographic description into coordinates through geocoding. This method ...@@ -669,17 +882,21 @@ Converts geographic description into coordinates through geocoding. This method
getAddressesFromLocationName(request: GeoCodeRequest) : Promise&lt;Array&lt;GeoAddress&gt;&gt; getAddressesFromLocationName(request: GeoCodeRequest) : Promise&lt;Array&lt;GeoAddress&gt;&gt;
Converts geographic description into coordinates through geocoding. This method uses a promise to return the result. Converts geographic description into coordinates through geocoding. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geocoder
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| request | [GeoCodeRequest](#geocoderequest) | Yes | Geocoding&nbsp;request. | | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.|
- Return values - Return value
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;geocoding&nbsp;result. | | Promise&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Callback used to return the geocoding result.|
- Example - Example
...@@ -692,16 +909,20 @@ Converts geographic description into coordinates through geocoding. This method ...@@ -692,16 +909,20 @@ Converts geographic description into coordinates through geocoding. This method
## geolocation.getCachedGnssLocationsSize ## geolocation.getCachedGnssLocationsSize<sup>8+</sup>
getCachedGnssLocationsSize(callback: AsyncCallback&lt;number&gt;) : void; getCachedGnssLocationsSize(callback: AsyncCallback&lt;number&gt;) : void;
Obtains the number of cached GNSS locations. Obtains the number of cached GNSS locations.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Gnss
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;number&nbsp;of&nbsp;cached&nbsp;GNSS&nbsp;locations. | | callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the number of cached GNSS locations. |
- Example - Example
...@@ -712,16 +933,20 @@ Obtains the number of cached GNSS locations. ...@@ -712,16 +933,20 @@ Obtains the number of cached GNSS locations.
``` ```
## geolocation.getCachedGnssLocationsSize ## geolocation.getCachedGnssLocationsSize<sup>8+</sup>
getCachedGnssLocationsSize() : Promise&lt;number&gt;; getCachedGnssLocationsSize() : Promise&lt;number&gt;;
Obtains the number of cached GNSS locations. Obtains the number of cached GNSS locations.
- Return values **Permission required**: ohos.permission.LOCATION
| Name | Description |
**System capability**: SystemCapability.Location.Location.Gnss
- Return value
| Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;number&nbsp;of&nbsp;cached&nbsp;GNSS&nbsp;locations. | | Promise&lt;number&gt; | Promise used to return the number of cached GNSS locations.|
- Example - Example
...@@ -732,16 +957,20 @@ Obtains the number of cached GNSS locations. ...@@ -732,16 +957,20 @@ Obtains the number of cached GNSS locations.
``` ```
## geolocation.flushCachedGnssLocations ## geolocation.flushCachedGnssLocations<sup>8+</sup>
flushCachedGnssLocations(callback: AsyncCallback&lt;boolean&gt;) : void; flushCachedGnssLocations(callback: AsyncCallback&lt;boolean&gt;) : void;
Obtains all cached GNSS locations and clears the GNSS cache queue. Obtains all cached GNSS locations and clears the GNSS cache queue.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Gnss
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;operation&nbsp;result. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the operation result.|
- Example - Example
...@@ -752,16 +981,20 @@ Obtains all cached GNSS locations and clears the GNSS cache queue. ...@@ -752,16 +981,20 @@ Obtains all cached GNSS locations and clears the GNSS cache queue.
``` ```
## geolocation.flushCachedGnssLocations ## geolocation.flushCachedGnssLocations<sup>8+</sup>
flushCachedGnssLocations() : Promise&lt;boolean&gt;; flushCachedGnssLocations() : Promise&lt;boolean&gt;;
Obtains all cached GNSS locations and clears the GNSS cache queue. Obtains all cached GNSS locations and clears the GNSS cache queue.
- Return values **Permission required**: ohos.permission.LOCATION
| Name | Description |
**System capability**: SystemCapability.Location.Location.Gnss
- Return value
| Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;operation&nbsp;result. | | Promise&lt;boolean&gt; | Promise used to return the operation result.|
- Example - Example
...@@ -772,17 +1005,21 @@ Obtains all cached GNSS locations and clears the GNSS cache queue. ...@@ -772,17 +1005,21 @@ Obtains all cached GNSS locations and clears the GNSS cache queue.
``` ```
## geolocation.sendCommand ## geolocation.sendCommand<sup>8+</sup>
sendCommand(command: LocationCommand, callback: AsyncCallback&lt;boolean&gt;) : void; sendCommand(command: LocationCommand, callback: AsyncCallback&lt;boolean&gt;) : void;
Sends an extended command to the location subsystem. This function can only be called by system applications. Sends an extended command to the location subsystem. This API can only be called by system applications.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| command | LocationCommand | Yes | Extended&nbsp;command&nbsp;(string)&nbsp;to&nbsp;be&nbsp;sent. | | command | LocationCommand | Yes| Extended command (string) to be sent.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;operation&nbsp;result. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the operation result.|
- Example - Example
...@@ -794,21 +1031,25 @@ Sends an extended command to the location subsystem. This function can only be c ...@@ -794,21 +1031,25 @@ Sends an extended command to the location subsystem. This function can only be c
``` ```
## geolocation.sendCommand ## geolocation.sendCommand<sup>8+</sup>
sendCommand(command: LocationCommand) : Promise&lt;boolean&gt;; sendCommand(command: LocationCommand) : Promise&lt;boolean&gt;;
Sends extended commands to the location subsystem. This function can only be called by system applications. Sends an extended command to the location subsystem. This API can only be called by system applications.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| command | LocationCommand | Yes | Extended&nbsp;command&nbsp;(string)&nbsp;to&nbsp;be&nbsp;sent. | | command | LocationCommand | Yes| Extended command (string) to be sent.|
- Return values - Return value
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;operation&nbsp;result. | | Promise&lt;boolean&gt; | Callback used to return the operation result.|
- Example - Example
...@@ -820,17 +1061,23 @@ Sends extended commands to the location subsystem. This function can only be cal ...@@ -820,17 +1061,23 @@ Sends extended commands to the location subsystem. This function can only be cal
``` ```
## geolocation.isLocationPrivacyConfirmed ## geolocation.isLocationPrivacyConfirmed<sup>8+</sup>
isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback&lt;boolean&gt;) : void; isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback&lt;boolean&gt;) : void;
Checks whether a user agrees with the privacy statement of the location service. This function can only be called by system applications. Checks whether a user agrees with the privacy statement of the location service. This API can only be called by system applications.
This is a system API and cannot be called by third-party applications.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | LocationPrivacyType | Yes | Privacy&nbsp;statement&nbsp;type,&nbsp;for&nbsp;example,&nbsp;privacy&nbsp;statement&nbsp;displayed&nbsp;in&nbsp;the&nbsp;startup&nbsp;wizard&nbsp;or&nbsp;privacy&nbsp;statement&nbsp;displayed&nbsp;when&nbsp;enabling&nbsp;the&nbsp;location&nbsp;service. | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result,&nbsp;which&nbsp;indicates&nbsp;whether&nbsp;the&nbsp;user&nbsp;agrees&nbsp;with&nbsp;the&nbsp;privacy&nbsp;statement. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.|
- Example - Example
...@@ -841,21 +1088,27 @@ Checks whether a user agrees with the privacy statement of the location service. ...@@ -841,21 +1088,27 @@ Checks whether a user agrees with the privacy statement of the location service.
``` ```
## geolocation.isLocationPrivacyConfirmed ## geolocation.isLocationPrivacyConfirmed<sup>8+</sup>
isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise&lt;boolean&gt;; isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise&lt;boolean&gt;;
Checks whether a user agrees with the privacy statement of the location service. This function can only be called by system applications. Checks whether a user agrees with the privacy statement of the location service. This API can only be called by system applications.
This is a system API and cannot be called by third-party applications.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | LocationPrivacyType | Yes | Privacy&nbsp;statement&nbsp;type,&nbsp;for&nbsp;example,&nbsp;privacy&nbsp;statement&nbsp;displayed&nbsp;in&nbsp;the&nbsp;startup&nbsp;wizard&nbsp;or&nbsp;privacy&nbsp;statement&nbsp;displayed&nbsp;when&nbsp;enabling&nbsp;the&nbsp;location&nbsp;service. | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.|
- Return values - Return value
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result,&nbsp;which&nbsp;indicates&nbsp;whether&nbsp;the&nbsp;user&nbsp;agrees&nbsp;with&nbsp;the&nbsp;privacy&nbsp;statement. | | Promise&lt;boolean&gt; | Callback used to return the result, which indicates whether the user agrees with the privacy statement.|
- Example - Example
...@@ -866,18 +1119,24 @@ Checks whether a user agrees with the privacy statement of the location service. ...@@ -866,18 +1119,24 @@ Checks whether a user agrees with the privacy statement of the location service.
``` ```
## geolocation.setLocationPrivacyConfirmStatus ## geolocation.setLocationPrivacyConfirmStatus<sup>8+</sup>
setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback&lt;boolean&gt;) : void; setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback&lt;boolean&gt;) : void;
Sets the user confirmation status for the privacy statement of the location service. This function can only be called by system applications. Sets the user confirmation status for the privacy statement of the location service. This API can only be called by system applications.
This is a system API and cannot be called by third-party applications.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | LocationPrivacyType | Yes | Privacy&nbsp;statement&nbsp;type,&nbsp;for&nbsp;example,&nbsp;privacy&nbsp;statement&nbsp;displayed&nbsp;in&nbsp;the&nbsp;startup&nbsp;wizard&nbsp;or&nbsp;privacy&nbsp;statement&nbsp;displayed&nbsp;when&nbsp;enabling&nbsp;the&nbsp;location&nbsp;service. | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.|
| isConfirmed | boolean | Yes | Whether&nbsp;the&nbsp;user&nbsp;agrees&nbsp;with&nbsp;the&nbsp;privacy&nbsp;statement&nbsp;of&nbsp;the&nbsp;location&nbsp;service. | | isConfirmed | boolean | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;operation&nbsp;result. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the operation result.|
- Example - Example
...@@ -888,22 +1147,28 @@ Sets the user confirmation status for the privacy statement of the location serv ...@@ -888,22 +1147,28 @@ Sets the user confirmation status for the privacy statement of the location serv
``` ```
## geolocation.setLocationPrivacyConfirmStatus ## geolocation.setLocationPrivacyConfirmStatus<sup>8+</sup>
setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise&lt;boolean&gt;; setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise&lt;boolean&gt;;
Sets the user confirmation status for the privacy statement of the location service. This function can only be called by system applications. Sets the user confirmation status for the privacy statement of the location service. This API can only be called by system applications.
This is a system API and cannot be called by third-party applications.
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | LocationPrivacyType | Yes | Privacy&nbsp;statement&nbsp;type,&nbsp;for&nbsp;example,&nbsp;privacy&nbsp;statement&nbsp;displayed&nbsp;in&nbsp;the&nbsp;startup&nbsp;wizard&nbsp;or&nbsp;privacy&nbsp;statement&nbsp;displayed&nbsp;when&nbsp;enabling&nbsp;the&nbsp;location&nbsp;service. | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.|
| isConfirmed | boolean | Yes | Whether&nbsp;the&nbsp;user&nbsp;agrees&nbsp;with&nbsp;the&nbsp;privacy&nbsp;statement&nbsp;of&nbsp;the&nbsp;location&nbsp;service. | | isConfirmed | boolean | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.|
- Return values - Return value
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;operation&nbsp;result. | | Promise&lt;boolean&gt; | Callback used to return the operation result.|
- Example - Example
...@@ -919,201 +1184,262 @@ Sets the user confirmation status for the privacy statement of the location serv ...@@ -919,201 +1184,262 @@ Sets the user confirmation status for the privacy statement of the location serv
Sets the priority of the location request. Sets the priority of the location request.
| Name | Default&nbsp;Value | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
| Name| Default Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| UNSET | 0x200 | Priority&nbsp;unspecified. | | UNSET | 0x200 | Priority unspecified.|
| ACCURACY | 0x201 | Location&nbsp;accuracy. | | ACCURACY | 0x201 | Location accuracy.|
| LOW_POWER | 0x202 | Power&nbsp;efficiency. | | LOW_POWER | 0x202 | Power efficiency.|
| FIRST_FIX | 0x203 | Fast&nbsp;location.&nbsp;Use&nbsp;this&nbsp;option&nbsp;if&nbsp;you&nbsp;want&nbsp;to&nbsp;obtain&nbsp;a&nbsp;location&nbsp;as&nbsp;fast&nbsp;as&nbsp;possible. | | FIRST_FIX | 0x203 | Fast location. Use this option if you want to obtain a location as fast as possible.|
## LocationRequestScenario ## LocationRequestScenario
Sets the scenario of the location request. Sets the scenario of the location request.
| Name | Default&nbsp;Value | Description |
**Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
| Name| Default Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| UNSET | 0x300 | Scenario&nbsp;unspecified. | | UNSET | 0x300 | Scenario unspecified.|
| NAVIGATION | 0x301 | Navigation. | | NAVIGATION | 0x301 | Navigation.|
| TRAJECTORY_TRACKING | 0x302 | Trajectory&nbsp;tracking. | | TRAJECTORY_TRACKING | 0x302 | Trajectory tracking.|
| CAR_HAILING | 0x303 | Ride&nbsp;hailing. | | CAR_HAILING | 0x303 | Ride hailing.|
| DAILY_LIFE_SERVICE | 0x304 | Daily&nbsp;life&nbsp;services. | | DAILY_LIFE_SERVICE | 0x304 | Daily life services.|
| NO_POWER | 0x305 | Power&nbsp;efficiency.&nbsp;Your&nbsp;application&nbsp;does&nbsp;not&nbsp;proactively&nbsp;start&nbsp;the&nbsp;location&nbsp;service.&nbsp;When&nbsp;responding&nbsp;to&nbsp;another&nbsp;application&nbsp;requesting&nbsp;the&nbsp;same&nbsp;location&nbsp;service,&nbsp;the&nbsp;system&nbsp;marks&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;location&nbsp;result&nbsp;to&nbsp;your&nbsp;application.&nbsp;In&nbsp;this&nbsp;way,&nbsp;your&nbsp;application&nbsp;will&nbsp;not&nbsp;consume&nbsp;extra&nbsp;power&nbsp;for&nbsp;obtaining&nbsp;the&nbsp;user&nbsp;location. | | NO_POWER | 0x305 | Power efficiency. Your application does not proactively start the location service. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.|
## GeoLocationErrorCode ## GeoLocationErrorCode
Enumerates error codes of the location service. Enumerates error codes of the location service.
| Name | Default&nbsp;Value | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
| Name| Default Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| INPUT_PARAMS_ERROR | 101 | Incorrect&nbsp;input&nbsp;parameters. | | INPUT_PARAMS_ERROR | 101 | Incorrect input parameters.|
| REVERSE_GEOCODE_ERROR | 102 | Failed&nbsp;to&nbsp;call&nbsp;the&nbsp;reverse&nbsp;geocoding&nbsp;API. | | REVERSE_GEOCODE_ERROR | 102 | Failed to call the reverse geocoding API.|
| GEOCODE_ERROR | 103 | Failed&nbsp;to&nbsp;call&nbsp;the&nbsp;geocoding&nbsp;API. | | GEOCODE_ERROR | 103 | Failed to call the geocoding API.|
| LOCATOR_ERROR | 104 | Failed&nbsp;to&nbsp;obtain&nbsp;the&nbsp;location. | | LOCATOR_ERROR | 104 | Failed to obtain the location.|
| LOCATION_SWITCH_ERROR | 105 | Failed&nbsp;to&nbsp;change&nbsp;the&nbsp;location&nbsp;service&nbsp;switch. | | LOCATION_SWITCH_ERROR | 105 | Failed to change the location service switch.|
| LAST_KNOWN_LOCATION_ERROR | 106 | Failed&nbsp;to&nbsp;obtain&nbsp;the&nbsp;previous&nbsp;location. | | LAST_KNOWN_LOCATION_ERROR | 106 | Failed to obtain the previous location.|
| LOCATION_REQUEST_TIMEOUT_ERROR | 107 | Failed&nbsp;to&nbsp;obtain&nbsp;the&nbsp;location&nbsp;within&nbsp;the&nbsp;specified&nbsp;time. | | LOCATION_REQUEST_TIMEOUT_ERROR | 107 | Failed to obtain the location within the specified time.|
## ReverseGeoCodeRequest ## ReverseGeoCodeRequest
Defines a reverse geocoding request. Defines a reverse geocoding request.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geocoder
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string | No | Language&nbsp;used&nbsp;for&nbsp;the&nbsp;location&nbsp;description.&nbsp;**zh**&nbsp;indicates&nbsp;Chinese,&nbsp;and&nbsp;**en**&nbsp;indicates&nbsp;English. | | locale | string | No| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| latitude | number | Yes | Latitude&nbsp;information.&nbsp;A&nbsp;positive&nbsp;value&nbsp;indicates&nbsp;north&nbsp;latitude,&nbsp;and&nbsp;a&nbsp;negative&nbsp;value&nbsp;indicates&nbsp;south&nbsp;latitude. | | latitude | number | Yes| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
| longitude | number | Yes | Longitude&nbsp;information.&nbsp;A&nbsp;positive&nbsp;value&nbsp;indicates&nbsp;east&nbsp;longitude&nbsp;,&nbsp;and&nbsp;a&nbsp;negative&nbsp;value&nbsp;indicates&nbsp;west&nbsp;longitude&nbsp;. | | longitude | number | Yes| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .|
| maxItems | number | No | Maximum&nbsp;number&nbsp;of&nbsp;location&nbsp;records&nbsp;to&nbsp;be&nbsp;returned. | | maxItems | number | No| Maximum number of location records to be returned.|
## GeoCodeRequest ## GeoCodeRequest
Defines a geocoding request. Defines a geocoding request.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geocoder
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string | No | Language&nbsp;used&nbsp;for&nbsp;the&nbsp;location&nbsp;description.&nbsp;**zh**&nbsp;indicates&nbsp;Chinese,&nbsp;and&nbsp;**en**&nbsp;indicates&nbsp;English. | | locale | string | No| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| description | number | Yes | Location&nbsp;description,&nbsp;for&nbsp;example,&nbsp;**No.&nbsp;xx,&nbsp;xx&nbsp;Road,&nbsp;Pudong&nbsp;New&nbsp;District,&nbsp;Shanghai**. | | description | number | Yes| Location description, for example, No. xx, xx Road, Pudong New District, Shanghai.|
| maxItems | number | No | Maximum&nbsp;number&nbsp;of&nbsp;location&nbsp;records&nbsp;to&nbsp;be&nbsp;returned. | | maxItems | number | No| Maximum number of location records to be returned.|
| minLatitude | number | No | Minimum&nbsp;latitude.&nbsp;This&nbsp;parameter&nbsp;is&nbsp;used&nbsp;with&nbsp;**minLongitude**,&nbsp;**maxLatitude**,&nbsp;and&nbsp;**maxLongitude**&nbsp;to&nbsp;specify&nbsp;the&nbsp;latitude&nbsp;and&nbsp;longitude&nbsp;ranges. | | minLatitude | number | No| Minimum latitude. This parameter is used with minLongitude, maxLatitude, and maxLongitude to specify the latitude and longitude ranges.|
| minLongitude | number | No | Minimum&nbsp;longitude. | | minLongitude | number | No| Minimum longitude.|
| maxLatitude | number | No | Maximum&nbsp;latitude. | | maxLatitude | number | No| Maximum latitude.|
| maxLongitude | number | No | Maximum&nbsp;longitude. | | maxLongitude | number | No| Maximum longitude.|
## GeoAddress ## GeoAddress
Defines a geographic location. Defines a geographic location.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geocoder
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| latitude | number | No | Latitude&nbsp;information.&nbsp;A&nbsp;positive&nbsp;value&nbsp;indicates&nbsp;north&nbsp;latitude,&nbsp;and&nbsp;a&nbsp;negative&nbsp;value&nbsp;indicates&nbsp;south&nbsp;latitude. | | latitude | number | No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
| longitude | number | No | Longitude&nbsp;information.&nbsp;A&nbsp;positive&nbsp;value&nbsp;indicates&nbsp;east&nbsp;longitude&nbsp;,&nbsp;and&nbsp;a&nbsp;negative&nbsp;value&nbsp;indicates&nbsp;west&nbsp;longitude&nbsp;. | | longitude | number | No| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .|
| locale | string | No | Language&nbsp;used&nbsp;for&nbsp;the&nbsp;location&nbsp;description.&nbsp;**zh**&nbsp;indicates&nbsp;Chinese,&nbsp;and&nbsp;**en**&nbsp;indicates&nbsp;English. | | locale | string | No| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| placeName | string | No | Landmark&nbsp;of&nbsp;the&nbsp;location. | | placeName | string | No| Landmark of the location.|
| countryCode | string | No | Country&nbsp;code. | | countryCode | string | No| Country code.|
| countryName | string | No | Country&nbsp;name. | | countryName | string | No| Country name.|
| administrativeArea | string | No | Administrative&nbsp;region&nbsp;name. | | administrativeArea | string | No| Administrative region name.|
| subAdministrativeArea | string | No | Sub-administrative&nbsp;region&nbsp;name. | | subAdministrativeArea | string | No| Sub-administrative region name.|
| locality | string | No | Locality&nbsp;information. | | locality | string | No| Locality information. |
| subLocality | string | No | Sub-locality&nbsp;information. | | subLocality | string | No| Sub-locality information. |
| roadName | string | No | Road&nbsp;name. | | roadName | string | No| Road name.|
| subRoadName | string | No | Auxiliary&nbsp;road&nbsp;information. | | subRoadName | string | No| Auxiliary road information.|
| premises | string | No | House&nbsp;information. | | premises | string | No| House information.|
| postalCode | string | No | Postal&nbsp;code. | | postalCode | string | No| Postal code.|
| phoneNumber | string | No | Phone&nbsp;number. | | phoneNumber | string | No| Phone number.|
| addressUrl | string | No | Website&nbsp;URL. | | addressUrl | string | No| Website URL.|
| descriptions | Array&lt;string&gt; | No | Additional&nbsp;description. | | descriptions | Array&lt;string&gt; | No| Additional description.|
| descriptionsSize | number | No | Total&nbsp;number&nbsp;of&nbsp;additional&nbsp;descriptions. | | descriptionsSize | number | No| Total number of additional descriptions.|
## LocationRequest ## LocationRequest
Defines a location request. Defines a location request.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| priority | [LocationRequestPriority](#locationrequestpriority) | No | Priority&nbsp;of&nbsp;the&nbsp;location&nbsp;request. | | priority | [LocationRequestPriority](#locationrequestpriority) | No| Priority of the location request.|
| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes | Scenario&nbsp;of&nbsp;the&nbsp;location&nbsp;request. | | scenario | [LocationRequestScenario](#locationrequestscenario) | Yes| Scenario of the location request.|
| timeInterval | number | No | Time&nbsp;interval&nbsp;at&nbsp;which&nbsp;location&nbsp;information&nbsp;is&nbsp;reported. | | timeInterval | number | No| Time interval at which location information is reported.|
| distanceInterval | number | No | Distance&nbsp;interval&nbsp;at&nbsp;which&nbsp;location&nbsp;information&nbsp;is&nbsp;reported. | | distanceInterval | number | No| Distance interval at which location information is reported.|
| maxAccuracy | number | No | Location&nbsp;accuracy. | | maxAccuracy | number | No| Location accuracy.|
## CurrentLocationRequest ## CurrentLocationRequest
Defines the current location request. Defines the current location request.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| priority | [LocationRequestPriority](#locationrequestpriority) | No | Priority&nbsp;of&nbsp;the&nbsp;location&nbsp;request. | | priority | [LocationRequestPriority](#locationrequestpriority) | No| Priority of the location request.|
| scenario | [LocationRequestScenario](#locationrequestscenario) | No | Scenario&nbsp;of&nbsp;the&nbsp;location&nbsp;request. | | scenario | [LocationRequestScenario](#locationrequestscenario) | No| Scenario of the location request.|
| maxAccuracy | number | No | Location&nbsp;accuracy,&nbsp;in&nbsp;meters. | | maxAccuracy | number | No| Location accuracy, in meters.|
| timeoutMs | number | No | Timeout&nbsp;duration,&nbsp;in&nbsp;milliseconds.&nbsp;The&nbsp;minimum&nbsp;value&nbsp;is&nbsp;**1000**. | | timeoutMs | number | No| Timeout duration, in milliseconds. The minimum value is 1000.|
## SatelliteStatusInfo ## SatelliteStatusInfo<sup>8+</sup>
Defines the satellite status information. Defines the satellite status information.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Gnss
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| satellitesNumber | number | Yes | Number&nbsp;of&nbsp;satellites. | | satellitesNumber | number | Yes| Number of satellites.|
| satelliteIds | Array&lt;number&gt; | Yes | Array&nbsp;of&nbsp;satellite&nbsp;IDs. | | satelliteIds | Array&lt;number&gt; | Yes| Array of satellite IDs.|
| carrierToNoiseDensitys | Array&lt;number&gt; | Yes | Carrier-to-noise&nbsp;density&nbsp;ratio,&nbsp;that&nbsp;is,&nbsp;cn0. | | carrierToNoiseDensitys | Array&lt;number&gt; | Yes| Carrier-to-noise density ratio, that is, **cn0**.|
| altitudes | Array&lt;number&gt; | Yes | Altitude&nbsp;information. | | altitudes | Array&lt;number&gt; | Yes| Altitude information.|
| azimuths | Array&lt;number&gt; | Yes | Azimuth&nbsp;information. | | azimuths | Array&lt;number&gt; | Yes| Azimuth information.|
| carrierFrequencies | Array&lt;number&gt; | Yes | Carrier&nbsp;frequency. | | carrierFrequencies | Array&lt;number&gt; | Yes| Carrier frequency.|
## CachedGnssLocationsRequest ## CachedGnssLocationsRequest<sup>8+</sup>
Represents a request for reporting cached GNSS locations. Represents a request for reporting cached GNSS locations.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Gnss
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| reportingPeriodSec | number | Yes | Interval&nbsp;for&nbsp;reporting&nbsp;the&nbsp;cached&nbsp;GNSS&nbsp;locations,&nbsp;in&nbsp;milliseconds. | | reportingPeriodSec | number | Yes| Interval for reporting the cached GNSS locations, in milliseconds.|
| wakeUpCacheQueueFull | boolean | Yes | **true**:&nbsp;reports&nbsp;the&nbsp;cached&nbsp;GNSS&nbsp;locations&nbsp;to&nbsp;the&nbsp;application&nbsp;when&nbsp;the&nbsp;cache&nbsp;queue&nbsp;is&nbsp;full.<br/>**false**:&nbsp;discards&nbsp;the&nbsp;cached&nbsp;GNSS&nbsp;locations&nbsp;when&nbsp;the&nbsp;cache&nbsp;queue&nbsp;is&nbsp;full. | | wakeUpCacheQueueFull | boolean | Yes| **true**: reports the cached GNSS locations to the application when the cache queue is full.<br>**false**: discards the cached GNSS locations when the cache queue is full.|
## Geofence ## Geofence<sup>8+</sup>
Defines a GNSS geofence. Currently, only circular geofences are supported. Defines a GNSS geofence. Currently, only circular geofences are supported.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geofence
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| latitude | number | Yes | Latitude&nbsp;information. | | latitude | number | Yes| Latitude information.|
| longitude | number | Yes | Longitude&nbsp;information. | | longitude | number | Yes| Longitude information.|
| radius | number | Yes | Radius&nbsp;of&nbsp;a&nbsp;circular&nbsp;geofence. | | radius | number | Yes| Radius of a circular geofence.|
| expiration | number | Yes | Expiration&nbsp;period&nbsp;of&nbsp;a&nbsp;geofence,&nbsp;in&nbsp;milliseconds. | | expiration | number | Yes| Expiration period of a geofence, in milliseconds.|
## GeofenceRequest ## GeofenceRequest<sup>8+</sup>
Represents a GNSS geofencing request. Represents a GNSS geofencing request.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Geofence
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| priority | LocationRequestPriority | Yes | Priority&nbsp;of&nbsp;the&nbsp;location&nbsp;information. | | priority | LocationRequestPriority | Yes| Priority of the location information.|
| scenario | LocationRequestScenario | Yes | Location&nbsp;scenario. | | scenario | LocationRequestScenario | Yes| Location scenario.|
| geofence | Geofence | Yes | Geofence&nbsp;information. | | geofence | Geofence | Yes| Geofence information.|
## LocationPrivacyType ## LocationPrivacyType<sup>8+</sup>
Defines the privacy statement type. Defines the privacy statement type.
| Name | Default&nbsp;Value | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
| Name| Default Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| OTHERS | 0 | Other&nbsp;scenarios. | | OTHERS | 0 | Other scenarios.|
| STARTUP | 1 | Privacy&nbsp;statement&nbsp;displayed&nbsp;in&nbsp;the&nbsp;startup&nbsp;wizard. | | STARTUP | 1 | Privacy statement displayed in the startup wizard.|
| CORE_LOCATION | 2 | Privacy&nbsp;statement&nbsp;displayed&nbsp;when&nbsp;enabling&nbsp;the&nbsp;location&nbsp;service. | | CORE_LOCATION | 2 | Privacy statement displayed when enabling the location service.|
## LocationCommand ## LocationCommand<sup>8+</sup>
Defines an extended command. Defines an extended command.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| scenario | LocationRequestScenario | Yes | Location&nbsp;scenario. | | scenario | LocationRequestScenario | Yes| Location scenario.|
| command | string | Yes | Extended&nbsp;command,&nbsp;in&nbsp;the&nbsp;string&nbsp;format. | | command | string | Yes| Extended command, in the string format.|
## Location ## Location
Defines a location. Defines a location.
| Name | Type | Mandatory | Description | **Permission required**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Core
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| latitude | number | Yes | Latitude&nbsp;information.&nbsp;A&nbsp;positive&nbsp;value&nbsp;indicates&nbsp;north&nbsp;latitude,&nbsp;and&nbsp;a&nbsp;negative&nbsp;value&nbsp;indicates&nbsp;south&nbsp;latitude. | | latitude | number | Yes| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
| longitude | number | Yes | Longitude&nbsp;information.&nbsp;A&nbsp;positive&nbsp;value&nbsp;indicates&nbsp;east&nbsp;longitude&nbsp;,&nbsp;and&nbsp;a&nbsp;negative&nbsp;value&nbsp;indicates&nbsp;west&nbsp;longitude&nbsp;. | | longitude | number | Yes| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .|
| altitude | number | Yes | Location&nbsp;altitude,&nbsp;in&nbsp;meters. | | altitude | number | Yes| Location altitude, in meters.|
| accuracy | number | Yes | Location&nbsp;accuracy,&nbsp;in&nbsp;meters. | | accuracy | number | Yes| Location accuracy, in meters.|
| speed | number | Yes | Speed,&nbsp;in&nbsp;m/s. | | speed | number | Yes| Speed, in m/s.|
| timeStamp | number | Yes | Location&nbsp;timestamp&nbsp;in&nbsp;the&nbsp;UTC&nbsp;format. | | timeStamp | number | Yes| Location timestamp in the UTC format.|
| direction | number | Yes | Direction&nbsp;information. | | direction | number | Yes| Direction information.|
| timeSinceBoot | number | Yes | Location&nbsp;timestamp&nbsp;since&nbsp;boot. | | timeSinceBoot | number | Yes| Location timestamp since boot.|
| additions | Array&lt;string&gt; | No | Additional&nbsp;description. | | additions | Array&lt;string&gt; | No| Additional information.|
| additionSize | number | No | Number&nbsp;of&nbsp;additional&nbsp;descriptions. | | additionSize | number | No| Number of additional descriptions.|
...@@ -21,19 +21,19 @@ Obtains the localized script for the specified language. ...@@ -21,19 +21,19 @@ Obtains the localized script for the specified language.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------------ | ------- | ---- | ---------------- |
| language | string | Yes| Specified language.| | language | string | Yes | Specified language. |
| locale | string | Yes| Locale ID.| | locale | string | Yes | Locale ID. |
| sentenceCase | boolean | No| Whether to use sentence case for the localized script.| | sentenceCase | boolean | No | Whether to use sentence case for the localized script.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------- |
| string | Localized script for the specified language.| | string | Localized script for the specified language.|
- Example **Example**
``` ```
i18n.getDisplayLanguage("zh", "en-GB", true); i18n.getDisplayLanguage("zh", "en-GB", true);
i18n.getDisplayLanguage("zh", "en-GB"); i18n.getDisplayLanguage("zh", "en-GB");
...@@ -48,19 +48,19 @@ Obtains the localized script for the specified country. ...@@ -48,19 +48,19 @@ Obtains the localized script for the specified country.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------------ | ------- | ---- | ---------------- |
| country | string | Yes| Specified country.| | country | string | Yes | Specified country. |
| locale | string | Yes| Locale ID.| | locale | string | Yes | Locale ID. |
| sentenceCase | boolean | No| Whether to use sentence case for the localized script.| | sentenceCase | boolean | No | Whether to use sentence case for the localized script.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------- |
| string | Localized script for the specified country.| | string | Localized script for the specified country.|
- Example **Example**
``` ```
i18n.getDisplayCountry("zh-CN", "en-GB", true); i18n.getDisplayCountry("zh-CN", "en-GB", true);
i18n.getDisplayCountry("zh-CN", "en-GB"); i18n.getDisplayCountry("zh-CN", "en-GB");
...@@ -75,17 +75,17 @@ Checks whether the localized script for the specified language is displayed from ...@@ -75,17 +75,17 @@ Checks whether the localized script for the specified language is displayed from
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Description| | Name | Type | Description |
| -------- | -------- | -------- | | ------ | ------ | ------- |
| locale | string | Locale ID.| | locale | string | Locale ID.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.| | boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.|
- Example **Example**
``` ```
i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned. i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned.
i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned. i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned.
...@@ -100,12 +100,12 @@ Obtains the system language. ...@@ -100,12 +100,12 @@ Obtains the system language.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------- |
| string | System language ID.| | string | System language ID.|
- Example **Example**
``` ```
i18n.getSystemLanguage(); i18n.getSystemLanguage();
``` ```
...@@ -117,19 +117,21 @@ setSystemLanguage(language: string): boolean ...@@ -117,19 +117,21 @@ setSystemLanguage(language: string): boolean
Sets the system language. Sets the system language.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Description| | Name | Type | Description |
| -------- | -------- | -------- | | -------- | ------ | ----- |
| language | string | Language ID.| | language | string | Language ID.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example **Example**
``` ```
i18n.setSystemLanguage('zh'); i18n.setSystemLanguage('zh');
``` ```
...@@ -137,18 +139,18 @@ Sets the system language. ...@@ -137,18 +139,18 @@ Sets the system language.
## i18n.getSystemLanguages ## i18n.getSystemLanguages
getSystemLanguages(): Array<string> getSystemLanguages(): Array&lt;string&gt;
Obtains the list of system languages. Obtains the list of system languages.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------- | ------------ |
| Array<string> | List of the IDs of system languages.| | Array&lt;string&gt; | List of the IDs of system languages.|
- Example **Example**
``` ```
i18n.getSystemLanguages(); i18n.getSystemLanguages();
``` ```
...@@ -156,23 +158,23 @@ Obtains the list of system languages. ...@@ -156,23 +158,23 @@ Obtains the list of system languages.
## i18n.getSystemCountries ## i18n.getSystemCountries
getSystemCountries(language: string): Array<string> getSystemCountries(language: string): Array&lt;string&gt;
Obtains the list of countries and regions supported for the specified language. Obtains the list of countries and regions supported for the specified language.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Description| | Name | Type | Description |
| -------- | -------- | -------- | | -------- | ------ | ----- |
| language | string | Language ID.| | language | string | Language ID.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------- | ------------ |
| Array<string> | List of the IDs of the countries and regions supported for the specified language.| | Array&lt;string&gt; | List of the IDs of the countries and regions supported for the specified language.|
- Example **Example**
``` ```
i18n.getSystemCountries('zh'); i18n.getSystemCountries('zh');
``` ```
...@@ -186,12 +188,12 @@ Obtains the system region. ...@@ -186,12 +188,12 @@ Obtains the system region.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------- |
| string | System region ID.| | string | System region ID.|
- Example **Example**
``` ```
i18n.getSystemRegion(); i18n.getSystemRegion();
``` ```
...@@ -203,19 +205,21 @@ setSystemRegion(region: string): boolean ...@@ -203,19 +205,21 @@ setSystemRegion(region: string): boolean
Sets the system region. Sets the system region.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Description| | Name | Type | Description |
| -------- | -------- | -------- | | ------ | ------ | ----- |
| region | string | Region ID.| | region | string | Region ID.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example **Example**
``` ```
i18n.setSystemRegion(); i18n.setSystemRegion();
``` ```
...@@ -229,12 +233,12 @@ Obtains the system locale. ...@@ -229,12 +233,12 @@ Obtains the system locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------- |
| string | System locale ID.| | string | System locale ID.|
- Example **Example**
``` ```
i18n.getSystemLocale(); i18n.getSystemLocale();
``` ```
...@@ -246,19 +250,21 @@ setSystemLocale(locale: string): boolean ...@@ -246,19 +250,21 @@ setSystemLocale(locale: string): boolean
Sets the system locale. Sets the system locale.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Description| | Name | Type | Description |
| -------- | -------- | -------- | | ------ | ------ | --------------- |
| locale | string | System locale ID, for example, **zh-CN**.| | locale | string | System locale ID, for example, **zh-CN**.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example **Example**
``` ```
i18n.setSystemLocale('zh-CN'); i18n.setSystemLocale('zh-CN');
``` ```
...@@ -272,18 +278,18 @@ Checks whether the system language matches the specified region. ...@@ -272,18 +278,18 @@ Checks whether the system language matches the specified region.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ------ | ---- | ------------- |
| language | string | Yes| Valid language ID, for example, **zh**.| | language | string | Yes | Valid language ID, for example, **zh**.|
| region | string | No| Valid region ID, for example, **CN**.| | region | string | No | Valid region ID, for example, **CN**. |
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the system language matches the specified region; returns **false** otherwise.| | boolean | Returns **true** if the system language matches the specified region; returns **false** otherwise.|
- Example **Example**
``` ```
i18n.isSuggested('zh', 'CN'); i18n.isSuggested('zh', 'CN');
``` ```
...@@ -297,18 +303,18 @@ Obtains a **Calendar** object. ...@@ -297,18 +303,18 @@ Obtains a **Calendar** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---------------------------------------- |
| locale | string | Yes| Valid locale value, for example, **zh-Hans-CN**.| | locale | string | Yes | Valid locale value, for example, **zh-Hans-CN**. |
| type | string | No| Valid calendar type. Currently, the valid types are as follows: **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic\_civil**, **islamic\_tbla**, **islamic\_umalqura**, **japanese**, and **persian**. If this parameter is left unspecified, the default calendar type of the specified locale is used.| | type | string | No | Valid calendar type. Currently, the valid types are as follows: **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic\_civil**, **islamic\_tbla**, **islamic\_umalqura**, **japanese**, and **persian**. If this parameter is left unspecified, the default calendar type of the specified locale is used.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ---------------------- | ----- |
| [Calendar](#calendar8) | **Calendar** object.| | [Calendar](#calendar8) | **Calendar** object.|
- Example **Example**
``` ```
i18n.getCalendar("zh-Hans", "gregory"); i18n.getCalendar("zh-Hans", "gregory");
``` ```
...@@ -325,12 +331,12 @@ Sets the date for this **Calendar** object. ...@@ -325,12 +331,12 @@ Sets the date for this **Calendar** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ---- | ---- | ----------------- |
| date | Date | Yes| Date to be set for the **Calendar** object.| | date | Date | Yes | Date to be set for the **Calendar** object.|
- Example **Example**
``` ```
var calendar = I18n.getCalendar("en-US", "gregory"); var calendar = I18n.getCalendar("en-US", "gregory");
var date = new Date(2021, 10, 7, 8, 0, 0, 0); var date = new Date(2021, 10, 7, 8, 0, 0, 0);
...@@ -346,12 +352,12 @@ Sets the date and time for this **Calendar** object. The value is represented by ...@@ -346,12 +352,12 @@ Sets the date and time for this **Calendar** object. The value is represented by
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ---------------------------------------- |
| time | number | Yes| Number of milliseconds that have elapsed since the Unix epoch.| | time | number | Yes | Number of milliseconds that have elapsed since the Unix epoch.|
- Example **Example**
``` ```
var calendar = I18n.getCalendar("en-US", "gregory"); var calendar = I18n.getCalendar("en-US", "gregory");
calendar.setTime(10540800000); calendar.setTime(10540800000);
...@@ -366,17 +372,17 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object ...@@ -366,17 +372,17 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ------ |
| year | number | Yes| Year to set.| | year | number | Yes | Year to set. |
| month | number | Yes| Month to set.| | month | number | Yes | Month to set. |
| date | number | Yes| Day to set.| | date | number | Yes | Day to set. |
| hour | number | No| Hour to set.| | hour | number | No | Hour to set.|
| minute | number | No| Minute to set.| | minute | number | No | Minute to set.|
| second | number | No| Second to set.| | second | number | No | Second to set. |
- Example **Example**
``` ```
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
...@@ -391,12 +397,12 @@ Sets the time zone of this **Calendar** object. ...@@ -391,12 +397,12 @@ Sets the time zone of this **Calendar** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ------ | ---- | ------------------------- |
| timezone | string | Yes| Time zone, for example, **Asia/Shanghai**.| | timezone | string | Yes | Time zone, for example, **Asia/Shanghai**.|
- Example **Example**
``` ```
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setTimeZone("Asia/Shanghai"); calendar.setTimeZone("Asia/Shanghai");
...@@ -411,12 +417,12 @@ Obtains the time zone of this **Calendar** object. ...@@ -411,12 +417,12 @@ Obtains the time zone of this **Calendar** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------- |
| string | Time zone of the **Calendar** object.| | string | Time zone of the **Calendar** object.|
- Example **Example**
``` ```
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setTimeZone("Asia/Shanghai"); calendar.setTimeZone("Asia/Shanghai");
...@@ -432,12 +438,12 @@ Obtains the start day of a week for this **Calendar** object. ...@@ -432,12 +438,12 @@ Obtains the start day of a week for this **Calendar** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | --------------------- |
| number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.| | number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
- Example **Example**
``` ```
var calendar = I18n.getCalendar("en-US", "gregory"); var calendar = I18n.getCalendar("en-US", "gregory");
calendar.getFirstDayOfWeek(); calendar.getFirstDayOfWeek();
...@@ -452,12 +458,12 @@ Sets the start day of a week for this **Calendar** object. ...@@ -452,12 +458,12 @@ Sets the start day of a week for this **Calendar** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ----- | ------ | ---- | --------------------- |
| value | number | No| Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.| | value | number | No | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
- Example **Example**
``` ```
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setFirstDayOfWeek(0); calendar.setFirstDayOfWeek(0);
...@@ -472,12 +478,12 @@ Obtains the minimum number of days in the first week of a year. ...@@ -472,12 +478,12 @@ Obtains the minimum number of days in the first week of a year.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------ |
| number | Minimum number of days in the first week of a year.| | number | Minimum number of days in the first week of a year.|
- Example **Example**
``` ```
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.getMinimalDaysInFirstWeek(); calendar.getMinimalDaysInFirstWeek();
...@@ -492,12 +498,12 @@ Sets the minimum number of days in the first week of a year. ...@@ -492,12 +498,12 @@ Sets the minimum number of days in the first week of a year.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ------------ |
| value | number | No| Minimum number of days in the first week of a year.| | value | number | No | Minimum number of days in the first week of a year.|
- Example **Example**
``` ```
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setMinimalDaysInFirstWeek(3); calendar.setMinimalDaysInFirstWeek(3);
...@@ -512,17 +518,17 @@ Obtains the value of the specified field in the **Calendar** object. ...@@ -512,17 +518,17 @@ Obtains the value of the specified field in the **Calendar** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ---------------------------------------- |
| field | string | Yes| Value of the specified field in the **Calendar** object. Currently, a valid field can be any of the following: **era**, **year**, **month**, **week\_of\_year**, **week\_of\_month**, **date**, **day\_of\_year**, **day\_of\_week**, **day\_of\_week\_in\_month**, **hour**, **hour\_of\_day**, **minute**, **second**, **millisecond**, **zone\_offset**, **dst\_offset**, **year\_woy**, **dow\_local**, **extended\_year**, **julian\_day**, **milliseconds\_in\_day**, **is\_leap\_month**.| | field | string | Yes | Value of the specified field in the **Calendar** object. Currently, a valid field can be any of the following: **era**, **year**, **month**, **week\_of\_year**, **week\_of\_month**, **date**, **day\_of\_year**, **day\_of\_week**, **day\_of\_week\_in\_month**, **hour**, **hour\_of\_day**, **minute**, **second**, **millisecond**, **zone\_offset**, **dst\_offset**, **year\_woy**, **dow\_local**, **extended\_year**, **julian\_day**, **milliseconds\_in\_day**, **is\_leap\_month**.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------------------------------------- |
| number | Value of the specified field. For example, if the year in the internal date of this **Calendar** object is **1990**, the **get("year")** function will return **1990**.| | number | Value of the specified field. For example, if the year in the internal date of this **Calendar** object is **1990**, the **get("year")** function will return **1990**.|
- Example **Example**
``` ```
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
...@@ -538,17 +544,17 @@ Obtains the name of the **Calendar** object displayed for the specified locale. ...@@ -538,17 +544,17 @@ Obtains the name of the **Calendar** object displayed for the specified locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---------------------------------------- |
| locale | string | Yes| Locale for which the name of the **Calendar** object is displayed. For example, if **locale** is **en-US**, the name of the Buddhist calendar will be **Buddhist Calendar**.| | locale | string | Yes | Locale for which the name of the **Calendar** object is displayed. For example, if **locale** is **en-US**, the name of the Buddhist calendar will be **Buddhist Calendar**.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------------- |
| string | Name of the **Calendar** object displayed for the specified locale.| | string | Name of the **Calendar** object displayed for the specified locale.|
- Example **Example**
``` ```
var calendar = i18n.getCalendar("en-US", "buddhist"); var calendar = i18n.getCalendar("en-US", "buddhist");
calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh. calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh.
...@@ -563,17 +569,17 @@ Checks whether the specified date in this **Calendar** object is a weekend. ...@@ -563,17 +569,17 @@ Checks whether the specified date in this **Calendar** object is a weekend.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ---- | ---- | ---------------------------------------- |
| date | Date | No| Specified date in this **Calendar** object. If this parameter is left unspecified, the system checks whether the current date in the **Calendar** object is a weekend.| | date | Date | No | Specified date in this **Calendar** object. If this parameter is left unspecified, the system checks whether the current date in the **Calendar** object is a weekend.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ----------------------------------- |
| boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.| | boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.|
- Example **Example**
``` ```
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setTime(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00 calendar.setTime(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00
...@@ -595,12 +601,12 @@ Creates a **PhoneNumberFormat** object. ...@@ -595,12 +601,12 @@ Creates a **PhoneNumberFormat** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
Parameters Parameters
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------- | ---------------------------------------- | ---- | ---------------- |
| country | string | Yes| Country or region to which the phone number to be formatted belongs.| | country | string | Yes | Country or region to which the phone number to be formatted belongs.|
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No| Options of the **PhoneNumberFormat** object.| | options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. |
- Example **Example**
``` ```
var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"}); var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"});
``` ```
...@@ -614,17 +620,17 @@ Checks whether the format of the specified phone number is valid. ...@@ -614,17 +620,17 @@ Checks whether the format of the specified phone number is valid.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | --------- |
| number | string | Yes| Phone number to be checked.| | number | string | Yes | Phone number to be checked.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ------------------------------------- |
| boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.| | boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.|
- Example **Example**
``` ```
var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); var phonenumberfmt = new i18n.PhoneNumberFormat("CN");
phonenumberfmt.isValidNumber("15812312312"); phonenumberfmt.isValidNumber("15812312312");
...@@ -639,17 +645,17 @@ Formats a phone number. ...@@ -639,17 +645,17 @@ Formats a phone number.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---------- |
| number | string | Yes| Phone number to be formatted.| | number | string | Yes | Phone number to be formatted.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------- |
| string | Formatted phone number.| | string | Formatted phone number.|
- Example **Example**
``` ```
var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); var phonenumberfmt = new i18n.PhoneNumberFormat("CN");
phonenumberfmt.format("15812312312"); phonenumberfmt.format("15812312312");
...@@ -662,9 +668,9 @@ Defines the options for this PhoneNumberFormat object. ...@@ -662,9 +668,9 @@ Defines the options for this PhoneNumberFormat object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ---- | ---------------------------------------- |
| type | string | Yes| Yes| Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.| | type | string | Yes | Yes | Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.|
## UnitInfo<sup>8+</sup> ## UnitInfo<sup>8+</sup>
...@@ -673,10 +679,10 @@ Defines the measurement unit information. ...@@ -673,10 +679,10 @@ Defines the measurement unit information.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------------- | ------ | ---- | ---- | ---------------------------------------- |
| unit | string | Yes| Yes| Name of the measurement unit, for example, **meter**, **inch**, or **cup**.| | unit | string | Yes | Yes | Name of the measurement unit, for example, **meter**, **inch**, or **cup**.|
| measureSystem | string | Yes| Yes| Measurement system. The value can be **SI**, **US**, or **UK**.| | measureSystem | string | Yes | Yes | Measurement system. The value can be **SI**, **US**, or **UK**.|
## Util<sup>8+</sup> ## Util<sup>8+</sup>
...@@ -690,21 +696,21 @@ Converts one measurement unit into another and formats the unit based on the spe ...@@ -690,21 +696,21 @@ Converts one measurement unit into another and formats the unit based on the spe
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------- | ---- | ---------------------------------------- |
| fromUnit | [UnitInfo](#unitinfo8) | Yes| Measurement unit to be converted.| | fromUnit | [UnitInfo](#unitinfo8) | Yes | Measurement unit to be converted. |
| toUnit | [UnitInfo](#unitinfo8) | Yes| Measurement unit to be converted to.| | toUnit | [UnitInfo](#unitinfo8) | Yes | Measurement unit to be converted to. |
| value | number | Yes| Value of the measurement unit to be converted.| | value | number | Yes | Value of the measurement unit to be converted. |
| locale | string | Yes| Locale used for formatting, for example, **zh-Hans-CN**.| | locale | string | Yes | Locale used for formatting, for example, **zh-Hans-CN**. |
| style | string | No| Style used for formatting. The value can be **long**, **short**, or **medium**.| | style | string | No | Style used for formatting. The value can be **long**, **short**, or **medium**.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ----------------------- |
| string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.| | string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.|
- Example **Example**
``` ```
I18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long"); I18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long");
``` ```
...@@ -718,17 +724,17 @@ Creates an **IndexUtil** object. ...@@ -718,17 +724,17 @@ Creates an **IndexUtil** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---------------------------- |
| locale | string | No| A string containing locale information, including the language, optional script, and region.| | locale | string | No | A string containing locale information, including the language, optional script, and region.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------------ | --------------------- |
| [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.| | [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.|
- Example **Example**
``` ```
var indexUtil= i18n.IndexUtil.getInstance("zh-CN"); var indexUtil= i18n.IndexUtil.getInstance("zh-CN");
``` ```
...@@ -745,12 +751,12 @@ Obtains the index list for this **locale** object. ...@@ -745,12 +751,12 @@ Obtains the index list for this **locale** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------- | ------------------ |
| Array&lt;string&gt; | Index list for this **locale** object.| | Array&lt;string&gt; | Index list for this **locale** object.|
- Example **Example**
``` ```
var indexUtil = i18n.getInstance("zh-CN"); var indexUtil = i18n.getInstance("zh-CN");
var indexList = indexUtil.getIndexList(); var indexList = indexUtil.getIndexList();
...@@ -765,12 +771,12 @@ Adds the index of the new **locale** object to the index list. ...@@ -765,12 +771,12 @@ Adds the index of the new **locale** object to the index list.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---------------------------- |
| locale | string | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string | Yes | A string containing locale information, including the language, optional script, and region.|
- Example **Example**
``` ```
var indexUtil = i18n.getInstance("zh-CN"); var indexUtil = i18n.getInstance("zh-CN");
indexUtil.addLocale("en-US"); indexUtil.addLocale("en-US");
...@@ -785,17 +791,17 @@ Obtains the index of a text object. ...@@ -785,17 +791,17 @@ Obtains the index of a text object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ------------ |
| text | string | Yes| **text** object whose index is to be obtained.| | text | string | Yes | **text** object whose index is to be obtained.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ----------- |
| string | Index of the **text** object.| | string | Index of the **text** object.|
- Example **Example**
``` ```
var indexUtil= i18n.getInstance("zh-CN"); var indexUtil= i18n.getInstance("zh-CN");
indexUtil.getIndex("hi"); // Return h. indexUtil.getIndex("hi"); // Return h.
...@@ -813,17 +819,17 @@ Checks whether the input character string is composed of digits. ...@@ -813,17 +819,17 @@ Checks whether the input character string is composed of digits.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ----- |
| char | string | Yes| Input character.| | char | string | Yes | Input character.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ------------------------------------ |
| boolean | Returns **true** if the input character is a digit; returns **false** otherwise.| | boolean | Returns **true** if the input character is a digit; returns **false** otherwise.|
- Example **Example**
``` ```
var isdigit = Character.isDigit("1"); // Return true. var isdigit = Character.isDigit("1"); // Return true.
``` ```
...@@ -837,17 +843,17 @@ Checks whether the input character is a space. ...@@ -837,17 +843,17 @@ Checks whether the input character is a space.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ----- |
| char | string | Yes| Input character.| | char | string | Yes | Input character.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | -------------------------------------- |
| boolean | Returns **true** if the input character is a space; returns **false** otherwise.| | boolean | Returns **true** if the input character is a space; returns **false** otherwise.|
- Example **Example**
``` ```
var isspacechar = Character.isSpaceChar("a"); // Return false. var isspacechar = Character.isSpaceChar("a"); // Return false.
``` ```
...@@ -861,17 +867,17 @@ Checks whether the input character is a white space. ...@@ -861,17 +867,17 @@ Checks whether the input character is a white space.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ----- |
| char | string | Yes| Input character.| | char | string | Yes | Input character.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | -------------------------------------- |
| boolean | Returns **true** if the input character is a white space; returns **false** otherwise.| | boolean | Returns **true** if the input character is a white space; returns **false** otherwise.|
- Example **Example**
``` ```
var iswhitespace = Character.isWhitespace("a"); // Return false. var iswhitespace = Character.isWhitespace("a"); // Return false.
``` ```
...@@ -885,17 +891,17 @@ Checks whether the input character is of the right to left (RTL) language. ...@@ -885,17 +891,17 @@ Checks whether the input character is of the right to left (RTL) language.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ----- |
| char | string | Yes| Input character.| | char | string | Yes | Input character.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.| | boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.|
- Example **Example**
``` ```
var isrtl = Character.isRTL("a"); // Return false. var isrtl = Character.isRTL("a"); // Return false.
``` ```
...@@ -909,17 +915,17 @@ Checks whether the input character is an ideographic character. ...@@ -909,17 +915,17 @@ Checks whether the input character is an ideographic character.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ----- |
| char | string | Yes| Input character.| | char | string | Yes | Input character.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.| | boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.|
- Example **Example**
``` ```
var isideograph = Character.isIdeograph("a"); // Return false. var isideograph = Character.isIdeograph("a"); // Return false.
``` ```
...@@ -933,17 +939,17 @@ Checks whether the input character is a letter. ...@@ -933,17 +939,17 @@ Checks whether the input character is a letter.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ----- |
| char | string | Yes| Input character.| | char | string | Yes | Input character.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ------------------------------------ |
| boolean | Returns **true** if the input character is a letter; returns **false** otherwise.| | boolean | Returns **true** if the input character is a letter; returns **false** otherwise.|
- Example **Example**
``` ```
var isletter = Character.isLetter("a"); // Return true. var isletter = Character.isLetter("a"); // Return true.
``` ```
...@@ -957,17 +963,17 @@ Checks whether the input character is a lowercase letter. ...@@ -957,17 +963,17 @@ Checks whether the input character is a lowercase letter.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ----- |
| char | string | Yes| Input character.| | char | string | Yes | Input character.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.| | boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.|
- Example **Example**
``` ```
var islowercase = Character.isLowerCase("a"); // Return true. var islowercase = Character.isLowerCase("a"); // Return true.
``` ```
...@@ -981,17 +987,17 @@ Checks whether the input character is an uppercase letter. ...@@ -981,17 +987,17 @@ Checks whether the input character is an uppercase letter.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ----- |
| char | string | Yes| Input character.| | char | string | Yes | Input character.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.| | boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.|
- Example **Example**
``` ```
var isuppercase = Character.isUpperCase("a"); // Return false. var isuppercase = Character.isUpperCase("a"); // Return false.
``` ```
...@@ -1005,17 +1011,17 @@ Obtains the type of the input character string. ...@@ -1005,17 +1011,17 @@ Obtains the type of the input character string.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ----- |
| char | string | Yes| Input character.| | char | string | Yes | Input character.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ----------- |
| string | Type of the input character.| | string | Type of the input character.|
- Example **Example**
``` ```
var type = Character.getType("a"); var type = Character.getType("a");
``` ```
...@@ -1029,17 +1035,17 @@ Obtains a [BreakIterator](#breakiterator8) object for text segmentation. ...@@ -1029,17 +1035,17 @@ Obtains a [BreakIterator](#breakiterator8) object for text segmentation.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---------------------------------------- |
| locale | string | Yes| Valid locale value, for example, **zh-Hans-CN**. The [BreakIterator](#breakiterator8) object segments text according to the rules of the specified locale.| | locale | string | Yes | Valid locale value, for example, **zh-Hans-CN**. The [BreakIterator](#breakiterator8) object segments text according to the rules of the specified locale.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------------------------------- | ----------- |
| [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.| | [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.|
- Example **Example**
``` ```
i18n.getLineInstance("en"); i18n.getLineInstance("en");
``` ```
...@@ -1056,12 +1062,12 @@ Sets the text to be processed by the [BreakIterator](#breakiterator8) object. ...@@ -1056,12 +1062,12 @@ Sets the text to be processed by the [BreakIterator](#breakiterator8) object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ----------------------- |
| text | string | Yes| Text to be processed by the **BreakIterator** object.| | text | string | Yes | Text to be processed by the **BreakIterator** object.|
- Example **Example**
``` ```
iterator = I18n.getLineInstance("en"); iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
...@@ -1076,12 +1082,12 @@ Obtains the text being processed by the [BreakIterator](#breakiterator8) object. ...@@ -1076,12 +1082,12 @@ Obtains the text being processed by the [BreakIterator](#breakiterator8) object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------------------- |
| string | Text being processed by the **BreakIterator** object.| | string | Text being processed by the **BreakIterator** object.|
- Example **Example**
``` ```
iterator = I18n.getLineInstance("en"); iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
...@@ -1097,12 +1103,12 @@ Obtains the position of the [BreakIterator](#breakiterator8) object in the text ...@@ -1097,12 +1103,12 @@ Obtains the position of the [BreakIterator](#breakiterator8) object in the text
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | --------------------------- |
| number | Position of the **BreakIterator** object in the text being processed.| | number | Position of the **BreakIterator** object in the text being processed.|
- Example **Example**
``` ```
iterator = I18n.getLineInstance("en"); iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
...@@ -1118,12 +1124,12 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi ...@@ -1118,12 +1124,12 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ----------------- |
| number | Offset to the first text boundary of the processed text.| | number | Offset to the first text boundary of the processed text.|
- Example **Example**
``` ```
iterator = I18n.getLineInstance("en"); iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
...@@ -1139,12 +1145,12 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic ...@@ -1139,12 +1145,12 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------------ |
| number | Offset of the last text boundary of the processed text.| | number | Offset of the last text boundary of the processed text.|
- Example **Example**
``` ```
iterator = I18n.getLineInstance("en"); iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
...@@ -1160,17 +1166,17 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb ...@@ -1160,17 +1166,17 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ---------------------------------------- |
| index | number | No| Number of text boundaries by which the [BreakIterator](#breakiterator8) object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as **1**.| | index | number | No | Number of text boundaries by which the [BreakIterator](#breakiterator8) object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as **1**.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------------------------------------- |
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.| | number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.|
- Example **Example**
``` ```
iterator = I18n.getLineInstance("en"); iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
...@@ -1188,12 +1194,12 @@ Moves the [BreakIterator](#breakiterator8) object to the previous text boundary. ...@@ -1188,12 +1194,12 @@ Moves the [BreakIterator](#breakiterator8) object to the previous text boundary.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------------------------------------- |
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.| | number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.|
- Example **Example**
``` ```
iterator = I18n.getLineInstance("en"); iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
...@@ -1211,17 +1217,17 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the ...@@ -1211,17 +1217,17 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---------------------------------------- |
| offset | number | Yes| Offset to the position before the text boundary to which the [BreakIterator](#breakiterator8) object is moved.| | offset | number | Yes | Offset to the position before the text boundary to which the [BreakIterator](#breakiterator8) object is moved.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------------------------------------- |
| number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.| | number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.|
- Example **Example**
``` ```
iterator = I18n.getLineInstance("en"); iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
...@@ -1239,17 +1245,17 @@ Checks whether the position specified by the offset is a text boundary. If **tru ...@@ -1239,17 +1245,17 @@ Checks whether the position specified by the offset is a text boundary. If **tru
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ----------- |
| offset | number | Yes| Position to check.| | offset | number | Yes | Position to check.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ------------------------------- |
| boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.| | boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.|
- Example **Example**
``` ```
iterator = I18n.getLineInstance("en"); iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
...@@ -1266,12 +1272,12 @@ Checks whether the 24-hour clock is used. ...@@ -1266,12 +1272,12 @@ Checks whether the 24-hour clock is used.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.| | boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.|
- Example **Example**
``` ```
var is24HourClock = i18n.is24HourClock(); var is24HourClock = i18n.is24HourClock();
``` ```
...@@ -1283,19 +1289,21 @@ set24HourClock(option: boolean): boolean ...@@ -1283,19 +1289,21 @@ set24HourClock(option: boolean): boolean
Sets the 24-hour clock. Sets the 24-hour clock.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------- | ---- | ---------------------------------------- |
| option | boolean | Yes| Whether to enable the 24-hour clock. The value **true** means to enable the 24-hour clock, and the value **false** means the opposite.| | option | boolean | Yes | Whether to enable the 24-hour clock. The value **true** means to enable the 24-hour clock, and the value **false** means the opposite.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.| | boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.|
- Example **Example**
``` ```
// Set the system time to the 24-hour clock. // Set the system time to the 24-hour clock.
var success = I18n.set24HourClock(true); var success = I18n.set24HourClock(true);
...@@ -1308,20 +1316,22 @@ addPreferredLanguage(language: string, index?: number): boolean ...@@ -1308,20 +1316,22 @@ addPreferredLanguage(language: string, index?: number): boolean
Adds a preferred language to the specified position on the preferred language list. Adds a preferred language to the specified position on the preferred language list.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ------ | ---- | ---------- |
| language | string | Yes| Preferred language to add.| | language | string | Yes | Preferred language to add. |
| index | number | No| Position to which the preferred language is added.| | index | number | No | Position to which the preferred language is added.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.| | boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.|
- Example **Example**
``` ```
// Add zh-CN to the preferred language list. // Add zh-CN to the preferred language list.
var language = 'zh-CN'; var language = 'zh-CN';
...@@ -1336,19 +1346,21 @@ removePreferredLanguage(index: number): boolean ...@@ -1336,19 +1346,21 @@ removePreferredLanguage(index: number): boolean
Deletes a preferred language from the specified position on the preferred language list. Deletes a preferred language from the specified position on the preferred language list.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ----- | ------ | ---- | --------------------- |
| index | number | Yes| Position of the preferred language to delete.| | index | number | Yes | Position of the preferred language to delete.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.| | boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.|
- Example **Example**
``` ```
// Delete the first preferred language from the preferred language list. // Delete the first preferred language from the preferred language list.
var index = 0; var index = 0;
...@@ -1358,18 +1370,18 @@ Deletes a preferred language from the specified position on the preferred langua ...@@ -1358,18 +1370,18 @@ Deletes a preferred language from the specified position on the preferred langua
## i18n.getPreferredLanguageList<sup>8+</sup> ## i18n.getPreferredLanguageList<sup>8+</sup>
getPreferredLanguageList(): Array<string> getPreferredLanguageList(): Array&lt;string&gt;
Obtains the list of preferred languages. Obtains the list of preferred languages.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------- | --------- |
| Array<string> | List of preferred languages.| | Array&lt;string&gt; | List of preferred languages.|
- Example **Example**
``` ```
var preferredLanguageList = i18n.getPreferredLanguageList(); var preferredLanguageList = i18n.getPreferredLanguageList();
``` ```
...@@ -1383,12 +1395,12 @@ Obtains the first language in the preferred language list. ...@@ -1383,12 +1395,12 @@ Obtains the first language in the preferred language list.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | -------------- |
| string | First language in the preferred language list.| | string | First language in the preferred language list.|
- Example **Example**
``` ```
var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); var firstPreferredLanguage = i18n.getFirstPreferredLanguage();
``` ```
...@@ -1402,17 +1414,17 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID. ...@@ -1402,17 +1414,17 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ----- |
| zondID | string | No| Time zone ID.| | zondID | string | No | Time zone ID.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | ------------ |
| TimeZone | **TimeZone** object corresponding to the time zone ID.| | TimeZone | **TimeZone** object corresponding to the time zone ID.|
- Example **Example**
``` ```
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
``` ```
...@@ -1429,12 +1441,12 @@ Obtains the ID of the specified **TimeZone** object. ...@@ -1429,12 +1441,12 @@ Obtains the ID of the specified **TimeZone** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------ |
| string | Time zone ID corresponding to the **TimeZone** object.| | string | Time zone ID corresponding to the **TimeZone** object.|
- Example **Example**
``` ```
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getID(); timezone.getID();
...@@ -1449,18 +1461,18 @@ Obtains the representation of a **TimeZone** object in the specified locale. ...@@ -1449,18 +1461,18 @@ Obtains the representation of a **TimeZone** object in the specified locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------- | ---- | -------------------- |
| locale | string | No| System locale ID.| | locale | string | No | System locale ID. |
| isDST | boolean | No| Whether to consider DST when obtaining the representation of the **TimeZone** object.| | isDST | boolean | No | Whether to consider DST when obtaining the representation of the **TimeZone** object.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------- |
| string | Representation of the **TimeZone** object in the specified locale.| | string | Representation of the **TimeZone** object in the specified locale.|
- Example **Example**
``` ```
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getDisplayName("zh-CN", false); timezone.getDisplayName("zh-CN", false);
...@@ -1475,12 +1487,12 @@ Obtains the offset between the time zone represented by a **TimeZone** object an ...@@ -1475,12 +1487,12 @@ Obtains the offset between the time zone represented by a **TimeZone** object an
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------------- |
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.| | number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.|
- Example **Example**
``` ```
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getRawOffset(); timezone.getRawOffset();
...@@ -1495,12 +1507,12 @@ Obtains the offset between the time zone represented by a **TimeZone** object an ...@@ -1495,12 +1507,12 @@ Obtains the offset between the time zone represented by a **TimeZone** object an
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ----------------------- |
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point.| | number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point.|
- Example **Example**
``` ```
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getOffset(1234567890); timezone.getOffset(1234567890);
......
...@@ -20,90 +20,187 @@ import inputDevice from '@ohos.multimodalInput.inputDevice'; ...@@ -20,90 +20,187 @@ import inputDevice from '@ohos.multimodalInput.inputDevice';
getDeviceIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void getDeviceIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
Obtains the IDs of all input devices. This method uses an asynchronous callback to return the result. Obtains the IDs of all input devices. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters** **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the result. |
**Example** | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the result.|
**Example**
``` ```
data: { export default {
data: {
deviceIds: Array, deviceIds: Array,
}, },
callback: function(ids) { callback: function(ids) {
this.deviceIds = ids; this.deviceIds = ids;
}, },
testGetDeviceIds: function () { testGetDeviceIds: function () {
console.info("InputDeviceJsTest---start---testGetDeviceIds"); console.info("InputDeviceJsTest---start---testGetDeviceIds");
inputDevice.getDeviceIds(this.callback); inputDevice.getDeviceIds(this.callback);
console.info("InputDeviceJsTest---end---testGetDeviceIds"); console.info("InputDeviceJsTest---end---testGetDeviceIds");
}
} }
``` ```
## inputDevice.getDeviceIds
function getDeviceIds(): Promise<Array<number>>
Obtains the IDs of all input devices. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Return value**
| Name | Description |
| ---------------------- | ------------------ |
| Promise<Array<number>> | Promise used to return the result.|
**Example**
```
export default {
testGetDeviceIds: function () {
console.info("InputDeviceJsTest---start---testGetDeviceIds");
let promise = inputDevice.getDeviceIds();
promise.then((data)=> {
console.info('GetDeviceIds successed, Data: ' + JSON.stringify(data))
}).catch((err)=>{
console.error('Failed GetDeviceIds. Cause: ' + JSON.stringify(err));
});
}
}
```
## inputDevice.getDevice ## inputDevice.getDevice
getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): void getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): void
Obtains the information about an input device. This method uses an asynchronous callback to return the result. Obtains the information about an input device. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters** **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------------- |
| deviceId | number | Yes | ID of the input device whose information is to be obtained. | | deviceId | number | Yes | ID of the input device whose information is to be obtained. |
| callback | AsyncCallback&lt;[InputDeviceData](#inputdevicedata)&gt; | Yes | Callback used to return the **InputDeviceData** object. | | callback | AsyncCallback&lt;[InputDeviceData](#inputdevicedata)&gt; | Yes | Callback used to return the **InputDeviceData** object.|
**Example** **Example**
``` ```
InputDeviceData { export default {
InputDeviceData: {
deviceId : 0, deviceId : 0,
name : "NA", name : "NA",
sources : Array, sources : Array,
axisRanges : Array, axisRanges : Array,
}, },
callback: function(deviceData) { callback: function(deviceData) {
this.InputDeviceData = deviceData; this.InputDeviceData = deviceData;
}, },
testGetDevice: function () { testGetDevice: function () {
// The example is used to obtain the information about the device whose ID is 1. // The example is used to obtain the information about the device whose ID is 1.
console.info("InputDeviceJsTest---start---testGetDevice"); console.info("InputDeviceJsTest---start---testGetDevice");
inputDevice.getDevice(1, this.callback); inputDevice.getDevice(1, this.callback);
console.info("InputDeviceJsTest---end---testGetDevice"); console.info("InputDeviceJsTest---end---testGetDevice");
}
}
```
## inputDevice.getDevice
function getDevice(deviceId: number): Promise<InputDeviceData>
Obtains the information about an input device. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Return value**
| Name | Description |
| ------------------------ | ------------------ |
| Promise<InputDeviceData> | Promise used to return the result.|
**Example**
```
export default {
InputDeviceData: {
deviceId : 0,
name : "NA",
sources : Array,
axisRanges : Array,
},
testGetDevice: function () {
// The example is used to obtain the information about the device whose ID is 1.
console.info("InputDeviceJsTest---start---testGetDevice");
let promise = inputDevice.getDevice(1);
promise.then((data)=> {
console.info('GetDeviceId successed, Data: ' + JSON.stringify(data))
}).catch((err)=>{
console.error('Failed GetDeviceId. Cause: ' + JSON.stringify(err));
});
}
} }
``` ```
## InputDeviceData ## InputDeviceData
Defines the information about an input device. Defines the information about an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| -------- | -------- | -------- | | Name | Type | Description |
| ------- | -------------------------------------- | ---------------------------------------- |
| id | number | Unique identifier of an input device. If the same physical device is repeatedly inserted and removed, its ID changes. | | id | number | Unique identifier of an input device. If the same physical device is repeatedly inserted and removed, its ID changes. |
| name | string | Name of the input device. | | name | string | Name of the input device. |
| sources | Array&lt;[SourceType](#sourcetype)&gt; | Source types of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad. | | sources | Array&lt;[SourceType](#sourcetype)&gt; | Source types of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad.|
## AxisType
Axis type. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
## AxisRange
Defines the axis information of an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| ------ | ------------------------- | -------- |
| source | [SourceType](#sourcetype) | Input source type of the axis.|
| axis | [AxisType](axistype) | Axis type. |
| max | number | Maximum value reported by the axis. |
| min | number | Minimum value reported by the axis. |
## SourceType ## SourceType
Enumerates the input source types. Enumerates the input source types. For example, if a mouse reports an x-axis event, the source of the x-axis is the mouse.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description | | Name | Type | Description |
| -------- | -------- | -------- | | ----------- | ------ | ----------- |
| keyboard | string | The input device is a keyboard. | | keyboard | string | The input device is a keyboard. |
| touchscreen | string | The input device is a touchscreen. | | touchscreen | string | The input device is a touchscreen.|
| mouse | string | The input device is a mouse. | | mouse | string | The input device is a mouse. |
| trackball | string | The input device is a trackball. | | trackball | string | The input device is a trackball.|
| touchpad | string | The input device is a touchpad. | | touchpad | string | The input device is a touchpad.|
| joystick | string | The input device is a joystick. | | joystick | string | The input device is a joystick.|
# Input Event Client
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
```
import inputEventClient from '@ohos.multimodalInput.inputEventClient';
```
## inputEventClient.injectEvent
injectEvent({KeyEvent: KeyEvent}): void
Injects a key.
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| KeyEvent | [KeyEvent](#keyevent) | Yes| Information about the key to inject.|
**Example**
```
let keyEvent = {
isPressed: true,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
}
res = inputEventClient.injectEvent({KeyEvent: keyEvent});
```
## KeyEvent
Defines the information about the key to inject.
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isPressed | boolean | Yes| Whether the key is pressed.|
| keyCode | Number | Yes| Key code.|
| keyDownDuration | boolean | Yes| Duration for which the key is pressed.|
| isIntercepted | Number | Yes| Whether the key can be intercepted.|
...@@ -20,18 +20,18 @@ import Intl from '@ohos.intl'; ...@@ -20,18 +20,18 @@ import Intl from '@ohos.intl';
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | --------------- | ------- | ---- | ---- | ---------------------------------------- |
| language | string | Yes| No| Language associated with the locale, for example, **zh**.| | language | string | Yes | No | Language associated with the locale, for example, **zh**. |
| script | string | Yes| No| Script type of the language, for example, **Hans**.| | script | string | Yes | No | Script type of the language, for example, **Hans**. |
| region | string | Yes| No| Region associated with the locale, for example, **CN**.| | region | string | Yes | No | Region associated with the locale, for example, **CN**. |
| baseName | string | Yes| No| Basic key information about the locale, which consists of the language, script, and region, for example, **zh-Hans-CN**.| | baseName | string | Yes | No | Basic key information about the locale, which consists of the language, script, and region, for example, **zh-Hans-CN**. |
| caseFirst | string | Yes| No| Whether case is taken into account for the locale's collation rules. The value can be **upper**, **lower**, or **false**.| | caseFirst | string | Yes | No | Whether case is taken into account for the locale's collation rules. The value can be **upper**, **lower**, or **false**.|
| calendar | string | Yes| No| Calendar for the locale. The value can be any of the following: **buddhist**, **chinese**, **coptic**, **dangi**, **ethioaa**, **ethiopic**, **gregory**, **hebrew**, **indian**, **islamic**, **islamic-umalqura**, **islamic-tbla**, **islamic-civil**, **islamic-rgsa**, **iso8601**, **japanese**, **persian**, **roc**, **islamicc**.| | calendar | string | Yes | No | Calendar for the locale. The value can be any of the following: **buddhist**, **chinese**, **coptic**, **dangi**, **ethioaa**, **ethiopic**, **gregory**, **hebrew**, **indian**, **islamic**, **islamic-umalqura**, **islamic-tbla**, **islamic-civil**, **islamic-rgsa**, **iso8601**, **japanese**, **persian**, **roc**, **islamicc**.|
| collation | string | Yes| No| Rule for sorting regions. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **searchjl**, **stroke**, **trad**, **unihan**, **zhuyin**.| | collation | string | Yes | No | Rule for sorting regions. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **searchjl**, **stroke**, **trad**, **unihan**, **zhuyin**.|
| hourCycle | string | Yes| No| Time system for the locale. The value can be any of the following: **h12**, **h23**, **h11**, **h24**.| | hourCycle | string | Yes | No | Time system for the locale. The value can be any of the following: **h12**, **h23**, **h11**, **h24**.|
| numberingSystem | string | Yes| No| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.| | numberingSystem | string | Yes | No | Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.|
| numeric | boolean | Yes| No| Whether to apply special collation rules for numeric characters.| | numeric | boolean | Yes | No | Whether to apply special collation rules for numeric characters. |
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
...@@ -42,7 +42,7 @@ Creates a Locale object. ...@@ -42,7 +42,7 @@ Creates a Locale object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Example **Example**
``` ```
var locale = new Intl.Locale(); var locale = new Intl.Locale();
``` ```
...@@ -56,13 +56,13 @@ Creates a Locale object. ...@@ -56,13 +56,13 @@ Creates a Locale object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------- | ------------- | ---- | ---------------------------- |
| locale | string | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string | Yes | A string containing locale information, including the language, optional script, and region.|
| options | LocaleOptions | No| Options for creating the **Locale** object.| | options | LocaleOptions | No | Options for creating the **Locale** object. |
- Example **Example**
``` ```
var locale = new Intl.Locale("zh-CN"); var locale = new Intl.Locale("zh-CN");
``` ```
...@@ -76,12 +76,12 @@ Converts locale information to a string. ...@@ -76,12 +76,12 @@ Converts locale information to a string.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ----------- |
| string | String containing locale information.| | string | String containing locale information.|
- Example **Example**
``` ```
var locale = new Intl.Locale("zh-CN"); var locale = new Intl.Locale("zh-CN");
locale.toString(); locale.toString();
...@@ -96,12 +96,12 @@ Maximizes information of the **Locale** object. If the script and locale informa ...@@ -96,12 +96,12 @@ Maximizes information of the **Locale** object. If the script and locale informa
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ----------------- | ---------- |
| [Locale](#locale) | **Locale** object with the maximized information.| | [Locale](#locale) | **Locale** object with the maximized information.|
- Example **Example**
``` ```
var locale = new Intl.Locale("zh-CN"); var locale = new Intl.Locale("zh-CN");
locale.maximize(); locale.maximize();
...@@ -116,12 +116,12 @@ Minimizes information of the **Locale** object. If the script and locale informa ...@@ -116,12 +116,12 @@ Minimizes information of the **Locale** object. If the script and locale informa
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ----------------- | ---------- |
| [Locale](#locale) | **Locale** object with the minimized information.| | [Locale](#locale) | **Locale** object with the minimized information.|
- Example **Example**
``` ```
var locale = new Intl.Locale("zh-CN"); var locale = new Intl.Locale("zh-CN");
locale.minimize(); locale.minimize();
...@@ -134,14 +134,14 @@ Represents the locale options. ...@@ -134,14 +134,14 @@ Represents the locale options.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | --------------- | ------- | ---- | ---- | ---------------------------------------- |
| calendar | string | Yes| Yes| Calendar for the locale. The calue can be any of the following: **buddhist**, **chinese**, **coptic**, **dangi**, **ethioaa**, **ethiopic**, **gregory**, **hebrew**, **indian**, **islamic**, **islamic-umalqura**, **islamic-tbla**, **islamic-civil**, **islamic-rgsa**, **iso8601**, **japanese**, **persian**, **roc**, **islamicc**.| | calendar | string | Yes | Yes | Calendar for the locale. The calue can be any of the following: **buddhist**, **chinese**, **coptic**, **dangi**, **ethioaa**, **ethiopic**, **gregory**, **hebrew**, **indian**, **islamic**, **islamic-umalqura**, **islamic-tbla**, **islamic-civil**, **islamic-rgsa**, **iso8601**, **japanese**, **persian**, **roc**, **islamicc**.|
| collation | string | Yes| Yes| Collation rule. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **emoji**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **search**, **searchjl**, **standard**, **stroke**, **trad**, **unihan**, **zhuyin**.| | collation | string | Yes | Yes | Collation rule. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **emoji**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**,**search**, **searchjl**, **standard**, **stroke**, **trad**, **unihan**, **zhuyin**.|
| hourCycle | string | Yes| Yes| Time system for the locale. The value can be any of the following: **h11**, **h12**, **h23**, **h24**.| | hourCycle | string | Yes | Yes | Time system for the locale. The value can be any of the following: **h11**, **h12**, **h23**, **h24**.|
| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.| | numberingSystem | string | Yes | Yes | Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.|
| numeric | boolean | Yes| Yes| Whether to use the 12-hour clock.| | numeric | boolean | Yes | Yes | Whether to use the 12-hour clock. |
| caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.| | caseFirst | string | Yes | Yes | Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.|
## DateTimeFormat ## DateTimeFormat
...@@ -155,7 +155,7 @@ Creates a **DateTimeOptions** object for the specified locale. ...@@ -155,7 +155,7 @@ Creates a **DateTimeOptions** object for the specified locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Example **Example**
``` ```
var datefmt= new Intl.DateTimeFormat(); var datefmt= new Intl.DateTimeFormat();
``` ```
...@@ -163,25 +163,25 @@ Creates a **DateTimeOptions** object for the specified locale. ...@@ -163,25 +163,25 @@ Creates a **DateTimeOptions** object for the specified locale.
### constructor ### constructor
constructor(locale: string | Array<string>, options?: DateTimeOptions) constructor(locale: string | Array&lt;string&gt;, options?: DateTimeOptions)
Creates a **DateTimeOptions** object for the specified locale. Creates a **DateTimeOptions** object for the specified locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------- | ----------------------------------- | ---- | ---------------------------- |
| locale | string \| Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [DateTimeOptions](#datetimeoptions) | No| Options for creating a **DateTimeFormat** object.| | options | [DateTimeOptions](#datetimeoptions) | No | Options for creating a **DateTimeFormat** object. |
- Example **Example**
``` ```
var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' }); var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' });
``` ```
- Example **Example**
``` ```
var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' });
``` ```
...@@ -195,17 +195,17 @@ Formats the specified date and time. ...@@ -195,17 +195,17 @@ Formats the specified date and time.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ---- | ---- | ------- |
| date | Date | Yes| Date and time to be formatted.| | date | Date | Yes | Date and time to be formatted.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------ |
| string | A string containing the formatted date and time.| | string | A string containing the formatted date and time.|
- Example **Example**
``` ```
var date = new Date(2021, 11, 17, 3, 24, 0); var date = new Date(2021, 11, 17, 3, 24, 0);
var datefmt = new Intl.DateTimeFormat("en-GB"); var datefmt = new Intl.DateTimeFormat("en-GB");
...@@ -221,18 +221,18 @@ Formats the specified date range. ...@@ -221,18 +221,18 @@ Formats the specified date range.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | --------- | ---- | ---- | -------- |
| startDate | Date | Yes| Start date and time to be formatted.| | startDate | Date | Yes | Start date and time to be formatted.|
| endDate | Date | Yes| End date and time to be formatted.| | endDate | Date | Yes | End date and time to be formatted.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | -------------- |
| string | A string containing the formatted date and time range.| | string | A string containing the formatted date and time range.|
- Example **Example**
``` ```
var startDate = new Date(2021, 11, 17, 3, 24, 0); var startDate = new Date(2021, 11, 17, 3, 24, 0);
var endDate = new Date(2021, 11, 18, 3, 24, 0); var endDate = new Date(2021, 11, 18, 3, 24, 0);
...@@ -249,12 +249,12 @@ Obtains the formatting options for **DateTimeFormat** object. ...@@ -249,12 +249,12 @@ Obtains the formatting options for **DateTimeFormat** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ----------------------------------- | ----------------------------- |
| [DateTimeOptions](#datetimeoptions) | Formatting options for **DateTimeFormat** objects.| | [DateTimeOptions](#datetimeoptions) | Formatting options for **DateTimeFormat** objects.|
- Example **Example**
``` ```
var datefmt = new Intl.DateTimeFormat("en-GB"); var datefmt = new Intl.DateTimeFormat("en-GB");
datefmt.resolvedOptions(); datefmt.resolvedOptions();
...@@ -267,27 +267,27 @@ Provides the options for the **DateTimeFormat** object. ...@@ -267,27 +267,27 @@ Provides the options for the **DateTimeFormat** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | --------------- | ------- | ---- | ---- | ---------------------------------------- |
| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.| | locale | string | Yes | No | Locale, for example, **zh-Hans-CN**. |
| dateStyle | string | Yes| Yes| Date display format. The value can be **long**, **short**, **medium**, or **full**.| | dateStyle | string | Yes | Yes | Date display format. The value can be **long**, **short**, **medium**, or **full**.|
| timeStyle | string | Yes| Yes| Time display format. The value can be **long**, **short**, **medium**, or **full**.| | timeStyle | string | Yes | Yes | Time display format. The value can be **long**, **short**, **medium**, or **full**.|
| hourCycle | string | Yes| Yes| Time system for the locale. The value can be any of the following: **h11**, **h12**, **h23**, **h24**.| | hourCycle | string | Yes | Yes | Time system for the locale. The value can be any of the following: **h11**, **h12**, **h23**, **h24**.|
| timeZone | string | Yes| Yes| Time zone represented by a valid IANA time zone ID.| | timeZone | string | Yes | Yes | Time zone represented by a valid IANA time zone ID. |
| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.| | numberingSystem | string | Yes | Yes | Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.|
| hour12 | boolean | Yes| Yes| Whether to use the 12-hour clock.| | hour12 | boolean | Yes | Yes | Whether to use the 12-hour clock. |
| weekday | string | Yes| Yes| Workday display format. The value can be **long**, **short**, or **narrow**.| | weekday | string | Yes | Yes | Workday display format. The value can be **long**, **short**, or **narrow**.|
| era | string | Yes| Yes| Era display format. The value can be **long**, **short**, or **narrow**.| | era | string | Yes | Yes | Era display format. The value can be **long**, **short**, or **narrow**.|
| year | string | Yes| Yes| Year display format. The value can be **numeric** or **2-digit**. | | year | string | Yes | Yes | Year display format. The value can be **numeric** or **2-digit**. |
| month | string | Yes| Yes| Month display format. The value can be any of the following: **numeric**, **2-digit**, **long**, **short**, **narrow**.| | month | string | Yes | Yes | Month display format. The value can be any of the following: **numeric**, **2-digit**, **long**, **short**, **narrow**.|
| day | string | Yes| Yes| Day display format. The value can be **numeric** or **2-digit**.| | day | string | Yes | Yes | Day display format. The value can be **numeric** or **2-digit**. |
| hour | string | Yes| Yes| Hour display format. The value can be **numeric** or **2-digit**.| | hour | string | Yes | Yes | Hour display format. The value can be **numeric** or **2-digit**. |
| minute | string | Yes| Yes| Minute display format. The value can be **numeric** or **2-digit**.| | minute | string | Yes | Yes | Minute display format. The value can be **numeric** or **2-digit**. |
| second | string | Yes| Yes| Seconds display format. The value can be **numeric** or **2-digit**.| | second | string | Yes | Yes | Seconds display format. The value can be **numeric** or **2-digit**. |
| timeZoneName | string | Yes| Yes| Localized representation of a time zone name.| | timeZoneName | string | Yes | Yes | Localized representation of a time zone name. |
| dayPeriod | string | Yes| Yes| Time period display format. The value can be **long**, **short**, or **narrow**.| | dayPeriod | string | Yes | Yes | Time period display format. The value can be **long**, **short**, or **narrow**.|
| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.| | localeMatcher | string | Yes | Yes | Locale matching algorithm. The value can be **lookup** or **best fit**.|
| formatMatcher | string | Yes| Yes| Format matching algorithm. The value can be **basic** or **best fit**.| | formatMatcher | string | Yes | Yes | Format matching algorithm. The value can be **basic** or **best fit**.|
## NumberFormat ## NumberFormat
...@@ -301,7 +301,7 @@ Creates a **NumberFormat** object for the specified locale. ...@@ -301,7 +301,7 @@ Creates a **NumberFormat** object for the specified locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Example **Example**
``` ```
var numfmt = new Intl.NumberFormat(); var numfmt = new Intl.NumberFormat();
``` ```
...@@ -309,19 +309,19 @@ Creates a **NumberFormat** object for the specified locale. ...@@ -309,19 +309,19 @@ Creates a **NumberFormat** object for the specified locale.
### constructor ### constructor
constructor(locale: string | Array<string>, options?: NumberOptions) constructor(locale: string | Array&lt;string&gt;, options?: NumberOptions)
Creates a **NumberFormat** object for the specified locale. Creates a **NumberFormat** object for the specified locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
Parameters Parameters
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------- | ------------------------------- | ---- | ---------------------------- |
| locale | string \| Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.| | options | [NumberOptions](#numberoptions) | No | Options for creating a **NumberFormat** object. |
- Example **Example**
``` ```
var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"}); var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"});
``` ```
...@@ -335,18 +335,18 @@ Formats a number. ...@@ -335,18 +335,18 @@ Formats a number.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---- |
| number | number | Yes| Number to be formatted.| | number | number | Yes | Number to be formatted.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------- |
| string | Formatted number.| | string | Formatted number.|
- Example **Example**
``` ```
var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"});
numfmt.format(1223); numfmt.format(1223);
...@@ -361,13 +361,13 @@ Obtains the options of the **NumberFormat** object. ...@@ -361,13 +361,13 @@ Obtains the options of the **NumberFormat** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------------------- | --------------------------- |
| [NumberOptions](#numberoptions) | Formatting options for **NumberFormat** objects.| | [NumberOptions](#numberoptions) | Formatting options for **NumberFormat** objects.|
- Example **Example**
``` ```
var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"});
numfmt.resolvedOptions(); numfmt.resolvedOptions();
...@@ -380,27 +380,27 @@ Provides the device capability. ...@@ -380,27 +380,27 @@ Provides the device capability.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------------------------ | ------- | ---- | ---- | ---------------------------------------- |
| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.| | locale | string | Yes | No | Locale, for example, **zh-Hans-CN**. |
| currency | string | Yes| Yes| Currency unit, for example, **EUR**, **CNY**, or **USD**.| | currency | string | Yes | Yes | Currency unit, for example, **EUR**, **CNY**, or **USD**. |
| currencySign | string | Yes| Yes| Currency unit symbol. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.| | currencySign | string | Yes | Yes | Currency unit symbol. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.|
| currencyDisplay | string | Yes| Yes| Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.| | currencyDisplay | string | Yes | Yes | Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.|
| unit | string | Yes| Yes| Unit name, for example, **meter**, **inch**, or **hectare**.| | unit | string | Yes | Yes | Unit name, for example, **meter**, **inch**, or **hectare**. |
| unitDisplay | string | Yes| Yes| Unit display format. The value can be **long**, **short**, or **medium**.| | unitDisplay | string | Yes | Yes | Unit display format. The value can be **long**, **short**, or **medium**.|
| unitUsage | string | Yes| Yes| Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.| | unitUsage | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.|
| signDisplay | string | Yes| Yes| Number sign display format. The value can be **auto**, **never**, **always**, or **expectZero**.| | signDisplay | string | Yes | Yes | Number sign display format. The value can be **auto**, **never**, **always**, or **expectZero**.|
| compactDisplay | string | Yes| Yes| Compact display format. The value can be **long** or **short**.| | compactDisplay | string | Yes | Yes | Compact display format. The value can be **long** or **short**. |
| notation | string | Yes| Yes| Number formatting specification. The value can be **standard**, **scientific**, **engineering**, or **compact**.| | notation | string | Yes | Yes | Number formatting specification. The value can be **standard**, **scientific**, **engineering**, or **compact**.|
| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.| | localeMatcher | string | Yes | Yes | Locale matching algorithm. The value can be **lookup** or **best fit**.|
| style | string | Yes| Yes| Number display format. The value can be **decimal**, **currency**, **percent**, or **unit**.| | style | string | Yes | Yes | Number display format. The value can be **decimal**, **currency**, **percent**, or **unit**.|
| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.| | numberingSystem | string | Yes | Yes | Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.|
| useGrouping | boolean | Yes| Yes| Whether to use grouping for display.| | useGrouping | boolean | Yes | Yes | Whether to use grouping for display. |
| minimumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.| | minimumIntegerDigits | number | Yes | Yes | Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**. |
| minimumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**.| | minimumFractionDigits | number | Yes | Yes | Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**. |
| maximumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.| | maximumFractionDigits | number | Yes | Yes | Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**. |
| minimumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.| | minimumSignificantDigits | number | Yes | Yes | Minimum number of the least significant digits. The value ranges from **1** to **21**. |
| maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.| | maximumSignificantDigits | number | Yes | Yes | Maximum number of the least significant digits. The value ranges from **1** to **21**. |
## Collator<sup>8+</sup> ## Collator<sup>8+</sup>
...@@ -414,7 +414,7 @@ Creates a Collator object. ...@@ -414,7 +414,7 @@ Creates a Collator object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Example **Example**
``` ```
var collator = new Intl.Collator(); var collator = new Intl.Collator();
``` ```
...@@ -422,20 +422,20 @@ Creates a Collator object. ...@@ -422,20 +422,20 @@ Creates a Collator object.
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
constructor(locale: string | Array<string>, options?: CollatorOptions) constructor(locale: string | Array&lt;string&gt;, options?: CollatorOptions)
Creates a Collator object. Creates a Collator object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------- | ----------------------------------- | ---- | ---------------------------- |
| locale | string \| Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [CollatorOptions](#collatoroptions) | No| Options for creating a **Collator** object.| | options | [CollatorOptions](#collatoroptions) | No | Options for creating a **Collator** object. |
- Example **Example**
``` ```
var collator = new Intl.Collator("zh-CN", {localeMatcher: "lookup", usage: "sort"}); var collator = new Intl.Collator("zh-CN", {localeMatcher: "lookup", usage: "sort"});
``` ```
...@@ -449,18 +449,18 @@ Compares two strings based on the sorting policy of the **Collator** object. ...@@ -449,18 +449,18 @@ Compares two strings based on the sorting policy of the **Collator** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ------------ |
| first | string | Yes| First string to compare.| | first | string | Yes | First string to compare. |
| second | string | Yes| Second string to compare.| | second | string | Yes | Second string to compare.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------------------------------------- |
| number | Comparison result. If the value is a negative number, the first string is before the second string. If the value of number is **0**, the first string is equal to the second string. If the value of number is a positive number, the first string is after the second string.| | number | Comparison result. If the value is a negative number, the first string is before the second string. If the value of number is **0**, the first string is equal to the second string. If the value of number is a positive number, the first string is after the second string.|
- Example **Example**
``` ```
var collator = new Intl.Collator("zh-Hans"); var collator = new Intl.Collator("zh-Hans");
collator.compare("first", "second"); collator.compare("first", "second");
...@@ -475,12 +475,12 @@ Returns properties reflecting the locale and collation options of a **Collator** ...@@ -475,12 +475,12 @@ Returns properties reflecting the locale and collation options of a **Collator**
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ----------------------------------- | ----------------- |
| [CollatorOptions](#collatoroptions) | Properties of the **Collator** object.| | [CollatorOptions](#collatoroptions) | Properties of the **Collator** object.|
- Example **Example**
``` ```
var collator = new Intl.Collator("zh-Hans"); var collator = new Intl.Collator("zh-Hans");
var options = collator.resolvedOptions(); var options = collator.resolvedOptions();
...@@ -493,15 +493,15 @@ Represents the properties of a **Collator** object. ...@@ -493,15 +493,15 @@ Represents the properties of a **Collator** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ----------------- | ------- | ---- | ---- | ---------------------------------------- |
| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.| | localeMatcher | string | Yes | Yes | Locale matching algorithm. The value can be **lookup** or **best fit**.|
| usage | string | Yes| Yes| Whether the comparison is for sorting or for searching. The value can be **sort** or **search**.| | usage | string | Yes | Yes | Whether the comparison is for sorting or for searching. The value can be **sort** or **search**. |
| sensitivity | string | Yes| Yes| Differences in the strings that lead to non-zero return values. The value can be **base**, **accent**, **case**, or **variant**.| | sensitivity | string | Yes | Yes | Differences in the strings that lead to non-zero return values. The value can be **base**, **accent**, **case**, or **variant**.|
| ignorePunctuation | boolean | Yes| Yes| Whether punctuation is ignored. The value can be **true** or **false**.| | ignorePunctuation | boolean | Yes | Yes | Whether punctuation is ignored. The value can be **true** or **false**. |
| collation | string | Yes| Yes| Rule for sorting regions. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **searchjl**, **stroke**, **trad**, **unihan**, **zhuyin**.| | collation | string | Yes | Yes | Rule for sorting regions. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **searchjl**, **stroke**, **trad**, **unihan**, **zhuyin**.|
| numeric | boolean | Yes| Yes| Whether numeric collation is used. The value can be **true** or **false**.| | numeric | boolean | Yes | Yes | Whether numeric collation is used. The value can be **true** or **false**. |
| caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.| | caseFirst | string | Yes | Yes | Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.|
## PluralRules<sup>8+</sup> ## PluralRules<sup>8+</sup>
...@@ -515,7 +515,7 @@ Create a **PluralRules** object. ...@@ -515,7 +515,7 @@ Create a **PluralRules** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Example **Example**
``` ```
var pluralRules = new Intl.PluralRules(); var pluralRules = new Intl.PluralRules();
``` ```
...@@ -523,19 +523,19 @@ Create a **PluralRules** object. ...@@ -523,19 +523,19 @@ Create a **PluralRules** object.
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
constructor(locale: string | Array<string>, options?: PluralRulesOptions) constructor(locale: string | Array&lt;string&gt;, options?: PluralRulesOptions)
Create a **PluralRules** object. Create a **PluralRules** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
Parameters Parameters
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [PluralRulesOptions](#pluralrulesoptions) | No| Options for creating a **PluralRules** object.| | options | [PluralRulesOptions](#pluralrulesoptions) | No | Options for creating a **PluralRules** object. |
- Example **Example**
``` ```
var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"});
``` ```
...@@ -549,17 +549,17 @@ Obtains a string that represents the singular-plural type of the specified numbe ...@@ -549,17 +549,17 @@ Obtains a string that represents the singular-plural type of the specified numbe
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ------------ |
| n | number | Yes| Number for which the singular-plural type is to be obtained.| | n | number | Yes | Number for which the singular-plural type is to be obtained.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------------------------------------- |
| string | Singular-plural type. The value can be any of the following: **one**, **two**, **few**, **many**, **others**.| | string | Singular-plural type. The value can be any of the following: **one**, **two**, **few**, **many**, **others**.|
- Example **Example**
``` ```
var pluralRules = new Intl.PluralRules("zh-Hans"); var pluralRules = new Intl.PluralRules("zh-Hans");
pluralRules.select(1); pluralRules.select(1);
...@@ -572,15 +572,15 @@ Represents the properties of a **PluralRules** object. ...@@ -572,15 +572,15 @@ Represents the properties of a **PluralRules** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------------------------ | ------ | ---- | ---- | ---------------------------------------- |
| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.| | localeMatcher | string | Yes | Yes | Locale matching algorithm. The value can be **lookup** or **best fit**.|
| type | string | Yes| Yes| Sorting type. The value can be **cardinal** or **ordinal**.| | type | string | Yes | Yes | Sorting type. The value can be **cardinal** or **ordinal**. |
| minimumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.| | minimumIntegerDigits | number | Yes | Yes | Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**. |
| minimumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**.| | minimumFractionDigits | number | Yes | Yes | Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**. |
| maximumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.| | maximumFractionDigits | number | Yes | Yes | Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**. |
| minimumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.| | minimumSignificantDigits | number | Yes | Yes | Minimum number of the least significant digits. The value ranges from **1** to **21**. |
| maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.| | maximumSignificantDigits | number | Yes | Yes | Maximum number of the least significant digits. The value ranges from **1** to **21**. |
## RelativeTimeFormat<sup>8+</sup> ## RelativeTimeFormat<sup>8+</sup>
...@@ -594,7 +594,7 @@ Creates a **RelativeTimeFormat** object. ...@@ -594,7 +594,7 @@ Creates a **RelativeTimeFormat** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Example **Example**
``` ```
var relativetimefmt = new Intl.RelativeTimeFormat(); var relativetimefmt = new Intl.RelativeTimeFormat();
``` ```
...@@ -602,19 +602,19 @@ Creates a **RelativeTimeFormat** object. ...@@ -602,19 +602,19 @@ Creates a **RelativeTimeFormat** object.
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions) constructor(locale: string | Array&lt;string&gt;, options?: RelativeTimeFormatInputOptions)
Creates a **RelativeTimeFormat** object. Creates a **RelativeTimeFormat** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
Parameters Parameters
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | No| Options for creating a **RelativeTimeFormat** object.| | options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | No | Options for creating a **RelativeTimeFormat** object. |
- Example **Example**
``` ```
var relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {"localeMatcher": "lookup", "numeric": "always", "style": "long"}); var relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {"localeMatcher": "lookup", "numeric": "always", "style": "long"});
``` ```
...@@ -628,18 +628,18 @@ Formats the value and unit based on the specified locale and formatting options. ...@@ -628,18 +628,18 @@ Formats the value and unit based on the specified locale and formatting options.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ---------------------------------------- |
| value | number | Yes| Value to format.| | value | number | Yes | Value to format. |
| unit | string | Yes| Unit to format. The value can be any of the following: **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, **second**.| | unit | string | Yes | Unit to format. The value can be any of the following: **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, **second**.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------- |
| string | Relative time after formatting.| | string | Relative time after formatting.|
- Example **Example**
``` ```
var relativetimefmt = new Intl.RelativeTimeFormat("zh-CN"); var relativetimefmt = new Intl.RelativeTimeFormat("zh-CN");
relativetimefmt.format(3, "quarter") relativetimefmt.format(3, "quarter")
...@@ -648,24 +648,24 @@ Formats the value and unit based on the specified locale and formatting options. ...@@ -648,24 +648,24 @@ Formats the value and unit based on the specified locale and formatting options.
### formatToParts<sup>8+</sup> ### formatToParts<sup>8+</sup>
formatToParts(value: number, unit: string): Array<object> formatToParts(value: number, unit: string): Array&lt;object&gt;
Returns an array of RelativeTimeFormat objects in parts for locale-aware formatting. Returns an array of RelativeTimeFormat objects in parts for locale-aware formatting.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ---------------------------------------- |
| value | number | Yes| Value to format.| | value | number | Yes | Value to format. |
| unit | string | Yes| Unit to format. The value can be any of the following: **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, **second**.| | unit | string | Yes | Unit to format. The value can be any of the following: **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, **second**.|
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------- | --------------------------- |
| Array<object> | An array of **RelativeTimeFormat** objects in parts.| | Array&lt;object&gt; | An array of **RelativeTimeFormat** objects in parts.|
- Example **Example**
``` ```
var relativetimefmt = new Intl.RelativeTimeFormat("en", {"numeric": "auto"}); var relativetimefmt = new Intl.RelativeTimeFormat("en", {"numeric": "auto"});
var parts = relativetimefmt.format(10, "seconds"); var parts = relativetimefmt.format(10, "seconds");
...@@ -680,12 +680,12 @@ Obtains the formatting options for **RelativeTimeFormat** objects. ...@@ -680,12 +680,12 @@ Obtains the formatting options for **RelativeTimeFormat** objects.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value **Return Value**
| Type| Description| | Type | Description |
| -------- | -------- | | ---------------------------------------- | --------------------------------- |
| [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions) | Formatting options for **RelativeTimeFormat** objects.| | [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions) | Formatting options for **RelativeTimeFormat** objects.|
- Example **Example**
``` ```
var relativetimefmt= new Intl.RelativeTimeFormat("en-GB"); var relativetimefmt= new Intl.RelativeTimeFormat("en-GB");
relativetimefmt.resolvedOptions(); relativetimefmt.resolvedOptions();
...@@ -698,11 +698,11 @@ Represents the properties of a **RelativeTimeFormat** object. ...@@ -698,11 +698,11 @@ Represents the properties of a **RelativeTimeFormat** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------------- | ------ | ---- | ---- | ---------------------------------------- |
| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.| | localeMatcher | string | Yes | Yes | Locale matching algorithm. The value can be **lookup** or **best fit**.|
| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.| | numeric | string | Yes | Yes | Format of the output message. The value can be **always** or **auto**. |
| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.| | style | string | Yes | Yes | Length of an internationalized message. The value can be **long**, **short**, or **narrow**.|
## RelativeTimeFormatResolvedOptions<sup>8+</sup><a name=relativetimeformatresolvedoptions></a> ## RelativeTimeFormatResolvedOptions<sup>8+</sup><a name=relativetimeformatresolvedoptions></a>
...@@ -711,9 +711,9 @@ Represents the properties of a **RelativeTimeFormat** object. ...@@ -711,9 +711,9 @@ Represents the properties of a **RelativeTimeFormat** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | --------------- | ------ | ---- | ---- | ---------------------------------------- |
| locale | string | Yes| Yes| A string containing locale information, including the language, optional script, and region.| | locale | string | Yes | Yes | A string containing locale information, including the language, optional script, and region. |
| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.| | numeric | string | Yes | Yes | Format of the output message. The value can be **always** or **auto**. |
| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.| | style | string | Yes | Yes | Length of an internationalized message. The value can be **long**, **short**, or **narrow**.|
| numberingSystem | string | Yes| Yes| Numbering system.| | numberingSystem | string | Yes | Yes | Numbering system. |
...@@ -176,7 +176,7 @@ let result = linkedList.get(2); ...@@ -176,7 +176,7 @@ let result = linkedList.get(2);
### getLastIndexOf ### getLastIndexOf
getLastIndexOf(element: T): number; getLastIndexOf(element: T): number
Obtains the index of the last occurrence of the specified entry in this container. Obtains the index of the last occurrence of the specified entry in this container.
...@@ -404,11 +404,10 @@ let result = linkedList.removeLastFound(4); ...@@ -404,11 +404,10 @@ let result = linkedList.removeLastFound(4);
``` ```
### clone ### clone
clone(): LinkedList&lt;T&gt;
Clones this container and returns a copy. clone(): LinkedList&lt;T&gt;
The modification to the copy does not affect the original instance. Clones this container and returns a copy. The modification to the copy does not affect the original instance.
**Return value** **Return value**
...@@ -428,6 +427,7 @@ let result = linkedList.clone(); ...@@ -428,6 +427,7 @@ let result = linkedList.clone();
``` ```
### forEach ### forEach
forEach(callbackfn: (value: T, index?: number, LinkedList?: LinkedList&lt;T&gt;) => void, forEach(callbackfn: (value: T, index?: number, LinkedList?: LinkedList&lt;T&gt;) => void,
thisArg?: Object): void thisArg?: Object): void
...@@ -462,6 +462,7 @@ linkedList.forEach((value, index) => { ...@@ -462,6 +462,7 @@ linkedList.forEach((value, index) => {
``` ```
### clear ### clear
clear(): void clear(): void
Clears this container and sets its length to **0**. Clears this container and sets its length to **0**.
...@@ -478,6 +479,7 @@ linkedList.clear(); ...@@ -478,6 +479,7 @@ linkedList.clear();
``` ```
### set ### set
set(index: number, element: T): T set(index: number, element: T): T
Replaces an entry at the specified position in this container with a given entry. Replaces an entry at the specified position in this container with a given entry.
...@@ -507,6 +509,7 @@ let result = linkedList.set(2, "b"); ...@@ -507,6 +509,7 @@ let result = linkedList.set(2, "b");
``` ```
### convertToArray ### convertToArray
convertToArray(): Array&lt;T&gt; convertToArray(): Array&lt;T&gt;
Converts this container into an array. Converts this container into an array.
...@@ -575,7 +578,7 @@ linkedList.getLast(); ...@@ -575,7 +578,7 @@ linkedList.getLast();
### [Symbol.iterator] ### [Symbol.iterator]
[Symbol.iterator]\(): IterableIterator&lt;T&gt;; [Symbol.iterator]\(): IterableIterator&lt;T&gt;
Obtains an iterator, each item of which is a JavaScript object. Obtains an iterator, each item of which is a JavaScript object.
......
...@@ -254,7 +254,7 @@ Enumerates the media description keys. ...@@ -254,7 +254,7 @@ Enumerates the media description keys.
| MD_KEY_BITRATE | "bitrate" | Bit rate, which is a number, in units of bit/s. | | MD_KEY_BITRATE | "bitrate" | Bit rate, which is a number, in units of bit/s. |
| MD_KEY_WIDTH | "width" | Video width, which is a number, in units of pixel. | | MD_KEY_WIDTH | "width" | Video width, which is a number, in units of pixel. |
| MD_KEY_HEIGHT | "height" | Video height, which is a number, in units of pixel. | | MD_KEY_HEIGHT | "height" | Video height, which is a number, in units of pixel. |
| MD_KEY_FRAME_RATE | "frame_rate" | Video frame rate, which is a number, in units of 100 fps. | | MD_KEY_FRAME_RATE | "frame_rate" | Video frame rate, which is a number, in units of 100 fps.|
| MD_KEY_AUD_CHANNEL_COUNT | "channel_count" | Number of audio channels, which is a number. | | MD_KEY_AUD_CHANNEL_COUNT | "channel_count" | Number of audio channels, which is a number. |
| MD_KEY_AUD_SAMPLE_RATE | "sample_rate" | Sampling rate, which is a number, in units of Hz. | | MD_KEY_AUD_SAMPLE_RATE | "sample_rate" | Sampling rate, which is a number, in units of Hz. |
...@@ -265,7 +265,7 @@ Enumerates the buffering event types. ...@@ -265,7 +265,7 @@ Enumerates the buffering event types.
**System capability**: SystemCapability.Multimedia.Media.Core **System capability**: SystemCapability.Multimedia.Media.Core
| Name | Value | Description | | Name | Value | Description |
| ----------------- | ---- | -------------------------- | | ----------------- | ---- | -------------------------------- |
| BUFFERING_START | 1 | Buffering starts. | | BUFFERING_START | 1 | Buffering starts. |
| BUFFERING_END | 2 | Buffering ends. | | BUFFERING_END | 2 | Buffering ends. |
| BUFFERING_PERCENT | 3 | Buffering progress, in percent. | | BUFFERING_PERCENT | 3 | Buffering progress, in percent. |
...@@ -283,7 +283,7 @@ For details about the audio playback demo, see [Audio Playback Development](../. ...@@ -283,7 +283,7 @@ For details about the audio playback demo, see [Audio Playback Development](../.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ----------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | ----------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| src | string | Yes | Yes | Audio media URI. The mainstream audio formats (MPEG-4, AAC, MPEG-3, OGG, and WAV) are supported.<br>**Example of supported URIs**:<br>1. FD playback: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP network playback: http://xx<br>3. HLS network playback path (under development)<br>**Note**:<br>To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly. | | src | string | Yes | Yes | Audio media URI. The mainstream audio formats (MPEG-4, AAC, MPEG-3, OGG, and WAV) are supported.<br>**Example of supported URIs**:<br>1. FD playback: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP network playback: http://xx<br>3. HLS network playback path (under development)<br>**Note**:<br>To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly.|
| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. | | loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. |
| currentTime | number | Yes | No | Current audio playback position. | | currentTime | number | Yes | No | Current audio playback position. |
| duration | number | Yes | No | Audio duration. | | duration | number | Yes | No | Audio duration. |
...@@ -368,7 +368,7 @@ Seeks to the specified playback position. ...@@ -368,7 +368,7 @@ Seeks to the specified playback position.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------ | | ------ | ------ | ---- | ------------------------------------ |
| timeMs | number | Yes | Position to seek to, in milliseconds.| | timeMs | number | Yes | Position to seek to, in milliseconds.|
**Example** **Example**
...@@ -677,7 +677,7 @@ For details about the video playback demo, see [Video Playback Development](../. ...@@ -677,7 +677,7 @@ For details about the video playback demo, see [Video Playback Development](../.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | | ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| url<sup>8+</sup> | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.<br>**Example of supported URIs**:<br>1. FD playback: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP network playback: http://xx<br>3. HLS network playback path (under development)<br>**Note**:<br>To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly. | | url<sup>8+</sup> | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.<br>**Example of supported URIs**:<br>1. FD playback: fd://xx<br>![](figures/en-us_image_url.png)<br>2. HTTP network playback: http://xx<br>3. HLS network playback path (under development)<br>**Note**:<br>To use media materials, you must declare the read permission. Otherwise, the media materials cannot be played properly.|
| loop<sup>8+</sup> | boolean | Yes | Yes | Whether to loop video playback. The value **true** means to loop video playback, and **false** means the opposite. | | loop<sup>8+</sup> | boolean | Yes | Yes | Whether to loop video playback. The value **true** means to loop video playback, and **false** means the opposite. |
| currentTime<sup>8+</sup> | number | Yes | No | Current video playback position. | | currentTime<sup>8+</sup> | number | Yes | No | Current video playback position. |
| duration<sup>8+</sup> | number | Yes | No | Video duration. The value **-1** indicates the live streaming mode. | | duration<sup>8+</sup> | number | Yes | No | Video duration. The value **-1** indicates the live streaming mode. |
...@@ -698,7 +698,7 @@ Sets **SurfaceId**. This API uses a callback to return the result. ...@@ -698,7 +698,7 @@ Sets **SurfaceId**. This API uses a callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | -------- | ---- | ------------------------- | | --------- | -------- | ---- | ------------------------- |
| surfaceId | string | Yes | Surface ID to set. | | surfaceId | string | Yes | Surface ID to set. |
| callback | function | Yes | Callback used to set **SurfaceId**.| | callback | function | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -730,7 +730,7 @@ Sets **SurfaceId**. This API uses a promise to return the result. ...@@ -730,7 +730,7 @@ Sets **SurfaceId**. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| ------------- | ------------------------------ | | ------------- | ------------------------------ |
| Promise<void> | Promise used to set **SurfaceId**.| | Promise<void> | Promise used to return the result.|
**Example** **Example**
...@@ -1027,9 +1027,9 @@ Seeks to the specified playback position. The next key frame at the specified po ...@@ -1027,9 +1027,9 @@ Seeks to the specified playback position. The next key frame at the specified po
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------ | | -------- | -------- | ---- | ------------------------------------ |
| timeMs | number | Yes | Position to seek to, in milliseconds.| | timeMs | number | Yes | Position to seek to, in milliseconds.|
| callback | function | Yes | Callback used to return the result.| | callback | function | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -1054,10 +1054,10 @@ Seeks to the specified playback position. This API uses a callback to return the ...@@ -1054,10 +1054,10 @@ Seeks to the specified playback position. This API uses a callback to return the
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------ | | -------- | ---------------------- | ---- | ------------------------------------ |
| timeMs | number | Yes | Position to seek to, in milliseconds.| | timeMs | number | Yes | Position to seek to, in milliseconds.|
| mode | [SeekMode](#seekmode8) | Yes | Seek mode. | | mode | [SeekMode](#seekmode8) | Yes | Seek mode. |
| callback | function | Yes | Callback used to return the result.| | callback | function | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -1082,7 +1082,7 @@ Seeks to the specified playback position. If **mode** is not specified, the next ...@@ -1082,7 +1082,7 @@ Seeks to the specified playback position. If **mode** is not specified, the next
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ---------------------- | ---- | ------------------------------ | | ------ | ---------------------- | ---- | ------------------------------------ |
| timeMs | number | Yes | Position to seek to, in milliseconds.| | timeMs | number | Yes | Position to seek to, in milliseconds.|
| mode | [SeekMode](#seekmode8) | No | Seek mode. | | mode | [SeekMode](#seekmode8) | No | Seek mode. |
...@@ -1803,11 +1803,14 @@ Describes audio recording configurations. ...@@ -1803,11 +1803,14 @@ Describes audio recording configurations.
| numberOfChannels | number | No | Number of audio channels. The default value is **2**. | | numberOfChannels | number | No | Number of audio channels. The default value is **2**. |
| format | [AudioOutputFormat](#audiooutputformat) | No | Audio output format. The default value is **MPEG_4**. | | format | [AudioOutputFormat](#audiooutputformat) | No | Audio output format. The default value is **MPEG_4**. |
| location | [Location](#location) | No | Geographical location of the recorded audio. | | location | [Location](#location) | No | Geographical location of the recorded audio. |
| uri | string | Yes | Audio output URI. Supported: fd://xx&nbsp;(fd&nbsp;number)<br>![en-us_image_0000001164217678](figures/en-us_image_url.png)<br>The file must be created by the caller and granted with proper permissions.| | uri | string | Yes | Audio output URI. Supported: fd://xx&nbsp;(fd&nbsp;number)<br>![en-us_image_0000001164217678](figures/en-us_image_url.png) <br>The file must be created by the caller and granted with proper permissions.|
| audioEncoderMime | [CodecMimeType](#codecmimetype8) | No | Audio encoding format. | | audioEncoderMime | [CodecMimeType](#codecmimetype8) | No | Audio encoding format. |
## AudioEncoder ## AudioEncoder<sup>(deprecated)</sup>
> **NOTE**
> This API is deprecated since API version 8. You are advised to use [CodecMimeType](#codecmimetype8) instead.
Enumerates the audio encoding formats. Enumerates the audio encoding formats.
...@@ -1815,14 +1818,17 @@ Enumerates the audio encoding formats. ...@@ -1815,14 +1818,17 @@ Enumerates the audio encoding formats.
| Name | Default Value| Description | | Name | Default Value| Description |
| ------- | ------ | ------------------------------------------------------------ | | ------- | ------ | ------------------------------------------------------------ |
| DEFAULT | 0 | Default audio encoding format, which is Adaptive Multi Rate-Narrow Band Speech Codec (AMR-NB).<br>This API is merely defined in OpenHarmony 3.1 Release and cannot be used currently. It can be used in OpenHarmony 3.1 MR.| | DEFAULT | 0 | Default audio encoding format, which is Adaptive Multi Rate-Narrow Band Speech Codec (AMR-NB).<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| AMR_NB | 1 | AMR-NB.<br>This API is merely defined in OpenHarmony 3.1 Release and cannot be used currently. It can be used in OpenHarmony 3.1 MR.| | AMR_NB | 1 | AMR-NB.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| AMR_WB | 2 | Adaptive Multi Rate-Wide Band Speech Codec (AMR-WB).<br>This API is merely defined in OpenHarmony 3.1 Release and cannot be used currently. It can be used in OpenHarmony 3.1 MR.| | AMR_WB | 2 | Adaptive Multi Rate-Wide Band Speech Codec (AMR-WB).<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| AAC_LC | 3 | Advanced Audio Coding Low Complexity (AAC-LC).| | AAC_LC | 3 | Advanced Audio Coding Low Complexity (AAC-LC).|
| HE_AAC | 4 | High-Efficiency Advanced&nbsp;Audio&nbsp;Coding (HE_AAC).<br>This API is merely defined in OpenHarmony 3.1 Release and cannot be used currently. It can be used in OpenHarmony 3.1 MR.| | HE_AAC | 4 | High-Efficiency Advanced&nbsp;Audio&nbsp;Coding (HE_AAC).<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
## AudioOutputFormat<sup>(deprecated)</sup>
## AudioOutputFormat > **NOTE**
> This API is deprecated since API version 8. You are advised to use [ContainerFormatType ](#containerformattype8) instead.
Enumerates the audio output formats. Enumerates the audio output formats.
...@@ -1830,10 +1836,10 @@ Enumerates the audio output formats. ...@@ -1830,10 +1836,10 @@ Enumerates the audio output formats.
| Name | Default Value| Description | | Name | Default Value| Description |
| -------- | ------ | ------------------------------------------------------------ | | -------- | ------ | ------------------------------------------------------------ |
| DEFAULT | 0 | Default encapsulation format, which is MPEG-4.<br>This API is merely defined in OpenHarmony 3.1 Release and cannot be used currently. It can be used in OpenHarmony 3.1 MR.| | DEFAULT | 0 | Default encapsulation format, which is MPEG-4.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| MPEG_4 | 2 | MPEG-4. | | MPEG_4 | 2 | MPEG-4. |
| AMR_NB | 3 | AMR_NB.<br>This API is merely defined in OpenHarmony 3.1 Release and cannot be used currently. It can be used in OpenHarmony 3.1 MR.| | AMR_NB | 3 | AMR_NB.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| AMR_WB | 4 | AMR_WB.<br>This API is merely defined in OpenHarmony 3.1 Release and cannot be used currently. It can be used in OpenHarmony 3.1 MR.| | AMR_WB | 4 | AMR_WB.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| AAC_ADTS | 6 | Audio Data Transport Stream (ADTS), which is a transport stream format of AAC-based audio.| | AAC_ADTS | 6 | Audio Data Transport Stream (ADTS), which is a transport stream format of AAC-based audio.|
## VideoRecorder<sup>9+</sup> ## VideoRecorder<sup>9+</sup>
...@@ -1856,7 +1862,7 @@ prepare(config: VideoRecorderConfig, callback: AsyncCallback\<void>): void; ...@@ -1856,7 +1862,7 @@ prepare(config: VideoRecorderConfig, callback: AsyncCallback\<void>): void;
Sets video recording parameters in asynchronous mode. This API uses a callback to return the result. Sets video recording parameters in asynchronous mode. This API uses a callback to return the result.
**Required permissions:** ohos.permission.MICROPHONE and ohos.permission.CAMERA **Required permissions:** ohos.permission.MICROPHONE
**System capability**: SystemCapability.Multimedia.Media.VideoRecorder **System capability**: SystemCapability.Multimedia.Media.VideoRecorder
...@@ -2434,7 +2440,7 @@ Enumerates the video recording states. You can obtain the state through the **st ...@@ -2434,7 +2440,7 @@ Enumerates the video recording states. You can obtain the state through the **st
| playing | string | Video recording is in progress. | | playing | string | Video recording is in progress. |
| paused | string | Video recording is paused. | | paused | string | Video recording is paused. |
| stopped | string | Video recording is stopped. | | stopped | string | Video recording is stopped. |
| error | string | Audio playback is in the error state. | | error | string | Video recording is in the error state. |
## VideoRecorderConfig<sup>9+</sup> ## VideoRecorderConfig<sup>9+</sup>
...@@ -2449,7 +2455,7 @@ Describes the video recording parameters. ...@@ -2449,7 +2455,7 @@ Describes the video recording parameters.
| profile | [VideoRecorderProfile](#videorecorderprofile9) | Yes | Video recording profile. | | profile | [VideoRecorderProfile](#videorecorderprofile9) | Yes | Video recording profile. |
| rotation | number | No | Rotation angle of the recorded video. | | rotation | number | No | Rotation angle of the recorded video. |
| location | [Location](#location) | No | Geographical location of the recorded video. | | location | [Location](#location) | No | Geographical location of the recorded video. |
| url | string | Yes | Video output URL. Supported: fd://xx&nbsp;(fd&nbsp;number)<br>![](figures/en-us_image_url.png) <br>The file must be created by the caller and granted with proper permissions.| | url | string | Yes | Video output URL. Supported: fd://xx&nbsp;(fd&nbsp;number)<br>![](figures/zh-cn_image_url.png) <br>The file must be created by the caller and granted with proper permissions.|
## AudioSourceType<sup>9+</sup> ## AudioSourceType<sup>9+</sup>
...@@ -2500,7 +2506,7 @@ Enumerates the container format types (CFTs). ...@@ -2500,7 +2506,7 @@ Enumerates the container format types (CFTs).
| Name | Value | Description | | Name | Value | Description |
| ----------- | ----- | --------------------- | | ----------- | ----- | --------------------- |
| CFT_MPEG_4 | "mp4" | Video container format MP4.| | CFT_MPEG_4 | "mp4" | Video container format MPEG-4 .|
| CFT_MPEG_4A | "m4a" | Audio container format M4A.| | CFT_MPEG_4A | "m4a" | Audio container format M4A.|
## Location ## Location
......
...@@ -8,19 +8,19 @@ ...@@ -8,19 +8,19 @@
import mediaLibrary from '@ohos.multimedia.medialibrary'; import mediaLibrary from '@ohos.multimedia.medialibrary';
``` ```
## mediaLibrary.getMediaLibrary ## mediaLibrary.getMediaLibrary<sup>8+</sup>
getMediaLibrary(context: Context): MediaLibrary getMediaLibrary(context: Context): MediaLibrary
Obtains a **MediaLibrary** instance, which is used to access and modify personal data of users. Obtains a **MediaLibrary** instance, which is used to access and modify personal media data such as audios, videos, images, and documents.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ------- | ---- | ---------------------------------------- | | ------- | ------- | ---- | -------------------------- |
| context | Context | Yes | Context of the ability. This parameter is optional for API version 7 and earlier versions, but mandatory for API version 8 and later versions.| | context | Context | Yes | Context of the ability.|
**Return value** **Return value**
...@@ -36,9 +36,31 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -36,9 +36,31 @@ import featureAbility from '@ohos.ability.featureAbility';
var context = featureAbility.getContext() var context = featureAbility.getContext()
var media = mediaLibrary.getMediaLibrary(context); var media = mediaLibrary.getMediaLibrary(context);
``` ```
## mediaLibrary.getMediaLibrary
getMediaLibrary(): MediaLibrary
Obtains a **MediaLibrary** instance, which is used to access and modify personal media data such as audios, videos, images, and documents.
> **Note**: This API is no longer maintained since API version 8. You are advised to use [mediaLibrary.getMediaLibrary<sup>8+</sup>](#medialibrarygetmedialibrary8) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
**Return value**
| Type | Description |
| ----------------------------- | :--------- |
| [MediaLibrary](#medialibrary) | **MediaLibrary** instance.|
**Example**
```js
var media = mediaLibrary.getMediaLibrary();
```
## MediaLibrary ## MediaLibrary
### getFileAssets<sup>8+</sup> ### getFileAssets<sup>7+</sup>
getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void
...@@ -51,10 +73,10 @@ Obtains file assets (also called files). This API uses an asynchronous callback ...@@ -51,10 +73,10 @@ Obtains file assets (also called files). This API uses an asynchronous callback
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ | | -------- | --------------------------------------------------- | ---- | --------------------------------- |
| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files. | | options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the files. |
| callback | AsyncCallback<[FetchFileResult](#fetchfileresult8)> | Yes | Asynchronous callback of **FetchFileResult**.| | callback | AsyncCallback<[FetchFileResult](#fetchfileresult7)> | Yes | Asynchronous callback of **FetchFileResult**.|
**Example** **Example**
...@@ -76,7 +98,7 @@ mediaLibrary.getFileAssets(imagesfetchOp, (error, fetchFileResult) => { ...@@ -76,7 +98,7 @@ mediaLibrary.getFileAssets(imagesfetchOp, (error, fetchFileResult) => {
} }
}); });
``` ```
### getFileAssets<sup>8+</sup> ### getFileAssets<sup>7+</sup>
getFileAssets(options: MediaFetchOptions): Promise&lt;FetchFileResult&gt; getFileAssets(options: MediaFetchOptions): Promise&lt;FetchFileResult&gt;
...@@ -88,15 +110,15 @@ Obtains file assets. This API uses a promise to return the result. ...@@ -88,15 +110,15 @@ Obtains file assets. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------------------------- | ---- | ------ | | ------- | ---------------------------------------- | ---- | ------------ |
| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files.| | options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the files.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------ | ------- | | ------------------------------------ | -------------- |
| [FetchFileResult](#fetchfileresult8) | Result set of the file retrieval operation.| | [FetchFileResult](#fetchfileresult7) | Result set of the file retrieval operation.|
**Example** **Example**
...@@ -171,12 +193,12 @@ Creates a media asset. This API uses an asynchronous callback to return the resu ...@@ -171,12 +193,12 @@ Creates a media asset. This API uses an asynchronous callback to return the resu
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------------ | --------------------------------------- | ---- | ---------------------------------------- | | ------------ | --------------------------------------- | ---- | ------------------------------------------------------------ |
| mediaType | [MediaType](#mediatype) | Yes | Media type. | | mediaType | [MediaType](#mediatype8) | Yes | Media type. |
| displayName | string | Yes | Display file name. | | displayName | string | Yes | Display file name. |
| relativePath | string | Yes | Path for storing the file. You can use [getPublicDirectory](#getpublicdirectory8) to obtain the paths for storing different types of files.| | relativePath | string | Yes | Path for storing the file. You can use [getPublicDirectory](#getpublicdirectory8) to obtain the paths for storing different types of files.|
| callback | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Asynchronous callback for **FileAsset**. | | callback | AsyncCallback<[FileAsset](#fileasset7)> | Yes | Asynchronous callback for **FileAsset**. |
**Example** **Example**
...@@ -208,17 +230,17 @@ Creates a media asset. This API uses a promise to return the result. ...@@ -208,17 +230,17 @@ Creates a media asset. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------------ | ----------------------- | ---- | ---------------------------------------- | | ------------ | ------------------------ | ---- | ------------------------------------------------------------ |
| mediaType | [MediaType](#mediatype) | Yes | Media type. | | mediaType | [MediaType](#mediatype8) | Yes | Media type. |
| displayName | string | Yes | Display file name. | | displayName | string | Yes | Display file name. |
| relativePath | string | Yes | Relative path. You can use [getPublicDirectory](#getpublicdirectory8) to obtain the relative path of the level-1 directory of different types of media files.| | relativePath | string | Yes | Relative path. You can use [getPublicDirectory](#getpublicdirectory8) to obtain the relative path of the level-1 directory of different types of media files.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------ | ------------- | | ------------------------ | ----------------- |
| [FileAsset](#fileasset8) | Media data (FileAsset).| | [FileAsset](#fileasset7) | Media data (FileAsset).|
**Example** **Example**
...@@ -246,9 +268,9 @@ Obtains a public directory. This API uses an asynchronous callback to return the ...@@ -246,9 +268,9 @@ Obtains a public directory. This API uses an asynchronous callback to return the
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ----------------- | | -------- | -------------------------------- | ---- | ------------------------- |
| type | [DirectoryType](#directorytype) | Yes | Type of the public directory. | | type | [DirectoryType](#directorytype8) | Yes | Type of the public directory. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the public directory.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the public directory.|
**Example** **Example**
...@@ -274,15 +296,15 @@ Obtains a public directory. This API uses a promise to return the result. ...@@ -274,15 +296,15 @@ Obtains a public directory. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type | Mandatory| Description |
| ---- | ------------------------------- | ---- | ------ | | ------ | -------------------------------- | ---- | ------------ |
| type | [DirectoryType](#directorytype) | Yes | Type of the public directory.| | type | [DirectoryType](#directorytype8) | Yes | Type of the public directory.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------- | -------- | | ---------------- | ---------------- |
| Promise<string> | Promise used to return the public directory.| | Promise\<string> | Promise used to return the public directory.|
**Example** **Example**
...@@ -298,7 +320,7 @@ async function example() { ...@@ -298,7 +320,7 @@ async function example() {
} }
``` ```
### getAlbums<sup>8+</sup> ### getAlbums<sup>7+</sup>
getAlbums(options: MediaFetchOptions, callback: AsyncCallback<Array&lt;Album&gt;>): void getAlbums(options: MediaFetchOptions, callback: AsyncCallback<Array&lt;Album&gt;>): void
...@@ -310,10 +332,10 @@ Obtains the albums. This API uses an asynchronous callback to return the result. ...@@ -310,10 +332,10 @@ Obtains the albums. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ---------------- | | -------- | -------------------------------------------- | ---- | --------------------------- |
| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the albums. | | options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the albums. |
| callback | AsyncCallback&lt;Array<[Album](#album8)>&gt; | Yes | Callback used to return the albums.| | callback | AsyncCallback&lt;Array<[Album](#album7)>&gt; | Yes | Callback used to return the albums.|
**Example** **Example**
...@@ -333,7 +355,7 @@ mediaLibrary.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => { ...@@ -333,7 +355,7 @@ mediaLibrary.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => {
}) })
``` ```
### getAlbums<sup>8+</sup> ### getAlbums<sup>7+</sup>
getAlbums(options: MediaFetchOptions): Promise<Array&lt;Album&gt;> getAlbums(options: MediaFetchOptions): Promise<Array&lt;Album&gt;>
...@@ -345,15 +367,15 @@ Obtains the albums. This API uses a promise to return the result. ...@@ -345,15 +367,15 @@ Obtains the albums. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------------------------- | ---- | ------ | | ------- | ---------------------------------------- | ---- | ------------ |
| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the albums.| | options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the albums.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | --------- | | -------------------------------- | ------------- |
| Promise<Array<[Album](#album8)>> | Promise used to return the albums.| | Promise<Array<[Album](#album7)>> | Promise used to return the albums.|
**Example** **Example**
...@@ -690,7 +712,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => { ...@@ -690,7 +712,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => {
``` ```
## FileAsset<sup>8+</sup> ## FileAsset<sup>7+</sup>
Provides APIs for encapsulating file asset attributes. Provides APIs for encapsulating file asset attributes.
...@@ -698,28 +720,28 @@ Provides APIs for encapsulating file asset attributes. ...@@ -698,28 +720,28 @@ Provides APIs for encapsulating file asset attributes.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable | Writable | Description | | Name | Type | Readable| Writable| Description |
| ------------ | ----------------------- | ---- | ---- | --------------------------------------- | | ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
| id | number | Yes | No | File asset ID. | | id | number | Yes | No | File asset ID. |
| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2.| | uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. |
| mimeType | string | Yes | No | Extended file attributes. | | mimeType | string | Yes | No | Extended file attributes. |
| mediaType | [MediaType](#mediatype) | Yes | No | Media type. | | mediaType<sup>8+</sup> | [MediaType](#mediatype8) | Yes | No | Media type. |
| displayName | string | Yes | Yes | Display file name, including the file name extension. | | displayName | string | Yes | Yes | Display file name, including the file name extension. |
| title | string | Yes | Yes | Title in the file. | | title | string | Yes | Yes | Title in the file. |
| relativePath | string | Yes | Yes | Relative public directory of the file. | | relativePath<sup>8+</sup> | string | Yes | Yes | Relative public directory of the file. |
| parent | number | Yes | No | Parent directory ID. | | parent<sup>8+</sup> | number | Yes | No | Parent directory ID. |
| size | number | Yes | No | File size, in bytes. | | size | number | Yes | No | File size, in bytes. |
| dateAdded | number | Yes | No | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.) | | dateAdded | number | Yes | No | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.) |
| dateModified | number | Yes | No | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.) | | dateModified | number | Yes | No | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.) |
| dateTaken | number | Yes | No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) | | dateTaken | number | Yes | No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) |
| artist | string | Yes | No | Artist of the file. | | artist<sup>8+</sup> | string | Yes | No | Artist of the file. |
| audioAlbum | string | Yes | No | Audio album. | | audioAlbum<sup>8+</sup> | string | Yes | No | Audio album. |
| width | number | Yes | No | Image width, in pixels. | | width | number | Yes | No | Image width, in pixels. |
| height | number | Yes | No | Image height, in pixels. | | height | number | Yes | No | Image height, in pixels. |
| orientation | number | Yes | Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees). | | orientation | number | Yes | Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees).|
| duration | number | Yes | No | Duration, in seconds. | | duration<sup>8+</sup> | number | Yes | No | Duration, in seconds. |
| albumId | number | Yes | No | ID of the album to which the file belongs. | | albumId | number | Yes | No | ID of the album to which the file belongs. |
| albumUri | string | Yes | No | URI of the album to which the file belongs. | | albumUri<sup>8+</sup> | string | Yes | No | URI of the album to which the file belongs. |
| albumName | string | Yes | No | Name of the album to which the file belongs. | | albumName | string | Yes | No | Name of the album to which the file belongs. |
...@@ -1134,8 +1156,12 @@ async function example() { ...@@ -1134,8 +1156,12 @@ async function example() {
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.getThumbnail(size, (err, pixelmap) => { asset.getThumbnail(size)
.then((pixelmap) => {
console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap);
})
.catch((err) => {
console.info('mediaLibraryTest : getThumbnail fail'+ err);
}); });
} }
``` ```
...@@ -1460,11 +1486,11 @@ async function example() { ...@@ -1460,11 +1486,11 @@ async function example() {
} }
``` ```
## FetchFileResult<sup>8+</sup> ## FetchFileResult<sup>7+</sup>
Implements the result set of the file retrieval operation. Implements the result set of the file retrieval operation.
### getCount<sup>8+</sup> ### getCount<sup>7+</sup>
getCount(): number getCount(): number
...@@ -1493,7 +1519,7 @@ async function example() { ...@@ -1493,7 +1519,7 @@ async function example() {
} }
``` ```
### isAfterLast<sup>8+</sup> ### isAfterLast<sup>7+</sup>
isAfterLast(): boolean isAfterLast(): boolean
...@@ -1536,7 +1562,7 @@ async function example() { ...@@ -1536,7 +1562,7 @@ async function example() {
} }
``` ```
### close<sup>8+</sup> ### close<sup>7+</sup>
close(): void close(): void
...@@ -1560,7 +1586,7 @@ async function example() { ...@@ -1560,7 +1586,7 @@ async function example() {
} }
``` ```
### getFirstObject<sup>8+</sup> ### getFirstObject<sup>7+</sup>
getFirstObject(callback: AsyncCallback&lt;FileAsset&gt;): void getFirstObject(callback: AsyncCallback&lt;FileAsset&gt;): void
...@@ -1570,9 +1596,9 @@ Obtains the first file asset in the result set. This API uses an asynchronous ca ...@@ -1570,9 +1596,9 @@ Obtains the first file asset in the result set. This API uses an asynchronous ca
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | -------------------------- | | -------- | --------------------------------------------- | ---- | ------------------------------------------- |
| callback | AsyncCallback&lt;[FileAsset](#fileasset8)&gt; | Yes | Callback used to return the first file asset.| | callback | AsyncCallback&lt;[FileAsset](#fileasset7)&gt; | Yes | Callback used to return the first file asset.|
**Example** **Example**
...@@ -1596,7 +1622,7 @@ async function example() { ...@@ -1596,7 +1622,7 @@ async function example() {
} }
``` ```
### getFirstObject<sup>8+</sup> ### getFirstObject<sup>7+</sup>
getFirstObject(): Promise&lt;FileAsset&gt; getFirstObject(): Promise&lt;FileAsset&gt;
...@@ -1607,8 +1633,8 @@ Obtains the first file asset in the result set. This API uses a promise to retur ...@@ -1607,8 +1633,8 @@ Obtains the first file asset in the result set. This API uses a promise to retur
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | -------------------- | | --------------------------------------- | -------------------------- |
| Promise&lt;[FileAsset](#fileasset8)&gt; | Promise used to return the file asset.| | Promise&lt;[FileAsset](#fileasset7)&gt; | Promise used to return the file asset.|
**Example** **Example**
...@@ -1630,7 +1656,7 @@ async function example() { ...@@ -1630,7 +1656,7 @@ async function example() {
} }
``` ```
### getNextObject<sup>8+</sup> ### getNextObject<sup>7+</sup>
getNextObject(callback: AsyncCallback&lt;FileAsset&gt;): void getNextObject(callback: AsyncCallback&lt;FileAsset&gt;): void
...@@ -1642,9 +1668,9 @@ Obtains the next file asset in the result set. This API uses an asynchronous cal ...@@ -1642,9 +1668,9 @@ Obtains the next file asset in the result set. This API uses an asynchronous cal
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| --------- | ---------------------------------------- | ---- | ------------------------- | | --------- | --------------------------------------------- | ---- | ----------------------------------------- |
| callbacke | AsyncCallback&lt;[FileAsset](#fileasset8)&gt; | Yes | Callback used to return the next file asset.| | callbacke | AsyncCallback&lt;[FileAsset](#fileasset7)&gt; | Yes | Callback used to return the next file asset.|
**Example** **Example**
...@@ -1668,7 +1694,7 @@ async function example() { ...@@ -1668,7 +1694,7 @@ async function example() {
} }
``` ```
### getNextObject<sup>8+</sup> ### getNextObject<sup>7+</sup>
getNextObject(): Promise&lt;FileAsset&gt; getNextObject(): Promise&lt;FileAsset&gt;
...@@ -1681,8 +1707,8 @@ Obtains the next file asset in the result set. This API uses a promise to return ...@@ -1681,8 +1707,8 @@ Obtains the next file asset in the result set. This API uses a promise to return
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | ------------- | | --------------------------------------- | ----------------- |
| Promise&lt;[FileAsset](#fileasset8)&gt; | Promise used to return the next file asset.| | Promise&lt;[FileAsset](#fileasset7)&gt; | Promise used to return the next file asset.|
**Example** **Example**
...@@ -1702,7 +1728,7 @@ async function example() { ...@@ -1702,7 +1728,7 @@ async function example() {
} }
``` ```
### getLastObject<sup>8+</sup> ### getLastObject<sup>7+</sup>
getLastObject(callback: AsyncCallback&lt;FileAsset&gt;): void getLastObject(callback: AsyncCallback&lt;FileAsset&gt;): void
...@@ -1712,9 +1738,9 @@ Obtains the last file asset in the result set. This API uses an asynchronous cal ...@@ -1712,9 +1738,9 @@ Obtains the last file asset in the result set. This API uses an asynchronous cal
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------ | | -------- | --------------------------------------------- | ---- | --------------------------- |
| callback | AsyncCallback&lt;[FileAsset](#fileasset8)&gt; | Yes | Callback used to return the last file asset.| | callback | AsyncCallback&lt;[FileAsset](#fileasset7)&gt; | Yes | Callback used to return the last file asset.|
**Example** **Example**
...@@ -1738,7 +1764,7 @@ async function example() { ...@@ -1738,7 +1764,7 @@ async function example() {
} }
``` ```
### getLastObject<sup>8+</sup> ### getLastObject<sup>7+</sup>
getLastObject(): Promise&lt;FileAsset&gt; getLastObject(): Promise&lt;FileAsset&gt;
...@@ -1749,8 +1775,8 @@ Obtains the last file asset in the result set. This API uses a promise to return ...@@ -1749,8 +1775,8 @@ Obtains the last file asset in the result set. This API uses a promise to return
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | ------------- | | --------------------------------------- | ----------------- |
| Promise&lt;[FileAsset](#fileasset8)&gt; | Promise used to return the next file asset.| | Promise&lt;[FileAsset](#fileasset7)&gt; | Promise used to return the next file asset.|
**Example** **Example**
...@@ -1768,7 +1794,7 @@ async function example() { ...@@ -1768,7 +1794,7 @@ async function example() {
} }
``` ```
### getPositionObject<sup>8+</sup> ### getPositionObject<sup>7+</sup>
getPositionObject(index: number, callback: AsyncCallback&lt;FileAsset&gt;): void getPositionObject(index: number, callback: AsyncCallback&lt;FileAsset&gt;): void
...@@ -1781,7 +1807,7 @@ Obtains a file asset with the specified index in the result set. This API uses a ...@@ -1781,7 +1807,7 @@ Obtains a file asset with the specified index in the result set. This API uses a
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------ | | -------- | ---------------------------------------- | ---- | ------------------ |
| index | number | Yes | Index of the file asset to obtain. The value starts from **0**. | | index | number | Yes | Index of the file asset to obtain. The value starts from **0**. |
| callback | AsyncCallback&lt;[FileAsset](#fileasset8)&gt; | Yes | Callback used to return the last file asset.| | callback | AsyncCallback&lt;[FileAsset](#fileasset7)&gt; | Yes | Callback used to return the last file asset.|
**Example** **Example**
...@@ -1805,7 +1831,7 @@ async function example() { ...@@ -1805,7 +1831,7 @@ async function example() {
} }
``` ```
### getPositionObject<sup>8+</sup> ### getPositionObject<sup>7+</sup>
getPositionObject(index: number): Promise&lt;FileAsset&gt; getPositionObject(index: number): Promise&lt;FileAsset&gt;
...@@ -1824,8 +1850,8 @@ Obtains a file asset with the specified index in the result set. This API uses a ...@@ -1824,8 +1850,8 @@ Obtains a file asset with the specified index in the result set. This API uses a
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | ------------- | | --------------------------------------- | ----------------- |
| Promise&lt;[FileAsset](#fileasset8)&gt; | Promise used to return the next file asset.| | Promise&lt;[FileAsset](#fileasset7)&gt; | Promise used to return the next file asset.|
**Example** **Example**
...@@ -1849,7 +1875,7 @@ async function example() { ...@@ -1849,7 +1875,7 @@ async function example() {
} }
``` ```
### getAllObject<sup>8+</sup> ### getAllObject<sup>7+</sup>
getAllObject(callback: AsyncCallback&lt;Array&lt;FileAsset&gt;&gt;): void getAllObject(callback: AsyncCallback&lt;Array&lt;FileAsset&gt;&gt;): void
...@@ -1863,7 +1889,7 @@ Obtains all the file assets in the result set. This API uses an asynchronous cal ...@@ -1863,7 +1889,7 @@ Obtains all the file assets in the result set. This API uses an asynchronous cal
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | -------------------- |
| callback | AsyncCallback<Array<[FileAsset](#fileasset8)>> | Yes | Callback used to return the file assets.| | callback | AsyncCallback<Array<[FileAsset](#fileasset7)>> | Yes | Callback used to return the file assets.|
**Example** **Example**
...@@ -1887,7 +1913,7 @@ async function example() { ...@@ -1887,7 +1913,7 @@ async function example() {
} }
``` ```
### getAllObject<sup>8+</sup> ### getAllObject<sup>7+</sup>
getAllObject(): Promise&lt;Array&lt;FileAsset&gt;&gt; getAllObject(): Promise&lt;Array&lt;FileAsset&gt;&gt;
...@@ -1898,8 +1924,8 @@ Obtains all the file assets in the result set. This API uses a promise to return ...@@ -1898,8 +1924,8 @@ Obtains all the file assets in the result set. This API uses a promise to return
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | --------------- | | ---------------------------------------- | --------------------- |
| Promise<Array<[FileAsset](#fileasset8)>> | Promise used to return the file assets.| | Promise<Array<[FileAsset](#fileasset7)>> | Promise used to return the file assets.|
**Example** **Example**
...@@ -1917,7 +1943,7 @@ async function example() { ...@@ -1917,7 +1943,7 @@ async function example() {
} }
``` ```
## Album<sup>8+</sup> ## Album<sup>7+</sup>
Provides APIs to implement a physical album. Provides APIs to implement a physical album.
...@@ -1929,11 +1955,11 @@ Provides APIs to implement a physical album. ...@@ -1929,11 +1955,11 @@ Provides APIs to implement a physical album.
| ------------ | ------ | ---- | ---- | ------- | | ------------ | ------ | ---- | ---- | ------- |
| albumId | number | Yes | No | Album ID. | | albumId | number | Yes | No | Album ID. |
| albumName | string | Yes | Yes | Album name. | | albumName | string | Yes | Yes | Album name. |
| albumUri | string | Yes | No | Album URI. | | albumUri<sup>8+</sup> | string | Yes | No | Album URI. |
| dateModified | number | Yes | No | Date when the album was modified. | | dateModified | number | Yes | No | Date when the album was modified. |
| count | number | Yes | No | Number of files in the album.| | count<sup>8+</sup> | number | Yes | No | Number of files in the album.|
| relativePath | string | Yes | No | Relative path of the album. | | relativePath<sup>8+</sup> | string | Yes | No | Relative path of the album. |
| coverUri | string | Yes | No | URI of the cover file of the album.| | coverUri<sup>8+</sup> | string | Yes | No | URI of the cover file of the album.|
### commitModify<sup>8+</sup> ### commitModify<sup>8+</sup>
...@@ -1947,8 +1973,8 @@ Commits the modification of the album attributes to the database. This API uses ...@@ -1947,8 +1973,8 @@ Commits the modification of the album attributes to the database. This API uses
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----- | | -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Void callback.| | callback | AsyncCallback&lt;void&gt; | Yes | Void callback.|
**Example** **Example**
...@@ -2007,7 +2033,7 @@ async function example() { ...@@ -2007,7 +2033,7 @@ async function example() {
} }
``` ```
### getFileAssets<sup>8+</sup> ### getFileAssets<sup>7+</sup>
getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void
...@@ -2019,10 +2045,10 @@ Obtains the file assets in this album. This API uses an asynchronous callback to ...@@ -2019,10 +2045,10 @@ Obtains the file assets in this album. This API uses an asynchronous callback to
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ | | -------- | --------------------------------------------------- | ---- | ----------------------------------- |
| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files. | | options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the files. |
| callback | AsyncCallback<[FetchFileResult](#fetchfileresult8)> | Yes | Callback used to return the file assets.| | callback | AsyncCallback<[FetchFileResult](#fetchfileresult7)> | Yes | Callback used to return the file assets.|
**Example** **Example**
...@@ -2041,7 +2067,7 @@ async function example() { ...@@ -2041,7 +2067,7 @@ async function example() {
} }
``` ```
### getFileAssets<sup>8+</sup> ### getFileAssets<sup>7+</sup>
getFileAssets(options?: MediaFetchOptions): Promise&lt;FetchFileResult&gt; getFileAssets(options?: MediaFetchOptions): Promise&lt;FetchFileResult&gt;
...@@ -2053,15 +2079,15 @@ Obtains the file assets in this album. This API uses a promise to return the res ...@@ -2053,15 +2079,15 @@ Obtains the file assets in this album. This API uses a promise to return the res
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------------------------- | ---- | ------ | | ------- | ---------------------------------------- | ---- | -------------- |
| options | [MediaFetchOptions](#mediafetchoptions8) | No | Options for fetching the files.| | options | [MediaFetchOptions](#mediafetchoptions7) | No | Options for fetching the files.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ------------------- | | --------------------------------------------- | ------------------------- |
| Promise<[FetchFileResult](#fetchfileresult8)> | Promise used to return the file assets.| | Promise<[FetchFileResult](#fetchfileresult7)> | Promise used to return the file assets.|
**Example** **Example**
...@@ -2087,38 +2113,36 @@ Describes information about a registered device. ...@@ -2087,38 +2113,36 @@ Describes information about a registered device.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable | Writable | Description | | Name | Type | Readable| Writable| Description |
| ---------- | ---------- | ---- | ---- | --------- | | ---------- | -------------------------- | ---- | ---- | ---------------- |
| deviceName | string | Yes | No | Name of the registered device. | | deviceName | string | Yes | No | Name of the registered device. |
| networkId | string | Yes | No | Network ID of the registered device.| | networkId | string | Yes | No | Network ID of the registered device.|
| deviceType | DeviceType | Yes | No | Type of the registered device. | | deviceType | [DeviceType](#devicetype8) | Yes | No | Type of the registered device. |
| isOnline | boolean | Yes | No | Whether the registered device is online. | | isOnline | boolean | Yes | No | Whether the registered device is online. |
MediaType ## MediaType<sup>8+</sup>
---------
Enumerates media types. Enumerates media types.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Default Value | Description | | Name | Default Value | Description|
| ----- | ---- | ---- | | ----- | ------ | ---- |
| FILE | 0 | File. | | FILE | 1 | File.|
| IMAGE | 1 | Image. | | IMAGE | 3 | Image.|
| VIDEO | 2 | Video. | | VIDEO | 4 | Video.|
| AUDIO | 3 | Audio. | | AUDIO | 5 | Audio.|
FileKey ## FileKey<sup>8+</sup>
-------
Enumerates key file information. Enumerates key file information.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Default Value | Description | | Name | Default Value | Description |
| ------------- | ------------------- | -------------------------------- | | ------------- | ------------------- | ---------------------------------------------------------- |
| ID | file_id | File ID. | | ID | file_id | File ID. |
| RELATIVE_PATH | relative_path | Relative public directory of the file. | | RELATIVE_PATH | relative_path | Relative public directory of the file. |
| DISPLAY_NAME | display_name | Display file name. | | DISPLAY_NAME | display_name | Display file name. |
...@@ -2139,15 +2163,14 @@ Enumerates key file information. ...@@ -2139,15 +2163,14 @@ Enumerates key file information.
| ALBUM_ID | bucket_id | ID of the album to which the file belongs. | | ALBUM_ID | bucket_id | ID of the album to which the file belongs. |
| ALBUM_NAME | bucket_display_name | Name of the album to which the file belongs. | | ALBUM_NAME | bucket_display_name | Name of the album to which the file belongs. |
DirectoryType ## DirectoryType<sup>8+</sup>
-------------
Enumerates directory types. Enumerates directory types.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Default Value | Description | | Name | Default Value | Description |
| ------------- | ---- | ------------ | | ------------- | ------ | ------------------ |
| DIR_CAMERA | 0 | Directory of camera files.| | DIR_CAMERA | 0 | Directory of camera files.|
| DIR_VIDEO | 1 | Directory of video files. | | DIR_VIDEO | 1 | Directory of video files. |
| DIR_IMAGE | 2 | Directory of image files. | | DIR_IMAGE | 2 | Directory of image files. |
...@@ -2155,15 +2178,14 @@ Enumerates directory types. ...@@ -2155,15 +2178,14 @@ Enumerates directory types.
| DIR_DOCUMENTS | 4 | Directory of documents. | | DIR_DOCUMENTS | 4 | Directory of documents. |
| DIR_DOWNLOAD | 5 | Download directory. | | DIR_DOWNLOAD | 5 | Download directory. |
DeviceType ## DeviceType<sup>8+</sup>
-----------
Enumerates device types. Enumerates device types.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Default Value | Description | | Name | Default Value | Description |
| ------------ | ---- | ----- | | ------------ | ------ | ---------- |
| TYPE_UNKNOWN | 0 | Unknown.| | TYPE_UNKNOWN | 0 | Unknown.|
| TYPE_LAPTOP | 1 | Laptop.| | TYPE_LAPTOP | 1 | Laptop.|
| TYPE_PHONE | 2 | Phone. | | TYPE_PHONE | 2 | Phone. |
...@@ -2172,20 +2194,20 @@ Enumerates device types. ...@@ -2172,20 +2194,20 @@ Enumerates device types.
| TYPE_CAR | 5 | Vehicle-mounted device. | | TYPE_CAR | 5 | Vehicle-mounted device. |
| TYPE_TV | 6 | TV. | | TYPE_TV | 6 | TV. |
## MediaFetchOptions<sup>8+</sup> ## MediaFetchOptions<sup>7+</sup>
Describes options for fetching media files. Describes options for fetching media files.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable | Writable | Mandatory | Description | | Name | Type | Readable| Writable| Mandatory| Description |
| ------------- | ------------------- | ---- | ---- | ---- | ---------------------------------------- | | ----------------------- | ------------------- | ---- | ---- | ---- | ------------------------------------------------------------ |
| selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey) are used as the column names of the conditions. Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?',| | selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?',|
| selectionArgs | Array&lt;string&gt; | Yes | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.<br>Example:<br>selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], | | selectionArgs | Array&lt;string&gt; | Yes | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.<br>Example:<br>selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], |
| order | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey) are used as the columns for sorting the search results. Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"| | order<sup>8+</sup> | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"|
| uri | string | Yes | Yes | No | File URI. | | uri<sup>8+</sup> | string | Yes | Yes | No | File URI. |
| networkId | string | Yes | Yes | No | Network ID of the registered device. | | networkId<sup>8+</sup> | string | Yes | Yes | No | Network ID of the registered device. |
| extendArgs | string | Yes | Yes | No | Extended parameters for fetching the files. Currently, no extended parameters are available. | | extendArgs<sup>8+</sup> | string | Yes | Yes | No | Extended parameters for fetching the files. Currently, no extended parameters are available. |
## Size<sup>8+</sup> ## Size<sup>8+</sup>
......
...@@ -893,7 +893,7 @@ Defines the network capability set. ...@@ -893,7 +893,7 @@ Defines the network capability set.
| linkUpBandwidthKbps | number | Uplink (from the device to the network) bandwidth.| | linkUpBandwidthKbps | number | Uplink (from the device to the network) bandwidth.|
| linkDownBandwidthKbps | number | Downlink (from the network to the device) bandwidth.| | linkDownBandwidthKbps | number | Downlink (from the network to the device) bandwidth.|
| networkCap | Array<[NetCap](#netcap)> | Network capability. | | networkCap | Array<[NetCap](#netcap)> | Network capability. |
| bearerTypes | Array<[NetBearType](#netbearType)> | Network type. | | bearerTypes | Array<[NetBearType](#netbeartype)> | Network type. |
## NetCap ## NetCap
......
...@@ -278,7 +278,7 @@ Registers an observer for connection status change events of the cellular data l ...@@ -278,7 +278,7 @@ Registers an observer for connection status change events of the cellular data l
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Connection status change event of the cellular data link. | | type | string | Yes | Connection status change event of the cellular data link. |
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectState), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).| | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).|
**Example** **Example**
...@@ -303,7 +303,7 @@ Registers an observer for connection status change events of the cellular data l ...@@ -303,7 +303,7 @@ Registers an observer for connection status change events of the cellular data l
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Connection status change event of the cellular data link. | | type | string | Yes | Connection status change event of the cellular data link. |
| slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2 | | slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2 |
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectState), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).| | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).|
**Example** **Example**
...@@ -331,7 +331,7 @@ Unregisters the observer for connection status change events of the cellular dat ...@@ -331,7 +331,7 @@ Unregisters the observer for connection status change events of the cellular dat
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Connection status change event of the cellular data link. | | type | string | Yes | Connection status change event of the cellular data link. |
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectState), network: [RatType](js-apis-radio.md#radiotechnology) }\> | No | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).| | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | No | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).|
**Example** **Example**
......
...@@ -17,7 +17,7 @@ import particleAbility from '@ohos.ability.particleAbility' ...@@ -17,7 +17,7 @@ import particleAbility from '@ohos.ability.particleAbility'
startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>): void startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>): void
Starts a particle ability. This API uses an asynchronous callback to return the result. Starts a Particle ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -60,7 +60,7 @@ particleAbility.startAbility( ...@@ -60,7 +60,7 @@ particleAbility.startAbility(
startAbility(parameter: StartAbilityParameter): Promise\<void>; startAbility(parameter: StartAbilityParameter): Promise\<void>;
Starts a particle ability. This API uses a promise to return the result. Starts a Particle ability. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -107,7 +107,7 @@ particleAbility.startAbility( ...@@ -107,7 +107,7 @@ particleAbility.startAbility(
terminateSelf(callback: AsyncCallback\<void>): void terminateSelf(callback: AsyncCallback\<void>): void
Terminates this particle ability. This API uses an asynchronous callback to return the result. Terminates this Particle ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -134,7 +134,7 @@ particleAbility.terminateSelf( ...@@ -134,7 +134,7 @@ particleAbility.terminateSelf(
terminateSelf(): Promise\<void> terminateSelf(): Promise\<void>
Terminates this particle ability. This API uses a promise to return the result. Terminates this Particle ability. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -188,7 +188,9 @@ particleAbility.acquireDataAbilityHelper(uri) ...@@ -188,7 +188,9 @@ particleAbility.acquireDataAbilityHelper(uri)
startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback&lt;void&gt;): void; startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback&lt;void&gt;): void;
Requests a continuous task from the system. This API uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) Requests a continuous task from the system. This API uses an asynchronous callback to return the result. You are advised to use the new API [backgroundTaskManager.startBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstartbackgroundrunning8).
**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
...@@ -250,9 +252,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { ...@@ -250,9 +252,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
startBackgroundRunning(id: number, request: NotificationRequest): Promise&lt;void&gt; startBackgroundRunning(id: number, request: NotificationRequest): Promise&lt;void&gt;
**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
Requests a continuous task from the system. This API uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) Requests a continuous task from the system. This API uses a promise to return the result. You are advised to use the new API [backgroundTaskManager.startBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstartbackgroundrunning8-1).
**Parameters** **Parameters**
...@@ -313,7 +317,7 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { ...@@ -313,7 +317,7 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
cancelBackgroundRunning(callback: AsyncCallback&lt;void&gt;): void; cancelBackgroundRunning(callback: AsyncCallback&lt;void&gt;): void;
Requests to cancel a continuous task from the system. This API uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) Requests to cancel a continuous task from the system. This API uses an asynchronous callback to return the result. You are advised to use the new API [backgroundTaskManager.stopBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstopbackgroundrunning8).
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
...@@ -344,7 +348,7 @@ particleAbility.cancelBackgroundRunning(callback); ...@@ -344,7 +348,7 @@ particleAbility.cancelBackgroundRunning(callback);
cancelBackgroundRunning(): Promise&lt;void&gt;; cancelBackgroundRunning(): Promise&lt;void&gt;;
Requests to cancel a continuous task from the system. This API uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) Requests a continuous task from the system. This API uses a promise to return the result. You are advised to use the new API [backgroundTaskManager.stopBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstopbackgroundrunning8-1).
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
...@@ -383,6 +387,17 @@ Connects this ability to a specific Service ability. This API uses a callback to ...@@ -383,6 +387,17 @@ Connects this ability to a specific Service ability. This API uses a callback to
| request | [Want](js-apis-featureAbility.md#want) | Yes | Service ability to connect.| | request | [Want](js-apis-featureAbility.md#want) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. | | options | ConnectOptions | Yes | Callback used to return the result. |
ConnectOptions
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory | Description |
| ------------ | ---- | -------- | ---- | ------------------------- |
| onConnect | Read only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
**Example** **Example**
```js ```js
...@@ -509,11 +524,8 @@ function onConnectCallback(element, remote){ ...@@ -509,11 +524,8 @@ function onConnectCallback(element, remote){
Enumerates error codes. Enumerates error codes.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Value | Description | | Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ | | ----------------------------- | ---- | ------------------------------------------------------------ |
| INVALID_PARAMETER | -1 | Invalid parameter.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| | INVALID_PARAMETER | -1 | Invalid parameter.|
...@@ -12,7 +12,7 @@ The Power Manager module provides APIs for rebooting and shutting down the syste ...@@ -12,7 +12,7 @@ The Power Manager module provides APIs for rebooting and shutting down the syste
import power from '@ohos.power'; import power from '@ohos.power';
``` ```
## System Capabilities ## System Capability
SystemCapability.PowerManager.PowerManager.Core SystemCapability.PowerManager.PowerManager.Core
...@@ -25,7 +25,7 @@ Shuts down the system. ...@@ -25,7 +25,7 @@ Shuts down the system.
This is a system API and cannot be called by third-party applications. This is a system API and cannot be called by third-party applications.
**Required permission:** ohos.permission.SHUTDOWN **Required permission**: ohos.permission.REBOOT
**Parameters** **Parameters**
...@@ -45,9 +45,9 @@ console.info('power_shutdown_device_test success') ...@@ -45,9 +45,9 @@ console.info('power_shutdown_device_test success')
rebootDevice(reason: string): void rebootDevice(reason: string): void
Restarts the device. Reboots the system.
**Required permission:** ohos.permission.REBOOT (to reboot) or ohos.permission.REBOOT_UPDATER (to reboot and enter the updater mode) **Required permission**: ohos.permission.REBOOT (to reboot) or ohos.permission.REBOOT_RECOVERY (to reboot and enter the recovery or updater mode)
**Parameters** **Parameters**
...@@ -94,10 +94,10 @@ isScreenOn(): Promise&lt;boolean&gt; ...@@ -94,10 +94,10 @@ isScreenOn(): Promise&lt;boolean&gt;
Checks the screen status of the current device. Checks the screen status of the current device.
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | --------------------------------------- | | ---------------------- | --------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to asynchronously obtain the return value. <br/>Return value: The value **true** indicates that the screen is on, and the value **false** indicates the opposite.| | Promise&lt;boolean&gt; | Promise used to obtain the return value. <br/>Return value: The value **true** indicates that the screen is on, and the value **false** indicates the opposite.|
**Example** **Example**
......
...@@ -173,7 +173,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A ...@@ -173,7 +173,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[NetworkSelectionMode](#networkselectionMode)\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[NetworkSelectionMode](#networkselectionmode)\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -622,7 +622,7 @@ Defines the network registration status. ...@@ -622,7 +622,7 @@ Defines the network registration status.
| isRoaming | boolean | Whether the user is roaming.| | isRoaming | boolean | Whether the user is roaming.|
| regState | [RegState](#regstate) | Network registration status of the device.| | regState | [RegState](#regstate) | Network registration status of the device.|
| cfgTech<sup>8+</sup> | [RadioTechnology](#radiotechnology) | RAT of the device.| | cfgTech<sup>8+</sup> | [RadioTechnology](#radiotechnology) | RAT of the device.|
| nsaState | [NsaState](#nsaState) | NSA network registration status of the device.| | nsaState | [NsaState](#nsastate) | NSA network registration status of the device.|
| isCaActive | boolean | CA status.| | isCaActive | boolean | CA status.|
| isEmergency | boolean | Whether only emergency calls are allowed.| | isEmergency | boolean | Whether only emergency calls are allowed.|
......
...@@ -11,30 +11,28 @@ import reminderAgent from'@ohos.reminderAgent'; ...@@ -11,30 +11,28 @@ import reminderAgent from'@ohos.reminderAgent';
``` ```
## Required Permissions
ohos.permission.PUBLISH_AGENT_REMINDER
## reminderAgent.publishReminder ## reminderAgent.publishReminder
publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback&lt;number&gt;): void publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback&lt;number&gt;): void
Publishes an agent-powered reminder. This API uses an asynchronous callback to return the result. Publishes an agent-powered reminder. This API uses an asynchronous callback to return the result.
- System capability **Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER
SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
**Parameters**
- Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.| | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
| callback | AsyncCallback&lt;number&gt; | Yes| Asynchronous callback used to return the published reminder's ID.| | callback | AsyncCallback&lt;number&gt; | Yes| Asynchronous callback used to return the published reminder's ID.|
- Example **Example**
``` ```
export default { data: {timer: { export default {
data: {
timer: {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 3 triggerTimeInSeconds: 3
} }
...@@ -53,23 +51,23 @@ publishReminder(reminderReq: ReminderRequest): Promise&lt;number&gt; ...@@ -53,23 +51,23 @@ publishReminder(reminderReq: ReminderRequest): Promise&lt;number&gt;
Publishes an agent-powered reminder. This API uses a promise callback to return the result. Publishes an agent-powered reminder. This API uses a promise callback to return the result.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.| | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the published reminder's ID.| | Promise&lt;number&gt; | Promise used to return the published reminder's ID.|
- Example **Example**
``` ```
export default { data: {timer: { export default {
data:
{timer: {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 3 triggerTimeInSeconds: 3
} }
...@@ -89,22 +87,21 @@ cancelReminder(reminderId: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -89,22 +87,21 @@ cancelReminder(reminderId: number, callback: AsyncCallback&lt;void&gt;): void
Cancels the reminder with the specified ID. This API uses an asynchronous callback to return the cancellation result. Cancels the reminder with the specified ID. This API uses an asynchronous callback to return the cancellation result.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent **Parameters**
- Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| reminderId | number | Yes| ID of the reminder to cancel.| | reminderId | number | Yes| ID of the reminder to cancel.|
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback used to return the result.|
- Example **Example**
``` ```
export default { export default {
cancel() { reminderAgent.cancelReminder(1, (err, data) => { cancel() {
reminderAgent.cancelReminder(1, (err, data) => {
console.log("do next"); console.log("do next");
}); });
} }
...@@ -118,23 +115,21 @@ cancelReminder(reminderId: number): Promise&lt;void&gt; ...@@ -118,23 +115,21 @@ cancelReminder(reminderId: number): Promise&lt;void&gt;
Cancels the reminder with the specified ID. This API uses a promise to return the cancellation result. Cancels the reminder with the specified ID. This API uses a promise to return the cancellation result.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent **Parameters**
- Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| reminderId | number | Yes| ID of the reminder to cancel.| | reminderId | number | Yes| ID of the reminder to cancel.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
export default { export default {
...@@ -153,17 +148,15 @@ getValidReminders(callback: AsyncCallback&lt;Array&lt;ReminderRequest&gt;&gt;): ...@@ -153,17 +148,15 @@ getValidReminders(callback: AsyncCallback&lt;Array&lt;ReminderRequest&gt;&gt;):
Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders. Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;[ReminderRequest](#reminderrequest)&gt;&gt; | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.| | callback | AsyncCallback&lt;Array&lt;[ReminderRequest](#reminderrequest)&gt;&gt; | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.|
- Example **Example**
``` ```
reminderAgent.getValidReminders((err, reminders) => { reminderAgent.getValidReminders((err, reminders) => {
...@@ -198,17 +191,15 @@ getValidReminders(): Promise&lt;Array&lt;ReminderRequest&gt;&gt; ...@@ -198,17 +191,15 @@ getValidReminders(): Promise&lt;Array&lt;ReminderRequest&gt;&gt;
Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders. Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent **Return value**
- Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[ReminderRequest](#reminderrequest)&gt;&gt; | Promise used to return an array of all valid reminders set by the current application.| | Promise&lt;Array&lt;[ReminderRequest](#reminderrequest)&gt;&gt; | Promise used to return an array of all valid reminders set by the current application.|
- Example **Example**
``` ```
reminderAgent.getValidReminders().then((reminders) => { reminderAgent.getValidReminders().then((reminders) => {
...@@ -243,17 +234,15 @@ cancelAllReminders(callback: AsyncCallback&lt;void&gt;): void ...@@ -243,17 +234,15 @@ cancelAllReminders(callback: AsyncCallback&lt;void&gt;): void
Cancels all reminders set by the current application. This API uses an asynchronous callback to return the cancellation result. Cancels all reminders set by the current application. This API uses an asynchronous callback to return the cancellation result.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback used to return the result.|
- Example **Example**
``` ```
reminderAgent.cancelAllReminders((err, data) =>{ reminderAgent.cancelAllReminders((err, data) =>{
...@@ -267,17 +256,15 @@ cancelAllReminders(): Promise&lt;void&gt; ...@@ -267,17 +256,15 @@ cancelAllReminders(): Promise&lt;void&gt;
Cancels all reminders set by the current application. This API uses a promise to return the cancellation result. Cancels all reminders set by the current application. This API uses a promise to return the cancellation result.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent **Return value**
- Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
reminderAgent.cancelAllReminders().then(() => { reminderAgent.cancelAllReminders().then(() => {
...@@ -291,18 +278,16 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback&lt;void&gt;) ...@@ -291,18 +278,16 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback&lt;void&gt;)
Adds a reminder notification slot. This API uses an asynchronous callback to return the result. Adds a reminder notification slot. This API uses an asynchronous callback to return the result.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Reminder notification slot to add.| | slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Reminder notification slot to add.|
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback used to return the result.|
- Example **Example**
``` ```
export default { data: { mySlot: { export default { data: { mySlot: {
...@@ -324,23 +309,21 @@ addNotificationSlot(slot: NotificationSlot): Promise&lt;void&gt; ...@@ -324,23 +309,21 @@ addNotificationSlot(slot: NotificationSlot): Promise&lt;void&gt;
Adds a reminder notification slot. This API uses a promise to return the result. Adds a reminder notification slot. This API uses a promise to return the result.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent **Parameters**
- Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Reminder notification slot to add.| | slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Reminder notification slot to add.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
export default { data: { mySlot: { export default { data: { mySlot: {
...@@ -362,18 +345,16 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback& ...@@ -362,18 +345,16 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback&
Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result. Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.| | slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.|
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback used to return the result.|
- Example **Example**
``` ```
export default { export default {
...@@ -391,23 +372,21 @@ removeNotificationSlot(slotType: notification.SlotType): Promise&lt;void&gt; ...@@ -391,23 +372,21 @@ removeNotificationSlot(slotType: notification.SlotType): Promise&lt;void&gt;
Removes a notification slot of a specified type. This API uses a promise to return the result. Removes a notification slot of a specified type. This API uses a promise to return the result.
- System capability **System capability**: SystemCapability.Notification.ReminderAgent
SystemCapability.Notification.ReminderAgent **Parameters**
- Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.| | slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
- Example **Example**
``` ```
export default { export default {
...@@ -423,7 +402,7 @@ export default { ...@@ -423,7 +402,7 @@ export default {
Enumerates button types. Enumerates button types.
- **System capability**: SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
| Name| Default Value| Description| | Name| Default Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -435,7 +414,7 @@ Enumerates button types. ...@@ -435,7 +414,7 @@ Enumerates button types.
Enumerates reminder types. Enumerates reminder types.
- **System capability**: SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
| Name| Default Value| Description| | Name| Default Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -448,7 +427,7 @@ Enumerates reminder types. ...@@ -448,7 +427,7 @@ Enumerates reminder types.
Defines a button displayed in the reminder notification. Defines a button displayed in the reminder notification.
- **System capability**: SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -460,7 +439,7 @@ Defines a button displayed in the reminder notification. ...@@ -460,7 +439,7 @@ Defines a button displayed in the reminder notification.
Sets the package and ability that are redirected to when the reminder notification is clicked. Sets the package and ability that are redirected to when the reminder notification is clicked.
- **System capability**: SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -472,7 +451,7 @@ Sets the package and ability that are redirected to when the reminder notificati ...@@ -472,7 +451,7 @@ Sets the package and ability that are redirected to when the reminder notificati
Sets the name of the target package and ability to start automatically when the reminder arrives and the device is not in use. If the device is in use, a notification will be displayed. Sets the name of the target package and ability to start automatically when the reminder arrives and the device is not in use. If the device is in use, a notification will be displayed.
- **System capability**: SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -484,7 +463,7 @@ Sets the name of the target package and ability to start automatically when the ...@@ -484,7 +463,7 @@ Sets the name of the target package and ability to start automatically when the
Defines the reminder to publish. Defines the reminder to publish.
- **System capability**: SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -509,7 +488,7 @@ ReminderRequestCalendar extends ReminderRequest ...@@ -509,7 +488,7 @@ ReminderRequestCalendar extends ReminderRequest
Defines a reminder for a calendar event. Defines a reminder for a calendar event.
- **System capability**: SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -524,9 +503,9 @@ ReminderRequestAlarm extends ReminderRequest ...@@ -524,9 +503,9 @@ ReminderRequestAlarm extends ReminderRequest
Defines a reminder for an alarm. Defines a reminder for an alarm.
- **System capability**: SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
| Name| Type| Mandatory| Description:| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| hour | number | Yes| Hour portion of the reminder time.| | hour | number | Yes| Hour portion of the reminder time.|
| minute | number | Yes| Minute portion of the reminder time.| | minute | number | Yes| Minute portion of the reminder time.|
...@@ -539,7 +518,7 @@ ReminderRequestTimer extends ReminderRequest ...@@ -539,7 +518,7 @@ ReminderRequestTimer extends ReminderRequest
Defines a reminder for a scheduled timer. Defines a reminder for a scheduled timer.
- **System capability**: SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -550,7 +529,7 @@ Defines a reminder for a scheduled timer. ...@@ -550,7 +529,7 @@ Defines a reminder for a scheduled timer.
Sets the time information for a calendar reminder. Sets the time information for a calendar reminder.
- **System capability**: SystemCapability.Notification.ReminderAgent **System capability**: SystemCapability.Notification.ReminderAgent
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
......
...@@ -107,16 +107,16 @@ Creates a **RunningLock** object. ...@@ -107,16 +107,16 @@ Creates a **RunningLock** object.
**Example** **Example**
``` ```
runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND, (error, lockIns) => {
.then(runninglock => { if (typeof error === "undefined") {
var used = runninglock.isUsed(); console.log('create runningLock test error: ' + error);
} else {
var used = lockIns.isUsed();
console.info('runninglock is used: ' + used); console.info('runninglock is used: ' + used);
runninglock.lock(500); lockIns.lock(500);
used = runninglock.isUsed(); used = lockIns.isUsed();
console.info('after lock runninglock is used ' + used); console.info('after lock runninglock is used ' + used);
}) }
.catch(error => {
console.log('create runningLock test error: ' + error);
}) })
``` ```
...@@ -170,11 +170,13 @@ Locks and holds a **RunningLock** object. ...@@ -170,11 +170,13 @@ Locks and holds a **RunningLock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core **System capability:** SystemCapability.PowerManager.PowerManager.Core
**Required permission:** ohos.permission.RUNNING_LOCK
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | -------------------- | | ------- | ------ | ---- | -------------------------- |
| timeout | number | No | Duration for locking and holding the **RunningLock** object.| | timeout | number | No | Duration for locking and holding the **RunningLock** object, in ms.|
**Example** **Example**
...@@ -185,7 +187,7 @@ runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.B ...@@ -185,7 +187,7 @@ runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.B
console.info('create runningLock success') console.info('create runningLock success')
}) })
.catch(error => { .catch(error => {
console.log('Lock runningLock test error: ' + error) console.log('create runningLock test error: ' + error)
}); });
``` ```
...@@ -198,16 +200,18 @@ Releases a **Runninglock** object. ...@@ -198,16 +200,18 @@ Releases a **Runninglock** object.
**System capability:** SystemCapability.PowerManager.PowerManager.Core **System capability:** SystemCapability.PowerManager.PowerManager.Core
**Required permission:** ohos.permission.RUNNING_LOCK
**Example** **Example**
``` ```
runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND)
.then(runningLock => { .then(runningLock => {
runningLock.unlock() runningLock.unlock()
console.info('unLock runningLock success') console.info('create and unLock runningLock success')
}) })
.catch(error => { .catch(error => {
console.log('unLock runningLock test error: ' + error) console.log('create runningLock test error: ' + error)
}); });
``` ```
......
...@@ -22,14 +22,14 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul ...@@ -22,14 +22,14 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER**.|
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes| Callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**.| | callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes | Callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -51,14 +51,14 @@ Subscribes to data changes of the linear acceleration sensor. If this API is cal ...@@ -51,14 +51,14 @@ Subscribes to data changes of the linear acceleration sensor. If this API is cal
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**.|
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes| Callback used to return the linear acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**.| | callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes | Callback used to return the linear acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -80,14 +80,14 @@ Subscribes to data changes of the uncalibrated acceleration sensor. If this API ...@@ -80,14 +80,14 @@ Subscribes to data changes of the uncalibrated acceleration sensor. If this API
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**.|
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | Yes| Callback used to return the uncalibrated acceleration sensor data. The reported data type in the callback is **AccelerometerUncalibratedResponse**.| | callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | Yes | Callback used to return the uncalibrated acceleration sensor data. The reported data type in the callback is **AccelerometerUncalibratedResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -110,14 +110,14 @@ Subscribes to data changes of the gravity sensor. If this API is called multiple ...@@ -110,14 +110,14 @@ Subscribes to data changes of the gravity sensor. If this API is called multiple
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GRAVITY**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GRAVITY**. |
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes| Callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**.| | callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes | Callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -139,14 +139,14 @@ Subscribes to data changes of the gyroscope sensor. If this API is called multip ...@@ -139,14 +139,14 @@ Subscribes to data changes of the gyroscope sensor. If this API is called multip
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE**. |
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes| Callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**.| | callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes | Callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -168,14 +168,14 @@ Subscribes to data changes of the uncalibrated gyroscope sensor. If this API is ...@@ -168,14 +168,14 @@ Subscribes to data changes of the uncalibrated gyroscope sensor. If this API is
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**.|
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes| Callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**.| | callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes | Callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -198,14 +198,14 @@ Subscribes to data changes of the significant motion sensor. If this API is call ...@@ -198,14 +198,14 @@ Subscribes to data changes of the significant motion sensor. If this API is call
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**.|
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes| Callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**.| | callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes | Callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
...@@ -225,14 +225,14 @@ Subscribes to data changes of the pedometer detection sensor. If this API is cal ...@@ -225,14 +225,14 @@ Subscribes to data changes of the pedometer detection sensor. If this API is cal
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**.|
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes| Callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**.| | callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes | Callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
...@@ -252,14 +252,14 @@ Subscribes to data changes of the pedometer sensor. If this API is called multip ...@@ -252,14 +252,14 @@ Subscribes to data changes of the pedometer sensor. If this API is called multip
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | --------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER**. |
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes| Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.| | callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes | Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
...@@ -277,14 +277,14 @@ Subscribes to data changes of the ambient temperature sensor. If this API is cal ...@@ -277,14 +277,14 @@ Subscribes to data changes of the ambient temperature sensor. If this API is cal
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**.|
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes| Callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**.| | callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes | Callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
...@@ -302,14 +302,14 @@ Subscribes to data changes of the magnetic field sensor. If this API is called m ...@@ -302,14 +302,14 @@ Subscribes to data changes of the magnetic field sensor. If this API is called m
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**.|
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes| Callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**.| | callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes | Callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -323,20 +323,20 @@ Subscribes to data changes of the magnetic field sensor. If this API is called m ...@@ -323,20 +323,20 @@ Subscribes to data changes of the magnetic field sensor. If this API is called m
## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED) ## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;, options: Options): void on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;, options?: Options): void
Subscribes to data changes of the uncalibrated magnetic field sensor. If this API is called multiple times for the same application, the last call takes effect. Subscribes to data changes of the uncalibrated magnetic field sensor. If this API is called multiple times for the same application, the last call takes effect.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED**.|
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes| Callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**.| | callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes | Callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -359,14 +359,14 @@ Subscribes to data changes of the proximity sensor. If this API is called multip ...@@ -359,14 +359,14 @@ Subscribes to data changes of the proximity sensor. If this API is called multip
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PROXIMITY**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PROXIMITY**. |
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes| Callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**.| | callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes | Callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
console.info('Distance: ' + data.distance); console.info('Distance: ' + data.distance);
...@@ -384,14 +384,14 @@ Subscribes to data changes of the humidity sensor. If this API is called multipl ...@@ -384,14 +384,14 @@ Subscribes to data changes of the humidity sensor. If this API is called multipl
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | -------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HUMIDITY**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HUMIDITY**. |
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes| Callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**.| | callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes | Callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
...@@ -409,14 +409,14 @@ Subscribes to data changes of the barometer sensor. If this API is called multip ...@@ -409,14 +409,14 @@ Subscribes to data changes of the barometer sensor. If this API is called multip
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_BAROMETER**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_BAROMETER**. |
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes| Callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**.| | callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes | Callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
...@@ -434,14 +434,14 @@ Subscribes to data changes of the Hall effect sensor. If this API is called mult ...@@ -434,14 +434,14 @@ Subscribes to data changes of the Hall effect sensor. If this API is called mult
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HALL**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HALL**. |
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes| Callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**.| | callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes | Callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
...@@ -459,14 +459,14 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu ...@@ -459,14 +459,14 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**.|
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | Yes| Callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**.| | callback | Callback&lt;[LightResponse](#lightresponse)&gt; | Yes | Callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**. |
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
...@@ -484,14 +484,14 @@ Subscribes to data changes of the orientation sensor. If this API is called mult ...@@ -484,14 +484,14 @@ Subscribes to data changes of the orientation sensor. If this API is called mult
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ORIENTATION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ORIENTATION**. |
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes| Callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**.| | callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes | Callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
...@@ -512,14 +512,14 @@ Subscribes to only one data change of the heart rate sensor. ...@@ -512,14 +512,14 @@ Subscribes to only one data change of the heart rate sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HEART_RATE**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HEART_RATE**. |
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**.| | callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**.|
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){
...@@ -537,14 +537,14 @@ Subscribes to data changes of the rotation vector sensor. If this API is called ...@@ -537,14 +537,14 @@ Subscribes to data changes of the rotation vector sensor. If this API is called
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**.|
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes| Callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**.| | callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes | Callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -565,14 +565,14 @@ Subscribes to data changes of the wear detection sensor. If this API is called m ...@@ -565,14 +565,14 @@ Subscribes to data changes of the wear detection sensor. If this API is called m
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_WEAR_DETECTION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_WEAR_DETECTION**.|
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes| Callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**.| | callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes | Callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**.|
| options | [Options](#options) | No| Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns.| | options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
- Example **Example**
``` ```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
console.info('Wear status: ' + data.value); console.info('Wear status: ' + data.value);
...@@ -592,13 +592,13 @@ Subscribes to only one data change of the acceleration sensor. ...@@ -592,13 +592,13 @@ Subscribes to only one data change of the acceleration sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER**. |
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes| One-shot callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**.| | callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes | One-shot callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -619,13 +619,13 @@ Subscribes to only one data change of the linear acceleration sensor. ...@@ -619,13 +619,13 @@ Subscribes to only one data change of the linear acceleration sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**.|
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes| One-shot callback used to return the linear acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**.| | callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes | One-shot callback used to return the linear acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -646,13 +646,13 @@ Subscribes to only one data change of the uncalibrated acceleration sensor. ...@@ -646,13 +646,13 @@ Subscribes to only one data change of the uncalibrated acceleration sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**.|
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | Yes| One-shot callback used to return the uncalibrated acceleration sensor data. The reported data type in the callback is **AccelerometerUncalibratedResponse**.| | callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | Yes | One-shot callback used to return the uncalibrated acceleration sensor data. The reported data type in the callback is **AccelerometerUncalibratedResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -674,13 +674,13 @@ Subscribes to only one data change of the gravity sensor. ...@@ -674,13 +674,13 @@ Subscribes to only one data change of the gravity sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | --------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GRAVITY**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GRAVITY**. |
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes| One-shot callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**.| | callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes | One-shot callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -701,13 +701,13 @@ Subscribes to only one data change of the gyroscope sensor. ...@@ -701,13 +701,13 @@ Subscribes to only one data change of the gyroscope sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE**. |
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes| One-shot callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**.| | callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes | One-shot callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -728,13 +728,13 @@ Subscribes to only one data change of the uncalibrated gyroscope sensor. ...@@ -728,13 +728,13 @@ Subscribes to only one data change of the uncalibrated gyroscope sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**.|
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes| One-shot callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**.| | callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes | One-shot callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -756,13 +756,13 @@ Subscribes to only one data change of the significant motion sensor. ...@@ -756,13 +756,13 @@ Subscribes to only one data change of the significant motion sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**.|
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes| One-shot callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**.| | callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes | One-shot callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
...@@ -781,13 +781,13 @@ Subscribes to only one data change of the pedometer detection sensor. ...@@ -781,13 +781,13 @@ Subscribes to only one data change of the pedometer detection sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**.|
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes| One-shot callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**.| | callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes | One-shot callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
...@@ -806,13 +806,13 @@ Subscribes to only one data change of the pedometer sensor. ...@@ -806,13 +806,13 @@ Subscribes to only one data change of the pedometer sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PEDOMETER**. |
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes| One-shot callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.| | callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes | One-shot callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
...@@ -829,13 +829,13 @@ Subscribes to only one data change of the ambient temperature sensor. ...@@ -829,13 +829,13 @@ Subscribes to only one data change of the ambient temperature sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**.|
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes| One-shot callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**.| | callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes | One-shot callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
...@@ -852,13 +852,13 @@ Subscribes to only one data change of the magnetic field sensor. ...@@ -852,13 +852,13 @@ Subscribes to only one data change of the magnetic field sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**. |
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes| One-shot callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**.| | callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes | One-shot callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -877,13 +877,13 @@ Subscribes to only one data change of the uncalibrated magnetic field sensor. ...@@ -877,13 +877,13 @@ Subscribes to only one data change of the uncalibrated magnetic field sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED**.|
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes| One-shot callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**.| | callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes | One-shot callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -905,13 +905,13 @@ Subscribes to only one data change of the proximity sensor. ...@@ -905,13 +905,13 @@ Subscribes to only one data change of the proximity sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PROXIMITY**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_PROXIMITY**. |
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes| One-shot callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**.| | callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes | One-shot callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) {
if (error) { if (error) {
...@@ -932,13 +932,13 @@ Subscribes to only one data change of the humidity sensor. ...@@ -932,13 +932,13 @@ Subscribes to only one data change of the humidity sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HUMIDITY**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HUMIDITY**. |
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes| One-shot callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**.| | callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes | One-shot callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
...@@ -955,13 +955,13 @@ Subscribes to only one data change of the barometer sensor. ...@@ -955,13 +955,13 @@ Subscribes to only one data change of the barometer sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_BAROMETER**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_BAROMETER**. |
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes| One-shot callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**.| | callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes | One-shot callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
...@@ -978,13 +978,13 @@ Subscribes to only one data change of the Hall effect sensor. ...@@ -978,13 +978,13 @@ Subscribes to only one data change of the Hall effect sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ------------------------------------ |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HALL**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HALL**. |
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes| One-shot callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**.| | callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes | One-shot callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
...@@ -1001,13 +1001,13 @@ Subscribes to only one data change of the ambient light sensor. ...@@ -1001,13 +1001,13 @@ Subscribes to only one data change of the ambient light sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | -------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**.|
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | Yes| One-shot callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**.| | callback | Callback&lt;[LightResponse](#lightresponse)&gt; | Yes | One-shot callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
...@@ -1024,13 +1024,13 @@ Subscribes to only one data change of the orientation sensor. ...@@ -1024,13 +1024,13 @@ Subscribes to only one data change of the orientation sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ORIENTATION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ORIENTATION**. |
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes| One-shot callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**.| | callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes | One-shot callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
...@@ -1049,13 +1049,13 @@ Subscribes to only one data change of the rotation vector sensor. ...@@ -1049,13 +1049,13 @@ Subscribes to only one data change of the rotation vector sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**.|
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes| One-shot callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**.| | callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes | One-shot callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
...@@ -1077,13 +1077,13 @@ Subscribes to only one data change of the heart rate sensor. ...@@ -1077,13 +1077,13 @@ Subscribes to only one data change of the heart rate sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HEART_RATE**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_HEART_RATE**. |
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes| One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**.| | callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) {
console.info("Heart rate: " + data.heartRate); console.info("Heart rate: " + data.heartRate);
...@@ -1100,13 +1100,13 @@ Subscribes to only one data change of the wear detection sensor. ...@@ -1100,13 +1100,13 @@ Subscribes to only one data change of the wear detection sensor.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes| Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_WEAR_DETECTION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to subscribe to, which is **SENSOR_TYPE_ID_WEAR_DETECTION**.|
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes| One-shot callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**.| | callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes | One-shot callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**.|
- Example **Example**
``` ```
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
console.info("Wear status: "+ data.value); console.info("Wear status: "+ data.value);
...@@ -1124,14 +1124,14 @@ Unsubscribes from sensor data changes. ...@@ -1124,14 +1124,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ACCELEROMETER**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ACCELEROMETER**.|
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes | Callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**.| | callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | Yes | Callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1152,14 +1152,14 @@ Unsubscribes from sensor data changes. ...@@ -1152,14 +1152,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED**.|
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | Yes | Callback used to return the uncalibrated acceleration sensor data. The reported data type in the callback is **AccelerometerUncalibratedResponse**.| | callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | Yes | Callback used to return the uncalibrated acceleration sensor data. The reported data type in the callback is **AccelerometerUncalibratedResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1181,14 +1181,14 @@ Unsubscribes from sensor data changes. ...@@ -1181,14 +1181,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_AMBIENT_LIGHT**.|
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | Yes | Callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**.| | callback | Callback&lt;[LightResponse](#lightresponse)&gt; | Yes | Callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**. |
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1205,14 +1205,14 @@ Unsubscribes from sensor data changes. ...@@ -1205,14 +1205,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_AMBIENT_TEMPERATURE**.|
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes | Callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**.| | callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | Yes | Callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1229,14 +1229,14 @@ Unsubscribes from sensor data changes. ...@@ -1229,14 +1229,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_BAROMETER**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_BAROMETER**.|
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes | Callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**.| | callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | Yes | Callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1253,14 +1253,14 @@ Unsubscribes from sensor data changes. ...@@ -1253,14 +1253,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GRAVITY**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GRAVITY**. |
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes | Callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**.| | callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | Yes | Callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1281,14 +1281,14 @@ Unsubscribes from sensor data changes. ...@@ -1281,14 +1281,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GYROSCOPE**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GYROSCOPE**.|
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes | Callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**.| | callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | Yes | Callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1301,7 +1301,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback); ...@@ -1301,7 +1301,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback);
## sensor.off(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED) ## sensor.off(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeResponse&gt;): void off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
Unsubscribes from sensor data changes. Unsubscribes from sensor data changes.
...@@ -1309,14 +1309,14 @@ Unsubscribes from sensor data changes. ...@@ -1309,14 +1309,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED**.|
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes | Callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**.| | callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | Yes | Callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1335,14 +1335,14 @@ Unsubscribes from sensor data changes. ...@@ -1335,14 +1335,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HALL**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HALL**. |
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes | Callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**.| | callback | Callback&lt;[HallResponse](#hallresponse)&gt; | Yes | Callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1361,14 +1361,14 @@ Unsubscribes from sensor data changes. ...@@ -1361,14 +1361,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype)[SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HEART_RATE**. | | type | [SensorType](#sensortype)[SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HEART_RATE**.|
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**.| | callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | Yes | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1387,14 +1387,14 @@ Unsubscribes from sensor data changes. ...@@ -1387,14 +1387,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HUMIDITY**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_HUMIDITY**. |
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes | Callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**.| | callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | Yes | Callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1413,14 +1413,14 @@ Unsubscribes from sensor data changes. ...@@ -1413,14 +1413,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_LINEAR_ACCELERATION**.|
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes | Callback used to return the acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**.| | callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | Yes | Callback used to return the acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1441,14 +1441,14 @@ Unsubscribes from sensor data changes. ...@@ -1441,14 +1441,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | ---------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD**.|
| callbackcallback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes | Callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**.| | callbackcallback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | Yes | Callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1467,14 +1467,14 @@ Unsubscribes from sensor data changes. ...@@ -1467,14 +1467,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED**.|
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes | Callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**.| | callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | Yes | Callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1496,14 +1496,14 @@ Unsubscribes from sensor data changes. ...@@ -1496,14 +1496,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ORIENTATION**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ORIENTATION**.|
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes | Callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**.| | callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | Yes | Callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1522,14 +1522,14 @@ Unsubscribes from sensor data changes. ...@@ -1522,14 +1522,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER**. |
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes | Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.| | callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | Yes | Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.|
- Example **Return value**
``` ```
function callback(data) { function callback(data) {
...@@ -1548,14 +1548,14 @@ Unsubscribes from sensor data changes. ...@@ -1548,14 +1548,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER_DETECTION**.|
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes | Callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**.| | callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | Yes | Callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1572,14 +1572,14 @@ Unsubscribes from sensor data changes. ...@@ -1572,14 +1572,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PROXIMITY**. | | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PROXIMITY**.|
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes | Callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**.| | callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | Yes | Callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1596,14 +1596,14 @@ Unsubscribes from sensor data changes. ...@@ -1596,14 +1596,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_ROTATION_VECTOR**.|
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes | Callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**.| | callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | Yes | Callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1623,14 +1623,14 @@ Unsubscribes from sensor data changes. ...@@ -1623,14 +1623,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_SIGNIFICANT_MOTION**.|
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes | Callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**.| | callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | Yes | Callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**.|
- Example **Example**
``` ```
function callback(data) { function callback(data) {
...@@ -1647,14 +1647,14 @@ Unsubscribes from sensor data changes. ...@@ -1647,14 +1647,14 @@ Unsubscribes from sensor data changes.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_WEAR_DETECTION**.| | type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_WEAR_DETECTION**.|
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes | Callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**.| | callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | Yes | Callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**.|
- Example **Example**
``` ```
function accCallback(data) { function accCallback(data) {
...@@ -1671,18 +1671,18 @@ Rotates a rotation vector so that it can represent the coordinate system in diff ...@@ -1671,18 +1671,18 @@ Rotates a rotation vector so that it can represent the coordinate system in diff
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------------- | ----------------------------------------- | ---- | ---------------------- | | ---------------- | ---------------------------------------- | ---- | ----------- |
| inRotationVector | Array&lt;number&gt; | Yes | Rotation vector to rotate. | | inRotationVector | Array&lt;number&gt; | Yes | Rotation vector to rotate. |
| coordinates | [CoordinatesOptions](#coordinatesoptions) | Yes | Direction of the coordinate system. | | coordinates | [CoordinatesOptions](#coordinatesoptions) | Yes | Direction of the coordinate system. |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the rotation vector after being rotated.| | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the rotation vector after being rotated.|
- Example **Example**
``` ```
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) { sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) {
if (err) { if (err) {
console.error("Operation failed. Error code: " + err.code + ", message: " + err.message); console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
return; return;
...@@ -1692,8 +1692,7 @@ Rotates a rotation vector so that it can represent the coordinate system in diff ...@@ -1692,8 +1692,7 @@ Rotates a rotation vector so that it can represent the coordinate system in diff
console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
} }
}) })
``` ```
## sensor.transformCoordinateSystem ## sensor.transformCoordinateSystem
transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions): Promise&lt;Array&lt;number&gt;&gt; transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions): Promise&lt;Array&lt;number&gt;&gt;
...@@ -1702,23 +1701,23 @@ Rotates a rotation vector so that it can represent the coordinate system in diff ...@@ -1702,23 +1701,23 @@ Rotates a rotation vector so that it can represent the coordinate system in diff
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------------- | ----------------------------------------- | ---- | ---------------- | | ---------------- | ---------------------------------------- | ---- | -------- |
| inRotationVector | Array&lt;number&gt; | Yes | Rotation vector to rotate. | | inRotationVector | Array&lt;number&gt; | Yes | Rotation vector to rotate. |
| coordinates | [CoordinatesOptions](#coordinatesoptions) | Yes | Direction of the coordinate system.| | coordinates | [CoordinatesOptions](#coordinatesoptions) | Yes | Direction of the coordinate system.|
- Return value **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ---------------------- | | ---------------------------------- | ----------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation vector after being converted.| | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation vector after being rotated.|
- Example **Example**
``` ```
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}); const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3});
promise.then((data) => { promise.then((data) => {
console.info("Operation successed."); console.info("Operation successed.");
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
...@@ -1726,11 +1725,8 @@ Rotates a rotation vector so that it can represent the coordinate system in diff ...@@ -1726,11 +1725,8 @@ Rotates a rotation vector so that it can represent the coordinate system in diff
} }
}).catch((err) => { }).catch((err) => {
console.info("Operation failed"); console.info("Operation failed");
}) })
``` ```
## sensor.getGeomagneticField ## sensor.getGeomagneticField
...@@ -1740,16 +1736,16 @@ Obtains the geomagnetic field of a geographic location. This API uses a callback ...@@ -1740,16 +1736,16 @@ Obtains the geomagnetic field of a geographic location. This API uses a callback
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | --------------- | ---------------------------------------- | ---- | ----------------- |
| locationOptions | [LocationOptions](#locationoptions) | Yes| Geographic location.| | locationOptions | [LocationOptions](#locationoptions) | Yes | Geographic location. |
| timeMillis | number | Yes| Time for obtaining the magnetic declination, in milliseconds.| | timeMillis | number | Yes | Time for obtaining the magnetic declination, in milliseconds.|
| callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Yes| Callback used to return the geomagnetic field.| | callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Yes | Callback used to return the geomagnetic field. |
- Example **Example**
``` ```
sensor.getGeomagneticField([80, 0, 0], {'timeMillis':1580486400000}, function(err, data) { sensor.getGeomagneticField([80, 0, 0], 1580486400000, function(err, data) {
if (err) { if (err) {
console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message); console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
return; return;
...@@ -1757,10 +1753,8 @@ Obtains the geomagnetic field of a geographic location. This API uses a callback ...@@ -1757,10 +1753,8 @@ Obtains the geomagnetic field of a geographic location. This API uses a callback
console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
}); });
``` ```
## sensor.getGeomagneticField ## sensor.getGeomagneticField
getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise&lt;GeomagneticResponse&gt; getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise&lt;GeomagneticResponse&gt;
...@@ -1769,20 +1763,20 @@ Obtains the geomagnetic field of a geographic location. This API uses a promise ...@@ -1769,20 +1763,20 @@ Obtains the geomagnetic field of a geographic location. This API uses a promise
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | --------------- | ----------------------------------- | ---- | ----------------- |
| locationOptions | [LocationOptions](#locationoptions) | Yes| Geographic location.| | locationOptions | [LocationOptions](#locationoptions) | Yes | Geographic location. |
| timeMillis | number | Yes| Time for obtaining the magnetic declination, in milliseconds.| | timeMillis | number | Yes | Time for obtaining the magnetic declination, in milliseconds.|
- Return value **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ---------------------------------------- | ------- |
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Promise used to return the geomagnetic field.| | Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Promise used to return the geomagnetic field.|
- Example **Return value**
``` ```
const promise = sensor.getGeomagneticField([80, 0, 0], {'timeMillis':1580486400000}); const promise = sensor.getGeomagneticField([80, 0, 0], 1580486400000);
promise.then((data) => { promise.then((data) => {
console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
...@@ -1800,15 +1794,15 @@ Obtains the altitude at which the device is located based on the sea-level atmos ...@@ -1800,15 +1794,15 @@ Obtains the altitude at which the device is located based on the sea-level atmos
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------------- | --------------------------- | ---- | ------------------------------------- | | --------------- | --------------------------- | ---- | -------------------- |
| seaPressure | number | Yes | Sea-level atmospheric pressure, in hPa. | | seaPressure | number | Yes | Sea-level atmospheric pressure, in hPa. |
| currentPressure | number | Yes | Current atmospheric pressure at the altitude where the device is located, in hPa.| | currentPressure | number | Yes | Atmospheric pressure at the altitude where the device is located, in hPa.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the altitude, in meters. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the altitude, in meters. |
- Example **Return value**
``` ```
sensor.getAltitude(0, 200, function(err, data) { sensor.getAltitude(0, 200, function(err, data) {
...@@ -1829,20 +1823,20 @@ Obtains the altitude at which the device is located based on the sea-level atmos ...@@ -1829,20 +1823,20 @@ Obtains the altitude at which the device is located based on the sea-level atmos
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------------- | ------ | ---- | ------------------------------------- | | --------------- | ------ | ---- | -------------------- |
| seaPressure | number | Yes | Sea-level atmospheric pressure, in hPa. | | seaPressure | number | Yes | Sea-level atmospheric pressure, in hPa. |
| currentPressure | number | Yes | Atmospheric pressure at the altitude where the device is located, in hPa.| | currentPressure | number | Yes | Atmospheric pressure at the altitude where the device is located, in hPa.|
- Return value **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the altitude, in meters.| | Promise&lt;number&gt; | Promise used to return the altitude, in meters.|
- Example **Return value**
``` ```
const promise = sensor.getAltitude(0, 200); const promise = sensor.getAltitude(0, 200);
...@@ -1862,14 +1856,14 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a callba ...@@ -1862,14 +1856,14 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a callba
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------------- | --------------------------- | ---- | ---------------------------- | | ----------------- | --------------------------- | ---- | -------------- |
| inclinationMatrix | Array&lt;number&gt; | Yes | Inclination matrix. | | inclinationMatrix | Array&lt;number&gt; | Yes | Inclination matrix. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the magnetic dip, in radians.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the magnetic dip, in radians.|
- Example **Return value**
``` ```
sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
...@@ -1878,7 +1872,7 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a callba ...@@ -1878,7 +1872,7 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a callba
err.message); err.message);
return; return;
} }
console.info(Successed to get getGeomagneticDip interface get data: " + data); console.info("Successed to get getGeomagneticDip interface get data: " + data);
}) })
``` ```
...@@ -1890,19 +1884,19 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a promis ...@@ -1890,19 +1884,19 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a promis
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------------- | ------------------- | ---- | -------------- | | ----------------- | ------------------- | ---- | ------- |
| inclinationMatrix | Array&lt;number&gt; | Yes | Inclination matrix.| | inclinationMatrix | Array&lt;number&gt; | Yes | Inclination matrix.|
- Return value **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------------------- | | --------------------- | -------------- |
| Promise&lt;number&gt; | Promise used to return the magnetic dip, in radians.| | Promise&lt;number&gt; | Promise used to return the magnetic dip, in radians.|
- Example **Return value**
``` ```
const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]); const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
...@@ -1921,15 +1915,15 @@ Obtains the angle change between two rotation matrices. This API uses a callback ...@@ -1921,15 +1915,15 @@ Obtains the angle change between two rotation matrices. This API uses a callback
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------------------- | ---------------------------------------- | ---- | --------------------------------- | | --------------------- | ---------------------------------------- | ---- | ------------------ |
| currentRotationMatrix | Array&lt;number&gt; | Yes | Current rotation matrix. | | currentRotationMatrix | Array&lt;number&gt; | Yes | Current rotation matrix. |
| preRotationMatrix | Array&lt;number&gt; | Yes | The other rotation matrix. | | preRotationMatrix | Array&lt;number&gt; | Yes | The other rotation matrix. |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the angle change around the z, x, and y axes.| | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the angle change around the z, x, and y axes.|
- Example **Return value**
``` ```
sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) { sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) {
...@@ -1954,20 +1948,20 @@ Obtains the angle change between two rotation matrices. This API uses a promise ...@@ -1954,20 +1948,20 @@ Obtains the angle change between two rotation matrices. This API uses a promise
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------------------- | ------------------- | ---- | ------------------ | | --------------------- | ------------------- | ---- | --------- |
| currentRotationMatrix | Array&lt;number&gt; | Yes | Current rotation matrix.| | currentRotationMatrix | Array&lt;number&gt; | Yes | Current rotation matrix.|
| preRotationMatrix | Array&lt;number&gt; | Yes | Rotation matrix.| | preRotationMatrix | Array&lt;number&gt; | Yes | Rotation matrix. |
- Return value **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | --------------------------------- | | ---------------------------------- | ------------------ |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the angle change around the z, x, and y axes.| | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the angle change around the z, x, and y axes.|
- Example **Return value**
``` ```
const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]); const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]);
...@@ -1990,14 +1984,14 @@ Converts a rotation vector into a rotation matrix. This API uses a callback to r ...@@ -1990,14 +1984,14 @@ Converts a rotation vector into a rotation matrix. This API uses a callback to r
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------------- | ---------------------------------------- | ---- | -------------- | | -------------- | ---------------------------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.| | rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.|
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the rotation matrix.| | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the rotation matrix.|
- Example **Return value**
``` ```
sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
...@@ -2022,19 +2016,19 @@ Converts a rotation vector into a rotation matrix. This API uses a promise to re ...@@ -2022,19 +2016,19 @@ Converts a rotation vector into a rotation matrix. This API uses a promise to re
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------------- | ------------------- | ---- | -------------- | | -------------- | ------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.| | rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.|
- Return value **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | -------------- | | ---------------------------------- | ------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation matrix.| | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation matrix.|
- Example **Return value**
``` ```
const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
...@@ -2057,14 +2051,14 @@ Converts a rotation vector into a quaternion. This API uses a callback to return ...@@ -2057,14 +2051,14 @@ Converts a rotation vector into a quaternion. This API uses a callback to return
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------------- | ---------------------------------------- | ---- | -------------- | | -------------- | ---------------------------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.| | rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.|
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the quaternion. | | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the quaternion. |
- Example **Return value**
``` ```
sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
...@@ -2089,19 +2083,19 @@ Converts a rotation vector into a quaternion. This API uses a promise to return ...@@ -2089,19 +2083,19 @@ Converts a rotation vector into a quaternion. This API uses a promise to return
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------------- | ------------------- | ---- | -------------- | | -------------- | ------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.| | rotationVector | Array&lt;number&gt; | Yes | Rotation vector to convert.|
- Return value **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------------ | | ---------------------------------- | ------ |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the quaternion.| | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the quaternion.|
- Example **Return value**
``` ```
const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]); const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
...@@ -2124,14 +2118,14 @@ Obtains the device direction based on the rotation matrix. This API uses a callb ...@@ -2124,14 +2118,14 @@ Obtains the device direction based on the rotation matrix. This API uses a callb
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------------- | ---------------------------------------- | ---- | --------------------------------- | | -------------- | ---------------------------------------- | ---- | ------------------ |
| rotationMatrix | Array&lt;number&gt; | Yes | Rotation matrix. | | rotationMatrix | Array&lt;number&gt; | Yes | Rotation matrix. |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the rotation angle around the z, x, and y axes.| | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the rotation angle around the z, x, and y axes.|
- Example **Return value**
``` ```
sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
...@@ -2156,19 +2150,19 @@ Obtains the device direction based on the rotation matrix. This API uses a promi ...@@ -2156,19 +2150,19 @@ Obtains the device direction based on the rotation matrix. This API uses a promi
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------------- | ------------------- | ---- | -------------- | | -------------- | ------------------- | ---- | ------- |
| rotationMatrix | Array&lt;number&gt; | Yes | Rotation matrix.| | rotationMatrix | Array&lt;number&gt; | Yes | Rotation matrix.|
- Return value **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | --------------------------------- | | ---------------------------------- | ------------------ |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation angle around the z, x, and y axes.| | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the rotation angle around the z, x, and y axes.|
- Example **Return value**
``` ```
const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]); const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
...@@ -2191,15 +2185,15 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th ...@@ -2191,15 +2185,15 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------------------------------------------------------------ | ---- | -------------- | | ----------- | ---------------------------------------- | ---- | ------- |
| gravity | Array&lt;number&gt; | Yes | Gravity vector.| | gravity | Array&lt;number&gt; | Yes | Gravity vector.|
| geomagnetic | Array&lt;number&gt; | Yes | Geomagnetic vector.| | geomagnetic | Array&lt;number&gt; | Yes | Geomagnetic vector.|
| callback | AsyncCallback&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Yes | Callback used to return the rotation matrix.| | callback | AsyncCallback&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Yes | Callback used to return the rotation matrix.|
- Example **Return value**
``` ```
sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) { sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) {
...@@ -2224,20 +2218,20 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th ...@@ -2224,20 +2218,20 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------------------- | ---- | -------------- | | ----------- | ------------------- | ---- | ------- |
| gravity | Array&lt;number&gt; | Yes | Gravity vector.| | gravity | Array&lt;number&gt; | Yes | Gravity vector.|
| geomagnetic | Array&lt;number&gt; | Yes | Geomagnetic vector.| | geomagnetic | Array&lt;number&gt; | Yes | Geomagnetic vector.|
- Return value **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------------------------ | -------------- | | ---------------------------------------- | ------- |
| Promise&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Promise used to return the rotation matrix.| | Promise&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | Promise used to return the rotation matrix.|
- Example **Return value**
``` ```
const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
...@@ -2259,28 +2253,28 @@ Enumerates the sensor types. ...@@ -2259,28 +2253,28 @@ Enumerates the sensor types.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Default Value| Description| | Name | Default Value | Description |
| -------- | -------- | -------- | | ---------------------------------------- | ---- | ----------- |
| SENSOR_TYPE_ID_ACCELEROMETER | 1 | Acceleration sensor.| | SENSOR_TYPE_ID_ACCELEROMETER | 1 | Acceleration sensor. |
| SENSOR_TYPE_ID_GYROSCOPE | 2 | Gyroscope sensor.| | SENSOR_TYPE_ID_GYROSCOPE | 2 | Gyroscope sensor. |
| SENSOR_TYPE_ID_AMBIENT_LIGHT | 5 | Ambient light sensor.| | SENSOR_TYPE_ID_AMBIENT_LIGHT | 5 | Ambient light sensor. |
| SENSOR_TYPE_ID_MAGNETIC_FIELD | 6 | Magnetic field sensor.| | SENSOR_TYPE_ID_MAGNETIC_FIELD | 6 | Magnetic field sensor. |
| SENSOR_TYPE_ID_BAROMETER | 8 | Barometer sensor.| | SENSOR_TYPE_ID_BAROMETER | 8 | Barometer sensor. |
| SENSOR_TYPE_ID_HALL | 10 | Hall effect sensor.| | SENSOR_TYPE_ID_HALL | 10 | Hall effect sensor. |
| SENSOR_TYPE_ID_PROXIMITY | 12 | Proximity sensor.| | SENSOR_TYPE_ID_PROXIMITY | 12 | Proximity sensor. |
| SENSOR_TYPE_ID_HUMIDITY | 13 | Humidity sensor.| | SENSOR_TYPE_ID_HUMIDITY | 13 | Humidity sensor. |
| SENSOR_TYPE_ID_ORIENTATION | 256 | Orientation sensor.| | SENSOR_TYPE_ID_ORIENTATION | 256 | Orientation sensor. |
| SENSOR_TYPE_ID_GRAVITY | 257 | Gravity sensor.| | SENSOR_TYPE_ID_GRAVITY | 257 | Gravity sensor. |
| SENSOR_TYPE_ID_LINEAR_ACCELERATION | 258 | Linear acceleration sensor.| | SENSOR_TYPE_ID_LINEAR_ACCELERATION | 258 | Linear acceleration sensor. |
| SENSOR_TYPE_ID_ROTATION_VECTOR | 259 | Rotation vector sensor.| | SENSOR_TYPE_ID_ROTATION_VECTOR | 259 | Rotation vector sensor. |
| SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 260 | Ambient temperature sensor.| | SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 260 | Ambient temperature sensor. |
| SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 261 | Uncalibrated magnetic field sensor.| | SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 261 | Uncalibrated magnetic field sensor. |
| SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 263 | Uncalibrated gyroscope sensor.| | SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 263 | Uncalibrated gyroscope sensor. |
| SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 264 | Significant motion sensor.| | SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 264 | Significant motion sensor. |
| SENSOR_TYPE_ID_PEDOMETER_DETECTION | 265 | Pedometer detection sensor.| | SENSOR_TYPE_ID_PEDOMETER_DETECTION | 265 | Pedometer detection sensor. |
| SENSOR_TYPE_ID_PEDOMETER | 266 | Pedometer sensor.| | SENSOR_TYPE_ID_PEDOMETER | 266 | Pedometer sensor. |
| SENSOR_TYPE_ID_HEART_RATE | 278 | Heart rate sensor.| | SENSOR_TYPE_ID_HEART_RATE | 278 | Heart rate sensor. |
| SENSOR_TYPE_ID_WEAR_DETECTION | 280 | Wear detection sensor.| | SENSOR_TYPE_ID_WEAR_DETECTION | 280 | Wear detection sensor. |
| SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 281 | Uncalibrated acceleration sensor.| | SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 281 | Uncalibrated acceleration sensor.|
...@@ -2290,9 +2284,9 @@ Describes the timestamp of the sensor data. ...@@ -2290,9 +2284,9 @@ Describes the timestamp of the sensor data.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | --------- | ------ | ---- | ---- | ------------ |
| timestamp | number | Yes| Yes| Timestamp when the sensor reports data.| | timestamp | number | Yes | Yes | Timestamp when the sensor reports data.|
## AccelerometerResponse ## AccelerometerResponse
...@@ -2302,11 +2296,11 @@ Describes the acceleration sensor data. It extends from [Response](#response). ...@@ -2302,11 +2296,11 @@ Describes the acceleration sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ---- | ---------------------- |
| x | number | Yes| Yes| Acceleration along the x-axis of the device, in m/s2.| | x | number | Yes | Yes | Acceleration along the x-axis of the device, in m/s2.|
| y | number | Yes| Yes| Acceleration along the y-axis of the device, in m/s2.| | y | number | Yes | Yes | Acceleration along the y-axis of the device, in m/s2.|
| z | number | Yes| Yes| Acceleration along the z-axis of the device, in m/s2.| | z | number | Yes | Yes | Acceleration along the z-axis of the device, in m/s2.|
## LinearAccelerometerResponse ## LinearAccelerometerResponse
...@@ -2316,11 +2310,11 @@ Describes the linear acceleration sensor data. It extends from [Response](#respo ...@@ -2316,11 +2310,11 @@ Describes the linear acceleration sensor data. It extends from [Response](#respo
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ---- | ------------------------ |
| x | number | Yes| Yes| Linear acceleration along the x-axis of the device, in m/s2.| | x | number | Yes | Yes | Linear acceleration along the x-axis of the device, in m/s2.|
| y | number | Yes| Yes| Linear acceleration along the y-axis of the device, in m/s2.| | y | number | Yes | Yes | Linear acceleration along the y-axis of the device, in m/s2.|
| z | number | Yes| Yes| Linear acceleration along the z-axis of the device, in m/s2.| | z | number | Yes | Yes | Linear acceleration along the z-axis of the device, in m/s2.|
## AccelerometerUncalibratedResponse ## AccelerometerUncalibratedResponse
...@@ -2330,14 +2324,14 @@ Describes the uncalibrated acceleration sensor data. It extends from [Response]( ...@@ -2330,14 +2324,14 @@ Describes the uncalibrated acceleration sensor data. It extends from [Response](
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ---- | ---------------------------- |
| x | number | Yes| Yes| Uncalibrated acceleration along the x-axis of the device, in m/s2.| | x | number | Yes | Yes | Uncalibrated acceleration along the x-axis of the device, in m/s2. |
| y | number | Yes| Yes| Uncalibrated acceleration along the y-axis of the device, in m/s2.| | y | number | Yes | Yes | Uncalibrated acceleration along the y-axis of the device, in m/s2. |
| z | number | Yes| Yes| Uncalibrated acceleration along the z-axis of the device, in m/s2.| | z | number | Yes | Yes | Uncalibrated acceleration along the z-axis of the device, in m/s2. |
| biasX | number | Yes| Yes| Uncalibrated acceleration bias along the x-axis of the device, in m/s2.| | biasX | number | Yes | Yes | Uncalibrated acceleration bias along the x-axis of the device, in m/s2. |
| biasY | number | Yes| Yes| Uncalibrated acceleration bias along the y-axis of the device, in m/s2.| | biasY | number | Yes | Yes | Uncalibrated acceleration bias along the y-axis of the device, in m/s2.|
| biasZ | number | Yes| Yes| Uncalibrated acceleration bias along the z-axis of the device, in m/s2.| | biasZ | number | Yes | Yes | Uncalibrated acceleration bias along the z-axis of the device, in m/s2. |
## GravityResponse ## GravityResponse
...@@ -2347,11 +2341,11 @@ Describes the gravity sensor data. It extends from [Response](#response). ...@@ -2347,11 +2341,11 @@ Describes the gravity sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ---- | ------------------------ |
| x | number | Yes| Yes| Gravitational acceleration along the x-axis of the device, in m/s2.| | x | number | Yes | Yes | Gravitational acceleration along the x-axis of the device, in m/s2.|
| y | number | Yes| Yes| Gravitational acceleration along the y-axis of the device, in m/s2.| | y | number | Yes | Yes | Gravitational acceleration along the y-axis of the device, in m/s2.|
| z | number | Yes| Yes| Gravitational acceleration along the z-axis of the device, in m/s2.| | z | number | Yes | Yes | Gravitational acceleration along the z-axis of the device, in m/s2.|
## OrientationResponse ## OrientationResponse
...@@ -2361,11 +2355,11 @@ Describes the orientation sensor data. It extends from [Response](#response). ...@@ -2361,11 +2355,11 @@ Describes the orientation sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ---- | ------------------------ |
| alpha | number | Yes| Yes| Rotation angle of the device around the z-axis, in rad.| | alpha | number | Yes | Yes | Rotation angle of the device around the z-axis, in rad.|
| beta | number | Yes| Yes| Rotation angle of the device around the x-axis, in rad.| | beta | number | Yes | Yes | Rotation angle of the device around the x-axis, in rad. |
| gamma | number | Yes| Yes| Rotation angle of the device around the y-axis, in rad.| | gamma | number | Yes | Yes | Rotation angle of the device around the y-axis, in rad. |
## RotationVectorResponse ## RotationVectorResponse
...@@ -2375,12 +2369,12 @@ Describes the rotation vector sensor data. It extends from [Response](#response) ...@@ -2375,12 +2369,12 @@ Describes the rotation vector sensor data. It extends from [Response](#response)
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ---- | --------- |
| x | number | Yes| Yes| X-component of the rotation vector.| | x | number | Yes | Yes | X-component of the rotation vector.|
| y | number | Yes| Yes| Y-component of the rotation vector.| | y | number | Yes | Yes | Y-component of the rotation vector.|
| z | number | Yes| Yes| Z-component of the rotation vector.| | z | number | Yes | Yes | Z-component of the rotation vector.|
| w | number | Yes| Yes| Scalar.| | w | number | Yes | Yes | Scalar. |
## GyroscopeResponse ## GyroscopeResponse
...@@ -2390,11 +2384,11 @@ Describes the gyroscope sensor data. It extends from [Response](#response). ...@@ -2390,11 +2384,11 @@ Describes the gyroscope sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ---- | ------------------- |
| x | number | Yes| Yes| Angular velocity of rotation around the x-axis of the device, in rad/s.| | x | number | Yes | Yes | Angular velocity of rotation around the x-axis of the device, in rad/s.|
| y | number | Yes| Yes| Angular velocity of rotation around the y-axis of the device, in rad/s.| | y | number | Yes | Yes | Angular velocity of rotation around the y-axis of the device, in rad/s.|
| z | number | Yes| Yes| Angular velocity of rotation around the z-axis of the device, in rad/s.| | z | number | Yes | Yes | Angular velocity of rotation around the z-axis of the device, in rad/s.|
## GyroscopeUncalibratedResponse ## GyroscopeUncalibratedResponse
...@@ -2404,14 +2398,14 @@ Describes the uncalibrated gyroscope sensor data. It extends from [Response](#re ...@@ -2404,14 +2398,14 @@ Describes the uncalibrated gyroscope sensor data. It extends from [Response](#re
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ---- | ------------------------ |
| x | number | Yes| Yes| Uncalibrated angular velocity of rotation around the x-axis of the device, in rad/s.| | x | number | Yes | Yes | Uncalibrated angular velocity of rotation around the x-axis of the device, in rad/s. |
| y | number | Yes| Yes| Uncalibrated angular velocity of rotation around the y-axis of the device, in rad/s.| | y | number | Yes | Yes | Uncalibrated angular velocity of rotation around the y-axis of the device, in rad/s. |
| z | number | Yes| Yes| Uncalibrated angular velocity of rotation around the z-axis of the device, in rad/s.| | z | number | Yes | Yes | Uncalibrated angular velocity of rotation around the z-axis of the device, in rad/s. |
| biasX | number | Yes| Yes| Uncalibrated angular velocity bias of rotation around the x-axis of the device, in rad/s.| | biasX | number | Yes | Yes | Uncalibrated angular velocity bias of rotation around the x-axis of the device, in rad/s.|
| biasY | number | Yes| Yes| Uncalibrated angular velocity bias of rotation around the y-axis of the device, in rad/s.| | biasY | number | Yes | Yes | Uncalibrated angular velocity bias of rotation around the y-axis of the device, in rad/s.|
| biasZ | number | Yes| Yes| Uncalibrated angular velocity bias of rotation around the z-axis of the device, in rad/s.| | biasZ | number | Yes | Yes | Uncalibrated angular velocity bias of rotation around the z-axis of the device, in rad/s.|
## SignificantMotionResponse ## SignificantMotionResponse
...@@ -2421,9 +2415,9 @@ Describes the significant motion sensor data. It extends from [Response](#respon ...@@ -2421,9 +2415,9 @@ Describes the significant motion sensor data. It extends from [Response](#respon
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---- | ---------------------------------------- |
| scalar | number | Yes| Yes| Intensity of a motion. This parameter specifies whether a device has a significant motion on three physical axes (X, Y, and Z). The value **0** means that the device does not have a significant motion, and **1** means the opposite.| | scalar | number | Yes | Yes | Intensity of a motion. This parameter specifies whether a device has a significant motion on three physical axes (X, Y, and Z). The value **0** means that the device does not have a significant motion, and **1** means the opposite.|
## ProximityResponse ## ProximityResponse
...@@ -2433,9 +2427,9 @@ Describes the proximity sensor data. It extends from [Response](#response). ...@@ -2433,9 +2427,9 @@ Describes the proximity sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | ------ | ---- | ---- | ---------------------------- |
| distance | number | Yes| Yes| Proximity between the visible object and the device monitor. The value **0** means the two are close to each other, and **1** means that they are far away from each other.| | distance | number | Yes | Yes | Proximity between the visible object and the device monitor. The value **0** means the two are close to each other, and **1** means that they are far away from each other.|
## LightResponse ## LightResponse
...@@ -2445,9 +2439,9 @@ Describes the ambient light sensor data. It extends from [Response](#response). ...@@ -2445,9 +2439,9 @@ Describes the ambient light sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | --------- | ------ | ---- | ---- | ----------- |
| intensity | number | Yes| Yes| Illumination, in lux.| | intensity | number | Yes | Yes | Illumination, in lux.|
## HallResponse ## HallResponse
...@@ -2457,9 +2451,9 @@ Describes the Hall effect sensor data. It extends from [Response](#response). ...@@ -2457,9 +2451,9 @@ Describes the Hall effect sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---- | --------------------------------- |
| status | number | Yes| Yes| Hall effect sensor status. This parameter specifies whether a magnetic field exists around a device. The value **0** means that a magnetic field exists around the device, and **1** means the opposite.| | status | number | Yes | Yes | Hall effect sensor status. This parameter specifies whether a magnetic field exists around a device. The value **0** means that a magnetic field exists around the device, and **1** means the opposite.|
## MagneticFieldResponse ## MagneticFieldResponse
...@@ -2469,11 +2463,11 @@ Describes the magnetic field sensor data. It extends from [Response](#response). ...@@ -2469,11 +2463,11 @@ Describes the magnetic field sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ---- | ------ | ---- | ---- | ------------------ |
| x | number | Yes| Yes| Magnetic field strength on the x-axis, in μT.| | x | number | Yes | Yes | Magnetic field strength on the x-axis, in μT. |
| y | number | Yes| Yes| Magnetic field strength on the y-axis, in μT.| | y | number | Yes | Yes | Magnetic field strength on the y-axis, in μT. |
| z | number | Yes| Yes| Magnetic field strength on the z-axis, in μT.| | z | number | Yes | Yes | Magnetic field strength on the z-axis, in μT.|
## MagneticFieldUncalibratedResponse ## MagneticFieldUncalibratedResponse
...@@ -2483,14 +2477,14 @@ Describes the uncalibrated magnetic field sensor data. It extends from [Response ...@@ -2483,14 +2477,14 @@ Describes the uncalibrated magnetic field sensor data. It extends from [Response
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ---- | ---------------------- |
| x | number | Yes| Yes| Uncalibrated magnetic field strength on the x-axis, in μT.| | x | number | Yes | Yes | Uncalibrated magnetic field strength on the x-axis, in μT. |
| y | number | Yes| Yes| Uncalibrated magnetic field strength on the y-axis, in μT.| | y | number | Yes | Yes | Uncalibrated magnetic field strength on the y-axis, in μT. |
| z | number | Yes| Yes| Uncalibrated magnetic field strength on the z-axis, in μT.| | z | number | Yes | Yes | Uncalibrated magnetic field strength on the z-axis, in μT. |
| biasX | number | Yes| Yes| Bias of the uncalibrated magnetic field strength on the x-axis, in μT.| | biasX | number | Yes | Yes | Bias of the uncalibrated magnetic field strength on the x-axis, in μT.|
| biasY | number | Yes| Yes| Bias of the uncalibrated magnetic field strength on the y-axis, in μT.| | biasY | number | Yes | Yes | Bias of the uncalibrated magnetic field strength on the y-axis, in μT.|
| biasZ | number | Yes| Yes| Bias of the uncalibrated magnetic field strength on the z-axis, in μT.| | biasZ | number | Yes | Yes | Bias of the uncalibrated magnetic field strength on the z-axis, in μT.|
## PedometerResponse ## PedometerResponse
...@@ -2500,9 +2494,9 @@ Describes the pedometer sensor data. It extends from [Response](#response). ...@@ -2500,9 +2494,9 @@ Describes the pedometer sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ---- | -------- |
| steps | number | Yes| Yes| Number of steps a user has walked.| | steps | number | Yes | Yes | Number of steps a user has walked.|
## HumidityResponse ## HumidityResponse
...@@ -2512,9 +2506,9 @@ Describes the humidity sensor data. It extends from [Response](#response). ...@@ -2512,9 +2506,9 @@ Describes the humidity sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | ------ | ---- | ---- | ------------------------------------ |
| humidity | number | Yes| Yes| Ambient relative humidity, in a percentage (%).| | humidity | number | Yes | Yes | Ambient relative humidity, in a percentage (%).|
## PedometerDetectionResponse ## PedometerDetectionResponse
...@@ -2524,9 +2518,9 @@ Describes the pedometer detection sensor data. It extends from [Response](#respo ...@@ -2524,9 +2518,9 @@ Describes the pedometer detection sensor data. It extends from [Response](#respo
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---- | ---------------------------------------- |
| scalar | number | Yes| Yes| Pedometer detection. This parameter specifies whether a user takes a step. The value **0** means that the user does not take a step, and **1** means that the user takes a step.| | scalar | number | Yes | Yes | Pedometer detection. This parameter specifies whether a user takes a step. The value **0** means that the user does not take a step, and **1** means that the user takes a step.|
## AmbientTemperatureResponse ## AmbientTemperatureResponse
...@@ -2536,9 +2530,9 @@ Describes the ambient temperature sensor data. It extends from [Response](#respo ...@@ -2536,9 +2530,9 @@ Describes the ambient temperature sensor data. It extends from [Response](#respo
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ----------- | ------ | ---- | ---- | ------------- |
| temperature | number | Yes| Yes| Ambient temperature, in degree Celsius.| | temperature | number | Yes | Yes | Ambient temperature, in degree Celsius.|
## BarometerResponse ## BarometerResponse
...@@ -2548,9 +2542,9 @@ Describes the barometer sensor data. It extends from [Response](#response). ...@@ -2548,9 +2542,9 @@ Describes the barometer sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | ------ | ---- | ---- | ------------ |
| pressure | number | Yes| Yes| Atmospheric pressure, in pascal.| | pressure | number | Yes | Yes | Atmospheric pressure, in pascal.|
## HeartRateResponse ## HeartRateResponse
...@@ -2560,9 +2554,9 @@ Describes the heart rate sensor data. It extends from [Response](#response). ...@@ -2560,9 +2554,9 @@ Describes the heart rate sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | --------- | ------ | ---- | ---- | --------------------- |
| heartRate | number | Yes| Yes| Heart rate, in beats per minute (bpm).| | heartRate | number | Yes | Yes | Heart rate, in beats per minute (bpm).|
## WearDetectionResponse ## WearDetectionResponse
...@@ -2572,9 +2566,9 @@ Describes the wear detection sensor data. It extends from [Response](#response). ...@@ -2572,9 +2566,9 @@ Describes the wear detection sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ---- | ------------------------- |
| value | number | Yes| Yes| Whether the device is being worn. The value **1** means that the device is being worn, and **0** means the opposite.| | value | number | Yes | Yes | Whether the device is being worn. The value **1** means that the device is being worn, and **0** means the opposite.|
## Options ## Options
...@@ -2583,8 +2577,8 @@ Describes the sensor data reporting frequency. ...@@ -2583,8 +2577,8 @@ Describes the sensor data reporting frequency.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Description| | Name | Type | Description |
| -------- | -------- | -------- | | -------- | ------ | --------------------------- |
| interval | number | Frequency at which a sensor reports data. The default value is 200,000,000 ns.| | interval | number | Frequency at which a sensor reports data. The default value is 200,000,000 ns.|
## RotationMatrixResponse ## RotationMatrixResponse
...@@ -2593,8 +2587,8 @@ Describes the response for setting the rotation matrix. ...@@ -2593,8 +2587,8 @@ Describes the response for setting the rotation matrix.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name | Type | Readable| Writable| Description | | Name | Type | Readable | Writable | Description |
| ----------- | ------------------- | ---- | ---- | ---------- | | ----------- | ------------------- | ---- | ---- | ----- |
| rotation | Array&lt;number&gt; | Yes | Yes | Rotation matrix.| | rotation | Array&lt;number&gt; | Yes | Yes | Rotation matrix.|
| inclination | Array&lt;number&gt; | Yes | Yes | Inclination matrix.| | inclination | Array&lt;number&gt; | Yes | Yes | Inclination matrix.|
...@@ -2605,8 +2599,8 @@ Describes the coordinate options. ...@@ -2605,8 +2599,8 @@ Describes the coordinate options.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description | | Name | Type | Readable | Writable | Description |
| ---- | -------- | ---- | ---- | ----------- | | ---- | ------ | ---- | ---- | ------ |
| x | number | Yes | Yes | X coordinate direction.| | x | number | Yes | Yes | X coordinate direction.|
| y | number | Yes | Yes | Y coordinate direction.| | y | number | Yes | Yes | Y coordinate direction.|
...@@ -2617,15 +2611,15 @@ Describes a geomagnetic response object. It extends from [Response](#response). ...@@ -2617,15 +2611,15 @@ Describes a geomagnetic response object. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | --------------- | ------ | ---- | ---- | ------------------------- |
| x | number | Yes| Yes| North component of the geomagnetic field.| | x | number | Yes | Yes | North component of the geomagnetic field. |
| y | number | Yes| Yes| East component of the geomagnetic field.| | y | number | Yes | Yes | East component of the geomagnetic field. |
| z | number | Yes| Yes| Vertical component of the geomagnetic field.| | z | number | Yes | Yes | Vertical component of the geomagnetic field. |
| geomagneticDip | number | Yes| Yes| Magnetic dip, also called magnetic inclination, which is the angle measured from the horizontal plane to the magnetic field vector.| | geomagneticDip | number | Yes | Yes | Magnetic dip, also called magnetic inclination, which is the angle measured from the horizontal plane to the magnetic field vector. |
| deflectionAngle | number | Yes| Yes| Magnetic declination, which is the angle between true north (geographic north) and the magnetic north (the horizontal component of the field).| | deflectionAngle | number | Yes | Yes | Magnetic declination, which is the angle between true north (geographic north) and the magnetic north (the horizontal component of the field).|
| levelIntensity | number | Yes| Yes| Horizontal intensity of the magnetic field vector field.| | levelIntensity | number | Yes | Yes | Horizontal intensity of the magnetic field vector field. |
| totalIntensity | number | Yes| Yes| Total intensity of the magnetic field vector.| | totalIntensity | number | Yes | Yes | Total intensity of the magnetic field vector. |
## LocationOptions ## LocationOptions
...@@ -2633,8 +2627,8 @@ Describes the geographical location. ...@@ -2633,8 +2627,8 @@ Describes the geographical location.
**System capability**: SystemCapability.Sensors.Sensor **System capability**: SystemCapability.Sensors.Sensor
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | --------- | ------ | ---- | ---- | ----- |
| latitude | number | Yes| Yes| Latitude.| | latitude | number | Yes | Yes | Latitude. |
| longitude | number | Yes| Yes| Longitude.| | longitude | number | Yes | Yes | Longitude. |
| altitude | number | Yes| Yes| Altitude.| | altitude | number | Yes | Yes | Altitude.|
...@@ -350,7 +350,7 @@ Obtains the status of the SIM card in the specified slot. This API uses an async ...@@ -350,7 +350,7 @@ Obtains the status of the SIM card in the specified slot. This API uses an async
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | -------------------------------------- | | -------- | -------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID. The options are as follows:<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[SimState](#simState)\> | Yes | Callback used to return the result. For details, see [SimState](#simState). | | callback | AsyncCallback\<[SimState](#simstate)\> | Yes | Callback used to return the result. For details, see [SimState](#simState). |
**Example** **Example**
...@@ -379,7 +379,7 @@ Obtains the status of the SIM card in the specified slot. This API uses a promis ...@@ -379,7 +379,7 @@ Obtains the status of the SIM card in the specified slot. This API uses a promis
| Type | Description | | Type | Description |
| -------------------------------- | ------------------------------------------ | | -------------------------------- | ------------------------------------------ |
| Promise\<[SimState](#simState)\> | Promise used to return the result.| | Promise\<[SimState](#simstate)\> | Promise used to return the result.|
**Example** **Example**
......
# Update # Update
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications. The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications.
...@@ -30,15 +30,15 @@ Obtains the **Updater** object for local update. ...@@ -30,15 +30,15 @@ Obtains the **Updater** object for local update.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | --------------------------- | ---- | -------- | | ----------- | --------------------------- | ---- | ---- |
| upgradeFile | string | Yes | Update file.| | upgradeFile | string | Yes | Update file.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type.| | updateType | [UpdateTypes](#updatetypes) | Yes | Update type.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | -------- | | ------------------- | ---- |
| [Updater](#updater) | **Updater** object.| | [Updater](#updater) | **Updater** object.|
**Example** **Example**
...@@ -61,16 +61,16 @@ Obtains the **Updater** object for the device to be updated. ...@@ -61,16 +61,16 @@ Obtains the **Updater** object for the device to be updated.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | --------------------------- | ---- | ---------- | | ----------- | --------------------------- | ---- | ----- |
| upgradeFile | string | Yes | Update file. | | upgradeFile | string | Yes | Update file. |
| device | string | Yes | Device to be updated.| | device | string | Yes | Device to be updated.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | | updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | -------- | | ------------------- | ---- |
| [Updater](#updater) | **Updater** object.| | [Updater](#updater) | **Updater** object.|
**Example** **Example**
...@@ -93,16 +93,16 @@ Obtains the **Updater** object from another device for the device to be updated. ...@@ -93,16 +93,16 @@ Obtains the **Updater** object from another device for the device to be updated.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | --------------------------- | ---- | ---------- | | ----------- | --------------------------- | ---- | ----- |
| upgradeFile | string | Yes | Update file. | | upgradeFile | string | Yes | Update file. |
| device | string | Yes | Device to be updated.| | device | string | Yes | Device to be updated.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | | updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | -------- | | ------------------- | ---- |
| [Updater](#updater) | **Updater** object.| | [Updater](#updater) | **Updater** object.|
**Example** **Example**
...@@ -121,15 +121,15 @@ try { ...@@ -121,15 +121,15 @@ try {
getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void
Obtains the new version information. This API uses an asynchronous callback to return the result. Obtains the new version information. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------ | ---- | ------------------ | | -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the result.| | callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information.|
**Example** **Example**
...@@ -146,15 +146,15 @@ update.getNewVersionInfo(info => { ...@@ -146,15 +146,15 @@ update.getNewVersionInfo(info => {
getNewVersionInfo(): Promise\<NewVersionInfo> getNewVersionInfo(): Promise\<NewVersionInfo>
Obtains the new version information. This API uses a promise to return the result. Obtains the new version information. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------- | ------------------------- | | ---------------------------------------- | ---------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.| | Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.|
**Example** **Example**
...@@ -172,15 +172,15 @@ updater.getNewVersionInfo().then(value => { ...@@ -172,15 +172,15 @@ updater.getNewVersionInfo().then(value => {
checkNewVersion(callback: AsyncCallback\<NewVersionInfo>): void checkNewVersion(callback: AsyncCallback\<NewVersionInfo>): void
Checks whether the current version is the latest. This API uses an asynchronous callback to return the result. Checks whether the current version is the latest. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------- | ---- | ------------------ | | -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the result.| | callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information.|
**Example** **Example**
...@@ -197,15 +197,15 @@ update.checkNewVersion(info => { ...@@ -197,15 +197,15 @@ update.checkNewVersion(info => {
checkNewVersion(): Promise\<NewVersionInfo> checkNewVersion(): Promise\<NewVersionInfo>
Checks whether the current version is the latest. This API uses a promise to return the result. Checks whether the current version is the latest. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------- | ------------------------- | | ---------------------------------------- | ---------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.| | Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.|
**Example** **Example**
...@@ -229,8 +229,8 @@ Verifies whether the update package is valid. ...@@ -229,8 +229,8 @@ Verifies whether the update package is valid.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | ------------------ | | ----------- | ------ | ---- | --------- |
| upgradeFile | string | Yes | Path of the update package to be verified.| | upgradeFile | string | Yes | Path of the update package to be verified.|
| certsFile | string | Yes | Certificate path. | | certsFile | string | Yes | Certificate path. |
...@@ -247,15 +247,15 @@ update.verifyUpdatePackage("XXX", "XXX"); ...@@ -247,15 +247,15 @@ update.verifyUpdatePackage("XXX", "XXX");
rebootAndCleanUserData(): Promise\<number> rebootAndCleanUserData(): Promise\<number>
Reboots the device and clears the user partition data. This API uses a promise to return the result. Reboots the device and clears the user partition data. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | ------------------------------- | | ---------------- | ------------------- |
| Promise\<number> | Promise used to return the result.| | Promise\<number> | Promise used to return the execution result.|
**Example** **Example**
...@@ -271,15 +271,15 @@ update.rebootAndCleanUserData().then(result => { ...@@ -271,15 +271,15 @@ update.rebootAndCleanUserData().then(result => {
rebootAndCleanUserData(callback: AsyncCallback\<number>): void rebootAndCleanUserData(callback: AsyncCallback\<number>): void
Reboots the device and clears the user partition data. This API uses an asynchronous callback to return the result. Reboots the device and clears the user partition data. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | -------- | ---- | ---------------------- | | -------- | -------- | ---- | ---------------------- |
| callback | AsyncCallback\<number>| Yes | Callback used to return the result.| | callback | AsyncCallback\<number>| Yes | Callback used to return the execution result.|
**Example** **Example**
...@@ -293,15 +293,15 @@ update.rebootAndCleanUserData(result => { ...@@ -293,15 +293,15 @@ update.rebootAndCleanUserData(result => {
applyNewVersion(): Promise\<number> applyNewVersion(): Promise\<number>
Installs the update package. This API uses a promise to return the result. Installs the update package. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | ------------------------------- | | ---------------- | ------------------- |
| Promise\<number> | Promise used to return the result.| | Promise\<number> | Promise used to return the execution result.|
**Example** **Example**
...@@ -317,15 +317,15 @@ update.applyNewVersion().then(result => { ...@@ -317,15 +317,15 @@ update.applyNewVersion().then(result => {
applyNewVersion(callback: AsyncCallback\<number>): void applyNewVersion(callback: AsyncCallback\<number>): void
Installs the update package. This API uses an asynchronous callback to return the result. Installs the update package. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | -------- | ---- | ---------------------- | | -------- | -------- | ---- | ---------------------- |
| callback | AsyncCallback\<number>| Yes | Callback used to return the result.| | callback | AsyncCallback\<number>| Yes | Callback used to return the execution result.|
**Example** **Example**
...@@ -356,7 +356,7 @@ updater.download(); ...@@ -356,7 +356,7 @@ updater.download();
### upgrade ### upgrade
updater.upgrade():void upgrade():void
Starts an update. Starts an update.
...@@ -377,16 +377,16 @@ updater.upgrade(); ...@@ -377,16 +377,16 @@ updater.upgrade();
setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\<number>): void setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\<number>): void
Sets the update policy. This API uses an asynchronous callback to return the result. Sets the update policy. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------- | ---- | ------------ | | -------- | ----------------------------- | ---- | ------ |
| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.| | policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the result.| | callback | Callback used to return the execution result. | Yes | Callback used to return the execution result.|
**Example** **Example**
...@@ -408,21 +408,21 @@ update.setUpdatePolicy(policy, result => { ...@@ -408,21 +408,21 @@ update.setUpdatePolicy(policy, result => {
setUpdatePolicy(policy: UpdatePolicy): Promise\<number> setUpdatePolicy(policy: UpdatePolicy): Promise\<number>
Sets the update policy. This API uses a promise to return the result. Sets the update policy. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------ | ----------------------------- | ---- | ------------ | | ------ | ----------------------------- | ---- | ------ |
| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.| | policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | ----------------------- | | ---------------- | --------------- |
| Promise\<number> | Promise used to return the result.| | Promise\<number> | Promise used to return the execution result.|
**Example** **Example**
...@@ -445,15 +445,15 @@ update.setUpdatePolicy(policy).then(result => ...@@ -445,15 +445,15 @@ update.setUpdatePolicy(policy).then(result =>
getUpdatePolicy(callback: AsyncCallback\<UpdatePolicy>): void getUpdatePolicy(callback: AsyncCallback\<UpdatePolicy>): void
Obtains the update policy. This API uses an asynchronous callback to return the result. Obtains the update policy. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the result.| | callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the update policy.|
**Example** **Example**
...@@ -470,15 +470,15 @@ update.getUpdatePolicy(policy => { ...@@ -470,15 +470,15 @@ update.getUpdatePolicy(policy => {
getUpdatePolicy(): Promise\<UpdatePolicy> getUpdatePolicy(): Promise\<UpdatePolicy>
Obtains the update policy. This API uses a promise to return the result. Obtains the update policy. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Return Value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | --------------------------- | | --------------------------------------- | ----------------- |
| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the result.| | Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the update policy.|
**Example** **Example**
...@@ -498,10 +498,10 @@ Enumerates update types. ...@@ -498,10 +498,10 @@ Enumerates update types.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name| Description | | Name | Description |
| ------ | -------- | | ----- | ----- |
| OTA | OTA update. | | OTA | OTA update.|
| patch | Patch update.| | patch | Patch update. |
## PackageTypes ## PackageTypes
...@@ -509,15 +509,15 @@ Enumerates update package types. ...@@ -509,15 +509,15 @@ Enumerates update package types.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Default Value| Description | | Name | Default Value | Description |
| -------------------- | ------ | -------------- | | -------------------- | ---- | ------- |
| PACKAGE_TYPE_NORMAL | 1 | Common update package. | | PACKAGE_TYPE_NORMAL | 1 | Common update package. |
| PACKAGE_TYPE_BASE | 2 | Basic update package. | | PACKAGE_TYPE_BASE | 2 | Basic update package. |
| PACKAGE_TYPE_CUST | 3 | Custom update package. | | PACKAGE_TYPE_CUST | 3 | Custom update package. |
| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package. | | PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package. |
| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.| | PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.|
| PACKAGE_TYPE_VERSION | 6 | Version update package. | | PACKAGE_TYPE_VERSION | 6 | Version update package. |
| PACKAGE_TYPE_PATCH | 7 | Patch packages | | PACKAGE_TYPE_PATCH | 7 | Patch package. |
## InstallMode ## InstallMode
...@@ -525,8 +525,8 @@ Enumerates update modes. ...@@ -525,8 +525,8 @@ Enumerates update modes.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Default Value| Description | | Name | Default Value | Description |
| ------------------- | ------ | -------- | | ------------------- | ---- | ---- |
| INSTALL_MODE_NORMAL | 0 | Normal update.| | INSTALL_MODE_NORMAL | 0 | Normal update.|
| INSTALL_MODE_NIGHT | 1 | Update at night.| | INSTALL_MODE_NIGHT | 1 | Update at night.|
| INSTALL_MODE_AUTO | 2 | Automatic update.| | INSTALL_MODE_AUTO | 2 | Automatic update.|
...@@ -537,8 +537,8 @@ Enumerates new version check results. ...@@ -537,8 +537,8 @@ Enumerates new version check results.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Default Value| Description | | Name | Default Value | Description |
| ------------------- | ------ | ---------------- | | ------------------- | ---- | -------- |
| VERSION_STATUS_ERR | -1 | System error while checking for the new version. | | VERSION_STATUS_ERR | -1 | System error while checking for the new version. |
| VERSION_STATUS_NEW | 0 | New version detected. | | VERSION_STATUS_NEW | 0 | New version detected. |
| VERSION_STATUS_NONE | 1 | No new version detected.| | VERSION_STATUS_NONE | 1 | No new version detected.|
...@@ -550,10 +550,10 @@ Defines the update policy. ...@@ -550,10 +550,10 @@ Defines the update policy.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------------------- | --------------------------- | ---- | -------------- | | ------------------- | --------------------------- | ---- | ------- |
| autoDownload | bool | Yes | Automatic update switch. | | autoDownload | bool | Yes | Automatic update switch. |
| installMode | [InstallMode](#installmode) | Yes | Installation mode. | | installMode | [InstallMode](#installmode) | Yes | Update mode. |
| autoUpgradeInterval | Array\<number> | Yes | Period of time for automatic update.| | autoUpgradeInterval | Array\<number> | Yes | Period of time for automatic update.|
## NewVersionInfo ## NewVersionInfo
...@@ -562,8 +562,8 @@ Defines the new version information. ...@@ -562,8 +562,8 @@ Defines the new version information.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| --------------- | ------------------------------------------- | ---- | -------- | | --------------- | ---------------------------------------- | ---- | ---- |
| status | [NewVersionStatus](#newversionstatus) | Yes | Update status.| | status | [NewVersionStatus](#newversionstatus) | Yes | Update status.|
| errMsg | string | Yes | Error message.| | errMsg | string | Yes | Error message.|
| checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result.| | checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result.|
...@@ -575,8 +575,8 @@ Defines the version check result. ...@@ -575,8 +575,8 @@ Defines the version check result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------------- | ----------------------------- | ---- | ------------ | | ------------- | ----------------------------- | ---- | ------ |
| versionName | string | Yes | Version name. | | versionName | string | Yes | Version name. |
| versionCode | number | Yes | Version code. | | versionCode | number | Yes | Version code. |
| size | number | Yes | Version size. | | size | number | Yes | Version size. |
...@@ -590,7 +590,7 @@ Defines the version description information. ...@@ -590,7 +590,7 @@ Defines the version description information.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Type| Mandatory| Description | | Name | Type | Mandatory | Description |
| ------------- | -------- | ---- | ----------------- | | ------------- | ------ | ---- | ------------- |
| descriptionId | string | Yes | Version ID information.| | descriptionId | string | Yes | Version ID information.|
| content | string | Yes | Version changelog information.| | content | string | Yes | Version changelog information.|
# UriPermissionManager # uriPermissionManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements URI permission management. Implements URI permission management.
...@@ -11,11 +11,11 @@ Implements URI permission management. ...@@ -11,11 +11,11 @@ Implements URI permission management.
``` ```
import UriPermissionManager from '@@ohos.application.UriPermissionManager'; import uriPermissionManager from '@ohos.application.uriPermissionManager';
``` ```
## verifyUriPermission ## uriPermissionManager.verifyUriPermission
verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number, callback: AsyncCallback&lt;number&gt;): void verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number, callback: AsyncCallback&lt;number&gt;): void
...@@ -25,7 +25,8 @@ Checks whether an application has the permission specified by **flag** for an UR ...@@ -25,7 +25,8 @@ Checks whether an application has the permission specified by **flag** for an UR
SystemCapability.Ability.AbilityRuntime.Core SystemCapability.Ability.AbilityRuntime.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.| | uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.|
...@@ -33,7 +34,7 @@ SystemCapability.Ability.AbilityRuntime.Core ...@@ -33,7 +34,7 @@ SystemCapability.Ability.AbilityRuntime.Core
| accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.| | accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.|
- Example **Example**
``` ```
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
...@@ -43,7 +44,7 @@ SystemCapability.Ability.AbilityRuntime.Core ...@@ -43,7 +44,7 @@ SystemCapability.Ability.AbilityRuntime.Core
``` ```
## verifyUriPermission ## uriPermissionManager.verifyUriPermission
verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise&lt;number&gt; verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise&lt;number&gt;
...@@ -53,19 +54,21 @@ Checks whether an application has the permission specified by **flag** for an UR ...@@ -53,19 +54,21 @@ Checks whether an application has the permission specified by **flag** for an UR
SystemCapability.Ability.AbilityRuntime.Core SystemCapability.Ability.AbilityRuntime.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.| | uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.|
| flag | wantConstant.Flags | Yes| Read or write permission on the file specified by the URI.| | flag | wantConstant.Flags | Yes| Read or write permission on the file specified by the URI.|
| accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.| | accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.| | Promise&lt;number&gt; | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.|
- Example **Example**
``` ```
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
......
...@@ -528,6 +528,7 @@ vector.increaseCapacityTo(8); ...@@ -528,6 +528,7 @@ vector.increaseCapacityTo(8);
``` ```
### trimToCurrentLength ### trimToCurrentLength
trimToCurrentLength(): void trimToCurrentLength(): void
Trims the capacity of this container into its current length. Trims the capacity of this container into its current length.
......
...@@ -22,18 +22,18 @@ Triggers vibration with a specific duration. This API uses a promise to return t ...@@ -22,18 +22,18 @@ Triggers vibration with a specific duration. This API uses a promise to return t
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ------ | ---- | ------------ |
| duration | number | Yes| Vibration duration.| | duration | number | Yes | Vibration duration.|
- Return value **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully.| | Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully.|
- Example **Example**
``` ```
vibrator.vibrate(1000).then(()=>{ vibrator.vibrate(1000).then(()=>{
console.log("Promise returned to indicate a successful vibration."); console.log("Promise returned to indicate a successful vibration.");
...@@ -53,13 +53,13 @@ Triggers vibration with a specific duration. This API uses an asynchronous callb ...@@ -53,13 +53,13 @@ Triggers vibration with a specific duration. This API uses an asynchronous callb
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ------------------------- | ---- | ----------------------- |
| duration | number | Yes| Vibration duration.| | duration | number | Yes | Vibration duration. |
| callback | AsyncCallback&lt;void&gt; | No| Callback used to indicate whether the vibration is triggered successfully.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully.|
- Example **Example**
``` ```
vibrator.vibrate(1000,function(error){ vibrator.vibrate(1000,function(error){
if(error){ if(error){
...@@ -81,17 +81,17 @@ Triggers vibration with a specific effect. This API uses a promise to return the ...@@ -81,17 +81,17 @@ Triggers vibration with a specific effect. This API uses a promise to return the
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | --------------------- | ---- | ------------- |
| effectId | [EffectId](#effectid) | Yes| String that indicates the vibration effect.| | effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect.|
- Return value **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully.| | Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully.|
- Example **Example**
``` ```
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{
console.log("Promise returned to indicate a successful vibration."); console.log("Promise returned to indicate a successful vibration.");
...@@ -111,13 +111,13 @@ Triggers vibration with a specific effect. This API uses an asynchronous callbac ...@@ -111,13 +111,13 @@ Triggers vibration with a specific effect. This API uses an asynchronous callbac
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ------------------------- | ---- | ----------------------- |
| effectId | [EffectId](#effectid) | Yes| String that indicates the vibration effect.| | effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. |
| callback | AsyncCallback&lt;void&gt; | No| Callback used to indicate whether the vibration is triggered successfully.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully.|
- Example **Example**
``` ```
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){
if(error){ if(error){
...@@ -139,17 +139,17 @@ Stops the vibration based on the specified **stopMode**. This API uses a promise ...@@ -139,17 +139,17 @@ Stops the vibration based on the specified **stopMode**. This API uses a promise
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ------------------------------------- | ---- | --------------- |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes| Vibration mode to stop.| | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop.|
- Return value **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is stopped successfully.| | Promise&lt;void&gt; | Promise used to indicate whether the vibration is stopped successfully.|
- Example **Example**
``` ```
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{
console.log("Promise returned to indicate a successful vibration."); console.log("Promise returned to indicate a successful vibration.");
...@@ -169,13 +169,13 @@ Stops the vibration based on the specified **stopMode**. This API uses an asynch ...@@ -169,13 +169,13 @@ Stops the vibration based on the specified **stopMode**. This API uses an asynch
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ------------------------------------- | ---- | ----------------------- |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes| Vibration mode to stop.| | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. |
| callback | AsyncCallback&lt;void&gt; | No| Callback used to indicate whether the vibration is stopped successfully.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is stopped successfully.|
- Example **Example**
``` ```
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){
if(error){ if(error){
...@@ -193,8 +193,8 @@ Describes the vibration effect. ...@@ -193,8 +193,8 @@ Describes the vibration effect.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name| Default Value| Description| | Name | Default Value | Description |
| -------- | -------- | -------- | | ------------------ | -------------------- | --------------- |
| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer.| | EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer.|
...@@ -204,7 +204,7 @@ Describes the vibration mode to stop. ...@@ -204,7 +204,7 @@ Describes the vibration mode to stop.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name| Default Value| Description| | Name | Default Value | Description |
| -------- | -------- | -------- | | ------------------------- | -------- | ---------------------------------------- |
| VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type.| | VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type.|
| VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type.| | VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type.|
...@@ -85,7 +85,7 @@ let ws = webSocket.createWebSocket(); ...@@ -85,7 +85,7 @@ let ws = webSocket.createWebSocket();
## WebSocket ## WebSocket
Defines a **WebSocket** object. Before invoking WebSocket APIs, you need to call [webSocket.createWebSocket](#webSocketcreatewebsocket) to create a **WebSocket** object. Defines a **WebSocket** object. Before invoking WebSocket APIs, you need to call [webSocket.createWebSocket](#websocketcreatewebsocket) to create a **WebSocket** object.
### connect ### connect
......
...@@ -160,12 +160,14 @@ Describes the color gamut mode. ...@@ -160,12 +160,14 @@ Describes the color gamut mode.
| DEFAULT | 0 | Default color gamut mode.| | DEFAULT | 0 | Default color gamut mode.|
| WIDE_GAMUT | 1 | Wide color gamut mode. | | WIDE_GAMUT | 1 | Wide color gamut mode. |
## window.create<sup>7</sup><a name="window-create"></a> ## window.create<sup>7+</sup>
create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
Creates a subwindow. This API uses an asynchronous callback to return the result. Creates a subwindow. This API uses an asynchronous callback to return the result.
This API is discarded since API version 8. You are advised to use [window.create<sup>8+</sup>](#windowcreate8) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
- Parameters - Parameters
...@@ -191,12 +193,14 @@ Creates a subwindow. This API uses an asynchronous callback to return the result ...@@ -191,12 +193,14 @@ Creates a subwindow. This API uses an asynchronous callback to return the result
}); });
``` ```
## window.create<sup>7</sup> ## window.create<sup>7+</sup>
create(id: string, type: WindowType): Promise&lt;Window&gt; create(id: string, type: WindowType): Promise&lt;Window&gt;
Creates a subwindow. This API uses a promise to return the result. Creates a subwindow. This API uses a promise to return the result.
This API is discarded since API version 8. You are advised to use [window.create<sup>8+</sup>](#windowcreate8) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
- Parameters - Parameters
...@@ -523,7 +527,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -523,7 +527,7 @@ This is a system API and cannot be called by third-party applications.
## Window ## Window
In the following API examples, you must use [getTopWindow()](#window-gettopwindow), [create()](#window-create), or [find()](#window-find) to obtain a **Window** instance and then call a method in this instance. In the following API examples, you must use [getTopWindow()](#window-gettopwindow), [create()](#windowcreate7), or [find()](#window-find) to obtain a **Window** instance and then call a method in this instance.
### hide<sup>7+</sup> ### hide<sup>7+</sup>
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
## Constraints ## Constraints
None None
## Modules to Import ## Modules to Import
import zlib from '@ohos.zlib'
```javascript
import zlib from '@ohos.zlib';
```
## zlib.zipFile ## zlib.zipFile
zipFile(inFile:string, outFile:string, options: Options): Promise<void>; zipFile(inFile:string, outFile:string, options: Options): Promise<void>;
Zips a file. This API uses a promise to return the result. Zips a file. This API uses a promise to return the result.
...@@ -134,7 +137,7 @@ zlib.unzipFile(inFile, outFile, options).then((data) => { ...@@ -134,7 +137,7 @@ zlib.unzipFile(inFile, outFile, options).then((data) => {
| MEM_LEVEL_MAX | Maximum memory used by the **zip** API during compression.| | MEM_LEVEL_MAX | Maximum memory used by the **zip** API during compression.|
| MEM_LEVEL_DEFAULT | Default memory used by the **zip** API during compression.| | MEM_LEVEL_DEFAULT | Default memory used by the **zip** API during compression.|
## Zip.CompressLevel ## zip.CompressLevel
| Name | Description | | Name | Description |
| --------------------------------------- | ----------------- | | --------------------------------------- | ----------------- |
...@@ -143,7 +146,7 @@ zlib.unzipFile(inFile, outFile, options).then((data) => { ...@@ -143,7 +146,7 @@ zlib.unzipFile(inFile, outFile, options).then((data) => {
| COMPRESS_LEVEL_BEST_COMPRESSION :9 | Compression level 9 that gives the best compression. | | COMPRESS_LEVEL_BEST_COMPRESSION :9 | Compression level 9 that gives the best compression. |
| COMPRESS_LEVEL_DEFAULT_COMPRESSION : -1| Default compression level. | | COMPRESS_LEVEL_DEFAULT_COMPRESSION : -1| Default compression level. |
## Zip.CompressStrategy ## zip.CompressStrategy
| Name | Description | | Name | Description |
| -------------------------------------- | ------------------------ | | -------------------------------------- | ------------------------ |
......
...@@ -3,6 +3,9 @@ The **\<web>** component displays web page content. ...@@ -3,6 +3,9 @@ The **\<web>** component displays web page content.
>![](../../public_sys-resources/icon-note.gif) **NOTE** >![](../../public_sys-resources/icon-note.gif) **NOTE**
> This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions
ohos.permission.INTERNET, required only for accessing online web pages.
## Constraints ## Constraints
The **\<web>** component does not follow the transition animation. A page allows only one **\<web>** component. The **\<web>** component does not follow the transition animation. A page allows only one **\<web>** component.
...@@ -44,7 +47,7 @@ The following methods are supported. ...@@ -44,7 +47,7 @@ The following methods are supported.
``` ```
``` ```
<!-- xxx.js --> // xxx.js
export default { export default {
reloadWeb() { reloadWeb() {
this.$element('web').reload() this.$element('web').reload()
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
- [ImageAnimator](ts-basic-components-imageanimator.md) - [ImageAnimator](ts-basic-components-imageanimator.md)
- [LoadingProgress](ts-basic-components-loadingprogress.md) - [LoadingProgress](ts-basic-components-loadingprogress.md)
- [Marquee](ts-basic-components-marquee.md) - [Marquee](ts-basic-components-marquee.md)
- [Navigation](ts-basic-components-navigation.md)
- [PatternLock](ts-basic-components-patternlock.md) - [PatternLock](ts-basic-components-patternlock.md)
- [PluginComponent](ts-basic-components-plugincomponent.md) - [PluginComponent](ts-basic-components-plugincomponent.md)
- [Progress](ts-basic-components-progress.md) - [Progress](ts-basic-components-progress.md)
...@@ -67,10 +68,13 @@ ...@@ -67,10 +68,13 @@
- [Radio](ts-basic-components-radio.md) - [Radio](ts-basic-components-radio.md)
- [Rating](ts-basic-components-rating.md) - [Rating](ts-basic-components-rating.md)
- [RichText](ts-basic-components-richtext.md) - [RichText](ts-basic-components-richtext.md)
- [ScrollBar](ts-basic-components-scrollbar.md)
- [Search](ts-basic-components-search.md) - [Search](ts-basic-components-search.md)
- [Select](ts-basic-components-select.md) - [Select](ts-basic-components-select.md)
- [Slider](ts-basic-components-slider.md) - [Slider](ts-basic-components-slider.md)
- [Span](ts-basic-components-span.md) - [Span](ts-basic-components-span.md)
- [Stepper](ts-basic-components-stepper.md)
- [StepperItem](ts-basic-components-stepperitem.md)
- [Text](ts-basic-components-text.md) - [Text](ts-basic-components-text.md)
- [TextArea](ts-basic-components-textarea.md) - [TextArea](ts-basic-components-textarea.md)
- [TextClock](ts-basic-components-textclock.md) - [TextClock](ts-basic-components-textclock.md)
...@@ -94,17 +98,13 @@ ...@@ -94,17 +98,13 @@
- [List](ts-container-list.md) - [List](ts-container-list.md)
- [ListItem](ts-container-listitem.md) - [ListItem](ts-container-listitem.md)
- [Navigator](ts-container-navigator.md) - [Navigator](ts-container-navigator.md)
- [Navigation](ts-basic-components-navigation.md)
- [Panel](ts-container-panel.md) - [Panel](ts-container-panel.md)
- [Refresh](ts-container-refresh.md) - [Refresh](ts-container-refresh.md)
- [Row](ts-container-row.md) - [Row](ts-container-row.md)
- [RowSplit](ts-container-rowsplit.md) - [RowSplit](ts-container-rowsplit.md)
- [Scroll](ts-container-scroll.md) - [Scroll](ts-container-scroll.md)
- [ScrollBar](ts-basic-components-scrollbar.md)
- [SideBarContainer](ts-container-sidebarcontainer.md) - [SideBarContainer](ts-container-sidebarcontainer.md)
- [Stack](ts-container-stack.md) - [Stack](ts-container-stack.md)
- [Stepper](ts-basic-components-stepper.md)
- [StepperItem](ts-basic-components-stepperitem.md)
- [Swiper](ts-container-swiper.md) - [Swiper](ts-container-swiper.md)
- [Tabs](ts-container-tabs.md) - [Tabs](ts-container-tabs.md)
- [TabContent](ts-container-tabcontent.md) - [TabContent](ts-container-tabcontent.md)
......
...@@ -29,11 +29,11 @@ Creates a component that can automatically display the navigation bar, title, an ...@@ -29,11 +29,11 @@ Creates a component that can automatically display the navigation bar, title, an
| Name | Type | Default Value | Description | | Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| title | string \| [Custom Builder](../../ui/ts-types.md) | - | Page title. | | title | string \| [CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Page title. |
| subtitle | string | - | Subtitle of the page. | | subtitle | string | - | Subtitle of the page. |
| menus | Array&lt;NavigationMenuItem&gt; \| [Custom Builder](../../ui/ts-types.md) | - | Menu in the upper right corner of the page. | | menus | Array&lt;NavigationMenuItem&gt; \| [CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Menu in the upper right corner of the page. |
| titleMode | NavigationTitleMode | NavigationTitleMode.Free | Display mode of the page title bar. | | titleMode | NavigationTitleMode | NavigationTitleMode.Free | Display mode of the page title bar. |
| toolBar | {<br/>items:[<br/>Object<br/>] }<br/>\| [Custom Builder](../../ui/ts-types.md) | - | Content of the toolbar.<br/>**items**: all items on the toolbar. | | toolBar | {<br/>items:[<br/>Object<br/>] }<br/>\| [CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Content of the toolbar.<br/>**items**: all items on the toolbar. |
| hideToolBar | boolean | false | Whether to hide the toolbar.<br/>**true**: Hide the toolbar.<br/>**false**: Show the toolbar. | | hideToolBar | boolean | false | Whether to hide the toolbar.<br/>**true**: Hide the toolbar.<br/>**false**: Show the toolbar. |
| hideTitleBar | boolean | false | Whether to hide the title bar. | | hideTitleBar | boolean | false | Whether to hide the title bar. |
| hideBackButton | boolean | false | Whether to hide the back button. | | hideBackButton | boolean | false | Whether to hide the back button. |
...@@ -67,7 +67,7 @@ Creates a component that can automatically display the navigation bar, title, an ...@@ -67,7 +67,7 @@ Creates a component that can automatically display the navigation bar, title, an
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| onTitleModeChanged(callback: (titleMode: NavigationTitleMode) =&gt; void) | Triggered when **titleMode** is set to **NavigationTitleMode.Free** and the title bar mode changes as content scrolls. | | onTitleModeChange(callback:&nbsp;(titleMode:&nbsp;NavigationTitleMode)&nbsp;=&gt;&nbsp;void) | Triggered when **titleMode** is set to **NavigationTitleMode.Free** and the title bar mode changes as content scrolls. |
## Example ## Example
...@@ -140,7 +140,7 @@ struct NavigationExample { ...@@ -140,7 +140,7 @@ struct NavigationExample {
.titleMode(NavigationTitleMode.Free) .titleMode(NavigationTitleMode.Free)
.hideTitleBar(false) .hideTitleBar(false)
.hideBackButton(false) .hideBackButton(false)
.onTitleModeChanged((titleModel: NavigationTitleMode) => { .onTitleModeChange((titleModel: NavigationTitleMode) => {
console.log('titleMode') console.log('titleMode')
}) })
.toolBar({ items: [ .toolBar({ items: [
......
...@@ -20,9 +20,9 @@ This component can contain a single child component. ...@@ -20,9 +20,9 @@ This component can contain a single child component.
## APIs ## APIs
ScrollBar(value: ScrollBarOption) ScrollBar(value: ScrollBarOptions)
- ScrollBarOption parameters - ScrollBarOptions parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| scroller | [Scroller](ts-container-scroll.md#scroller) | Yes | - | Scroller, which can be bound to and control scrollable components. | | scroller | [Scroller](ts-container-scroll.md#scroller) | Yes | - | Scroller, which can be bound to and control scrollable components. |
......
...@@ -20,8 +20,8 @@ Select(options: Array<SelectOption>) ...@@ -20,8 +20,8 @@ Select(options: Array<SelectOption>)
| Name| Type| Mandatory| Default Value| Description| | Name| Type| Mandatory| Default Value| Description|
| ------ | ----------------------------------------------- | ---- | ------ | -------------- | | ------ | ----------------------------------------------- | ---- | ------ | -------------- |
| value | [ResourceStr](../../ui/ts-types.md#ResourceStr) | Yes| - | Value of an option in the drop-down list box.| | value | [ResourceStr](../../ui/ts-types.md) | Yes| - | Value of an option in the drop-down list box.|
| icon | [ResourceStr](../../ui/ts-types.md#ResourceStr) | No| - | Icon of an option in the drop-down list box.| | icon | [ResourceStr](../../ui/ts-types.md) | No| - | Icon of an option in the drop-down list box.|
## Attributes ## Attributes
...@@ -30,19 +30,19 @@ Select(options: Array<SelectOption>) ...@@ -30,19 +30,19 @@ Select(options: Array<SelectOption>)
| selected | number | - | Index of the initial selected option in the drop-down list box. The index of the first option is **0**.| | selected | number | - | Index of the initial selected option in the drop-down list box. The index of the first option is **0**.|
| value | string | - | Text of the drop-down button.| | value | string | - | Text of the drop-down button.|
| font | [Font](../../ui/ts-types.md) | - | Text font of the drop-down button.| | font | [Font](../../ui/ts-types.md) | - | Text font of the drop-down button.|
| fontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of the drop-down button.| | fontColor | [ResourceColor](../../ui/ts-types.md) | - | Text color of the drop-down button.|
| selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Background color of the selected option in the drop-down list box.| | selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md) | - | Background color of the selected option in the drop-down list box.|
| selectedOptionFont | [Font](../../ui/ts-types.md) | - | Text font of the selected option in the drop-down list box.| | selectedOptionFont | [Font](../../ui/ts-types.md) | - | Text font of the selected option in the drop-down list box.|
| selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of the selected option in the drop-down list box.| | selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md) | - | Text color of the selected option in the drop-down list box.|
| optionBgColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Background color of an option in the drop-down list box.| | optionBgColor | [ResourceColor](../../ui/ts-types.md) | - | Background color of an option in the drop-down list box.|
| optionFont | [Font](../../ui/ts-types.md) | - | Text font of an option in the drop-down list box.| | optionFont | [Font](../../ui/ts-types.md) | - | Text font of an option in the drop-down list box.|
| optionFontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of an option in the drop-down list box.| | optionFontColor | [ResourceColor](../../ui/ts-types.md) | - | Text color of an option in the drop-down list box.|
## Events ## Events
| Name| Description| | Name| Description|
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------ | ------------------------------------------------------------ |
| onSelected(callback: (index: number, value?:string) => void)| Invoked when an option in the drop-down list box is selected. **index** indicates the index of the selected option. **value** indicates the value of the selected option.| | onSelect(callback: (index: number, value?:string) => void) | Invoked when an option in the drop-down list box is selected. **index** indicates the index of the selected option. **value** indicates the value of the selected option.|
## Example ## Example
...@@ -61,7 +61,7 @@ struct SliderExample { ...@@ -61,7 +61,7 @@ struct SliderExample {
.font({size: 30, weight:400, family: 'serif', style: FontStyle.Normal }) .font({size: 30, weight:400, family: 'serif', style: FontStyle.Normal })
.selectedOptionFont({size: 40, weight: 500, family: 'serif', style: FontStyle.Normal }) .selectedOptionFont({size: 40, weight: 500, family: 'serif', style: FontStyle.Normal })
.optionFont({size: 30, weight: 400, family: 'serif', style: FontStyle.Normal }) .optionFont({size: 30, weight: 400, family: 'serif', style: FontStyle.Normal })
.onSelected((index:number)=>{ .onSelecte((index:number)=>{
console.info("Select:" + index) console.info("Select:" + index)
}) })
} }
......
...@@ -31,7 +31,7 @@ TextInput(value?:{placeholder?: string controller?: TextInputController}) ...@@ -31,7 +31,7 @@ TextInput(value?:{placeholder?: string controller?: TextInputController})
## Attributes ## Attributes
In addition to [universal attributes](ts-universal-attributes.md), the following attributes are supported. In addition to [universal attributes](ts-universal-attributes-index.md), the following attributes are supported.
| Name | Type | Default Value | Description | | Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -60,16 +60,6 @@ In addition to [universal attributes](ts-universal-attributes.md), the following ...@@ -60,16 +60,6 @@ In addition to [universal attributes](ts-universal-attributes.md), the following
| InputType.Email | Email address input mode. | | InputType.Email | Email address input mode. |
| InputType.Number | Digit input mode. | | InputType.Number | Digit input mode. |
## Events
| Name | Description |
| --------------------------------------------------------- | ------------------------------------------------------------ |
| onChange(value: string) =&gt; void | Triggered when the input changes. |
| onSubmit(callback: (enterKey: EnterKeyType) =&gt; void) | Triggered when the Enter key on the physical or soft keyboard is pressed. |
| onEditChanged(callback: (isEditing: boolean) =&gt; void) | Triggered when the input status changes. |
| onCopy<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be copied. |
| onCut<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be cut. |
| onPaste<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be pasted. |
### TextInputController<sup>8+</sup> ### TextInputController<sup>8+</sup>
...@@ -88,7 +78,7 @@ controller: TextInputController = new TextInputController() ...@@ -88,7 +78,7 @@ controller: TextInputController = new TextInputController()
``` ```
### caretPosition ### controller.createPosition
caretPosition(value: number): void caretPosition(value: number): void
...@@ -100,6 +90,19 @@ Sets the cursor in a specified position. ...@@ -100,6 +90,19 @@ Sets the cursor in a specified position.
| value | number | Yes | - | Position of the input cursor.<br/>**value**: indicates the length from the start of the string to the position where the input cursor is located. | | value | number | Yes | - | Position of the input cursor.<br/>**value**: indicates the length from the start of the string to the position where the input cursor is located. |
## Events
| Name | Description |
| -------- | -------- |
| onChange(value: string) =&gt; void | Triggered when the input changes. |
| onSubmit(callback: (enterKey: EnterKeyType) =&gt; void) | Triggered when the Enter key on the physical or soft keyboard is pressed. |
| onEditChanged(callback:&nbsp;(isEditing:&nbsp;boolean)&nbsp;=&gt;&nbsp;void)<sup>(deprecated) </sup> | Triggered when the input status changes. |
| onEditChange(callback:&nbsp;(isEditing:&nbsp;boolean)&nbsp;=&gt;&nbsp;void) <sup>8+</sup> | Triggered when the input status changes. |
| onCopy<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be copied. |
| onCut<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be cut. |
| onPaste<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be pasted. |
## Example ## Example
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
The **<Web\>** component can be used to display web pages. The **<Web\>** component can be used to display web pages.
## Required Permissions
ohos.permission.INTERNET, required only for accessing online web pages.
## Child Components ## Child Components
None None
...@@ -31,9 +34,9 @@ None ...@@ -31,9 +34,9 @@ None
| Name | Type | Default Value | Description | | Name | Type | Default Value | Description |
| ----------------- | ------------------------------------------------------------ | -------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ | -------------- | ------------------------------------------------------------ |
| domStorageAccess | boolean | false | Whether to enable the DOM Storage API permission. By default, the permission is disabled.| | domStorageAccess | boolean | false | Whether to enable the DOM Storage API permission. By default, the permission is disabled.|
| fileAccess | boolean | true | Whether to enable in-application rawfile access through [$rawfile(filepath/filename)](ts-application-resource-access.md#referencing-resources). By default, this feature is enabled. | | fileAccess | boolean | true | Whether to enable in-application rawfile access through [$rawfile(filepath/filename)](../../ui/ts-application-resource-access.md). By default, this feature is enabled.|
| imageAccess | boolean | true | Whether to enable automatic image loading. By default, this feature is enabled. | | imageAccess | boolean | true | Whether to enable automatic image loading. By default, this feature is enabled. |
| javaScriptProxy | { <br> object: object, <br> name: string, <br> methodList: Array\<string\>, <br> controller: WebController <br>} | - | JavaScript object to be injected into the window. Methods of this object can be invoked in the window. The parameters in this attribute cannot be updated.<br>**object** indicates the object to be registered. Methods can be declared, but not attributes. The parameters and return value can only be of the string, number, or Boolean type.<br>**name** indicates the name of the object to be registered, which is the same as that invoked in the window. After registration, the window can use this name to access the JavaScript object at the application side.<br>**methodList** indicates the methods of the JavaScript object to be registered at the application side.<br>**controller** indicates the controller. | | javaScriptProxy | { <br> object: object, <br> name: string, <br> methodList: Array\<string\>, <br> controller: WebController <br>} | - | JavaScript object to be injected into the window. Methods of this object can be invoked in the window. The parameters in this attribute cannot be updated.<br> **object** indicates the object to be registered. Methods can be declared, but not attributes. The parameters and return value can only be of the string, number, or Boolean type.<br> **name** indicates the name of the object to be registered, which is the same as that invoked in the window. After registration, the window can use this name to access the JavaScript object at the application side.<br> **methodList** indicates the methods of the JavaScript object to be registered at the application side.<br> **controller** indicates the controller.|
| javaScriptAccess | boolean | true | Whether JavaScript scripts can be executed. By default, JavaScript scripts can be executed. | | javaScriptAccess | boolean | true | Whether JavaScript scripts can be executed. By default, JavaScript scripts can be executed. |
| mixedMode | [MixedMode](#MixedMode) | MixedMode.None | Whether to enable loading of HTTP and HTTPS hybrid content can be loaded. By default, this feature is disabled.| | mixedMode | [MixedMode](#MixedMode) | MixedMode.None | Whether to enable loading of HTTP and HTTPS hybrid content can be loaded. By default, this feature is disabled.|
| onlineImageAccess | boolean | true | Whether to enable access to online images through HTTP and HTTPS. By default, this feature is enabled.| | onlineImageAccess | boolean | true | Whether to enable access to online images through HTTP and HTTPS. By default, this feature is enabled.|
...@@ -62,7 +65,7 @@ Universal events are not supported. ...@@ -62,7 +65,7 @@ Universal events are not supported.
| onConsole(callback: (event?: { message: [ConsoleMessage](#ConsoleMessage) }) => boolean) | <p>Triggered when the host application is notified of a JavaScript console message.<br>**message**: console message.</p> | | onConsole(callback: (event?: { message: [ConsoleMessage](#ConsoleMessage) }) => boolean) | <p>Triggered when the host application is notified of a JavaScript console message.<br>**message**: console message.</p> |
| onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisposition: string, mimetype: string, contentLength: number }) => void) | <p>Triggered when a download task starts on the web page.<br>**url**: URL for the download task.<br>**userAgent**: name of the user agent (UA) for the download task.<br>**contentDisposition**: Content-Disposition response header returned by the server, which may be empty.<br>**mimetype**: content media type (MIME) returned by the server.<br>**contentLength**: length of the file returned by the server.</p> | | onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisposition: string, mimetype: string, contentLength: number }) => void) | <p>Triggered when a download task starts on the web page.<br>**url**: URL for the download task.<br>**userAgent**: name of the user agent (UA) for the download task.<br>**contentDisposition**: Content-Disposition response header returned by the server, which may be empty.<br>**mimetype**: content media type (MIME) returned by the server.<br>**contentLength**: length of the file returned by the server.</p> |
| onErrorReceive(callback: (event?: { request: [WebResourceRequest](#WebResourceError), error: [WebResourceError](#WebResourceError) }) => void) | <p>Triggered when an error occurs during web page loading.<br>For best results, simplify the implementation logic in the callback.<br>**request**: encapsulation of a web page request.<br>**error**: encapsulation of a web page resource loading error.</p> | | onErrorReceive(callback: (event?: { request: [WebResourceRequest](#WebResourceError), error: [WebResourceError](#WebResourceError) }) => void) | <p>Triggered when an error occurs during web page loading.<br>For best results, simplify the implementation logic in the callback.<br>**request**: encapsulation of a web page request.<br>**error**: encapsulation of a web page resource loading error.</p> |
| onHttpErrorReceive(callback: (event?: { request: [WebResourceRequest](#WebResourceError), response: [WebResourceResponse](#WebResourceResponse) }) => void) | <p>Triggered when an HTTP error (the response code is greater than or equal to 400) occurs during web page resource loading.<br>**request**: encapsulation of a web page request.<br>**response**: encapsulation of a web page response.</p> | | onHttpErrorReceive(callback: (event?: { request: [WebResourceRequest](#WebResourceError), response: [WebResourceResponse](#WebResourceResponse) }) => void) | <p>Triggered when an HTTP error (the response code is greater than or equal to 400) occurs during web page resource loading.<br>**request**: encapsulation of a web page request.<br>**response**: encapsulation of a web page response.</p>|
| onPageBegin(callback: (event?: { url: string }) => void) | <p>Triggered when the web page starts to be loaded. This API is triggered only for the main frame content, and not for the iframe or frameset content.<br>**url**: URL of the page.</p> | | onPageBegin(callback: (event?: { url: string }) => void) | <p>Triggered when the web page starts to be loaded. This API is triggered only for the main frame content, and not for the iframe or frameset content.<br>**url**: URL of the page.</p> |
| onPageEnd(callback: (event?: { url: string }) => void) | <p>Triggered when the web page loading is complete. This API is triggered only for the main frame content.<br>**url**: URL of the page.</p> | | onPageEnd(callback: (event?: { url: string }) => void) | <p>Triggered when the web page loading is complete. This API is triggered only for the main frame content.<br>**url**: URL of the page.</p> |
| onProgressChange(callback: (event?: { newProgress: number }) => void) | <p>Triggered when the web page loading progress changes.<br>**newProgress**: new loading progress. The value is an integer ranging from 0 to 100.</p> | | onProgressChange(callback: (event?: { newProgress: number }) => void) | <p>Triggered when the web page loading progress changes.<br>**newProgress**: new loading progress. The value is an integer ranging from 0 to 100.</p> |
...@@ -127,10 +130,10 @@ Describes the request/response header object returned by the **\<Web>** componen ...@@ -127,10 +130,10 @@ Describes the request/response header object returned by the **\<Web>** componen
- Parameters - Parameters
| Name | Description | | Name | Type |Description |
| ----------- | ---------------------- | | ----------- | ----------- |---------------------- |
| headerKey: string | <p>Key of the request/response header.</p> | | headerKey | string |Key of the request/response header.|
| headerValue: string | <p>Value of the request/response header.</p> | | headerValue | string |Value of the request/response header.|
### WebResourceResponse ### WebResourceResponse
...@@ -178,7 +181,13 @@ Indicates whether a specific number of steps forward or backward can be performe ...@@ -178,7 +181,13 @@ Indicates whether a specific number of steps forward or backward can be performe
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------------------- | | ---- | ------ | ---- | ---- | --------------------- |
| step | number | Yes | - | Number of the steps to take. A positive number means to going forward, and a negative number means to going backward. | | step | number | Yes | - | Number of the steps to take. A positive number means to going forward, and a negative number means to going backward.|
- Return value
| Type | Description |
| ---- | ------ |
| boolean | Whether to go forward or backward from the current page.|
### backward ### backward
......
...@@ -12,7 +12,7 @@ None ...@@ -12,7 +12,7 @@ None
## APIs ## APIs
PanGesture(options?: { fingers?: number, direction?: PanDirection, distance?: number } | [PanGestureOption](#pangestureoption)) PanGesture(options?: { fingers?: number, direction?: PanDirection, distance?: number } | [PanGestureOption](#pangestureoptions))
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
...@@ -34,11 +34,11 @@ PanGesture(options?: { fingers?: number, direction?: PanDirection, distance?: nu ...@@ -34,11 +34,11 @@ PanGesture(options?: { fingers?: number, direction?: PanDirection, distance?: nu
| None | Slide disabled. | | None | Slide disabled. |
### PanGestureOption ### PanGestureOptions
The attributes of the slide gesture recognizer can be dynamically modified using the **PanGestureOption** AP. This avoids modifying attributes through status variables, which will cause the UI to be refreshed. The attributes of the slide gesture recognizer can be dynamically modified using the **PanGestureOptions** AP. This avoids modifying attributes through status variables, which will cause the UI to be refreshed.
PanGestureOption(options?: { fingers?: number, direction?: PanDirection, distance?: number }) PanGestureOptions(options?: { fingers?: number, direction?: PanDirection, distance?: number })
- Parameters - Parameters
For details, see **PanGesture**. For details, see **PanGesture**.
...@@ -53,7 +53,7 @@ PanGestureOption(options?: { fingers?: number, direction?: PanDirection, distanc ...@@ -53,7 +53,7 @@ PanGestureOption(options?: { fingers?: number, direction?: PanDirection, distanc
## Events ## Events
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| onActionStart(callback: (event?: PanGestureEvent) =&gt; void) | Callback for the pan gestures reorganization event. | | onActionStart(callback: (event?: PanGestureEvent) =&gt; void) | Callback for the pan gestures reorganization event. |
| onActionUpdate(callback: (event?: PanGestureEvent) =&gt; void) | Callback invoked when a pan gesture is recognized. | | onActionUpdate(callback: (event?: PanGestureEvent) =&gt; void) | Callback invoked when a pan gesture is recognized. |
......
...@@ -31,7 +31,7 @@ AlphabetIndexer(value: {arrayValue : Array&lt;string&gt;, selected : number}) ...@@ -31,7 +31,7 @@ AlphabetIndexer(value: {arrayValue : Array&lt;string&gt;, selected : number})
## Attributes ## Attributes
| Name | Type | Description | | Name | Type | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| selectedColor | Color | Font color of the selected text. | | selectedColor | Color | Font color of the selected text. |
| popupColor | Color | Font color of the pop-up text. | | popupColor | Color | Font color of the pop-up text. |
...@@ -53,11 +53,12 @@ AlphabetIndexer(value: {arrayValue : Array&lt;string&gt;, selected : number}) ...@@ -53,11 +53,12 @@ AlphabetIndexer(value: {arrayValue : Array&lt;string&gt;, selected : number})
## Events ## Events
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| onSelected(index: number) =&gt; void | Callback invoked when an item in the alphabetic indexer bar is selected. | | onSelected(index:&nbsp;number)&nbsp;=&gt;&nbsp;void<sup>(deprecated) </sup> | Invoked when an item in the alphabetic indexer bar is selected. |
| onSelect(index:&nbsp;number)&nbsp;=&gt;&nbsp;void<sup>8+</sup> | Invoked when an item in the alphabetic indexer bar is selected. |
| onRequestPopupData(callback: (index: number) =&gt; Array&lt;string&gt;)<sup>8+</sup> | Invoked when a request for displaying content in the index prompt window is sent when an item in the alphabetic indexer bar is selected.<br/>The return value is a string array corresponding to the indexes. The string array is displayed vertically in the pop-up window. It can display up to five strings at a time and allows scrolling. | | onRequestPopupData(callback: (index: number) =&gt; Array&lt;string&gt;)<sup>8+</sup> | Invoked when a request for displaying content in the index prompt window is sent when an item in the alphabetic indexer bar is selected.<br/>The return value is a string array corresponding to the indexes. The string array is displayed vertically in the pop-up window. It can display up to five strings at a time and allows scrolling. |
| onPopupSelected(callback: (index: number) =&gt; void)<sup>8+</sup> | Invoked when an item in the index pop-up window is selected. | | onPopupSelect(callback: (index: number) =&gt; void)<sup>8+</sup> | Invoked when an item in the index pop-up window is selected. |
## Example ## Example
...@@ -80,7 +81,7 @@ struct AlphabetIndexerSample { ...@@ -80,7 +81,7 @@ struct AlphabetIndexerSample {
.popupFont({ size: 30, weight: FontWeight.Bolder }) // Font style of the pop-up text .popupFont({ size: 30, weight: FontWeight.Bolder }) // Font style of the pop-up text
.itemSize(28) // Size of each item (square) .itemSize(28) // Size of each item (square)
.alignStyle(IndexerAlign.Left) // Left aligned .alignStyle(IndexerAlign.Left) // Left aligned
.onSelected((index: number) => { .onSelect((index: number) => {
console.info(this.value[index] + 'Selected') // Event indicating that an item is selected console.info(this.value[index] + 'Selected') // Event indicating that an item is selected
}) })
.margin({ left: 50 }) .margin({ left: 50 })
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| animateTo(value: [AnimationOption](#animationoption-object), event: ()=&gt; void) : void | Provides a transition animation when the status changes due to the closure code.<br/>**event** specifies the closure function that displays the dynamic effect. The system automatically inserts the transition animation if the status changes in the closure function. | | animateTo(value: [AnimationOptions](#animationoptions), event: ()=&gt; void) : void | Provides a transition animation when the status changes due to the closure code.<br/>**event** specifies the closure function that displays the dynamic effect. The system automatically inserts the transition animation if the status changes in the closure function. |
## AnimationOption Object ## AnimationOptions
- Attributes - Attributes
| Name | Type | Default Value | Description | | Name | Type | Default Value | Description |
......
...@@ -15,9 +15,9 @@ The **&lt;Video&gt;** component does not support any child component. ...@@ -15,9 +15,9 @@ The **&lt;Video&gt;** component does not support any child component.
## APIs ## APIs
Video(value: VideoOption) Video(value: VideoOptions)
- VideoOption attributes - VideoOptions attributes
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| src | string | No | - | Path of the video source. | | src | string | No | - | Path of the video source. |
...@@ -49,7 +49,7 @@ Video(value: VideoOption) ...@@ -49,7 +49,7 @@ Video(value: VideoOption)
## Events ## Events
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| onStart() =&gt; void | Triggered when the video is played. | | onStart() =&gt; void | Triggered when the video is played. |
| onPause() =&gt; void | Triggered when the video playback is paused. | | onPause() =&gt; void | Triggered when the video playback is paused. |
...@@ -66,7 +66,7 @@ Video(value: VideoOption) ...@@ -66,7 +66,7 @@ Video(value: VideoOption)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> A **VideoController** object can control one or more videos. > A **VideoController** object can control one or more videos.
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| start() : void | Starts playback. | | start() : void | Starts playback. |
| pause() : void | Pauses playback. | | pause() : void | Pauses playback. |
......
...@@ -11,11 +11,11 @@ None ...@@ -11,11 +11,11 @@ None
## TextPickerDialog.show ## TextPickerDialog.show
show(options: TextPickerDialogOption) show(options: TextPickerDialogOptions)
Shows a text picker in the given settings. Shows a text picker in the given settings.
- TextPickerDialogOption parameters - TextPickerDialogOptions
| Name| Type| Mandatory| Default Value| Description| | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| range | string[] | Yes| - | Data selection range of the picker.| | range | string[] | Yes| - | Data selection range of the picker.|
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
...@@ -13,7 +13,7 @@ None ...@@ -13,7 +13,7 @@ None
## Attributes ## Attributes
| **Name** | **Type** | **Default Value** | **Description** | | **Name** | **Type** | **Default Value** | **Description** |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| touchable | boolean | true | Whether the current component is touchable. | | touchable | boolean | true | Whether the current component is touchable. |
......
...@@ -12,7 +12,7 @@ None ...@@ -12,7 +12,7 @@ None
## Attributes ## Attributes
| Name | Type | Default Value | Description | | Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| hoverEffect | HoverEffect | HoverEffect.Auto | Hover effect of the component in hover state. | | hoverEffect | HoverEffect | HoverEffect.Auto | Hover effect of the component in hover state. |
...@@ -21,7 +21,7 @@ None ...@@ -21,7 +21,7 @@ None
| -------- | -------- | | -------- | -------- |
| Auto | Default hover effect. | | Auto | Default hover effect. |
| Scale | Scale effect. | | Scale | Scale effect. |
| Board | Fade-in and fade-out effect. | | Highlight | Fade-in and fade-out effect. |
| None | No effect. | | None | No effect. |
...@@ -43,17 +43,17 @@ struct HoverExample { ...@@ -43,17 +43,17 @@ struct HoverExample {
.position({ x: 40, y: 120 }) .position({ x: 40, y: 120 })
.hoverEffect(HoverEffect.Scale) .hoverEffect(HoverEffect.Scale)
.onHover((isHover: boolean) => { .onHover((isHover: boolean) => {
console.info('Scale' + isHover) console.info('Scale isHover: ' + isHover)
this.isHoverVal = isHover this.isHoverVal = isHover
}) })
Text('Board').fontSize(20).fontColor(Color.Gray).width('90%').position({ x: 0, y: 380 }) Text('Board').fontSize(20).fontColor(Color.Gray).width('90%').position({ x: 0, y: 380 })
Column() Column()
.width('80%').height(200).backgroundColor(Color.Gray) .width('80%').height(200).backgroundColor(Color.Gray)
.hoverEffect(HoverEffect.Board) .hoverEffect(HoverEffect.Highlight)
.position({ x: 40, y: 420 }) .position({ x: 40, y: 420 })
.onHover((isHover: boolean) => { .onHover((isHover: boolean) => {
console.info('HoverEffect.Board') console.info('Highlight isHover: ' +isHover )
this.isHoverVal = isHover this.isHoverVal = isHover
}) })
} }
......
...@@ -15,9 +15,9 @@ None ...@@ -15,9 +15,9 @@ None
## Attributes ## Attributes
| Name | Type | Default Value | Description | | Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| stateStyle | StateStyles | - | Sets the styles of a component for different states. | | stateStyles | StateStyles | - | Styles of a component for different states. |
- StateStyles<sup>8+</sup> - StateStyles<sup>8+</sup>
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
......
...@@ -13,12 +13,12 @@ None ...@@ -13,12 +13,12 @@ None
## Attributes ## Attributes
| Name | Type | Default Value | Description | | Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bindPopup | show: boolean,<br/>popup: PopupOption \| CustomPopupOption | - | Settings of the popup bound to a component.<br/>**show**: whether to display the popup on the creation page by default. The default value is **false**.<br/>**popup**: parameters of the current popup. | | bindPopup | show: boolean,<br/>popup: PopupOptions \| CustomPopupOptions | - | Settings of the popup bound to a component.<br/>**show**: whether to display the popup on the creation page by default. The default value is **false**.<br/>**popup**: parameters of the current popup. |
- PopupOption attributes - PopupOptions attributes
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| message | string | Yes | - | Content of the popup message. | | message | string | Yes | - | Content of the popup message. |
...@@ -27,7 +27,7 @@ None ...@@ -27,7 +27,7 @@ None
| secondaryButton | {<br/>value: string,<br/>action: () =&gt; void<br/>} | No | - | Second button.<br/>**value**: text of the secondary button in the popup.<br/>**action**: callback function for clicking the secondary button. | | secondaryButton | {<br/>value: string,<br/>action: () =&gt; void<br/>} | No | - | Second button.<br/>**value**: text of the secondary button in the popup.<br/>**action**: callback function for clicking the secondary button. |
| onStateChange | (isVisible: boolean) =&gt; void | No | - | Callback for the popup status change event. The parameter **isVisible** indicates the visibility of the popup. | | onStateChange | (isVisible: boolean) =&gt; void | No | - | Callback for the popup status change event. The parameter **isVisible** indicates the visibility of the popup. |
- CustomPopupOption<sup>8+</sup> - CustomPopupOptions<sup>8+</sup>
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| builder | () =&gt; any | Yes | - | Builder of the tooltip content. | | builder | () =&gt; any | Yes | - | Builder of the tooltip content. |
......
...@@ -12,14 +12,14 @@ None ...@@ -12,14 +12,14 @@ None
## Events ## Events
| Name | Bubble Supported | Description | | Name | Bubble Supported | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| onClick(callback: (event?: ClickEvent) =&gt; void) | No | Called when a click event occurs. For details about the event parameters, see [ClickEvent](#clickevent). | | onClick(callback: (event?: ClickEvent) =&gt; void) | No | Called when a click event occurs. For details about the event parameters, see [ClickEvent](#clickevent). |
### ClickEvent ### ClickEvent
| Name | Type | Description | | Name | Type | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| screenX | number | X coordinate of the click relative to the left edge of the screen. | | screenX | number | X coordinate of the click relative to the left edge of the screen. |
| screenY | number | Y coordinate of the click relative to the upper edge of the screen. | | screenY | number | Y coordinate of the click relative to the upper edge of the screen. |
...@@ -40,8 +40,8 @@ None ...@@ -40,8 +40,8 @@ None
| -------- | -------- | -------- | | -------- | -------- | -------- |
| width | number | Width of the target element, in vp. | | width | number | Width of the target element, in vp. |
| height | number | Height of the target element, in vp. | | height | number | Height of the target element, in vp. |
| pos | Position | Position of the upper left corner of the target element relative to that of the parent element. | | position | Position | Position of the upper left corner of the target element relative to that of the parent element. |
| globalPos | Position | Position of the upper left corner of the target element relative to that of the page. | | globalPosition | Position | Position of the upper left corner of the target element relative to that of the page. |
- Position<sup>8+</sup> attributes - Position<sup>8+</sup> attributes
......
...@@ -378,6 +378,7 @@ ...@@ -378,6 +378,7 @@
- [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md)
- [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md)
- [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md)
- [Navigation](reference/arkui-ts/ts-basic-components-navigation.md)
- [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md)
- [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md)
- [Progress](reference/arkui-ts/ts-basic-components-progress.md) - [Progress](reference/arkui-ts/ts-basic-components-progress.md)
...@@ -385,6 +386,7 @@ ...@@ -385,6 +386,7 @@
- [Radio](reference/arkui-ts/ts-basic-components-radio.md) - [Radio](reference/arkui-ts/ts-basic-components-radio.md)
- [Rating](reference/arkui-ts/ts-basic-components-rating.md) - [Rating](reference/arkui-ts/ts-basic-components-rating.md)
- [RichText](reference/arkui-ts/ts-basic-components-richtext.md) - [RichText](reference/arkui-ts/ts-basic-components-richtext.md)
- [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md)
- [Search](reference/arkui-ts/ts-basic-components-search.md) - [Search](reference/arkui-ts/ts-basic-components-search.md)
- [Select](reference/arkui-ts/ts-basic-components-select.md) - [Select](reference/arkui-ts/ts-basic-components-select.md)
- [Slider](reference/arkui-ts/ts-basic-components-slider.md) - [Slider](reference/arkui-ts/ts-basic-components-slider.md)
...@@ -414,13 +416,11 @@ ...@@ -414,13 +416,11 @@
- [List](reference/arkui-ts/ts-container-list.md) - [List](reference/arkui-ts/ts-container-list.md)
- [ListItem](reference/arkui-ts/ts-container-listitem.md) - [ListItem](reference/arkui-ts/ts-container-listitem.md)
- [Navigator](reference/arkui-ts/ts-container-navigator.md) - [Navigator](reference/arkui-ts/ts-container-navigator.md)
- [Navigation](reference/arkui-ts/ts-basic-components-navigation.md)
- [Panel](reference/arkui-ts/ts-container-panel.md) - [Panel](reference/arkui-ts/ts-container-panel.md)
- [Refresh](reference/arkui-ts/ts-container-refresh.md) - [Refresh](reference/arkui-ts/ts-container-refresh.md)
- [Row](reference/arkui-ts/ts-container-row.md) - [Row](reference/arkui-ts/ts-container-row.md)
- [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md)
- [Scroll](reference/arkui-ts/ts-container-scroll.md) - [Scroll](reference/arkui-ts/ts-container-scroll.md)
- [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md)
- [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md)
- [Stack](reference/arkui-ts/ts-container-stack.md) - [Stack](reference/arkui-ts/ts-container-stack.md)
- [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Swiper](reference/arkui-ts/ts-container-swiper.md)
......
...@@ -40,7 +40,7 @@ int main() ...@@ -40,7 +40,7 @@ int main()
## Compilation<a name="section534302242515"></a> ## Compilation<a name="section534302242515"></a>
``` ```
$ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos --sysroot=/home/<user-name>/harmony/out/hispark_taurus/ipcamera_hispark_taurus/sysroot $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a) $ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos --sysroot=/home/<user-name>/directory/out/hispark_taurus/ipcamera_hispark_taurus/sysroot $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a)
``` ```
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE:**
...@@ -48,7 +48,7 @@ $ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp ...@@ -48,7 +48,7 @@ $ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp
>- When compiling user programs and required libraries, add the option **-funwind-tables -rdynamic -g** for stack backtracking. >- When compiling user programs and required libraries, add the option **-funwind-tables -rdynamic -g** for stack backtracking.
>- The **-mfloat-abi=softfp**, **-mcpu=cortex-a7**, and **-mfpu=neon-vfpv4** options specify the floating-point calculation optimization, chip architecture, and FPU, which must be the same as the compilation options used by the libc library. Otherwise, the libc library file cannot be found during the link time. >- The **-mfloat-abi=softfp**, **-mcpu=cortex-a7**, and **-mfpu=neon-vfpv4** options specify the floating-point calculation optimization, chip architecture, and FPU, which must be the same as the compilation options used by the libc library. Otherwise, the libc library file cannot be found during the link time.
>- **-target arm-liteos** specifies the path of the library files related to the compiler. >- **-target arm-liteos** specifies the path of the library files related to the compiler.
>- **--sysroot=/home/<user-name\>/harmony/out/hispark\_taurus/ipcamera\_hispark\_taurus/sysroot** specifies the root directory of the compiler library files. In this example, the OpenHarmony project code is stored in **/home/<user-name\>/harmony**. The **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory indicates the product specified by the **hb set** command during compilation. In this example, **ipcamera\_hispark\_taurus** is the product specified. >- **--sysroot=/home/<user-name\>/directory/out/hispark\_taurus/ipcamera\_hispark\_taurus/sysroot** specifies the root directory of the compiler library files. In this example, the OpenHarmony project code is stored in **/home/<user-name\>/directory**. The **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory indicates the product specified by the **hb set** command during compilation. In this example, **ipcamera\_hispark\_taurus** is the product specified.
>- **$\(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a\)** specifies the path of the unwind library. >- **$\(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a\)** specifies the path of the unwind library.
## Debugging Information<a name="section1017419992515"></a> ## Debugging Information<a name="section1017419992515"></a>
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
HiLog is the log system of OpenHarmony that provides logging for the system framework, services, and applications to record information on user operations and system running status. HiLog is the log system of OpenHarmony that provides logging for the system framework, services, and applications to record information on user operations and system running status.
This development guide is applicable to Standard-System Devices \(reference memory ≥ 128 MB\). This development guide is applicable to standard-system devices \(reference memory ≥ 128 MB\).
## Available APIs<a name="section6748124155012"></a> ## Available APIs<a name="section6748124155012"></a>
**Table 1** Description of C++ and C APIs **Table 1** List of C++ and C APIs
<a name="table94501354193619"></a> <a name="table94501354193619"></a>
<table><thead align="left"><tr id="row954285483614"><th class="cellrowborder" valign="top" width="18.258174182581744%" id="mcps1.2.4.1.1"><p id="p16542254203611"><a name="p16542254203611"></a><a name="p16542254203611"></a><strong id="b17542185414366"><a name="b17542185414366"></a><a name="b17542185414366"></a>C++</strong></p> <table><thead align="left"><tr id="row954285483614"><th class="cellrowborder" valign="top" width="18.258174182581744%" id="mcps1.2.4.1.1"><p id="p16542254203611"><a name="p16542254203611"></a><a name="p16542254203611"></a><strong id="b17542185414366"><a name="b17542185414366"></a><a name="b17542185414366"></a>C++</strong></p>
......
# Overview # OpenHarmony Documentation
This project stores OpenHarmony documentation, including the quick start guide, development guides, and API reference. We appreciate your contribution to the OpenHarmony documentation. This repository stores a complete range of OpenHarmony documentation. The content outline is as follows:
## Contents - OpenHarmony Development
- [Device Development](device-dev/Readme-EN.md)
- [OpenHarmony Overview](OpenHarmony-Overview.md) - [Application Development](application-dev/Readme-EN.md)
- Device development - [Release Notes](release-notes/Readme.md)
- Mini and Small System Development Guidelines \(Reference Memory < 128 MB\) - [Subsystems](./readme)
- Device development - OpenHarmony Contribution
- **overview**: [Device Development Overview](device-dev/Readme-EN.md) - [How to Contribute](contribute/contribution.md)
- **quick-start**: [Quick Start](device-dev/quick-start/Readme-EN.md) \(covering environment setup, source code acquisition, build, and burning\) - [OpenHarmony Part and API Design Reference](./design)
- Basic development capabilities
- **Kernel**: [Kernel for Mini Systems](device-dev/kernel/kernel-mini.md)
- **Kernel:**[Kernel for Small Systems](device-dev/kernel/kernel-small.md)
- **Drivers**: [drivers](device-dev/driver/Readme-EN.md)
- **Subsystems**: [subsystems](device-dev/subsystems/Readme-EN.md) \(such as compilation and building, graphics, DFX, and XTS\)
- **Security**: [privacy and security](device-dev/security/Readme-EN.md)
- **guide**:
- [WLAN-connected Products](device-dev/guide/device-wlan.md) \(LED peripheral control and third-party SDK integration\)
- [Screenless Cameras](device-dev/guide/device-iotcamera-control.md) \(camera control\)
- [Cameras with a Screen](device-dev/guide/device-camera.md) \(screen and camera control, visual application development\)
- **porting**:
- [Third-Party Library Porting Guide for Mini and Small Systems](device-dev/porting/porting-thirdparty.md)
- [Mini System SoC Porting Guide](device-dev/porting/porting-minichip.md)
- [Small System SoC Porting Guide](device-dev/porting/porting-smallchip.md)
- **bundles**:
- [HPM Bundle Development Specifications](device-dev/bundles/bundles-standard-rules.md)
- [HPM Bundle Development Guidelines](device-dev/bundles/bundles-guide.md)
- [HPM User Guide](device-dev/bundles/bundles-demo.md)
- Standard System Development Guidelines \(Reference Memory ≥ 128 MB\)
- Device development
- **overview**: [Device Development Overview](device-dev/Readme-EN.md)
- **quick-start**: [Quick Start](device-dev/quick-start/quickstart-standard.md) \(covering environment setup, source code acquisition, build, and burning\)
- Basic development capabilities
- **Kernel**: [Kernel for the Standard System](device-dev/kernel/kernel-standard.md)
- **Drivers**: [Drivers](device-dev/driver/Readme-EN.md)
- **Subsystems**: [Subsystems](device-dev/subsystems/Readme-EN.md) \(such as compilation and building, graphics, DFX, and XTS\)
- **Security**: [Privacy and Security](device-dev/security/Readme-EN.md)
- **guide**:
- [Development Guidelines on Clock Apps](device-dev/guide/device-clock-guide.md)
- [Development Example for Platform Drivers](device-dev/guide/device-driver-demo.md)
- [Development Example for Peripheral Drivers](device-dev/guide/device-outerdriver-demo.md)
- **porting**:
- [Standard System SoC Porting Guide](device-dev/porting/standard-system-porting-guide.md)
- [A Method for Rapidly Porting the OpenHarmony Linux Kernel ](device-dev/porting/porting-linux-kernel.md)
- **bundles**:
- [HPM Bundle Development Specifications](device-dev/bundles/bundles-standard-rules.md)
- [HPM Bundle Development Guidelines](device-dev/bundles/bundles-guide.md)
- [HPM User Guide](device-dev/bundles/bundles-demo.md)
- [FAQs](device-dev/faqs/Readme-EN.md)
- App development
- **Overview**: [Application Development Overview](application-dev/application-dev-guide.md)
- **quick-start**: [Quick Start](application-dev/quick-start/Readme-EN.md)
- **ui**: [UI](application-dev/ui/Readme-EN.md)
- **media**: [Media](application-dev/media/Readme-EN.md)
- **security**: [Security](application-dev/security/Readme-EN.md)
- **connectivity**: [Connectivity](application-dev/connectivity/Readme-EN.md)
- **Database**[Data Management](application-dev/database/Readme-CN.md)
- **usb**: [USB Service](application-dev//usb/Readme-EN.md)
- **dfx**: [DFX](application-dev/dfx/Readme-EN.md)
- **reference**: [Development References](application-dev/reference/Readme-EN.md)
- **glossary**: [Glossary](device-dev/glossary/glossary.md)
## Version Change History
For details, see [OpenHarmony Release Notes](release-notes/Readme.md).
## Third-Party Open-Source Software and License Notice
3rd-Party-License: [Third-Party Open-Source Software and License Notice](contribute/third-party-open-source-software-and-license-notice.md)
## How to Contribute
A great open-source project wouldn't be possible without the hard work of many contributors. We'd like to invite anyone from around the world to [participate](contribute/contribution.md) in this exciting journey, and we're grateful for your time, passion, and efforts!
You can evaluate available documents, make simple modifications, provide feedback on document quality, and contribute your original content. For details, see [Documentation Contribution](contribute/documentation-contribution.md).
Excellent contributors will be awarded and the contributions will be publicized in the developer community.
...@@ -408,20 +408,20 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI ...@@ -408,20 +408,20 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI
## Repositories Involved<a name="section10492183517430"></a> ## Repositories Involved<a name="section10492183517430"></a>
AI subsystem: [AI subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/ai.md)
ai\_engine [ai_engine](https://gitee.com/openharmony/ai_engine)
Dependency repositories: Dependency repositories:
build\_lite [build\_lite](https://gitee.com/openharmony/build_lite/blob/master/README.md)
distributedschedule\_services\_samgr\_lite [distributedschedule\_samgr\_lite](https://gitee.com/openharmony/distributedschedule_samgr_lite/blob/master/README.md)
startup\_init\_lite [startup\_init\_lite](https://gitee.com/openharmony/startup_init_lite/blob/master/README.md)
## Reference<a name="section6808423133718"></a> ## Reference<a name="section6808423133718"></a>
[AI Engine Framework Development Guide](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/development-examples.md) [AI Engine Framework Development Guide](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/subsys-aiframework-guide.md)
...@@ -424,6 +424,7 @@ ...@@ -424,6 +424,7 @@
- [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md)
- [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md)
- [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md)
- [Navigation](reference/arkui-ts/ts-basic-components-navigation.md)
- [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md)
- [PluginComponent](reference/arkui-ts/ts-basic-components-pluginComponent.md) - [PluginComponent](reference/arkui-ts/ts-basic-components-pluginComponent.md)
- [Progress](reference/arkui-ts/ts-basic-components-progress.md) - [Progress](reference/arkui-ts/ts-basic-components-progress.md)
...@@ -431,12 +432,13 @@ ...@@ -431,12 +432,13 @@
- [Radio](reference/arkui-ts/ts-basic-components-radio.md) - [Radio](reference/arkui-ts/ts-basic-components-radio.md)
- [Rating](reference/arkui-ts/ts-basic-components-rating.md) - [Rating](reference/arkui-ts/ts-basic-components-rating.md)
- [RichText](reference/arkui-ts/ts-basic-components-richtext.md) - [RichText](reference/arkui-ts/ts-basic-components-richtext.md)
- [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md)
- [Search](reference/arkui-ts/ts-basic-components-search.md) - [Search](reference/arkui-ts/ts-basic-components-search.md)
- [Select](reference/arkui-ts/ts-basic-components-select.md) - [Select](reference/arkui-ts/ts-basic-components-select.md)
- [Slider](reference/arkui-ts/ts-basic-components-slider.md) - [Slider](reference/arkui-ts/ts-basic-components-slider.md)
- [Span](reference/arkui-ts/ts-basic-components-span.md)
- [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md)
- [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md)
- [Span](reference/arkui-ts/ts-basic-components-span.md)
- [Text](reference/arkui-ts/ts-basic-components-text.md) - [Text](reference/arkui-ts/ts-basic-components-text.md)
- [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md)
- [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md)
...@@ -459,13 +461,13 @@ ...@@ -459,13 +461,13 @@
- [List](reference/arkui-ts/ts-container-list.md) - [List](reference/arkui-ts/ts-container-list.md)
- [ListItem](reference/arkui-ts/ts-container-listitem.md) - [ListItem](reference/arkui-ts/ts-container-listitem.md)
- [Navigator](reference/arkui-ts/ts-container-navigator.md) - [Navigator](reference/arkui-ts/ts-container-navigator.md)
- [Navigation](reference/arkui-ts/ts-basic-components-navigation.md)
- [Panel](reference/arkui-ts/ts-container-panel.md) - [Panel](reference/arkui-ts/ts-container-panel.md)
- [Refresh](reference/arkui-ts/ts-container-refresh.md) - [Refresh](reference/arkui-ts/ts-container-refresh.md)
- [Row](reference/arkui-ts/ts-container-row.md) - [Row](reference/arkui-ts/ts-container-row.md)
- [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md)
- [Scroll](reference/arkui-ts/ts-container-scroll.md) - [Scroll](reference/arkui-ts/ts-container-scroll.md)
- [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md)
- [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md)
- [Stack](reference/arkui-ts/ts-container-stack.md) - [Stack](reference/arkui-ts/ts-container-stack.md)
- [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Swiper](reference/arkui-ts/ts-container-swiper.md)
......
...@@ -8,6 +8,8 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 ...@@ -8,6 +8,8 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以
在进行应用开发的过程中,建议开发者通过on('stateChange')方法订阅AudioCapturer的状态变更。因为针对AudioCapturer的某些操作,仅在音频采集器在固定状态时才能执行。如果应用在音频采集器处于错误状态时执行操作,系统可能会抛出异常或生成其他未定义的行为。 在进行应用开发的过程中,建议开发者通过on('stateChange')方法订阅AudioCapturer的状态变更。因为针对AudioCapturer的某些操作,仅在音频采集器在固定状态时才能执行。如果应用在音频采集器处于错误状态时执行操作,系统可能会抛出异常或生成其他未定义的行为。
详细API含义可参考:[音频管理API文档AudioCapturer](../reference/apis/js-apis-audio.md)
## 开发步骤 ## 开发步骤
1. 使用createAudioCapturer()创建一个AudioCapturer实例。 1. 使用createAudioCapturer()创建一个AudioCapturer实例。
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
## 开发步骤 ## 开发步骤
详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) 详细API含义可参考:[媒体服务API文档AudioPlayer](../reference/apis/js-apis-media.md)
### 全流程场景 ### 全流程场景
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
## 开发步骤 ## 开发步骤
详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) 详细API含义可参考:[媒体服务API文档AudioRecorder](../reference/apis/js-apis-media.md)
### 全流程场景 ### 全流程场景
......
...@@ -16,7 +16,7 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可 ...@@ -16,7 +16,7 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
### 异步操作 ### 异步操作
为保证UI线程不被阻塞,大部分AudioRenderer调用都是异步的。对于每个API均提供了callback函数和Promise函数,以下示例均采用Promise函数,更多方式可参考[js-apis-audio](../reference/apis/js-apis-audio.md#audiorenderer8) 为保证UI线程不被阻塞,大部分AudioRenderer调用都是异步的。对于每个API均提供了callback函数和Promise函数,以下示例均采用Promise函数,更多方式可参考[音频管理API文档AudioRenderer](../reference/apis/js-apis-audio.md#audiorenderer8)
## 开发步骤 ## 开发步骤
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## 接口说明 ## 接口说明
详细API含义请参考[js-apis-image.md](../reference/apis/js-apis-image.md) 详细API含义请参考[图片处理API文档](../reference/apis/js-apis-image.md)
## 开发步骤 ## 开发步骤
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
## 开发步骤 ## 开发步骤
详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) 详细API含义可参考:[媒体服务API文档VideoPlayer](../reference/apis/js-apis-media.md)
### 全流程场景 ### 全流程场景
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
## 开发步骤 ## 开发步骤
详细API含义可参考:[js-apis-media.md](../reference/apis/js-apis-media.md) 详细API含义可参考:[媒体服务API文档VideoRecorder](../reference/apis/js-apis-media.md)
### 全流程场景 ### 全流程场景
......
# SysCap使用指南
## 概述
### 系统能力与 API
SysCap,全称SystemCapability,即系统能力,指操作系统中每一个相对独立的特性,如蓝牙,WIFI,NFC,摄像头等,都是系统能力之一。每个系统能力对应多个 API,这些 API 绑定在一起,随着目标设备是否支持该系统能力共同存在或消失,也会随着 IDE 一起提供给开发者做联想。
![image-20220326064841782](figures/image-20220326064841782.png)
### 支持能力集,联想能力集与要求能力集
支持能力集,联想能力集与要求能力集都是系统能力的集合。
支持能力集描述的是设备能力,要求能力集描述的是应用能力。若应用A的要求能力集是设备N的支持能力集的子集,则应用A可分发到设备N上安装运行,否则不能分发。
联想能力集是该应用开发时,IDE 可联想的 API 所在的系统能力集合。
![image-20220326064913834](figures/image-20220326064913834.png)
### 设备与支持能力集
每个设备根据其硬件能力,对应不同的支持能力集。
SDK 将设备分为两组,爆款设备和自定义设备,爆款设备的支持能力集由 OpenHarmony 来定义,自定义设备由设备厂商给出。
![image-20220326064955505](figures/image-20220326064955505.png)
### 设备与SDK能力的对应
SDK 提供全量的 API 给 IDE,IDE 通过开发者的项目支持的设备,找到该设备的支持能力集,筛选支持能力集包含的 API 提供给开发者做联想。
![image-20220326065043006](figures/image-20220326065043006.png)
## SysCap开发指导
### PCID导入
DevEco Studio 工程支持 PCID 的导入。导入的 PCID 文件解码后输出的 syscap 会被写入 syscap.json 文件中。
在工程目录右键后选择 Import Product Compatibility ID,即可上传 PCID 文件并导入至 syscap.json 中。
![20220329-103626](figures/20220329-103626.gif)
### 配置联想能力集和要求能力集
IDE 会根据创建的工程所支持的设置自动配置联想能力集和要求能力集,开发者也可以自行修改。
对于联想能力集,开发者通过添加更多的系统能力,在 IDE 中可以使用更多的 API,但要注意这些 API 可能在设备上不支持,使用前需要判断。
对于要求能力集,开发者修改时要十分慎重,修改不当会导致应用无法分发到目标设备上。
```
/* syscap.json */
{
devices: {
general: [ /*每一个爆款设备对应一个syscap支持能力集,可配置多个爆款设备*/
“phone”,
"car,
"pc",
...
],
custom: [ /*厂家自定义设备*/
{
"某自定义设备": [
"SystemCapability.Communication.SoftBus.Core",
...
]
},
...
]
},
development: { /*addedSysCaps内的sycap集合与devices中配置的各设备支持的syscap集合的并集共同构成联想能力集*/
addedSysCaps: [
"SystemCapability.Location.Location.Lite",
...
]
},
production: { /*用于生成rpcid,慎重添加,可能导致应用无法分发到目标设备上*/
addedSysCaps: [], //devices中配置的各设备支持的syscap集合的交集,添加addedSysCaps集合再除去removedSysCaps集合,共同构成要求能力集
removedSysCaps: [] //当该要求能力集为某设备的子集时,应用才可被分发到该设备上
}
}
```
### 单设备应用开发
默认应用的联想能力集、要求系统能力集和设备的支持系统能力集相等,开发者修改要求能力集需要慎重。
![image-20220326065124911](figures/image-20220326065124911.png)
### 跨设备应用开发
默认应用的联想能力集是多个设备支持能力集的并集,要求能力集则是交集。
![image-20220326065201867](figures/image-20220326065201867.png)
### 判断 API 是否可以使用
首先我们定义了 API canIUse 帮助开发者来判断该工程是否支持某个特定的syscap。
```
if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) {
console.log("该应用支持SystemCapability.ArkUI.ArkUI.Full");
} else {
console.log("该应用不支持SystemCapability.ArkUI.ArkUI.Full");
}
```
开发者可通过 import 的方式将模块导入,若当前设备不支持该模块,import 的结果为 undefined,开发者在使用其 API 时,需要判断其是否存在。
```
import geolocation from '@ohos.geolocation';
if (geolocation) {
geolocation.getCurrentLocation((location) => {
console.log(location.latitude, location.longitude);
});
} else {
console.log('该设备不支持位置信息');
}
```
### 不同设备相同能力的差异检查
即使是相同的系统能力,在不同的设备下,也会有能力的差异。比如同是摄像头的能力,手机比手表要强很多。
```
import userAuth from '@ohos.userIAM.userAuth';
const authenticator = userAuth.getAuthenticator();
const result = authenticator.checkAbility('FACE_ONLY', 'S1');
if (result == authenticator.CheckAvailabilityResult.AUTH_NOT_SUPPORT) {
console.log('该设备不支持人脸识别');
}
//强行调用不支持的 API 会返回错误信息,但不会出现语法错误。
authenticator.execute('FACE_ONLY', 'S1', (err, result) => {
if (err) {
console.log(err.message);
return;
}
})
```
### 设备间的SysCap差异如何产生的
设备的SysCap因产品解决方案厂商拼装的部件组合不同而不同,整体流程如下图:
![image-20220326072448840](figures/image-20220326072448840.png)
1、一套 OpenHarmony 源码由可选和必选部件集组成,不同的部件为对外体现的系统能力不同,即部件与 SysCap 之间映射关系。
2、发布归一化的 SDK,API 与 SysCap 之间存在映射关系。
3、产品解决方案厂商按硬件能力和产品诉求,可按需拼装部件。
4、产品配置的部件可以是 OpenHarmony 的部件,也可以是三方开发的私有部件,由于部件与SysCap间存在映射,所有拼装后即可得到该产品的SysCap集合。
5、SysCap集编码生成 PCID (Product Compatibility ID, 产品兼容性标识),应用开发者可将 PCID 导入 IDE解码成SysCap ,开发时对设备的SysCap差异做兼容性处理。
6、部署到设备上的系统参数中包含了 SysCap 集,系统提供了native的接口和应用接口,可供系统内的部件和应用查询某个 SysCap 是否存在。
7、应用开发过程中,应用必要的 SysCap 将被编码成 RPCID(Required Product Compatibility ID),并写入应用安装包中。应用安装时,包管理器将解码 RPCID 得到应用需要的 SysCap,与设备当前具备的 SysCap 比较,若应用要求的 SysCap 都被满足,则安装成功。
8、应用运行时,可通过 canIUse 接口查询设备的 SysCap,保证在不同设备上的兼容性。
...@@ -27,9 +27,9 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback&lt;KVManager&gt ...@@ -27,9 +27,9 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback&lt;KVManager&gt
| callback | AsyncCallback&lt;[KVManager](#kvmanager)&gt; | 是 | KVManager实例创建时调用的回调,返回KVManager对象实例。 | | callback | AsyncCallback&lt;[KVManager](#kvmanager)&gt; | 是 | KVManager实例创建时调用的回调,返回KVManager对象实例。 |
**示例** **示例**
``` ```
let kvManager; let kvManager;
try { try {
const kvManagerConfig = { const kvManagerConfig = {
bundleName : 'com.example.datamanagertest', bundleName : 'com.example.datamanagertest',
userInfo : { userInfo : {
...@@ -45,10 +45,10 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback&lt;KVManager&gt ...@@ -45,10 +45,10 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback&lt;KVManager&gt
console.log("createKVManager success"); console.log("createKVManager success");
kvManager = manager; kvManager = manager;
}); });
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
## distributedData.createKVManager ## distributedData.createKVManager
...@@ -71,9 +71,10 @@ createKVManager(config: KVManagerConfig): Promise&lt;KVManager&gt; ...@@ -71,9 +71,10 @@ createKVManager(config: KVManagerConfig): Promise&lt;KVManager&gt;
| Promise&lt;[KVManager](#kvmanager)&gt; | 指定的Promise回调方法,返回创建的KVManager对象实例。 | | Promise&lt;[KVManager](#kvmanager)&gt; | 指定的Promise回调方法,返回创建的KVManager对象实例。 |
**示例** **示例**
```
let kvManager; ```
try { let kvManager;
try {
const kvManagerConfig = { const kvManagerConfig = {
bundleName : 'com.example.datamanagertest', bundleName : 'com.example.datamanagertest',
userInfo : { userInfo : {
...@@ -87,10 +88,10 @@ createKVManager(config: KVManagerConfig): Promise&lt;KVManager&gt; ...@@ -87,10 +88,10 @@ createKVManager(config: KVManagerConfig): Promise&lt;KVManager&gt;
}).catch((err) => { }).catch((err) => {
console.log("createKVManager err: " + JSON.stringify(err)); console.log("createKVManager err: " + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
## KVManagerConfig ## KVManagerConfig
...@@ -103,8 +104,6 @@ createKVManager(config: KVManagerConfig): Promise&lt;KVManager&gt; ...@@ -103,8 +104,6 @@ createKVManager(config: KVManagerConfig): Promise&lt;KVManager&gt;
| userInfo | [UserInfo](#userinfo) | 是 | 调用方的用户信息。 | | userInfo | [UserInfo](#userinfo) | 是 | 调用方的用户信息。 |
| bundleName | string | 是 | 调用方的包名。 | | bundleName | string | 是 | 调用方的包名。 |
## UserInfo ## UserInfo
用户信息。 用户信息。
...@@ -132,8 +131,6 @@ createKVManager(config: KVManagerConfig): Promise&lt;KVManager&gt; ...@@ -132,8 +131,6 @@ createKVManager(config: KVManagerConfig): Promise&lt;KVManager&gt;
数据管理实例,用于获取KVStore的相关信息。在调用KVManager的方法前,需要先通过createKVManager构建一个KVManager实例。 数据管理实例,用于获取KVStore的相关信息。在调用KVManager的方法前,需要先通过createKVManager构建一个KVManager实例。
### getKVStore ### getKVStore
getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options, callback: AsyncCallback&lt;T&gt;): void getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options, callback: AsyncCallback&lt;T&gt;): void
...@@ -152,10 +149,10 @@ getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options, callback: ...@@ -152,10 +149,10 @@ getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options, callback:
**示例** **示例**
``` ```
let kvStore; let kvStore;
let kvManager; let kvManager;
try { try {
const options = { const options = {
createIfMissing : true, createIfMissing : true,
encrypt : false, encrypt : false,
...@@ -172,10 +169,10 @@ getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options, callback: ...@@ -172,10 +169,10 @@ getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options, callback:
console.log("getKVStore success"); console.log("getKVStore success");
kvStore = store; kvStore = store;
}); });
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
### getKVStore ### getKVStore
...@@ -200,13 +197,12 @@ getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options): Promise& ...@@ -200,13 +197,12 @@ getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options): Promise&
| -------------------------------------- | ------------------------ | | -------------------------------------- | ------------------------ |
| Promise&lt;T&gt; &lt;T extends KVStore&gt; | 指定的Promise回调方法,返回创建的KVStore数据库实例。 | | Promise&lt;T&gt; &lt;T extends KVStore&gt; | 指定的Promise回调方法,返回创建的KVStore数据库实例。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
let kvManager; let kvManager;
try { try {
const options = { const options = {
createIfMissing : true, createIfMissing : true,
encrypt : false, encrypt : false,
...@@ -221,10 +217,10 @@ getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options): Promise& ...@@ -221,10 +217,10 @@ getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options): Promise&
}).catch((err) => { }).catch((err) => {
console.log("getKVStore err: " + JSON.stringify(err)); console.log("getKVStore err: " + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
### closeKVStore<sup>8+</sup> ### ### closeKVStore<sup>8+</sup> ###
...@@ -244,13 +240,12 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa ...@@ -244,13 +240,12 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa
| kvStore | [KVStore](#kvstore) | 是 | 要关闭的KvStore数据库。 | | kvStore | [KVStore](#kvstore) | 是 | 要关闭的KvStore数据库。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,如果数据库关闭成功则返回true,否则返回false。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,如果数据库关闭成功则返回true,否则返回false。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
let kvManager; let kvManager;
const options = { const options = {
createIfMissing : true, createIfMissing : true,
encrypt : false, encrypt : false,
backup : false, backup : false,
...@@ -267,10 +262,11 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa ...@@ -267,10 +262,11 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa
console.log('closeKVStore success'); console.log('closeKVStore success');
}); });
}); });
} catch (e) { } catch (e) {
console.log('closeKVStore e ' + e); console.log('closeKVStore e ' + e);
} }
``` ```
### closeKVStore<sup>8+</sup> ### ### closeKVStore<sup>8+</sup> ###
...@@ -296,10 +292,10 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise&lt;void& ...@@ -296,10 +292,10 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise&lt;void&
**示例** **示例**
``` ```
let kvManager; let kvManager;
let kvStore; let kvStore;
const options = { const options = {
createIfMissing : true, createIfMissing : true,
encrypt : false, encrypt : false,
backup : false, backup : false,
...@@ -307,7 +303,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise&lt;void& ...@@ -307,7 +303,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise&lt;void&
kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, kvStoreType : distributedData.KVStoreType.SINGLE_VERSION,
schema : '', schema : '',
securityLevel : distributedData.SecurityLevel.S2, securityLevel : distributedData.SecurityLevel.S2,
} }
try { try {
kvManager.getKVStore('storeId', options).then(async (store) => { kvManager.getKVStore('storeId', options).then(async (store) => {
console.log('getKVStore success'); console.log('getKVStore success');
...@@ -322,8 +318,8 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise&lt;void& ...@@ -322,8 +318,8 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise&lt;void&
}); });
} catch (e) { } catch (e) {
console.log('closeKVStore e ' + e); console.log('closeKVStore e ' + e);
} }
``` ```
### deleteKVStore<sup>8+</sup> ### ### deleteKVStore<sup>8+</sup> ###
...@@ -342,13 +338,12 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback&lt;void&gt ...@@ -342,13 +338,12 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback&lt;void&gt
| storeId | string | 是 | 要删除的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | | storeId | string | 是 | 要删除的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,如果成功返回true,否则返回false。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,如果成功返回true,否则返回false。 |
**示例** **示例**
``` ```
let kvManager; let kvManager;
let kvStore; let kvStore;
const options = { const options = {
createIfMissing : true, createIfMissing : true,
encrypt : false, encrypt : false,
backup : false, backup : false,
...@@ -356,8 +351,8 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback&lt;void&gt ...@@ -356,8 +351,8 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback&lt;void&gt
kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, kvStoreType : distributedData.KVStoreType.SINGLE_VERSION,
schema : '', schema : '',
securityLevel : distributedData.SecurityLevel.S2, securityLevel : distributedData.SecurityLevel.S2,
} }
try { try {
kvManager.getKVStore('store', options, async function (err, store) { kvManager.getKVStore('store', options, async function (err, store) {
console.log('getKVStore success'); console.log('getKVStore success');
kvStore = store; kvStore = store;
...@@ -365,10 +360,10 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback&lt;void&gt ...@@ -365,10 +360,10 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback&lt;void&gt
console.log('deleteKVStore success'); console.log('deleteKVStore success');
}); });
}); });
} catch (e) { } catch (e) {
console.log('DeleteKVStore e ' + e); console.log('DeleteKVStore e ' + e);
} }
``` ```
### deleteKVStore<sup>8+</sup> ### ### deleteKVStore<sup>8+</sup> ###
...@@ -394,10 +389,10 @@ deleteKVStore(appId: string, storeId: string): Promise&lt;void&gt; ...@@ -394,10 +389,10 @@ deleteKVStore(appId: string, storeId: string): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvManager; let kvManager;
let kvStore; let kvStore;
const options = { const options = {
createIfMissing : true, createIfMissing : true,
encrypt : false, encrypt : false,
backup : false, backup : false,
...@@ -405,8 +400,8 @@ deleteKVStore(appId: string, storeId: string): Promise&lt;void&gt; ...@@ -405,8 +400,8 @@ deleteKVStore(appId: string, storeId: string): Promise&lt;void&gt;
kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, kvStoreType : distributedData.KVStoreType.SINGLE_VERSION,
schema : '', schema : '',
securityLevel : distributedData.SecurityLevel.S2, securityLevel : distributedData.SecurityLevel.S2,
} }
try { try {
kvManager.getKVStore('storId', options).then(async (store) => { kvManager.getKVStore('storId', options).then(async (store) => {
console.log('getKVStore success'); console.log('getKVStore success');
kvStore = store; kvStore = store;
...@@ -418,10 +413,10 @@ deleteKVStore(appId: string, storeId: string): Promise&lt;void&gt; ...@@ -418,10 +413,10 @@ deleteKVStore(appId: string, storeId: string): Promise&lt;void&gt;
}).catch((err) => { }).catch((err) => {
console.log('getKVStore err ' + JSON.stringify(err)); console.log('getKVStore err ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
console.log('deleteKVStore e ' + e); console.log('deleteKVStore e ' + e);
} }
``` ```
### getAllKVStoreId<sup>8+</sup> ### ### getAllKVStoreId<sup>8+</sup> ###
...@@ -441,17 +436,17 @@ getAllKVStoreId(appId: string, callback: AsyncCallback&lt;string[]&gt;): void ...@@ -441,17 +436,17 @@ getAllKVStoreId(appId: string, callback: AsyncCallback&lt;string[]&gt;): void
**示例** **示例**
``` ```
let kvManager; let kvManager;
try { try {
kvManager.getAllKVStoreId('appId', function (err, data) { kvManager.getAllKVStoreId('appId', function (err, data) {
console.log('GetAllKVStoreId success'); console.log('GetAllKVStoreId success');
console.log('GetAllKVStoreId size = ' + data.length); console.log('GetAllKVStoreId size = ' + data.length);
}); });
} catch (e) { } catch (e) {
console.log('GetAllKVStoreId e ' + e); console.log('GetAllKVStoreId e ' + e);
} }
``` ```
### getAllKVStoreId<sup>8+</sup> ### ### getAllKVStoreId<sup>8+</sup> ###
...@@ -477,9 +472,9 @@ getAllKVStoreId(appId: string): Promise&lt;string[]&gt; ...@@ -477,9 +472,9 @@ getAllKVStoreId(appId: string): Promise&lt;string[]&gt;
**示例** **示例**
``` ```
let kvManager; let kvManager;
try { try {
console.log('GetAllKVStoreId'); console.log('GetAllKVStoreId');
kvManager.getAllKVStoreId('apppId').then((data) => { kvManager.getAllKVStoreId('apppId').then((data) => {
console.log('getAllKVStoreId success'); console.log('getAllKVStoreId success');
...@@ -487,10 +482,10 @@ getAllKVStoreId(appId: string): Promise&lt;string[]&gt; ...@@ -487,10 +482,10 @@ getAllKVStoreId(appId: string): Promise&lt;string[]&gt;
}).catch((err) => { }).catch((err) => {
console.log('getAllKVStoreId err ' + JSON.stringify(err)); console.log('getAllKVStoreId err ' + JSON.stringify(err));
}); });
} catch(e) { } catch(e) {
console.log('getAllKVStoreId e ' + e); console.log('getAllKVStoreId e ' + e);
} }
``` ```
### on<sup>8+</sup> ### ### on<sup>8+</sup> ###
...@@ -508,23 +503,21 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback&lt;void&gt;): voi ...@@ -508,23 +503,21 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback&lt;void&gt;): voi
| event | 'distributedDataServiceDie' | 是 | 服务状态改变时触发的事件名。 | | event | 'distributedDataServiceDie' | 是 | 服务状态改变时触发的事件名。 |
| deathCallback | Callback&lt;void&gt; | 是 | 回调函数,在设备状态改变时获取通知。 | | deathCallback | Callback&lt;void&gt; | 是 | 回调函数,在设备状态改变时获取通知。 |
**示例** **示例**
``` ```
let kvManager; let kvManager;
try { try {
console.log('KVManagerOn'); console.log('KVManagerOn');
const deathCallback = function () { const deathCallback = function () {
console.log('death callback call'); console.log('death callback call');
} }
kvManager.on('distributedDataServiceDie', deathCallback); kvManager.on('distributedDataServiceDie', deathCallback);
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
### off<sup>8+</sup> ### ### off<sup>8+</sup> ###
...@@ -545,19 +538,19 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback&lt;void&gt;): v ...@@ -545,19 +538,19 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback&lt;void&gt;): v
**示例** **示例**
``` ```
let kvManager; let kvManager;
try { try {
console.log('KVManagerOff'); console.log('KVManagerOff');
const deathCallback = function () { const deathCallback = function () {
console.log('death callback call'); console.log('death callback call');
} }
kvManager.off('distributedDataServiceDie', deathCallback); kvManager.off('distributedDataServiceDie', deathCallback);
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
## Options ## Options
...@@ -589,7 +582,6 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback&lt;void&gt;): v ...@@ -589,7 +582,6 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback&lt;void&gt;): v
| MULTI_VERSION | 2 | 表示多版本数据库。此类型当前不允许使用。 | | MULTI_VERSION | 2 | 表示多版本数据库。此类型当前不允许使用。 |
## SecurityLevel ## SecurityLevel
用于指定创建的数据库的安全级别。 用于指定创建的数据库的安全级别。
...@@ -630,7 +622,7 @@ KVStore常量。 ...@@ -630,7 +622,7 @@ KVStore常量。
| 名称 | 类型 | 说明 | | 名称 | 类型 | 说明 |
| --- | ---- | ----------------------- | | --- | ---- | ----------------------- |
| root<sup>8+</sup> | [FieldNode](#fieldnode8) | 表示json根对象 | | root<sup>8+</sup> | [FieldNode](#fieldnode8) | 表示json根对象 |
| indexes<sup>8+</sup> | Array<string> | 表示json类型的字符串数组。 | | indexes<sup>8+</sup> | Array\<string> | 表示json类型的字符串数组。 |
| mode<sup>8+</sup> | number | 表示Schema的模式。 | | mode<sup>8+</sup> | number | 表示Schema的模式。 |
| skip<sup>8+</sup> | number | Schema的跳跃大小。 | | skip<sup>8+</sup> | number | Schema的跳跃大小。 |
...@@ -691,9 +683,9 @@ appendChild(child: FieldNode): boolean ...@@ -691,9 +683,9 @@ appendChild(child: FieldNode): boolean
**示例** **示例**
``` ```
import ddm from '@ohos.data.distributedData'; import ddm from '@ohos.data.distributedData';
try { try {
let node = new ddm.FieldNode("root"); let node = new ddm.FieldNode("root");
let child1 = new ddm.FieldNode("child1"); let child1 = new ddm.FieldNode("child1");
let child2 = new ddm.FieldNode("child2"); let child2 = new ddm.FieldNode("child2");
...@@ -706,12 +698,10 @@ appendChild(child: FieldNode): boolean ...@@ -706,12 +698,10 @@ appendChild(child: FieldNode): boolean
child2 = null; child2 = null;
child3 = null; child3 = null;
node = null; node = null;
} catch (e) { } catch (e) {
console.log("AppendChild " + e); console.log("AppendChild " + e);
} }
``` ```
## KvStoreResultSet<sup>8+</sup> ## ## KvStoreResultSet<sup>8+</sup> ##
...@@ -735,9 +725,9 @@ getCount(): number ...@@ -735,9 +725,9 @@ getCount(): number
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -747,11 +737,10 @@ getCount(): number ...@@ -747,11 +737,10 @@ getCount(): number
}); });
const count = resultSet.getCount(); const count = resultSet.getCount();
console.log("GetCount " + count); console.log("GetCount " + count);
} catch (e) { } catch (e) {
console.log("GetCount fail " + e); console.log("GetCount fail " + e);
} }
``` ```
### getPosition<sup>8+</sup> ### ### getPosition<sup>8+</sup> ###
...@@ -769,9 +758,9 @@ getPosition(): number ...@@ -769,9 +758,9 @@ getPosition(): number
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -781,10 +770,10 @@ getPosition(): number ...@@ -781,10 +770,10 @@ getPosition(): number
}); });
const position = resultSet.getPosition(); const position = resultSet.getPosition();
console.log("getPosition " + position); console.log("getPosition " + position);
} catch (e) { } catch (e) {
console.log("GetPosition fail " + e); console.log("GetPosition fail " + e);
} }
``` ```
### moveToFirst<sup>8+</sup> ### ### moveToFirst<sup>8+</sup> ###
...@@ -803,9 +792,9 @@ moveToFirst(): boolean ...@@ -803,9 +792,9 @@ moveToFirst(): boolean
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -815,10 +804,10 @@ moveToFirst(): boolean ...@@ -815,10 +804,10 @@ moveToFirst(): boolean
}); });
const moved = resultSet.moveToFirst(); const moved = resultSet.moveToFirst();
console.log("moveToFirst " + moved); console.log("moveToFirst " + moved);
} catch (e) { } catch (e) {
console.log("MoveToFirst fail " + e); console.log("MoveToFirst fail " + e);
} }
``` ```
### moveToLast<sup>8+</sup> ### ### moveToLast<sup>8+</sup> ###
...@@ -837,9 +826,9 @@ moveToLast(): boolean ...@@ -837,9 +826,9 @@ moveToLast(): boolean
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -849,10 +838,10 @@ moveToLast(): boolean ...@@ -849,10 +838,10 @@ moveToLast(): boolean
}); });
const moved = resultSet.moveToLast(); const moved = resultSet.moveToLast();
console.log("moveToLast " + moved); console.log("moveToLast " + moved);
} catch (e) { } catch (e) {
console.log("moveToLast fail " + e); console.log("moveToLast fail " + e);
} }
``` ```
### moveToNext<sup>8+</sup> ### ### moveToNext<sup>8+</sup> ###
...@@ -871,9 +860,9 @@ moveToNext(): boolean ...@@ -871,9 +860,9 @@ moveToNext(): boolean
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -883,10 +872,10 @@ moveToNext(): boolean ...@@ -883,10 +872,10 @@ moveToNext(): boolean
}); });
const moved = resultSet.moveToNext(); const moved = resultSet.moveToNext();
console.log("moveToNext " + moved); console.log("moveToNext " + moved);
} catch (e) { } catch (e) {
console.log("moveToNext fail " + e); console.log("moveToNext fail " + e);
} }
``` ```
### moveToPrevious<sup>8+</sup> ### ### moveToPrevious<sup>8+</sup> ###
...@@ -905,9 +894,9 @@ moveToPrevious(): boolean ...@@ -905,9 +894,9 @@ moveToPrevious(): boolean
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -917,10 +906,10 @@ moveToPrevious(): boolean ...@@ -917,10 +906,10 @@ moveToPrevious(): boolean
}); });
const moved = resultSet.moveToPrevious(); const moved = resultSet.moveToPrevious();
console.log("moveToPrevious " + moved); console.log("moveToPrevious " + moved);
} catch (e) { } catch (e) {
console.log("moveToPrevious fail " + e); console.log("moveToPrevious fail " + e);
} }
``` ```
### move<sup>8+</sup> ### ### move<sup>8+</sup> ###
...@@ -945,9 +934,9 @@ move(offset: number): boolean ...@@ -945,9 +934,9 @@ move(offset: number): boolean
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -957,10 +946,10 @@ move(offset: number): boolean ...@@ -957,10 +946,10 @@ move(offset: number): boolean
}); });
const moved = resultSet.move(); const moved = resultSet.move();
console.log("move " + moved); console.log("move " + moved);
} catch (e) { } catch (e) {
console.log("move fail " + e); console.log("move fail " + e);
} }
``` ```
### moveToPosition<sup>8+</sup> ### ### moveToPosition<sup>8+</sup> ###
...@@ -985,9 +974,9 @@ moveToPosition(position: number): boolean ...@@ -985,9 +974,9 @@ moveToPosition(position: number): boolean
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -997,10 +986,10 @@ moveToPosition(position: number): boolean ...@@ -997,10 +986,10 @@ moveToPosition(position: number): boolean
}); });
const moved = resultSet.moveToPosition(); const moved = resultSet.moveToPosition();
console.log("moveToPosition " + moved); console.log("moveToPosition " + moved);
} catch (e) { } catch (e) {
console.log("moveToPosition fail " + e); console.log("moveToPosition fail " + e);
} }
``` ```
### isFirst<sup>8+</sup> ### ### isFirst<sup>8+</sup> ###
...@@ -1019,9 +1008,9 @@ isFirst(): boolean ...@@ -1019,9 +1008,9 @@ isFirst(): boolean
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -1031,10 +1020,10 @@ isFirst(): boolean ...@@ -1031,10 +1020,10 @@ isFirst(): boolean
}); });
const moved = resultSet.isFirst(); const moved = resultSet.isFirst();
console.log("isFirst " + moved); console.log("isFirst " + moved);
} catch (e) { } catch (e) {
console.log("isFirst fail " + e); console.log("isFirst fail " + e);
} }
``` ```
### isLast<sup>8+</sup> ### ### isLast<sup>8+</sup> ###
...@@ -1053,9 +1042,9 @@ isLast(): boolean ...@@ -1053,9 +1042,9 @@ isLast(): boolean
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -1065,11 +1054,10 @@ isLast(): boolean ...@@ -1065,11 +1054,10 @@ isLast(): boolean
}); });
const moved = resultSet.isLast(); const moved = resultSet.isLast();
console.log("isLast " + moved); console.log("isLast " + moved);
} catch (e) { } catch (e) {
console.log("isLast fail " + e); console.log("isLast fail " + e);
} }
``` ```
### isBeforeFirst<sup>8+</sup> ### ### isBeforeFirst<sup>8+</sup> ###
...@@ -1087,9 +1075,9 @@ isBeforeFirst(): boolean ...@@ -1087,9 +1075,9 @@ isBeforeFirst(): boolean
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -1099,10 +1087,10 @@ isBeforeFirst(): boolean ...@@ -1099,10 +1087,10 @@ isBeforeFirst(): boolean
}); });
const moved = resultSet.isBeforeFirst(); const moved = resultSet.isBeforeFirst();
console.log("isBeforeFirst " + moved); console.log("isBeforeFirst " + moved);
} catch (e) { } catch (e) {
console.log("isBeforeFirst fail " + e); console.log("isBeforeFirst fail " + e);
} }
``` ```
### isAfterLast<sup>8+</sup> ### ### isAfterLast<sup>8+</sup> ###
...@@ -1121,9 +1109,9 @@ isAfterLast(): boolean ...@@ -1121,9 +1109,9 @@ isAfterLast(): boolean
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -1133,10 +1121,10 @@ isAfterLast(): boolean ...@@ -1133,10 +1121,10 @@ isAfterLast(): boolean
}); });
const moved = resultSet.isAfterLast(); const moved = resultSet.isAfterLast();
console.log("isAfterLast " + moved); console.log("isAfterLast " + moved);
} catch (e) { } catch (e) {
console.log("isAfterLast fail " + e); console.log("isAfterLast fail " + e);
} }
``` ```
### getEntry<sup>8+</sup> ### ### getEntry<sup>8+</sup> ###
...@@ -1155,9 +1143,9 @@ getEntry(): Entry ...@@ -1155,9 +1143,9 @@ getEntry(): Entry
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('batch_test_string_key').then((result) => { kvStore.getResultSet('batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -1168,10 +1156,10 @@ getEntry(): Entry ...@@ -1168,10 +1156,10 @@ getEntry(): Entry
const moved = resultSet.moveToNext(); const moved = resultSet.moveToNext();
const entry = resultSet.getEntry(); const entry = resultSet.getEntry();
console.log("getEntry " + JSON.stringify(entry)); console.log("getEntry " + JSON.stringify(entry));
} catch (e) { } catch (e) {
console.log("getEntry fail " + e); console.log("getEntry fail " + e);
} }
``` ```
## Query<sup>8+</sup> ## ## Query<sup>8+</sup> ##
...@@ -1206,18 +1194,18 @@ reset(): Query ...@@ -1206,18 +1194,18 @@ reset(): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.equalTo("key", "value"); query.equalTo("key", "value");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query.reset(); query.reset();
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("simply calls should be ok :" + e); console.log("simply calls should be ok :" + e);
} }
``` ```
### equalTo<sup>8+</sup> ### ### equalTo<sup>8+</sup> ###
...@@ -1243,16 +1231,16 @@ equalTo(field: string, value: number|string|boolean): Query; ...@@ -1243,16 +1231,16 @@ equalTo(field: string, value: number|string|boolean): Query;
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.equalTo("field", "value"); query.equalTo("field", "value");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### notEqualTo<sup>8+</sup> ### ### notEqualTo<sup>8+</sup> ###
...@@ -1278,16 +1266,16 @@ notEqualTo(field: string, value: number|string|boolean): Query ...@@ -1278,16 +1266,16 @@ notEqualTo(field: string, value: number|string|boolean): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.notEqualTo("field", "value"); query.notEqualTo("field", "value");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### greaterThan<sup>8+</sup> ### ### greaterThan<sup>8+</sup> ###
...@@ -1303,7 +1291,7 @@ greaterThan(field: string, value: number|string|boolean): Query ...@@ -1303,7 +1291,7 @@ greaterThan(field: string, value: number|string|boolean): Query
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 |
| value | number/string/boolean | 是 | 表示指定的值。| | value | number\|string\|boolean | 是 | 表示指定的值。|
**返回值** **返回值**
...@@ -1313,16 +1301,16 @@ greaterThan(field: string, value: number|string|boolean): Query ...@@ -1313,16 +1301,16 @@ greaterThan(field: string, value: number|string|boolean): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.greaterThan("field", "value"); query.greaterThan("field", "value");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### lessThan<sup>8+</sup> ### ### lessThan<sup>8+</sup> ###
...@@ -1338,7 +1326,7 @@ lessThan(field: string, value: number|string): Query ...@@ -1338,7 +1326,7 @@ lessThan(field: string, value: number|string): Query
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 |
| value | number/string/boolean | 是 | 表示指定的值。| | value | number\|string\|boolean | 是 | 表示指定的值。|
**返回值** **返回值**
...@@ -1348,16 +1336,16 @@ lessThan(field: string, value: number|string): Query ...@@ -1348,16 +1336,16 @@ lessThan(field: string, value: number|string): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.lessThan("field", "value"); query.lessThan("field", "value");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### greaterThanOrEqualTo<sup>8+</sup> ### ### greaterThanOrEqualTo<sup>8+</sup> ###
...@@ -1373,7 +1361,7 @@ greaterThanOrEqualTo(field: string, value: number|string): Query ...@@ -1373,7 +1361,7 @@ greaterThanOrEqualTo(field: string, value: number|string): Query
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 |
| value | number/string/boolean | 是 | 表示指定的值。| | value | number\|string\|boolean | 是 | 表示指定的值。|
**返回值** **返回值**
...@@ -1383,16 +1371,16 @@ greaterThanOrEqualTo(field: string, value: number|string): Query ...@@ -1383,16 +1371,16 @@ greaterThanOrEqualTo(field: string, value: number|string): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.greaterThanOrEqualTo("field", "value"); query.greaterThanOrEqualTo("field", "value");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### lessThanOrEqualTo<sup>8+</sup> ### ### lessThanOrEqualTo<sup>8+</sup> ###
...@@ -1408,7 +1396,7 @@ lessThanOrEqualTo(field: string, value: number|string): Query ...@@ -1408,7 +1396,7 @@ lessThanOrEqualTo(field: string, value: number|string): Query
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 |
| value | number/string/boolean | 是 | 表示指定的值。| | value | number\|string\|boolean | 是 | 表示指定的值。|
**返回值** **返回值**
...@@ -1418,16 +1406,16 @@ lessThanOrEqualTo(field: string, value: number|string): Query ...@@ -1418,16 +1406,16 @@ lessThanOrEqualTo(field: string, value: number|string): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.lessThanOrEqualTo("field", "value"); query.lessThanOrEqualTo("field", "value");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### isNull<sup>8+</sup> ### ### isNull<sup>8+</sup> ###
...@@ -1453,16 +1441,16 @@ isNull(field: string): Query ...@@ -1453,16 +1441,16 @@ isNull(field: string): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.isNull("field"); query.isNull("field");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### inNumber<sup>8+</sup> ### ### inNumber<sup>8+</sup> ###
...@@ -1487,19 +1475,18 @@ inNumber(field: string, valueList: number[]): Query ...@@ -1487,19 +1475,18 @@ inNumber(field: string, valueList: number[]): Query
| ------ | ------- | | ------ | ------- |
| [Query](#query8) |返回查询对象。| | [Query](#query8) |返回查询对象。|
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.inNumber("field", [0, 1]); query.inNumber("field", [0, 1]);
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### inString<sup>8+</sup> ### ### inString<sup>8+</sup> ###
...@@ -1525,16 +1512,16 @@ inString(field: string, valueList: string[]): Query ...@@ -1525,16 +1512,16 @@ inString(field: string, valueList: string[]): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.inString("field", ['test1', 'test2']); query.inString("field", ['test1', 'test2']);
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### notInNumber<sup>8+</sup> ### ### notInNumber<sup>8+</sup> ###
...@@ -1560,16 +1547,16 @@ notInNumber(field: string, valueList: number[]): Query ...@@ -1560,16 +1547,16 @@ notInNumber(field: string, valueList: number[]): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.notInNumber("field", [0, 1]); query.notInNumber("field", [0, 1]);
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### notInString<sup>8+</sup> ### ### notInString<sup>8+</sup> ###
...@@ -1595,16 +1582,16 @@ notInString(field: string, valueList: string[]): Query ...@@ -1595,16 +1582,16 @@ notInString(field: string, valueList: string[]): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.notInString("field", ['test1', 'test2']); query.notInString("field", ['test1', 'test2']);
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### like<sup>8+</sup> ### ### like<sup>8+</sup> ###
...@@ -1630,16 +1617,16 @@ like(field: string, value: string): Query ...@@ -1630,16 +1617,16 @@ like(field: string, value: string): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.like("field", "value"); query.like("field", "value");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### unlike<sup>8+</sup> ### ### unlike<sup>8+</sup> ###
...@@ -1665,16 +1652,16 @@ unlike(field: string, value: string): Query ...@@ -1665,16 +1652,16 @@ unlike(field: string, value: string): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.unlike("field", "value"); query.unlike("field", "value");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### and<sup>8+</sup> ### ### and<sup>8+</sup> ###
...@@ -1693,18 +1680,18 @@ and(): Query ...@@ -1693,18 +1680,18 @@ and(): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.notEqualTo("field", "value1"); query.notEqualTo("field", "value1");
query.and(); query.and();
query.notEqualTo("field", "value2"); query.notEqualTo("field", "value2");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### or<sup>8+</sup> ### ### or<sup>8+</sup> ###
...@@ -1723,18 +1710,18 @@ or(): Query ...@@ -1723,18 +1710,18 @@ or(): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.notEqualTo("field", "value1"); query.notEqualTo("field", "value1");
query.or(); query.or();
query.notEqualTo("field", "value2"); query.notEqualTo("field", "value2");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### orderByAsc<sup>8+</sup> ### ### orderByAsc<sup>8+</sup> ###
...@@ -1759,17 +1746,17 @@ orderByAsc(field: string): Query ...@@ -1759,17 +1746,17 @@ orderByAsc(field: string): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.notEqualTo("field", "value"); query.notEqualTo("field", "value");
query.orderByAsc("field"); query.orderByAsc("field");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### orderByDesc<sup>8+</sup> ### ### orderByDesc<sup>8+</sup> ###
...@@ -1792,20 +1779,19 @@ orderByDesc(field: string): Query ...@@ -1792,20 +1779,19 @@ orderByDesc(field: string): Query
| ------ | ------- | | ------ | ------- |
| [Query](#query8) |返回查询对象。| | [Query](#query8) |返回查询对象。|
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.notEqualTo("field", "value"); query.notEqualTo("field", "value");
query.orderByDesc("field"); query.orderByDesc("field");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### limit<sup>8+</sup> ### ### limit<sup>8+</sup> ###
...@@ -1831,17 +1817,17 @@ limit(total: number, offset: number): Query ...@@ -1831,17 +1817,17 @@ limit(total: number, offset: number): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.notEqualTo("field", "value"); query.notEqualTo("field", "value");
query.limit("total", "offset"); query.limit("total", "offset");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### isNotNull<sup>8+</sup> ### ### isNotNull<sup>8+</sup> ###
...@@ -1866,16 +1852,16 @@ isNotNull(field: string): Query ...@@ -1866,16 +1852,16 @@ isNotNull(field: string): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.isNotNull("field"); query.isNotNull("field");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### beginGroup<sup>8+</sup> ### ### beginGroup<sup>8+</sup> ###
...@@ -1894,18 +1880,18 @@ beginGroup(): Query ...@@ -1894,18 +1880,18 @@ beginGroup(): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.beginGroup(); query.beginGroup();
query.isNotNull("field"); query.isNotNull("field");
query.endGroup(); query.endGroup();
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### endGroup<sup>8+</sup> ### ### endGroup<sup>8+</sup> ###
...@@ -1924,18 +1910,18 @@ endGroup(): Query ...@@ -1924,18 +1910,18 @@ endGroup(): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.beginGroup(); query.beginGroup();
query.isNotNull("field"); query.isNotNull("field");
query.endGroup(); query.endGroup();
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### prefixKey<sup>8+</sup> ### ### prefixKey<sup>8+</sup> ###
...@@ -1960,17 +1946,17 @@ prefixKey(prefix: string): Query ...@@ -1960,17 +1946,17 @@ prefixKey(prefix: string): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.prefixKey("$.name"); query.prefixKey("$.name");
query.prefixKey("0"); query.prefixKey("0");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### setSuggestIndex<sup>8+</sup> ### ### setSuggestIndex<sup>8+</sup> ###
...@@ -1995,17 +1981,17 @@ setSuggestIndex(index: string): Query ...@@ -1995,17 +1981,17 @@ setSuggestIndex(index: string): Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.setSuggestIndex("$.name"); query.setSuggestIndex("$.name");
query.setSuggestIndex("0"); query.setSuggestIndex("0");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
query = null; query = null;
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok :" + e); console.log("dumplicated calls should be ok :" + e);
} }
``` ```
### deviceId<sup>8+</sup> ### ### deviceId<sup>8+</sup> ###
...@@ -2031,15 +2017,15 @@ deviceId(deviceId:string):Query ...@@ -2031,15 +2017,15 @@ deviceId(deviceId:string):Query
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
query.deviceId("deviceId"); query.deviceId("deviceId");
console.log("query is " + query.getSqlLike()); console.log("query is " + query.getSqlLike());
} catch (e) { } catch (e) {
console.log("should be ok on Method Chaining : " + e); console.log("should be ok on Method Chaining : " + e);
} }
``` ```
### getSqlLike<sup>8+</sup> ### ### getSqlLike<sup>8+</sup> ###
...@@ -2058,15 +2044,15 @@ getSqlLike():string ...@@ -2058,15 +2044,15 @@ getSqlLike():string
**示例** **示例**
``` ```
try { try {
let query = new distributedData.Query(); let query = new distributedData.Query();
let sql1 = query.getSqlLike(); let sql1 = query.getSqlLike();
console.log("GetSqlLike sql=" + sql1); console.log("GetSqlLike sql=" + sql1);
} catch (e) { } catch (e) {
console.log("dumplicated calls should be ok : " + e); console.log("dumplicated calls should be ok : " + e);
} }
``` ```
## KVStore ## KVStore
...@@ -2093,11 +2079,11 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC ...@@ -2093,11 +2079,11 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
if (err != undefined) { if (err != undefined) {
console.log("put err: " + JSON.stringify(err)); console.log("put err: " + JSON.stringify(err));
...@@ -2105,10 +2091,10 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC ...@@ -2105,10 +2091,10 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC
} }
console.log("put success"); console.log("put success");
}); });
}catch (e) { }catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
### put ### put
...@@ -2132,23 +2118,22 @@ put(key: string, value: Uint8Array | string | number | boolean): Promise&lt;void ...@@ -2132,23 +2118,22 @@ put(key: string, value: Uint8Array | string | number | boolean): Promise&lt;void
| ------ | ------- | | ------ | ------- |
| Promise&lt;void&gt; |Promise实例,用于异步处理。| | Promise&lt;void&gt; |Promise实例,用于异步处理。|
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => {
console.log("put success: " + JSON.stringify(data)); console.log("put success: " + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log("put err: " + JSON.stringify(err)); console.log("put err: " + JSON.stringify(err));
}); });
}catch (e) { }catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
### delete ### delete
...@@ -2168,11 +2153,11 @@ delete(key: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -2168,11 +2153,11 @@ delete(key: string, callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
if (err != undefined) { if (err != undefined) {
console.log("put err: " + JSON.stringify(err)); console.log("put err: " + JSON.stringify(err));
...@@ -2187,10 +2172,10 @@ delete(key: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -2187,10 +2172,10 @@ delete(key: string, callback: AsyncCallback&lt;void&gt;): void
console.log("delete success"); console.log("delete success");
}); });
}); });
}catch (e) { }catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
### delete ### delete
...@@ -2215,11 +2200,11 @@ delete(key: string): Promise&lt;void&gt; ...@@ -2215,11 +2200,11 @@ delete(key: string): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => {
console.log("put success: " + JSON.stringify(data)); console.log("put success: " + JSON.stringify(data));
kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => { kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => {
...@@ -2230,10 +2215,10 @@ delete(key: string): Promise&lt;void&gt; ...@@ -2230,10 +2215,10 @@ delete(key: string): Promise&lt;void&gt;
}).catch((err) => { }).catch((err) => {
console.log("put err: " + JSON.stringify(err)); console.log("put err: " + JSON.stringify(err));
}); });
}catch (e) { }catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
### on ### on
...@@ -2252,15 +2237,14 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback&lt;ChangeNotific ...@@ -2252,15 +2237,14 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback&lt;ChangeNotific
| type |[SubscribeType](#subscribetype) | 是 |表示订阅的类型。 | | type |[SubscribeType](#subscribetype) | 是 |表示订阅的类型。 |
| observer |Callback&lt;[ChangeNotification](#changenotification)&gt; | 是 |回调函数。 | | observer |Callback&lt;[ChangeNotification](#changenotification)&gt; | 是 |回调函数。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) { kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) {
console.log("dataChange callback call data: " + JSON.stringify(data)); console.log("dataChange callback call data: " + JSON.stringify(data));
}); });
``` ```
### on ### on
...@@ -2278,15 +2262,14 @@ on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt ...@@ -2278,15 +2262,14 @@ on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt
| event |'syncComplete' | 是 |回调函数名称。 | | event |'syncComplete' | 是 |回调函数名称。 |
| syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | 是 |回调函数。 | | syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | 是 |回调函数。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
kvStore.on('syncComplete', function (data) { kvStore.on('syncComplete', function (data) {
console.log("syncComplete callback call data: " + data); console.log("syncComplete callback call data: " + data);
}); });
``` ```
### off<sup>8+</sup> ### off<sup>8+</sup>
...@@ -2305,15 +2288,15 @@ off(event:'dataChange', observer?: Callback&lt;ChangeNotification&gt;): void ...@@ -2305,15 +2288,15 @@ off(event:'dataChange', observer?: Callback&lt;ChangeNotification&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
kvStore.on('dataChange', function (data) { kvStore.on('dataChange', function (data) {
console.log("syncComplete callback call data: " + data); console.log("syncComplete callback call data: " + data);
}); });
kvStore.off('dataChange', function (data) { kvStore.off('dataChange', function (data) {
console.log("syncComplete callback call data: " + data); console.log("syncComplete callback call data: " + data);
}); });
``` ```
### putBatch<sup>8+</sup> ### putBatch<sup>8+</sup>
...@@ -2333,9 +2316,9 @@ putBatch(entries: Entry[], callback: AsyncCallback&lt;void&gt;): void ...@@ -2333,9 +2316,9 @@ putBatch(entries: Entry[], callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -2357,11 +2340,10 @@ putBatch(entries: Entry[], callback: AsyncCallback&lt;void&gt;): void ...@@ -2357,11 +2340,10 @@ putBatch(entries: Entry[], callback: AsyncCallback&lt;void&gt;): void
console.log('entrys[0]: ' + JSON.stringify(entrys[0])); console.log('entrys[0]: ' + JSON.stringify(entrys[0]));
}); });
}); });
}catch(e) { }catch(e) {
console.log('PutBatch e ' + e); console.log('PutBatch e ' + e);
} }
```
```
### putBatch<sup>8+</sup> ### putBatch<sup>8+</sup>
...@@ -2386,9 +2368,9 @@ putBatch(entries: Entry[]): Promise&lt;void&gt; ...@@ -2386,9 +2368,9 @@ putBatch(entries: Entry[]): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -2413,10 +2395,10 @@ putBatch(entries: Entry[]): Promise&lt;void&gt; ...@@ -2413,10 +2395,10 @@ putBatch(entries: Entry[]): Promise&lt;void&gt;
}).catch((err) => { }).catch((err) => {
console.log('putBatch fail ' + JSON.stringify(err)); console.log('putBatch fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('PutBatch e ' + e); console.log('PutBatch e ' + e);
} }
``` ```
### deleteBatch<sup>8+</sup> ### deleteBatch<sup>8+</sup>
...@@ -2436,9 +2418,9 @@ deleteBatch(keys: string[], callback: AsyncCallback&lt;void&gt;): void ...@@ -2436,9 +2418,9 @@ deleteBatch(keys: string[], callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
let keys = []; let keys = [];
for (var i = 0; i < 5; i++) { for (var i = 0; i < 5; i++) {
...@@ -2460,10 +2442,10 @@ deleteBatch(keys: string[], callback: AsyncCallback&lt;void&gt;): void ...@@ -2460,10 +2442,10 @@ deleteBatch(keys: string[], callback: AsyncCallback&lt;void&gt;): void
console.log('deleteBatch success'); console.log('deleteBatch success');
}); });
}); });
}catch(e) { }catch(e) {
console.log('DeleteBatch e ' + e); console.log('DeleteBatch e ' + e);
} }
``` ```
### deleteBatch<sup>8+</sup> ### ### deleteBatch<sup>8+</sup> ###
...@@ -2488,9 +2470,9 @@ deleteBatch(keys: string[]): Promise&lt;void&gt; ...@@ -2488,9 +2470,9 @@ deleteBatch(keys: string[]): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
let keys = []; let keys = [];
for (var i = 0; i < 5; i++) { for (var i = 0; i < 5; i++) {
...@@ -2516,10 +2498,10 @@ deleteBatch(keys: string[]): Promise&lt;void&gt; ...@@ -2516,10 +2498,10 @@ deleteBatch(keys: string[]): Promise&lt;void&gt;
}).catch((err) => { }).catch((err) => {
console.log('putBatch fail ' + JSON.stringify(err)); console.log('putBatch fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('DeleteBatch e ' + e); console.log('DeleteBatch e ' + e);
} }
``` ```
### startTransaction<sup>8+</sup> ### ### startTransaction<sup>8+</sup> ###
...@@ -2538,9 +2520,9 @@ startTransaction(callback: AsyncCallback&lt;void&gt;): void ...@@ -2538,9 +2520,9 @@ startTransaction(callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
function putBatchString(len, prefix) { function putBatchString(len, prefix) {
let entries = []; let entries = [];
for (var i = 0; i < len; i++) { for (var i = 0; i < len; i++) {
var entry = { var entry = {
...@@ -2553,8 +2535,8 @@ startTransaction(callback: AsyncCallback&lt;void&gt;): void ...@@ -2553,8 +2535,8 @@ startTransaction(callback: AsyncCallback&lt;void&gt;): void
entries.push(entry); entries.push(entry);
} }
return entries; return entries;
} }
try { try {
var count = 0; var count = 0;
kvStore.on('dataChange', 0, function (data) { kvStore.on('dataChange', 0, function (data) {
console.log('startTransaction 0' + data) console.log('startTransaction 0' + data)
...@@ -2568,10 +2550,10 @@ startTransaction(callback: AsyncCallback&lt;void&gt;): void ...@@ -2568,10 +2550,10 @@ startTransaction(callback: AsyncCallback&lt;void&gt;): void
console.log('putBatch success'); console.log('putBatch success');
}); });
}); });
}catch(e) { }catch(e) {
console.log('startTransaction e ' + e); console.log('startTransaction e ' + e);
} }
``` ```
### startTransaction<sup>8+</sup> ### ### startTransaction<sup>8+</sup> ###
...@@ -2590,9 +2572,9 @@ startTransaction(): Promise&lt;void&gt; ...@@ -2590,9 +2572,9 @@ startTransaction(): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
var count = 0; var count = 0;
kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) {
console.log('startTransaction ' + JSON.stringify(data)); console.log('startTransaction ' + JSON.stringify(data));
...@@ -2603,10 +2585,10 @@ startTransaction(): Promise&lt;void&gt; ...@@ -2603,10 +2585,10 @@ startTransaction(): Promise&lt;void&gt;
}).catch((err) => { }).catch((err) => {
console.log('startTransaction fail ' + JSON.stringify(err)); console.log('startTransaction fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('startTransaction e ' + e); console.log('startTransaction e ' + e);
} }
``` ```
### commit<sup>8+</sup> ### ### commit<sup>8+</sup> ###
...@@ -2625,9 +2607,9 @@ commit(callback: AsyncCallback&lt;void&gt;): void ...@@ -2625,9 +2607,9 @@ commit(callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
kvStore.commit(function (err,data) { kvStore.commit(function (err,data) {
if (err == undefined) { if (err == undefined) {
console.log('commit success'); console.log('commit success');
...@@ -2635,10 +2617,10 @@ commit(callback: AsyncCallback&lt;void&gt;): void ...@@ -2635,10 +2617,10 @@ commit(callback: AsyncCallback&lt;void&gt;): void
console.log('commit fail'); console.log('commit fail');
} }
}); });
}catch(e) { }catch(e) {
console.log('Commit e ' + e); console.log('Commit e ' + e);
} }
``` ```
### commit<sup>8+</sup> ### ### commit<sup>8+</sup> ###
...@@ -2657,18 +2639,18 @@ commit(): Promise&lt;void&gt; ...@@ -2657,18 +2639,18 @@ commit(): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
kvStore.commit().then(async (err) => { kvStore.commit().then(async (err) => {
console.log('commit success'); console.log('commit success');
}).catch((err) => { }).catch((err) => {
console.log('commit fail ' + JSON.stringify(err)); console.log('commit fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('Commit e ' + e); console.log('Commit e ' + e);
} }
``` ```
### rollback<sup>8+</sup> ### ### rollback<sup>8+</sup> ###
...@@ -2687,9 +2669,9 @@ rollback(callback: AsyncCallback&lt;void&gt;): void ...@@ -2687,9 +2669,9 @@ rollback(callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
kvStore.rollback(function (err,data) { kvStore.rollback(function (err,data) {
if (err == undefined) { if (err == undefined) {
console.log('commit success'); console.log('commit success');
...@@ -2697,10 +2679,10 @@ rollback(callback: AsyncCallback&lt;void&gt;): void ...@@ -2697,10 +2679,10 @@ rollback(callback: AsyncCallback&lt;void&gt;): void
console.log('commit fail'); console.log('commit fail');
} }
}); });
}catch(e) { }catch(e) {
console.log('Rollback e ' + e); console.log('Rollback e ' + e);
} }
``` ```
### rollback<sup>8+</sup> ### ### rollback<sup>8+</sup> ###
...@@ -2719,18 +2701,18 @@ rollback(): Promise&lt;void&gt; ...@@ -2719,18 +2701,18 @@ rollback(): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
kvStore.rollback().then(async (err) => { kvStore.rollback().then(async (err) => {
console.log('rollback success'); console.log('rollback success');
}).catch((err) => { }).catch((err) => {
console.log('rollback fail ' + JSON.stringify(err)); console.log('rollback fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('Rollback e ' + e); console.log('Rollback e ' + e);
} }
``` ```
### enableSync<sup>8+</sup> ### ### enableSync<sup>8+</sup> ###
...@@ -2750,9 +2732,9 @@ enableSync(enabled: boolean, callback: AsyncCallback&lt;void&gt;): void ...@@ -2750,9 +2732,9 @@ enableSync(enabled: boolean, callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
kvStore.enableSync(true, function (err,data) { kvStore.enableSync(true, function (err,data) {
if (err == undefined) { if (err == undefined) {
console.log('enableSync success'); console.log('enableSync success');
...@@ -2760,10 +2742,10 @@ enableSync(enabled: boolean, callback: AsyncCallback&lt;void&gt;): void ...@@ -2760,10 +2742,10 @@ enableSync(enabled: boolean, callback: AsyncCallback&lt;void&gt;): void
console.log('enableSync fail'); console.log('enableSync fail');
} }
}); });
}catch(e) { }catch(e) {
console.log('EnableSync e ' + e); console.log('EnableSync e ' + e);
} }
``` ```
### enableSync<sup>8+</sup> ### ### enableSync<sup>8+</sup> ###
...@@ -2788,18 +2770,18 @@ enableSync(enabled: boolean): Promise&lt;void&gt; ...@@ -2788,18 +2770,18 @@ enableSync(enabled: boolean): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
kvStore.enableSync(true).then((err) => { kvStore.enableSync(true).then((err) => {
console.log('enableSync success'); console.log('enableSync success');
}).catch((err) => { }).catch((err) => {
console.log('enableSync fail ' + JSON.stringify(err)); console.log('enableSync fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('EnableSync e ' + e); console.log('EnableSync e ' + e);
} }
``` ```
### setSyncRange<sup>8+</sup> ### ### setSyncRange<sup>8+</sup> ###
...@@ -2820,18 +2802,18 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: Asy ...@@ -2820,18 +2802,18 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: Asy
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
const localLabels = ['A', 'B']; const localLabels = ['A', 'B'];
const remoteSupportLabels = ['C', 'D']; const remoteSupportLabels = ['C', 'D'];
kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) { kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) {
console.log('SetSyncRange put success'); console.log('SetSyncRange put success');
}); });
}catch(e) { }catch(e) {
console.log('SetSyncRange e ' + e); console.log('SetSyncRange e ' + e);
} }
``` ```
### setSyncRange<sup>8+</sup> ### ### setSyncRange<sup>8+</sup> ###
...@@ -2858,9 +2840,9 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise&lt;v ...@@ -2858,9 +2840,9 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise&lt;v
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
const localLabels = ['A', 'B']; const localLabels = ['A', 'B'];
const remoteSupportLabels = ['C', 'D']; const remoteSupportLabels = ['C', 'D'];
kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => { kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => {
...@@ -2868,10 +2850,10 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise&lt;v ...@@ -2868,10 +2850,10 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise&lt;v
}).catch((err) => { }).catch((err) => {
console.log('delete fail ' + err); console.log('delete fail ' + err);
}); });
}catch(e) { }catch(e) {
console.log('SetSyncRange e ' + e); console.log('SetSyncRange e ' + e);
} }
``` ```
## SubscribeType ## SubscribeType
...@@ -2958,15 +2940,15 @@ get(key: string, callback: AsyncCallback&lt;Uint8Array | string | boolean | numb ...@@ -2958,15 +2940,15 @@ get(key: string, callback: AsyncCallback&lt;Uint8Array | string | boolean | numb
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 |
| callback |AsyncCallback&lt;Uint8Array / string / boolean / number&gt;) | 是 |回调函数,获取查询的值。 | | callback |AsyncCallback&lt;Uint8Array \| string \| boolean \| number&gt;) | 是 |回调函数,获取查询的值。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
if (err != undefined) { if (err != undefined) {
console.log("put err: " + JSON.stringify(err)); console.log("put err: " + JSON.stringify(err));
...@@ -2977,10 +2959,10 @@ get(key: string, callback: AsyncCallback&lt;Uint8Array | string | boolean | numb ...@@ -2977,10 +2959,10 @@ get(key: string, callback: AsyncCallback&lt;Uint8Array | string | boolean | numb
console.log("get success data: " + data); console.log("get success data: " + data);
}); });
}); });
}catch (e) { }catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
### get ### get
...@@ -3002,16 +2984,15 @@ get(key: string): Promise&lt;Uint8Array | string | boolean | number&gt; ...@@ -3002,16 +2984,15 @@ get(key: string): Promise&lt;Uint8Array | string | boolean | number&gt;
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ------- | | ------ | ------- |
|Promise&lt;Uint8Array / string / boolean / number&gt; |Promise实例,用于获取异步返回结果。| |Promise&lt;Uint8Array \| string \| boolean \| number&gt; |Promise实例,用于获取异步返回结果。|
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => {
console.log("put success: " + JSON.stringify(data)); console.log("put success: " + JSON.stringify(data));
kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => {
...@@ -3022,10 +3003,10 @@ get(key: string): Promise&lt;Uint8Array | string | boolean | number&gt; ...@@ -3022,10 +3003,10 @@ get(key: string): Promise&lt;Uint8Array | string | boolean | number&gt;
}).catch((err) => { }).catch((err) => {
console.log("put err: " + JSON.stringify(err)); console.log("put err: " + JSON.stringify(err));
}); });
}catch (e) { }catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
### getEntries<sup>8+</sup> ### ### getEntries<sup>8+</sup> ###
...@@ -3040,13 +3021,13 @@ getEntries(keyPrefix: string, callback: AsyncCallback&lt;Entry[]&gt;): void ...@@ -3040,13 +3021,13 @@ getEntries(keyPrefix: string, callback: AsyncCallback&lt;Entry[]&gt;): void
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| keyPrefix |string | 是 |表示要匹配的键前缀。 | | keyPrefix |string | 是 |表示要匹配的键前缀。 |
| callback |AsyncCallback&lt;Entry[]&gt; | 是 |回调函数,获取指定前缀的键值对列表。 | | callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | 是 |回调函数,获取指定前缀的键值对列表。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_number_key'; var key = 'batch_test_number_key';
...@@ -3067,10 +3048,10 @@ getEntries(keyPrefix: string, callback: AsyncCallback&lt;Entry[]&gt;): void ...@@ -3067,10 +3048,10 @@ getEntries(keyPrefix: string, callback: AsyncCallback&lt;Entry[]&gt;): void
console.log('entrys[0]: ' + JSON.stringify(entrys[0])); console.log('entrys[0]: ' + JSON.stringify(entrys[0]));
}); });
}); });
}catch(e) { }catch(e) {
console.log('PutBatch e ' + e); console.log('PutBatch e ' + e);
} }
``` ```
### getEntries<sup>8+</sup> ### ### getEntries<sup>8+</sup> ###
...@@ -3095,9 +3076,9 @@ getEntries(keyPrefix: string): Promise&lt;Entry[]&gt; ...@@ -3095,9 +3076,9 @@ getEntries(keyPrefix: string): Promise&lt;Entry[]&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -3125,10 +3106,10 @@ getEntries(keyPrefix: string): Promise&lt;Entry[]&gt; ...@@ -3125,10 +3106,10 @@ getEntries(keyPrefix: string): Promise&lt;Entry[]&gt;
}).catch((err) => { }).catch((err) => {
console.log('putBatch fail ' + JSON.stringify(err)); console.log('putBatch fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('PutBatch e ' + e); console.log('PutBatch e ' + e);
} }
``` ```
### getEntries<sup>8+</sup> ### ### getEntries<sup>8+</sup> ###
...@@ -3144,13 +3125,13 @@ getEntries(query: Query, callback: AsyncCallback&lt;Entry[]&gt;): void ...@@ -3144,13 +3125,13 @@ getEntries(query: Query, callback: AsyncCallback&lt;Entry[]&gt;): void
| 参数名 | 参数类型 | 必填 | 说明 | | 参数名 | 参数类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| query |[Query](#query8) | 是 |表示要匹配的键前缀。 | | query |[Query](#query8) | 是 |表示要匹配的键前缀。 |
| callback |AsyncCallback&lt;Entry[]&gt; | 是 |回调函数,获取指定前缀的键值对列表。 | | callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | 是 |回调函数,获取指定前缀的键值对列表。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
var arr = new Uint8Array([21,31]); var arr = new Uint8Array([21,31]);
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -3176,10 +3157,10 @@ getEntries(query: Query, callback: AsyncCallback&lt;Entry[]&gt;): void ...@@ -3176,10 +3157,10 @@ getEntries(query: Query, callback: AsyncCallback&lt;Entry[]&gt;): void
}); });
}); });
console.log('GetEntries success'); console.log('GetEntries success');
}catch(e) { }catch(e) {
console.log('GetEntries e ' + e); console.log('GetEntries e ' + e);
} }
``` ```
### getEntries<sup>8+</sup> ### ### getEntries<sup>8+</sup> ###
...@@ -3204,8 +3185,8 @@ getEntries(query: Query): Promise&lt;Entry[]&gt; ...@@ -3204,8 +3185,8 @@ getEntries(query: Query): Promise&lt;Entry[]&gt;
**示例** **示例**
``` ```
try { try {
var arr = new Uint8Array([21,31]); var arr = new Uint8Array([21,31]);
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -3233,10 +3214,10 @@ getEntries(query: Query): Promise&lt;Entry[]&gt; ...@@ -3233,10 +3214,10 @@ getEntries(query: Query): Promise&lt;Entry[]&gt;
console.log('GetEntries putBatch fail ' + JSON.stringify(err)) console.log('GetEntries putBatch fail ' + JSON.stringify(err))
}); });
console.log('GetEntries success'); console.log('GetEntries success');
}catch(e) { }catch(e) {
console.log('GetEntries e ' + e); console.log('GetEntries e ' + e);
} }
``` ```
### getResultSet<sup>8+</sup> ### ### getResultSet<sup>8+</sup> ###
...@@ -3256,9 +3237,9 @@ getResultSet(keyPrefix: string, callback: AsyncCallback&lt;KvStoreResultSet&gt;) ...@@ -3256,9 +3237,9 @@ getResultSet(keyPrefix: string, callback: AsyncCallback&lt;KvStoreResultSet&gt;)
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -3282,10 +3263,10 @@ getResultSet(keyPrefix: string, callback: AsyncCallback&lt;KvStoreResultSet&gt;) ...@@ -3282,10 +3263,10 @@ getResultSet(keyPrefix: string, callback: AsyncCallback&lt;KvStoreResultSet&gt;)
}) })
}); });
}); });
}catch(e) { }catch(e) {
console.log('GetResultSet e ' + e); console.log('GetResultSet e ' + e);
} }
``` ```
### getResultSet<sup>8+</sup> ### ### getResultSet<sup>8+</sup> ###
...@@ -3310,9 +3291,9 @@ getResultSet(keyPrefix: string): Promise&lt;KvStoreResultSet&gt; ...@@ -3310,9 +3291,9 @@ getResultSet(keyPrefix: string): Promise&lt;KvStoreResultSet&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -3342,10 +3323,10 @@ getResultSet(keyPrefix: string): Promise&lt;KvStoreResultSet&gt; ...@@ -3342,10 +3323,10 @@ getResultSet(keyPrefix: string): Promise&lt;KvStoreResultSet&gt;
}).catch((err) => { }).catch((err) => {
console.log('closeResultSet fail ' + JSON.stringify(err)); console.log('closeResultSet fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('GetResult e ' + e); console.log('GetResult e ' + e);
} }
``` ```
### getResultSet<sup>8+</sup> ### ### getResultSet<sup>8+</sup> ###
...@@ -3365,9 +3346,9 @@ getResultSet(query: Query, callback: AsyncCallback&lt;KvStoreResultSet&gt;): voi ...@@ -3365,9 +3346,9 @@ getResultSet(query: Query, callback: AsyncCallback&lt;KvStoreResultSet&gt;): voi
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -3390,10 +3371,10 @@ getResultSet(query: Query, callback: AsyncCallback&lt;KvStoreResultSet&gt;): voi ...@@ -3390,10 +3371,10 @@ getResultSet(query: Query, callback: AsyncCallback&lt;KvStoreResultSet&gt;): voi
resultSet = result; resultSet = result;
}); });
}); });
} catch(e) { } catch(e) {
console.log('GetResultSet e ' + e); console.log('GetResultSet e ' + e);
} }
``` ```
### getResultSet<sup>8+</sup> ### ### getResultSet<sup>8+</sup> ###
...@@ -3418,9 +3399,9 @@ getResultSet(query: Query): Promise&lt;KvStoreResultSet&gt; ...@@ -3418,9 +3399,9 @@ getResultSet(query: Query): Promise&lt;KvStoreResultSet&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -3447,10 +3428,10 @@ getResultSet(query: Query): Promise&lt;KvStoreResultSet&gt; ...@@ -3447,10 +3428,10 @@ getResultSet(query: Query): Promise&lt;KvStoreResultSet&gt;
}).catch((err) => { }).catch((err) => {
console.log('getResultSet fail ' + JSON.stringify(err)); console.log('getResultSet fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('GetResultSet e ' + e); console.log('GetResultSet e ' + e);
} }
``` ```
### closeResultSet<sup>8+</sup> ### ### closeResultSet<sup>8+</sup> ###
...@@ -3469,9 +3450,9 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback&lt;void&gt;) ...@@ -3469,9 +3450,9 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback&lt;void&gt;)
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet = null; let resultSet = null;
kvStore.closeResultSet(resultSet, function (err, data) { kvStore.closeResultSet(resultSet, function (err, data) {
if (err == undefined) { if (err == undefined) {
...@@ -3480,10 +3461,10 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback&lt;void&gt;) ...@@ -3480,10 +3461,10 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback&lt;void&gt;)
console.log('closeResultSet fail'); console.log('closeResultSet fail');
} }
}); });
}catch(e) { }catch(e) {
console.log('CloseResultSet e ' + e); console.log('CloseResultSet e ' + e);
} }
``` ```
### closeResultSet<sup>8+</sup> ### ### closeResultSet<sup>8+</sup> ###
...@@ -3508,19 +3489,19 @@ closeResultSet(resultSet: KvStoreResultSet): Promise&lt;void&gt; ...@@ -3508,19 +3489,19 @@ closeResultSet(resultSet: KvStoreResultSet): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet = null; let resultSet = null;
kvStore.closeResultSet(resultSet).then(() => { kvStore.closeResultSet(resultSet).then(() => {
console.log('closeResultSet success'); console.log('closeResultSet success');
}).catch((err) => { }).catch((err) => {
console.log('closeResultSet fail ' + JSON.stringify(err)); console.log('closeResultSet fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('CloseResultSet e ' + e); console.log('CloseResultSet e ' + e);
} }
``` ```
### getResultSize<sup>8+</sup> ### ### getResultSize<sup>8+</sup> ###
...@@ -3540,9 +3521,9 @@ getResultSize(query: Query, callback: AsyncCallback&lt;number&gt;): void ...@@ -3540,9 +3521,9 @@ getResultSize(query: Query, callback: AsyncCallback&lt;number&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -3563,10 +3544,10 @@ getResultSize(query: Query, callback: AsyncCallback&lt;number&gt;): void ...@@ -3563,10 +3544,10 @@ getResultSize(query: Query, callback: AsyncCallback&lt;number&gt;): void
console.log('getResultSet success'); console.log('getResultSet success');
}); });
}); });
} catch(e) { } catch(e) {
console.log('GetResultSize e ' + e); console.log('GetResultSize e ' + e);
} }
``` ```
### getResultSize<sup>8+</sup> ### ### getResultSize<sup>8+</sup> ###
...@@ -3591,9 +3572,9 @@ getResultSize(query: Query): Promise&lt;number&gt; ...@@ -3591,9 +3572,9 @@ getResultSize(query: Query): Promise&lt;number&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -3618,10 +3599,10 @@ getResultSize(query: Query): Promise&lt;number&gt; ...@@ -3618,10 +3599,10 @@ getResultSize(query: Query): Promise&lt;number&gt;
}).catch((err) => { }).catch((err) => {
console.log('getResultSet fail ' + JSON.stringify(err)); console.log('getResultSet fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('GetResultSize e ' + e); console.log('GetResultSize e ' + e);
} }
``` ```
### removeDeviceData<sup>8+</sup> ### ### removeDeviceData<sup>8+</sup> ###
...@@ -3641,11 +3622,11 @@ removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -3641,11 +3622,11 @@ removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2';
const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) {
console.log('put success'); console.log('put success');
const deviceid = 'no_exist_device_id'; const deviceid = 'no_exist_device_id';
...@@ -3660,10 +3641,10 @@ removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -3660,10 +3641,10 @@ removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void
} }
}); });
}); });
}catch(e) { }catch(e) {
console.log('RemoveDeviceData e ' + e); console.log('RemoveDeviceData e ' + e);
} }
``` ```
### removeDeviceData<sup>8+</sup> ### ### removeDeviceData<sup>8+</sup> ###
...@@ -3688,11 +3669,11 @@ removeDeviceData(deviceId: string): Promise&lt;void&gt; ...@@ -3688,11 +3669,11 @@ removeDeviceData(deviceId: string): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2';
const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; const VALUE_TEST_STRING_ELEMENT = 'value-string-001';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => {
console.log('removeDeviceData put success'); console.log('removeDeviceData put success');
}).catch((err) => { }).catch((err) => {
...@@ -3709,10 +3690,10 @@ removeDeviceData(deviceId: string): Promise&lt;void&gt; ...@@ -3709,10 +3690,10 @@ removeDeviceData(deviceId: string): Promise&lt;void&gt;
}).catch((err) => { }).catch((err) => {
console.log('RemoveDeviceData get fail ' + JSON.stringify(err)); console.log('RemoveDeviceData get fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('RemoveDeviceData e ' + e); console.log('RemoveDeviceData e ' + e);
} }
``` ```
### on<sup>8+</sup> ### ### on<sup>8+</sup> ###
...@@ -3732,11 +3713,11 @@ on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt ...@@ -3732,11 +3713,11 @@ on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
const VALUE_TEST_FLOAT_ELEMENT = 321.12; const VALUE_TEST_FLOAT_ELEMENT = 321.12;
try { try {
kvStore.on('syncComplete', function (data) { kvStore.on('syncComplete', function (data) {
console.log('syncComplete ' + data) console.log('syncComplete ' + data)
}); });
...@@ -3745,10 +3726,10 @@ on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt ...@@ -3745,10 +3726,10 @@ on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt
}).catch((error) => { }).catch((error) => {
console.log('syncComplete put fail ' + error); console.log('syncComplete put fail ' + error);
}); });
}catch(e) { }catch(e) {
console.log('syncComplete put e ' + e); console.log('syncComplete put e ' + e);
} }
``` ```
### off<sup>8+</sup> ### ### off<sup>8+</sup> ###
...@@ -3766,21 +3747,20 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]& ...@@ -3766,21 +3747,20 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&
| event |'syncComplete' | 是 |同步完成时触发的事件名。 | | event |'syncComplete' | 是 |同步完成时触发的事件名。 |
| syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | 否 |用于向调用方发送同步结果的回调。 | | syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | 否 |用于向调用方发送同步结果的回调。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
const func = function (data) { const func = function (data) {
console.log('syncComplete ' + data) console.log('syncComplete ' + data)
}; };
kvStore.on('syncComplete', func); kvStore.on('syncComplete', func);
kvStore.off('syncComplete', func); kvStore.off('syncComplete', func);
}catch(e) { }catch(e) {
console.log('syncComplete e ' + e); console.log('syncComplete e ' + e);
} }
``` ```
### sync ### sync
...@@ -3802,10 +3782,10 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void ...@@ -3802,10 +3782,10 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000); kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000);
``` ```
### setSyncParam<sup>8+</sup> ### ### setSyncParam<sup>8+</sup> ###
...@@ -3822,20 +3802,19 @@ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback&lt;void&gt;) ...@@ -3822,20 +3802,19 @@ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback&lt;void&gt;)
| defaultAllowedDelayMs |number | 是 |表示数据库同步允许的默认延迟,以毫秒为单位。 | | defaultAllowedDelayMs |number | 是 |表示数据库同步允许的默认延迟,以毫秒为单位。 |
| callback |AsyncCallback&lt;void&gt; | 是 |回调函数。 | | callback |AsyncCallback&lt;void&gt; | 是 |回调函数。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
const defaultAllowedDelayMs = 500; const defaultAllowedDelayMs = 500;
kvStore.setSyncParam(defaultAllowedDelayMs, function (err,data) { kvStore.setSyncParam(defaultAllowedDelayMs, function (err,data) {
console.log('SetSyncParam put success'); console.log('SetSyncParam put success');
}); });
}catch(e) { }catch(e) {
console.log('testSingleKvStoreSetSyncParam e ' + e); console.log('testSingleKvStoreSetSyncParam e ' + e);
} }
``` ```
### setSyncParam<sup>8+</sup> ### ### setSyncParam<sup>8+</sup> ###
...@@ -3861,19 +3840,19 @@ setSyncParam(defaultAllowedDelayMs: number): Promise&lt;void&gt; ...@@ -3861,19 +3840,19 @@ setSyncParam(defaultAllowedDelayMs: number): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
const defaultAllowedDelayMs = 500; const defaultAllowedDelayMs = 500;
kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => { kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => {
console.log('SetSyncParam put success'); console.log('SetSyncParam put success');
}).catch((err) => { }).catch((err) => {
console.log('SetSyncParam put fail ' + JSON.stringify(err)); console.log('SetSyncParam put fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('SetSyncParam e ' + e); console.log('SetSyncParam e ' + e);
} }
``` ```
### getSecurityLevel<sup>8+</sup> ### ### getSecurityLevel<sup>8+</sup> ###
...@@ -3892,16 +3871,16 @@ getSecurityLevel(callback: AsyncCallback&lt;SecurityLevel&gt;): void ...@@ -3892,16 +3871,16 @@ getSecurityLevel(callback: AsyncCallback&lt;SecurityLevel&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
kvStore.getSecurityLevel(function (err,data) { kvStore.getSecurityLevel(function (err,data) {
console.log('getSecurityLevel success'); console.log('getSecurityLevel success');
}); });
}catch(e) { }catch(e) {
console.log('GetSecurityLeve e ' + e); console.log('GetSecurityLeve e ' + e);
} }
``` ```
### getSecurityLevel<sup>8+</sup> ### ### getSecurityLevel<sup>8+</sup> ###
...@@ -3918,21 +3897,20 @@ getSecurityLevel(): Promise&lt;SecurityLevel&gt; ...@@ -3918,21 +3897,20 @@ getSecurityLevel(): Promise&lt;SecurityLevel&gt;
| ------ | ------- | | ------ | ------- |
|Promise&lt;[SecurityLevel](#securitylevel)&gt; |Promise实例,用于获取异步返回结果。| |Promise&lt;[SecurityLevel](#securitylevel)&gt; |Promise实例,用于获取异步返回结果。|
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
kvStore.getSecurityLevel().then((data) => { kvStore.getSecurityLevel().then((data) => {
console.log(' getSecurityLevel success'); console.log(' getSecurityLevel success');
}).catch((err) => { }).catch((err) => {
console.log('getSecurityLevel fail ' + JSON.stringify(err)); console.log('getSecurityLevel fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('GetSecurityLeve e ' + e); console.log('GetSecurityLeve e ' + e);
} }
``` ```
## DeviceKVStore<sup>8+</sup> ## ## DeviceKVStore<sup>8+</sup> ##
...@@ -3955,26 +3933,25 @@ get(deviceId: string, key: string, callback: AsyncCallback&lt;boolean|string|num ...@@ -3955,26 +3933,25 @@ get(deviceId: string, key: string, callback: AsyncCallback&lt;boolean|string|num
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| deviceId |string | 是 |标识要查询其数据的设备。 | | deviceId |string | 是 |标识要查询其数据的设备。 |
| key |string | 是 |表示要查询 key 值的键。 | | key |string | 是 |表示要查询 key 值的键。 |
| callback |AsyncCallback&lt;boolean/string/number/Uint8Array&gt; | 是 |回调函数,返回匹配给定条件的字符串值。 | | callback |AsyncCallback&lt;boolean\|string\|number\|Uint8Array&gt; | 是 |回调函数,返回匹配给定条件的字符串值。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2';
const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002';
try{ try{
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) {
console.log('put success'); console.log('put success');
kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err,data) { kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err,data) {
console.log('get success'); console.log('get success');
}); });
}) })
}catch(e) { }catch(e) {
console.log('get e' + e); console.log('get e' + e);
} }
``` ```
### get<sup>8+</sup> ### ### get<sup>8+</sup> ###
...@@ -3996,15 +3973,15 @@ get(deviceId: string, key: string): Promise&lt;boolean|string|number|Uint8Array& ...@@ -3996,15 +3973,15 @@ get(deviceId: string, key: string): Promise&lt;boolean|string|number|Uint8Array&
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ------- | | ------ | ------- |
|Promise&lt;boolean/string/number/Uint8Array&gt; |Promise实例,用于获取异步返回结果。| |Promise&lt;boolean\|string\|number\|Uint8Array&gt; |Promise实例,用于获取异步返回结果。|
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2';
const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => {
console.log(' put success'); console.log(' put success');
kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => {
...@@ -4015,10 +3992,10 @@ get(deviceId: string, key: string): Promise&lt;boolean|string|number|Uint8Array& ...@@ -4015,10 +3992,10 @@ get(deviceId: string, key: string): Promise&lt;boolean|string|number|Uint8Array&
}).catch((error) => { }).catch((error) => {
console.log('put error' + error); console.log('put error' + error);
}); });
} catch (e) { } catch (e) {
console.log('Get e ' + e); console.log('Get e ' + e);
} }
``` ```
### getEntries<sup>8+</sup> ### ### getEntries<sup>8+</sup> ###
...@@ -4039,9 +4016,9 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;Entry ...@@ -4039,9 +4016,9 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;Entry
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -4063,10 +4040,10 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;Entry ...@@ -4063,10 +4040,10 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;Entry
console.log('entrys[0]: ' + JSON.stringify(entrys[0])); console.log('entrys[0]: ' + JSON.stringify(entrys[0]));
}); });
}); });
}catch(e) { }catch(e) {
console.log('PutBatch e ' + e); console.log('PutBatch e ' + e);
} }
``` ```
### getEntries<sup>8+</sup> ### ### getEntries<sup>8+</sup> ###
...@@ -4092,9 +4069,9 @@ getEntries(deviceId: string, keyPrefix: string): Promise&lt;Entry[]&gt; ...@@ -4092,9 +4069,9 @@ getEntries(deviceId: string, keyPrefix: string): Promise&lt;Entry[]&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -4122,10 +4099,10 @@ getEntries(deviceId: string, keyPrefix: string): Promise&lt;Entry[]&gt; ...@@ -4122,10 +4099,10 @@ getEntries(deviceId: string, keyPrefix: string): Promise&lt;Entry[]&gt;
}).catch((err) => { }).catch((err) => {
console.log('putBatch fail ' + JSON.stringify(err)); console.log('putBatch fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('PutBatch e ' + e); console.log('PutBatch e ' + e);
} }
``` ```
### getEntries<sup>8+</sup> ### ### getEntries<sup>8+</sup> ###
...@@ -4145,9 +4122,9 @@ getEntries(query: Query, callback: AsyncCallback&lt;Entry[]&gt;): void ...@@ -4145,9 +4122,9 @@ getEntries(query: Query, callback: AsyncCallback&lt;Entry[]&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
var arr = new Uint8Array([21,31]); var arr = new Uint8Array([21,31]);
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -4175,10 +4152,10 @@ getEntries(query: Query, callback: AsyncCallback&lt;Entry[]&gt;): void ...@@ -4175,10 +4152,10 @@ getEntries(query: Query, callback: AsyncCallback&lt;Entry[]&gt;): void
}); });
}); });
console.log('GetEntries success'); console.log('GetEntries success');
}catch(e) { }catch(e) {
console.log('GetEntries e ' + e); console.log('GetEntries e ' + e);
} }
``` ```
### getEntries<sup>8+</sup> ### ### getEntries<sup>8+</sup> ###
...@@ -4203,9 +4180,9 @@ getEntries(query: Query): Promise&lt;Entry[]&gt; ...@@ -4203,9 +4180,9 @@ getEntries(query: Query): Promise&lt;Entry[]&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
var arr = new Uint8Array([21,31]); var arr = new Uint8Array([21,31]);
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -4233,10 +4210,10 @@ getEntries(query: Query): Promise&lt;Entry[]&gt; ...@@ -4233,10 +4210,10 @@ getEntries(query: Query): Promise&lt;Entry[]&gt;
console.log('GetEntries putBatch fail ' + JSON.stringify(err)) console.log('GetEntries putBatch fail ' + JSON.stringify(err))
}); });
console.log('GetEntries success'); console.log('GetEntries success');
}catch(e) { }catch(e) {
console.log('GetEntries e ' + e); console.log('GetEntries e ' + e);
} }
``` ```
### getEntries<sup>8+</sup> ### ### getEntries<sup>8+</sup> ###
...@@ -4257,9 +4234,9 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback&lt;Entry[]&gt ...@@ -4257,9 +4234,9 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback&lt;Entry[]&gt
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
var arr = new Uint8Array([21,31]); var arr = new Uint8Array([21,31]);
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -4287,10 +4264,10 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback&lt;Entry[]&gt ...@@ -4287,10 +4264,10 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback&lt;Entry[]&gt
}) })
}); });
console.log('GetEntries success'); console.log('GetEntries success');
}catch(e) { }catch(e) {
console.log('GetEntries e ' + e); console.log('GetEntries e ' + e);
} }
``` ```
### getEntries<sup>8+</sup> ### ### getEntries<sup>8+</sup> ###
...@@ -4316,9 +4293,9 @@ getEntries(deviceId: string, query: Query): Promise&lt;Entry[]&gt; ...@@ -4316,9 +4293,9 @@ getEntries(deviceId: string, query: Query): Promise&lt;Entry[]&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
var arr = new Uint8Array([21,31]); var arr = new Uint8Array([21,31]);
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -4347,10 +4324,10 @@ getEntries(deviceId: string, query: Query): Promise&lt;Entry[]&gt; ...@@ -4347,10 +4324,10 @@ getEntries(deviceId: string, query: Query): Promise&lt;Entry[]&gt;
console.log('putBatch fail ' + JSON.stringify(err)); console.log('putBatch fail ' + JSON.stringify(err));
}); });
console.log('GetEntries success'); console.log('GetEntries success');
}catch(e) { }catch(e) {
console.log('GetEntries e ' + e); console.log('GetEntries e ' + e);
} }
``` ```
### getResultSet<sup>8+</sup> ### ### getResultSet<sup>8+</sup> ###
...@@ -4371,9 +4348,9 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;KvS ...@@ -4371,9 +4348,9 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;KvS
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('localDeviceId', 'batch_test_string_key', async function (err, result) { kvStore.getResultSet('localDeviceId', 'batch_test_string_key', async function (err, result) {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -4382,10 +4359,10 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;KvS ...@@ -4382,10 +4359,10 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;KvS
console.log('closeResultSet success'); console.log('closeResultSet success');
}) })
}); });
}catch(e) { }catch(e) {
console.log('GetResultSet e ' + e); console.log('GetResultSet e ' + e);
} }
``` ```
### getResultSet<sup>8+</sup> ### ### getResultSet<sup>8+</sup> ###
...@@ -4411,9 +4388,9 @@ getResultSet(deviceId: string, keyPrefix: string): Promise&lt;KvStoreResultSet&g ...@@ -4411,9 +4388,9 @@ getResultSet(deviceId: string, keyPrefix: string): Promise&lt;KvStoreResultSet&g
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => { kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => {
console.log('getResultSet success'); console.log('getResultSet success');
...@@ -4426,10 +4403,10 @@ getResultSet(deviceId: string, keyPrefix: string): Promise&lt;KvStoreResultSet&g ...@@ -4426,10 +4403,10 @@ getResultSet(deviceId: string, keyPrefix: string): Promise&lt;KvStoreResultSet&g
}).catch((err) => { }).catch((err) => {
console.log('closeResultSet fail ' + JSON.stringify(err)); console.log('closeResultSet fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('GetResultSet e ' + e); console.log('GetResultSet e ' + e);
} }
``` ```
### getResultSet<sup>8+</sup> ### ### getResultSet<sup>8+</sup> ###
...@@ -4449,9 +4426,9 @@ getResultSet(query: Query, callback: AsyncCallback&lt;KvStoreResultSet&gt;): voi ...@@ -4449,9 +4426,9 @@ getResultSet(query: Query, callback: AsyncCallback&lt;KvStoreResultSet&gt;): voi
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -4478,10 +4455,10 @@ getResultSet(query: Query, callback: AsyncCallback&lt;KvStoreResultSet&gt;): voi ...@@ -4478,10 +4455,10 @@ getResultSet(query: Query, callback: AsyncCallback&lt;KvStoreResultSet&gt;): voi
}) })
}); });
}); });
} catch(e) { } catch(e) {
console.log('GetResultSet e ' + e); console.log('GetResultSet e ' + e);
} }
``` ```
### getResultSet<sup>8+</sup> ### ### getResultSet<sup>8+</sup> ###
...@@ -4506,9 +4483,9 @@ getResultSet(query: Query): Promise&lt;KvStoreResultSet&gt; ...@@ -4506,9 +4483,9 @@ getResultSet(query: Query): Promise&lt;KvStoreResultSet&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -4542,10 +4519,10 @@ getResultSet(query: Query): Promise&lt;KvStoreResultSet&gt; ...@@ -4542,10 +4519,10 @@ getResultSet(query: Query): Promise&lt;KvStoreResultSet&gt;
}).catch((err) => { }).catch((err) => {
console.log('closeResultSet fail ' + JSON.stringify(err)); console.log('closeResultSet fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('GetResultSet e ' + e); console.log('GetResultSet e ' + e);
} }
``` ```
### getResultSet<sup>8+</sup> ### ### getResultSet<sup>8+</sup> ###
...@@ -4566,9 +4543,9 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback&lt;KvStoreR ...@@ -4566,9 +4543,9 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback&lt;KvStoreR
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -4594,10 +4571,10 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback&lt;KvStoreR ...@@ -4594,10 +4571,10 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback&lt;KvStoreR
}) })
}); });
}); });
} catch(e) { } catch(e) {
console.log('GetResultSet e ' + e); console.log('GetResultSet e ' + e);
} }
``` ```
### getResultSet<sup>8+</sup> ### ### getResultSet<sup>8+</sup> ###
...@@ -4623,9 +4600,9 @@ getResultSet(deviceId: string, query: Query): Promise&lt;KvStoreResultSet&gt; ...@@ -4623,9 +4600,9 @@ getResultSet(deviceId: string, query: Query): Promise&lt;KvStoreResultSet&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let resultSet; let resultSet;
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
...@@ -4660,10 +4637,10 @@ getResultSet(deviceId: string, query: Query): Promise&lt;KvStoreResultSet&gt; ...@@ -4660,10 +4637,10 @@ getResultSet(deviceId: string, query: Query): Promise&lt;KvStoreResultSet&gt;
console.log('GetResultSet closeResultSet fail ' + JSON.stringify(err)); console.log('GetResultSet closeResultSet fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('GetResultSet e ' + e); console.log('GetResultSet e ' + e);
} }
``` ```
### closeResultSet<sup>8+</sup> ### ### closeResultSet<sup>8+</sup> ###
...@@ -4683,9 +4660,9 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback&lt;void&gt;) ...@@ -4683,9 +4660,9 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback&lt;void&gt;)
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
console.log('CloseResultSet success'); console.log('CloseResultSet success');
let resultSet = null; let resultSet = null;
kvStore.closeResultSet(resultSet, function (err, data) { kvStore.closeResultSet(resultSet, function (err, data) {
...@@ -4695,10 +4672,10 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback&lt;void&gt;) ...@@ -4695,10 +4672,10 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback&lt;void&gt;)
console.log('closeResultSet fail'); console.log('closeResultSet fail');
} }
}); });
}catch(e) { }catch(e) {
console.log('CloseResultSet e ' + e); console.log('CloseResultSet e ' + e);
} }
``` ```
### closeResultSet<sup>8+</sup> ### ### closeResultSet<sup>8+</sup> ###
...@@ -4723,9 +4700,9 @@ closeResultSet(resultSet: KvStoreResultSet): Promise&lt;void&gt; ...@@ -4723,9 +4700,9 @@ closeResultSet(resultSet: KvStoreResultSet): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
console.log('CloseResultSet success'); console.log('CloseResultSet success');
let resultSet = null; let resultSet = null;
kvStore.closeResultSet(resultSet).then(() => { kvStore.closeResultSet(resultSet).then(() => {
...@@ -4733,10 +4710,10 @@ closeResultSet(resultSet: KvStoreResultSet): Promise&lt;void&gt; ...@@ -4733,10 +4710,10 @@ closeResultSet(resultSet: KvStoreResultSet): Promise&lt;void&gt;
}).catch((err) => { }).catch((err) => {
console.log('closeResultSet fail ' + JSON.stringify(err)); console.log('closeResultSet fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('CloseResultSet e ' + e); console.log('CloseResultSet e ' + e);
} }
``` ```
### getResultSize<sup>8+</sup> ### ### getResultSize<sup>8+</sup> ###
...@@ -4756,9 +4733,9 @@ getResultSize(query: Query, callback: AsyncCallback&lt;number&gt;): void ...@@ -4756,9 +4733,9 @@ getResultSize(query: Query, callback: AsyncCallback&lt;number&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -4780,10 +4757,10 @@ getResultSize(query: Query, callback: AsyncCallback&lt;number&gt;): void ...@@ -4780,10 +4757,10 @@ getResultSize(query: Query, callback: AsyncCallback&lt;number&gt;): void
console.log('getResultSet success'); console.log('getResultSet success');
}); });
}); });
} catch(e) { } catch(e) {
console.log('GetResultSize e ' + e); console.log('GetResultSize e ' + e);
} }
``` ```
### getResultSize<sup>8+</sup> ### ### getResultSize<sup>8+</sup> ###
...@@ -4808,9 +4785,9 @@ getResultSize(query: Query): Promise&lt;number&gt; ...@@ -4808,9 +4785,9 @@ getResultSize(query: Query): Promise&lt;number&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -4836,10 +4813,10 @@ getResultSize(query: Query): Promise&lt;number&gt; ...@@ -4836,10 +4813,10 @@ getResultSize(query: Query): Promise&lt;number&gt;
}).catch((err) => { }).catch((err) => {
console.log('getResultSet fail ' + JSON.stringify(err)); console.log('getResultSet fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('GetResultSize e ' + e); console.log('GetResultSize e ' + e);
} }
``` ```
### getResultSize<sup>8+</sup> ### ### getResultSize<sup>8+</sup> ###
...@@ -4860,9 +4837,9 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback&lt;number& ...@@ -4860,9 +4837,9 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback&lt;number&
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -4883,10 +4860,10 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback&lt;number& ...@@ -4883,10 +4860,10 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback&lt;number&
console.log('getResultSet success'); console.log('getResultSet success');
}); });
}); });
} catch(e) { } catch(e) {
console.log('GetResultSize e ' + e); console.log('GetResultSize e ' + e);
} }
``` ```
### getResultSize<sup>8+</sup> ### ### getResultSize<sup>8+</sup> ###
...@@ -4912,9 +4889,9 @@ getResultSize(deviceId: string, query: Query): Promise&lt;number&gt; ...@@ -4912,9 +4889,9 @@ getResultSize(deviceId: string, query: Query): Promise&lt;number&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
let entries = []; let entries = [];
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var key = 'batch_test_string_key'; var key = 'batch_test_string_key';
...@@ -4939,10 +4916,10 @@ getResultSize(deviceId: string, query: Query): Promise&lt;number&gt; ...@@ -4939,10 +4916,10 @@ getResultSize(deviceId: string, query: Query): Promise&lt;number&gt;
}).catch((err) => { }).catch((err) => {
console.log('getResultSet fail ' + JSON.stringify(err)); console.log('getResultSet fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('GetResultSize e ' + e); console.log('GetResultSize e ' + e);
} }
``` ```
### removeDeviceData<sup>8+</sup> ### ### removeDeviceData<sup>8+</sup> ###
...@@ -4962,11 +4939,11 @@ removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -4962,11 +4939,11 @@ removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; const VALUE_TEST_STRING_ELEMENT = 'value-string-001';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) {
console.log('RemoveDeviceData put success'); console.log('RemoveDeviceData put success');
const deviceid = 'no_exist_device_id'; const deviceid = 'no_exist_device_id';
...@@ -4981,10 +4958,10 @@ removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -4981,10 +4958,10 @@ removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void
} }
}); });
}); });
}catch(e) { }catch(e) {
console.log('RemoveDeviceData e ' + e); console.log('RemoveDeviceData e ' + e);
} }
``` ```
### removeDeviceData<sup>8+</sup> ### ### removeDeviceData<sup>8+</sup> ###
...@@ -5009,11 +4986,11 @@ removeDeviceData(deviceId: string): Promise&lt;void&gt; ...@@ -5009,11 +4986,11 @@ removeDeviceData(deviceId: string): Promise&lt;void&gt;
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; const VALUE_TEST_STRING_ELEMENT = 'value-string-001';
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => {
console.log('RemoveDeviceData put success'); console.log('RemoveDeviceData put success');
}).catch((err) => { }).catch((err) => {
...@@ -5030,10 +5007,10 @@ removeDeviceData(deviceId: string): Promise&lt;void&gt; ...@@ -5030,10 +5007,10 @@ removeDeviceData(deviceId: string): Promise&lt;void&gt;
}).catch((err) => { }).catch((err) => {
console.log('RemoveDeviceData get fail ' + JSON.stringify(err)); console.log('RemoveDeviceData get fail ' + JSON.stringify(err));
}); });
}catch(e) { }catch(e) {
console.log('RemoveDeviceData e ' + e); console.log('RemoveDeviceData e ' + e);
} }
``` ```
### sync<sup>8+</sup> ### ### sync<sup>8+</sup> ###
...@@ -5053,14 +5030,13 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void ...@@ -5053,14 +5030,13 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void
| mode |[SyncMode](#syncmode) | 是 |表示同步方式,PUSH、PULL或PUSH_PULL。 | | mode |[SyncMode](#syncmode) | 是 |表示同步方式,PUSH、PULL或PUSH_PULL。 |
| allowedDelayMs |number | 否 |可选参数,允许延时时间,单位:ms(毫秒)。 | | allowedDelayMs |number | 否 |可选参数,允许延时时间,单位:ms(毫秒)。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
try { try {
kvStore.on('syncComplete', function (data) { kvStore.on('syncComplete', function (data) {
console.log('Sync dataChange'); console.log('Sync dataChange');
}); });
...@@ -5070,10 +5046,10 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void ...@@ -5070,10 +5046,10 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void
const mode = distributedData.SyncMode.PULL_ONLY; const mode = distributedData.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode); kvStore.sync(devices, mode);
}); });
}catch(e) { }catch(e) {
console.log('Sync e' + e); console.log('Sync e' + e);
} }
``` ```
### on<sup>8+</sup> ### ### on<sup>8+</sup> ###
...@@ -5092,10 +5068,10 @@ on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt ...@@ -5092,10 +5068,10 @@ on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt
**示例** **示例**
``` ```
const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
const VALUE_TEST_FLOAT_ELEMENT = 321.12; const VALUE_TEST_FLOAT_ELEMENT = 321.12;
try { try {
kvStore.on('syncComplete', function (data) { kvStore.on('syncComplete', function (data) {
console.log('syncComplete ' + data) console.log('syncComplete ' + data)
}); });
...@@ -5104,10 +5080,10 @@ on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt ...@@ -5104,10 +5080,10 @@ on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt
}).catch((error) => { }).catch((error) => {
console.log('syncComplete put fail ' + error); console.log('syncComplete put fail ' + error);
}); });
}catch(e) { }catch(e) {
console.log('syncComplete put e ' + e); console.log('syncComplete put e ' + e);
} }
``` ```
### off<sup>8+</sup> ### ### off<sup>8+</sup> ###
...@@ -5125,21 +5101,20 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]& ...@@ -5125,21 +5101,20 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&
| event |'syncComplete' | 是 |同步完成时触发的事件名。 | | event |'syncComplete' | 是 |同步完成时触发的事件名。 |
| syncCallback |Callback<Array&lt;[string, number]&gt;&gt; | 否 |用于向调用方发送同步结果的回调。 | | syncCallback |Callback<Array&lt;[string, number]&gt;&gt; | 否 |用于向调用方发送同步结果的回调。 |
**示例** **示例**
``` ```
let kvStore; let kvStore;
try { try {
const func = function (data) { const func = function (data) {
console.log('syncComplete ' + data) console.log('syncComplete ' + data)
}; };
kvStore.on('syncComplete', func); kvStore.on('syncComplete', func);
kvStore.off('syncComplete', func); kvStore.off('syncComplete', func);
}catch(e) { }catch(e) {
console.log('syncComplete e ' + e); console.log('syncComplete e ' + e);
} }
``` ```
## SyncMode ## SyncMode
......
...@@ -26,7 +26,7 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>): ...@@ -26,7 +26,7 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>):
| 名称 | 类型 | 必填 | 描述 | | 名称 | 类型 | 必填 | 描述 |
| --------- | ----------------------------------------------- | ---- | ----------------- | | --------- | ----------------------------------------------- | ---- | ----------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | 是 | 指示启动的ability | | parameter | [StartAbilityParameter](js-apis-featureAbility.md#startabilityparameter) | 是 | 指示启动的ability |
| callback | AsyncCallback\<void> | 是 | 被指定的回调方法 | | callback | AsyncCallback\<void> | 是 | 被指定的回调方法 |
**示例:** **示例:**
...@@ -69,7 +69,7 @@ startAbility(parameter: StartAbilityParameter): Promise\<void>; ...@@ -69,7 +69,7 @@ startAbility(parameter: StartAbilityParameter): Promise\<void>;
| 名称 | 类型 | 必填 | 描述 | | 名称 | 类型 | 必填 | 描述 |
| --------- | ----------------------------------------------- | ---- | ----------------- | | --------- | ----------------------------------------------- | ---- | ----------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | 是 | 指示启动的ability | | parameter | [StartAbilityParameter](js-apis-featureAbility.md#startabilityparameter) | 是 | 指示启动的ability |
**返回值:** **返回值:**
...@@ -384,7 +384,7 @@ connectAbility(request: Want, options:ConnectOptions): number ...@@ -384,7 +384,7 @@ connectAbility(request: Want, options:ConnectOptions): number
| 名称 | 类型 | 必填 | 描述 | | 名称 | 类型 | 必填 | 描述 |
| ------- | -------------- | ---- | ---------------------------- | | ------- | -------------- | ---- | ---------------------------- |
| request | [Want](#want) | 是 | 表示被连接的ServiceAbility。 | | request | [Want](js-apis-featureAbility.md#want) | 是 | 表示被连接的ServiceAbility。 |
| options | ConnectOptions | 是 | 被指定的回调方法。 | | options | ConnectOptions | 是 | 被指定的回调方法。 |
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
- [ImageAnimator](ts-basic-components-imageanimator.md) - [ImageAnimator](ts-basic-components-imageanimator.md)
- [LoadingProgress](ts-basic-components-loadingprogress.md) - [LoadingProgress](ts-basic-components-loadingprogress.md)
- [Marquee](ts-basic-components-marquee.md) - [Marquee](ts-basic-components-marquee.md)
- [Navigation](ts-basic-components-navigation.md)
- [PatternLock](ts-basic-components-patternlock.md) - [PatternLock](ts-basic-components-patternlock.md)
- [PluginComponent](ts-basic-components-plugincomponent.md) - [PluginComponent](ts-basic-components-plugincomponent.md)
- [Progress](ts-basic-components-progress.md) - [Progress](ts-basic-components-progress.md)
...@@ -67,10 +68,13 @@ ...@@ -67,10 +68,13 @@
- [Radio](ts-basic-components-radio.md) - [Radio](ts-basic-components-radio.md)
- [Rating](ts-basic-components-rating.md) - [Rating](ts-basic-components-rating.md)
- [RichText](ts-basic-components-richtext.md) - [RichText](ts-basic-components-richtext.md)
- [ScrollBar](ts-basic-components-scrollbar.md)
- [Search](ts-basic-components-search.md) - [Search](ts-basic-components-search.md)
- [Select](ts-basic-components-select.md) - [Select](ts-basic-components-select.md)
- [Slider](ts-basic-components-slider.md) - [Slider](ts-basic-components-slider.md)
- [Span](ts-basic-components-span.md) - [Span](ts-basic-components-span.md)
- [Stepper](ts-basic-components-stepper.md)
- [StepperItem](ts-basic-components-stepperitem.md)
- [Text](ts-basic-components-text.md) - [Text](ts-basic-components-text.md)
- [TextArea](ts-basic-components-textarea.md) - [TextArea](ts-basic-components-textarea.md)
- [TextClock](ts-basic-components-textclock.md) - [TextClock](ts-basic-components-textclock.md)
...@@ -94,17 +98,13 @@ ...@@ -94,17 +98,13 @@
- [List](ts-container-list.md) - [List](ts-container-list.md)
- [ListItem](ts-container-listitem.md) - [ListItem](ts-container-listitem.md)
- [Navigator](ts-container-navigator.md) - [Navigator](ts-container-navigator.md)
- [Navigation](ts-basic-components-navigation.md)
- [Panel](ts-container-panel.md) - [Panel](ts-container-panel.md)
- [Refresh](ts-container-refresh.md) - [Refresh](ts-container-refresh.md)
- [Row](ts-container-row.md) - [Row](ts-container-row.md)
- [RowSplit](ts-container-rowsplit.md) - [RowSplit](ts-container-rowsplit.md)
- [Scroll](ts-container-scroll.md) - [Scroll](ts-container-scroll.md)
- [ScrollBar](ts-basic-components-scrollbar.md)
- [SideBarContainer](ts-container-sidebarcontainer.md) - [SideBarContainer](ts-container-sidebarcontainer.md)
- [Stack](ts-container-stack.md) - [Stack](ts-container-stack.md)
- [Stepper](ts-basic-components-stepper.md)
- [StepperItem](ts-basic-components-stepperitem.md)
- [Swiper](ts-container-swiper.md) - [Swiper](ts-container-swiper.md)
- [Tabs](ts-container-tabs.md) - [Tabs](ts-container-tabs.md)
- [TabContent](ts-container-tabcontent.md) - [TabContent](ts-container-tabcontent.md)
......
# 安全 # 安全
- 访问控制
- [访问控制开发概述](accesstoken-overview.md)
- [访问控制开发指导](accesstoken-guidelines.md)
- 用户认证 - 用户认证
- [用户认证开发概述](userauth-overview.md) - [用户认证开发概述](userauth-overview.md)
- [用户认证开发指导](userauth-guidelines.md) - [用户认证开发指导](userauth-guidelines.md)
- 密钥管理 - 密钥管理
- [HUKS开发概述](huks-overview.md) - [HUKS开发概述](huks-overview.md)
- [HUKS开发指导](huks-guidelines.md) - [HUKS开发指导](huks-guidelines.md)
- Hap包签名工具 - Hap包签名工具
- [Hap包签名工具指导](hapsigntool-guidelines.md) - [Hap包签名工具指导](hapsigntool-guidelines.md)
- 访问控制
- [访问控制开发概述](accesstoken-overview.md)
- [访问控制开发指导](accesstoken-guidelines.md)
# 用户认证开发指导 # 用户认证开发指导
> **说明:**
> 该开发指导需匹配API Version 8或以上版本的SDK使用。
## 场景介绍 ## 场景介绍
当前用户认证支持2D人脸识别、3D人脸识别,可应用于设备解锁、应用登录、支付等身份认证场景。 当前用户认证支持2D人脸识别、3D人脸识别,可应用于设备解锁、应用登录、支付等身份认证场景。
## 接口说明 ## 接口说明
userIAM_userAuth模块提供了用户认证的相关方法,包括检测认证能力、认证和取消认证等,用户可以通过人脸等生物特征信息进行认证操作。具体接口说明可以查阅[API参考](../reference/apis/js-apis-useriam-userauth.md) userIAM_userAuth模块提供了用户认证的相关方法,包括检测认证能力、认证和取消认证等,用户可以使用人脸等生物特征信息进行认证操作。具体接口说明可以查阅[API参考](../reference/apis/js-apis-useriam-userauth.md)
在执行认证前,需要检查设备是否支持该认证能力,具体指认证类型、安全级别和是否本地认证。如果不支持,需要考虑使用其他认证能力。 在执行认证前,需要检查设备是否支持该认证能力,具体指认证类型、认证等级。如果不支持,需要考虑使用其他认证能力。
**表1** 用户认证开放能力列表 **表1** 用户认证开放能力列表
| 接口名 | 功能描述 | | 接口名 | 功能描述 |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------ | ------------------------------------------------------------ |
| getAuthenticator(): Authenticator | 获取Authenticator对象,用于执行用户身份认证。<sup>6+</sup><br>获取Authenticator对象,用于检测设备身份认证能力、执行和取消用户身份认证,获取认证过程中的提示信息。<sup>7+</sup> | | getVersion() : number | 获取认证对象的版本信息。 |
| checkAvailability(type: AuthType, level: SecureLevel): number | 根据指定的认证类型、安全等级,检测当前设备是否支持相应的认证能力。 | | getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 |
| execute(type: AuthType, level: SecureLevel, callback: AsyncCallback\<number>): void | 执行用户认证,使用callback方式作为异步方法。 | | auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array | 执行用户认证,使用callback方式作为异步方法。 |
| execute(type: AuthType, level: SecureLevel): Promise\<number> | 执行用户认证,使用Promise方式作为异步方法。 | | cancelAuth(contextID : Uint8Array) : number | 通过contextID取消本次认证操作。 |
| cancel(): void | 取消当前的认证流程。 |
| on(type: "tip", callback: Callback\<Tip>): void | 订阅指定类型的事件。 |
| off(type: "tip", callback?: Callback\<Tip>): void | 取消订阅指定类型的事件。 |
## 开发步骤 ## 开发步骤
...@@ -34,66 +34,78 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括检测认证 ...@@ -34,66 +34,78 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括检测认证
1. 获取Authenticator的单例对象,代码示例如下: 1. 获取Authenticator的单例对象,代码示例如下:
```js ```js
let auth = userIAM_userAuth.getAuthenticator(); let auth = new userIAM_userAuth.UserAuth();
``` ```
2. 检测设备是否具有指定级别的认证能力 2. (可选)获取认证对象的版本信息,代码示例如下
2D人脸识别支持低于S2级别的认证,3D人脸识别支持低于S3级别的认证。代码示例如下: ```js
let auth = new userIAM_userAuth.UserAuth();
let version = auth.getVersion();
console.info("auth version = " + version);
```
3. 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力,代码示例如下:
```js ```js
let authenticator = userIAM_userAuth.getAuthenticator(); let auth = new userIAM_userAuth.UserAuth();
let checkCode = authenticator.checkAvailability("FACE_ONLY", "S2"); let checkCode = auth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1);
if (checkCode == userIAM_userAuth.CheckAvailabilityResult.SUPPORTED) { if (checkCode == userIAM_userAuth.ResultCode.SUCCESS) {
console.info("check auth support success"); console.info("check auth support success");
// 此处添加支持指定类型认证的逻辑
} else { } else {
console.error("check auth support fail, code = " + checkCode); console.error("check auth support fail, code = " + checkCode);
// 此处添加不支持指定类型认证的逻辑
} }
``` ```
3. (可选)订阅人脸tip信息,代码示例如下:
```js
let authenticator = userIAM_userAuth.getAuthenticator();
let tipCallback = (tip)=>{
console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode +") event(" +
tip.tipEvent + ") info(" + tip.tipInfo + ")");
};
authenticator.on("tip", tipCallback);
```
4. 执行认证操作,代码示例如下: 4. 执行认证操作,代码示例如下:
```js ```js
let authenticator = userIAM_userAuth.getAuthenticator(); let auth = new userIAM_userAuth.UserAuth();
authenticator.execute("FACE_ONLY", "S2").then((code)=>{ auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
authenticator.off("tip", tipCallback); onResult: (result, extraInfo) => {
console.info("auth success"); try {
}).catch((code)=>{ console.info("auth onResult result = " + result);
authenticator.off("tip", tipCallback); console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo));
console.error("auth fail, code = " + code); if (result == 'SUCCESS') {
// 此处添加认证成功逻辑
} else {
// 此处添加认证失败逻辑
}
} catch (e) {
console.info("auth onResult error = " + e);
}
},
onAcquireInfo: (module, acquire, extraInfo) => {
try {
console.info("auth onAcquireInfo module = " + module);
console.info("auth onAcquireInfo acquire = " + acquire);
console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo));
} catch (e) {
console.info("auth onAcquireInfo error = " + e);
}
}
}); });
``` ```
5. (仅执行订阅信息后需要)取消订阅人脸tip信息 5. 认证过程中取消认证,代码示例如下
```js ```js
let authenticator = userIAM_userAuth.getAuthenticator(); let auth = new userIAM_userAuth.UserAuth();
let tipCallback = (tip)=>{ // contextId通过auth接口获取
console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode + ") event(" + let contextId = auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, {
tip.tipEvent + ") info(" + tip.tipInfo + ")"); onResult: (result, extraInfo) => {
}; console.info("auth onResult result = " + result);
// 取消订阅指定回调 },
authenticator.off("tip", tipCallback);
// 取消订阅所有回调authenticator.off("tip"); onAcquireInfo: (module, acquire, extraInfo) => {
``` console.info("auth onAcquireInfo module = " + module);
}
6. 认证过程中取消认证,代码示例如下: });
let cancelCode = auth.cancel(contextId);
```js if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) {
let authenticator = userIAM_userAuth.getAuthenticator();
let cancelCode = authenticator.cancel();
if (cancelCode == userIAM_userAuth.Result.SUCCESS) {
console.info("cancel auth success"); console.info("cancel auth success");
} else { } else {
console.error("cancel auth fail"); console.error("cancel auth fail");
......
...@@ -440,6 +440,7 @@ ...@@ -440,6 +440,7 @@
- [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md)
- [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md)
- [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md)
- [Navigation](reference/arkui-ts/ts-basic-components-navigation.md)
- [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md)
- [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md)
- [Progress](reference/arkui-ts/ts-basic-components-progress.md) - [Progress](reference/arkui-ts/ts-basic-components-progress.md)
...@@ -447,12 +448,13 @@ ...@@ -447,12 +448,13 @@
- [Radio](reference/arkui-ts/ts-basic-components-radio.md) - [Radio](reference/arkui-ts/ts-basic-components-radio.md)
- [Rating](reference/arkui-ts/ts-basic-components-rating.md) - [Rating](reference/arkui-ts/ts-basic-components-rating.md)
- [RichText](reference/arkui-ts/ts-basic-components-richtext.md) - [RichText](reference/arkui-ts/ts-basic-components-richtext.md)
- [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md)
- [Search](reference/arkui-ts/ts-basic-components-search.md) - [Search](reference/arkui-ts/ts-basic-components-search.md)
- [Select](reference/arkui-ts/ts-basic-components-select.md) - [Select](reference/arkui-ts/ts-basic-components-select.md)
- [Slider](reference/arkui-ts/ts-basic-components-slider.md) - [Slider](reference/arkui-ts/ts-basic-components-slider.md)
- [Span](reference/arkui-ts/ts-basic-components-span.md)
- [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md)
- [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md)
- [Span](reference/arkui-ts/ts-basic-components-span.md)
- [Text](reference/arkui-ts/ts-basic-components-text.md) - [Text](reference/arkui-ts/ts-basic-components-text.md)
- [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md)
- [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md)
...@@ -476,13 +478,11 @@ ...@@ -476,13 +478,11 @@
- [List](reference/arkui-ts/ts-container-list.md) - [List](reference/arkui-ts/ts-container-list.md)
- [ListItem](reference/arkui-ts/ts-container-listitem.md) - [ListItem](reference/arkui-ts/ts-container-listitem.md)
- [Navigator](reference/arkui-ts/ts-container-navigator.md) - [Navigator](reference/arkui-ts/ts-container-navigator.md)
- [Navigation](reference/arkui-ts/ts-basic-components-navigation.md)
- [Panel](reference/arkui-ts/ts-container-panel.md) - [Panel](reference/arkui-ts/ts-container-panel.md)
- [Refresh](reference/arkui-ts/ts-container-refresh.md) - [Refresh](reference/arkui-ts/ts-container-refresh.md)
- [Row](reference/arkui-ts/ts-container-row.md) - [Row](reference/arkui-ts/ts-container-row.md)
- [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md)
- [Scroll](reference/arkui-ts/ts-container-scroll.md) - [Scroll](reference/arkui-ts/ts-container-scroll.md)
- [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md)
- [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md)
- [Stack](reference/arkui-ts/ts-container-stack.md) - [Stack](reference/arkui-ts/ts-container-stack.md)
- [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Swiper](reference/arkui-ts/ts-container-swiper.md)
......
...@@ -41,7 +41,7 @@ int main() ...@@ -41,7 +41,7 @@ int main()
## 编译 ## 编译
``` ```
$ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos --sysroot=/home/<user-name>/harmony/out/hispark_taurus/ipcamera_hispark_taurus/sysroot $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a) $ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos --sysroot=/home/<user-name>/directory/out/hispark_taurus/ipcamera_hispark_taurus/sysroot $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a)
``` ```
...@@ -54,7 +54,7 @@ $ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp ...@@ -54,7 +54,7 @@ $ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp
> >
> - -target arm-liteos用于指定编译器相关库文件路径。 > - -target arm-liteos用于指定编译器相关库文件路径。
> >
> - --sysroot=/home/&lt;user-name&gt;/harmony/out/hispark_taurus/ipcamera_hispark_taurus/sysroot用于指定编译器库文件搜索根目录,假设OpenHarmony工程代码存放路径为/home/&lt;user-name&gt;/harmony。其中out/hispark_taurus/ipcamera_hispark_taurus路径为在编译时,hb set命令指定的具体产品,本示例选择的是ipcamera_hispark_taurus产品。 > - --sysroot=/home/&lt;user-name&gt;/directory/out/hispark_taurus/ipcamera_hispark_taurus/sysroot用于指定编译器库文件搜索根目录,假设OpenHarmony工程代码存放路径为/home/&lt;user-name&gt;/directory。其中out/hispark_taurus/ipcamera_hispark_taurus路径为在编译时,hb set命令指定的具体产品,本示例选择的是ipcamera_hispark_taurus产品。
> >
> - $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a)用于指定相应的unwind库的路径。 > - $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a)用于指定相应的unwind库的路径。
......
...@@ -10,7 +10,7 @@ Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代I ...@@ -10,7 +10,7 @@ Hi3516DV300作为新一代行业专用Smart HD IP摄像机SOC,集成新一代I
**图 1** Hi3516单板正面外观图<a name="fig11402183715219"></a> **图 1** Hi3516单板正面外观图<a name="fig11402183715219"></a>
![](figures/3516正面.png) ![](figures/Hi3516单板正面外观图.png)
## 开发板规格<a name="section15192203316533"></a> ## 开发板规格<a name="section15192203316533"></a>
......
...@@ -415,17 +415,17 @@ AI业务子系统是OpenHarmony提供原生的分布式AI能力的子系统。 ...@@ -415,17 +415,17 @@ AI业务子系统是OpenHarmony提供原生的分布式AI能力的子系统。
## 涉及仓<a name="section10492183517430"></a> ## 涉及仓<a name="section10492183517430"></a>
AI子系统 [AI子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/AI%E4%B8%9A%E5%8A%A1%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
ai_engine [ai_engine](https://gitee.com/openharmony/ai_engine)
依赖仓: 依赖仓:
build\_lite [build\_lite](https://gitee.com/openharmony/build_lite/blob/master/README_zh.md)
distributedschedule\_services\_samgr\_lite [distributedschedule\_samgr\_lite](https://gitee.com/openharmony/distributedschedule_samgr_lite/blob/master/README_zh.md)
startup\_init\_lite [startup\_init\_lite](https://gitee.com/openharmony/startup_init_lite/blob/master/README_zh.md)
## AI引擎开发导航<a name="section6808423133718"></a> ## AI引擎开发导航<a name="section6808423133718"></a>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册