diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md
index a99ca9b372e2f9e7865987a093b1d5566bef067f..a4144bde7d65241c73dc829347b97963b29c65a7 100644
--- a/en/application-dev/Readme-EN.md
+++ b/en/application-dev/Readme-EN.md
@@ -20,6 +20,7 @@
- [Data Management](database/Readme-EN.md)
- [Device](device/Readme-EN.md)
- [DFX](dfx/Readme-EN.md)
+ - [Window Manager](windowmanager/Readme-EN.md)
- Tools
- [DevEco Studio \(OpenHarmony\) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- Hands-On Tutorials
diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md
index 494ebd562b0cf6c241137823e2360122c21f5bea..6094f0453f58144d9955db7093f73818a80d60fa 100644
--- a/en/application-dev/database/database-relational-guidelines.md
+++ b/en/application-dev/database/database-relational-guidelines.md
@@ -13,19 +13,20 @@ The following table describes the APIs available for creating and deleting an RD
**Table 1** APIs for creating and deleting an RDB store
-| Class| API| Description|
-| -------- | -------- | -------- |
-| dataRdb | getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void | Obtains an RDB store. This method uses a callback to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.
- **config**: configuration of the RDB store.
- **version**: RDB version.
- **callback**: callback invoked to return the RDB store obtained.|
-| dataRdb | getRdbStore(config: StoreConfig, version: number): Promise<RdbStore> | Obtains an RDB store. This method uses a promise to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.
- **config**: configuration of the RDB store.
- **version**: RDB version.|
-| dataRdb | deleteRdbStore(name: string, callback: AsyncCallback<void>): void | Deletes an RDB store. This method uses a callback to return the result.
- **name**: RDB store to delete.
- **callback**: callback invoked to return the result. If the RDB store is deleted, **true** will be returned. Otherwise, **false** will be returned.|
-| dataRdb | deleteRdbStore(name: string): Promise<void> | Deletes an RDB store. This method uses a promise to return the result.
- **name**: RDB store to delete.|
+| API| Description|
+| -------- | -------- |
+|getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void | Obtains an RDB store. This method uses a callback to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.
- **config**: configuration of the RDB store.
- **version**: RDB version.
- **callback**: callback invoked to return the RDB store obtained.|
+|getRdbStore(config: StoreConfig, version: number): Promise<RdbStore> | Obtains an RDB store. This method uses a promise to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.
- **config**: configuration of the RDB store.
- **version**: RDB version.|
+|deleteRdbStore(name: string, callback: AsyncCallback<void>): void | Deletes an RDB store. This method uses a callback to return the result.
- **name**: RDB store to delete.
- **callback**: callback invoked to return the result. If the RDB store is deleted, **true** will be returned. Otherwise, **false** will be returned.|
+| deleteRdbStore(name: string): Promise<void> | Deletes an RDB store. This method uses a promise to return the result.
- **name**: RDB store to delete.|
**Managing Data in an RDB Store**
The RDB provides APIs for inserting, deleting, updating, and querying data in the local RDB store.
-- **Inserting data**
+- **Inserting data**
The RDB provides APIs for inserting data through a **ValuesBucket** in a data table. If the data is inserted, the row ID of the data inserted will be returned; otherwise, **-1** will be returned.
+
**Table 2** APIs for inserting data
| Class| API| Description|
@@ -33,7 +34,7 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
| RdbStore | insert(name: string, values: ValuesBucket, callback: AsyncCallback<number>):void | Inserts a row of data into a table. This method uses a callback to return the result.
- **name**: name of the target table.
- **values**: data to be inserted into the table.
- **callback**: callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
| RdbStore | insert(name: string, values: ValuesBucket): Promise<number> | Inserts a row of data into a table. This method uses a promise to return the result.
- **name**: name of the target table.
- **values**: data to be inserted into the table.|
-- **Updating data**
+- **Updating data**
Call the **update()** method to pass new data and specify the update conditions by using **RdbPredicates**. If the data is updated, the number of rows of the updated data will be returned; otherwise, **0** will be returned.
**Table 3** APIs for updating data
@@ -43,7 +44,7 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
| RdbStore | update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.
- **values**: data to update, which is stored in a **ValuesBucket**.
- **rdbPredicates**: conditions for updating data.
- **callback**: callback invoked to return the number of rows updated.|
| RdbStore | update(values: ValuesBucket, rdbPredicates: RdbPredicates): Promise | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result.
- **values**: data to update, which is stored in a **ValuesBucket**.
- **rdbPredicates**: conditions for updating data.|
-- **Deleting data**
+- **Deleting data**
Call the **delete()** method to delete data meeting the conditions specified by **RdbPredicates**. If the data is deleted, the number of rows of the deleted data will be returned; otherwise, **0** will be returned.
**Table 4** APIs for deleting data
@@ -53,7 +54,7 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
| RdbStore | delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.
- **rdbPredicates**: conditions for deleting data.
- **callback**: callback invoked to return the number of rows deleted.|
| RdbStore | delete(rdbPredicates: RdbPredicates): Promise | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result.
- **rdbPredicates**: conditions for deleting data.|
-- **Querying data**
+- **Querying data**
You can query data in an RDB store in either of the following ways:
- Call the **query()** method to query data based on the predicates, without passing any SQL statement.
@@ -76,42 +77,42 @@ The RDB provides **RdbPredicates** for you to set database operation conditions.
| Class| API| Description|
| -------- | -------- | -------- |
-| RdbPredicates |inDevices(devices: Array): RdbPredicates | Specifies remote devices on the network with RDB stores to be synchronized.
- **devices**: IDs of the remote devices on the network.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates |inAllDevices(): RdbPredicates | Connects to all remote devices on the network with RDB stores to be synchronized.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | equalTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | notEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | beginWrap(): RdbPredicates | Adds a left parenthesis to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with a left parenthesis. |
-| RdbPredicates | endWrap(): RdbPredicates | Adds a right parenthesis to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with a right parenthesis. |
-| RdbPredicates | or(): RdbPredicates | Adds the OR condition to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with the OR condition. |
-| RdbPredicates | and(): RdbPredicates | Adds the AND condition to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with the AND condition. |
-| RdbPredicates | contains(field: string, value: string): RdbPredicats | Sets the **RdbPredicates** to match a string containing the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified string. |
-| RdbPredicates | beginsWith(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that starts with the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified string. |
-| RdbPredicates | endsWith(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that ends with the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified string. |
-| RdbPredicates | isNull(field: string): RdbPredicates | Sets the **RdbPredicates** to match the field whose value is null.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | isNotNull(field: string): RdbPredicates | Sets the **RdbPredicates** to match the field whose value is not null.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | like(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that is similar to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified string. |
-| RdbPredicates | glob(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match the specified string.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified string. |
-| RdbPredicates | between(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value within the specified range.
- **field**: column name in the database table.
- **low**: minimum value that matches the **RdbPredicates**.
- **high**: maximum value that matches the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value out of the specified range.
- **field**: column name in the database table.
- **low**: minimum value that matches the **RdbPredicates**.
- **high**: maximum value that matches the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | greaterThan(field: string, value: ValueType): RdbPredicatesgr | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | lessThan(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than or equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than or equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | orderByAsc(field: string): RdbPredicates | Sets the **RdbPredicates** to match the column with values sorted in ascending order.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that sorts the values in ascending order. |
-| RdbPredicates | orderByDesc(field: string): RdbPredicates | Sets the **RdbPredicates** to match the column with values sorted in descending order.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that sorts the values in descending order. |
-| RdbPredicates | distinct(): RdbPredicates | Sets the **RdbPredicates** to filter out duplicate records.
- **RdbPredicates**: returns a **RdbPredicates** object that can filter out duplicate records. |
-| RdbPredicates | limitAs(value: number): RdbPredicates | Sets the **RdbPredicates** to specify the maximum number of records.
- **value**: maximum number of records.
- **RdbPredicates**: returns a **RdbPredicates** object that can be used to set the maximum number of records. |
-| RdbPredicates | offsetAs(rowOffset: number): RdbPredicates | Sets the **RdbPredicates** to specify the start position of the returned result.
- **rowOffset**: start position of the returned result. The value is a positive integer.
- **RdbPredicates**: returns a **RdbPredicates** object that specifies the start position of the returned result. |
-| RdbPredicates | groupBy(fields: Array<string>): RdbPredicates | Sets the **RdbPredicates** to group rows that have the same value into summary rows.
- **fields**: names of the columns grouped for querying data.
- **RdbPredicates**: returns a **RdbPredicates** object that groups rows with the same value. |
-| RdbPredicates | indexedBy(indexName: string): RdbPredicates | Sets the **RdbPredicates** to specify the index column.
- **indexName**: name of the index column.
- **RdbPredicates**: returns a **RdbPredicates** object that specifies the index column. |
-| RdbPredicates | in(field: string, value: Array<ValueType>): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array<ValueType>** and value within the specified range.
- **field**: column name in the database table.
- **value**: array of **ValueType** to match.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
-| RdbPredicates | notIn(field: string, value: Array<ValueType>): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array<ValueType>** and value out of the specified range.
- **field**: column name in the database table.
- **value**: array of **ValueType** to match.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
+| RdbPredicates |inDevices(devices: Array): RdbPredicates | Specifies remote devices on the network with RDB stores to be synchronized.
- **devices**: IDs of the remote devices on the network.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates |inAllDevices(): RdbPredicates | Connects to all remote devices on the network with RDB stores to be synchronized.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | equalTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | notEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | beginWrap(): RdbPredicates | Adds a left parenthesis to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with a left parenthesis.|
+| RdbPredicates | endWrap(): RdbPredicates | Adds a right parenthesis to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with a right parenthesis.|
+| RdbPredicates | or(): RdbPredicates | Adds the OR condition to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with the OR condition.|
+| RdbPredicates | and(): RdbPredicates | Adds the AND condition to the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** with the AND condition.|
+| RdbPredicates | contains(field: string, value: string): RdbPredicats | Sets the **RdbPredicates** to match a string containing the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified string.|
+| RdbPredicates | beginsWith(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that starts with the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | endsWith(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that ends with the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | isNull(field: string): RdbPredicates | Sets the **RdbPredicates** to match the field whose value is null.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | isNotNull(field: string): RdbPredicates | Sets the **RdbPredicates** to match the field whose value is not null.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | like(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that is similar to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | glob(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match the specified string.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | between(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value within the specified range.
- **field**: column name in the database table.
- **low**: minimum value that matches the **RdbPredicates**.
- **high**: maximum value that matches the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value out of the specified range.
- **field**: column name in the database table.
- **low**: minimum value that matches the **RdbPredicates**.
- **high**: maximum value that matches the **RdbPredicates**.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | greaterThan(field: string, value: ValueType): RdbPredicatesgr | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | lessThan(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than or equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than or equal to the specified value.
- **field**: column name in the database table.
- **value**: value specified.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | orderByAsc(field: string): RdbPredicates | Sets the **RdbPredicates** to match the column with values sorted in ascending order.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | orderByDesc(field: string): RdbPredicates | Sets the **RdbPredicates** to match the column with values sorted in descending order.
- **field**: column name in the database table.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | distinct(): RdbPredicates | Sets the **RdbPredicates** to filter out duplicate records.
- **RdbPredicates**: returns a **RdbPredicates** object that can filter out duplicate records.|
+| RdbPredicates | limitAs(value: number): RdbPredicates | Sets the **RdbPredicates** to specify the maximum number of records.
- **value**: maximum number of records.
- **RdbPredicates**: returns a **RdbPredicates** object that can be used to set the maximum number of records.|
+| RdbPredicates | offsetAs(rowOffset: number): RdbPredicates | Sets the **RdbPredicates** to specify the start position of the returned result.
- **rowOffset**: start position of the returned result. The value is a positive integer.
- **RdbPredicates**: returns a **RdbPredicates** object that specifies the start position of the returned result.|
+| RdbPredicates | groupBy(fields: Array<string>): RdbPredicates | Sets the **RdbPredicates** to group rows that have the same value into summary rows.
- **fields**: names of the columns grouped for querying data.
- **RdbPredicates**: returns a **RdbPredicates** object that groups rows with the same value.|
+| RdbPredicates | indexedBy(indexName: string): RdbPredicates | Sets the **RdbPredicates** to specify the index column.
- **indexName**: name of the index column.
- **RdbPredicates**: returns a **RdbPredicates** object that specifies the index column.|
+| RdbPredicates | in(field: string, value: Array<ValueType>): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array<ValueType>** and value within the specified range.
- **field**: column name in the database table.
- **value**: array of **ValueType** to match.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | notIn(field: string, value: Array<ValueType>): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array<ValueType>** and value out of the specified range.
- **field**: column name in the database table.
- **value**: array of **ValueType** to match.
- **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
**Using the Result Set**
A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**.
->  **NOTICE**
+>  **NOTICE**
> After a result set is used, you must call the **close()** method to close it explicitly.
**Table 7** APIs for using the result set
@@ -206,12 +207,12 @@ You can obtain the distributed table name for a remote device based on the local
The sample code is as follows:
```
- import dataRdb from '@ohos.data.rdb';
+ import data_rdb from '@ohos.data.rdb'
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
const STORE_CONFIG = {name: "rdbstore.db",}
- let rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
+ let rdbStore = await data_rdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST);
```
@@ -235,7 +236,7 @@ You can obtain the distributed table name for a remote device based on the local
The sample code is as follows:
```
- let predicates = new dataRdb.RdbPredicates("test");
+ let predicates = new data_rdb.RdbPredicates("test");
predicates.equalTo("name", "Tom")
let resultSet = await rdbStore.query(predicates)
@@ -272,7 +273,7 @@ You can obtain the distributed table name for a remote device based on the local
The sample code is as follows:
```
- let predicate = new dataRdb.RdbPredicates('test')
+ let predicate = new data_rdb.RdbPredicates('test')
predicate.inDevices(['12345678abcde'])
let promise = rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicate)
promise.then(result) {
diff --git a/en/application-dev/device-usage-statistics/Readme-EN.md b/en/application-dev/device-usage-statistics/Readme-EN.md
new file mode 100644
index 0000000000000000000000000000000000000000..75cfad35e1f36bfe07f0cb408c936f87e0ee520a
--- /dev/null
+++ b/en/application-dev/device-usage-statistics/Readme-EN.md
@@ -0,0 +1,4 @@
+# Device Usage Statistics
+
+- [Device Usage Statistics Overview](device-usage-statistics-overview.md)
+- [Device Usage Statistics Development](device-usage-statistics-dev-guide.md)
diff --git a/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md b/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
new file mode 100644
index 0000000000000000000000000000000000000000..ed6d64d2f532114c44220f493fcdce9180d0aa1f
--- /dev/null
+++ b/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
@@ -0,0 +1,207 @@
+## Device Usage Statistics Development
+
+## When to Use
+
+With device usage statistics APIs, you can have a better understanding of the application, notification, and system usage. For example, in application usage statistics, you can query the application usage, event log, and bundle group.
+The application records (usage history statistics and event records) cached by components are updated to the database for persistent storage within 30 minutes after an event is reported.
+
+## Available APIs
+Import the **stats** package to implement registration:
+```js
+import stats from '@ohos.bundleState';
+```
+
+**Table 1** Major APIs for device usage statistics
+
+| API| Description|
+| -------- | -------- |
+| function queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void | Queries events of all applications based on the specified start time and end time.|
+| function queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<BundleActiveInfoResponse>): void | Queries the application usage duration statistics based on the specified start time and end time.|
+| function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void | Queries events of this application based on the specified start time and end time.|
+| function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback<Array<BundleStateInfo>>): void | Queries the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually).|
+| function queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void | Queries the priority group of the current invoker application.|
+| function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void | Checks whether the application specified by **bundleName** is in the idle state. |
+
+## How to Develop
+
+1. Configure the device usage statistics permission in the **config.json** file.
+
+ ```json
+ "module": {
+ "package": "com.example.deviceUsageStatistics",
+ ...,
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.BUNDLE_ACTIVE_INFO"
+ }
+ ]
+ }
+ ```
+
+2. Query events of all applications based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file.
+
+ ```js
+ import stats from '@ohos.bundleState'
+
+ // Use a promise to return the result.
+ stats.queryBundleActiveStates(0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates promise number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates promise result ' + JSON.stringify(res[i]));
+ }
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code);
+ });
+
+ // Use an asynchronous callback to return the result.
+ stats.queryBundleActiveStates(0, 20000000000000, (err, res) => {
+ if(err.code == 0) {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i]));
+ }
+ } else {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
+ }
+ });
+ ```
+
+3. Query the application usage duration statistics based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file.
+
+ ```js
+ import stats from '@ohos.bundleState'
+
+ // Use a promise to return the result.
+ stats.queryBundleStateInfos(0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.');
+ let i = 1;
+ for(let key in res){
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos promise number : ' + i);
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key]));
+ i++;
+ }
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code);
+ });
+
+ // Use an asynchronous callback to return the result.
+ stats.queryBundleStateInfos(0, 20000000000000, (err, res) => {
+ if(err.code == 0) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.');
+ let i = 1;
+ for(let key in res){
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos callback number : ' + i);
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key]));
+ i++;
+ }
+ } else {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
+ }
+ });
+ ```
+
+4. Query events of this application based on the specified start time and end time. This requires no permission to be configured in the **config.json** file.
+
+ ```js
+ import stats from '@ohos.bundleState'
+
+ // Use a promise to return the result.
+ stats.queryCurrentBundleActiveStates(0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise result ' + JSON.stringify(res[i]));
+ }
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code);
+ });
+
+ // Use an asynchronous callback to return the result.
+ stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => {
+ if(err.code == 0) {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i]));
+ }
+ } else {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
+ }
+ });
+ ```
+
+5. Query the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually). This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file.
+
+ ```js
+ import stats from '@ohos.bundleState'
+
+ // Use a promise to return the result.
+ stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise result ' + JSON.stringify(res[i]));
+ }
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code);
+ });
+
+ // Use an asynchronous callback to return the result.
+ stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => {
+ if(err.code == 0) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i]));
+ }
+ } else {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
+ }
+ });
+ ```
+
+6. Query the priority group of the current invoker application. This requires no permission to be configured in the **config.json** file.
+
+ ```js
+ import stats from '@ohos.bundleState'
+
+ // Use a promise to return the result.
+ stats.queryAppUsagePriorityGroup().then( res => {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
+ });
+
+ // Use an asynchronous callback to return the result.
+ stats.queryAppUsagePriorityGroup((err, res) => {
+ if(err.code === 0) {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
+ } else {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
+ }
+ });
+ ```
+
+7. Check whether the application specified by **bundleName** is in the idle state. This requires no permission to be configured in the **config.json** file.
+
+ ```js
+ import stats from '@ohos.bundleState'
+
+ // Use a promise to return the result.
+ stats.isIdleState("com.ohos.camera").then( res => {
+ console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res));
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code);
+ });
+
+ // Use an asynchronous callback to return the result.
+ stats.isIdleState("com.ohos.camera", (err, res) => {
+ if(err.code === 0) {
+ console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
+ } else {
+ console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code);
+ }
+ });
+ ```
diff --git a/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md b/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
new file mode 100644
index 0000000000000000000000000000000000000000..b34bd46548c94779dfa35ba21f1d7a5ea9ad01c3
--- /dev/null
+++ b/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
@@ -0,0 +1,24 @@
+# Device Usage Statistics Overview
+
+With device usage statistics APIs, you can have a better understanding of the application, notification, and system usage. In application usage statistics, you can query the application usage, event log, and bundle group. The application records (usage history statistics and event records) cached by components are updated to the database for persistent storage within 30 minutes after an event is reported.
+
+## Introduction
+
+Currently you can have access to statistics on the application usage, and notification and system usage statistics feature will be available for use in later versions.
+
+- **The application usage statistics is updated**:
+>1. Every 30 minutes
+>2. Upon system time change
+>3. Upon start of a new day
+
+- **The application usage statistics can include the following**:
+>1. Events of all applications based on the specified start time and end time
+>2. Application usage duration statistics based on the specified start time and end time
+>3. Events of the current application based on the specified start time and end time
+>4. Application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually)
+>5. Priority group of the current invoker application
+>6. Whether a specific application is in the idle state
+
+### Required Permissions
+- The **queryBundleActiveStates**, **queryBundleStateInfos**, and **queryBundleStateInfoByInterval** APIs used for device usage statistics are system APIs. Before calling these APIs, you need to apply for the **ohos.permission.BUNDLE_ACTIVE_INFO** permission.
+- This permission is not required for calling **queryCurrentBundleActiveStates**, **queryAppUsagePriorityGroup**, and **isIdleState**, which are third-party APIs.
diff --git a/en/application-dev/device/figures/en-us_image_0000001196654004.png b/en/application-dev/device/figures/en-us_image_0000001196654004.png
new file mode 100644
index 0000000000000000000000000000000000000000..48b1613b6e67f2dd57cd480fdb7fd0312594e049
Binary files /dev/null and b/en/application-dev/device/figures/en-us_image_0000001196654004.png differ
diff --git a/en/application-dev/device/figures/en-us_image_0000001226521897.png b/en/application-dev/device/figures/en-us_image_0000001226521897.png
new file mode 100644
index 0000000000000000000000000000000000000000..a97bd3bfbcf21cc091ee69cee0b6759b2e864116
Binary files /dev/null and b/en/application-dev/device/figures/en-us_image_0000001226521897.png differ
diff --git a/en/application-dev/device/figures/en-us_image_0000001241693881.png b/en/application-dev/device/figures/en-us_image_0000001241693881.png
new file mode 100644
index 0000000000000000000000000000000000000000..5c54c71606ce2f81308923d8d4c579f1b9b3ad3c
Binary files /dev/null and b/en/application-dev/device/figures/en-us_image_0000001241693881.png differ
diff --git a/en/application-dev/device/figures/en-us_image_0000001241733907.png b/en/application-dev/device/figures/en-us_image_0000001241733907.png
new file mode 100644
index 0000000000000000000000000000000000000000..d0a680b7138b81e6e9a1e598634b66dd598dd603
Binary files /dev/null and b/en/application-dev/device/figures/en-us_image_0000001241733907.png differ
diff --git a/en/application-dev/device/sensor-guidelines.md b/en/application-dev/device/sensor-guidelines.md
new file mode 100644
index 0000000000000000000000000000000000000000..88d24d59bc4885135b92302c3446c7c81bd33d5d
--- /dev/null
+++ b/en/application-dev/device/sensor-guidelines.md
@@ -0,0 +1,133 @@
+# Sensor Development
+
+
+## When to Use
+
+- Data provided by the compass sensor denotes the current orientation of the user device, which helps your application accurately navigate for the user.
+
+- Data provided by the proximity sensor denotes the distance between the device and a visible object, which enables the device to automatically turn on or off its screen accordingly to prevent accidental touch on the screen.
+
+- Data provided by the barometer sensor helps your application accurately determine the altitude of the device.
+
+- Data provided by the ambient light sensor helps your device automatically adjust its backlight.
+
+- Data provided by the Hall effect sensor implements the smart cover mode of your device.
+
+- Data provided by the heart rate sensor helps your application track the health of a user.
+
+- Data provided by the pedometer sensor helps your application obtain the number steps a user has walked.
+
+- Data provided by the wear detection sensor helps your application detect whether a user is wearing a wearable device.
+
+
+## Available APIs
+
+ | Module | API | Description |
+| -------- | -------- | -------- |
+| ohos.sensor | sensor.on(sensorType,callback:AsyncCallback<Response>):void | Subscribes to data changes of a type of sensor. |
+| ohos.sensor | sensor.once(sensorType,callback:AsyncCallback<Response>):void | Subscribes to only one data change of a type of sensor. |
+| ohos.sensor | sensor.off(sensorType,callback:AsyncCallback<void>):void | Unsubscribes from sensor data changes. |
+
+
+## How to Develop
+
+1. To obtain data from a type of sensor, configure the request permissions in the **config.json** file.
+
+ ```
+ "reqPermissions":[
+ {
+ "name":"ohos.permission.ACCELEROMETER",
+ "reason"":"",
+ "usedScene":{
+ "ability": ["sensor.index.MainAbility",".MainAbility"],
+ "when":"inuse"
+ }
+ },
+ {
+ "name":"ohos.permission.GYROSCOPE",
+ "reason"":"",
+ "usedScene":{
+ "ability": ["sensor.index.MainAbility",".MainAbility"],
+ "when":"inuse"
+ }
+ },
+ {
+ "name":"ohos.permission.ACTIVITY_MOTION",
+ "reason"":"ACTIVITY_MOTION_TEST",
+ "usedScene":{
+ "ability": ["sensor.index.MainAbility",".MainAbility"],
+ "when":"inuse"
+ }
+ },
+ {
+ "name":"ohos.permission.READ_HEALTH_DATA",
+ "reason"":"HEALTH_DATA_TEST",
+ "usedScene":{
+ "ability": ["sensor.index.MainAbility",".MainAbility"],
+ "when":"inuse"
+ }
+ },
+ {
+ "name":"ohos.permission.VIBRATE",
+ "reason"":"",
+ "usedScene":{
+ "ability": [".MainAbility"],
+ "when":"inuse"
+ }
+ },
+ ]
+ ```
+
+2. Subscribe to data changes of a type of sensor.
+
+ ```
+ import sensor from "@ohos.sensor"
+ sensor.on(type:sensorType,function(error,data){
+ if (error) {// The call fails, and error.code and error.message are printed.
+ console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
+ return;
+ };
+ console.info("Subscription succeeded. data = "+ data);// The call is successful, and the obtained sensor data is printed.
+ }
+ );
+ ```
+
+ The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**.
+
+ 
+
+3. Unsubscribe from sensor data changes.
+
+ ```
+ import sensor from "@ohos.sensor"
+ sensor.off(type:sensorType,function(error) {
+ if (error) {// The unsubscription fails, and error.code and error.message are printed.
+ console.error("Failed to unsubscribe from acceleration sensor data. Error code: " + error.code + "; message: " + error.message);
+ return;
+ };
+ console.info("Succeeded in unsubscribing from acceleration sensor data.");// The unsubscription is successful, and the result is printed.
+ }
+ );
+ ```
+
+ The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**.
+
+ 
+
+4. Subscribe to only one data change of a type of sensor.
+
+ ```
+ import sensor from "@ohos.sensor"
+ sensor.once(tyep:sensorType,function(error, data) {
+ if (error) {// The call fails, and error.code and error.message are printed.
+ console.error("Failed to obtain data. Error code: " + error.code + "; message: " + error.message);
+ return;
+ };
+ console.info("Data obtained successfully. data="+data);// The call is successful, and the obtained sensor data is printed.
+ }
+ );
+ ```
+
+ The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**.
+
+ 
diff --git a/en/application-dev/device/sensor-overview.md b/en/application-dev/device/sensor-overview.md
new file mode 100644
index 0000000000000000000000000000000000000000..ea75d0b5dfc4a0611d118d5ddb9fbbaac1345bc5
--- /dev/null
+++ b/en/application-dev/device/sensor-overview.md
@@ -0,0 +1,111 @@
+# Sensor Overview
+
+
+Sensors in OpenHarmony are an abstraction of underlying hardware-based sensors. Your application can access the underlying sensors via OpenHarmony sensors. Using the APIs provided by OpenHarmony sensors, you can query sensors on your device, subscribe to sensor data, customize algorithms based on sensor data, and develop various sensor-based applications, such as compass, fitness and health, and games applications.
+
+
+The sensors are classified into the following categories based on their functions: motion, environment, orientation, light, body, and other categories (such as Hall effect sensors). Each category includes different sensor types. A sensor type may be a single physical sensor or a composite of multiple physical sensors.
+
+
+ **Table1** Motion - ohos.sensor.agent.CategoryMotionAgent
+
+| Sensor Type | Sensor Name | Description | Usage |
+| -------- | -------- | -------- | -------- |
+| SENSOR_TYPE_ACCELEROMETER | Acceleration sensor | Measures the acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2. | Detecting the motion status |
+| SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | Uncalibrated acceleration sensor | Measures the uncalibrated acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2. | Measuring the acceleration bias estimation |
+| SENSOR_TYPE_LINEAR_ACCELERATION | Linear acceleration sensor | Measures the linear acceleration (excluding the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2. | Detecting the linear acceleration in each axis |
+| SENSOR_TYPE_GRAVITY | Gravity sensor | Measures the gravity acceleration applied to a device on three physical axes (X, Y, and Z), in the unit of m/s2. | Measuring the gravity |
+| SENSOR_TYPE_GYROSCOPE | Gyroscope sensor | Measures the rotation angular velocity of a device on three physical axes (X, Y, and Z), in the unit of rad/s. | Measuring the rotation angular velocity |
+| SENSOR_TYPE_GYROSCOPE_UNCALIBRATED | Uncalibrated gyroscope sensor | Measures the uncalibrated rotation angular velocity of a device on three physical axes (X, Y, and Z), in the unit of rad/s. | Measuring the bias estimation of the rotation angular velocity |
+| SENSOR_TYPE_SIGNIFICANT_MOTION | Significant motion sensor | Checks whether a device has a significant motion on three physical axes (X, Y, and Z). The value can be **0** (having no significant motion) or **1** (having a significant motion). | Detecting significant motions of a device |
+| SENSOR_TYPE_DROP_DETECTION | Drop detection sensor | Detects the device drop status. The value can be **0** (the device is not dropped) or **1** (the device is dropped). | Detecting whether a device is dropped |
+| SENSOR_TYPE_PEDOMETER_DETECTION | Pedometer detection sensor | Detects whether a user takes a step. The value can be **0** (the user does not take a step) or **1** (the user takes a step). | Detecting whether a user takes a step |
+| SENSOR_TYPE_PEDOMETER | Pedometer sensor | Records the number of steps a user has walked. | Providing the number of steps a user has walked |
+
+
+ **Table2** Environment - ohos.sensor.agent.CategoryOrientationAgent
+
+| Sensor Type | Sensor Name | Description | Usage |
+| -------- | -------- | -------- | -------- |
+| SENSOR_TYPE_AMBIENT_TEMPERATURE | Ambient temperature sensor. | Measures the ambient temperature, in the unit of degree Celsius (°C). | Measuring the ambient temperature |
+| SENSOR_TYPE_MAGNETIC_FIELD | Magnetic field sensor | Measures the magnetic field on three physical axes (X, Y, and Z), in the unit of μT. | Creating a compass |
+| SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED | Uncalibrated magnetic field sensor | Measures the uncalibrated magnetic field on three physical axes (X, Y, and Z), in the unit of μT. | Measuring the magnetic field bias estimation |
+| SENSOR_TYPE_HUMIDITY | Humidity sensor | Measures the ambient relative humidity, in a percentage (%). | Monitoring the dew point, absolute humidity, and relative humidity |
+| SENSOR_TYPE_BAROMETER | Barometer sensor | Measures the barometric pressure, in the unit of hPa or mbar. | Measuring the barometric pressure |
+| SENSOR_TYPE_SAR | Specific Absorption Rate (SAR) sensor | Measures the SAR, in the unit of W/kg. | Measuring the SAR of electromagnetic waves for a device |
+
+
+ **Table3** Orientation - ohos.sensor.agent.CategoryOrientationAgent
+
+| Sensor Type | Sensor Name | Description | Usage |
+| -------- | -------- | -------- | -------- |
+| SENSOR_TYPE_6DOF | Degrees of Freedom (DoF) sensor | Measures the forward/backward, up/down, and left/right translational movement of a device on the three axes (X, Y, and Z) in the unit of m or mm as well as the roll, pitch, and yaw rotation angles on the three axes (X, Y, and Z) in the unit of rad. | Positioning an object by detecting its freedom of translational and rotational motions, for example, VR |
+| SENSOR_TYPE_SCREEN_ROTATION | Screen rotation sensor | Checks the rotation status of the device screen. | Detecting whether the device screen is rotating |
+| SENSOR_TYPE_DEVICE_ORIENTATION | Device orientation sensor | Measures the rotation angles of the device, in the unit of rad. | Measuring the angles that a device has rotated |
+| SENSOR_TYPE_ORIENTATION | Orientation sensor | Measures the rotation angles of a device on three physical axes (X, Y, and Z), in the unit of rad. | Providing the three orientation angles of the screen |
+| SENSOR_TYPE_ROTATION_VECTOR | Rotation vector sensor | Measures the rotation vector of a device. It is a composite sensor that generates data from the acceleration sensor, magnetic field sensor, and gyroscope sensor. | Detecting the orientation of a device in the East, North, Up (ENU) Cartesian coordinate system |
+| SENSOR_TYPE_GAME_ROTATION_VECTOR
SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR | Game rotation vector sensor
Geomagnetic rotation vector sensor | Measures the game rotation vector of a device. It is a composite sensor that generates data from the acceleration sensor and gyroscope sensor.
Measures the geomagnetic rotation vector of a device. It is a composite sensor that generates data from the acceleration sensor and magnetic field sensor. | Applied in games
Measuring the geomagnetic rotation vector |
+
+
+ **Table4** Light - ohos.sensor.agent.CategoryLightAgent
+
+| Sensor Type | Sensor Name | Description | Usage |
+| -------- | -------- | -------- | -------- |
+| SENSOR_TYPE_PROXIMITY | Proximity sensor | Measures the distance between a visible object and the device screen. | Measuring the distance between a person and the device during a call |
+| SENSOR_TYPE_TOF | Time of flight (ToF) sensor | Measures the time required for light to travel a distance in the medium. | Facial recognition |
+| SENSOR_TYPE_AMBIENT_LIGHT | Ambient light sensor | Measures the ambient light intensity of a device, in the unit of lux. | Automatically adjusting the screen brightness and checking whether the screen is covered on the top |
+| SENSOR_TYPE_COLOR_TEMPERATURE | Color temperature sensor | Measures the ambient color temperature. | Image processing on the device |
+| SENSOR_TYPE_COLOR_RGB | RGB color sensor | Measures the ambient RGB color values. | Color detection implemented by the reflectance of RGB colors |
+| SENSOR_TYPE_COLOR_XYZ | XYZ color sensor | Measures the ambient XYZ color values. | Identifying true-color spots to reproduce more natural colors |
+
+
+ **Table5** Body - ohos.sensor.agent.CategoryBodyAgent
+
+| Sensor Type | Sensor Name | Description | Usage |
+| -------- | -------- | -------- | -------- |
+| SENSOR_TYPE_HEART_RATE | Heart rate sensor | Measures the heart rate of a user. | Providing users' heart rate data |
+| SENSOR_TYPE_WEAR_DETECTION | Wear detection sensor | Checks whether a user is wearing a wearable device. | Detecting wearables |
+
+
+ **Table6** Others
+
+| Sensor Type | Sensor Name | Description | Usage |
+| -------- | -------- | -------- | -------- |
+| SENSOR_TYPE_HALL | Hall effect sensor | Detects a magnetic field around a device. | Smart cover mode of the device |
+| SENSOR_TYPE_GRIP_DETECTOR | Grip detection sensor | Detects grip force applied on a device. | Detecting whether the device is gripped on its sides |
+| SENSOR_TYPE_MAGNET_BRACKET | Magnet bracket sensor | Checks whether a device is magnetized. | Detecting an in-vehicle or indoor device |
+| SENSOR_TYPE_PRESSURE_DETECTOR | Pressure detection sensor | Detects pressure force applied on a device. | Detecting pressure on the top of the device |
+
+
+## How a Service Is Shared Using Huawei Share
+
+The following modules work cooperatively to implement OpenHarmony sensors: Sensor API, Sensor Framework, Sensor Service, and HD_IDL.
+
+ **Figure1** Working principles for OpenHarmony sensors
+ 
+
+- Sensor API: provides APIs for performing basic operations on sensors, including querying the sensor list, subscribing to or unsubscribing from sensor data, and executing control commands. This module makes application development simpler.
+
+- Sensor Framework: manages sensor data subscription, creates and destroys data channels, subscribes to or unsubscribes from sensor data, and implements communication with the Sensor Service module.
+
+- Sensor Service: interacts with the HD_IDL module to receive, parse, and distribute data, manages foreground and background policies and sensors of a device, and controls sensor permissions.
+
+- HD_IDL: selects proper policies based on the hardware first in first out (FIFO) and frequency, and adapts to different devices.
+
+
+## Limitations and Constraints
+
+To obtain data of the following sensors, you must claim the required permissions.
+
+
+ **Table7** Sensor data permission
+
+| Sensor | Permission Name | Sensitivity | Permission Description |
+| -------- | -------- | -------- | -------- |
+| Acceleration sensor, uncalibrated acceleration sensor, and linear acceleration sensor | ohos.permission.ACCELEROMETER | system_grant | Allows your application to subscribe to data of these acceleration-related sensors in the motion category. |
+| Gyroscope sensor and uncalibrated gyroscope sensor | ohos.permission.GYROSCOPE | system_grant | Allows your application to subscribe to data of these gyroscope-related sensors in the motion category. |
+| Pedometer sensor | ohos.permission.ACTIVITY_MOTION | user_grant | Allows your application to subscribe to the motion status. |
+| Heart rate sensor | ohos.permission.READ_HEALTH_DATA | user_grant | Allows your application to read health data. |
+
+
+The APIs for subscribing to and unsubscribing from sensor data work in pairs. If you do not need sensor data, call the unsubscription API to stop sensor data reporting.
diff --git a/en/application-dev/media/image.md b/en/application-dev/media/image.md
new file mode 100644
index 0000000000000000000000000000000000000000..67472950556a999cbaed31279222c22087965f91
--- /dev/null
+++ b/en/application-dev/media/image.md
@@ -0,0 +1,272 @@
+# Image Development
+
+## When to Use
+
+You can use image development APIs to decode images into pixel maps and encode the pixel maps into a supported format.
+
+## Available APIs
+
+For details about the APIs, see [js-apis-image.md](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md).
+
+## How to Develop
+
+### Full-Process Scenario
+
+The full process includes creating an instance, reading image information, reading and writing pixel maps, updating data, packaging pixels, and releasing resources.
+
+```js
+const Color = new ArrayBuffer(96); // Create a buffer to store image pixel data.
+let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } } // Image pixel data.
+
+// Create a PixelMap object.
+const Color = new ArrayBuffer(96);
+let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } }
+ image.createPixelMap(Color, opts, pixelmap => {
+ expect(pixelmap !== null).assertTrue();
+ console.info('TC_001-1 success');
+ done();
+ })
+// Read pixels.
+ pixelmap.readPixels(area,(data) => {
+ if(data !== null) {
+ var bufferArr = new Uint8Array(area.pixels);
+ var res = true;
+ for (var i = 0; i < bufferArr.length; i++) {
+ console.info('TC_021-1 buffer ' + bufferArr[i]);
+ if(res) {
+ if(bufferArr[i] == 0) {
+ res = false;
+ console.info('TC_021-1 Success');
+ expect(true).assertTrue();
+ done();
+ break;
+ }
+ }
+ }
+
+// Store pixels.
+const readBuffer = new ArrayBuffer(96);
+pixelmap.readPixelsToBuffer(readBuffer,() => {
+var bufferArr = new Uint8Array(readBuffer);
+var res = true;
+for (var i = 0; i < bufferArr.length; i++) {
+ if(res) {
+ if (bufferArr[i] !== 0) {
+ res = false;
+ console.info('TC_020-1 Success');
+ expect(true).assertTrue();
+ done();
+ break;
+ }
+ }
+ }
+
+// Write pixels.
+pixelmap.writePixels(area,() => {
+ const readArea = { pixels: new ArrayBuffer(20), offset: 0, stride: 8, region: { size: { height: 1, width: 2 }, x: 0, y: 0 }}
+ pixelmap.readPixels(readArea,() => {
+ var readArr = new Uint8Array(readArea.pixels);
+ var res = true;
+ for (var i = 0; i < readArr.length; i++) {
+ if(res) {
+ if (readArr[i] !== 0) {
+ res = false;
+ console.info('TC_022-1 Success');
+ expect(true).assertTrue();
+ done();
+ break;
+ }
+ }
+ }
+
+// Write pixels to the buffer.
+ pixelmap.writeBufferToPixels(writeColor).then(() => {
+ const readBuffer = new ArrayBuffer(96);
+ pixelmap.readPixelsToBuffer(readBuffer).then (() => {
+ var bufferArr = new Uint8Array(readBuffer);
+ var res = true;
+ for (var i = 0; i < bufferArr.length; i++) {
+ if(res) {
+ if (bufferArr[i] !== i) {
+ res = false;
+ console.info('TC_023 Success');
+ expect(true).assertTrue()
+ done();
+ break;
+ }
+ }
+ }
+
+// Obtain image information.
+pixelmap.getImageInfo( imageInfo => {
+ if (imageInfo !== null) {
+ console.info('TC_024-1 imageInfo is ready');
+ expect(imageInfo.size.height == 4).assertTrue();
+ expect(imageInfo.size.width == 6).assertTrue();
+ expect(imageInfo.pixelFormat == 4).assertTrue();
+ done();
+ }
+ })
+
+// Release the PixelMap object.
+pixelmap.release(()=>{
+ expect(true).assertTrue();
+ console.log('TC_027-1 suc');
+ done();
+})
+
+// Create an image source (uri).
+const imageSourceApi = image.createImageSource(path);//'/data/local/tmp/test.jpg'
+
+// Create an image source (fd).
+const imageSourceApi = image.createImageSource(29);
+
+// Create an image source (data).
+const data = new ArrayBuffer(96);
+const imageSourceApi = image.createImageSource(data);
+
+// Release the image source.
+imageSourceApi.release(() => {
+ console.info('TC_044-1 Success');
+ })
+
+// Encode the image.
+const imagePackerApi = image.createImagePacker();
+imagePackerApi.packing(imageSourceApi, packOpts, data => {
+ console.info('TC_062-1 finished');
+ expect(data !== null).assertTrue();
+ done();
+ })
+
+// Release the ImagePacker object.
+imagePackerApi.release();
+```
+
+### Decoding Scenario
+
+```js
+/data/local/tmp/test.jpg // Set the path for creating an image source.
+
+// Create an image source using a path.
+const imageSourceApi = image.createImageSource(path);//'/data/local/tmp/test.jpg'
+
+// Set parameters.
+let decodingOptions = {
+ sampleSize:1, // Sampling size of the thumbnail.
+ editable: true, // Whether the image can be edited.
+ desiredSize:{ width:1, height:2}, // Desired output size of the image.
+ rotateDegrees:10, // Rotation angle of the image.
+ desiredPixelFormat:2, // Decoded pixel format.
+ desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 }, // Region of the image to decode.
+ index:0// Image sequence number.
+ };
+
+// Create a pixel map in callback mode.
+imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
+ console.info('TC_050 createPixelMap ');
+ expect(pixelmap !== null ).assertTrue();
+ done();
+ })
+}
+
+// Create a pixel map in promise mode.
+imageSourceApi.createPixelMap().then(pixelmap => {
+ console.info('TC_050-11 createPixelMap ');
+ expect(pixelmap !== null ).assertTrue();
+ done();
+})
+
+// Capture error information when an exception occurs during function invoking.
+catch(error => {
+ console.log('TC_050-11 error: ' + error);
+ expect().assertFail();
+ done();
+ })
+
+// Obtain the number of bytes in each line of pixels.
+pixelmap.getBytesNumberPerRow( num => {
+ console.info('TC_025-1 num is ' + num);
+ expect(num == expectNum).assertTrue();
+ done();
+})
+
+// Obtain the total number of pixel bytes.
+pixelmap.getPixelBytesNumber(num => {
+ console.info('TC_026-1 num is ' + num);
+ expect(num == expectNum).assertTrue();
+ done();
+ })
+
+// Obtain the pixel map information.
+ pixelmap.getImageInfo( imageInfo => {})
+
+// Print the failure information.
+console.info('TC_024-1 imageInfo is empty');
+expect(false).assertTrue()
+
+// Release the PixelMap object.
+pixelmap.release(()=>{
+ expect(true).assertTrue();
+ console.log('TC_027-1 suc');
+ done();
+ })
+
+// Capture release failure information.
+catch(error => {
+ console.log('TC_027-1 error: ' + error);
+ expect().assertFail();
+ done();
+ })
+```
+
+### Encoding Scenario
+
+```js
+/data/local/tmp/test.png // Set the path for creating an image source.
+
+// Set the image source.
+ const imageSourceApi = image.createImageSource(path);//'/data/local/tmp/test.png'
+
+// Print the error message if the image source fails to be created.
+if (imageSourceApi == null) {
+ console.info('TC_062 create image source failed');
+ expect(false).assertTrue();
+ done();
+ }
+
+// Create an image packer if the image source is successfully created.
+const imagePackerApi = image.createImagePacker();
+
+// Print the error information if the image packer fails to be created.
+if (imagePackerApi == null) {
+ console.info('TC_062 create image packer failed');
+ expect(false).assertTrue();
+ done();
+ }
+
+// Set encoding parameters if the image packer is successfully created.
+let packOpts = { format:["image/jpeg"], // The supported encoding format is jpg.
+ quality:98 }// Image quality, which ranges from 0 to 100.
+
+// Encode the image.
+imagePackerApi.packing(imageSourceApi, packOpts)
+.then( data => {
+ console.info('TC_062 finished');
+ expect(data !== null).assertTrue();
+ done();
+ })
+
+// Release the image packer after the encoding is complete.
+ imagePackerApi.release();
+
+// Obtain the image source information.
+imageSourceApi.getImageInfo(imageInfo => {
+ console.info('TC_045 imageInfo');
+ expect(imageInfo !== null).assertTrue();
+ done();
+ })
+
+// Update incremental data.
+imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> {})
+
+```
diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md
index b1e826787f33151f1dd4eba2ff2078c35cbaab9d..f9f0247e9fff7af42e5d4ba0e57bec7750d41fa5 100644
--- a/en/application-dev/reference/apis/Readme-EN.md
+++ b/en/application-dev/reference/apis/Readme-EN.md
@@ -79,6 +79,7 @@
- [WebGL](js-apis-webgl.md)
- [WebGL2](js-apis-webgl2.md)
- [Screenshot](js-apis-screenshot.md)
+ - [Accessibility](js-apis-accessibility.md)
- DFX
- [HiAppEvent](js-apis-hiappevent.md)
- [Performance Tracing](js-apis-hitracemeter.md)
@@ -109,4 +110,6 @@
- [Nonlinear Container TreeSet](js-apis-treeset.md)
- [Nonlinear Container LightWeightMap](js-apis-lightweightmap.md)
- [Nonlinear Container LightWeightSet](js-apis-lightweightset.md)
+- Custom Management
+ - [Configuration Policy](js-apis-config-policy.md)
diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md
index 8fc52e97652cd9755d7f2e3a2094913301cd5709..3f0d520d7045762ac01cd95a9c221c6d9bee5ff6 100644
--- a/en/application-dev/reference/apis/js-apis-Bundle.md
+++ b/en/application-dev/reference/apis/js-apis-Bundle.md
@@ -15,18 +15,22 @@ SystemCapability.BundleManager.BundleFramework
| Required Permissions| Permission Level| Description|
|-------| --------- | ---- |
| 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.|
## bundle.getApplicationInfo
-getApplicationInfo(bundleName: string, bundleFlags: number, userId: number): Promise\
+getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\
-Obtains the application information of the specified user based on a given bundle name in asynchronous mode. This method uses a promise to return the result.
+Obtains the application information based on a given bundle name. This method uses a promise to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -34,7 +38,7 @@ ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_IN
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| 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.|
-| 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 | 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**
@@ -62,11 +66,15 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId)
getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\): void
-Obtains the application information of the specified user based on a given bundle name in asynchronous mode. This method uses a callback to return the result.
+Obtains the application information based on a given bundle name. This method uses an asynchronous callback to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -93,16 +101,56 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => {
```
+## bundle.getApplicationInfo
+
+getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\): void
+
+Obtains the application information based on a given bundle name. This method uses an asynchronous callback to return the result.
+
+**Required permissions**
+
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------------------------------- | ---- | ------------------------------------------------------------ |
+| 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.|
+| callback | AsyncCallback\ | Yes | Callback used to return the application information. |
+
+**Example**
+
+```js
+let bundleName = "com.example.myapplication";
+let bundleFlags = 0;
+bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+ })
+```
+
## bundle.getAllBundleInfo
getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise>
-Obtains the information of all available bundles in the system in asynchronous mode. This method uses a promise to return the result.
+Obtains the information of all available bundles of a specified user in the system. This method uses a promise to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -136,11 +184,15 @@ bundle.getAllBundleInfo(bundleFlag, userId)
getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback>): void
-Obtains the information of all available bundles in the system in asynchronous mode. This method uses a callback to return the result.
+Obtains the information of all available bundles in the system. This method uses an asynchronous callback to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -167,11 +219,15 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => {
getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void
-Obtains the information of all available bundles in the system in asynchronous mode. This method uses a callback to return the result.
+Obtains the information of all available bundles in the system. This method uses an asynchronous callback to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -201,11 +257,15 @@ bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => {
getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\
-Obtains the bundle information based on a given bundle name in asynchronous mode. This method uses a promise to return the result.
+Obtains the bundle information based on a given bundle name. This method uses a promise to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -213,7 +273,7 @@ ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_IN
| ----------- | ------ | ---- | ------------------------------------------------------------ |
| 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.|
-| options | BundleOptions | No | Includes **userId** and **networkId**. |
+| options | BundleOptions | No | Includes **userId**. |
**Return value**
@@ -227,8 +287,7 @@ ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_IN
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
- "userId" : 100,
- "networkId" : null
+ "userId" : 100
};
bundle.getBundleInfo(bundleName, bundleFlags, options)
.then((data) => {
@@ -244,11 +303,15 @@ bundle.getBundleInfo(bundleName, bundleFlags, options)
getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\): void
-Obtains the bundle information based on a given bundle name in asynchronous mode. This method uses a callback to return the result.
+Obtains the bundle information based on a given bundle name. This method uses an asynchronous callback to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -277,11 +340,15 @@ bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => {
getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\): void
-Obtains the bundle information based on a given bundle name in asynchronous mode. This method uses a callback to return the result.
+Obtains the bundle information based on a given bundle name. This method uses an asynchronous callback to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -289,7 +356,7 @@ ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_IN
| ----------- | -------------------------- | ---- | ------------------------------------------------------------ |
| 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.|
-| options | BundleOptions | Yes | Includes **userId** and **networkId**. |
+| options | BundleOptions | Yes | Includes **userId**. |
| callback | AsyncCallback\ | Yes | Callback used to return the bundle information. |
**Example**
@@ -298,8 +365,7 @@ ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_IN
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
- "userId" : 100,
- "networkId" : null
+ "userId" : 100
};
bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => {
if (err) {
@@ -313,20 +379,24 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => {
## bundle.getAllApplicationInfo
-getAllApplicationInfo(bundleFlags: number, userId: number): Promise>
+getAllApplicationInfo(bundleFlags: number, userId?: number): Promise>
Obtains the information about all applications of the specified user. This method uses a promise to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
| 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.|
-| 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 | 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**
@@ -353,18 +423,22 @@ bundle.getAllApplicationInfo(bundleFlags, userId)
getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback>): void
-Obtains the information about all installed applications of the specified user. This method uses a callback to return the result.
+Obtains the information about all applications of the specified user. This method uses an asynchronous callback to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
| 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.|
-| 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 | 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> | Yes | Callback used to return the application information. |
**Example**
@@ -382,16 +456,356 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
```
+## bundle.getAllApplicationInfo
+
+function getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>) : void;
+
+Obtains the information about all applications. This method uses an asynchronous callback to return the result.
+
+**Required permissions**
+
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| 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.|
+| callback | AsyncCallback> | Yes | Callback used to return the application information. |
+
+**Example**
+
+```js
+let bundleFlags = 8;
+bundle.getAllApplicationInfo(bundleFlags, (err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+})
+```
+
+## bundle.getAbilityInfo
+
+getAbilityInfo(bundleName: string, abilityName: string): Promise\
+
+Obtains the ability information based on a given want. This method uses a promise to return the result.
+
+**Required permissions**
+
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | -------------------------------------------------------- |
+| bundleName | string | Yes | Bundle name of the application. |
+| abilityName | string | Yes | Name of the ability.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------- | ---------------------------- |
+| Promise\ | Promise used to return the ability information.|
+
+**Example**
+
+```js
+let bundleName = "com.example.myapplication";
+let abilityName = "com.example.myapplication.MainAbility";
+bundle.getAbilityInfo(bundleName, abilityName)
+.then((data) => {
+ console.info('Operation successful. Data: ' + JSON.stringify(data));
+}).catch((error) => {
+ console.error('Operation failed. Cause: ' + JSON.stringify(error));
+})
+```
+
+## bundle.getAbilityInfo
+
+getAbilityInfo(bundleName: string, abilityName: string): callback :
+AsyncCallback\: void
+
+Obtains the ability information based on a given want. This method uses an asynchronous callback to return the result.
+
+**Required permissions**
+
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | --------------------------------------------------------- |
+| bundleName | string | Yes | Bundle name of the application. |
+| abilityName | string | Yes | Name of the ability.|
+| callback | AsyncCallback\ | Yes| Callback used to return the ability information.|
+
+**Example**
+
+```js
+let bundleName = "com.example.myapplication";
+let abilityName = "com.example.myapplication.MainAbility";
+bundle.getAbilityInfo(bundleName, abilityName, (err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+})
+```
+
+## bundle.getAbilityLabel
+
+getAbilityLabel(bundleName: string, abilityName: string): Promise\
+
+Obtains the application name based on a given want. This method uses a promise to return the result.
+
+**Required permissions**
+
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | -------------------------------------------------------- |
+| bundleName | string | Yes | Bundle name of the application. |
+| abilityName | string | Yes | Name of the ability.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------- | ---------------------------- |
+| Promise\ | Promise used to return the application name.|
+
+**Example**
+
+```js
+let bundleName = "com.example.myapplication";
+let abilityName = "com.example.myapplication.MainAbility";
+bundle.getAbilityLabel(bundleName, abilityName)
+.then((data) => {
+ console.info('Operation successful. Data: ' + JSON.stringify(data));
+}).catch((error) => {
+ console.error('Operation failed. Cause: ' + JSON.stringify(error));
+})
+```
+
+## bundle.getAbilityLabel
+
+getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\): void
+
+Obtains the application name based on a given want. This method uses an asynchronous callback to return the result.
+
+**Required permissions**
+
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | --------------------------------------------------------- |
+| bundleName | string | Yes | Bundle name of the application. |
+| abilityName | string | Yes | Name of the ability.|
+| callback | AsyncCallback\ | Yes| Callback used to return the application name.|
+
+**Example**
+
+```js
+let bundleName = "com.example.myapplication";
+let abilityName = "com.example.myapplication.MainAbility";
+bundle.getAbilityLabel(bundleName, abilityName, (err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+})
+```
+
+## bundle.isAbilityEnabled
+
+isAbilityEnabled(info: AbilityInfo): Promise\
+
+Checks whether an ability is enabled based on a given want. This method uses a promise to return the result.
+
+**Required permissions**
+
+None
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | ------------ |
+| info | AbilityInfo | Yes | Ability information. |
+
+**Return value**
+
+| Type | Description |
+| ---------------------------- | ------------------------|
+| Promise\ | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
+
+**Example**
+
+```js
+let Info = {
+ bundleName : "com.example.myapplication",
+ name : "com.example.myapplication.MainAbility"
+};
+bundle.isAbilityEnabled(Info)
+.then((data) => {
+ console.info('Operation successful. Data: ' + JSON.stringify(data));
+}).catch((error) => {
+ console.error('Operation failed. Cause: ' + JSON.stringify(error));
+})
+```
+
+## bundle.isAbilityEnabled
+
+isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\): void
+
+Checks whether an ability is enabled based on a given want. This method uses an asynchronous callback to return the result.
+
+**Required permissions**
+
+None
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | --------------------------------------------------------- |
+| info | AbilityInfo | Yes | Ability information. |
+| callback | AsyncCallback\ | 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**
+
+```js
+let Info = {
+ bundleName : "com.example.myapplication",
+ name : "com.example.myapplication.MainAbility"
+};
+bundle.isAbilityEnabled(Info, (err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+})
+```
+
+## bundle.isApplicationEnabled
+
+isApplicationEnabled(bundleName: string): Promise\
+
+Checks whether an application is enabled based on a given want. This method uses a promise to return the result.
+
+**Required permissions**
+
+None
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | -------------------------------------------------------- |
+| bundleName | string | Yes | Bundle name of the application. |
+
+**Return value**
+
+| Type | Description |
+| ---------------------------- | ------------------------|
+| Promise\ | Promise used to return whether the application is enabled. If the application is enabled, **true** will be returned; otherwise, **false** will be returned.|
+
+**Example**
+
+```js
+let bundleName = "com.example.myapplication";
+bundle.isApplicationEnabled(bundleName)
+.then((data) => {
+ console.info('Operation successful. Data: ' + JSON.stringify(data));
+}).catch((error) => {
+ console.error('Operation failed. Cause: ' + JSON.stringify(error));
+})
+```
+
+## bundle.isApplicationEnabled
+
+isApplicationEnabled(bundleName: string, callback : AsyncCallback\): void
+
+Checks whether an application is enabled based on a given want. This method uses an asynchronous callback to return the result.
+
+**Required permissions**
+
+None
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | --------------------------------------------------------- |
+| bundleName | string | Yes | Bundle name of the application. |
+| callback | AsyncCallback\ | Yes| Callback used to return whether the application is enabled. If the application is enabled, **true** will be returned; otherwise, **false** will be returned.|
+
+**Example**
+
+```js
+let bundleName : "com.example.myapplication";
+bundle.isApplicationEnabled(bundleName, (err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+})
+```
## bundle.queryAbilityByWant
queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise>
-Obtains the ability information of the specified user based on a given want. This method uses a promise to return the result.
+Obtains the ability information based on a given want. This method uses a promise to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -430,7 +844,11 @@ bundle.queryAbilityByWant(want, bundleFlags, userId)
queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback\>): void
-Obtains the ability information of the specified user 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 method uses an asynchronous callback to return the result.
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -461,10 +879,14 @@ bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => {
## bundle.queryAbilityByWant
-queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback>): void
+queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback>): void
Obtains the ability information based on a given want. This method uses an asynchronous callback to return the result.
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -492,19 +914,23 @@ bundle.queryAbilityByWant(want, bundleFlags, (err, data) => {
## bundle.getBundleInstaller
-getBundleInstaller(): Promise
+getBundleInstaller(): Promise\
-Obtains the bundle installer in asynchronous mode. This method uses a promise to return the result.
+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 | Promise used to return the bundle installer.|
+| Promise\ | Promise used to return the bundle installer.|
**Example**
@@ -531,19 +957,23 @@ bundle.getBundleInstaller()
## bundle.getBundleInstaller
-getBundleInstaller(callback: AsyncCallback): void;
+getBundleInstaller(callback: AsyncCallback\): void;
-Obtains the bundle installer in asynchronous mode. This method uses a callback to return the result.
+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 | Yes | Callback used to return the bundle installer.|
+| callback | AsyncCallback\ | Yes | Callback used to return the bundle installer.|
**Example**
@@ -573,11 +1003,15 @@ bundle.getBundleInstaller((err, installerObject) => {
getLaunchWantForBundle(bundleName: string): Promise\
-Obtains the **Want** object that launches the specified application in asynchronous mode. This method uses a promise to return the result.
+Obtains the **Want** object that launches the specified application. This method uses a promise to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -604,13 +1038,17 @@ bundle.getLaunchWantForBundle(bundleName)
## bundle.getLaunchWantForBundle
-getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void;
+getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\): void;
-Obtains the **Want** object that launches the specified application in asynchronous mode. This method uses a callback to return the result.
+Obtains the **Want** object that launches the specified application. This method uses an asynchronous callback to return the result.
**Required permissions**
-ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -637,7 +1075,11 @@ bundle.getLaunchWantForBundle(bundleName, (err, data) => {
getNameForUid(uid: number): Promise\
-Obtains the bundle name based on a UID in asynchronous mode. This method uses a promise to return the result.
+Obtains the bundle name based on a UID. This method uses a promise to return the result.
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -664,9 +1106,13 @@ bundle.getNameForUid(uid)
## bundle.getNameForUid
-getNameForUid(uid: number, callback: AsyncCallback): void;
+getNameForUid(uid: number, callback: AsyncCallback\): 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 in asynchronous mode. This method uses a callback to return the result.
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
**Parameters**
@@ -689,8 +1135,190 @@ bundle.getNameForUid(uid, (err, data) => {
```
+## bundle.getAbilityIcon
+
+function getAbilityIcon(bundleName: string, abilityName: string): Promise\<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)>;
+
+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.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | ------ | ---- | -------- |
+| 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.|
+
+**Return value**
+| 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)>.|
+
+**Example**
+
+```js
+let bundleName = com.example.myapplication;
+let abilityName = com.example.myapplication.MainAbility;
+bundle.getAbilityIcon(bundleName, abilityName)
+.then((data) => {
+ console.info('Operation successful. Data: ' + JSON.stringify(data));
+}).catch((error) => {
+ console.error('Operation failed. Cause: ' + JSON.stringify(error));
+})
+```
+
+## bundle.getAbilityIcon
+
+function 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;
+
+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.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | ------ | ---- | -------- |
+| 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.|
+| 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)>.|
+
+**Example**
+
+```js
+let bundleName = com.example.myapplication;
+let abilityName = com.example.myapplication.MainAbility;
+bundle.getAbilityIcon(bundleName, abilityName, (err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+})
+```
+
+
+## bundle.queryExtensionAbilityInfosByWant
+
+function queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId?: number): Promise>
+
+Obtains the extension ability information based on a given want. This method uses a promise to return the result.
+
+**Required permissions**
+
+ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | ------------------------------------------------------------ |
+| 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.|
+| 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**
+
+| Type | Description |
+| ---------------------------- | ---------------------------- |
+| Promise> | Promise used to return the extension ability information.|
+
+**Example**
+
+```js
+let extensionFlags = 0;
+let userId = 100;
+let want = {
+ bundleName : "com.example.myapplication",
+ abilityName : "com.example.myapplication.MainAbility"
+};
+bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, userId)
+.then((data) => {
+ console.info('Operation successful. Data: ' + JSON.stringify(data));
+}).catch((error) => {
+ console.error('Operation failed. Cause: ' + JSON.stringify(error));
+})
+```
+
+
+
+## bundle.queryExtensionAbilityInfosByWant
+
+function queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId: number, callback: AsyncCallback>): void
+
+Obtains the extension ability information based on a given want. This method uses an asynchronous callback to return the result.
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ |
+| 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.|
+| 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> | Yes | Callback used to return the extension ability information. |
+
+**Example**
+
+```js
+let extensionFlags = 0;
+let userId = 100;
+let want = {
+ bundleName : "com.example.myapplication",
+ abilityName : "com.example.myapplication.MainAbility"
+};
+bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, userId, (err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+})
+```
+
+## bundle.queryExtensionAbilityInfosByWant
+
+function queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, callback: AsyncCallback>): void;
+
+Obtains the extension ability information based on a given want. This method uses an asynchronous callback to return the result.
+
+**System capability**
+
+SystemCapability.BundleManager.BundleFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ |
+| 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.|
+| callback | AsyncCallback> | Yes | Callback used to return the extension ability information. |
+
+**Example**
+
+```js
+let extensionFlags = 0;
+let want = {
+ bundleName : "com.example.myapplication",
+ abilityName : "com.example.myapplication.MainAbility"
+};
+bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+})
+```
+
+
## ElementName
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | ------ | ---- | ------------------------------------------------------------ |
| deviceId | Read-only | string | No | ID of the device that runs the ability. |
@@ -701,13 +1329,17 @@ bundle.getNameForUid(uid, (err, data) => {
## InstallStatus
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
| Name | Readable/Writable| Type | Mandatory| Description |
| ------------- | -------- | ---------------- | ---- | ------------------------------------------------------------ |
| status | Read-only | InstallErrorCode | Yes | Installation result code.
SUCCESS = 0
STATUS_INSTALL_FAILURE = 1
STATUS_INSTALL_FAILURE_ABORTED = 2,
STATUS_INSTALL_FAILURE_INVALID = 3
STATUS_INSTALL_FAILURE_CONFLICT = 4
STATUS_INSTALL_FAILURE_STORAGE = 5
STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6
STATUS_UNINSTALL_FAILURE = 7
STATUS_UNINSTALL_FAILURE_BLOCKED = 8
STATUS_UNINSTALL_FAILURE_ABORTED = 9
STATUS_UNINSTALL_FAILURE_CONFLICT = 10
STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B
STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C
STATUS_RECOVER_FAILURE_INVALID = 0x0D
STATUS_ABILITY_NOT_FOUND = 0x40
STATUS_BMS_SERVICE_ERROR = 0x41
STATUS_FAILED_NO_SPACE_LEFT = 0x42
STATUS_GRANT_REQUEST_PERMISSIONS_FAILED = 0x43
STATUS_INSTALL_PERMISSION_DENIED = 0x44
STATUS_UNINSTALL_PERMISSION_DENIED = 0x45 |
## BundleFlag
-Enumerates the bundle flags.
+Enumerates bundle flags.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Default Value| Description |
| ------ | ------ | ------ |
@@ -718,8 +1350,9 @@ Enumerates the bundle flags.
| 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_ABILITY_INFO_WITH_METADATA | 0x00000020 | Obtains the ability metadata information.|
+| GET_BUNDLE_WITH_EXTENSION_ABILITY | 0x00000020 | Obtains the bundle information with the extension ability information.|
| GET_APPLICATION_INFO_WITH_METADATA | 0x00000040 | Obtains the application metadata information.|
-| GET_ABILITY_INFO_SYSTEMAPP_ONLY | 0x00000080 | Obtains only the ability information with information about system applications.|
+| GET_ABILITY_INFO_SYSTEMAPP_ONLY | 0x00000080 | Obtains the ability information with information about system applications.|
| GET_ABILITY_INFO_WITH_DISABLE | 0x00000100 | Obtains information about disabled abilities.|
| GET_APPLICATION_INFO_WITH_DISABLE | 0x00000200 | Obtains information about disabled applications.|
| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information.|
@@ -728,45 +1361,51 @@ Enumerates the bundle flags.
Describes the bundle options.
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
| 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.|
-| networkId | string | Yes| Yes| Network ID. The default value is **null**.|
## BundleInfo
Describes the application bundle information.
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
| Name | Type| Readable| Writable| Description|
| ------ | ------ | ------ | ------ | ------ |
| name | string | Yes | No | Bundle name. |
| type | string | Yes | No | Bundle type. |
| appId | string | Yes | No | ID of the application to which the bundle belongs. |
| uid | number | Yes | No | UID of the application to which the bundle belongs. |
-| installTime | number | Yes | No | Time when the HAP file is installed. |
-| updateTime | number | Yes | No | Time when the HAP file is updated. |
+| installTime | number | Yes | No | Time when the HAP file was installed. |
+| updateTime | number | Yes | No | Time when the HAP file was updated. |
| appInfo | ApplicationInfo | Yes | No | Application configuration information. |
-| abilityInfo | Array | Yes | No | Ability configuration information. |
-| reqPermissions | Array | Yes | No | Array of the permissions to request from the system. |
-| reqPermissionDetails | Array | Yes | No | Detailed information of the permissions to request from the system.|
+| abilityInfos | Array\ | Yes | No | Ability configuration information. |
+| reqPermissions | Array\ | Yes | No | Array of the permissions to request from the system. |
+| reqPermissionDetails | Array\ | Yes | No | Detailed information of the permissions to request from the system.|
| vendor | string | Yes | No | Vendor of the bundle. |
| versionCode | number | Yes | No | Version number of the bundle. |
| versionName | string | Yes | No | Version description of the bundle. |
| compatibleVersion | number | Yes | No | Earliest SDK version required for running the bundle. |
| targetVersion | number | Yes | No | Latest SDK version required for running the bundle. |
| isCompressNativeLibs | boolean | Yes | No | Whether to compress the native library of the bundle. The default value is **true**. |
-| hapModuleInfo | Array | Yes | No | Module configuration information. |
+| hapModuleInfos | Array\ | Yes | No | Module configuration information. |
| entryModuleName | string | Yes | No | Name of the entry module. |
| cpuAbi | string | Yes | No | cpuAbi information of the bundle. |
| 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. |
| entryInstallationFree | boolean | Yes| No| Whether installation-free is supported for the entry.|
-| reqPermissionStates | Array | Yes| No| Permission grant state.|
+| reqPermissionStates | Array\ | Yes| No| Permission grant state.|
+| extensionAbilityInfo | Array\ | Yes| No| Extended information of the ability.|
## ApplicationInfo
Describes the application information.
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
| Name | Type| Readable| Writable| Description|
| ------ | ------ | ------ | ------ | ------ |
| name | string | Yes | No | Application name. |
@@ -778,22 +1417,26 @@ Describes the application information.
| labelId | string | Yes | No | Application label ID. |
| icon | string | Yes | No | Application icon. |
| iconId | string | Yes | No | Application icon ID. |
-| process | string | Yes | No | Process in which this application runs. If this parameter is not set, the bundle name is used by default.|
+| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used by default.|
| supportedModes | number | Yes | No | Running modes supported by the application. |
-| moduleSourceDirs | Array | Yes | No | Relative paths for storing application resources. |
-| permissions | Array | Yes | No | Permissions required for accessing the application. |
-| moduleInfos | Array | Yes | No | Application module information. |
+| moduleSourceDirs | Array\ | Yes | No | Relative paths for storing application resources. |
+| permissions | Array\ | Yes | No | Permissions required for accessing the application. |
+| moduleInfos | Array\ | Yes | No | Application module information. |
| entryDir | string | Yes | No | Path for storing application files. |
-| customizeData | Map> | Yes | Yes | Custom data of the application. |
+| customizeData | Map> | Yes | Yes | Custom data of the application. |
| codePath | string | Yes| No| Installation directory of the application.|
-| metaData | Map> | Yes| No| Custom metadata of the application.|
+| metaData | Map> | Yes| No| Custom metadata of the application.|
+| metaData | Map> | Yes| No| Metadata of the application.|
| removable | boolean | Yes| No| Whether the application is removable.|
| accessTokenId | number | Yes| No| Access token ID of the application.|
| uid | number | Yes| No| UID of the application.|
+| entityType | string | Yes| No| Entity type of the application.|
## ModuleInfo
-Describes the application module information.
+Describes the module information of the application.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description|
| ------ | ------ | ------ | ------ | ------ |
@@ -804,6 +1447,8 @@ Describes the application module information.
Describes the custom metadata.
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
| Name | Type | Readable| Writable| Description |
| ----- | ------ | ---- | ---- | ---------------- |
| name | string | Yes | Yes | Custom metadata name.|
@@ -815,6 +1460,8 @@ Describes the custom metadata.
Describes the HAP module information.
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
| Name | Type| Readable| Writable| Description|
| ------ | ------ | ------ | ------ | ------ |
| name | string | Yes | No | Module name. |
@@ -826,18 +1473,22 @@ Describes the HAP module information.
| iconId | number | Yes | No | Module icon ID. |
| backgroundImg | string | Yes | No | Module background image. |
| supportedModes | number | Yes | No | Modes supported by the module. |
-| reqCapabilities | Array | Yes | No | Capabilities required for module running.|
-| deviceTypes | Array | Yes | No | An array of supported device types.|
-| abilityInfo | Array | Yes | No | Ability information. |
+| reqCapabilities | Array\ | Yes | No | Capabilities required for module running.|
+| deviceTypes | Array\ | Yes | No | An array of supported device types.|
+| abilityInfo | Array\ | Yes | No | Ability information. |
| moduleName | string | Yes | No | Module name. |
| mainAbilityName | string | Yes | No | Name of the entry ability. |
| installationFree | boolean | Yes | No | Whether installation-free is supported. |
| mainElementName | string | Yes| No| Information about the entry ability.|
+| extensionAbilityInfo | Array\ | Yes| No| Extension ability information.|
+| metadata | Array\ | Yes| No| Metadata of the ability.|
## ReqPermissionDetail
Describes the detailed information of the permissions to request from the system.
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
| Name | Type| Readable| Writable| Description|
| ------ | ------ | ------ | ------ | ------ |
| name | string | Yes | Yes | Name of the permission to request. |
@@ -848,15 +1499,19 @@ Describes the detailed information of the permissions to request from the system
Describes the application scenario and timing for using the permission.
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
| Name | Type| Readable| Writable| Description|
| ------ | ------ | ------ | ------ | ------ |
-| abilities | Array | Yes | Yes | Abilities that use the permission.|
+| abilities | Array\ | Yes | Yes | Abilities that use the permission.|
| when | string | Yes | Yes | Time when the permission is used. |
## AbilityInfo
-Describes ability information.
+Describes the ability information.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Readable| Writable| Description|
| ------ | ------ | ------ | ------ | ------ |
@@ -869,34 +1524,31 @@ Describes ability information.
| iconId | number | Yes | No | Ability icon ID. |
| moduleName | string | Yes | No | Name of the HAP file to which the ability belongs. |
| process | string | Yes | No | Process in which this ability runs. If this parameter is not set, the bundle name is used by default.|
-| targetAbility | string | Yes | No | Target ability that this ability alias points to. |
+| targetAbility | string | Yes | No | Target ability that the ability alias points to. |
| backgroundModes | number | Yes | No | Background service mode of the ability. |
| isVisible | boolean | Yes | No | Whether the ability can be called by other applications. |
| formEnabled | boolean | Yes | No | Whether the ability provides the service widget capability. |
| type | AbilityType | Yes | No | Ability type. |
| orientation | DisplayOrientation | Yes | No | Ability display orientation. |
| launchMode | LaunchMode | Yes | No | Ability launch mode. |
-| permissions | Array | Yes | No | Permissions required for other applications to call the ability.|
-| deviceTypes | Array | Yes | No | Device types supported by the ability. |
-| deviceCapabilities | Array | Yes | No | Device capabilities required for the ability. |
+| permissions | Array\ | Yes | No | Permissions required for other applications to call the ability.|
+| deviceTypes | Array\ | Yes | No | Device types supported by the ability. |
+| deviceCapabilities | Array\ | Yes | No | Device capabilities required for the ability. |
| readPermission | string | Yes | No | Permission required for reading the ability data. |
| writePermission | string | Yes | No | Permission required for writing data to the ability. |
| applicationInfo | ApplicationInfo | Yes | No | Application configuration information. |
-| formEntity | number | Yes | No | Area where the ability form can be displayed. |
-| minFormHeight | number | Yes | No | Minimum height of the ability form. |
-| defaultFormHeight | number | Yes | No | Default height of the ability form. |
-| minFormWidth | number | Yes | No | Minimum width of the ability form. |
-| defaultFormWidth | number | Yes | No | Default width of the ability form. |
| uri | string | Yes | No | URI of the ability. |
-| customizeData | Map> | Yes | Yes | Custom data of the ability. |
| labelId | number | Yes | No | Ability label ID. |
| subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability. |
-| metaData | Array | Yes| No| Custom metadata of the ability.|
+| metaData | Array\ | Yes| No| Custom information of the ability.|
+| metaData | Array\ | Yes| No| Metadata of the ability.|
| enabled | boolean | Yes| No| Whether the ability is enabled.|
## AbilityType
-Describes the ability type.
+Enumerates ability types.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description |
| ------- | ---- | --------------------------- |
@@ -907,7 +1559,9 @@ Describes the ability type.
## DisplayOrientation
-Describes the display orientation.
+Enumerates display orientations.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description |
| ------------- | ---- | ------------------------ |
@@ -918,18 +1572,92 @@ Describes the display orientation.
## LaunchMode
-Describes the launch mode.
+Enumerates launch modes.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description |
| ----------- | ---- | ------------------- |
-| UNSPECIFIED | 0 | The ability has only one instance.|
+| SINGLETON | 0 | The ability has only one instance.|
| STANDARD | 1 | The ability can have multiple instances. |
## AbilitySubType
-Describes the ability subtype.
+Enumerates ability subtypes.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type| Description |
| ----------- | ---- | ----------------------------- |
| UNSPECIFIED | 0 | Undefined ability subtype. |
| CA | 1 | Ability that has a UI.|
+
+
+## ExtensionAbilityType
+
+Enumerates extension ability types.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
+| Name | Type| Description |
+| -------------------- | ---- | ----------------------------- |
+| FORM | 0 | Form included. |
+| WORK_SCHEDULER | 1 | Work scheduler included.|
+| INPUT_METHOD | 2 | Input method included. |
+| SERVICE | 3 | Service included. |
+| ACCESSIBILITY | 4 | Accessibility included. |
+| DATA_SHARE | 5 | Data sharing included.|
+| FILE_SHARE | 6 | File sharing included.|
+| STATIC_SUBSCRIBER | 7 | Subscribers included. |
+| WALLPAPER | 8 | Wallpaper included. |
+| UNSPECIFIED | 9 | Unspecified type. |
+
+## ExtensionFlag
+
+Enumerates extension flags.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
+| Name | Default Value| Description |
+| ------ | ------ | ------ |
+| GET_EXTENSION_INFO_DEFAULT | 0x00000000 | Obtains the default extension ability information.|
+| GET_EXTENSION_INFO_WITH_PERMISSION | 0x00000002 | Obtains the extension ability information that carries permission information.|
+| GET_EXTENSION_INFO_WITH_APPLICATION | 0x00000004 | Obtains the extension ability information that carries application information.|
+| GET_EXTENSION_INFO_WITH_METADATA | 0x00000020 | Obtains the extension ability information that carries metadata information.|
+
+
+## ExtensionAbilityInfo
+
+Describes the extension ability information.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
+| Name | Type| Readable| Writable| Description|
+| ------ | ------ | ------ | ------ | ------ |
+| bundleName | string | Yes | No | Application bundle name. |
+| moduleName | string | Yes | No | Name of the HAP file to which the extension ability belongs. |
+| name | string | Yes | No | Name of the extension ability. |
+| labelId | number | Yes | No | Label ID of the extension ability. |
+| descriptionId | number | Yes | No | Description ID of the extension ability. |
+| iconId | number | Yes | No | Icon ID of the extension ability. |
+| isVisible | boolean | Yes | No | Whether the extension ability can be called by other applications. |
+| extensionAbilityType | bundle.ExtensionAbilityType | Yes | No | Type of the extension ability. |
+| permissions | Array\ | Yes | No | Permissions required for other applications to call the extension ability.|
+| applicationInfo | ApplicationInfo | Yes | No | Application configuration information. |
+| metaData | Array\ | Yes| No| Metadata of the extension ability.|
+| enabled | boolean | Yes| No| Whether the extension ability is enabled.|
+| readPermission | string | Yes | No | Permission required for reading the extension ability data. |
+| writePermission | string | Yes | No | Permission required for writing data to the extension ability. |
+
+
+## Metadata
+
+Describes the metadata information.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework
+
+| Name | Type | Readable| Writable| Description |
+| ----- | ------ | ---- | ---- | ---------------- |
+| name | string | Yes | Yes | Metadata name.|
+| value | string | Yes | Yes | Metadata value. |
+| resource | string | Yes | Yes | Metadata resource. |
diff --git a/en/application-dev/reference/apis/js-apis-Context.md b/en/application-dev/reference/apis/js-apis-Context.md
index ea7efb523f253f83fec2133b7a9acb37ddd5727d..4b2526ce8336f5ae3391f0652cbf17dacb7c6f54 100644
--- a/en/application-dev/reference/apis/js-apis-Context.md
+++ b/en/application-dev/reference/apis/js-apis-Context.md
@@ -7,7 +7,7 @@ import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
```
-The **Context** object is created in a **featureAbility** and returned through its **getContext()** method. Therefore, you must import the **@ohos.ability.featureAbility** package before using the Context module. An example is as follows:
+The **Context** object is created in a **featureAbility** and returned through its **getContext()** API. Therefore, you must import the **@ohos.ability.featureAbility** package before using the Context module. An example is as follows:
```js
import featureAbility from '@ohos.ability.featureAbility'
@@ -15,26 +15,21 @@ var context = featureAbility.getContext();
context.getOrCreateLocalDir()
```
-## Context
-
-### getOrCreateLocalDir
+## Context.getOrCreateLocalDir
getOrCreateLocalDir(callback: AsyncCallback\): void
-Obtains the local root directory of the application. This method uses a callback to return the result.
-
-If this method is called for the first time, a root directory is created.
+Obtains the local root directory of the application. This API uses an asynchronous callback to return the result.
-**System capabilities**
+If this API is called for the first time, a root directory will be created.
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
-
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the local root directory of the application.|
+| callback | AsyncCallback\ | Yes | Callback used to return the local root directory.|
**Example**
@@ -48,23 +43,21 @@ context.getOrCreateLocalDir((err, data)=>{
-### getOrCreateLocalDir
+## Context.getOrCreateLocalDir
getOrCreateLocalDir(): Promise\
-Obtains the local root directory of the application. This method uses a promise to return the result.
+Obtains the local root directory of the application. This API uses a promise to return the result.
-If this method is called for the first time, a root directory is created.
+If this API is called for the first time, a root directory will be created.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ---------------- | ---------------------- |
-| Promise\ | Promise used to return the local root directory of the application.|
+| Promise\ | Promise used to return the local root directory.|
**Example**
@@ -78,19 +71,16 @@ context.getOrCreateLocalDir().then((data) => {
-### verifyPermission
+## Context.verifyPermission
verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback\): void
-Verifies whether a specific PID and UID have the given permission. This method uses a callback to return the result.
-
-**System capabilities**
+Verifies whether a specific PID and UID have the given permission. This API uses an asynchronous callback to return the result.
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
-
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ------------------------------------- |
| permission | string | Yes | Name of the permission to verify. |
@@ -110,14 +100,15 @@ bundle.getBundleInfo('com.context.test', 1, (datainfo) =>{
-### verifyPermission
+## Context.verifyPermission
verifyPermission(permission: string, callback: AsyncCallback\): void
-Verifies whether the current PID and UID have the given permission. This method uses a callback to return the result.
+Verifies whether the current PID and UID have the given permission. This API uses an asynchronous callback to return the result.
-**Parameters**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ---------------------- | ---- | ------------------------------------- |
@@ -132,19 +123,16 @@ var context = featureAbility.getContext();
context.verifyPermission("com.example.permission")
```
-### verifyPermission
+## Context.verifyPermission
verifyPermission(permission: string, options?: PermissionOptions): Promise\
-Verifies whether a specific PID and UID have the given permission. This method uses a promise to return the result.
+Verifies whether a specific PID and UID have the given permission. This API uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
-
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ---------------- |
| permission | string | Yes | Name of the permission to verify.|
@@ -170,24 +158,22 @@ context.verifyPermission('com.context.permission',Permission).then((data) => {
-### requestPermissionsFromUser
+## Context.requestPermissionsFromUser
-requestPermissionsFromUser(permissions: Array\, requestCode: number, resultCallback: AsyncCallback<[PermissionRequestResult](#permissionrequestresult)>)
+requestPermissionsFromUser(permissions: Array\, requestCode: number, resultCallback: AsyncCallback<[PermissionRequestResult](#permissionrequestresult)>): void
-Requests certain permissions from the system. This method uses a callback to return the result.
+Requests certain permissions from the system. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
-
| Name | Type | Mandatory| Description |
| -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- |
| permissions | Array\ | Yes | Permissions to request. This parameter cannot be **null**. |
| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**.|
| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes | Permission request result. |
+
**Example**
```js
@@ -208,15 +194,13 @@ context.requestPermissionsFromUser(
-### getApplicationInfo
+## Context.getApplicationInfo
-getApplicationInfo(callback: AsyncCallback\)
+getApplicationInfo(callback: AsyncCallback\): void
-Obtains information about the current application. This method uses a callback to return the result.
+Obtains information about the current application. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
@@ -234,15 +218,13 @@ context.getApplicationInfo()
-### getApplicationInfo
+## Context.getApplicationInfo
getApplicationInfo(): Promise\
-Obtains information about the current application. This method uses a promise to return the result.
-
-**System capabilities**
+Obtains information about the current application. This API uses a promise to return the result.
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
@@ -263,15 +245,13 @@ context.getApplicationInfo().then((data) => {
-### getBundleName
+## Context.getBundleName
getBundleName(callback: AsyncCallback\): void
-Obtains the bundle name of the current ability. This method uses a callback to return the result.
+Obtains the bundle name of the current ability. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
@@ -289,15 +269,13 @@ context.getBundleName()
-### getBundleName
+## Context.getBundleName
getBundleName(): Promise\
-Obtains the bundle name of the current ability. This method uses a promise to return the result.
-
-**System capabilities**
+Obtains the bundle name of the current ability. This API uses a promise to return the result.
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
@@ -318,15 +296,13 @@ context.getBundleName().then((data) => {
-### getProcessInfo
+## Context.getProcessInfo
-getProcessInfo(callback: AsyncCallback\)
+getProcessInfo(callback: AsyncCallback\): void
-Obtains information about the current process, including the PID and process name. This method uses a callback to return the result.
+Obtains information about the current process, including the PID and process name. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
@@ -344,15 +320,13 @@ context.getProcessInfo()
-### getProcessInfo
+## Context.getProcessInfo
getProcessInfo(): Promise\
-Obtains information about the current process, including the PID and process name. This method uses a promise to return the result.
-
-**System capabilities**
+Obtains information about the current process, including the PID and process name. This API uses a promise to return the result.
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
@@ -373,17 +347,15 @@ context.getProcessInfo().then((data) => {
-### getElementName
+## Context.getElementName
getElementName(callback: AsyncCallback\): void
-Obtains the **ohos.bundle.ElementName** object of the current ability. This method uses a callback to return the result.
+Obtains the **ohos.bundle.ElementName** object of the current ability. This API uses an asynchronous callback to return the result.
-This method is available only to Page abilities.
+This API is available only to Page abilities.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
@@ -401,17 +373,15 @@ context.getElementName()
-### getElementName
+## Context.getElementName
getElementName(): Promise\
-Obtains the **ohos.bundle.ElementName** object of the current ability. This method uses a promise to return the result.
-
-This method is available only to Page abilities.
+Obtains the **ohos.bundle.ElementName** object of the current ability. This API uses a promise to return the result.
-**System capabilities**
+This API is available only to Page abilities.
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
@@ -430,15 +400,15 @@ context.getElementName().then((data) => {
});
```
-### getProcessName
+## Context.getProcessName
getProcessName(callback: AsyncCallback\): void
-Obtains the name of the current process. This method uses a callback to return the result.
+Obtains the name of the current process. This API uses an asynchronous callback to return the result.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------- |
@@ -454,15 +424,13 @@ context.getProcessName()
-### getProcessName
+## Context.getProcessName
getProcessName(): Promise\
-Obtains the name of the current process. This method uses a promise to return the result.
+Obtains the name of the current process. This API uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
@@ -483,15 +451,13 @@ context.getProcessName().then((data) => {
-### getCallingBundle
+## Context.getCallingBundle
getCallingBundle(callback: AsyncCallback\): void
-Obtains the bundle name of the calling ability. This method uses a callback to return the result.
-
-**System capabilities**
+Obtains the bundle name of the calling ability. This API uses an asynchronous callback to return the result.
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
@@ -509,15 +475,13 @@ context.getCallingBundle()
-### getCallingBundle
+## Context.getCallingBundle
getCallingBundle(): Promise\
-Obtains the bundle name of the calling ability. This method uses a promise to return the result.
+Obtains the bundle name of the calling ability. This API uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
@@ -536,17 +500,443 @@ context.getCallingBundle().then((data) => {
});
```
+## Context.getCacheDir
+
+getCacheDir(callback: AsyncCallback\): void
+
+Obtains the cache directory of the application on the internal storage. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ------------------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the cache directory.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getCacheDir();
+context.getCacheDir((err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+});
+```
+
+## Context.getCacheDir
+
+getCacheDir(): Promise\
+
+Obtains the cache directory of the application on the internal storage. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| --------------- | ------------------------- |
+| Promise\ | Promise used to return the cache directory.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getCacheDir().then((data) => {
+ console.info("======================>getCacheDirPromsie====================>");
+ console.info("====>data====>" + JSON.stringify(data));
+});
+```
+
+## Context.getFilesDir
+
+getFilesDir(callback: AsyncCallback\): void
+
+Obtains the file directory of the application on the internal storage. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ------------------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the file directory.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getFilesDir();
+context.getFilesDir((err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+});
+```
+
+## Context.getFilesDir
+
+getFilesDir(): Promise\
+
+Obtains the file directory of the application on the internal storage. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| --------------- | ------------------------- |
+| Promise\ | Promise used to return the file directory.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getFilesDir().then((data) => {
+ console.info("======================>getFilesDirPromsie====================>");
+ console.info("====>data====>" + JSON.stringify(data));
+});
+```
+
+## Context.getOrCreateDistributedDir
+
+getOrCreateDistributedDir(callback: AsyncCallback\): void
+
+Obtains the distributed file path for storing ability or application data files. This API uses an asynchronous callback to return the result.
+
+If the distributed file path does not exist, the system will create one and return the created path.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ------------------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getOrCreateDistributedDir((err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+});
+```
+
+## Context.getOrCreateDistributedDir
+
+getOrCreateDistributedDir(): Promise\
+
+Obtains the distributed file path for storing ability or application data files. This API uses a promise to return the result.
+
+If the distributed file path does not exist, the system will create one and return the created path.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| --------------- | ------------------------- |
+| Promise\ | Promise used to return the distributed file path. If this API is called for the first time, a new path will be created.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getOrCreateDistributedDir().then((data) => {
+ console.info("====>data====>" + JSON.stringify(data));
+});
+```
+
+## Context.getAppType
+
+getAppType(callback: AsyncCallback\): void
+
+Obtains the application type. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ------------------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the application type.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getAppType((err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+});
+```
+
+## Context.getAppType
+
+getAppType(): Promise\
+
+Obtains the application type. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| --------------- | ------------------------- |
+| Promise\ | Promise used to return the application type.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getAppType().then((data) => {
+ console.info("====>data====>" + JSON.stringify(data));
+});
+```
+
+## Context.getHapModuleInfo
+
+getHapModuleInfo(callback: AsyncCallback\): void
+
+Obtains the **ModuleInfo** object of the application. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ------------------------- |
+| callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | Yes | Callback used to return the **ModuleInfo** object.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getHapModuleInfo((err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+});
+```
+
+## Context.getHapModuleInfo
+
+getHapModuleInfo(): Promise\
+
+Obtains the **ModuleInfo** object of the application. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| --------------- | ------------------------- |
+| Promise\<[HapModuleInfo](#hapmoduleinfo)> | Promise used to return the **ModuleInfo** object.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getHapModuleInfo().then((data) => {
+ console.info("====>data====>" + JSON.stringify(data));
+});
+```
+
+## Context.getAppVersionInfo
+
+getAppVersionInfo(callback: AsyncCallback\): void
+
+Obtains the version information of the application. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ------------------------- |
+| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getAppVersionInfo((err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+});
+```
+
+## Context.getAppVersionInfo
+
+getAppVersionInfo(): Promise\
+
+Obtains the version information of the application. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| --------------- | ------------------------- |
+| Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getAppVersionInfo().then((data) => {
+ console.info("====>data====>" + JSON.stringify(data));
+});
+```
+
+## Context.getAbilityInfo
+
+getAbilityInfo(callback: AsyncCallback\): void
+
+Obtains information of the current ability. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ------------------------- |
+| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes |Callback used to return the ability information.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getAbilityInfo((err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Operation successful. Data:' + JSON.stringify(data));
+});
+```
+
+## Context.getAbilityInfo
+
+getAbilityInfo(): Promise\
+
+Obtains information of the current ability. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| --------------- | ------------------------- |
+| Promise\<[AbilityInfo](#abilityInfo)> | Promise used to return the ability information.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext();
+context.getAbilityInfo().then((data) => {
+ console.info("====>data====>" + JSON.stringify(data));
+});
+```
+
+## Context.getApplicationContext
+
+getApplicationContext(): Context
+
+Obtains the context of the application.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Parameters | Type | Description |
+| --------------- | ------------------------- |------ |
+| Context | Context |Application context.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility'
+var context = featureAbility.getContext().getApplicationContext();
+```
+
## PermissionOptions
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
| Name| Readable/Writable| Type | Mandatory| Description |
| ---- | -------- | ------ | ---- | ------ |
-| pid | Read-only | number | No | PID.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core|
-| uid | Read-only | number | No | UID.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core|
+| pid | Read-only | number | No | Process ID.|
+| uid | Read-only | number | No | User ID.|
## PermissionRequestResult
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------- | ---- | ------------------ |
-| requestCode | Read-only | number | Yes | Request code passed.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core|
-| permissions | Read-only | Array\ | Yes | Permissions passed.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core |
-| authResults | Read-only | Array\ | Yes | Permission request result.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core |
+| requestCode | Read-only | number | Yes | Request code passed.|
+| permissions | Read-only | Array\ | Yes | Permissions requested. |
+| authResults | Read-only | Array\ | Yes | Permission request result. |
+
+## HapModuleInfo
+
+Describes the HAP module information.
+
+| Name | Type| Readable| Writable| Description|
+| ------ | ------ | ------ | ------ | ------ |
+| name | string | Yes | No | Module name. |
+| description | string | Yes | No | Module description. |
+| descriptionId | number | Yes | No | Module description ID. |
+| icon | string | Yes | No | Module icon. |
+| label | string | Yes | No | Module label. |
+| labelId | number | Yes | No | Module label ID. |
+| iconId | number | Yes | No | Module icon ID. |
+| backgroundImg | string | Yes | No | Module background image. |
+| supportedModes | number | Yes | No | Modes supported by the module. |
+| reqCapabilities | Array | Yes | No | Capabilities required for module running.|
+| deviceTypes | Array | Yes | No | An array of supported device types.|
+| abilityInfo | Array | Yes | No | Ability information. |
+| moduleName | string | Yes | No | Module name. |
+| mainAbilityName | string | Yes | No | Name of the entrance ability. |
+| installationFree | boolean | Yes | No | When installation-free is supported. |
+| mainElementName | string | Yes| No| Information about the entry ability.|
+
+## AppVersionInfo
+
+| Name | Type| Readable | Writable | Description|
+| ------ | ------ | ------| ------ | ------ |
+| appName | string | Yes | No | Module name. |
+| versionCode | number | Yes | No | Module description. |
+| versionName | string | Yes | No | Module description ID. |
diff --git a/en/application-dev/reference/apis/js-apis-DataUriUtils.md b/en/application-dev/reference/apis/js-apis-DataUriUtils.md
index b45c839bc405c3cd65bbebe2f029e9930d8074ee..267ba0d27b3fbf9e3b35a8dbb884da04286f5729 100644
--- a/en/application-dev/reference/apis/js-apis-DataUriUtils.md
+++ b/en/application-dev/reference/apis/js-apis-DataUriUtils.md
@@ -1,5 +1,8 @@
# DataUriUtils Module
+>  **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.
+
## Modules to Import
```js
@@ -12,15 +15,17 @@ getId(uri: string): number
Obtains the ID attached to the end of a given URI.
-**Parameters**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-| Name| Type| Mandatory| Description|
+| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
-| uri | string | Yes| URI object from which the ID is to be obtained.|
+| uri | string | Yes | URI object from which the ID is to be obtained.|
**Return value**
-| Type| Description|
+
+| Type | Description |
| ------ | ------------------------ |
| number | ID obtained from the URI object.|
@@ -38,16 +43,18 @@ attachId(uri: string, id: number): string
Attaches an ID to the end of a given URI.
-**Parameters**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-| Name| Type| Mandatory| Description|
+| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
-| uri | string | Yes| URI object to which an ID is to be attached.|
-| id | number | Yes| ID to be attached.|
+| uri | string | Yes | URI object to which an ID is to be attached.|
+| id | number | Yes | ID to be attached. |
**Return value**
-| Type| Description|
+
+| Type | Description |
| ------ | --------------------- |
| string | URI object with the ID attached.|
@@ -69,14 +76,17 @@ deleteId(uri: string): string
Deletes the ID from the end of a given URI.
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
**Parameters**
-| Name| Type| Mandatory| Description|
+| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
-| uri | string | Yes| URI object from which the ID is to be deleted.|
+| uri | string | Yes | URI object from which the ID is to be deleted.|
**Return value**
-| Type| Description|
+
+| Type | Description |
| ------ | ------------------- |
| string | URI object with the ID deleted.|
@@ -94,15 +104,18 @@ updateId(uri: string, id: number): string
Updates the ID in a given URI.
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
**Parameters**
-| Name| Type| Mandatory| Description|
+| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------- |
-| uri | string | Yes| URI object to be updated.|
-| id | number | Yes| New ID.|
+| uri | string | Yes | URI object to be updated.|
+| id | number | Yes | New ID. |
**Return value**
-| Type| Description|
+
+| Type | Description |
| ------ | --------------- |
| string | URI object with the new ID.|
diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md
index 7652774178a2357e7a8cb5928545f80348d1c2d2..6e5f9e4b36e1df88f85f2b9a91434b700f508673 100644
--- a/en/application-dev/reference/apis/js-apis-ability-context.md
+++ b/en/application-dev/reference/apis/js-apis-ability-context.md
@@ -14,7 +14,7 @@ Before using the **AbilityContext** module, you must define a child class that i
-```
+```js
import Ability from '@ohos.application.Ability'
class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
@@ -28,28 +28,28 @@ class MainAbility extends Ability {
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| abilityInfo | AbilityInfo | Yes| No| Ability information.|
-| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.|
+| abilityInfo | AbilityInfo | Yes| No| Ability information.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
+| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
-## startAbility
+## AbilityContext.startAbility
startAbility(want: Want, callback: AsyncCallback<void>): void
-Starts an ability. This method uses a callback to return the result.
+Starts an ability. This API uses a callback to return the result.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
-- Example
- ```
+**Example**
+
+ ```js
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
@@ -61,26 +61,25 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## startAbility
+## AbilityContext.startAbility
startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void
-Starts an ability. This method uses a callback to return the result.
+Starts an ability. This API uses a callback to return the result.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
-- Example
+**Example**
- ```
+ ```js
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
@@ -95,29 +94,30 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## startAbility
+## AbilityContext.startAbility
-startAbility(want: Want, options: StartOptions): Promise<void>;
+startAbility(want: Want, options?: StartOptions): Promise<void>;
-Starts an ability. This method uses a promise to return the result.
+Starts an ability. This API uses a promise to return the result.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.|
- | options | StartOptions | Yes| Parameters used for starting the ability.|
+ | options | StartOptions | No| Parameters used for starting the ability.|
+
+**Return value**
-- Return value
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
-- Example
- ```
+**Example**
+
+ ```js
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
@@ -135,25 +135,25 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## startAbilityForResult
+## AbilityContext.startAbilityForResult
startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void;
-Starts an ability. This method uses a callback to return the execution result when the ability is terminated.
+Starts an ability. This API uses a callback to return the execution result when the ability is terminated.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.|
-- Example
- ```
+**Example**
+
+ ```js
this.context.startAbilityForResult(
{bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"},
(error, result) => {
@@ -163,17 +163,16 @@ SystemCapability.Ability.AbilityRuntime.Core
);
```
-## startAbilityForResult
+## AbilityContext.startAbilityForResult
startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void;
-Starts an ability. This method uses a callback to return the execution result when the ability is terminated.
+Starts an ability. This API uses a callback to return the execution result when the ability is terminated.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.|
@@ -181,8 +180,9 @@ SystemCapability.Ability.AbilityRuntime.Core
| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.|
-- Example
- ```
+**Example**
+
+ ```js
var options = {
windowMode: 0,
};
@@ -196,30 +196,31 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## startAbilityForResult
+## AbilityContext.startAbilityForResult
-startAbilityForResult(want: Want, options: StartOptions): Promise<AbilityResult>;
+startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>;
-Starts an ability. This method uses a promise to return the execution result when the ability is terminated.
+Starts an ability. This API uses a promise to return the execution result when the ability is terminated.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.|
- | options | StartOptions | Yes| Parameters used for starting the ability.|
+ | options | StartOptions | No| Parameters used for starting the ability.|
-- Return value
+**Return value**
+
| Type| Description|
| -------- | -------- |
| Promise<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Promise used to return the result.|
-- Example
- ```
+**Example**
+
+ ```js
var options = {
windowMode: 0,
};
@@ -231,46 +232,46 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## terminateSelf
+## AbilityContext.terminateSelf
terminateSelf(callback: AsyncCallback<void>): void;
-Terminates this ability. This method uses a callback to return the result.
+Terminates this ability. This API uses a callback to return the result.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the method is successfully called.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the API is successfully called.|
-- Example
- ```
+**Example**
+
+ ```js
this.context.terminateSelf((err) => {
console.log('terminateSelf result:' + JSON.stringfy(err));
});
```
-## terminateSelf
+## AbilityContext.terminateSelf
terminateSelf(): Promise<void>;
-Terminates this ability. This method uses a promise to return the result.
+Terminates this ability. This API uses a promise to return the result.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Return value**
-- Return value
| Type| Description|
| -------- | -------- |
- | Promise<void> | Promise used to return the result indicating whether the method is successfully called.|
+ | Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
-- Example
- ```
+**Example**
+
+ ```js
this.context.terminateSelf(want).then((data) => {
console.log('success:' + JSON.stringfy(data));
}).catch((error) => {
@@ -279,24 +280,24 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## terminateSelfWithResult
+## AbilityContext.terminateSelfWithResult
terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void;
-Terminates this ability. This method uses a callback to return the information to the caller of **startAbilityForResult**.
+Terminates this ability. This API uses a callback to return the information to the caller of **startAbilityForResult**.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
-- Example
- ```
+**Example**
+
+ ```js
this.context.terminateSelfWithResult(
{
want: {bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo"},
@@ -308,28 +309,29 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## terminateSelfWithResult
+## AbilityContext.terminateSelfWithResult
terminateSelfWithResult(parameter: AbilityResult): Promise<void>;
-Terminates this ability. This method uses a promise to return information to the caller of **startAbilityForResult**.
+Terminates this ability. This API uses a promise to return information to the caller of **startAbilityForResult**.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
-- Return value
+**Return value**
+
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
-- Example
- ```
+**Example**
+
+ ```js
this.context.terminateSelfWithResult(
{
want: {bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo"},
@@ -341,29 +343,29 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## startAbilityByCall
+## AbilityContext.startAbilityByCall
startAbilityByCall(want: Want): Promise<Caller>;
Obtains the caller interface of the specified ability, and if the specified ability is not started, starts the ability in the background.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.|
-- Return value
- | Type| Description|
+**Return value**
+
+ | Type| Description|
| -------- | -------- |
- | Promise<> | Promise used to return the caller object to communicate with.|
+ | Promise<Caller> | Promise used to return the caller object to communicate with.|
-- Example
+**Example**
- ```
+ ```js
import Ability from '@ohos.application.Ability';
var caller;
export default class MainAbility extends Ability {
@@ -383,23 +385,22 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## requestPermissionsFromUser
+## AbilityContext.requestPermissionsFromUser
requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>) : void;
-Requests permissions from the user by displaying a pop-up window. This method uses a callback to return the result.
+Requests permissions from the user by displaying a pop-up window. This API uses a callback to return the result.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| permissions | Array<string> | Yes| Permissions to request.|
- | callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result indicating whether the method is successfully called.|
+ | callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result indicating whether the API is successfully called.|
-- Example
+**Example**
```
this.context.requestPermissionsFromUser(permissions,(result) => {
@@ -408,27 +409,27 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## requestPermissionsFromUser
+## AbilityContext.requestPermissionsFromUser
requestPermissionsFromUser(permissions: Array<string>) : Promise<PermissionRequestResult>;
-Requests permissions from the user by displaying a pop-up window. This method uses a promise to return the result.
+Requests permissions from the user by displaying a pop-up window. This API uses a promise to return the result.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | permissions | Array<string> | Yes| Permissions to request.|
+ | permissions | Array<string> | Yes| Permissions to request.|
+
+**Return value**
-- Return value
- | Type| Description|
+ | Type| Description|
| -------- | -------- |
- | Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result indicating whether the method is successfully called.|
+ | Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result indicating whether the API is successfully called.|
-- Example
+**Example**
```
this.context.requestPermissionsFromUser(permissions).then((data) => {
@@ -439,54 +440,53 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## setMissionLabel
+## AbilityContext.setMissionLabel
setMissionLabel(label: string, callback:AsyncCallback<void>): void;
-Sets the label of the ability displayed in the task. This method uses a callback to return the result.
+Sets the label of the ability displayed in the task. This API uses a callback to return the result.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.|
- | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the method is successfully called.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the API is successfully called.|
-- Example
+**Example**
- ```
+ ```js
this.context.setMissionLabel("test",(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringfy(result));
});
```
-## setMissionLabel
+## AbilityContext.setMissionLabel
setMissionLabel(label: string): Promise<void>
-Sets the label of the ability displayed in the task. This method uses a promise to return the result.
+Sets the label of the ability displayed in the task. This API uses a promise to return the result.
-**System capabilities**
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.|
-- Return value
- | Type| Description|
+**Return value**
+
+ | Type| Description|
| -------- | -------- |
- | Promise<void> | Promise used to return the result indicating whether the method is successfully called.|
+ | Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
-- Example
+**Example**
- ```
+ ```js
this.context.setMissionLabel("test").then((data) => {
console.log('success:' + JSON.stringfy(data));
}).catch((error) => {
diff --git a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md
index 58673b2285ee51d3c952af4b14e9ede1137b909d..0ed9eb40d2cfe73bcc98bfb394d894809f6700dc 100644
--- a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md
+++ b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md
@@ -10,38 +10,39 @@ Provides ability running information.
## Usage
-The ability running information is obtained by using the **getAbilityRunningInfos** method in **abilityManager**.
+The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**.
-
-```
+
+```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getAbilityRunningInfos((err,data) => {
console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
```
-
## Attributes
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
- | Name| Type| Readable| Writable| Description|
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| ability | ElementName | Yes| No| Information that matches an ability.|
+| ability | ElementName | Yes| No| Information that matches an ability. |
| pid | number | Yes| No| Process ID.|
-| uid | number | Yes| No| User ID.|
-| processName | string | Yes| No| Process name.|
-| startTime | number | Yes| No| Ability start time.|
-| abilityState | [abilityManager.AbilityState](#abilitymanager-abilitystate) | Yes| No| Ability state.|
+| uid | number | Yes| No| User ID. |
+| processName | string | Yes| No| Process name. |
+| startTime | number | Yes| No| Ability start time. |
+| abilityState | [abilityManager.AbilityState](#abilitymanager-abilitystate) | Yes| No| Ability state. |
## abilityManager.AbilityState
-
Enumerates the ability states.
- | Name| Value| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name| Value| Description|
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.|
-| FOREGROUND | 9 | The ability is in the foreground state.|
-| BACKGROUND | 10 | The ability is in the background state.|
-| FOREGROUNDING | 11 | The ability is in the foregrounding state.|
-| BACKGROUNDING | 12 | The ability is in the backgrounding state.|
+| FOREGROUND | 9 | The ability is in the foreground state. |
+| BACKGROUND | 10 | The ability is in the background state. |
+| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
+| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
diff --git a/en/application-dev/reference/apis/js-apis-abilitystagecontext.md b/en/application-dev/reference/apis/js-apis-abilitystagecontext.md
index c41326589ba67c9297b8326ab10085f18863f48e..91e8a7513e8c68f06105d14d4a96fc0cec9e2fac 100644
--- a/en/application-dev/reference/apis/js-apis-abilitystagecontext.md
+++ b/en/application-dev/reference/apis/js-apis-abilitystagecontext.md
@@ -14,7 +14,7 @@ The ability stage context is obtained through an **AbilityStage** instance.
-```
+```js
import AbilityStage from '@ohos.application.AbilityStage';
class MyAbilityStage extends AbilityStage {
onCreate() {
@@ -25,8 +25,9 @@ class MyAbilityStage extends AbilityStage {
## Attributes
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
- | Name| Type| Readable| Writable| Description|
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes| No| **ModuleInfo** object corresponding to the **AbilityStage**.|
| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running.|
diff --git a/en/application-dev/reference/apis/js-apis-accessibility.md b/en/application-dev/reference/apis/js-apis-accessibility.md
new file mode 100644
index 0000000000000000000000000000000000000000..c39e6e8f9437e64b3f05f59986ec08d35170eb71
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-accessibility.md
@@ -0,0 +1,627 @@
+# Accessibility
+
+>  **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.
+
+## Modules to Import
+
+```typescript
+import accessibility from '@ohos.accessibility';
+```
+
+## AbilityState
+
+Enumerates the states of an accessibility application.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+| Name| Description|
+| -------- | -------- |
+| enable | The accessibility application is enabled.|
+| disable | The accessibility application is disabled.|
+| install | The accessibility application has been installed.|
+
+## AbilityType
+
+Enumerates the types of accessibility applications.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+| Name| Description|
+| -------- | -------- |
+| audible | The accessibility application provides audible feedback.|
+| generic | The accessibility application provides generic feedback.|
+| haptic | The accessibility application provides haptic feedback.|
+| spoken | The accessibility application provides spoken feedback.|
+| visual | The accessibility application provides visual feedback.|
+
+## AccessibilityAbilityInfo
+
+Provides information about an accessibility application.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+### Attributes
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| id | number | Yes| No| Ability ID.|
+| name | string | Yes| No| Ability name.|
+| bundleName | string | Yes| No| Bundle name.|
+| abilityTypes | Array<[AbilityType](#abilitytype)> | Yes| No| Accessibility application type.|
+| capabilities | Array<[Capability](#capability)> | Yes| No| Capabilities list of the accessibility application.|
+| description | string | Yes| No| Description of the accessibility application.|
+| eventTypes | Array<[EventType](#eventtype)> | Yes| No| List of events that the accessibility application focuses on.|
+
+## Action
+
+Describes the target action supported by an accessibility application.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+| Name| Description|
+| -------- | -------- |
+| click | Clicking.|
+| longClick | Long pressing.|
+| scrollForward | Scrolling forward.|
+| scrollBackward | Scrolling backward.|
+| focus | Obtaining focus.|
+| clearFocus | Clearing focus.|
+| clearSelection | Clearing selection.|
+| accessibilityFocus | Obtaining the accessibility focus.|
+| clearAccessibilityFocus | Clearing the accessibility focus.|
+| cut | Cut.|
+| copy | Copy.|
+| paste | Paste.|
+| select | Select.|
+| setText | Setting the text.|
+| delete | Delete.|
+| setSelection | Setting the selection.|
+
+## Capability
+
+Enumerates the capabilities of an auxiliary application.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+| Name| Description|
+| -------- | -------- |
+| retrieve | Capability to retrieve the window content.|
+| touchGuide | Capability of touch guide mode.|
+| keyEventObserver | Capability to filter key events.|
+| zoom | Capability to control the display zoom level.|
+| gesture | Capability to perform gesture actions.|
+
+## CaptionsFontEdgeType8+
+
+Enumerates the caption font edge type.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing
+
+| Name| Description|
+| -------- | -------- |
+| none | No effect.|
+| raised | Raised effect.|
+| depressed | Depressed effect.|
+| uniform | Uniform effect.|
+| dropShadow | Drop shadow effect.|
+
+## CaptionsFontFamily8+
+
+Enumerates the caption font families.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing
+
+| Name| Description|
+| -------- | -------- |
+| default | Default font family.|
+| monospacedSerif | Monospaced Serif fonts, which use the same width for each character.|
+| serif | Serif fonts.|
+| monospacedSansSerif | Monospaced Sans Serif fonts, which use the same width for each character.|
+| sansSerif | Sans Serif fonts.|
+| casual | Casual fonts.|
+| cursive | Cursive fonts.|
+| smallCapitals | Small caps fonts.|
+
+## CaptionsStyle8+
+
+Describes the caption style.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | Yes| No| Font family of the captions.|
+| fontScale | number | Yes| No| Font scale of the captions.|
+| fontColor | number \| string | Yes| No| Font color of the captions.|
+| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | Yes| No| Font edge type of the captions.|
+| backgroundColor | number \| string | Yes| No| Background color of the captions.|
+| windowColor | number \| string | Yes| No| Window color of the captions.|
+
+## CaptionsManager8+
+
+Implements caption configuration management.
+
+### Attributes
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| enabled | boolean | Yes| No| Whether to enable caption configuration.|
+| style | [CaptionsStyle](#captionsstyle8) | Yes| No| Caption style.|
+
+### Methods
+
+In the following API examples, you must first use the [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) method to obtain a **captionsManager** instance, and then call the methods using the obtained instance.
+
+#### on('enableChange')
+
+on(type: 'enableChange', callback: Callback<boolean>): void;
+
+Enables listening for enable status changes of caption configuration.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing
+
+- **Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | type | string | Yes| Type of the event to listen for, which is set to **enableChange** in this API.|
+ | callback | Callback<boolean> | Yes| Callback invoked when the enable status of caption configuration changes.|
+
+- Example
+
+ ```typescript
+ captionsManager.on('enableChange',(data) => {
+ console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
+ })
+ ```
+
+#### on('styleChange')
+
+on(type: 'styleChange', callback: Callback<CaptionsStyle>): void;
+
+Enables listening for caption style changes.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing
+
+- **Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | type | string | Yes| Type of the event to listen for, which is set to **styleChange** in this API.|
+ | callback | Callback<[CaptionsStyle](#captionsstyle8)> | Yes| Callback invoked when the caption style changes.|
+
+- Example
+
+ ```typescript
+ captionsManager.on('styleChange',(data) => {
+ console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
+ })
+ ```
+
+#### off('enableChange')
+
+off(type: 'enableChange', callback?: Callback<boolean>): void;
+
+Disables listening for enable status changes of caption configuration.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing
+
+- **Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | type | string | Yes| Type of the event to listen for, which is set to **enableChange** in this API.|
+ | callback | Callback<boolean> | No| Callback invoked when the enable status of caption configuration changes.|
+
+- Example
+
+ ```typescript
+ captionsManager.off('enableChange')
+ ```
+
+#### off('styleChange')
+
+off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void;
+
+Disables listening for caption style changes.s is removed.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing
+
+- **Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | type | string | Yes| Type of the event to listen for, which is set to **styleChange** in this API.|
+ | callback | Callback<[CaptionsStyle](#captionsstyle8)> | No| Callback invoked when the caption style changes.|
+
+- Example
+
+ ```typescript
+ captionsManager.off('styleChange')
+ ```
+
+## EventInfo
+
+Describes a GUI change event.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+### Attributes
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| type | [EventType](#eventtype) | Yes| Yes| Accessibility event type.|
+| windowUpdateType | [WindowUpdateType](#windowupdatetype) | Yes| Yes| Window update type.|
+| bundleName | string | Yes| Yes| Target application name.|
+| componentType | string | Yes| Yes| Type of the event source component, for example, button or chart.|
+| pageId | number | Yes| Yes| Page ID of the event source.|
+| description | string | Yes| Yes| Event description.|
+| triggerAction | [Action](#action) | Yes| Yes| Action that triggers the event.|
+| textMoveUnit | [TextMoveUnit](#textmoveunit) | Yes| Yes| Text movement unit.|
+| contents | Array<string> | Yes| Yes| Array of contents.|
+| lastContent | string | Yes| Yes| Latest content.|
+| beginIndex | number | Yes| Yes| Sequence number of the first item displayed on the page.|
+| currentIndex | number | Yes| Yes| Sequence number of the current item.|
+| endIndex | number | Yes| Yes| Sequence number of the last item displayed on the page.|
+| itemCount | number | Yes| Yes| Total number of items.|
+
+## EventType
+
+Enumerates accessibility event types.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+| Name| Description|
+| -------- | -------- |
+| click | Event of clicking a component.|
+| longClick | Event of long-pressing a component.|
+| select | Event of selecting a component.|
+| focus | Event indicating that the component obtains the focus.|
+| textUpdate | Event indicating that the component text has been updated.|
+| hoverEnter | Event indicating that the hover enters a component.|
+| hoverExit | Event indicating that the hover exits a component.|
+| scroll | Event of the scroll view.|
+| textSelectionUpdate | Event indicating that the selected text has been updated.|
+| accessibilityFocus | Event indicating that the accessibility focus has been obtained.|
+| accessibilityFocusClear | Event indicating that the accessibility focus has been cleared.|
+
+## TextMoveUnit
+
+Enumerates the movement units for traversing the node text.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+| Name| Description|
+| -------- | -------- |
+| char | The movement unit for traversing the node text is by character.|
+| word | The movement unit for traversing the node text is by word.|
+| line | The movement unit for traversing the node text is by line.|
+| page | The movement unit for traversing the node text is by page.|
+| paragraph | The movement unit for traversing the node text is by paragraph.|
+
+## WindowUpdateType
+
+Enumerates window update types.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+| Name| Description|
+| -------- | -------- |
+| add | Window adding.|
+| remove | Window deletion.|
+| title | Window title change.|
+| bounds | Window boundary change.|
+| layer | Window layer change.|
+| active | Window activity change.|
+| focus | Window focus change.|
+| accessibilityFocus | Window accessibility focus change.|
+| parent | Parent window change.|
+| children | Child window change.|
+| pip | Picture-in-picture (PIP) mode change.|
+
+## accessibility.getAbilityLists
+
+getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<Array<AccessibilityAbilityInfo>>
+
+Obtains the accessibility application list. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+- **Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
+ | stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|
+
+- Return value
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise used to return the accessibility application list.|
+
+- Example
+
+ ```typescript
+ accessibility.getAbilityLists("spoken", "enable")
+ .then((data) => {
+ console.info('success data:getAbilityList1 : ' + JSON.stringify(data));
+ for (let item of data) {
+ console.info(item.id);
+ console.info(item.name);
+ console.info(item.description);
+ console.info(item.abilityTypes);
+ console.info(item.eventTypes);
+ console.info(item.capabilities);
+ console.info(item.packageName);
+ console.info(item.filterBundleNames);
+ console.info(item.bundleName);
+ }
+ }).catch((error) => {
+ console.error('failed to getAbilityList1 because ' + JSON.stringify(error));
+ })
+ ```
+
+## accessibility.getAbilityLists
+
+getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void
+
+Obtains the accessibility application list. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+- **Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
+ | stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|
+ | callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.|
+
+- Example
+
+ ```typescript
+ accessibility.getAbilityLists("visual", "enable", (err, data) => {
+ if (err) {
+ console.error('failed to getAbilityList2 because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('success data:getAbilityList2 : ' + JSON.stringify(data));
+ for (let item of data) {
+ console.info(item.id);
+ console.info(item.name);
+ console.info(item.description);
+ console.info(item.abilityTypes);
+ console.info(item.eventTypes);
+ console.info(item.capabilities);
+ console.info(item.packageName);
+ console.info(item.filterBundleNames);
+ console.info(item.bundleName);
+ }
+ })
+ ```
+
+## accessibility.getCaptionsManager8+
+
+getCaptionsManager(): CaptionsManager
+
+Obtains the accessibility caption configuration.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing
+
+- Return value
+
+ | Type| Description|
+ | -------- | -------- |
+ | [CaptionsManager](#captionsmanager8) | Accessibility caption configuration.|
+
+- Example
+
+ ```typescript
+ captionsManager = accessibility.getCaptionsManager()
+ ```
+
+## accessibility.on('accessibilityStateChange' | 'touchGuideStateChange')
+
+on(type: 'accessibilityStateChange' | 'touchGuideStateChange', callback: Callback<boolean>): void
+
+Enables listening for the accessibility application or touch guide mode status changes.
+
+- **Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | type | string | Yes| Type of the event to listen for.
- **accessibilityStateChange** means to listen for enable status changes of the accessibility application.
**System capability**: SystemCapability.Barrierfree.Accessibility.Core
- **touchGuideStateChange** means to listen for enable status changes of the touch guide mode.
**System capability**: SystemCapability.Barrierfree.Accessibility.Vision|
+ | callback | Callback<boolean> | Yes| Callback invoked when the enable status changes.|
+
+- Example
+
+ ```typescript
+ accessibility.on('accessibilityStateChange',(data) => {
+ console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
+ })
+ ```
+
+## accessibility.off('accessibilityStateChange' | 'touchGuideStateChange')
+
+off(type: 'accessibilityStateChange ' | 'touchGuideStateChange', callback?: Callback<boolean>): void
+
+Disables listening for the accessibility application or touch guide mode status changes.
+
+
+
+- **Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | type | string | No| Type of the event to listen for.
- **accessibilityStateChange** means to listen for enable status changes of the accessibility application.
**System capability**: SystemCapability.Barrierfree.Accessibility.Core
- **touchGuideStateChange** means to listen for enable status changes of the touch guide mode.
**System capability**: SystemCapability.Barrierfree.Accessibility.Vision|
+ | callback | Callback<boolean> | No| Callback invoked when the enable status changes.|
+
+- Example
+
+ ```typescript
+ accessibility.off('accessibilityStateChange',(data) => {
+ console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data))
+ })
+ ```
+
+## accessibility.isOpenAccessibility
+
+isOpenAccessibility(): Promise<boolean>
+
+Checks whether accessibility is enabled. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+- Return value
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<boolean> | Returns **true** if accessibility is enabled; returns **false** otherwise.|
+
+- Example
+
+ ```typescript
+ accessibility.isOpenAccessibility()
+ .then((data) => {
+ console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
+ }).catch((error) => {
+ console.error('failed to isOpenAccessibility because ' + JSON.stringify(error));
+ })
+ ```
+
+## accessibility.isOpenAccessibility
+
+isOpenAccessibility(callback: AsyncCallback<boolean>): void
+
+Checks whether accessibility is enabled. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+- Parameters
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.|
+
+- Example
+
+ ```typescript
+ accessibility.isOpenAccessibility((err, data) => {
+ if (err) {
+ console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
+ })
+ ```
+
+## accessibility.isOpenTouchGuide
+
+isOpenTouchGuide(): Promise<boolean>
+
+Checks whether touch guide mode is enabled. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+- Return value
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<boolean> | Returns **true** if touch guide mode is enabled; returns **false** otherwise.|
+
+- Example
+
+ ```typescript
+ accessibility.isOpenTouchGuide()
+ .then((data) => {
+ console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
+ }).catch((error) => {
+ console.error('failed to isOpenTouchGuide because ' + JSON.stringify(error));
+ })
+ ```
+
+## accessibility.isOpenTouchGuide
+
+isOpenTouchGuide(callback: AsyncCallback<boolean>): void
+
+Checks whether touch guide mode is enabled. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+- Parameters
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.|
+
+- Example
+
+ ```typescript
+ accessibility.isOpenTouchGuide((err, data) => {
+ if (err) {
+ console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
+ })
+ ```
+
+## accessibility.sendEvent
+
+sendEvent(event: EventInfo): Promise<void>
+
+Sends an accessibility event. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+- **Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
+
+- Return value
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise.|
+
+- Example
+
+ ```typescript
+ accessibility.sendEvent(this.eventInfo)
+ .then((data) => {
+ console.info('success data:sendEvent : ' + JSON.stringify(data))
+ }).catch((error) => {
+ console.error('failed to sendEvent because ' + JSON.stringify(error));
+ })
+ ```
+
+## accessibility.sendEvent
+
+sendEvent(event: EventInfo, callback: AsyncCallback<void>): void
+
+Sends an accessibility event. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Barrierfree.Accessibility.Core
+
+- **Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise.|
+
+- Example
+
+ ```typescript
+ accessibility.sendEvent(this.eventInfo,(err, data) => {
+ if (err) {
+ console.error('failed to sendEvent because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('success data:sendEvent : ' + JSON.stringify(data))
+ })
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md
index be6cd158135e72fe8fa598c930fd1bf15e3ddd04..bf7a006160c46af9bf7a2da5365253d084921607 100644
--- a/en/application-dev/reference/apis/js-apis-appAccount.md
+++ b/en/application-dev/reference/apis/js-apis-appAccount.md
@@ -1,7 +1,6 @@
# App Account Management
->  **NOTE**
->
+>  **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -12,23 +11,20 @@ import account_appAccount from '@ohos.account.appAccount';
```
-## System Capabilities
-
-SystemCapability.Account.AppAccount
-
-
## account_appAccount.createAppAccountManager
-createAppAccountManager(): AppAccountManager;
+createAppAccountManager(): AppAccountManager
Creates an **AppAccountManager** instance.
-- Return value
- | Type| Description|
- | -------- | -------- |
- | AppAccountManager | **AppAccountManager** instance created.|
+**System capability**: SystemCapability.Account.AppAccount
-- Example
+**Return Value**
+| Type | Description |
+| ----------------- | ------------------------ |
+| AppAccountManager | **AppAccountManager** instance created.|
+
+**Example**
```
var appAccountManager = account.createAppAccountManager();
```
@@ -39,20 +35,20 @@ Provides methods to manage app accounts.
### addAccount
-addAccount(name: string, callback: AsyncCallback<void>): void;
+addAccount(name: string, callback: AsyncCallback<void>): void
Adds an app account to the account management service. This method uses an asynchronous callback to return the result.
-Required permission: none.
+**System capability**: SystemCapability.Account.AppAccount
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | ------------------- | ---- | ------------------------------------------ |
- | name | string | Yes| Name of the app account to add.|
- | callback | AsyncCallback<void> | Yes| Callback invoked when the app account is added.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | ------------------------------------------ |
+| name | string | Yes | Name of the app account to add. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is added.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -63,21 +59,21 @@ Required permission: none.
### addAccount
-addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void;
+addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void
Adds an app account and its additional information to the account management service. This method uses an asynchronous callback to return the result.
-Required permission: none.
+**System capability**: SystemCapability.Account.AppAccount
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | --------- | ------------------- | ---- | ------------------------------------------------------------ |
- | name | string | Yes| Name of the app account to add.|
- | extraInfo | string | Yes| Additional information (for example, token) of the app account to add. The additional information cannot contain sensitive information about the app account.|
- | callback | AsyncCallback<void> | Yes| Callback invoked when the app account and its additional information are added.|
+| Name | Type | Mandatory| Description |
+| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
+| name | string | Yes | Name of the app account to add. |
+| extraInfo | string | Yes | Additional information (for example, token) of the app account to add. The additional information cannot contain sensitive information about the app account.|
+| callback | AsyncCallback<void> | Yes | Callback invoked when the app account and its additional information are added. |
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -90,26 +86,26 @@ Required permission: none.
### addAccount
-addAccount(name: string, extraInfo?: string): Promise<void>;
+addAccount(name: string, extraInfo?: string): Promise<void>
Adds an app account and its additional information to the account management service. This method uses a promise to return the result.
-Required permission: none.
+**System capability**: SystemCapability.Account.AppAccount
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | --------- | ------ | ---- | ------------------------------------------------------------ |
- | name | string | Yes| Name of the app account to add.|
- | extraInfo | string | Yes| Additional information of the app account to add. The additional information cannot contain sensitive information about the app account.|
+| Name | Type | Mandatory| Description |
+| --------- | ------ | ---- | ------------------------------------------------------------ |
+| name | string | Yes | Name of the app account to add. |
+| extraInfo | string | Yes | Additional information of the app account to add. The additional information cannot contain sensitive information about the app account.|
-- Return value
+**Return Value**
- | Type| Description|
- | ------------- | ---------------------------------- |
- | Promise<void> | Promise used to return the result.|
+| Type | Description |
+| ------------------- | ---------------------------------- |
+| Promise<void> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -122,38 +118,38 @@ Required permission: none.
### addAccountImplicitly8+
-addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
+addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
Implicitly adds an app account based on the specified account owner, authentication type, and options. This method uses an asynchronous callback to return the result.
-Required permission: none.
+**System capability**: SystemCapability.Account.AppAccount
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | --------------------- | --- | -------------------------- |
- | owner | string | Yes| Bundle name of the app account to add.|
- | authType | string | Yes| Authentication type of the app account to add.|
- | options | {[key: string]: any} | Yes| Options for the authentication.|
- | callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------------- | ---- | ------------------------------ |
+| owner | string | Yes | Bundle name of the app account to add.|
+| authType | string | Yes | Authentication type of the app account to add. |
+| options | {[key: string]: any} | Yes | Options for the authentication. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
-- Example
+**Example**
```
import featureAbility from '@ohos.ability.featureAbility';
-
+
function onResultCallback(code, result) {
console.log("resultCode: " + code);
console.log("result: " + JSON.stringify(result));
}
-
+
function onRequestRedirectedCallback(request) {
let abilityStartSetting = {want: request};
featureAbility.startAbility(abilityStartSetting, (err)=>{
console.log("startAbility err: " + JSON.stringify(err));
});
}
-
+
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccountImplicitly("LiSi", "readAge", {}, {
onResult: onResultCallback,
@@ -163,18 +159,20 @@ Required permission: none.
### deleteAccount
-deleteAccount(name: string, callback: AsyncCallback<void>): void;
+deleteAccount(name: string, callback: AsyncCallback<void>): void
Deletes an app account from the account management service. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------- | ------------------- | ---- | ---------------------------------- |
- | name | string | Yes| Name of the app account to delete.|
- | callback | AsyncCallback<void> | Yes| Callback invoked when the app account is deleted.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | ---------------------------------- |
+| name | string | Yes | Name of the app account to delete. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is deleted.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -185,23 +183,25 @@ Deletes an app account from the account management service. This method uses an
### deleteAccount
-deleteAccount(name: string): Promise<void>;
+deleteAccount(name: string): Promise<void>
Deletes an app account from the account management service. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | ------ | ------ | ---- | ------------------------ |
- | name | string | Yes| Name of the app account to delete.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------------------------ |
+| name | string | Yes | Name of the app account to delete.|
-- Return value
+**Return Value**
- | Type| Description|
- | :------------ | :---------------------------------- |
- | Promise<void> | Promise used to return the result.|
+| Type | Description |
+| :------------------ | :---------------------------------- |
+| Promise<void> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -214,19 +214,21 @@ Deletes an app account from the account management service. This method uses a p
### disableAppAccess
-disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void;
+disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void
Disables an app account from accessing an application with the given bundle name. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | ---------- | ------------------- | ---- | ------------------------------------------------------------ |
- | name | string | Yes| App account name.|
- | bundleName | string | Yes| Bundle name of an app.|
- | callback | AsyncCallback<void> | Yes| Callback invoked when the app account is disabled from accessing the application with the given bundle name.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------- | ---- | ------------------------------------------------------------ |
+| name | string | Yes | App account name. |
+| bundleName | string | Yes | Bundle name of an app. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is disabled from accessing the application with the given bundle name.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -237,24 +239,26 @@ Disables an app account from accessing an application with the given bundle name
### disableAppAccess
-disableAppAccess(name: string, bundleName: string): Promise<void>;
+disableAppAccess(name: string, bundleName: string): Promise<void>
Disables an app account from accessing an application with the given bundle name. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | ---------- | ------ | ---- | ---------------------------------- |
- | name | string | Yes| App account name.|
- | bundleName | string | Yes| Bundle name of an app.|
+| Name | Type | Mandatory| Description |
+| ---------- | ------ | ---- | ---------------------------------- |
+| name | string | Yes | App account name.|
+| bundleName | string | Yes | Bundle name of an app. |
-- Return value
+**Return Value**
- | Type| Description|
- | :------------ | :---------------------------------- |
- | Promise<void> | Promise used to return the result.|
+| Type | Description |
+| :------------------ | :---------------------------------- |
+| Promise<void> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -267,19 +271,21 @@ Disables an app account from accessing an application with the given bundle name
### enableAppAccess
-enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void;
+enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void
Enables an app account to access an application with the given bundle name. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | ---------- | ------------------- | ---- | ------------------------------------------------------------ |
- | name | string | Yes| App account name.|
- | bundleName | string | Yes| Bundle name of an app.|
- | callback | AsyncCallback<void> | Yes| Callback invoked when the app account is enabled to access the application with the given bundle name.|
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------- | ---- | ------------------------------------------------------------ |
+| name | string | Yes | App account name. |
+| bundleName | string | Yes | Bundle name of an app. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is enabled to access the application with the given bundle name.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -290,24 +296,26 @@ Enables an app account to access an application with the given bundle name. This
### enableAppAccess
-enableAppAccess(name: string, bundleName: string): Promise<void>;
+enableAppAccess(name: string, bundleName: string): Promise<void>
Enables an app account to access an application with the given bundle name. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | ---------- | ------ | ---- | ------------------ |
- | name | string | Yes| App account name.|
- | bundleName | string | Yes| Bundle name of an app.|
+**Parameters**
-- Return value
+| Name | Type | Mandatory| Description |
+| ---------- | ------ | ---- | ------------------ |
+| name | string | Yes | App account name. |
+| bundleName | string | Yes | Bundle name of an app.|
- | Type| Description|
- | :------------ | :---------------------------------- |
- | Promise<void> | Promise used to return the result.|
+**Return Value**
-- Example
+| Type | Description |
+| :------------------ | :---------------------------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
```
app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
@@ -319,20 +327,22 @@ Enables an app account to access an application with the given bundle name. This
### checkAppAccountSyncEnable
-checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void;
+checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void
Checks whether an app account allows application data synchronization. This method uses an asynchronous callback to return the result.
-The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
+
+**System capability**: SystemCapability.Account.AppAccount
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | ---------------------- | ---- | -------------------------------------------- |
- | name | string | Yes| App account name.|
- | callback | AsyncCallback<boolean> | Yes| Callback used to return whether the app account allows application data synchronization.|
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------- | ---- | -------------------------------------------- |
+| name | string | Yes | App account name. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the app account allows application data synchronization.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -344,25 +354,27 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis
### checkAppAccountSyncEnable
-checkAppAccountSyncEnable(name: string): Promise<boolean>;
+checkAppAccountSyncEnable(name: string): Promise<boolean>
Checks whether an app account allows application data synchronization. This method uses a promise to return the result.
-The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | ------ | ------ | ---- | -------------- |
- | name | string | Yes| App account name.|
+**Parameters**
-- Return value
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------- |
+| name | string | Yes | App account name.|
- | Type| Description|
- | :--------------- | :---------------------------------- |
- | Promise<boolean> | Promise used to return the result.|
+**Return Value**
-- Example
+| Type | Description |
+| :--------------------- | :---------------------------------- |
+| Promise<boolean> | Promise used to return the result.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -375,20 +387,22 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis
### setAccountCredential
-setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void;
+setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void
Sets a credential for an app account. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------------- | ------------------- | ---- | ---------------------------- |
- | name | string | Yes| App account name.|
- | credentialType | string | Yes| Type of the credential to set.|
- | credential | string | Yes| Credential to set.|
- | callback | AsyncCallback<void> | Yes| Callback invoked when a credential is set for the specified app account.|
+| Name | Type | Mandatory| Description |
+| -------------- | ------------------------- | ---- | ---------------------------- |
+| name | string | Yes | App account name. |
+| credentialType | string | Yes | Type of the credential to set. |
+| credential | string | Yes | Credential to set. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when a credential is set for the specified app account.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -399,25 +413,27 @@ Sets a credential for an app account. This method uses an asynchronous callback
### setAccountCredential
-setAccountCredential(name: string, credentialType: string, credential: string): Promise<void>;
+setAccountCredential(name: string, credentialType: string, credential: string): Promise<void>
Sets a credential for an app account. This method uses a promise to return the result asynchronously.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------------- | ------ | ---- | -------------------- |
- | name | string | Yes| App account name.|
- | credentialType | string | Yes| Type of the credential to set.|
- | credential | string | Yes| Credential to set.|
+**Parameters**
-- Return value
+| Name | Type | Mandatory| Description |
+| -------------- | ------ | ---- | -------------------- |
+| name | string | Yes | App account name. |
+| credentialType | string | Yes | Type of the credential to set.|
+| credential | string | Yes | Credential to set. |
- | Type| Description|
- | :------------ | :---------------------------------- |
- | Promise<void> | Promise used to return the result.|
+**Return Value**
-- Example
+| Type | Description |
+| :------------------ | :---------------------------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -430,19 +446,21 @@ Sets a credential for an app account. This method uses a promise to return the r
### setAccountExtraInfo
-setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void;
+setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void
Sets additional information for an app account. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | --------- | ------------------- | ---- | -------------------------------- |
- | name | string | Yes| App account name.|
- | extraInfo | string | Yes| Additional information to set.|
- | callback | AsyncCallback<void> | Yes| Callback invoked when additional information is set for the specified app account.|
+| Name | Type | Mandatory| Description |
+| --------- | ------------------------- | ---- | -------------------------------- |
+| name | string | Yes | App account name. |
+| extraInfo | string | Yes | Additional information to set. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when additional information is set for the specified app account.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -453,24 +471,26 @@ Sets additional information for an app account. This method uses an asynchronous
### setAccountExtraInfo
-setAccountExtraInfo(name: string, extraInfo: string): Promise<void>;
+setAccountExtraInfo(name: string, extraInfo: string): Promise<void>
Sets additional information for an app account. This method uses a promise to return the result asynchronously.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | --------- | ------ | ---- | ------------------ |
- | name | string | Yes| App account name.|
- | extraInfo | string | Yes| Additional information to set.|
+**Parameters**
-- Return value
+| Name | Type | Mandatory| Description |
+| --------- | ------ | ---- | ------------------ |
+| name | string | Yes | App account name. |
+| extraInfo | string | Yes | Additional information to set.|
- | Type| Description|
- | :------------ | :---------------------------------- |
- | Promise<void> | Promise used to return the result.|
+**Return Value**
-- Example
+| Type | Description |
+| :------------------ | :---------------------------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -483,21 +503,23 @@ Sets additional information for an app account. This method uses a promise to re
### setAppAccountSyncEnable
-setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void;
+setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void
Sets whether to enable application data synchronization for an app account. This method uses an asynchronous callback to return the result.
-The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
+
+**System capability**: SystemCapability.Account.AppAccount
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | ------------------- | ---- | -------------------------------------------------- |
- | name | string | Yes| App account name.|
- | isEnable | boolean | Yes| Whether to enable app data synchronization.|
- | callback | AsyncCallback<void> | Yes| Callback invoked when application data synchronization is enabled or disabled for the app account.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | -------------------------------------------------- |
+| name | string | Yes | App account name. |
+| isEnable | boolean | Yes | Whether to enable app data synchronization. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when application data synchronization is enabled or disabled for the app account.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -508,26 +530,28 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis
### setAppAccountSyncEnable
-setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>;
+setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>
Sets whether to enable application data synchronization for an app account. This method uses a promise to return the result asynchronously.
-The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
+
+**System capability**: SystemCapability.Account.AppAccount
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | ------- | ---- | ---------------------- |
- | name | string | Yes| App account name.|
- | isEnable | boolean | Yes| Whether to enable app data synchronization.|
+| Name | Type | Mandatory| Description |
+| -------- | ------- | ---- | ---------------------- |
+| name | string | Yes | App account name. |
+| isEnable | boolean | Yes | Whether to enable app data synchronization.|
-- Return value
+**Return Value**
- | Type| Description|
- | :------------ | :---------------------------------- |
- | Promise<void> | Promise used to return the result.|
+| Type | Description |
+| :------------------ | :---------------------------------- |
+| Promise<void> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -540,20 +564,22 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis
### setAssociatedData
-setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void;
+setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void
Sets data to be associated with an app account. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------- | ------------------- | ---- | ---------------------------------- |
- | name | string | Yes| App account name.|
- | key | string | Yes| Key of the data to set. The private key can be customized.|
- | value | string | Yes| Value of the data to be set.|
- | callback | AsyncCallback<void> | Yes| Callback invoked when the data associated with the specified app account is set.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | ---------------------------------- |
+| name | string | Yes | App account name. |
+| key | string | Yes | Key of the data to set. The private key can be customized.|
+| value | string | Yes | Value of the data to be set. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when the data associated with the specified app account is set.|
+
+**Example**
```
app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
@@ -563,25 +589,27 @@ Sets data to be associated with an app account. This method uses an asynchronous
### setAssociatedData
-setAssociatedData(name: string, key: string, value: string): Promise<void>;
+setAssociatedData(name: string, key: string, value: string): Promise<void>
Sets data to be associated with an app account. This method uses a promise to return the result asynchronously.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | ------ | ------ | ---- | ---------------------------------- |
- | name | string | Yes| App account name.|
- | key | string | Yes| Key of the data to set. The private key can be customized.|
- | value | string | Yes| Value of the data to be set.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------------------------- |
+| name | string | Yes | App account name. |
+| key | string | Yes | Key of the data to set. The private key can be customized.|
+| value | string | Yes | Value of the data to be set. |
-- Return value
+**Return Value**
- | Type| Description|
- | :------------ | :---------------------------------- |
- | Promise<void> | Promise used to return the result.|
+| Type | Description |
+| :------------------ | :---------------------------------- |
+| Promise<void> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -594,19 +622,21 @@ Sets data to be associated with an app account. This method uses a promise to re
### getAccountCredential
-getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void;
+getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void
Obtains the credential of an app account. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------------- | --------------------- | ---- | ---------------------------- |
- | name | string | Yes| App account name.|
- | credentialType | string | Yes| Type of the credential to obtain.|
- | callback | AsyncCallback<string> | Yes| Callback invoked to return the credential of the specified app account.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| -------------- | --------------------------- | ---- | ---------------------------- |
+| name | string | Yes | App account name. |
+| credentialType | string | Yes | Type of the credential to obtain. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the credential of the specified app account.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -618,24 +648,26 @@ Obtains the credential of an app account. This method uses an asynchronous callb
### getAccountCredential
-getAccountCredential(name: string, credentialType: string): Promise<string>;
+getAccountCredential(name: string, credentialType: string): Promise<string>
Obtains the credential of an app account. This method uses a promise to return the result asynchronously.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------------- | ------ | ---- | -------------------- |
- | name | string | Yes| App account name.|
- | credentialType | string | Yes| Type of the credential to obtain.|
+| Name | Type | Mandatory| Description |
+| -------------- | ------ | ---- | -------------------- |
+| name | string | Yes | App account name. |
+| credentialType | string | Yes | Type of the credential to obtain.|
-- Return value
+**Return Value**
- | Type| Description|
- | :-------------- | :---------------------------------- |
- | Promise<string> | Promise used to return the result.|
+| Type | Description |
+| :-------------------- | :---------------------------------- |
+| Promise<string> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -648,18 +680,20 @@ Obtains the credential of an app account. This method uses a promise to return t
### getAccountExtraInfo
-getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void;
+getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void
Obtains additional information of an app account. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------- | --------------------- | ---- | -------------------------------- |
- | name | string | Yes| App account name.|
- | callback | AsyncCallback<string> | Yes| Callback invoked to return the additional information of the specified app account.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------- | ---- | -------------------------------- |
+| name | string | Yes | App account name. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the additional information of the specified app account.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -671,23 +705,25 @@ Obtains additional information of an app account. This method uses an asynchrono
### getAccountExtraInfo
-getAccountExtraInfo(name: string): Promise<string>;
+getAccountExtraInfo(name: string): Promise<string>
Obtains additional information of an app account. This method uses a promise to return the result asynchronously.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | ------ | ------ | ---- | -------------- |
- | name | string | Yes| App account name.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------- |
+| name | string | Yes | App account name.|
-- Return value
+**Return Value**
- | Type| Description|
- | :-------------- | :---------------------------------- |
- | Promise<string> | Promise used to return the result.|
+| Type | Description |
+| :-------------------- | :---------------------------------- |
+| Promise<string> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -700,19 +736,21 @@ Obtains additional information of an app account. This method uses a promise to
### getAssociatedData
-getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void;
+getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void
Obtains data associated with an app account. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------- | --------------------- | ---- | ---------------------------------- |
- | name | string | Yes| App account name.|
- | key | string | Yes| Key of the data to obtain.|
- | callback | AsyncCallback<string> | Yes| Callback invoked to return the data associated with the specified app account.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------- | ---- | ---------------------------------- |
+| name | string | Yes | App account name. |
+| key | string | Yes | Key of the data to obtain. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the data associated with the specified app account.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -724,24 +762,26 @@ Obtains data associated with an app account. This method uses an asynchronous ca
### getAssociatedData
-getAssociatedData(name: string, key: string): Promise<string>;
+getAssociatedData(name: string, key: string): Promise<string>
Obtains data associated with an app account. This method uses a promise to return the result asynchronously.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | ------ | ------ | ---- | ------------------- |
- | name | string | Yes| App account name.|
- | key | string | Yes| Key of the data to obtain.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------------------- |
+| name | string | Yes | App account name. |
+| key | string | Yes | Key of the data to obtain.|
-- Return value
+**Return Value**
- | Type| Description|
- | :-------------- | :---------------------------------- |
- | Promise<string> | Promise used to return the result.|
+| Type | Description |
+| :-------------------- | :---------------------------------- |
+| Promise<string> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -754,19 +794,21 @@ Obtains data associated with an app account. This method uses a promise to retur
### getAllAccessibleAccounts
-getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void;
+getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void
Obtains information about all accessible app accounts. This method uses an asynchronous callback to return the result.
-The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only.
+**Required permissions**: ohos.permission.GET_ACCOUNTS_PRIVILEGED (available only to system applications)
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------- | ------------------------------------ | ---- | ---------------- |
- | callback | AsyncCallback<Array<AppAccountInfo>> | Yes| Callback invoked to return information about all accessible app accounts.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------ | ---- | ---------------- |
+| callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -778,19 +820,21 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per
### getAllAccessibleAccounts
-getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>;
+getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>
+
+Obtains information about all accessible app accounts. This method uses an asynchronous callback to return the result.
-Obtains information about all accessible app accounts. This method uses a promise to return the result.
+**Required permissions**: ohos.permission.GET_ACCOUNTS_PRIVILEGED (available only to system applications)
-The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only.
+**System capability**: SystemCapability.Account.AppAccount
-- Parameters
+**Parameters**
- | Type| Description|
- | ------------------------------ | ----------------------------------- |
- | Promise<Array<AppAccountInfo>> | Promise used to return the result.|
+| Type | Description |
+| ------------------------------------------ | ----------------------------------- |
+| Promise<Array<AppAccountInfo>> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -803,20 +847,22 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per
### getAllAccounts
-getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void;
+getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void
Obtains information about all app accounts of the specified app. This method uses an asynchronous callback to return the result.
-The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only.
+**Required permissions**: ohos.permission.GET_ACCOUNTS_PRIVILEGED (available only to system applications)
+
+**System capability**: SystemCapability.Account.AppAccount
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | ------------------------------------ | ---- | ---------------- |
- | owner | string | Yes| Bundle name of the app.|
- | callback | AsyncCallback<Array<AppAccountInfo>> | Yes| Callback invoked to return information about all app accounts.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------ | ---- | ---------------- |
+| owner | string | Yes | Bundle name of the app. |
+| callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts.|
-- Example
+**Example**
```
const appAccountManager = account.createAppAccountManager();
@@ -829,25 +875,27 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per
### getAllAccounts
-getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>;
+getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>
+
+Obtains information about all app accounts of the specified app. This method uses an asynchronous callback to return the result.
-Obtains information about all app accounts of the specified app. This method uses a promise to return the result.
+**Required permissions**: ohos.permission.GET_ACCOUNTS_PRIVILEGED (available only to system applications)
-The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only.
+**System capability**: SystemCapability.Account.AppAccount
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | ------ | ------ | ---- | ---------- |
- | owner | string | Yes| Bundle name of the app.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------- |
+| owner | string | Yes | Bundle name of the app.|
-- Parameters
+**Parameters**
- | Type| Description|
- | ------------------------------ | ----------------------------------- |
- | Promise<Array<AppAccountInfo>> | Promise used to return the result.|
+| Type | Description |
+| ------------------------------------------ | ----------------------------------- |
+| Promise<Array<AppAccountInfo>> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -861,19 +909,21 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per
### on('change')
-on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void;
+on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void
Subscribes to the account change event of the specified account owners. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
- | type | 'change' | Yes| Type of the event to subscribe to. The subscriber will receive a notification when the account owners update their accounts.|
- | owners | Array<string> | Yes| Owners of the accounts.|
- | callback | Callback<Array<AppAccountInfo>> | Yes| Callback invoked to return the account change.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
+| type | 'change' | Yes | Type of the event to subscribe to. The subscriber will receive a notification when the account owners update their accounts.|
+| owners | Array<string> | Yes | Owners of the accounts. |
+| callback | Callback<Array<AppAccountInfo>> | Yes | Callback invoked to return the account change. |
+
+**Example**
```
const appAccountManager = account.createAppAccountManager();
@@ -890,18 +940,20 @@ Subscribes to the account change event of the specified account owners. This met
### off('change')
-off(type: 'change', callback?: Callback<void>): void;
+off(type: 'change', callback?: Callback>): void
Unsubscribes from the account change event. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------------------- | ---- | ------------------------ |
- | type | 'change' | Yes| Account change event to unsubscribe from.|
- | callback | Callback<void> | No| Callback used to report the account change.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------- | ---- | ------------------------ |
+| type | 'change' | Yes | Account change event to unsubscribe from. |
+| callback | Callback> | No | Callback used to report the account change.|
-- Example
+**Example**
```
const appAccountManager = account.createAppAccountManager();
@@ -921,37 +973,39 @@ Unsubscribes from the account change event. This method uses an asynchronous cal
### authenticate8+
-authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
+authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
Authenticates an app account to obtain the Open Authorization (OAuth) access token. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | --------------------- | ---- | --------------------------- |
- | name | string | Yes| Name of the app account to authenticate.|
- | owner | string | Yes| Bundle name of the app.|
- | authType | string | Yes| Authentication type.|
- | options | {[key: string]: any} | Yes| Options for the authentication.|
- | callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------------- | ---- | ------------------------------ |
+| name | string | Yes | Name of the app account to authenticate. |
+| owner | string | Yes | Bundle name of the app.|
+| authType | string | Yes | Authentication type. |
+| options | {[key: string]: any} | Yes | Options for the authentication. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
-- Example
+**Example**
```
import featureAbility from '@ohos.ability.featureAbility';
-
+
function onResultCallback(code, result) {
console.log("resultCode: " + code);
console.log("result: " + JSON.stringify(result));
}
-
+
function onRequestRedirectedCallback(request) {
let abilityStartSetting = {want: request};
featureAbility.startAbility(abilityStartSetting, (err)=>{
console.log("startAbility err: " + JSON.stringify(err));
});
}
-
+
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "readAge", {}, {
onResult: onResultCallback,
@@ -961,20 +1015,22 @@ Authenticates an app account to obtain the Open Authorization (OAuth) access tok
### getOAuthToken8+
-getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void;
+getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void
Obtains the OAuth access token of an app account based on the specified authentication type. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | --------------------------- | ---- | -------------------- |
- | name | string | Yes| App account name.|
- | owner | string | Yes| Bundle name of the app.|
- | authType | string | Yes| Authentication type.|
- | callback | AsyncCallback<string> | Yes| Callback invoked to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------- | ---- | ---------------------- |
+| name | string | Yes | App account name. |
+| owner | string | Yes | Bundle name of the app.|
+| authType | string | Yes | Authentication type. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. |
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -986,25 +1042,27 @@ Obtains the OAuth access token of an app account based on the specified authenti
### getOAuthToken8+
-getOAuthToken(name: string, owner: string, authType: string): Promise<string>;
+getOAuthToken(name: string, owner: string, authType: string): Promise<string>
Obtains the OAuth access token of an app account based on the specified authentication type. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------- | ------ | ---- | -------------------- |
- | name | string | Yes| App account name.|
- | owner | string | Yes| Bundle name of the app.|
- | authType | string | Yes| Authentication type.|
+**Parameters**
-- Parameters
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ---------------------- |
+| name | string | Yes | App account name. |
+| owner | string | Yes | Bundle name of the app.|
+| authType | string | Yes | Authentication type. |
- | Type| Description|
- | --------------------- | -------------------------------- |
- | Promise<string> | Promise used to return the result.|
+**Parameters**
-- Example
+| Type | Description |
+| --------------------- | ----------------------------------- |
+| Promise<string> | Promise used to return the result.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1017,20 +1075,22 @@ Obtains the OAuth access token of an app account based on the specified authenti
### setOAuthToken8+
-setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void;
+setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void
Sets an OAuth access token for an app account. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | ------------------------- | ---- | ------------- |
- | name | string | Yes| App account name.|
- | authType | string | Yes| Authentication type.|
- | token | string | Yes| OAuth access token to set.|
- | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | ---------------- |
+| name | string | Yes | App account name.|
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | OAuth access token to set. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1041,25 +1101,27 @@ Sets an OAuth access token for an app account. This method uses an asynchronous
### setOAuthToken8+
-setOAuthToken(name: string, authType: string, token: string): Promise<void>;
+setOAuthToken(name: string, authType: string, token: string): Promise<void>
Sets an OAuth access token for an app account. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------- | ------ | ---- | ------------- |
- | name | string | Yes| App account name.|
- | authType | string | Yes| Authentication type.|
- | token | string | Yes| OAuth access token to set.|
+**Parameters**
-- Parameters
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ---------------- |
+| name | string | Yes | App account name.|
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | OAuth access token to set. |
- | Type| Description|
- | ------------------- | -------------------------------- |
- | Promise<void> | Promise used to return the result.|
+**Parameters**
-- Example
+| Type | Description |
+| ------------------- | ----------------------------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1072,21 +1134,23 @@ Sets an OAuth access token for an app account. This method uses a promise to ret
### deleteOAuthToken8+
-deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void;
+deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void
Deletes the specified OAuth access token for an app account. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | ------------------------- | ---- | ------------------ |
- | name | string | Yes| App account name.|
- | owner | string | Yes| Bundle name of the app.|
- | authType | string | Yes| Authentication type.|
- | token | string | Yes| OAuth access token to delete.|
- | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | ---------------------- |
+| name | string | Yes | App account name. |
+| owner | string | Yes | Bundle name of the app.|
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | OAuth access token to delete. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1097,26 +1161,28 @@ Deletes the specified OAuth access token for an app account. This method uses an
### deleteOAuthToken8+
-deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>;
+deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>
Deletes the specified OAuth access token for an app account. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | ------ | ---- | ------------------ |
- | name | string | Yes| App account name.|
- | owner | string | Yes| Bundle name of the app.|
- | authType | string | Yes| Authentication type.|
- | token | string | Yes| OAuth access token to delete.|
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ---------------------- |
+| name | string | Yes | App account name. |
+| owner | string | Yes | Bundle name of the app.|
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | OAuth access token to delete. |
-- Parameters
+**Parameters**
- | Type| Description|
- | ------------------------------ | --------------------- |
- | Promise<void> | Promise used to return the result.|
+| Type | Description |
+| ------------------- | ----------------------------------- |
+| Promise<void> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1129,21 +1195,23 @@ Deletes the specified OAuth access token for an app account. This method uses a
### setOAuthTokenVisibility8+
-setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void;
+setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void
Sets the visibility of an OAuth access token to the specified app. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | ---------- | ------------------------- | ---- | ------------------- |
- | name | string | Yes| App account name.|
- | authType | string | Yes| Authentication type.|
- | bundleName | string | Yes| Bundle name of the app.|
- | isVisible | boolean | Yes| Whether the OAuth access token is visible to the app.|
- | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------- | ---- | ------------------------ |
+| name | string | Yes | App account name. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app.|
+| isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1154,26 +1222,28 @@ Sets the visibility of an OAuth access token to the specified app. This method u
### setOAuthTokenVisibility8+
-setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>;
+setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>
Sets the visibility of an OAuth access token to the specified app. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | ---------- | ------------------------- | ---- | ------------------- |
- | name | string | Yes| App account name.|
- | authType | string | Yes| Authentication type.|
- | bundleName | string | Yes| Bundle name of the app.|
- | isVisible | boolean | Yes| Whether the OAuth access token is visible to the app.|
+| Name | Type | Mandatory| Description |
+| ---------- | ------- | ---- | ------------------------ |
+| name | string | Yes | App account name. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app.|
+| isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. |
-- Parameters
+**Parameters**
- | Type| Description|
- | ------------------------------ | --------------------- |
- | Promise<void> | Promise used to return the result.|
+| Type | Description |
+| ------------------- | ----------------------------------- |
+| Promise<void> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1187,20 +1257,22 @@ Sets the visibility of an OAuth access token to the specified app. This method u
### checkOAuthTokenVisibility8+
-checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void;
+checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void
Checks whether an OAuth token is visible to the specified app. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | ---------- | ---------------------------- | ---- | ---------------------- |
- | name | string | Yes| App account name.|
- | authType | string | Yes| Authentication type.|
- | bundleName | string | Yes| Bundle name of the app.|
- | callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| ---------- | ---------------------------- | ---- | -------------------------- |
+| name | string | Yes | App account name. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app.|
+| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. |
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1212,25 +1284,27 @@ Checks whether an OAuth token is visible to the specified app. This method uses
### checkOAuthTokenVisibility8+
-checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>;
+checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>
Checks whether an OAuth token is visible to the specified app. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | ---------- | ------------------------- | ---- | ---------------------- |
- | name | string | Yes| App account name.|
- | authType | string | Yes| Authentication type.|
- | bundleName | string | Yes| Bundle name of the app.|
+| Name | Type | Mandatory| Description |
+| ---------- | ------ | ---- | -------------------------- |
+| name | string | Yes | App account name. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app.|
-- Parameters
+**Parameters**
- | Type| Description|
- | ------------------------------ | ------------------------ |
- | Promise<boolean> | Promise used to return the result.|
+| Type | Description |
+| ---------------------- | ----------------------------------- |
+| Promise<boolean> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1243,19 +1317,21 @@ Checks whether an OAuth token is visible to the specified app. This method uses
### getAllOAuthTokens8+
-getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void;
+getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void
Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------- | ------------------------------------------------ | ---- | ------------------- |
- | name | string | Yes| App account name.|
- | owner | string | Yes| Bundle name of the app.|
- | callback | AsyncCallback<Array<OAuthTokenInfo>> | Yes| Callback invoked to return the result.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------ | ---- | ---------------------- |
+| name | string | Yes | App account name. |
+| owner | string | Yes | Bundle name of the app.|
+| callback | AsyncCallback<Array<OAuthTokenInfo>> | Yes | Callback invoked to return the result. |
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1267,24 +1343,26 @@ Obtains information about all OAuth access tokens of an app account visible to t
### getAllOAuthTokens8+
-getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>>;
+getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>>
Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | ------ | ---- | ------------------- |
- | name | string | Yes| App account name.|
- | owner | string | Yes| Bundle name of the app.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------------- |
+| name | string | Yes | App account name. |
+| owner | string | Yes | Bundle name of the app.|
-- Parameters
+**Parameters**
- | Type| Description|
- | ------------------------------ | ----------------------------------- |
- | Promise<Array<OAuthTokenInfo>> | Promise used to return the result.|
+| Type | Description |
+| ------------------------------------------ | ----------------------------------- |
+| Promise<Array<OAuthTokenInfo>> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1297,19 +1375,21 @@ Obtains information about all OAuth access tokens of an app account visible to t
### getOAuthList8+
-getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void;
+getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void
Obtains the authorization list of OAuth access tokens of an app account. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | -------- | ---------------------------------------- | ---- | ------------------ |
- | name | string | Yes| App account name.|
- | owner | string | Yes| Bundle name of the app.|
- | callback | AsyncCallback<Array<string>> | Yes| Callback invoked to return the result.|
+**Parameters**
-- Example
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------------------- | ---- | ---------------------- |
+| name | string | Yes | App account name. |
+| owner | string | Yes | Bundle name of the app.|
+| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. |
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1321,24 +1401,26 @@ Obtains the authorization list of OAuth access tokens of an app account. This me
### getOAuthList8+
-getOAuthList(name: string, authType: string): Promise<Array<string>>;
+getOAuthList(name: string, authType: string): Promise<Array<string>>
Obtains the authorization list of OAuth access tokens of an app account. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | ------ | ---- | ------------------- |
- | name | string | Yes| App account name.|
- | owner | string | Yes| Bundle name of the app.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------------- |
+| name | string | Yes | App account name. |
+| owner | string | Yes | Bundle name of the app.|
-- Parameters
+**Parameters**
- | Type| Description|
- | ------------------------------ | ------------------------------------ |
- | Promise<Array<string>> | Promise used to return the result.|
+| Type | Description |
+| ---------------------------------- | ----------------------------------- |
+| Promise<Array<string>> | Promise used to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1351,63 +1433,71 @@ Obtains the authorization list of OAuth access tokens of an app account. This me
### getAuthenticatorCallback8+
-getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void;
+getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void
Obtains the authenticator callback for a session. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | --------- | ------------------------------------------ | ---- | -------------- |
- | sessionId | string | Yes| ID of the session to authenticate.|
- | callback | AsyncCallback<AuthenticatorCallback> | Yes| Callback invoked to return the result.|
+| Name | Type | Mandatory| Description |
+| --------- | ------------------------------------------ | ---- | ---------------- |
+| sessionId | string | Yes | ID of the session to authenticate.|
+| callback | AsyncCallback<AuthenticatorCallback> | Yes | Callback invoked to return the result.|
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant((err, want) => {
- var sessionId = want.parameters[Constants.KEY_SESSION_ID];
+ var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => {
- if (err.code != ResultCode.SUCCESS) {
+ if (err.code != account_appAccount.ResultCode.SUCCESS) {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
return;
}
- var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo",
- Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"};
- callback.OnResult(ResultCode.SUCCESS, result);
+ var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
+ [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
+ [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
});
});
```
### getAuthenticatorCallback8+
-getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>;
+getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>
Obtains the authenticator callback for a session. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | ---------- | ------ | ---- | -------------- |
- | sessionId | string | Yes| ID of the session to authenticate.|
+**Parameters**
-- Parameters
+| Name | Type | Mandatory| Description |
+| --------- | ------ | ---- | ---------------- |
+| sessionId | string | Yes | ID of the session to authenticate.|
- | Type| Description|
- | ------------------------------------ | -------------------------------- |
- | Promise<AuthenticatorCallback> | Promise used to return the result.|
+**Parameters**
-- Example
+| Type | Description |
+| ------------------------------------ | ----------------------------------- |
+| Promise<AuthenticatorCallback> | Promise used to return the result.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant().then((want) => {
- var sessionId = want.parameters[Constants.KEY_SESSION_ID];
+ var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
- var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo",
- Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"};
- callback.OnResult(ResultCode.SUCCESS, result);
+ var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
+ [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
+ [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
});
@@ -1418,18 +1508,20 @@ Obtains the authenticator callback for a session. This method uses a promise to
### getAuthenticatorInfo8+
-getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void;
+getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void
Obtains authenticator information of an app account. This method uses an asynchronous callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------------------------------------- | ---- | ------------------- |
- | owner | string | Yes| Bundle name of the app.|
- | callback | AsyncCallback<AuthenticatorInfo> | Yes| Callback invoked to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------------- | ---- | ---------------------- |
+| owner | string | Yes | Bundle name of the app.|
+| callback | AsyncCallback<AuthenticatorInfo> | Yes | Callback invoked to return the result. |
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1441,23 +1533,25 @@ Obtains authenticator information of an app account. This method uses an asynchr
### getAuthenticatorInfo8+
-getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>;
+getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>
Obtains authenticator information of an app account. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Account.AppAccount
- | Name| Type| Mandatory| Description|
- | ----- | ------ | ---- | -------------------- |
- | owner | string | Yes| Bundle name of the app.|
+**Parameters**
-- Parameters
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------------- |
+| owner | string | Yes | Bundle name of the app.|
- | Type| Description|
- | ------------------------------ | ----------------------------------- |
- | Promise<AuthenticatorInfo> | Promise used to return the result.|
+**Parameters**
-- Example
+| Type | Description |
+| -------------------------------- | ----------------------------------- |
+| Promise<AuthenticatorInfo> | Promise used to return the result.|
+
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
@@ -1472,73 +1566,83 @@ Obtains authenticator information of an app account. This method uses a promise
Defines app account information.
-| Name| Type| Mandatory| Description|
-| ----- | ------ | ---- | ---------------- |
-| owner | string | Yes| Bundle name of the app.|
-| name | string | Yes| App account name.|
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------------- |
+| owner | string | Yes | Bundle name of the app.|
+| name | string | Yes | App account name. |
## OAuthTokenInfo8+
Defines OAuth access token information.
-| Name| Type| Mandatory| Description|
-| -------- | ------ | ---- | -------------- |
-| authType | string | Yes| Authentication type.|
-| token | string | Yes| Value of the access token.|
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ---------------- |
+| authType | string | Yes | Authentication type.|
+| token | string | Yes | Value of the access token. |
## AuthenticatorInfo8+
Defines OAuth authenticator information.
-| Name| Type| Mandatory| Description|
-| ------- | ------ | ---- | ------------------ |
-| owner | string | Yes| Bundle name of the authenticator owner.|
-| iconId | string | Yes| ID of the authenticator icon.|
-| labelId | string | Yes| ID of the authenticator label.|
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Type | Mandatory| Description |
+| ------- | ------ | ---- | -------------------- |
+| owner | string | Yes | Bundle name of the authenticator owner.|
+| iconId | string | Yes | ID of the authenticator icon. |
+| labelId | string | Yes | ID of the authenticator label. |
## Constants8+
Enumerates the constants.
-| Name| Default Value| Description|
-| ----------------------------- | ---------------------- | ----------------------- |
-| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation for implicitly adding an account.|
-| ACTION_AUTHENTICATE | "authenticate" | Authentication operation.|
-| KEY_NAME | "name" | App account name.|
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Default Value | Description |
+| ----------------------------- | ---------------------- | ------------------------- |
+| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation for implicitly adding an account. |
+| ACTION_AUTHENTICATE | "authenticate" | Authentication operation. |
+| KEY_NAME | "name" | App account name. |
| KEY_OWNER | "owner" | App account owner.|
-| KEY_TOKEN | "token" | OAuth access token.|
-| KEY_ACTION | "action" | Action.|
-| KEY_AUTH_TYPE | "authType" | Authentication type.|
-| KEY_SESSION_ID | "sessionId" | Session ID.|
-| KEY_CALLER_PID | "callerPid" | Caller process ID (PID).|
-| KEY_CALLER_UID | "callerUid" | Caller user ID (UID).|
-| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Caller bundle name.|
+| KEY_TOKEN | "token" | OAuth access token. |
+| KEY_ACTION | "action" | Action. |
+| KEY_AUTH_TYPE | "authType" | Authentication type. |
+| KEY_SESSION_ID | "sessionId" | Session ID. |
+| KEY_CALLER_PID | "callerPid" | Caller process ID (PID). |
+| KEY_CALLER_UID | "callerUid" | Caller user ID (UID). |
+| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Caller bundle name. |
## ResultCode8+
Enumerates the result codes.
-| Name| Default Value| Description|
-| ----------------------------------- | ----- | ---------------------- |
-| SUCCESS | 0 | The operation is successful.|
-| ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist.|
-| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal.|
-| ERROR_INVALID_PASSWORD | 10003 | The password is invalid.|
-| ERROR_INVALID_REQUEST | 10004 | The request is invalid.|
-| ERROR_INVALID_RESPONSE | 10005 | The response is invalid.|
-| ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal.|
-| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist.|
-| ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled.|
-| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit.|
-| ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy.|
-| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal.|
-| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist.|
-| ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out.|
-| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth access token does not exist.|
-| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth access tokens reaches the limit.|
-| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported.|
-| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported.|
-| ERROR_PERMISSION_DENIED | 10018 | The required permission is missing.|
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Default Value| Description |
+| ----------------------------------- | ------ | ------------------------ |
+| SUCCESS | 0 | The operation is successful. |
+| ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist. |
+| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal. |
+| ERROR_INVALID_PASSWORD | 10003 | The password is invalid. |
+| ERROR_INVALID_REQUEST | 10004 | The request is invalid. |
+| ERROR_INVALID_RESPONSE | 10005 | The response is invalid. |
+| ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal. |
+| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist. |
+| ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled. |
+| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit. |
+| ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy. |
+| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal. |
+| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist. |
+| ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out. |
+| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth access token does not exist.|
+| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth access tokens reaches the limit. |
+| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported. |
+| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported. |
+| ERROR_PERMISSION_DENIED | 10018 | The required permission is missing. |
## AuthenticatorCallback8+
@@ -1546,25 +1650,29 @@ Provides methods for managing the OAuth authenticator callback.
### onResult8+
-onResult: (code: number, result: {[key: string]: any}) => void;
+onResult: (code: number, result: {[key: string]: any}) => void
Called back to send the authentication result.
-- Parameters
- | Name| Type| Mandatory| Description|
- | ------ | -------------------- | ---- | ----------- |
- | code | number | Yes| Authentication result code.|
- | result | {[key: string]: any} | Yes| Authentication result.|
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+| Name| Type | Mandatory| Description |
+| ------ | -------------------- | ---- | ------------ |
+| code | number | Yes | Authentication result code.|
+| result | {[key: string]: any} | Yes | Authentication result. |
-- Example
+**Example**
```
const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
- var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo",
- Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"};
- callback.OnResult(ResultCode.SUCCESS, result);
+ var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
+ [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
+ [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
});
@@ -1572,16 +1680,18 @@ Called back to send the authentication result.
### onRequestRedirected8+
-onRequestRedirected: (request: Want) => void;
+onRequestRedirected: (request: Want) => void
Called back to redirect an authentication request.
-- Parameters
- | Name| Type| Mandatory| Description|
- | ------- | ---- | ---- | ------------------ |
- | request | Want | Yes| Request to be redirected.|
+**System capability**: SystemCapability.Account.AppAccount
-- Example
+**Parameters**
+| Name | Type| Mandatory| Description |
+| ------- | ---- | ---- | -------------------- |
+| request | Want | Yes | Request to be redirected.|
+
+**Example**
```
class MyAuthenticator extends account_appAccount.Authenticator {
@@ -1591,10 +1701,12 @@ Called back to redirect an authentication request.
abilityName: "com.example.ohos.accountjsdemo.LoginAbility",
});
}
-
+
authenticate(name, authType, callerBundleName, options, callback) {
- var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"};
- callback.onResult(ResultCode.SUCCESS, result);
+ var result = {[account_appAccount.Constants.KEY_NAME]: name,
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
+ [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
}
```
@@ -1605,34 +1717,38 @@ Defines the OAuth authenticator base class.
### addAccountImplicitly8+
-addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
+addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
Implicitly adds an app account based on the specified authentication type and options. This method uses an asynchronous callback to return the result.
-- Parameters
- | Name| Type| Mandatory| Description|
- | ---------------- | --------------------- | --- | -------------------------- |
- | authType | string | Yes| Authentication type.|
- | callerBundleName | string | Yes| Bundle name of the authentication requester.|
- | options | {[key: string]: any} | Yes| Options for the authentication.|
- | callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.|
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+| Name | Type | Mandatory| Description |
+| ---------------- | --------------------- | ---- | ------------------------------ |
+| authType | string | Yes | Authentication type. |
+| callerBundleName | string | Yes | Bundle name of the authentication requester. |
+| options | {[key: string]: any} | Yes | Options for the authentication. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
### authenticate8+
-authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
+authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
Authenticates an app account to obtain the OAuth access token. This method uses an asynchronous callback to return the result.
-- Parameters
- | Name| Type| Mandatory| Description|
- | ---------------- | --------------------- | ---- | -------------------------- |
- | name | string | Yes| App account name.|
- | authType | string | Yes| Authentication type.|
- | callerBundleName | string | Yes| Bundle name of the authentication requester.|
- | options | {[key: string]: any} | Yes| Options for the authentication.|
- | callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.|
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+| Name | Type | Mandatory| Description |
+| ---------------- | --------------------- | ---- | ------------------------------ |
+| name | string | Yes | App account name. |
+| authType | string | Yes | Authentication type. |
+| callerBundleName | string | Yes | Bundle name of the authentication requester. |
+| options | {[key: string]: any} | Yes | Options for the authentication. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
-- Example
+**Example**
```
class MyAuthenticator extends account_appAccount.Authenticator {
@@ -1642,13 +1758,15 @@ Authenticates an app account to obtain the OAuth access token. This method uses
abilityName: "com.example.ohos.accountjsdemo.LoginAbility",
});
}
-
+
authenticate(name, authType, callerBundleName, options, callback) {
- var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"};
- callback.onResult(ResultCode.SUCCESS, result);
+ var result = {[account_appAccount.Constants.KEY_NAME]: name,
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
+ [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
}
-
+
export default {
onConnect(want) {
return new MyAuthenticator();
diff --git a/en/application-dev/reference/apis/js-apis-application-MissionInfo.md b/en/application-dev/reference/apis/js-apis-application-MissionInfo.md
new file mode 100644
index 0000000000000000000000000000000000000000..c707cbf2efba04e7135468409b417bd85290ef67
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-application-MissionInfo.md
@@ -0,0 +1,35 @@
+# MissionInfo
+
+> **NOTE**
+> The initial APIs of this module are supported since API 8.
+
+
+Provides mission information of an ability.
+
+
+## Modules to Import
+
+Import **Want** before use.
+
+
+```
+import Want from "../@ohos.application.Want";
+```
+
+
+## MissionInfo
+
+Describes the mission information.
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| missionId | number | Yes| Yes| Mission ID.|
+| runningState | number | Yes| Yes| Running state of the mission.|
+| lockedState | boolean | Yes| Yes| Locked state of the mission.|
+| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
+| want | [Want](js-apis-featureAbility.md#want) | Yes| Yes| **Want** information of the mission.|
+| label | string | Yes| Yes| Label of the mission.|
+| iconPath | string | Yes| Yes| Path of the mission icon.|
+| continuable | boolean | Yes| Yes| Whether the mission is continuable.|
diff --git a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md
new file mode 100644
index 0000000000000000000000000000000000000000..fffd17605b6e72d0e3cc612c12bdd9e8bdcd5ab0
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md
@@ -0,0 +1,29 @@
+# MissionSnapshot
+
+
+> **NOTE**
+> The initial APIs of this module are supported since API 8.
+
+
+Provides snapshot of a mission.
+
+
+## Modules to Import
+
+Import ElementName and image before use.
+
+
+```
+import { ElementName } from '../bundle/elementName';
+import { image } from '../@ohos.multimedia.image';
+```
+
+
+## MissionSnapshot
+
+Describes the mission snapshot.
+
+ | Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| ability | ElementName | Yes| Yes| Information that matches an ability.|
+| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission.|
diff --git a/en/application-dev/reference/apis/js-apis-application-ability.md b/en/application-dev/reference/apis/js-apis-application-ability.md
index 230d2a73f61aa324c547ec0819a234a6603d4b24..e775138da3d761cc425df00d59e58e2f6fbbc3bc 100644
--- a/en/application-dev/reference/apis/js-apis-application-ability.md
+++ b/en/application-dev/reference/apis/js-apis-application-ability.md
@@ -1,7 +1,7 @@
# Ability
>  **NOTE**
-> The 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 supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Manages the ability lifecycle and context.
@@ -14,31 +14,33 @@ Manages the ability lifecycle and context.
import Ability from '@ohos.application.Ability';
```
-
## Attributes
- | Name| Type| Readable| Writable| Description|
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.|
-| launchWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters for starting the ability.|
-| lastRequestWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters used when the ability was started last time.|
+| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore|
+| launchWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters for starting the ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore|
+| lastRequestWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters used when the ability was started last time.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore|
-## onCreate
+## Ability.onCreate
-onCreate(want: Want, param: LaunchParam): void
+onCreate(want: Want, param: AbilityConstant.LaunchParam): void;
Called to initialize the service logic when an ability is created.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information related to this ability, including the ability name and bundle name.|
- | param | LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
+ | param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
-- Example
+**Example**
- ```
+ ```js
class myAbility extends Ability {
onCreate(want, param) {
console.log('onCreate, want:' + want.abilityName);
@@ -47,20 +49,23 @@ Called to initialize the service logic when an ability is created.
```
-## onWindowStageCreate
+## Ability.onWindowStageCreate
onWindowStageCreate(windowStage: window.WindowStage): void
Called when a **WindowStage** is created for this ability.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
-- Example
+**Example**
- ```
+ ```js
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
@@ -69,15 +74,17 @@ Called when a **WindowStage** is created for this ability.
```
-## onWindowStageDestroy
+## Ability.onWindowStageDestroy
onWindowStageDestroy(): void
Called when the **WindowStage** is destroyed for this ability.
-- Example
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Example**
- ```
+ ```js
class myAbility extends Ability {
onWindowStageDestroy() {
console.log('onWindowStageDestroy');
@@ -86,20 +93,23 @@ Called when the **WindowStage** is destroyed for this ability.
```
-## onWindowStageRestore
+## Ability.onWindowStageRestore
onWindowStageRestore(windowStage: window.WindowStage): void
Called when the **WindowStage** is restored during the migration of this ability, which is a multi-instance ability.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
-- Example
+**Example**
- ```
+ ```js
class myAbility extends Ability {
onWindowStageRestore(windowStage) {
console.log('onWindowStageRestore');
@@ -108,15 +118,17 @@ Called when the **WindowStage** is restored during the migration of this ability
```
-## onDestroy
+## Ability.onDestroy
onDestroy(): void;
Called when this ability is destroyed to clear resources.
-- Example
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Example**
- ```
+ ```js
class myAbility extends Ability {
onDestroy() {
console.log('onDestroy');
@@ -125,15 +137,17 @@ Called when this ability is destroyed to clear resources.
```
-## onForeground
+## Ability.onForeground
onForeground(): void;
Called when this ability is running in the foreground.
-- Example
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Example**
- ```
+ ```js
class myAbility extends Ability {
onForeground() {
console.log('onForeground');
@@ -142,15 +156,17 @@ Called when this ability is running in the foreground.
```
-## onBackground
+## Ability.onBackground
onBackground(): void;
Callback when this ability is switched to the background.
-- Example
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Example**
- ```
+ ```js
class myAbility extends Ability {
onBackground() {
console.log('onBackground');
@@ -159,25 +175,29 @@ Callback when this ability is switched to the background.
```
-## onContinue
+## Ability.onContinue
-onContinue(wantParam : {[key: string]: any}): boolean;
+onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
Called to save data during the ability migration preparation process.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wantParam | {[key: string]: any} | Yes| **want** parameter.|
-- Return value
- | Type| Description|
+**Return value**
+
+ | Type| Description|
| -------- | -------- |
- | boolean | Returns **true** if the migration is accepted; returns **false** otherwise.|
+ | AbilityConstant.OnContinueResult | Continuation result.|
-- Example
+**Example**
- ```
+ ```js
class myAbility extends Ability {
onContinue(wantParams) {
console.log('onContinue');
@@ -188,20 +208,23 @@ Called to save data during the ability migration preparation process.
```
-## onNewWant
+## Ability.onNewWant
onNewWant(want: Want): void;
Called when the ability startup mode is set to singleton.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Want parameters, such as the ability name and bundle name.|
-- Example
+**Example**
- ```
+ ```js
class myAbility extends Ability {
onNewWant(want) {
console.log('onNewWant, want:' + want.abilityName);
@@ -210,20 +233,23 @@ Called when the ability startup mode is set to singleton.
```
-## onConfigurationUpdated
+## Ability.onConfigurationUpdated
onConfigurationUpdated(config: Configuration): void;
Called when the configuration of the environment where the ability is running is updated.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](#section188911144124715) | Yes| New configuration.|
-- Example
+**Example**
- ```
+ ```js
class myAbility extends Ability {
onConfigurationUpdated(config) {
console.log('onConfigurationUpdated, config:' + JSON.stringify(config));
@@ -237,31 +263,36 @@ Called when the configuration of the environment where the ability is running is
Implements sending of sequenceable data to the target ability when an ability (caller) invokes the target ability (callee).
-### call
+## Caller.call
-call(method, data: rpc.Sequenceable): Promise<void>;
+call(method: string, data: rpc.Sequenceable): Promise<void>;
Sends sequenceable data to the target ability.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
-- Return value
- | Type| Description|
+**Return value**
+
+ | Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return a response.|
-- Example
+**Example**
- ```
+ ```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{ // Custom sequenceable data structure
- num: 0
- str: ''
- constructor() {}
+ constructor(name, str) {
+ this.name = name;
+ this.str = str;
+ }
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
@@ -279,47 +310,59 @@ Sends sequenceable data to the target ability.
var caller;
export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
- caller = await this.context.startAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
- deviceId: ""
- });
- let msg = new MyMessageAble(1, "world"); // See the definition of Sequenceable.
- caller.call(method, msg)
- .then(() => {
- console.log('Caller call() called');
- }).catch((e) => {
- console.log('Caller call() catch error ' + e);
- });
+ this.context.startAbilityByCall({
+ bundleName: "com.example.myservice",
+ abilityName: "com.example.myservice.MainAbility",
+ deviceId: ""
+ }).then((obj) => {
+ caller = obj;
+ let msg = new MyMessageAble(1, "world"); // See the definition of Sequenceable.
+ caller.call(method, msg)
+ .then(() => {
+ console.log('Caller call() called');
+ }).catch((e) => {
+ console.log('Caller call() catch error ' + e);
+ });
+ console.log('Caller GetCaller Get ' + caller);
+ }).catch((e) => {
+ console.log('Caller GetCaller error ' + e);
+ });
}
+
}
```
-### callWithResult
+## Caller.callWithResult
-callWithResult(method, data: rpc.Sequenceable): Promise<rpc.MessageParcel>;
+callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel>;
Sends sequenceable data to the target ability and obtains the sequenceable data returned by the target ability.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
-- Return value
- | Type| Description|
+**Return value**
+
+ | Type| Description|
| -------- | -------- |
| Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability.|
-- Example
+**Example**
- ```
+ ```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
- num: 0
- str: ''
+ constructor(name, str) {
+ this.name = name;
+ this.str = str;
+ }
constructor() {}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
@@ -338,83 +381,104 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
var caller;
export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
- caller = await this.context.startAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
- deviceId: ""
- });
- let msg = new MyMessageAble(1, "world");
- caller.callWithResult(method, msg)
- .then((data) => {
- console.log('Caller call() called');
- let retmsg = new MyMessageAble(0, "");
- data.readSequenceable(retmsg);
- }).catch((e) => {
- console.log('Caller call() catch error ' + e);
- });
+ onWindowStageCreate(windowStage) {
+ this.context.startAbilityByCall({
+ bundleName: "com.example.myservice",
+ abilityName: "com.example.myservice.MainAbility",
+ deviceId: ""
+ }).then((obj) => {
+ caller = obj;
+ let msg = new MyMessageAble(1, "world");
+ caller.callWithResult(method, msg)
+ .then((data) => {
+ console.log('Caller callWithResult() called');
+ let retmsg = new MyMessageAble(0, "");
+ data.readSequenceable(retmsg);
+ }).catch((e) => {
+ console.log('Caller callWithResult() catch error ' + e);
+ });
+ console.log('Caller GetCaller Get ' + caller);
+ }).catch((e) => {
+ console.log('Caller GetCaller error ' + e);
+ });
}
}
```
-### release
+## Caller.release
release(): void;
Releases the caller interface of the target ability.
-- Example
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Example**
- ```
+ ```js
import Ability from '@ohos.application.Ability';
var caller;
export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
- caller = await this.context.startAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
- deviceId: ""
- });
- try {
- caller.release();
- } catch (e) {
- console.log('Caller Release error ' + e);
- }
+ this.context.startAbilityByCall({
+ bundleName: "com.example.myservice",
+ abilityName: "com.example.myservice.MainAbility",
+ deviceId: ""
+ }).then((obj) => {
+ caller = obj;
+ try {
+ caller.release();
+ } catch (e) {
+ console.log('Caller Release error ' + e);
+ }
+ console.log('Caller GetCaller Get ' + caller);
+ }).catch((e) => {
+ console.log('Caller GetCaller error ' + e);
+ });
}
}
```
-### onRelease
+## Caller.onRelease
-onRelease(callback: function): void;
+onRelease(callback: OnReleaseCallBack): void;
Registers a callback that is invoked when the Stub on the target ability is disconnected.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | callback | function | Yes| Callback used for the **onRelease** method.|
+ | callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
-- Example
+**Example**
- ```
+ ```js
import Ability from '@ohos.application.Ability';
var caller;
export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
- caller = await this.context.startAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
- deviceId: ""
- });
- try {
- caller.onRelease((str) => {
- console.log(' Caller OnRelease CallBack is called ' + str);
- });
- } catch (e) {
- console.log('Caller Release error ' + e);
- }
+ this.context.startAbilityByCall({
+ bundleName: "com.example.myservice",
+ abilityName: "com.example.myservice.MainAbility",
+ deviceId: ""
+ }).then((obj) => {
+ caller = obj;
+ try {
+ caller.onRelease((str) => {
+ console.log(' Caller OnRelease CallBack is called ' + str);
+ });
+ } catch (e) {
+ console.log('Caller Release error ' + e);
+ }
+ console.log('Caller GetCaller Get ' + caller);
+ }).catch((e) => {
+ console.log('Caller GetCaller error ' + e);
+ });
}
}
```
@@ -425,26 +489,30 @@ Registers a callback that is invoked when the Stub on the target ability is disc
Implements callbacks for caller notification registration and unregistration.
-### on
+## Callee.on
-on(method: string, callback: function): void;
+on(method: string, callback: CaleeCallBack): void;
Registers a caller notification callback, which is invoked when the target ability registers a function.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.|
- | callback | function | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.|
+ | callback | CaleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.|
-- Example
+**Example**
- ```
+ ```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
- num: 0
- str: ''
- constructor() {}
+ constructor(name, str) {
+ this.name = name;
+ this.str = str;
+ }
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
@@ -474,20 +542,23 @@ Registers a caller notification callback, which is invoked when the target abili
```
-### off
+## Callee.off
off(method: string): void;
Unregisters a caller notification callback, which is invoked when the target ability registers a function.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Registered notification message string.|
-- Example
+**Example**
- ```
+ ```js
import Ability from '@ohos.application.Ability';
var method = 'call_Function';
export default class MainAbility extends Ability {
@@ -497,3 +568,20 @@ Unregisters a caller notification callback, which is invoked when the target abi
}
}
```
+
+## OnReleaseCallBack
+
+(msg: string): void;
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| (msg: string) | function | Yes| No| Prototype of the listener function interface registered by the caller.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore |
+
+
+ ## CaleeCallBack
+
+(indata: rpc.MessageParcel): rpc.Sequenceable;
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the message listener function interface registered by the callee.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore |
diff --git a/en/application-dev/reference/apis/js-apis-application-abilitystage.md b/en/application-dev/reference/apis/js-apis-application-abilitystage.md
index 15b3acce30aed572a1deaf316c042739c5ec63ed..4f04fa0a109852d619697b1d4cab23382d086477 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilitystage.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilitystage.md
@@ -4,26 +4,29 @@
> 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.
-Runtime class for HAP files. It provides methods to notify you when a HAP file starts loading. You can then initialize the HAP file, for example, pre-load resources and create threads.
+Runtime class for HAP files. It provides APIs to notify you when a HAP file starts loading. You can then initialize the HAP file, for example, pre-load resources and create threads.
## Modules to Import
-```
+```js
import AbilityStage from '@ohos.application.AbilityStage';
```
-
-## onCreate
+## AbilityStage.onCreate
onCreate(): void
Called when the application is created.
-- Example
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+
+
+**Example**
- ```
+ ```js
class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage.onCreate is called")
@@ -32,25 +35,29 @@ Called when the application is created.
```
-## onAcceptWant
+## AbilityStage.onAcceptWant
onAcceptWant(want: Want): string;
Called when a specified ability is started.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to start, such as the ability name and bundle name.|
-- Return value
- | Type| Description|
+**Return value**
+
+ | Type| Description|
| -------- | -------- |
| string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started.|
-- Example
+**Example**
- ```
+ ```js
class MyAbilityStage extends AbilityStage {
onAcceptWant(want) {
console.log("MyAbilityStage.onAcceptWant called");
@@ -60,23 +67,33 @@ Called when a specified ability is started.
```
-## onConfigurationUpdated
+## AbilityStage.onConfigurationUpdated
onConfigurationUpdated(config: Configuration): void;
Called when the global configuration is updated.
-- Parameters
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode.|
-- Example
+**Example**
- ```
+ ```js
class MyAbilityStage extends AbilityStage {
onConfigurationUpdated(config) {
console.log('onConfigurationUpdated, language:' + config.language);
}
}
```
+## AbilityStage.context
+
+Describes the configuration information about the context.
+
+| Name | Type | Description |
+| ----------- | --------------------------- | ------------------------------------------------------------ |
+| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
diff --git a/en/application-dev/reference/apis/js-apis-application-context.md b/en/application-dev/reference/apis/js-apis-application-context.md
index 8c4ac18f623f3266933ffab172c6d05647d86b28..eaf0b4ceca53a65a4f8bb70ff4d181284271ea76 100644
--- a/en/application-dev/reference/apis/js-apis-application-context.md
+++ b/en/application-dev/reference/apis/js-apis-application-context.md
@@ -14,6 +14,7 @@ You must extend **AbilityContext** to implement this module.
## Attributes
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
@@ -29,44 +30,51 @@ You must extend **AbilityContext** to implement this module.
| eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.|
-## createBundleContext
+## Context.createBundleContext
createBundleContext(bundleName: string): Context;
Creates an application context.
-- **Parameters**
- | Name| Type| Mandatory| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
-- Return value
- | Type| Description|
+**Return value**
+
+ | Type| Description|
| -------- | -------- |
| Context | Context of the application created.|
-- Example
+**Example**
- ```
+ ```js
let test = "com.example.test";
let context = this.context.createBundleContext(test);
```
-## getApplicationContext
+## Context.getApplicationContext
getApplicationContext(): Context;
Obtains the context of this application.
-- Return value
- | Type| Description|
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+ | Type| Description|
| -------- | -------- |
| Context | Context obtained.|
-- Example
+**Example**
- ```
+ ```js
// This part is mandatory.
let context = this.context.getApplicationContext();
```
diff --git a/en/application-dev/reference/apis/js-apis-appmanager.md b/en/application-dev/reference/apis/js-apis-appmanager.md
index 45ae9509e03e8bfec6fe71568e8a1fffb680dc67..a803daded9f58c1e1e53d4e464807d478a76bcc5 100644
--- a/en/application-dev/reference/apis/js-apis-appmanager.md
+++ b/en/application-dev/reference/apis/js-apis-appmanager.md
@@ -1,7 +1,7 @@
# appManager
>  **NOTE**
-> The initial APIs of this module are supported since API 8. 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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements application management.
@@ -10,50 +10,159 @@ Implements application management.
## Modules to Import
-```
+```js
import app from '@ohos.application.appManager';
```
-## isRunningInStabilityTest
+## appManager.isRunningInStabilityTest8+
static isRunningInStabilityTest(callback: AsyncCallback<boolean>): void
-Checks whether this application is undergoing a stability test. This API uses a callback to return the result.
+Checks whether this application is undergoing a stability test. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
-- Parameters
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | No| Callback used to return the result.|
+ | callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
-- Example
+**Example**
- ```
+ ```js
import app from '@ohos.application.appManager';
app.isRunningInStabilityTest((err, flag) => {
- console.log('startAbility result:' + JSON.stringfy(err);
- }
+ console.log('startAbility result:' + JSON.stringfy(err));
+ })
```
-## isRunningInStabilityTest
+## appManager.isRunningInStabilityTest8+
static isRunningInStabilityTest(): Promise<boolean>
-Checks whether this application is undergoing a stability test. This method uses a promise to return the result.
+Checks whether this application is undergoing a stability test. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
-- Return value
- | Type| Description|
+ | Type| Description|
| -------- | -------- |
- | Promise<boolean> | Promise used to return the result.|
+ | Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
-- Example
+**Example**
- ```
+ ```js
import app from '@ohos.application.appManager';
app.isRunningInStabilityTest().then((flag) => {
console.log('success:' + JSON.stringfy(flag));
- )).catch((error) => {
+ }).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
});
```
+
+
+## appManager.isRamConstrainedDevice
+
+isRamConstrainedDevice(): Promise\;
+
+Checks whether this application is running in a RAM constrained device. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<boolean> | 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.|
+
+**Example**
+
+ ```js
+ IsRamConstrainedDevicePromise(){
+ app.isRamConstrainedDevicePromise().then((data) => {
+ console.log('success:' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log('failed:' + JSON.stringify(error));
+ });
+ }
+ ```
+
+## appManager.isRamConstrainedDevice
+
+isRamConstrainedDevice(callback: AsyncCallback\): void;
+
+Checks whether this application is running in a RAM constrained device. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<boolean> | 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.|
+
+**Example**
+
+ ```js
+ IsRamConstrainedDeviceCallBack(){
+ app.isRamConstrainedDevicePromise((err, data) => {
+ console.log('startAbility result failed:' + JSON.stringify(err));
+ console.log('startAbility result success:' + JSON.stringify(data));
+ })
+ }
+ ```
+
+## appManager.getAppMemorySize
+
+getAppMemorySize(): Promise\;
+
+Obtains the memory size of this application. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<number> | Size of the application memory.|
+
+**Example**
+
+ ```js
+ GetAppMemorySize(){
+ app.getAppMemorySize().then((data) => {
+ console.log('success:' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log('failed:' + JSON.stringify(error));
+ });
+ }
+ ```
+
+## appManager.getAppMemorySize
+
+getAppMemorySize(callback: AsyncCallback\): void;
+
+Obtains the memory size of this application. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<number> | No| Size of the application memory.|
+
+**Example**
+
+ ```js
+ GetAppMemorySizeCallBack(){
+ app.getAppMemorySize((err, data) => {
+ console.log('startAbility result failed :' + JSON.stringify(err));
+ console.log('startAbility result success:' + JSON.stringify(data));
+ })
+ }
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-bluetooth.md b/en/application-dev/reference/apis/js-apis-bluetooth.md
index 588c942cb2b77556023606197b23a106f9ffc0be..e8ccbc86d3803b9f2eb70e9cbb7421e43f6e45ab 100644
--- a/en/application-dev/reference/apis/js-apis-bluetooth.md
+++ b/en/application-dev/reference/apis/js-apis-bluetooth.md
@@ -1,5 +1,7 @@
->  **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.
+# Bluetooth
+
+>  **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 Bluetooth module provides Classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
@@ -22,59 +24,73 @@ ohos.permission.DISCOVER_BLUETOOTH
ohos.permission.LOCATION
-## bluetooth.enableBluetooth
+
+
+## bluetooth.enableBluetooth8+
enableBluetooth(): boolean
Enables Bluetooth.
-**Return values:**
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if Bluetooth is enabled; returns **false** otherwise. |
+| boolean | Returns **true** if Bluetooth is enabled; returns **false** otherwise.|
-**Example:**
+**Example**
-```
+```js
let enable = bluetooth.enableBluetooth();
```
-## bluetooth.disableBluetooth
+## bluetooth.disableBluetooth8+
disableBluetooth(): boolean
Disables Bluetooth.
-**Return values:**
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if Bluetooth is disabled; returns **false** otherwise. |
+| boolean | Returns **true** if Bluetooth is disabled; returns **false** otherwise.|
-**Example:**
+**Example**
-```
+```js
let disable = bluetooth.disableBluetooth();
```
-## bluetooth.getLocalName
+## bluetooth.getLocalName8+
getLocalName(): string
Obtains the name of the local Bluetooth device.
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| string | Name of the local Bluetooth device. |
+| string | Name of the local Bluetooth device obtained.|
-**Example:**
+**Example**
-```
+```js
let localName = bluetooth.getLocalName();
```
@@ -85,15 +101,19 @@ getState(): BluetoothState
Obtains the Bluetooth state.
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| [BluetoothState](#bluetoothstate) | Bluetooth state obtained. |
+| [BluetoothState](#bluetoothstate) | Bluetooth state obtained.|
-**Example:**
+**Example**
-```
+```js
let state = bluetooth.getState();
```
@@ -104,40 +124,48 @@ getBtConnectionState(): ProfileConnectionState
Obtains the profile connection state of this Bluetooth device.
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained. |
+| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained.|
-**Example:**
+**Example**
-```
+```js
let connectionState = bluetooth.getBtConnectionState();
```
-## bluetooth.setLocalName
+## bluetooth.setLocalName8+
setLocalName(name: string): boolean
Sets the name of the local Bluetooth device.
-**Parameters:**
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| name | string | Yes | Bluetooth device name to be set. It cannot exceed 128 characters. |
+| name | string | Yes| Bluetooth device name to set. It cannot exceed 248 characters.|
-**Return values:**
+**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**
-```
+```js
let ret = bluetooth.setLocalName('device_name');
```
@@ -148,106 +176,242 @@ pairDevice(deviceId: string): boolean
Initiates Bluetooth pairing.
-**Parameters:**
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | Address of the peer device to pair, for example, **8F:8F:8E:8E:6D:6D**. |
+| deviceId | string | Yes| Address of the remote device to pair, for example, XX:XX:XX:XX:XX:XX.|
-**Return values:**
+**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**
+```js
+// The address can be scanned.
+let result = bluetooth.pairDevice("XX:XX:XX:XX:XX:XX");
```
-// The actual address can be scanned.
-let result = bluetooth.pairDevice("8F:8F:8E:8E:6D:6D");
+
+
+## bluetooth.getProfileConnState8+
+
+getProfileConnState(profileId: ProfileId): ProfileConnectionState
+
+Obtains the connection status of a profile.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ProfileId | profileId | Yes| ID of the target profile, for example, **PROFILE_A2DP_SOURCE**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| [ProfileConnectionState](#ProfileConnectionState) | Profile connection state obtained.|
+
+**Example**
+
+```js
+let result = bluetooth.getProfileConnState(PROFILE_A2DP_SOURCE);
```
-## bluetooth.getPairedDevices
+## bluetooth.cancelPairedDevice8+
+
+cancelPairedDevice(deviceId: string): boolean
+
+Cancels a paired remote device.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| deviceId | string | Yes| Address of the remote device to cancel, for example, XX:XX:XX:XX:XX:XX.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+
+**Example**
+
+```js
+let result = bluetooth.cancelPairedDevice("XX:XX:XX:XX:XX:XX");
+```
+
+
+## bluetooth.getRemoteDeviceName8+
+
+getRemoteDeviceName(deviceId: string): string
+
+Obtains the name of the remote Bluetooth device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| deviceId | string | Yes| Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| string | Device name (a string) obtained.|
+
+**Example**
+
+```js
+let remoteDeviceName = bluetooth.getRemoteDeviceName("XX:XX:XX:XX:XX:XX");
+```
+
+
+## bluetooth.getRemoteDeviceClass8+
+
+getRemoteDeviceClass(deviceId: string): DeviceClass
+
+Obtains the type of the remote Bluetooth device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| deviceId | string | Yes| Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| [DeviceClass](#deviceclass) | Type of a remote device obtained.|
+
+**Example**
+
+```js
+let remoteDeviceClass = bluetooth.getRemoteDeviceClass("XX:XX:XX:XX:XX:XX");
+```
+
+
+## bluetooth.getPairedDevices8+
getPairedDevices(): Array<string>
Obtains the Bluetooth pairing list.
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| Array<string> | List of the addresses of the paired Bluetooth devices. |
+| Array<string> | List of the addresses of the paired Bluetooth devices.|
-**Example:**
+**Example**
-```
+```js
let devices = bluetooth.getPairedDevices();
```
-## bluetooth.setBluetoothScanMode
+## bluetooth.setBluetoothScanMode8+
setBluetoothScanMode(mode: ScanMode, duration: number): boolean
-Sets the Bluetooth scan mode so that the device can be discovered by a peer device.
+Sets the Bluetooth scan mode so that the device can be discovered by a remote device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| mode | [ScanMode](#scanmode) | Yes | Bluetooth scan mode. |
-| duration | number | Yes | Duration (in seconds) in which the device can be discovered. The value **0** indicates unlimited time. |
+| mode | [ScanMode](#scanmode) | Yes| Bluetooth scan mode to set.|
+| duration | number | Yes| Duration (in seconds) in which the device can be discovered. The value **0** indicates unlimited time.|
-**Return values:**
+**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**
-```
+```js
// The device can be discovered and connected only when the discoverable and connectable mode is used.
let result = bluetooth.setBluetoothScanMode(ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 100);
```
-## bluetooth.getBluetoothScanMode
+## bluetooth.getBluetoothScanMode8+
getBluetoothScanMode(): ScanMode
Obtains the Bluetooth scan mode.
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| [ScanMode](#scanmode) | Bluetooth scan mode obtained. |
+| [ScanMode](#scanmode) | Bluetooth scan mode obtained.|
-**Example:**
+**Example**
-```
+```js
let scanMode = bluetooth.getBluetoothScanMode();
```
-## bluetooth.startBluetoothDiscovery
+## bluetooth.startBluetoothDiscovery8+
startBluetoothDiscovery(): boolean
-Starts Bluetooth scan to discover peer devices.
+Starts Bluetooth scan to discover remote devices.
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH and ohos.permission.LOCATION
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| 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**
-```
+```js
let deviceId;
function onReceiveEvent(data) {
deviceId = data;
@@ -257,48 +421,56 @@ let result = bluetooth.startBluetoothDiscovery();
```
-## bluetooth.stopBluetoothDiscovery
+## bluetooth.stopBluetoothDiscovery8+
stopBluetoothDiscovery(): boolean
Stops Bluetooth scan.
-**Return values:**
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| 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**
-```
+```js
let result = bluetooth.stopBluetoothDiscovery();
```
-## bluetooth.setDevicePairingConfirmation
+## bluetooth.setDevicePairingConfirmation8+
setDevicePairingConfirmation(device: string, accept: boolean): boolean
Sets the device pairing confirmation.
-**Parameters:**
+**Required permissions**: ohos.permission.MANAGE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| device | string | Yes | Address of the peer device, for example, **8F:8F:8E:8E:6D:6D**. |
-| accept | boolean | Yes | Whether to accept the pairing request. The value **true** means to accept the pairing request, and the value **false** means the opposite. |
+| device | string | Yes| Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
+| accept | boolean | Yes| Whether to accept the pairing request. The value **true** means to accept the pairing request, and the value **false** means the opposite.|
-**Return values:**
+**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**
-```
-// Subscribe to the pinRequired event and configure the pairing confirmation after receiving a pairing request from the peer device.
+```js
+// Subscribe to the pinRequired event and configure the pairing confirmation after receiving a pairing request from the remote device.
function onReceivePinRequiredEvent(data) { // data is the input parameter for the pairing request.
console.info('pin required = '+ JSON.stringify(data));
bluetooth.setDevicePairingConfirmation(data.deviceId, true);
@@ -307,26 +479,30 @@ bluetooth.on("pinRequired", onReceivePinRequiredEvent);
```
-## bluetooth.on('bluetoothDeviceFind')
+## bluetooth.on('bluetoothDeviceFind')8+
on(type: "bluetoothDeviceFind", callback: Callback<Array<string>>): void
Subscribes to the Bluetooth device discovery events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered. |
-| callback | Callback<Array<string>> | Yes | Callback invoked to return the discovered devices. You need to implement this callback. |
+| type | string | Yes| Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered.|
+| callback | Callback<Array<string>> | Yes| Callback invoked to return the discovered devices. You need to implement this callback.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function onReceiveEvent(data) { // data is a set of Bluetooth device addresses.
console.info('bluetooth device find = '+ JSON.stringify(data));
}
@@ -334,26 +510,30 @@ bluetooth.on('bluetoothDeviceFind', onReceiveEvent);
```
-## bluetooth.off('bluetoothDeviceFind')
+## bluetooth.off('bluetoothDeviceFind')8+
off(type: "bluetoothDeviceFind", callback?: Callback<Array<string>>): void
Unsubscribes from the Bluetooth device discovery events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered. |
-| callback | Callback<Array<string>> | No | Callback used to report the discovered devices. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered.|
+| callback | Callback<Array<string>> | No| Callback used to report the discovered devices. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function onReceiveEvent(data) {
console.info('bluetooth device find = '+ JSON.stringify(data));
}
@@ -362,26 +542,30 @@ bluetooth.off('bluetoothDeviceFind', onReceiveEvent);
```
-## bluetooth.on('pinRequired')
+## bluetooth.on('pinRequired')8+
on(type: "pinRequired", callback: Callback<PinRequiredParam>): void
-Subscribes to the pairing request events of the peer Bluetooth device.
+Subscribes to the pairing request events of the remote Bluetooth device.
-**Parameters:**
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **pinRequired** indicates a pairing request event. |
-| callback | Callback<[PinRequiredParam](#pinrequiredparam)> | Yes | Callback invoked to return the pairing request. You need to implement this callback. |
+| type | string | Yes| Event type. The value **pinRequired** indicates a pairing request event.|
+| callback | Callback<[PinRequiredParam](#pinrequiredparam)> | Yes| Callback invoked to return the pairing request. You need to implement this callback.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function onReceiveEvent(data) { // data is the pairing request parameter.
console.info('pin required = '+ JSON.stringify(data));
}
@@ -389,26 +573,30 @@ bluetooth.on('pinRequired', onReceiveEvent);
```
-## bluetooth.off('pinRequired')
+## bluetooth.off('pinRequired')8+
off(type: "pinRequired", callback?: Callback<PinRequiredParam>): void
-Unsubscribes from the pairing request events of the peer Bluetooth device.
+Unsubscribes from the pairing request events of the remote Bluetooth device.
-**Parameters:**
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **pinRequired** indicates a pairing request event. |
-| callback | Callback<[PinRequiredParam](#pinrequiredparam)> | No | Callback used to report the Bluetooth pairing request. The input parameter is the pairing request parameter. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **pinRequired** indicates a pairing request event.|
+| callback | Callback<[PinRequiredParam](#pinrequiredparam)> | No| Callback used to report the Bluetooth pairing request. The input parameter is the pairing request parameter. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function onReceiveEvent(data) {
console.info('pin required = '+ JSON.stringify(data));
}
@@ -417,26 +605,30 @@ bluetooth.off('pinRequired', onReceiveEvent);
```
-## bluetooth.on('bondStateChange')
+## bluetooth.on('bondStateChange')8+
on(type: "bondStateChange", callback: Callback<BondState>): void
Subscribes to the Bluetooth pairing state change events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event. |
-| callback | Callback<[BondState](#bondstate)> | Yes | Callback invoked to return the pairing state. You need to implement this callback. |
+| type | string | Yes| Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event.|
+| callback | Callback<[BondState](#bondstate)> | Yes| Callback invoked to return the pairing state. You need to implement this callback.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function onReceiveEvent(data) { // data, as the input parameter of the callback, indicates the pairing state.
console.info('pair state = '+ JSON.stringify(data));
}
@@ -444,26 +636,30 @@ bluetooth.on('bondStateChange', onReceiveEvent);
```
-## bluetooth.off('bondStateChange')
+## bluetooth.off('bondStateChange')8+
off(type: "bondStateChange", callback?: Callback<BondState>): void
Unsubscribes from the Bluetooth pairing state change events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event. |
-| callback | Callback<[BondState](#bondstate)> | No | Callback used to report the change of the Bluetooth pairing state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event.|
+| callback | Callback<[BondState](#bondstate)> | No| Callback used to report the change of the Bluetooth pairing state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function onReceiveEvent(data) {
console.info('bond state = '+ JSON.stringify(data));
}
@@ -472,26 +668,30 @@ bluetooth.off('bondStateChange', onReceiveEvent);
```
-## bluetooth.on('stateChange')
+## bluetooth.on('stateChange')8+
on(type: "stateChange", callback: Callback<BluetoothState>): void
Subscribes to the Bluetooth connection state change events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **stateChange** indicates a Bluetooth connection state change event. |
-| callback | Callback<[BluetoothState](#bluetoothstate)> | Yes | Callback invoked to return the Bluetooth connection state. You need to implement this callback. |
+| type | string | Yes| Event type. The value **stateChange** indicates a Bluetooth connection state change event.|
+| callback | Callback<[BluetoothState](#bluetoothstate)> | Yes| Callback invoked to return the Bluetooth connection state. You need to implement this callback.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function onReceiveEvent(data) {
console.info('bluetooth state = '+ JSON.stringify(data));
}
@@ -499,26 +699,30 @@ bluetooth.on('stateChange', onReceiveEvent);
```
-## bluetooth.off('stateChange')
+## bluetooth.off('stateChange')8+
off(type: "stateChange", callback?: Callback<BluetoothState>): void
Unsubscribes from the Bluetooth connection state change events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **stateChange** indicates a Bluetooth connection state change event. |
-| callback | Callback<[BluetoothState](#bluetoothstate)> | No | Callback used to report the Bluetooth connection state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **stateChange** indicates a Bluetooth connection state change event.|
+| callback | Callback<[BluetoothState](#bluetoothstate)> | No| Callback used to report the Bluetooth connection state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function onReceiveEvent(data) {
console.info('bluetooth state = '+ JSON.stringify(data));
}
@@ -527,23 +731,27 @@ bluetooth.off('stateChange', onReceiveEvent);
```
-## bluetooth.sppListen
+## bluetooth.sppListen8+
sppListen(name: string, option: SppOption, callback: AsyncCallback<number>): void
Creates a server listening socket.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| name | string | Yes | Service name. |
-| option | [SppOption](#sppoption) | Yes | Serial port profile (SPP) listening configuration. |
-| callback | AsyncCallback<number> | Yes | Callback invoked to return the server socket ID. |
+| name | string | Yes| Name of the service.|
+| option | [SppOption](#sppoption) | Yes| Serial port profile (SPP) listening configuration.|
+| callback | AsyncCallback<number> | Yes| Callback invoked to return the server socket ID.|
-**Example:**
+**Example**
-```
+```js
let serverNumber = -1;
function serverSocket(code, number) {
console.log('bluetooth error code: ' + code.code);
@@ -558,22 +766,24 @@ bluetooth.sppListen('server1', sppOption, serverSocket);
```
-## bluetooth.sppAccept
+## bluetooth.sppAccept8+
sppAccept(serverSocket: number, callback: AsyncCallback<number>): void
Listens for a connection to be made to this socket from the client and accepts it.
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| serverSocket | number | Yes | Server socket ID. |
-| callback | AsyncCallback<number> | Yes | Callback invoked to return the client socket ID. |
+| serverSocket | number | Yes| Server socket ID.|
+| callback | AsyncCallback<number> | Yes| Callback invoked to return the client socket ID.|
-**Example:**
+**Example**
-```
+```js
let clientNumber = -1;
function acceptClientSocket(code, number) {
console.log('bluetooth error code: ' + code.code);
@@ -587,23 +797,27 @@ bluetooth.sppAccept(serverNumber, acceptClientSocket);
```
-## bluetooth.sppConnect
+## bluetooth.sppConnect8+
sppConnect(device: string, option: SppOption, callback: AsyncCallback<number>): void
-Initiates an SPP connection to a peer device from the client.
+Initiates an SPP connection to a remote device from the client.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| device | string | Yes | Address of the peer device, for example, **8F:8F:8E:8E:6D:6D**. |
-| option | [SppOption](#sppoption) | Yes | Configuration for connecting to the SPP client. |
-| callback | AsyncCallback<number> | Yes | Callback invoked to return the client socket ID. |
+| device | string | Yes| Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
+| option | [SppOption](#sppoption) | Yes| Configuration for connecting to the SPP client.|
+| callback | AsyncCallback<number> | Yes| Callback invoked to return the client socket ID.|
-**Example:**
+**Example**
-```
+```js
let clientNumber = -1;
function clientSocket(code, number) {
if (code.code != 0) {
@@ -614,70 +828,78 @@ function clientSocket(code, number) {
clientNumber = number;
}
let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', secure: false, type: 0};
-bluetooth.sppConnect('8F:8F:8E:8E:6D:6D', sppOption, clientSocket);
+bluetooth.sppConnect('XX:XX:XX:XX:XX:XX', sppOption, clientSocket);
```
-## bluetooth.sppCloseServerSocket
+## bluetooth.sppCloseServerSocket8+
sppCloseServerSocket(socket: number): void
Closes the listening socket of the server.
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| socket | number | Yes | ID of the listening socket on the server. The ID is obtained by **sppListen**. |
+| socket | number | Yes| ID of the listening socket on the server. The ID is obtained by **sppListen**.|
-**Example:**
+**Example**
-```
+```js
bluetooth.sppCloseServerSocket(serverNumber);
```
-## bluetooth.sppCloseClientSocket
+## bluetooth.sppCloseClientSocket8+
sppCloseClientSocket(socket: number): void
Closes the client socket.
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| socket | number | Yes | Client socket ID, which is obtained by **sppAccept** or **sppConnect**. |
+| Name| Type| Mandatory| Description|
+| socket | number | Yes| Client socket ID, which is obtained by **sppAccept** or **sppConnect**.|
-**Example:**
+**Example**
-```
+```js
bluetooth.sppCloseClientSocket(clientNumber);
```
-## bluetooth.sppWrite
+## bluetooth.sppWrite8+
sppWrite(clientSocket: number, data: ArrayBuffer): boolean
-Writes data to the peer device through the socket.
+Writes data to the remote device through the socket.
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| clientSocket | number | Yes | Client socket ID, which is obtained by **sppAccept** or **sppConnect**. |
-| data | ArrayBuffer | Yes | Data to write. |
+| clientSocket | number | Yes| Client socket ID, which is obtained by **sppAccept** or **sppConnect**.|
+| data | ArrayBuffer | Yes| Data to write.|
-**Return values:**
+**Return value**
-| Type | Description |
+| | |
| -------- | -------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
+| Type | Description |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
-**Example:**
+**Example**
-```
+```js
let arrayBuffer = new ArrayBuffer(8);
let data = new Uint8Array(arrayBuffer);
data[0] = 123;
@@ -690,27 +912,29 @@ if (ret) {
```
-## bluetooth.on('sppRead')
+## bluetooth.on('sppRead')8+
on(type: "sppRead", clientSocket: number, callback: Callback<ArrayBuffer>): void
Subscribes to the SPP read request events.
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **sppRead** indicates an SPP read request event. |
-| clientSocket | number | Yes | Client socket ID, which is obtained by **sppAccept** or **sppConnect**. |
-| callback | Callback<ArrayBuffer> | Yes | Callback invoked to return the data read. |
+| type | string | Yes| Event type. The value **sppRead** indicates an SPP read request event.|
+| clientSocket | number | Yes| Client socket ID, which is obtained by **sppAccept** or **sppConnect**.|
+| callback | Callback<ArrayBuffer> | Yes| Callback invoked to return the data read.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function dataRead(dataBuffer) {
let data = new Uint8Array(dataBuffer);
console.log('bluetooth data is: ' + data[0]);
@@ -719,31 +943,61 @@ bluetooth.on('sppRead', clientNumber, dataRead);
```
-## bluetooth.off('sppRead')
+## bluetooth.off('sppRead')8+
off(type: "sppRead", clientSocket: number, callback?: Callback<ArrayBuffer>): void
Unsubscribes from the SPP read request events.
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **sppRead** indicates an SPP read request event. |
-| clientSocket | number | Yes | Client socket ID, which is obtained by **sppAccept** or **sppConnect**. |
-| callback | Callback<ArrayBuffer> | No | Callback used to report an SPP read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **sppRead** indicates an SPP read request event.|
+| clientSocket | number | Yes| Client socket ID, which is obtained by **sppAccept** or **sppConnect**.|
+| callback | Callback<ArrayBuffer> | No| Callback used to report an SPP read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
bluetooth.off('sppRead', clientNumber);
```
+## bluetooth.getProfile8+
+
+getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile
+
+Obtains a profile object.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ProfileId | profileId | Yes| ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
+
+**Return value**
+
+| | |
+| -------- | -------- |
+| Type | Description |
+| A2dpSourceProfile or HandsFreeAudioGatewayProfile | Profile object obtained. Only **A2dpSourceProfile** and **HandsFreeAudioGatewayProfile** are supported. |
+
+**Example**
+
+```js
+A2dpSourceProfile a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
+```
+
+
## bluetooth.BLE
### bluetooth.BLE.createGattServer
@@ -752,15 +1006,17 @@ createGattServer(): GattServer
Creates a **GattServer** instance.
-**Return values:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Type | Description |
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| [GattServer](#gattserver) | **GattServer** instance created. Before using a method of the server, you must create a **GattSever** instance. |
+| [GattServer](#gattserver) | **GattServer** instance created. Before using a method of the server, you must create a **GattSever** instance.|
-**Example:**
+**Example**
-```
+```js
let gattServer = bluetooth.BLE.createGattServer();
```
@@ -771,152 +1027,509 @@ createGattClientDevice(deviceId: string): GattClientDevice
Creates a **GattClientDevice** instance.
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| deviceId | string | Yes| Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| [GattClientDevice](#gattclientdevice) | **GattClientDevice** instance created. Before using a method of the client, you must create a **GattClientDevice** instance.|
+
+**Example**
+
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+```
+
+
+### bluetooth.BLE.getConnectedBLEDevices
+
+getConnectedBLEDevices(): Array<string>
+
+Obtains the BLE devices connected to this device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
-| Name | Type | Mandatory | Description |
+| Type| Description|
+| -------- | -------- |
+| Array<string> | Addresses of the BLE devices connected to this device.|
+
+**Example**
+
+```js
+let result = bluetooth.BLE.getConnectedBLEDevices();
+```
+
+
+### bluetooth.BLE.startBLEScan
+
+startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void
+
+Starts a BLE scan.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH, ohos.permission.MANAGE_BLUETOOTH, and ohos.permission.LOCATION
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| filters | Array<[ScanFilter](#scanfilter)> | Yes| Criteria for filtering the scan result. Set this parameter to **null** if you do not want to filter the scan result.|
+| options | [ScanOptions](#scanoptions) | No| Scan options.|
+
+**Return value**
+
+No value is returned.
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('BLE scan device find result = '+ JSON.stringify(data));
+}
+bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent);
+bluetooth.BLE.startBLEScan(
+ [{
+ deviceId:"XX:XX:XX:XX:XX:XX",
+ name:"test",
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb"
+ }],
+ {
+ interval: 500,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+);
+```
+
+
+### bluetooth.BLE.stopBLEScan
+
+stopBLEScan(): void
+
+Stops the BLE scan.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+No value is returned.
+
+**Example**
+
+```js
+bluetooth.BLE.stopBLEScan();
+```
+
+
+### bluetooth.BLE.on('BLEDeviceFind')
+
+on(type: "BLEDeviceFind", callback: Callback<Array<ScanResult>>): void
+
+Subscribe to the BLE device discovery events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered.|
+| callback | Callback<Array<[ScanResult](#scanresult)>> | Yes| Callback invoked to return the discovered devices. You need to implement this callback.|
+
+**Return value**
+
+No value is returned.
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('bluetooth device find = '+ JSON.stringify(data));
+}
+bluetooth.BLE.on('BLEDeviceFind', onReceiveEvent);
+```
+
+
+### bluetooth.BLE.off('BLEDeviceFind')
+
+off(type: "BLEDeviceFind", callback?: Callback<Array<ScanResult>>): void
+
+Unsubscribes from the BLE device discovery events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered.|
+| callback | Callback<Array<[ScanResult](#scanresult)>> | No| Callback used to report the discovered devices. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Return value**
+
+No value is returned.
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('bluetooth device find = '+ JSON.stringify(data));
+}
+bluetooth.BLE.on('BLEDeviceFind', onReceiveEvent);
+bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+```
+
+
+## BaseProfile
+
+Provides the profile base class.
+
+
+### getConnectionDevices8+
+
+getConnectionDevices(): Array<string>
+
+Obtains the connected devices.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+No value is returned.
+
+**Return value**
+
+| | |
+| -------- | -------- |
+| Type | Description |
+| Array<string> | List of addresses of the connected devices. |
+
+
+### getDeviceState8+
+
+getDeviceState(device: string): ProfileConnectionState
+
+Obtains the connection status of the profile.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | Address of the peer device, for example, **8F:8F:8E:8E:6D:6D**. |
+| device | string | Yes| Address of the remote device.|
+|
-**Return values:**
+**Return value**
+| | |
+| -------- | -------- |
| Type | Description |
+| [ProfileConnectionState](#profileconnectionState) | Profile connection state obtained. |
+
+
+## A2dpSourceProfile
+
+Before using a method of **A2dpSourceProfile**, you need to create an instance of this class by using the **getProfile()** method.
+
+
+### connect8+
+
+connect(device: string): boolean
+
+Sets up an Advanced Audio Distribution Profile (A2DP) connection.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| device | string | Yes| Address of the remote device to connect.|
+|
+
+**Return value**
+
+| | |
+| -------- | -------- |
+| Type | Description |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
+
+**Example**
+
+```js
+A2dpSourceProfile a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
+boolean ret = a2dpSrc.connect('XX:XX:XX:XX:XX:XX');
+```
+
+
+### disconnect8+
+
+disconnect(device: string): boolean
+
+Disconnects an A2DP connection.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| device | string | Yes| Address of the remote device to disconnect.|
+|
+
+**Return value**
+
+| | |
+| -------- | -------- |
+| Type | Description |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
+
+**Example**
+
+```js
+A2dpSourceProfile a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
+boolean ret = a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX');
+```
+
+
+### A2dpSourceProfile.on('connectionStateChange')8+
+
+on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
+
+Subscribes to the A2DP connection status change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type. The value **connectionStateChange** indicates an A2DP connection state change event.|
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes| Callback invoked to return the A2DP connection state change event.|
+
+**Return value**
+
+No value is returned.
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('a2dp state = '+ JSON.stringify(data));
+}
+A2dpSourceProfile.on('connectionStateChange', onReceiveEvent);
+```
+
+
+### A2dpSourceProfile.off('connectionStateChange')8+
+
+off(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
+
+Unsubscribes from the A2DP connection status change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type. The value **connectionStateChange** indicates an A2DP connection state change event.|
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes| Callback used to return the A2DP connection state change event.|
+
+**Return value**
+
+No value is returned.
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('a2dp state = '+ JSON.stringify(data));
+}
+A2dpSourceProfile.off('connectionStateChange', onReceiveEvent);
+```
+
+
+### getPlayingState
+
+getPlayingState(device: string): PlayingState
+
+Obtains the playing status of a device.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| device | string | Yes| Address of the target device.|
+
+**Return value**
+
+| | |
| -------- | -------- |
-| [GattClientDevice](#gattclientdevice) | **GattClientDevice** instance created. Before using a method of the client, you must create a **GattClientDevice** instance. |
+| Type | Description |
+| [PlayingState](#PlayingState) | Playing status obtained. |
-**Example:**
+**Example**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+A2dpSourceProfile a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
+PlayingState state = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
```
-### bluetooth.BLE.getConnectedBLEDevices
+## HandsFreeAudioGatewayProfile
-getConnectedBLEDevices(): Array<string>
+Before using a method of **HandsFreeAudioGatewayProfile**, you need to create an instance of this class by using the **getProfile()** method.
-Obtains the BLE devices connected to this device.
-**Return values:**
+### connect8+
-| Type | Description |
-| -------- | -------- |
-| Array<string> | Addresses of the BLE devices connected to this device. |
+connect(device: string): boolean
-**Example:**
+Sets up a Hands-free Profile (HFP) connection of a device.
-```
-let result = bluetooth.BLE.getConnectedBLEDevices();
-```
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-### bluetooth.BLE.startBLEScan
+**Parameters**
-startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| device | string | Yes| Address of the target device.|
+|
-Starts a BLE scan.
+**Return value**
-**Parameters:**
+| | |
+| -------- | -------- |
+| Type | Description |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
-| Name | Type | Mandatory | Description |
-| -------- | -------- | -------- | -------- |
-| filters | Array<[ScanFilter](#scanfilter)> | Yes | Criteria for filtering the scan result. Set this parameter to **null** if you do not want to filter the scan result. |
-| options | [ScanOptions](#scanoptions) | No | Scan options. |
+**Example**
-**Return values:**
+```js
+HandsFreeAudioGatewayProfile hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY);
+boolean ret = hfpAg.connect('XX:XX:XX:XX:XX:XX');
+```
-None.
-**Example:**
+### disconnect8+
-```
-function onReceiveEvent(data) {
- console.info('BLE scan device find result = '+ JSON.stringify(data));
-}
-bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent);
-bluetooth.BLE.startBLEScan(
- [{
- deviceId:"8F:8F:8E:8E:6D:6D",
- name:"test",
- serviceUuid:"00001888-0000-1000-8000-00805f9b34fb"
- }],
- {
- interval: 500,
- dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
- matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
- }
-);
-```
+disconnect(device: string): boolean
+Disconnects the HFP connection of a device.
-### bluetooth.BLE.stopBLEScan
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
-stopBLEScan(): void
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-Stops the BLE scan.
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| device | string | Yes| Address of the target device.|
+|
-**Return values:**
+**Return value**
-None.
+| | |
+| -------- | -------- |
+| Type | Description |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
-**Example:**
+**Example**
-```
-bluetooth.BLE.stopBLEScan();
+```js
+HandsFreeAudioGatewayProfile hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY);
+boolean ret = hfpAg.disconnect('XX:XX:XX:XX:XX:XX');
```
-### bluetooth.BLE.on('BLEDeviceFind')
+### HandsFreeAudioGatewayProfile.on('connectionStateChange')8+
-on(type: "BLEDeviceFind", callback: Callback<Array<ScanResult>>): void
+on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
-Subscribe to the BLE device discovery events.
+Subscribes to the HFP connection status change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered. |
-| callback | Callback<Array<[ScanResult](#scanresult)>> | Yes | Callback invoked to return the discovered devices. You need to implement this callback. |
+| type | string | Yes| Event type. The value **connectionStateChange** indicates an HFP connection state change event.|
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes| Callback invoked to return the HFP connection state change event.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function onReceiveEvent(data) {
- console.info('bluetooth device find = '+ JSON.stringify(data));
+ console.info('hfp state = '+ JSON.stringify(data));
}
-bluetooth.BLE.on('BLEDeviceFind', onReceiveEvent);
+HandsFreeAudioGatewayProfile.on('connectionStateChange', onReceiveEvent);
```
-### bluetooth.BLE.off('BLEDeviceFind')
+### HandsFreeAudioGatewayProfile.off('connectionStateChange')8+
-off(type: "BLEDeviceFind", callback?: Callback<Array<ScanResult>>): void
+off(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
-Unsubscribes from the BLE device discovery events.
+Unsubscribes from the HFP connection status change events.
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered. |
-| callback | Callback<Array<[ScanResult](#scanresult)>> | No | Callback used to report the discovered devices. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **connectionStateChange** indicates an HFP connection state change event.|
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes| Callback used to return the HFP connection state change event.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function onReceiveEvent(data) {
- console.info('bluetooth device find = '+ JSON.stringify(data));
+ console.info('hfp state = '+ JSON.stringify(data));
}
-bluetooth.BLE.on('BLEDeviceFind', onReceiveEvent);
-bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+HandsFreeAudioGatewayProfile.off('connectionStateChange', onReceiveEvent);
```
@@ -931,21 +1544,25 @@ startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?
Starts BLE advertising.
-**Parameters:**
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| setting | [AdvertiseSetting](#advertisesetting) | Yes | Settings related to BLE advertising. |
-| advData | [AdvertiseData](#advertisedata) | Yes | Content of the BLE advertisement packet. |
-| advResponse | [AdvertiseData](#advertisedata) | No | Response to the BLE scan request. |
+| setting | [AdvertiseSetting](#advertisesetting) | Yes| Settings related to BLE advertising.|
+| advData | [AdvertiseData](#advertisedata) | Yes| Content of the BLE advertisement packet.|
+| advResponse | [AdvertiseData](#advertisedata) | No| Response to the BLE scan request.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2;
@@ -994,13 +1611,17 @@ stopAdvertising(): void
Stops BLE advertising.
-**Return values:**
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
-None.
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-**Example:**
+**Return value**
-```
+No value is returned.
+
+**Example**
+
+```js
let server = bluetooth.BLE.createGattServer();
server.stopAdvertising();
```
@@ -1012,21 +1633,25 @@ addService(service: GattService): boolean
Adds a service to this GATT server.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| service | [GattService](#gattservice) | Yes | Service to add. |
+| service | [GattService](#gattservice) | Yes| Service to add. Settings related to BLE advertising.|
-**Return values:**
+**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**
-```
+```js
// Create descriptors.
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
@@ -1067,21 +1692,26 @@ removeService(serviceUuid: string): boolean
Removes a service from this GATT server.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| serviceUuid | string | Yes | Universally unique identifier (UUID) of the service to remove, for example, **00001810-0000-1000-8000-00805F9B34FB**. |
+| serviceUuid | string | Yes| Universally unique identifier (UUID) of the service to remove, for example, **00001810-0000-1000-8000-00805F9B34FB**.|
-**Return values:**
+**Return value**
-| Type | Description |
+| | |
| -------- | -------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
+| Type | Description |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
-**Example:**
+**Example**
-```
+```js
let server = bluetooth.BLE.createGattServer();
server.removeService('00001810-0000-1000-8000-00805F9B34FB');
```
@@ -1091,12 +1721,15 @@ server.removeService('00001810-0000-1000-8000-00805F9B34FB');
close(): void
+Closes this GATT server to unregister it from the protocol stack. After this method is called, this [GattServer](#gattserver) cannot be used.
-Closes this GATT server to unregister it from the protocol stack. After this method is called, this [GattServer](#gattserver) instance cannot be used.
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-**Example:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-```
+**Example**
+
+```js
let server = bluetooth.BLE.createGattServer();
server.close();
```
@@ -1108,26 +1741,31 @@ notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharac
Notifies the connected client device when a characteristic value changes.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | Address of the client device to notify, for example, **8F:8F:8E:8E:6D:6D**. |
-| notifyCharacteristic | [NotifyCharacteristic](#notifycharacteristic) | Yes | New characteristic value. |
+| deviceId | string | Yes| Address of the client that receives notifications, for example, XX:XX:XX:XX:XX:XX.|
+| notifyCharacteristic | [NotifyCharacteristic](#notifycharacteristic) | Yes| New characteristic value.|
-**Return values:**
+**Return value**
-| Type | Description |
+| | |
| -------- | -------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
+| Type | Description |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
-**Example:**
+**Example**
-```
+```js
let notifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: notifyCcc.characteristicValue, confirm: false};
let server = bluetooth.BLE.createGattServer();
-server.notifyCharacteristicChanged('8F:8F:8E:8E:6D:6D', notifyCharacteristic);
+server.notifyCharacteristicChanged('XX:XX:XX:XX:XX:XX', notifyCharacteristic);
```
@@ -1137,27 +1775,32 @@ sendResponse(serverResponse: ServerResponse): boolean
Sends a response to a read or write request from the GATT client.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| serverResponse | [ServerResponse](#serverresponse) | Yes | Response returned by the GATT server. |
+| serverResponse | [ServerResponse](#serverresponse) | Yes| Response returned by the GATT server.|
-**Return values:**
+**Return value**
-| Type | Description |
+| | |
| -------- | -------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
+| Type | Description |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
-**Example:**
+**Example**
-```
-/* Send a response. */
+```js
+/* send response */
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 1123;
let serverResponse = {
- "deviceId": "8F:8F:8E:8E:6D:6D",
+ "deviceId": "XX:XX:XX:XX:XX:XX",
"transId": 0,
"status": 0,
"offset": 0,
@@ -1180,20 +1823,24 @@ on(type: "characteristicRead", callback: Callback<CharacteristicReadReq>):
Subscribes to the characteristic read request events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **characteristicRead** indicates a characteristic read request event. |
-| callback | Callback<[CharacteristicReadReq](#characteristicreadreq)> | Yes | Callback invoked to return a characteristic read request from the GATT client. |
+| type | string | Yes| Event type. The value **characteristicRead** indicates a characteristic read request event.|
+| callback | Callback<[CharacteristicReadReq](#characteristicreadreq)> | Yes| Callback invoked to return a characteristic read request from the GATT client.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 1123;
@@ -1224,20 +1871,24 @@ off(type: "characteristicRead", callback?: Callback<CharacteristicReadReq>
Unsubscribes from the characteristic read request events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **characteristicRead** indicates a characteristic read request event. |
-| callback | Callback<[CharacteristicReadReq](#characteristicreadreq)> | No | Callback used to report a characteristic read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **characteristicRead** indicates a characteristic read request event.|
+| callback | Callback<[CharacteristicReadReq](#characteristicreadreq)> | No| Callback used to report a characteristic read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
let gattServer = bluetooth.BLE.createGattServer();
gattServer.off("characteristicRead");
```
@@ -1249,20 +1900,24 @@ on(type: "characteristicWrite", callback: Callback<CharacteristicWriteReq>
Subscribes to the characteristic write request events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **characteristicWrite** indicates a characteristic write request event. |
-| callback | Callback<[DescriptorWriteReq](#descriptorwritereq)> | Yes | Callback invoked to return a characteristic write request from the GATT client. |
+| type | string | Yes| Event type. The value **characteristicWrite** indicates a characteristic write request event.|
+| callback | Callback<[DescriptorWriteReq](#descriptorwritereq)> | Yes| Callback invoked to return a characteristic write request from the GATT client.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
function WriteCharacteristicReq(CharacteristicWriteReq) {
@@ -1296,20 +1951,24 @@ off(type: "characteristicWrite", callback?: Callback<CharacteristicWriteReq&g
Unsubscribes from the characteristic write request events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **characteristicWrite** indicates a characteristic write request event. |
-| callback | Callback<[CharacteristicWriteReq](#characteristicwritereq)> | No | Callback used to report a characteristic write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **characteristicWrite** indicates a characteristic write request event.|
+| callback | Callback<[CharacteristicWriteReq](#characteristicwritereq)> | No| Callback used to report a characteristic write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
let gattServer = bluetooth.BLE.createGattServer();
gattServer.off("characteristicWrite");
```
@@ -1321,20 +1980,24 @@ on(type: "descriptorRead", callback: Callback<DescriptorReadReq>): void
Subscribes to the descriptor read request events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **descriptorRead** indicates a descriptor read request event. |
-| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | Yes | Callback invoked to return a descriptor read request from the GATT client. |
+| type | string | Yes| Event type. The value **descriptorRead** indicates a descriptor read request event.|
+| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | Yes| Callback invoked to return a descriptor read request event from the GATT client.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
let arrayBufferDesc = new ArrayBuffer(8);
let descValue = new Uint8Array(arrayBufferDesc);
descValue[0] = 1101;
@@ -1365,20 +2028,24 @@ off(type: "descriptorRead", callback?: Callback<DescriptorReadReq>): void
Unsubscribes from the descriptor read request events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **descriptorRead** indicates a descriptor read request event. |
-| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | No | Callback used to report a descriptor read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **descriptorRead** indicates a descriptor read request event.|
+| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | No| Callback used to report a descriptor read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
let gattServer = bluetooth.BLE.createGattServer();
gattServer.off("descriptorRead");
```
@@ -1390,20 +2057,24 @@ on(type: "descriptorWrite", callback: Callback<DescriptorWriteReq>): void
Subscribes to the descriptor write request events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **descriptorWrite** indicates a descriptor write request event. |
-| callback | Callback<[DescriptorWriteReq](#descriptorwritereq)> | Yes | Callback invoked to return a descriptor write request from the GATT client. |
+| type | string | Yes| Event type. The value **descriptorWrite** indicates a descriptor write request event.|
+| callback | Callback<[DescriptorWriteReq](#descriptorwritereq)> | Yes| Callback invoked to return a descriptor write request from the GATT client.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
let arrayBufferDesc = new ArrayBuffer(8);
let descValue = new Uint8Array(arrayBufferDesc);
function WriteDescriptorReq(DescriptorWriteReq) {
@@ -1437,20 +2108,24 @@ off(type: "descriptorWrite", callback?: Callback<DescriptorWriteReq>): voi
Unsubscribes from the descriptor write request events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **descriptorWrite** indicates a descriptor write request event. |
-| callback | Callback<[DescriptorWriteReq](#descriptorwritereq)> | No | Callback used to report a descriptor read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **descriptorWrite** indicates a descriptor write request event.|
+| callback | Callback<[DescriptorWriteReq](#descriptorwritereq)> | No| Callback used to report a descriptor write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
let gattServer = bluetooth.BLE.createGattServer();
gattServer.off("descriptorWrite");
```
@@ -1462,20 +2137,24 @@ on(type: "connectStateChange", callback: Callback<BLEConnectChangedState>)
Subscribes to the BLE connection state change events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **connectStateChange** indicates a BLE connection state change event. |
-| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | Yes | Callback invoked to return the BLE connection state. |
+| type | string | Yes| Event type. The value **connectStateChange** indicates a BLE connection state change event.|
+| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | Yes| Callback invoked to return the BLE connection state.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function Connected(BLEConnectChangedState) {
let deviceId = BLEConnectChangedState.deviceId;
let status = BLEConnectChangedState.state;
@@ -1492,20 +2171,24 @@ off(type: "connectStateChange", callback?: Callback<BLEConnectChangedState>
Unsubscribes from the BLE connection state change events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **connectStateChange** indicates a BLE connection state change event. |
-| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | No | Callback used to report the BLE connection state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **connectStateChange** indicates a BLE connection state change event.|
+| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | No| Callback used to report the BLE connection state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
let gattServer = bluetooth.BLE.createGattServer();
gattServer.off("connectStateChange");
```
@@ -1520,18 +2203,22 @@ Implements the GATT client. Before using a method of this class, you must create
connect(): boolean
-Initiates a connection to the peer BLE device.
+Initiates a connection to the remote BLE device.
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the connection is successful; returns **false** otherwise. |
+| boolean | Returns **true** if the connection is successful; returns **false** otherwise.|
-**Example:**
+**Example**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
let ret = device.connect();
```
@@ -1540,18 +2227,22 @@ let ret = device.connect();
disconnect(): boolean
-Disconnects from the peer BLE device.
+Disconnects from the remote BLE device.
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the connection is successful; returns **false** otherwise. |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-**Example:**
+**Example**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
let ret = device.disconnect();
```
@@ -1562,16 +2253,20 @@ close(): boolean
Closes this GATT client to unregister it from the protocol stack. After this method is called, this [GattClientDevice](#gattclientdevice) instance cannot be used.
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| 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**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
let ret = device.close();
```
@@ -1582,21 +2277,25 @@ let ret = device.close();
getServices(callback: AsyncCallback<Array<GattService>>): void
-Obtains all services of the peer BLE device. This method uses an asynchronous callback to return the result.
+Obtains all services of the remote BLE device. This method uses an asynchronous callback to return the result.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<Array<[GattService](#gattservice)>> | Yes | Callback invoked to return the services obtained. |
+| callback | AsyncCallback<Array<[GattService](#gattservice)>> | Yes| Callback invoked to return the services obtained.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
// Callback
function getServices(code, gattServices) {
if (code.code == 0) {
@@ -1610,7 +2309,7 @@ function getServices(code, gattServices) {
}
}
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.connect();
device.getServices(getServices);
```
@@ -1620,21 +2319,25 @@ device.getServices(getServices);
getServices(): Promise<Array<GattService>>
-Obtains all services of the peer BLE device. This method uses a promise to return the result.
+Obtains all services of the remote BLE device. This method uses a promise to return the result.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-**Return values:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Type | Description |
+**Parameters**
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| Promise<Array<[GattService](#gattservice)>> | Promise used to return the services obtained. |
+| Promise<Array<[GattService](#gattservice)>> | Promise used to return the services obtained.|
-**Example:**
+**Example**
-```
+```js
// Promise
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.connect();
let services = device.getServices();
console.log("bluetooth services size is ", services.length);
@@ -1649,22 +2352,26 @@ for (let i = 0; i < services.length; i++) {
readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback<BLECharacteristic>): void
-Reads the characteristic value of the specific service of the peer BLE device. This method uses an asynchronous callback to return the result.
+Reads the characteristic value of the specific service of the remote BLE device. This method uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| characteristic | [BLECharacteristic](#blecharacteristic) | Yes | Characteristic value to read. |
-| callback | AsyncCallback<[BLECharacteristic](#blecharacteristic)> | Yes | Callback invoked to return the characteristic value read. |
+| characteristic | [BLECharacteristic](#blecharacteristic) | Yes| Characteristic value to read.|
+| callback | AsyncCallback<[BLECharacteristic](#blecharacteristic)> | Yes| Callback invoked to return the characteristic value read.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function readCcc(code, BLECharacteristic) {
if (code.code != 0) {
return;
@@ -1674,7 +2381,7 @@ function readCcc(code, BLECharacteristic) {
console.log('bluetooth characteristic value: ' + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
}
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
let descriptors = [];
let bufferDesc = new ArrayBuffer(8);
let descV = new Uint8Array(bufferDesc);
@@ -1699,24 +2406,29 @@ device.readCharacteristicValue(characteristic, readCcc);
readCharacteristicValue(characteristic: BLECharacteristic): Promise<BLECharacteristic>
-Reads the characteristic value of the specific service of the peer BLE device. This method uses a promise to return the result.
+Reads the characteristic value of the specific service of the remote BLE device. This method uses a promise to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| characteristic | [BLECharacteristic](#blecharacteristic) | Yes | Characteristic value to read. |
+| characteristic | [BLECharacteristic](#blecharacteristic) | Yes| Characteristic value to read.|
-**Return values:**
+**Return value**
-| Type | Description |
+| | |
| -------- | -------- |
-| Promise<[BLECharacteristic](#blecharacteristic)> | Promise used to return the characteristic value read. |
+| Type | Description |
+| Promise<[BLECharacteristic](#blecharacteristic)> | Promise used to return the characteristic value read. |
-**Example:**
+**Example**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
let descriptors = [];
let bufferDesc = new ArrayBuffer(8);
let descV = new Uint8Array(bufferDesc);
@@ -1741,22 +2453,26 @@ device.readCharacteristicValue(characteristic);
readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback<BLEDescriptor>): void
-Reads the descriptor contained in the specific characteristic of the peer BLE device. This method uses an asynchronous callback to return the result.
+Reads the descriptor contained in the specific characteristic of the remote BLE device. This method uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| descriptor | [BLEDescriptor](#bledescriptor) | Yes | Descriptor to read. |
-| callback | AsyncCallback<[BLECharacteristic](#blecharacteristic)> | Yes | Callback invoked to return the descriptor read. |
+| descriptor | [BLEDescriptor](#bledescriptor) | Yes| Descriptor to read.|
+| callback | AsyncCallback<[BLECharacteristic](#blecharacteristic)> | Yes| Callback invoked to return the descriptor read.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function readDesc(code, BLEDescriptor) {
if (code.code != 0) {
return;
@@ -1766,7 +2482,7 @@ function readDesc(code, BLEDescriptor) {
console.log('bluetooth descriptor value: ' + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
}
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
let bufferDesc = new ArrayBuffer(8);
let descV = new Uint8Array(bufferDesc);
descV[0] = 11;
@@ -1781,24 +2497,29 @@ device.readDescriptorValue(descriptor, readDesc);
readDescriptorValue(descriptor: BLEDescriptor): Promise<BLEDescriptor>
-Reads the descriptor contained in the specific characteristic of the peer BLE device. This method uses a promise to return the result.
+Reads the descriptor contained in the specific characteristic of the remote BLE device. This method uses a promise to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| descriptor | [BLEDescriptor](#bledescriptor) | Yes | Descriptor to read. |
+| descriptor | [BLEDescriptor](#bledescriptor) | Yes| Descriptor to read.|
-**Return values:**
+**Return value**
-| Type | Description |
+| | |
| -------- | -------- |
-| Promise<[BLEDescriptor](#bledescriptor)> | Promise used to return the descriptor read. |
+| Type | Description |
+| Promise<[BLEDescriptor](#bledescriptor)> | Promise used to return the descriptor read. |
-**Example:**
+**Example**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
let bufferDesc = new ArrayBuffer(8);
let descV = new Uint8Array(bufferDesc);
descV[0] = 11;
@@ -1813,25 +2534,28 @@ device.readDescriptorValue(descriptor);
writeCharacteristicValue(characteristic: BLECharacteristic): boolean
-Writes a characteristic value to the peer BLE device.
+Writes a characteristic value to the remote BLE device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| characteristic | [BLECharacteristic](#blecharacteristic) | Yes | Binary value and other parameters of the BLE device characteristic. |
+| characteristic | [BLECharacteristic](#blecharacteristic) | Yes| Binary value and other parameters of the BLE device characteristic.|
-**Return values:**
+**Return value**
-| Name | Type | Mandatory | Description |
+| Type| Description|
| -------- | -------- |
-| Name | Type | Mandatory | 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**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
let descriptors = [];
let bufferDesc = new ArrayBuffer(8);
let descV = new Uint8Array(bufferDesc);
@@ -1860,24 +2584,28 @@ if (retWriteCcc) {
writeDescriptorValue(descriptor: BLEDescriptor): boolean
-Writes binary data to the specific descriptor of the peer BLE device.
+Writes binary data to the specific descriptor of the remote BLE device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| descriptor | [BLEDescriptor](#bledescriptor) | Yes | Binary value and other parameters of the BLE device descriptor. |
+| descriptor | [BLEDescriptor](#bledescriptor) | Yes| Binary value and other parameters of the BLE device descriptor.|
-**Return values:**
+**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**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
let bufferDesc = new ArrayBuffer(8);
let descV = new Uint8Array(bufferDesc);
descV[0] = 22;
@@ -1897,24 +2625,28 @@ if (retWriteDesc) {
setBLEMtuSize(mtu: number): boolean
-Sets the maximum transmission unit (MTU) that can be transmitted between the GATT client and its peer BLE device. This method can be used only after a connection is set up by calling **connect**.
+Sets the maximum transmission unit (MTU) that can be transmitted between the GATT client and its remote BLE device. This method can be used only after a connection is set up by calling [connect](#connect).
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| mtu | number | Yes | MTU to set, which ranges from 22 to 512 bytes. |
+| mtu | number | Yes| MTU to set, which ranges from 22 to 512 bytes.|
-**Return values:**
+**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**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.setBLEMtuSize(128);
```
@@ -1923,25 +2655,29 @@ device.setBLEMtuSize(128);
setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): boolean
-Sets the function of notifying the GATT client when the characteristic value of the peer BLE device changes.
+Sets the function of notifying the GATT client when the characteristic value of the remote BLE device changes.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| characteristic | [BLECharacteristic](#blecharacteristic) | Yes | BLE characteristic to listen for. |
-| enable | boolean | Yes | Whether to enable the notify function. The value **true** means to enable the notify function, and the value **false** means the opposite. |
+| characteristic | [BLECharacteristic](#blecharacteristic) | Yes| BLE characteristic to listen for.|
+| enable | boolean | Yes| Whether to enable the notify function. The value **true** means to enable the notify function, and the value **false** means the opposite.|
-**Return values:**
+**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**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.setNotifyCharacteristicChanged(notifyCcc, false);
```
@@ -1952,26 +2688,30 @@ on(type: "BLECharacteristicChange", callback: Callback<BLECharacteristic>)
Subscribes to the BLE characteristic change events. The client can receive a notification from the server only after the **setNotifyCharacteristicChanged** method is called.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **BLECharacteristicChange** indicates a characteristic value change event. |
-| callback | Callback<[BLECharacteristic](#blecharacteristic)> | Yes | Callback invoked to return the characteristic value changes. |
+| type | string | Yes| Event type. The value **BLECharacteristicChange** indicates a characteristic value change event.|
+| callback | Callback<[BLECharacteristic](#blecharacteristic)> | Yes| Callback invoked to return the characteristic value changes.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function CharacteristicChange(CharacteristicChangeReq) {
let serviceUuid = CharacteristicChangeReq.serviceUuid;
let characteristicUuid = CharacteristicChangeReq.characteristicUuid;
let value = new Uint8Array(CharacteristicChangeReq.characteristicValue);
}
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.on('BLECharacteristicChange', CharacteristicChange);
```
@@ -1982,21 +2722,25 @@ off(type: "BLECharacteristicChange", callback?: Callback<BLECharacteristic>
Unsubscribes from the BLE characteristic change events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **BLECharacteristicChange** indicates a characteristic value change event. |
-| callback | Callback<[BLECharacteristic](#blecharacteristic)> | No | Callback used to report the characteristic value. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **BLECharacteristicChange** indicates a characteristic value change event.|
+| callback | Callback<[BLECharacteristic](#blecharacteristic)> | No| Callback used to report the characteristic value. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.off('BLECharacteristicChange');
```
@@ -2007,25 +2751,29 @@ on(type: "BLEConnectionStateChange", callback: Callback<BLEConnectChangedStat
Subscribes to the BLE connection state change events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Name | Type | Mandatory | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **BLEConnectionStateChange** indicates a BLE connection state change event. |
-| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | Yes | Callback invoked to return the BLE connection state. |
+| type | string | Yes| Event type. The value **BLEConnectionStateChange** indicates a BLE connection state change event.|
+| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | Yes| Callback invoked to return the BLE connection state.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
+```js
function ConnectStateChanged(state) {
console.log('bluetooth connect state changed');
let connectState = state.state;
}
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.on('BLEConnectionStateChange', ConnectStateChanged);
```
@@ -2036,21 +2784,25 @@ off(type: "BLEConnectionStateChange", callback?: Callback<BLEConnectChangedSt
Unsubscribes from the BLE connection state change events.
-**Parameters:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes | Event type. The value **BLEConnectionStateChange** indicates a BLE connection state change event. |
-| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | No | Callback used to report the BLE connection state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. |
+| type | string | Yes| Event type. The value **BLEConnectionStateChange** indicates a BLE connection state change event.|
+| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | No| Callback used to report the BLE connection state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
-let device = bluetooth.BLE.createGattClientDevice('8F:8F:8E:8E:6D:6D');
+```js
+let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.off('BLEConnectionStateChange');
```
@@ -2059,23 +2811,27 @@ device.off('BLEConnectionStateChange');
getDeviceName(callback: AsyncCallback<string>): void
-Obtains the name of the peer BLE device. This method uses an asynchronous callback to return the result.
+Obtains the name of the remote BLE device. This method uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-**Parameters:**
+**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<string> | Yes | Callback invoked to return the peer BLE device name. |
+| callback | AsyncCallback<string> | Yes| Callback invoked to return the remote BLE device name obtained.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
-// Callback
-let gattClient = bluetooth.BLE.createGattClientDevice("8F:8F:8E:8E:6D:6D");
+```js
+// callback
+let gattClient = bluetooth.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
let deviceName = gattClient.getDeviceName((err, data)=> {
console.info('device name err ' + JSON.stringify(err));
console.info('device name' + JSON.stringify(data));
@@ -2087,19 +2843,23 @@ let deviceName = gattClient.getDeviceName((err, data)=> {
getDeviceName(): Promise<string>
-Obtains the name of the peer BLE device. This method uses a promise to return the result.
+Obtains the name of the remote BLE device. This method uses a promise to return the result.
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| Promise<string> | Promise used to return the peer BLE device name. |
+| Promise<string> | Promise used to return the remote BLE device name.|
-**Example:**
+**Example**
-```
-// Promise
-let gattClient = bluetooth.BLE.createGattClientDevice("8F:8F:8E:8E:6D:6D");
+```js
+// promise
+let gattClient = bluetooth.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
let ret = device.connect();
let deviceName = gattClient.getDeviceName().then((data) => {
console.info('device name' + JSON.stringify(data));
@@ -2111,23 +2871,27 @@ let deviceName = gattClient.getDeviceName().then((data) => {
getRssiValue(callback: AsyncCallback<number>): void
-Obtains the received signal strength indication (RSSI) of the peer BLE device. This method uses an asynchronous callback to return the result. It can be used only after a connection is set up by calling [connect](#connect).
+Obtains the received signal strength indication (RSSI) of the remote BLE device. This method uses an asynchronous callback to return the result. It can be used only after a connection is set up by calling [connect](#connect).
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-**Parameters:**
+**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Mandatory | Description |
+**Parameters**
+
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<number> | Yes | Callback invoked to return the RSSI, in dBm. |
+| callback | AsyncCallback<number> | Yes| Callback invoked to return the RSSI, in dBm.|
-**Return values:**
+**Return value**
-None.
+No value is returned.
-**Example:**
+**Example**
-```
-// Callback
-let gattClient = bluetooth.BLE.createGattClientDevice("8F:8F:8E:8E:6D:6D");
+```js
+// callback
+let gattClient = bluetooth.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
let ret = device.connect();
let rssi = gattClient.getRssiValue((err, data)=> {
console.info('rssi err ' + JSON.stringify(err));
@@ -2140,327 +2904,548 @@ let rssi = gattClient.getRssiValue((err, data)=> {
getRssiValue(): Promise<number>
-Obtains the RSSI of the peer BLE device. This method uses a promise to return the result. It can be used only after a connection is set up by calling [connect](#connect).
+Obtains the RSSI of the remote BLE device. This method uses a promise to return the result. It can be used only after a connection is set up by calling [connect](#connect).
-**Return values:**
+**Required permissions**: ohos.permission.USE_BLUETOOTH
-| Type | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type| Description|
| -------- | -------- |
-| Promise<number> | Promise used to return the RSSI, in dBm. |
+| Promise<number> | Promise used to return the RSSI, in dBm.|
-**Example:**
+**Example**
-```
-// Promise
-let gattClient = bluetooth.BLE.createGattClientDevice("8F:8F:8E:8E:6D:6D");
+```js
+// promise
+let gattClient = bluetooth.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
let rssi = gattClient.getRssiValue().then((data) => {
console.info('rssi' + JSON.stringify(data));
})
```
-
-## ScanMode
+## ScanMode8+
Enumerates the scan modes.
-| Mode | Default Value | Description |
-| -------- | -------- | -------- |
-| SCAN_MODE_NONE | 0 | No scan mode is specified. |
-| SCAN_MODE_CONNECTABLE | 1 | Discoverable mode. |
-| SCAN_MODE_GENERAL_DISCOVERABLE | 2 | General discoverable mode. |
-| SCAN_MODE_LIMITED_DISCOVERABLE | 3 | Limited discoverable mode. |
-| SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE | 4 | General connectable and discoverable mode. |
-| SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE | 5 | Limited connectable and discoverable mode. |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+| Name| Default Value| Description|
+| -------- | -------- | -------- |
+| SCAN_MODE_NONE | 0 | No scan mode.|
+| SCAN_MODE_CONNECTABLE | 1 | Connectable mode.|
+| SCAN_MODE_GENERAL_DISCOVERABLE | 2 | General discoverable mode.|
+| SCAN_MODE_LIMITED_DISCOVERABLE | 3 | Limited discoverable mode.|
+| SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE | 4 | General connectable and discoverable mode.|
+| SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE | 5 | Limited connectable and discoverable mode.|
-## BondState
+## BondState8+
Enumerates the pairing states.
-| State | Default Value | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Default Value| Description|
| -------- | -------- | -------- |
-| BOND_STATE_INVALID | 0 | Invalid pairing. |
-| BOND_STATE_BONDING | 1 | Pairing. |
-| BOND_STATE_BONDED | 2 | Paired. |
+| BOND_STATE_INVALID | 0 | Invalid pairing.|
+| BOND_STATE_BONDING | 1 | Pairing.|
+| BOND_STATE_BONDED | 2 | Paired.|
-## SppOption
+## SppOption8+
Defines the SPP configuration parameters.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| uuid | string | Yes | Yes | UUID of the SPP. |
-| isPrimary | boolean | Yes | Yes | Whether it is a secure channel. |
-| type | [SppType](#SppType) | Yes | Yes | Type of the SPP link. |
+| uuid | string | Yes| Yes| UUID of the SPP.|
+| secure | boolean | Yes| Yes| Whether it is a secure channel.|
+| type | [SppType](#spptype) | Yes| Yes| Type of the SPP link.|
-## SppType
+## SppType8+
Enumerates the SPP link types.
-| Type | Default Value | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Default Value| Description|
| -------- | -------- | -------- |
-| SPP_RFCOMM | 0 | Radio frequency communication (RFCOMM) link type. |
+| SPP_RFCOMM | 0 | Radio frequency communication (RFCOMM) link type.|
## GattService
Defines the GATT service API parameters.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**. |
-| isPrimary | boolean | Yes | Yes | Whether the service is a primary service. The value **true** means a primary service. |
-| characteristics | Array<[BLECharacteristic](#BLECharacteristic)> | Yes | Yes | List of characteristics of the service. |
-| includeServices | Array<[GattService](#GattService)> | Yes | Yes | Services on which the service depends. |
+| serviceUuid | string | Yes| Yes| UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| isPrimary | boolean | Yes| Yes| Whether the service is a primary service. The value **true** means a primary service.|
+| characteristics | Array<[BLECharacteristic](#blecharacteristic)> | Yes| Yes| List of characteristics of the service.|
+| includeServices | Array<[GattService](#gattservice)> | Yes| Yes| Services on which the service depends.|
## BLECharacteristic
Defines the characteristic API parameters.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**. |
-| characteristicUuid | string | Yes | Yes | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**. |
-| characteristicValue | ArrayBuffer | Yes | Yes | Binary value of the characteristic. |
-| descriptors | Array<[BLEDescriptor](#BLEDescriptor)> | Yes | Yes | List of descriptors of the characteristic. |
+| serviceUuid | string | Yes| Yes| UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes| Yes| UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| characteristicValue | ArrayBuffer | Yes| Yes| Binary value of the characteristic.|
+| descriptors | Array<[BLEDescriptor](#bledescriptor)> | Yes| Yes| List of descriptors of the characteristic.|
## BLEDescriptor
Defines the descriptor API parameters.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**. |
-| characteristicUuid | string | Yes | Yes | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**. |
-| descriptorUuid | string | Yes | Yes | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**. |
-| descriptorValue | ArrayBuffer | Yes | Yes | Binary value of the descriptor. |
+| serviceUuid | string | Yes| Yes| UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes| Yes| UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| descriptorUuid | string | Yes| Yes| UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
+| descriptorValue | ArrayBuffer | Yes| Yes| Binary value of the descriptor.|
## NotifyCharacteristic
Defines the parameters in the notifications sent when the server characteristic value changes.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**. |
-| characteristicUuid | string | Yes | Yes | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**. |
-| characteristicValue | ArrayBuffer | Yes | Yes | Binary value of the characteristic. |
-| confirm | boolean | Yes | Yes | Whether the notification needs to be confirmed by the peer end. For a notification, set it to **true**. In this case, the peer end must confirm the receipt of the notification. For an indication, set it to **false**. In this case, the peer end does not need to confirm the receipt of the notification. |
+| serviceUuid | string | Yes| Yes| UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes| Yes| UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| characteristicValue | ArrayBuffer | Yes| Yes| Binary value of the characteristic.|
+| confirm | boolean | Yes| Yes| Whether the notification needs to be confirmed by the remote end. For a notification, set it to **true**. In this case, the remote end must confirm the receipt of the notification. For an indication, set it to **false**. In this case, the remote end does not need to confirm the receipt of the notification.|
## CharacteristicReadReq
Defines the parameters of the **CharacteristicReadReq** event received by the server.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | No | Address of the client that sends the request, for example, **8F:8F:8E:8E:6D:6D**. |
-| transId | number | Yes | No | Transmission ID of the read request. The response returned by the server must use the same transmission ID. |
-| offset | number | Yes | No | Position from which the characteristic value is read. For example, **k** means to read from the _k_th byte. The response returned by the server must use the same offset. |
-| characteristicUuid | string | Yes | No | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**. |
-| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**. |
+| deviceId | string | Yes| No| Address of the remote device that sends the **CharacteristicReadReq** event, for example, XX:XX:XX:XX:XX:XX.|
+| transId | number | Yes| No| Transmission ID of the read request. The response returned by the server must use the same transmission ID.|
+| offset | number | Yes| No| Position from which the characteristic value is read. For example, **k** means to read from the kth byte. The response returned by the server must use the same offset.|
+| characteristicUuid | string | Yes| No| UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| serviceUuid | string | Yes| No| UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
## CharacteristicWriteReq
Defines the parameters of the **CharacteristicWriteReq** event received by the server.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | No | Address of the client that sends the request, for example, **8F:8F:8E:8E:6D:6D**. |
-| transId | number | Yes | No | Transmission ID of the write request. The response returned by the server must use the same transmission ID. |
-| offset | number | Yes | No | Start position for writing the characteristic value. For example, **k** means to write from the _k_th byte. The response returned by the server must use the same offset. |
-| descriptorUuid | string | Yes | No | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**. |
-| characteristicUuid | string | Yes | No | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**. |
-| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**. |
+| deviceId | string | Yes| No| Address of the remote device that sends the **CharacteristicWriteReq** event, for example, XX:XX:XX:XX:XX:XX.|
+| transId | number | Yes| No| Transmission ID of the write request. The response returned by the server must use the same transmission ID.|
+| offset | number | Yes| No| Start position for writing the characteristic value. For example, **k** means to write from the kth byte. The response returned by the server must use the same offset.|
+| descriptorUuid | string | Yes| No| UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes| No| UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| serviceUuid | string | Yes| No| UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
## DescriptorReadReq
Defines the parameters of the **DescriptorReadReq** event received by the server.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | No | Address of the client that sends the request, for example, **8F:8F:8E:8E:6D:6D**. |
-| transId | number | Yes | No | Transmission ID of the read request. The response returned by the server must use the same transmission ID. |
-| offset | number | Yes | No | Position from which the descriptor is read. For example, **k** means to read from the _k_th byte. The response returned by the server must use the same offset. |
-| descriptorUuid | string | Yes | No | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**. |
-| characteristicUuid | string | Yes | No | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**. |
-| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**. |
+| deviceId | string | Yes| No| Address of the remote device that sends a **DescriptorReadReq** event, for example, XX:XX:XX:XX:XX:XX.|
+| transId | number | Yes| No| Transmission ID of the read request. The response returned by the server must use the same transmission ID.|
+| offset | number | Yes| No| Position from which the descriptor is read. For example, **k** means to read from the kth byte. The response returned by the server must use the same offset.|
+| descriptorUuid | string | Yes| No| UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes| No| UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| serviceUuid | string | Yes| No| UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
## DescriptorWriteReq
Defines the parameters of the **DescriptorWriteReq** event received by the server.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | No | Address of the client that sends the request, for example, **8F:8F:8E:8E:6D:6D**. |
-| transId | number | Yes | No | Transmission ID of the write request. The response returned by the server must use the same transmission ID. |
-| offset | number | Yes | No | Start position for writing the descriptor. For example, **k** means to write from the _k_th byte. The response returned by the server must use the same offset. |
-| isPrep | boolean | Yes | No | Whether the write request is executed immediately. |
-| needRsp | boolean | Yes | No | Whether to send a response to the GATT client. |
-| value | ArrayBuffer | Yes | No | Binary value of the descriptor to write. |
-| descriptorUuid | string | Yes | No | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**. |
-| characteristicUuid | string | Yes | No | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**. |
-| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**. |
+| deviceId | string | Yes| No| Address of the remote device that sends a **DescriptorWriteReq** event, for example, XX:XX:XX:XX:XX:XX.|
+| transId | number | Yes| No| Transmission ID of the write request. The response returned by the server must use the same transmission ID.|
+| offset | number | Yes| No| Start position for writing the descriptor. For example, **k** means to write from the kth byte. The response returned by the server must use the same offset.|
+| isPrep | boolean | Yes| No| Whether the write request is executed immediately.|
+| needRsp | boolean | Yes| No| Whether to send a response to the GATT client.|
+| value | ArrayBuffer | Yes| No| Binary value of the descriptor to write.|
+| descriptorUuid | string | Yes| No| UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes| No| UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| serviceUuid | string | Yes| No| UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
## ServerResponse
Defines the parameters of the server's response to the GATT client's read/write request.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | No | Address of the client, for example, **8F:8F:8E:8E:6D:6D**. |
-| transId | number | Yes | No | Transmission ID of the request. The value must be the same as the ID carried in the read/write request received. |
-| status | number | Yes | No | Response state. Set this parameter to **0**, which indicates a normal response. |
-| offset | number | Yes | No | Start read/write position. The value must be the same as the **offset** carried in the read/write request. |
-| value | ArrayBuffer | Yes | No | Binary data in the response. |
+| deviceId | string | Yes| No| Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
+| transId | number | Yes| No| Transmission ID of the request. The value must be the same as the ID carried in the read/write request received.|
+| status | number | Yes| No| Response state. Set this parameter to **0**, which indicates a normal response.|
+| offset | number | Yes| No| Start read/write position. The value must be the same as the offset carried in the read/write request.|
+| value | ArrayBuffer | Yes| No| Binary data in the response.|
## BLEConnectChangedState
Defines the parameters of **BLEConnectChangedState**.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | No | Address of the peer device, for example, **8F:8F:8E:8E:6D:6D**. |
-| state | [ProfileConnectionState](#ProfileConnectionState) | Yes | Yes | BLE connection state. |
+| deviceId | string | Yes| No| Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
+| state | [ProfileConnectionState](#profileconnectionState) | Yes| Yes| BLE connection state.|
## ProfileConnectionState
Enumerates the profile connection states.
-| Name | Default Value | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Default Value| Description|
| -------- | -------- | -------- |
-| STATE_DISCONNECTED | 0 | Disconnected. |
-| STATE_CONNECTING | 1 | Connecting. |
-| STATE_CONNECTED | 2 | Connected. |
-| STATE_DISCONNECTING | 3 | Disconnecting. |
+| STATE_DISCONNECTED | 0 | Disconnected.|
+| STATE_CONNECTING | 1 | Connecting.|
+| STATE_CONNECTED | 2 | Connected.|
+| STATE_DISCONNECTING | 3 | Disconnecting.|
## ScanFilter
Defines the scan filter parameters.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | Yes | Address of the BLE device to filter, for example, **8F:8F:8E:8E:6D:6D**. |
-| name | string | Yes | Yes | Name of the BLE device to filter. |
-| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**. |
+| deviceId | string | Yes| Yes| Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX.|
+| name | string | Yes| Yes| Name of the BLE device to filter.|
+| serviceUuid | string | Yes| Yes| UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
## ScanOptions
Defines the scan configuration parameters.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| interval | number | Yes | Yes | Delay in reporting the scan result. The default value is **0**. |
-| dutyMode | [ScanDuty](#ScanDuty) | Yes | Yes | Scan duty. The default value is **SCAN_MODE_LOW_POWER**. |
-| matchMode | [MatchMode](#MatchMode) | Yes | Yes | Hardware match mode for BLE scan filters. The default value is **MATCH_MODE_AGGRESSIVE**. |
+| interval | number | Yes| Yes| Delay in reporting the scan result. The default value is **0**.|
+| dutyMode | [ScanDuty](#scanduty) | Yes| Yes| Scan duty. The default value is **SCAN_MODE_LOW_POWER**.|
+| matchMode | [MatchMode](#matchmode) | Yes| Yes| Hardware filtering match mode. The default value is **MATCH_MODE_AGGRESSIVE**.|
## ScanDuty
Enumerates the scan duty options.
-| Name | Default Value | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Default Value| Description|
| -------- | -------- | -------- |
-| SCAN_MODE_LOW_POWER | 0 | Low-power mode, which is the default value. |
-| SCAN_MODE_BALANCED | 1 | Balanced mode. |
-| SCAN_MODE_LOW_LATENCY | 2 | Low-latency mode. |
+| SCAN_MODE_LOW_POWER | 0 | Low-power mode, which is the default value.|
+| SCAN_MODE_BALANCED | 1 | Balanced mode.|
+| SCAN_MODE_LOW_LATENCY | 2 | Low-latency mode.|
## MatchMode
Enumerates the hardware match modes of BLE scan filters.
-| Name | Default Value | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Default Value| Description|
| -------- | -------- | -------- |
-| MATCH_MODE_AGGRESSIVE | 1 | Hardware reports the scan result with a lower threshold of signal strength and few number of matches in a duration. This is the default value. |
-| SCAN_MODE_LOW_LATENCY | 2 | Hardware reports the scan result with a higher threshold of signal strength and sightings. |
+| MATCH_MODE_AGGRESSIVE | 1 | Hardware reports the scan result with a lower threshold of signal strength and few number of matches in a duration. This is the default value.|
+| MATCH_MODE_STICKY | 2 | Hardware reports the scan result with a higher threshold of signal strength and sightings.|
## ScanResult
Defines the scan result.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | No | Address of the device discovered, for example, **8F:8F:8E:8E:6D:6D**. |
-| rssi | number | Yes | No | RSSI of the device. |
-| data | ArrayBuffer | Yes | No | Advertisement packets sent by the device. |
+| deviceId | string | Yes| No| Address of the scanned device, for example, XX:XX:XX:XX:XX:XX.|
+| rssi | number | Yes| No| RSSI of the device.|
+| data | ArrayBuffer | Yes| No| Advertisement packets sent by the device.|
## BluetoothState
Enumerates the Bluetooth states.
-| Name | Default Value | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Default Value| Description|
| -------- | -------- | -------- |
-| STATE_OFF | 0 | Bluetooth is turned off. |
-| STATE_TURNING_ON | 1 | Bluetooth is being turned on. |
-| STATE_ON | 2 | Bluetooth is turned on. |
-| STATE_TURNING_OFF | 3 | Bluetooth is being turned off. |
-| STATE_BLE_TURNING_ON | 4 | The LE-only mode is being turned on for Bluetooth. |
-| STATE_BLE_ON | 5 | Bluetooth is in LE-only mode. |
-| STATE_BLE_TURNING_OFF | 6 | The LE-only mode is being turned off for Bluetooth. |
+| STATE_OFF | 0 | Bluetooth is turned off.|
+| STATE_TURNING_ON | 1 | Bluetooth is being turned on.|
+| STATE_ON | 2 | Bluetooth is turned on.|
+| STATE_TURNING_OFF | 3 | Bluetooth is being turned off.|
+| STATE_BLE_TURNING_ON | 4 | The LE-only mode is being turned on for Bluetooth.|
+| STATE_BLE_ON | 5 | Bluetooth is in LE-only mode.|
+| STATE_BLE_TURNING_OFF | 6 | The LE-only mode is being turned off for Bluetooth.|
## AdvertiseSetting
Defines the BLE advertising parameters.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| interval | number | Yes | Yes | Interval for BLE advertising. The minimum value is **32** slots (20 ms). The maximum value is **16777215** slots. The default value is **1600** slots (1s). |
-| txPower | number | Yes | Yes | Transmit power, in dBm. The value range is –127 to 1. The default value is **–7**. |
-| connectable | boolean | Yes | Yes | Whether the advertisement is connectable. The default value is **true**. |
+| interval | number | Yes| Yes| Interval for BLE advertising. The minimum value is **32** slots (20 ms). The maximum value is **16777215** slots. The default value is **1600** slots (1s).|
+| txPower | number | Yes| Yes| Transmit power, in dBm. The value range is –127 to 1. The default value is **–7**.|
+| connectable | boolean | Yes| Yes| Whether the advertisement is connectable. The default value is **true**.|
## AdvertiseData
Defines the content of a BLE advertisement packet.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| serviceUuids | Array<string> | Yes | Yes | List of service UUIDs to be broadcasted. |
-| manufactureData | Array<[ManufactureData](#ManufactureData)> | Yes | Yes | List of manufacturers to be broadcasted. |
-| serviceData | Array<[ServiceData](#ServiceData)> | Yes | Yes | List of service data to be broadcasted. |
+| serviceUuids | Array<string> | Yes| Yes| List of service UUIDs to broadcast.|
+| manufactureData | Array<[ManufactureData](#manufacturedata)> | Yes| Yes| List of manufacturers to broadcast.|
+| serviceData | Array<[ServiceData](#servicedata)> | Yes| Yes| List of service data to broadcast.|
## ManufactureData
Defines the content of a BLE advertisement packet.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| manufactureId | Array<string> | Yes | Yes | Manufacturer ID allocated by the Bluetooth SIG. |
-| manufactureValue | ArrayBuffer | Yes | Yes | Manufacturer data. |
+| manufactureId | Array<string> | Yes| Yes| Manufacturer ID allocated by the Bluetooth SIG.|
+| manufactureValue | ArrayBuffer | Yes| Yes| Manufacturer data.|
## ServiceData
Defines the service data contained in an advertisement packet.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| serviceUuid | string | Yes | Yes | Service UUID. |
-| serviceValue | ArrayBuffer | Yes | Yes | Service data. |
+| serviceUuid | string | Yes| Yes| Service UUID.|
+| serviceValue | ArrayBuffer | Yes| Yes| Service data.|
-## PinRequiredParam
+## PinRequiredParam8+
Defines the pairing request parameters.
-| Name | Type | Readable | Writable | Description |
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| deviceId | string | Yes | No | ID of the device to pair. |
-| pinCode | string | Yes | No | Key for the device pairing. |
+| deviceId | string | Yes| No| ID of the device to pair.|
+| pinCode | string | Yes| No| Key for the device pairing.|
+
+
+## StateChangeParam8+
+
+Defines the profile state change parameters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| deviceId | string | Yes| No| Address of a Bluetooth device.|
+| state | [ProfileConnectionState](#ProfileConnectionState) | Yes| No| Profile connection state of the device.|
+
+
+## DeviceClass8+
+
+Defines the class of a Bluetooth device.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| majorClass | [MajorClass](#majorclass) | Yes| No| Major classes of Bluetooth devices.|
+| majorMinorClass | [MajorMinorClass](#majorminorclass) | Yes| No| Major and minor classes of Bluetooth devices.|
+| classOfDevice | number | Yes| No| Class of the device.|
+
+
+
+## MajorClass8+
+
+Enumerates the major classes of Bluetooth devices.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Default Value| Description|
+| -------- | -------- | -------- |
+| MAJOR_MISC | 0x0000 | Miscellaneous device.|
+| MAJOR_COMPUTER | 0x0100 | Computer.|
+| MAJOR_PHONE | 0x0200 | Mobile phone.|
+| MAJOR_NETWORKING | 0x0300 | Network device.|
+| MAJOR_AUDIO_VIDEO | 0x0400 | Audio or video device.|
+| MAJOR_PERIPHERAL | 0x0500 | Peripheral device.|
+| MAJOR_IMAGING | 0x0600 | Imaging device.|
+| MAJOR_WEARABLE | 0x0700 | Wearable device.|
+| MAJOR_TOY | 0x0800 | Toy.|
+| MAJOR_HEALTH | 0x0900 | Health device.|
+| MAJOR_UNCATEGORIZED | 0x1F00 | Unclassified device.|
+
+
+## MajorMinorClass8+
+
+Enumerates the major and minor classes of Bluetooth devices.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Default Value| Description|
+| -------- | -------- | -------- |
+| COMPUTER_UNCATEGORIZED | 0x0100 | Unclassified computer.|
+| COMPUTER_DESKTOP | 0x0104 | Desktop computer.|
+| COMPUTER_SERVER | 0x0108 | Server.|
+| COMPUTER_LAPTOP | 0x010C | Laptop.|
+| COMPUTER_HANDHELD_PC_PDA | 0x0110 | Hand-held computer.|
+| COMPUTER_PALM_SIZE_PC_PDA | 0x0114 | Palmtop computer.|
+| COMPUTER_WEARABLE | 0x0118 | Wearable computer.|
+| COMPUTER_TABLET | 0x011C | Tablet.|
+| PHONE_UNCATEGORIZED | 0x0200 | Unclassified mobile phone.|
+| PHONE_CELLULAR | 0x0204 | Portable phone.|
+| PHONE_CORDLESS | 0x0208 | Cordless phone.|
+| PHONE_SMART | 0x020C | Smartphone.|
+| PHONE_MODEM_OR_GATEWAY | 0x0210 | Modem or gateway phone.|
+| PHONE_ISDN | 0x0214 | ISDN phone.|
+| NETWORK_FULLY_AVAILABLE | 0x0300 | Device with network fully available.|
+| NETWORK_1_TO_17_UTILIZED | 0x0320 | Device used on network 1 to 17.|
+| NETWORK_17_TO_33_UTILIZED | 0x0340 | Device used on network 17 to 33.|
+| NETWORK_33_TO_50_UTILIZED | 0x0360 | Device used on network 33 to 50.|
+| NETWORK_60_TO_67_UTILIZED | 0x0380 | Device used on network 60 to 67.|
+| NETWORK_67_TO_83_UTILIZED | 0x03A0 | Device used on network 67 to 83.|
+| NETWORK_83_TO_99_UTILIZED | 0x03C0 | Device used on network 83 to 99.|
+| NETWORK_NO_SERVICE | 0x03E0 | Device without network service
+| AUDIO_VIDEO_UNCATEGORIZED | 0x0400 | Unclassified audio or video device.|
+| AUDIO_VIDEO_WEARABLE_HEADSET | 0x0404 | Wearable audio or video headset.|
+| AUDIO_VIDEO_HANDSFREE | 0x0408 | Hands-free audio or video device.|
+| AUDIO_VIDEO_MICROPHONE | 0x0410 | Audio or video microphone.|
+| AUDIO_VIDEO_LOUDSPEAKER | 0x0414 | Audio or video loudspeaker.|
+| AUDIO_VIDEO_HEADPHONES | 0x0418 | Audio or video headphones.|
+| AUDIO_VIDEO_PORTABLE_AUDIO | 0x041C | Portable audio or video device.|
+| AUDIO_VIDEO_CAR_AUDIO | 0x0420 | In-vehicle audio or video device.|
+| AUDIO_VIDEO_SET_TOP_BOX | 0x0424 | Audio or video STB device.|
+| AUDIO_VIDEO_HIFI_AUDIO | 0x0428 | High-fidelity speaker device.|
+| AUDIO_VIDEO_VCR| 0x042C | Video cassette recording (VCR) device.|
+| AUDIO_VIDEO_VIDEO_CAMERA | 0x0430 | Camera.|
+| AUDIO_VIDEO_CAMCORDER | 0x0434 | Camcorder|
+| AUDIO_VIDEO_VIDEO_MONITOR | 0x0438 | Audio or video monitor.|
+| AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER | 0x043C | Video display or loudspeaker.|
+| AUDIO_VIDEO_VIDEO_CONFERENCING | 0x0440 | Video conferencing device.|
+| AUDIO_VIDEO_VIDEO_GAMING_TOY | 0x0448 | Audio or video gaming toy.|
+| PERIPHERAL_NON_KEYBOARD_NON_POINTING | 0x0500 | Non-keyboard or non-pointing peripheral device.|
+| PERIPHERAL_KEYBOARD | 0x0540 | Keyboard device.|
+| PERIPHERAL_POINTING_DEVICE | 0x0580 | Pointing peripheral device.|
+| PERIPHERAL_KEYBOARD_POINTING| 0x05C0 | Keyboard pointing device.|
+| PERIPHERAL_UNCATEGORIZED | 0x0500 | Unclassified peripheral device.|
+| PERIPHERAL_JOYSTICK | 0x0504 | Peripheral joystick.|
+| PERIPHERAL_GAMEPAD | 0x0508 | Peripheral game pad|
+| PERIPHERAL_REMOTE_CONTROL | 0x05C0 | Peripheral remote control device|
+| PERIPHERAL_SENSING_DEVICE | 0x0510 | Peripheral sensing device.|
+| PERIPHERAL_DIGITIZER_TABLET | 0x0514 | Peripheral digitizer tablet.|
+| PERIPHERAL_CARD_READER | 0x0518 | Peripheral card reader.|
+| PERIPHERAL_DIGITAL_PEN | 0x051C | Peripheral digital pen.|
+| PERIPHERAL_SCANNER_RFID | 0x0520 | Peripheral RFID scanner.|
+| PERIPHERAL_GESTURAL_INPUT | 0x0522 | Gesture input device.|
+| IMAGING_UNCATEGORIZED | 0x0600 | Unclassified imaging device.|
+| IMAGING_DISPLAY | 0x0610 | Imaging display device.|
+| IMAGING_CAMERA | 0x0620 | Imaging camera device.|
+| IMAGING_SCANNER | 0x0640 | Imaging scanner.|
+| IMAGING_PRINTER | 0x0680 | Imaging printer.|
+| WEARABLE_UNCATEGORIZED | 0x0700 | Unclassified wearable device.|
+| WEARABLE_WRIST_WATCH | 0x0704 | Smart watch.|
+| WEARABLE_PAGER | 0x0708 | Wearable pager.|
+| WEARABLE_JACKET | 0x070C | Smart jacket.|
+| WEARABLE_HELMET | 0x0710 | Wearable helmet.|
+| WEARABLE_GLASSES | 0x0714 | Wearable glasses.|
+| TOY_UNCATEGORIZED | 0x0800 | Unclassified toy.|
+| TOY_ROBOT| 0x0804 | Toy robot.|
+| TOY_VEHICLE | 0x0808 | Toy vehicle.|
+| TOY_DOLL_ACTION_FIGURE | 0x080C | Humanoid toy doll.|
+| TOY_CONTROLLER | 0x0810 | Toy controller.|
+| TOY_GAME | 0x0814 | Toy gaming device.|
+| HEALTH_UNCATEGORIZED | 0x0900 | Unclassified health devices.|
+| HEALTH_BLOOD_PRESSURE | 0x0904 | Blood pressure device.|
+| HEALTH_THERMOMETER | 0x0908 | Thermometer|
+| HEALTH_WEIGHING | 0x090C | Body scale.|
+| HEALTH_GLUCOSE | 0x0910 | Blood glucose monitor.|
+| HEALTH_PULSE_OXIMETER | 0x0914 | Pulse oximeter.|
+| HEALTH_PULSE_RATE | 0x0918 | Heart rate monitor.|
+| HEALTH_DATA_DISPLAY | 0x091C | Health data display.|
+| HEALTH_STEP_COUNTER | 0x0920 | Step counter.|
+| HEALTH_BODY_COMPOSITION_ANALYZER | 0x0924 | Body composition analyzer.|
+| HEALTH_PEAK_FLOW_MOITOR | 0x0928 | Hygrometer.|
+| HEALTH_MEDICATION_MONITOR | 0x092C | Medication monitor.|
+| HEALTH_KNEE_PROSTHESIS | 0x0930 | Prosthetic knee.|
+| HEALTH_ANKLE_PROSTHESIS | 0x0934 | Prosthetic ankle.|
+| HEALTH_GENERIC_HEALTH_MANAGER | 0x0938 | Generic health management device.|
+| HEALTH_PERSONAL_MOBILITY_DEVICE | 0x093C | Personal mobility device.|
+
+
+## PlayingState8+
+
+Enumerates the A2DP playing states.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Default Value| Description|
+| -------- | -------- | -------- |
+| STATE_NOT_PLAYING | 0x0000 | Not playing.|
+| STATE_PLAYING | 0x0001 | Playing.|
+
+
+## ProfileId8+
+
+Enumerates the Bluetooth profile IDs.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name| Default Value| Description|
+| -------- | -------- | -------- |
+| PROFILE_A2DP_SOURCE | 0x0001 | A2DP profile.|
+| PROFILE_HANDS_FREE_AUDIO_GATEWAY | 0x0004 | HFP profile.|
diff --git a/en/application-dev/reference/apis/js-apis-brightness.md b/en/application-dev/reference/apis/js-apis-brightness.md
index 55ad71e3dd1a97d5ba65c07e51bf1639df999f46..c76047bde1b92f0e213a58091aafcf2a41d8793d 100644
--- a/en/application-dev/reference/apis/js-apis-brightness.md
+++ b/en/application-dev/reference/apis/js-apis-brightness.md
@@ -1,6 +1,6 @@
# Brightness
->  **NOTE**
+>  **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The Brightness module provides an API for setting the screen brightness.
@@ -14,19 +14,19 @@ import brightness from '@ohos.brightness';
## brightness.setValue
-setValue(value: number)
+setValue(value: number): void
Sets the screen brightness.
-**System capability:** SystemCapability.PowerManager.DisplayPowerManager
+This is a system API and cannot be called by third-party applications.
-**Note:** This is a system API and it is used only for system applications.
+**System capability:** SystemCapability.PowerManager.DisplayPowerManager
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----------- |
-| value | number | Yes | Brightness value, ranging from 0 to 255.|
+| value | number | Yes | Brightness value, ranging from **0** to **255**.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-config-policy.md b/en/application-dev/reference/apis/js-apis-config-policy.md
new file mode 100644
index 0000000000000000000000000000000000000000..3991e4ab9dff7911220c98d4aa89b2c896cbb1fe
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-config-policy.md
@@ -0,0 +1,170 @@
+# Configuration Policy
+
+>  **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.
+
+The configuration policy provides the capability of obtaining the custom configuration directory and file path based on the predefined custom configuration level.
+
+## Modules to Import
+
+```
+import configPolicy from '@ohos.configPolicy';
+```
+
+## getOneCfgFile
+
+getOneCfgFile(relPath: string, callback: AsyncCallback<string>): void
+
+Obtains the path of a configuration file with the specified name and highest priority. This API uses an asynchronous callback to return the result.
+For example, if the **config.xml** file is stored in **/system/etc/config.xml** and **/sys-pod/etc/config.xml** (in ascending order of priority), then **/sys-pod/etc/config.xml** is returned.
+
+**System capability**: SystemCapability.Customization.ConfigPolicy
+
+**Parameters**
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | relPath | string | Yes| Name of the configuration file.|
+ | callback | AsyncCallback<string> | Yes| Callback used to return the path of the configuration file.|
+
+**Example**
+ ```
+ configPolicy.getOneCfgFile('config.xml', (error, value) => {
+ if (error == undefined) {
+ console.log(value);
+ } else {
+ console.log(error);
+ }
+ });
+ ```
+
+
+## getOneCfgFile
+
+getOneCfgFile(relPath: string): Promise<string>
+
+Obtains the path of a configuration file with the specified name and highest priority. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Customization.ConfigPolicy
+
+**Parameters**
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | relPath | string | Yes| Name of the configuration file.|
+
+**Return value**
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<string> | Promise used to return the path of the configuration file.|
+
+**Example**
+ ```
+ configPolicy.getOneCfgFile('config.xml').then(value => {
+ console.log(value);
+ }).catch(error => {
+ console.log("getOneCfgFile promise " + error);
+ });
+ ```
+
+
+## getCfgFiles
+
+getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>): void
+
+Obtains all configuration files with the specified name and lists them in ascending order of priority. This API uses an asynchronous callback to return the result. For example, if the **config.xml** file is stored in **/system/etc/config.xml**
+and **/sys-pod/etc/config.xml**, then **/system/etc/config.xml, /sys-pod/etc/config.xml** is returned.
+
+**System capability**: SystemCapability.Customization.ConfigPolicy
+
+**Parameters**
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | relPath | string | Yes| Name of the configuration file.|
+ | callback | AsyncCallback<Array<string>> | Yes| Callback used to return the file list.|
+
+**Example**
+ ```
+ configPolicy.getCfgFiles('config.xml', (error, value) => {
+ if (error == undefined) {
+ console.log(value);
+ } else {
+ console.log(error);
+ }
+ });
+ ```
+
+
+## getCfgFiles
+
+getCfgFiles(relPath: string): Promise<Array<string>>
+
+Obtains all configuration files with the specified name and lists them in ascending order of priority. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Customization.ConfigPolicy
+
+**Parameters**
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | relPath | string | Yes| Name of the configuration file.|
+
+**Return value**
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<Array<string>> | Promise used to return the file list.|
+
+**Example**
+ ```
+ configPolicy.getCfgFiles('config.xml').then(value => {
+ console.log(value);
+ }).catch(error => {
+ console.log("getCfgFiles promise " + error);
+ });
+ ```
+
+
+## getCfgDirList
+
+getCfgDirList(callback: AsyncCallback<Array<string>>): void
+
+Obtains the configuration level directory list. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Customization.ConfigPolicy
+
+**Parameters**
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<Array<string>> | Yes| Callback used to return the configuration level directory list.|
+
+**Example**
+ ```
+ configPolicy.getCfgDirList((error, value) => {
+ if (error == undefined) {
+ console.log(value);
+ } else {
+ console.log(error);
+ }
+ });
+ ```
+
+
+## getCfgDirList
+
+getCfgDirList(): Promise<Array<string>>
+
+Obtains the configuration level directory list. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Customization.ConfigPolicy
+
+**Return value**
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<Array<string>> | Promise used to return the configuration level directory list.|
+
+**Example**
+ ```
+ configPolicy.getCfgDirList().then(value => {
+ console.log(value);
+ }).catch(error => {
+ console.log("getCfgDirList promise " + error);
+ });
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-configuration.md b/en/application-dev/reference/apis/js-apis-configuration.md
index e4199544636c77103197529f72de34145756ae5c..50803fb4587f9e8ec8e31f447a90eeccdd44780c 100644
--- a/en/application-dev/reference/apis/js-apis-configuration.md
+++ b/en/application-dev/reference/apis/js-apis-configuration.md
@@ -10,17 +10,19 @@ Provides the configuration for the environment where the ability is running.
## Modules to Import
-```
+```js
import Configuration from '@ohos.application.Configuration';
```
## Attributes
+**System capability**: SystemCapability.Ability.AbilityBase
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| language | string | Yes| Yes| Language of the application.|
| colorMode | [ColorMode](js-apis-configurationconstant.md) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
-| direction | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
-| screenDensity | ScreenDensity | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
-| displayId | number | Yes| No| ID of the display where the application is located.|
+| direction9+ | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
+| screenDensity9+ | ScreenDensity | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
+| displayId9+ | number | Yes| No| ID of the display where the application is located.|
diff --git a/en/application-dev/reference/apis/js-apis-configurationconstant.md b/en/application-dev/reference/apis/js-apis-configurationconstant.md
index 0e480eafe47e691044f6eb5095285962322e4a51..55f42b926d4bfcbb4b07a48185611b22a92cbc32 100644
--- a/en/application-dev/reference/apis/js-apis-configurationconstant.md
+++ b/en/application-dev/reference/apis/js-apis-configurationconstant.md
@@ -10,46 +10,67 @@ Defines enumerated values of the configuration for the environment where the abi
## Modules to Import
-```
+```js
import ConfigurationConstant from '@ohos.application.ConfigurationConstant';
```
-## ColorMode
+## ConfigurationConstant.ColorMode
+
+The value is obtained through the **ConfigurationConstant.ColorMode** API.
-To obtain the value, use **ConfigurationConstant.ColorMode**, for example, **ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT**.
+**Example**
+```
+ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT
+```
- | Name| Value| Description|
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name| Value| Description|
| -------- | -------- | -------- |
| COLOR_MODE_NOT_SET | -1 | Unspecified color mode.|
| COLOR_MODE_DARK | 0 | Dark mode.|
| COLOR_MODE_LIGHT | 1 | Light mode.|
-## Direction
+## ConfigurationConstant.Direction
-To obtain the value, use **ConfigurationConstant.Direction**, for example, **ConfigurationConstant.Direction.DIRECTION_VERTICAL**.
+The value is obtained through the **ConfigurationConstant.Direction** API.
+**Example**
- | Name| Value| Description|
+```
+ConfigurationConstant.Direction.DIRECTION_VERTICAL
+```
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name| Value| Description|
| -------- | -------- | -------- |
-| DIRECTION_NOT_SET | -1 | Unspecified direction.|
-| DIRECTION_VERTICAL | 0 | Vertical direction.|
-| DIRECTION_HORIZONTAL | 1 | Horizontal direction.|
+| DIRECTION_NOT_SET9+ | -1 | Unspecified direction.|
+| DIRECTION_VERTICAL9+ | 0 | Vertical direction.|
+| DIRECTION_HORIZONTAL9+ | 1 | Horizontal direction.|
+
+## ConfigurationConstant.ScreenDensity
-## ScreenDensity
+The value is obtained through the **ConfigurationConstant.ScreenDensity** API.
-To obtain the value, use **ConfigurationConstant.ScreenDensity**, for example, **ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_NOT_SET**.
+**Example**
+
+```
+ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_NOT_SET
+```
+**System capability**: SystemCapability.Ability.AbilityBase
- | Name| Value| Description|
+| Name| Value| Description|
| -------- | -------- | -------- |
-| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
-| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
-| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
-| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
-| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
-| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
-| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
+| SCREEN_DENSITY_NOT_SET9+ | 0 | Unspecified screen resolution.|
+| SCREEN_DENSITY_SDPI9+ | 120 | The screen resolution is sdpi.|
+| SCREEN_DENSITY_MDPI9+ | 160 | The screen resolution is mdpi.|
+| SCREEN_DENSITY_LDPI9+ | 240 | The screen resolution is ldpi.|
+| SCREEN_DENSITY_XLDPI9+ | 320 | The screen resolution is xldpi.|
+| SCREEN_DENSITY_XXLDPI9+ | 480 | The screen resolution is xxldpi.|
+| SCREEN_DENSITY_XXXLDPI9+ | 640 | The screen resolution is xxxldpi.|
diff --git a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md
index 49e61156a499d926620ecd0aa7bb6455c4aec9c7..fb34371c004c08cfc346a81cc13b8d3387f3ca94 100644
--- a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md
+++ b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md
@@ -8,17 +8,13 @@ import ohos_data_ability from '@ohos.data.dataability'
import ohos_data_rdb from '@ohos.data.rdb'
```
-## DataAbilityHelper
-
-### openFile
+## DataAbilityHelper.openFile
openFile(uri: string, mode: string, callback: AsyncCallback\): void
-Opens a file with a specified URI. This method uses a callback to return the result.
-
-**System capabilities**
+Opens a file with a specified URI. This API uses an asynchronous callback to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -44,15 +40,13 @@ DAHelper.openFile(
});
```
-### openFile
+## DataAbilityHelper.openFile
openFile(uri: string, mode: string): Promise\
-Opens a file with a specified URI. This method uses a promise to return the result.
-
-**System capabilities**
+Opens a file with a specified URI. This API uses a promise to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -62,6 +56,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| mode | string | Yes | Mode for opening the file. The value can be **rwt**. |
**Return value**
+
| Type | Description |
| ---------------- | ---------------- |
| Promise\ | Promise used to return the file descriptor.|
@@ -81,15 +76,13 @@ DAHelper.openFile(
});
```
-### on('dataChange')
+## DataAbilityHelper.on
on(type: 'dataChange', uri: string, callback: AsyncCallback\): void
-Registers an observer to observe data specified by a given URI. This method uses a callback to return the result.
-
-**System capabilities**
+Registers an observer to observe data specified by a given URI. This API uses an asynchronous callback to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -116,15 +109,13 @@ helper.on(
)
```
-### off('dataChange')
+## DataAbilityHelper.off
off(type: 'dataChange', uri: string, callback?: AsyncCallback\): void
-Unregisters the observer used to observe data specified by a given URI. This method uses a callback to return the result.
+Unregisters the observer used to observe data specified by a given URI. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -155,15 +146,13 @@ helper.off(
)
```
-### getType
+## DataAbilityHelper.getType
getType(uri: string, callback: AsyncCallback\): void
-Obtains the MIME type of the data specified by a given URI. This method uses a callback to return the result.
-
-**System capabilities**
+Obtains the MIME type of the data specified by a given URI. This API uses an asynchronous callback to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -186,15 +175,13 @@ DAHelper.getType(
});
```
-### getType
+## DataAbilityHelper.getType
getType(uri: string): Promise\
-Obtains the MIME type of the data specified by a given URI. This method uses a promise to return the result.
+Obtains the MIME type of the data specified by a given URI. This API uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -203,6 +190,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| uri | string | Yes | URI of the data.|
**Return value**
+
| Type | Description |
| ---------------- | ----------------------------------- |
| Promise\ | Promise used to return the MIME type.|
@@ -221,15 +209,13 @@ DAHelper.getType(
});
```
-### getFileTypes
+## DataAbilityHelper.getFileTypes
getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void
-Obtains the supported MIME types of a specified file. This method uses a callback to return the result.
+Obtains the supported MIME types of a specified file. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -256,15 +242,13 @@ DAHelper.getFileTypes(
-### getFileTypes
+## DataAbilityHelper.getFileTypes
getFileTypes(uri: string, mimeTypeFilter: string): Promise\>
-Obtains the supported MIME types of a specified file. This method uses a promise to return the result.
-
-**System capabilities**
+Obtains the supported MIME types of a specified file. This API uses a promise to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -274,6 +258,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| mimeTypeFilter | string | Yes | MIME type of the file.|
**Return value**
+
| Type | Description |
| ------------------------ | ------------------------ |
| Promise\> | Promise used to return the supported MIME types.|
@@ -293,15 +278,13 @@ DAHelper.getFileTypes(
});
```
-### normalizeUri
+## DataAbilityHelper.normalizeUri
normalizeUri(uri: string, callback: AsyncCallback\): void
-Converts the URI that refers to a Data ability into a normalized URI. This method uses a callback to return the result.
+Converts the URI that refers to a Data ability into a normalized URI. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -324,15 +307,13 @@ DAHelper.normalizeUri(
});
```
-### normalizeUri
+## DataAbilityHelper.normalizeUri
normalizeUri(uri: string): Promise\
-Converts the URI that refers to a Data ability into a normalized URI. This method uses a promise to return the result.
-
-**System capabilities**
+Converts the URI that refers to a Data ability into a normalized URI. This API uses a promise to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -341,6 +322,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| uri | string | Yes | URI object to normalize.|
**Return value**
+
| Type | Description |
| ---------------- | ------------------------------------------------------ |
| Promise\ | Promise used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.|
@@ -359,15 +341,13 @@ DAHelper.normalizeUri(
});
```
-### denormalizeUri
+## DataAbilityHelper.denormalizeUri
denormalizeUri(uri: string, callback: AsyncCallback\): void
-Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: string, callback: AsyncCallback\)** to a denormalized one. This method uses a callback to return the result.
-
-**System capabilities**
+Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: string, callback: AsyncCallback\)** to a denormalized one. This API uses an asynchronous callback to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -392,15 +372,13 @@ DAHelper.denormalizeUri(
-### denormalizeUri
+## DataAbilityHelper.denormalizeUri
denormalizeUri(uri: string): Promise\
-Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: string)** to a denormalized one. This method uses a promise to return the result.
+Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: string)** to a denormalized one. This API uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -409,6 +387,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| uri | string | Yes | URI object to normalize.|
**Return value**
+
| Type | Description |
| ---------------- | ----------------------------------------- |
| Promise\ | Promise used to return the denormalized URI object.|
@@ -427,15 +406,13 @@ DAHelper.denormalizeUri(
});
```
-### notifyChange
+## DataAbilityHelper.notifyChange
notifyChange(uri: string, callback: AsyncCallback\): void
-Notifies the registered observer of a change to the data specified by the URI. This method uses a callback to return the result.
+Notifies the registered observer of a change to the data specified by the URI. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -458,15 +435,13 @@ helper.notifyChange(
});
```
-### notifyChange
+## DataAbilityHelper.notifyChange
notifyChange(uri: string): Promise\
-Notifies the registered observer of a change to the data specified by the URI. This method uses a promise to return the result.
-
-**System capabilities**
+Notifies the registered observer of a change to the data specified by the URI. This API uses a promise to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -475,6 +450,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| uri | string | Yes | URI of the data.|
**Return value**
+
| Type | Description |
| -------------- | --------------------- |
| Promise\ | Promise used to return the result.|
@@ -493,15 +469,13 @@ DAHelper.notifyChange(
});
```
-### insert
+## DataAbilityHelper.insert
insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\): void
-Inserts a single data record into the database. This method uses a callback to return the result.
+Inserts a single data record into the database. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -532,15 +506,13 @@ DAHelper.insert(
});
```
-### insert
+## DataAbilityHelper.insert
insert(uri: string, valuesBucket: rdb.ValuesBucket): Promise\
-Inserts a single data record into the database. This method uses a promise to return the result.
-
-**System capabilities**
+Inserts a single data record into the database. This API uses a promise to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -550,6 +522,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| valuesBucket | rdb.ValuesBucket | Yes | Data record to insert. If this parameter is **null**, a blank row will be inserted.|
**Return value**
+
| Type | Description |
| ---------------- | ------------------------ |
| Promise\ | Promise used to return the index of the inserted data record.|
@@ -575,15 +548,13 @@ DAHelper.insert(
});
```
-### batchInsert
+## DataAbilityHelper.batchInsert
batchInsert(uri: string, valuesBuckets: Array, callback: AsyncCallback\): void
-Inserts multiple data records into the database. This method uses a callback to return the result.
-
-**System capabilities**
+Inserts multiple data records into the database. This API uses an asynchronous callback to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -611,15 +582,13 @@ DAHelper.batchInsert(
});
```
-### batchInsert
+## DataAbilityHelper.batchInsert
batchInsert(uri: string, valuesBuckets: Array): Promise\
-Inserts multiple data records into the database. This method uses a promise to return the result.
+Inserts multiple data records into the database. This API uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -629,6 +598,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| valuesBucket | Array | Yes | Data record to insert. |
**Return value**
+
| Type | Description |
| ---------------- | ---------------------- |
| Promise\ | Promise used to return the number of inserted data records.|
@@ -651,15 +621,13 @@ DAHelper.batchInsert(
});
```
-### delete
+## DataAbilityHelper.delete
delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void
-Deletes one or more data records from the database. This method uses a callback to return the result.
+Deletes one or more data records from the database. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -686,15 +654,13 @@ DAHelper.delete(
});
```
-### delete
+## DataAbilityHelper.delete
delete(uri: string, predicates: dataAbility.DataAbilityPredicates): Promise\
-Deletes one or more data records from the database. This method uses a promise to return the result.
-
-**System capabilities**
+Deletes one or more data records from the database. This API uses a promise to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -704,6 +670,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| valuesBucket | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.|
**Return value**
+
| Type | Description |
| ---------------- | ------------------------ |
| Promise\ | Promise used to return the number of deleted data records.|
@@ -724,15 +691,13 @@ DAHelper.delete(
});
```
-### update
+## DataAbilityHelper.update
update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void
-Updates data records in the database. This method uses a callback to return the result.
+Updates data records in the database. This API uses an asynchronous callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -767,15 +732,13 @@ DAHelper.update(
});
```
-### update
+## DataAbilityHelper.update
update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates): Promise\
-Updates data records in the database. This method uses a promise to return the result.
-
-**System capabilities**
+Updates data records in the database. This API uses a promise to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -786,9 +749,10 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.|
**Return value**
+
| Type | Description |
| ---------------- | -------------------------------------------- |
-| Promise\ | Promise used to return the number of updated data records.|
+| Promise\ | Promise used to return the number of updated data records. |
**Example**
@@ -814,15 +778,13 @@ DAHelper.update(
});
```
-### query
+## DataAbilityHelper.query
query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void
-Queries data in the database. This method uses a callback to return the result.
-
-**System capabilities**
+Queries data in the database. This API uses an asynchronous callback to return the result.
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -854,15 +816,13 @@ DAHelper.query(
-### query
+## DataAbilityHelper.query
query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates): Promise\
-Queries data in the database. This method uses a promise to return the result.
+Queries data in the database. This API uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -873,6 +833,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.|
**Return value**
+
| Type | Description |
| ------------------- | -------------- |
| Promise\ | Promise used to return the data queried.|
@@ -895,3 +856,77 @@ DAHelper.query(
console.info("==========================>queryCallback=======================>");
});
```
+
+## DataAbilityHelper.call
+
+call(uri: string, method: string, arg: string, extras: PacMap): Promise
+
+Calls the extended API of the Data ability. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | --------------------------------- | ---- | ------------------------------------------------ |
+| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx" |
+| method | string | Yes | Name of the API to call. |
+| arg | string | Yes |Parameter to pass. |
+| extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. |
+
+**Return value**
+
+| Type| Description|
+|------ | ------- |
+|Promise<[PacMap](#pacmap)> | Promise used to return the result.|
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility';
+
+let dataAbilityHelper = featureAbility.acquireDataAbilityHelper("dataability:///com.example.jsapidemo.UserDataAbility");
+dataAbilityHelper.call("dataability:///com.example.jsapidemo.UserDataAbility", "method", "arg", {"key1":"value1"}).then((data) => {
+ console.info('Operation succeeded: ' + data);
+}).catch((error) => {
+ console.error('Operation failed. Cause: ' + error);
+});
+```
+
+## DataAbilityHelper.call
+
+call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCallback): void
+
+Calls the extended API of the Data ability. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | --------------------------------- | ---- | ------------------------------------------------ |
+| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx" |
+| method | string | Yes | Name of the API to call. |
+| arg | string | Yes |Parameter to pass. |
+| extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. |
+| callback | AsyncCallback<[PacMap](#pacmap)> | Yes| Callback used to return the result. |
+
+**Example**
+
+```js
+import featureAbility from '@ohos.ability.featureAbility';
+
+let dataAbilityHelper = featureAbility.acquireDataAbilityHelper("dataability:///com.example.jsapidemo.UserDataAbility");
+dataAbilityHelper.call("dataability:///com.example.jsapidemo.UserDataAbility", "method", "arg", {"key1":"value1"}, (err, data) => {
+ if (err) {
+ console.error('Operation failed. Cause: ' + err);
+ return;
+ }
+ console.info('Operation succeeded: ' + data);
+});
+```
+## PacMap
+
+| Name| Type| Mandatory| Description|
+| ------ | ------ | ------ | ------ |
+| [key: string] | number \| string \| boolean \| Array\ \| null | Yes| Data stored in key-value pairs.|
diff --git a/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md b/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
new file mode 100644
index 0000000000000000000000000000000000000000..4478eceb76e79a4ff0873eee07a6cd0fc2a6cf17
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
@@ -0,0 +1,443 @@
+# Device Usage Statistics
+
+>  **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.
+
+
+## Modules to Import
+
+```
+import bundleState from '@ohos.bundleState'
+```
+
+## bundleState.isIdleState
+isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void
+Checks whether the application specified by **bundleName** is in the idle state. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes| Bundle name of an application.|
+| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns whether the application specified by **bundleName** is in the idle state if the value of **bundleName** is valid; returns **null** otherwise.|
+
+**Example**
+
+ ```
+ bundleState.isIdleState("com.ohos.camera", (err, res) => {
+ if(err.code === 0) {
+ console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
+ } else {
+ console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code);
+ }
+ });
+ ```
+
+## bundleState.isIdleState
+isIdleState(bundleName: string): Promise<boolean>
+Checks whether the application specified by **bundleName** is in the idle state. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes| Bundle name of an application.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<boolean> | Promise used to return the result. Returns whether the application specified by **bundleName** is in the idle state if the value of **bundleName** is valid; returns **null** otherwise.|
+
+**Example**
+
+ ```
+ bundleState.isIdleState("com.ohos.camera").then( res => {
+ console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res));
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code);
+ });
+ ```
+
+## bundleState.queryAppUsagePriorityGroup
+queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void
+Queries the priority group of the current invoker application. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<number> | Yes| Callback used to return the result.|
+
+**Example**
+
+ ```
+ bundleState.queryAppUsagePriorityGroup((err, res) => {
+ if(err.code === 0) {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
+ } else {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
+ }
+ });
+ ```
+
+## bundleState.queryAppUsagePriorityGroup
+queryAppUsagePriorityGroup(): Promise<number>
+Queries the priority group of the current invoker application. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<number> | Promise used to return the result.|
+
+**Example**
+
+ ```
+ bundleState.queryAppUsagePriorityGroup().then( res => {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
+ });
+ ```
+
+## bundleState.queryBundleStateInfos
+queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<BundleActiveInfoResponse>): void
+Queries the application usage duration statistics based on the specified start time and end time. This API uses an asynchronous callback to return the result.
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| begin | number | Yes| Start time.|
+| end | number | Yes| End time.|
+| callback | AsyncCallback<[BundleActiveInfoResponse](#bundleactiveinforesponse)> | Yes| Callback used to return the result.|
+
+**Example**
+
+ ```
+ bundleState.queryBundleStateInfos(0, 20000000000000, (err, res) => {
+ if(err.code == 0) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.');
+ let i = 1;
+ for(let key in res){
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos callback number : ' + i);
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key]));
+ i++;
+ }
+ } else {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
+ }
+ });
+ ```
+
+## bundleState.queryBundleStateInfos
+queryBundleStateInfos(begin: number, end: number): Promise<BundleActiveInfoResponse>
+Queries the application usage duration statistics based on the specified start time and end time. This API uses a promise to return the result.
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| begin | number | Yes| Start time.|
+| end | number | Yes| End time.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<[BundleActiveInfoResponse](#bundleactiveinforesponse)> | Promise used to return the result.|
+
+**Example**
+
+ ```
+ bundleState.queryBundleStateInfos(0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.');
+ let i = 1;
+ for(let key in res){
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos promise number : ' + i);
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key]));
+ i++;
+ }
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code);
+ });
+ ```
+
+## bundleState.queryBundleStateInfoByInterval
+queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback<Array<BundleStateInfo>>): void
+Queries the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually). This API uses an asynchronous callback to return the result.
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| byInterval | [IntervalType](#intervaltype) | Yes| Interval type.|
+| begin | number | Yes| Start time.|
+| end | number | Yes| End time.|
+| callback | AsyncCallback<Array<[BundleStateInfo](#bundlestateinfo)>> | Yes| Callback used to return the result.|
+
+**Example**
+
+ ```
+ bundleState.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => {
+ if(err.code == 0) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i]));
+ }
+ } else {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
+ }
+ });
+ ```
+
+## bundleState.queryBundleStateInfoByInterval
+queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise<Array<BundleStateInfo>>
+Queries the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually). This API uses a promise to return the result.
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| byInterval | [IntervalType](#intervaltype) | Yes| Interval type.|
+| begin | number | Yes| Start time.|
+| end | number | Yes| End time.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<Array<[BundleStateInfo](#bundlestateinfo)>> | Promise used to return the result.|
+
+**Example**
+
+ ```
+ bundleState.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise result ' + JSON.stringify(res[i]));
+ }
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code);
+ });
+ ```
+
+## bundleState.queryBundleActiveStates
+queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void
+Queries events of all applications based on the specified start time and end time. This API uses an asynchronous callback to return the result.
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| begin | number | Yes| Start time.|
+| end | number | Yes| End time.|
+| callback | AsyncCallback<Array<[BundleActiveState](#bundleactivestate)>> | Yes| Callback used to return the result.|
+
+**Example**
+
+ ```
+ bundleState.queryBundleActiveStates(0, 20000000000000, (err, res) => {
+ if(err.code == 0) {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i]));
+ }
+ } else {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
+ }
+ });
+ ```
+
+## bundleState.queryBundleActiveStates
+queryBundleActiveStates(begin: number, end: number): Promise<Array<BundleActiveState>>
+Queries events of all applications based on the specified start time and end time. This API uses a promise to return the result.
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| begin | number | Yes| Start time.|
+| end | number | Yes| End time.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<Array<[BundleActiveState](#bundleactivestate)>> | Promise used to return the result.|
+
+**Example**
+
+ ```
+ bundleState.queryBundleActiveStates(0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates promise number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates promise result ' + JSON.stringify(res[i]));
+ }
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code);
+ });
+ ```
+
+## bundleState.queryCurrentBundleActiveStates
+queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void
+Queries events of this application based on the specified start time and end time. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| begin | number | Yes| Start time.|
+| end | number | Yes| End time.|
+| callback | AsyncCallback<Array<[BundleActiveState](#bundleactivestate)>> | Yes| Callback used to return the result.|
+
+**Example**
+
+ ```
+ bundleState.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => {
+ if(err.code == 0) {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i]));
+ }
+ } else {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
+ }
+ });
+ ```
+
+## bundleState.queryCurrentBundleActiveStates
+queryCurrentBundleActiveStates(begin: number, end: number): Promise<Array<BundleActiveState>>
+Queries events of this application based on the specified start time and end time. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| begin | number | Yes| Start time.|
+| end | number | Yes| End time.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<Array<[BundleActiveState](#bundleactivestate)>> | Promise used to return the result.|
+
+**Example**
+
+ ```
+ bundleState.queryCurrentBundleActiveStates(0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.');
+ for (let i = 0; i < res.length; i++) {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise number : ' + (i + 1));
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise result ' + JSON.stringify(res[i]));
+ }
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code);
+ });
+ ```
+
+## BundleStateInfo
+Provides the usage duration information of an application.
+
+### Attributes
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes| Application bundle name.|
+| abilityPrevAccessTime | number | Yes| Last time when the application was used.|
+| abilityInFgTotalTime | number | Yes| Total time that the application runs in the foreground.|
+| id | number | No| User ID.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| abilityPrevSeenTime | number | No| Last time when the application was visible in the foreground.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| abilitySeenTotalTime | number | No| Total time when the application is visible in the foreground.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| fgAbilityAccessTotalTime | number | No| Total time that the application accesses the foreground.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| fgAbilityPrevAccessTime | number | No| Last time when the application accessed the foreground.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| infosBeginTime | number | No| Time logged in the first application usage record in the **BundleActiveInfo** object.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| infosBeginTime | number | No| Time logged in the last application usage record in the **BundleActiveInfo** object.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+
+### merge
+merge(toMerge: BundleStateInfo): void
+
+Merges the application usage information that has the same bundle name.
+This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| toMerge | [BundleStateInfo](#bundlestateinfo) | Yes| Application usage information to merge.|
+
+## BundleActiveState
+Provides information about an application event.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes| Application bundle name.|
+| stateType | number | Yes| Application event type.|
+| stateOccurredTime | number | Yes| Timestamp when the application event occurs.|
+| appUsagePriorityGroup | number | No| Usage priority group of the application.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| indexOfLink | string | No| Shortcut ID.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| nameOfClass | string | No| Class name.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+
+## BundleActiveInfoResponse
+Provides the usage duration information of applications.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| [key: string]: BundleStateInfo | [BundleStateInfo](#bundlestateinfo) | Yes| Usage duration information by application.|
+
+## IntervalType
+Enumerates the interval types for querying the application usage duration.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+|Name |Default Value |Description|
+| -------- | -------- | -------- |
+| BY_OPTIMIZED | 0 | The system obtains the application usage duration statistics in the specified time frame at the interval the system deems appropriate.|
+| BY_DAILY | 1 | The system obtains the application usage duration statistics in the specified time frame on a daily basis.|
+| BY_WEEKLY | 2 | The system obtains the application usage duration statistics in the specified time frame on a weekly basis.|
+| BY_MONTHLY | 3 | The system obtains the application usage duration statistics in the specified time frame on a monthly basis.|
+| BY_ANNUALLY | 4 | The system obtains the application usage duration statistics in the specified time frame on an annual basis.|
diff --git a/en/application-dev/reference/apis/js-apis-environment.md b/en/application-dev/reference/apis/js-apis-environment.md
index c0b761a179f18dd89805b4c0777c84d15328b87e..8eed7e797ab7d723903fc3e4b9d2b141067dfee6 100644
--- a/en/application-dev/reference/apis/js-apis-environment.md
+++ b/en/application-dev/reference/apis/js-apis-environment.md
@@ -1,7 +1,9 @@
# Environment
->  **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.
+>  **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
@@ -9,19 +11,17 @@
import environment from '@ohos.environment';
```
-## System Capabilities
-
-SystemCapability.FileManagement.File.Environment
-
## environment.getStorageDataDir
getStorageDataDir():Promise<string>
-Obtains the root directory of the storage. This method uses a promise to return the result.
+Obtains the root directory of the storage. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.FileManagement.File.Environment
- Return value
- | Type| Description|
+ | Type | Description |
| --------------------- | ---------------- |
| Promise<string> | Promise returned with the root directory of the storage.|
@@ -39,13 +39,15 @@ Obtains the root directory of the storage. This method uses a promise to return
getStorageDataDir(callback:AsyncCallback<string>):void
-Obtains the root directory of the storage. This method uses an asynchronous callback to return the result.
+Obtains the root directory of the storage. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.FileManagement.File.Environment
- Parameters
- | Name| Type| Mandatory| Description|
+ | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------- |
- | callback | AsyncCallback<string> | Yes| Asynchronous callback used to return the root directory of the storage.|
+ | callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the root directory of the storage.|
- Example
@@ -59,11 +61,13 @@ Obtains the root directory of the storage. This method uses an asynchronous call
getUserDataDir():Promise<string>
-Obtains the root directory of public files. This method uses a promise to return the result.
+Obtains the root directory of public files. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.FileManagement.File.Environment
- Return value
- | Type| Description|
+ | Type | Description |
| --------------------- | ------------------ |
| Promise<string> | Promise returned with the root directory of public files.|
@@ -81,13 +85,15 @@ Obtains the root directory of public files. This method uses a promise to return
getUserDataDir(callback:AsyncCallback<string>): void
-Obtains the root directory of public files. This method uses an asynchronous callback to return the result.
+Obtains the root directory of public files. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.FileManagement.File.Environment
- Parameters
- | Name| Type| Mandatory| Description|
+ | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------- |
- | callback | AsyncCallback<string> | Yes| Asynchronous callback used to return the root directory of public files.|
+ | callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the root directory of public files.|
- Example
diff --git a/en/application-dev/reference/apis/js-apis-eventhub.md b/en/application-dev/reference/apis/js-apis-eventhub.md
index 40f4b05797aa03b575743df830ef3ff9115bc50f..cee0f8f7bbfe663d548939e11193b18b1a55b6c2 100644
--- a/en/application-dev/reference/apis/js-apis-eventhub.md
+++ b/en/application-dev/reference/apis/js-apis-eventhub.md
@@ -10,11 +10,11 @@ Implements event subscription, unsubscription, and triggering.
## Usage
-Before using any methods in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
+Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
-```
+```js
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onForeground() {
@@ -24,25 +24,24 @@ export default class MainAbility extends Ability {
```
-## on
+## EventHub.on
on(event: string, callback: Function): void;
Subscribes to an event.
-**System capability**:
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | Yes| Callback invoked when the event is triggered.|
-- Example
+**Example**
- ```
+ ```js
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
@@ -63,25 +62,24 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## off
+## EventHub.off
off(event: string, callback?: Function): void;
-Unsubscribes from an event. If **callback** is specified, this method unsubscribes from the specified callback. If **callback** is not specified, this method unsubscribes from all callbacks in the event.
+Unsubscribes from an event. If **callback** is specified, this API unsubscribes from the specified callback. If **callback** is not specified, this API unsubscribes from all callbacks in the event.
-**System capability**:
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | No| Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed.|
-- Example
+**Example**
- ```
+ ```js
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
@@ -102,25 +100,24 @@ SystemCapability.Ability.AbilityRuntime.Core
```
-## emit
+## EventHub.emit
emit(event: string, ...args: Object[]): void;
Triggers an event.
-**System capability**:
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-SystemCapability.Ability.AbilityRuntime.Core
+**Parameters**
-- Parameters
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered.|
-- Example
+**Example**
- ```
+ ```js
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
diff --git a/en/application-dev/reference/apis/js-apis-extension-context.md b/en/application-dev/reference/apis/js-apis-extension-context.md
index 08f53266f7a09ada42632df73fb0f58e6966a070..5a9466444cd91cc39805c69028cd083fae8e4843 100644
--- a/en/application-dev/reference/apis/js-apis-extension-context.md
+++ b/en/application-dev/reference/apis/js-apis-extension-context.md
@@ -1,6 +1,6 @@
# ExtensionContext
->  **Note:**
+>  **NOTE**
> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -11,4 +11,4 @@ Implements the extension context. This module is inherited from **Context**.
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core|
+| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core |
diff --git a/en/application-dev/reference/apis/js-apis-featureAbility.md b/en/application-dev/reference/apis/js-apis-featureAbility.md
index b8097b7a49bff4ad39312a5b4f257e035d4e2649..9e4324677acf9b4643b8980c65f3a20796dc0930 100644
--- a/en/application-dev/reference/apis/js-apis-featureAbility.md
+++ b/en/application-dev/reference/apis/js-apis-featureAbility.md
@@ -1,5 +1,8 @@
# FeatureAbility Module (JavaScript)
+>  **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.
+
## Constraints
APIs of the **FeatureAbility** module can be called only by Page abilities.
@@ -16,9 +19,7 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\)
Starts an ability. This method uses a callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -57,9 +58,7 @@ startAbility(parameter: StartAbilityParameter): Promise\
Starts an ability. This method uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -91,15 +90,13 @@ featureAbility.startAbility(
});
```
-## featureAbility.acquireDataAbilityHelper
+## featureAbility.acquireDataAbilityHelper7+
acquireDataAbilityHelper(uri: string): DataAbilityHelper
Obtains a **dataAbilityHelper** object.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -122,15 +119,13 @@ featureAbility.acquireDataAbilityHelper(
)
```
-## featureAbility.startAbilityForResult
+## featureAbility.startAbilityForResult7+
startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\): void
Starts an ability. This method uses a callback to return the execution result when the ability is destroyed.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -161,15 +156,13 @@ featureAbility.startAbilityForResult(
)
```
-## featureAbility.startAbilityForResult
+## featureAbility.startAbilityForResult7+
startAbilityForResult(parameter: StartAbilityParameter): Promise\
Starts an ability. This method uses a promise to return the execution result when the ability is destroyed.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -178,6 +171,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
**Return value**
+
| Type | Description |
| ----------------------------------------- | -------------- |
| Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.|
@@ -218,15 +212,13 @@ featureAbility.startAbilityForResult(
});
```
-## featureAbility.terminateSelfWithResult
+## featureAbility.terminateSelfWithResult7+
terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\): void
Destroys this Page ability, with the result code and data sent to the caller. This method uses a callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -268,15 +260,13 @@ featureAbility.terminateSelfWithResult(
);
```
-## featureAbility.terminateSelfWithResult
+## featureAbility.terminateSelfWithResult7+
terminateSelfWithResult(parameter: AbilityResult): Promise\
Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -285,6 +275,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.|
**Return value**
+
| Type | Description |
| -------------- | ----------------------- |
| Promise\ | Promise used to return the result.|
@@ -326,15 +317,13 @@ featureAbility.terminateSelfWithResult(
-## featureAbility.hasWindowFocus
+## featureAbility.hasWindowFocus7+
hasWindowFocus(callback: AsyncCallback\): void
Checks whether the main window of this ability has the focus. This method uses a callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -351,15 +340,13 @@ featureAbility.hasWindowFocus()
-## featureAbility.hasWindowFocus
+## featureAbility.hasWindowFocus7+
hasWindowFocus(): Promise\
Checks whether the main window of this ability has the focus. This method uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Return value**
@@ -384,9 +371,7 @@ getWant(callback: AsyncCallback\): void
Obtains the **Want** object sent from this ability. This method uses a callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -409,11 +394,10 @@ getWant(): Promise\
Obtains the **Want** object sent from this ability. This method uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Return value**
+
| Type | Description |
| ----------------------- | ------------------------- |
| Promise\<[Want](#want)> | Promise used to return the result.|
@@ -433,11 +417,10 @@ getContext(): Context
Obtains the application context.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Return value**
+
| Type | Description |
| ------- | -------------------- |
| Context | Application context returned.|
@@ -452,15 +435,13 @@ context.getBundleName()
-## featureAbility.terminateSelf
+## featureAbility.terminateSelf7+
terminateSelf(callback: AsyncCallback\): void
Destroys this Page ability, with the result code and data sent to the caller. This method uses a callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -477,17 +458,16 @@ featureAbility.terminateSelf()
-## featureAbility.terminateSelf
+## featureAbility.terminateSelf7+
terminateSelf(): Promise\
Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Return value**
+
| Type | Description |
| -------------- | ------------------------- |
| Promise\ | Promise used to return the result.|
@@ -500,15 +480,13 @@ featureAbility.terminateSelf().then((data) => { console.info("=============
});
```
-## featureAbility.connectAbility
+## featureAbility.connectAbility7+
connectAbility(request: Want, options:ConnectOptions): number
Connects this ability to a specific Service ability. This method uses a callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -519,21 +497,26 @@ SystemCapability.Ability.AbilityRuntime.FAModel
Want
+**System capability**: SystemCapability.Ability.AbilityBase
+
| 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.
System capabilities: SystemCapability.Ability.AbilityBase|
-| bundleName | Read-only | string | Yes | Bundle name of the Service ability to connect.
System capabilities: SystemCapability.Ability.AbilityBase |
-| abilityName | Read-only | string | Yes | Class name of the Service ability to connect.
System capabilities: SystemCapability.Ability.AbilityBase |
+| 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. |
+| abilityName | Read-only | string | Yes | Class name of the Service ability to connect. |
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.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core |
-| onDisconnect | Read-only | function | Yes | Callback invoked when the connection fails.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core |
-| onFailed | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core|
+| 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.|
**Return value**
+
| Type | Description |
| ------ | ------------------------ |
| number | Returns the ID of the Service ability connected.|
@@ -566,15 +549,13 @@ var connId = featureAbility.connectAbility(
);
```
-## featureAbility.disconnectAbility
+## featureAbility.disconnectAbility7+
disconnectAbility(connection: number, callback:AsyncCallback\): void
Disconnects this ability from a specific Service ability. This method uses a callback to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -615,15 +596,13 @@ var result = featureAbility.disconnectAbility(connId,
);
```
-## featureAbility.disconnectAbility
+## featureAbility.disconnectAbility7+
disconnectAbility(connection: number): Promise\
Disconnects this ability from a specific Service ability. This method uses a promise to return the result.
-**System capabilities**
-
-SystemCapability.Ability.AbilityRuntime.FAModel
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -632,6 +611,7 @@ SystemCapability.Ability.AbilityRuntime.FAModel
| connection | number | Yes | ID of the Service ability to disconnect.|
**Return value**
+
| Type | Description |
| -------------- | ----------------------- |
| Promise\ | Promise used to return the result.|
@@ -661,54 +641,176 @@ var connId = featureAbility.connectAbility(
onFailed: onFailedCallback,
},
);
-var result = await featureAbility.disconnectAbility(connId);
+
+featureAbility.disconnectAbility(connId).then((error,data)=>{
+ console.log('featureAbilityTest result errCode : ' + error.code + " data: " + data);
+});
```
+
+## featureAbility.getWindow7+
+
+getWindow(callback: AsyncCallback\): void
+
+Obtains the window corresponding to this ability. This method uses a callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
+| callback | AsyncCallback\ | Yes | Callback used to return the window.|
+
+**Example**
+
+```javascript
+GetWindow(){
+ featureAbility.getWindow()
+ }
+```
+
+## featureAbility.getWindow7+
+
+getWindow(): Promise\;
+
+Obtains the window corresponding to this ability. This method uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
+
+**Return value**
+
+| Type | Description |
+| ----------------- | ---------------------------------------------------------- |
+| Promise\ | Promise used to return the window.|
+
+**Example**
+
+```javascript
+GetWindowPromise(){
+ featureAbility.getWindow().then((data) => {
+ console.info("=============getWindowPromise========== " + JSON.stringify(data));
+ });
+ }
+```
+
+
+## AbilityWindowConfiguration
+
+The value is obtained through the **featureAbility.AbilityWindowConfiguration** API.
+
+**Example**
+
+```
+featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED
+```
+
+| Name | Name| Description |
+| --------------------------- | ---- | ---------- |
+| WINDOW_MODE_UNDEFINED7+ | 0 | The Page ability is in an undefined window display mode.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel |
+| WINDOW_MODE_FULLSCREEN7+ | 1 | The Page ability is in full screen mode.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel |
+| WINDOW_MODE_SPLIT_PRIMARY7+ | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+| WINDOW_MODE_SPLIT_SECONDARY7+ | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+| WINDOW_MODE_FLOATING7+ | 102 | The Page ability is displayed in floating window mode.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel |
+
+
+## AbilityStartSetting
+
+The **AbilityStartSetting** attribute is an object defined as [key: string]: any. The key is a type of **AbilityStartSetting**, and the value is a type of **AbilityWindowConfiguration**.
+
+The value is obtained through the **featureAbility.AbilityStartSetting** API.
+
+**Example**
+
+```
+featureAbility.AbilityStartSetting.BOUNDS_KEY
+```
+
+| Name | Name | Description |
+| --------------- | --------------- | -------------------------- |
+| BOUNDS_KEY7+ | "abilityBounds" | Ability window size.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel |
+| WINDOW_MODE_KEY7+ | "windowMode" | Ability window display mode.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel |
+| DISPLAY_ID_KEY7+ | "displayId" | Display device ID.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+
+## ErrorCode
+
+Enumerates error codes.
+
+| Variable | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| NO_ERROR7+ | 0 | No error occurs.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+| INVALID_PARAMETER7+ | -1 | Invalid parameter.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+| ABILITY_NOT_FOUND7+ | -2 | The ability is not found.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+| PERMISSION_DENY7+ | -3 | The request is denied.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+
+
+## DataAbilityOperationType
+
+Enumerates operation types of the Data ability.
+
+| Variable | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| TYPE_INSERT7+ | 1 | Insert operation.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+| TYPE_UPDATE7+ | 2 | Update operation.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+| TYPE_DELETE7+ | 3 | Deletion operation.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+| TYPE_ASSERT7+ | 4 | Assert operation.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
+
+
+
## AbilityResult
+**System capability**: SystemCapability.Ability.AbilityBase
+
| Name | Readable/Writable| Type | Mandatory| Description |
| ---------- | -------- | --------------------- | ---- | ------------------------------------------------------------ |
-| resultCode | Read-only | number | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.
System capabilities: SystemCapability.Ability.AbilityBase|
-| want | 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**.
System capabilities: SystemCapability.Ability.AbilityBase |
+| resultCode7+ | Read-only | number | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.|
+| want7+ | 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**. |
## StartAbilityParameter
+**System capability**: SystemCapability.AbilityRuntime.FAModel
+
| Name | Readable/Writable| Type | Mandatory| Description |
| ------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
-| want | Read-only | [Want](#want) | Yes | Information about the ability to start.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel |
-| abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel|
+| 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.|
+
## Want
+**System capability**: SystemCapability.Ability.AbilityBase
+
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
-| deviceId | Read-only | string | No | ID of the device that runs the ability.
System capabilities: SystemCapability.Ability.AbilityBase |
-| 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.
System capabilities: SystemCapability.Ability.AbilityBase|
-| 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.
System capabilities: SystemCapability.Ability.AbilityBase|
-| 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**.
System capabilities: SystemCapability.Ability.AbilityBase|
-| type | Read-only | string | No | MIME type, for example, text/plain or image/*.
System capabilities: SystemCapability.Ability.AbilityBase |
-| flags | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).
System capabilities: SystemCapability.Ability.AbilityBase|
-| action | Read-only | string | No | Action option.
System capabilities: SystemCapability.Ability.AbilityBase |
-| parameters | Read-only | {[key: string]: any} | No | List of parameters in a **Want** object.
System capabilities: SystemCapability.Ability.AbilityBase |
-| entities | Read-only | Array\ | No | List of entities.
System capabilities: SystemCapability.Ability.AbilityBase |
+| deviceId8+ | Read-only | string | No | ID of the device that runs the ability. |
+| bundleName8+ | 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.|
+| abilityName8+ | 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.|
+| uri8+ | 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**.|
+| type8+ | Read-only | string | No | MIME type, for example, text/plain or image/*. |
+| flags8+ | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).|
+| action8+ | Read-only | string | No | Action option. |
+| parameters8+ | Read-only | {[key: string]: any} | No | List of parameters in a **Want** object. |
+| entities8+ | Read-only | Array\ | No | List of entities. |
## flags
+**System capability**: SystemCapability.Ability.AbilityBase
+
| Name | Name | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ |
-| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.
System capabilities: SystemCapability.Ability.AbilityBase |
-| 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**.
System capabilities: SystemCapability.Ability.AbilityBase|
-| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.
System capabilities: SystemCapability.Ability.AbilityBase |
-| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.
System capabilities: SystemCapability.Ability.AbilityBase|
+| 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_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
+| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device. |
+| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
+| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability. |
+| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. |
+| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. |
+| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
+| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
+| 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_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_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.|
diff --git a/en/application-dev/reference/apis/js-apis-fileio.md b/en/application-dev/reference/apis/js-apis-fileio.md
index 9b88c6a1bb9e4eeae87f45ca47c5bec6cc290842..67e1d8d19ef2eb70aa14c8a9a18e5281367b974f 100644
--- a/en/application-dev/reference/apis/js-apis-fileio.md
+++ b/en/application-dev/reference/apis/js-apis-fileio.md
@@ -1,6 +1,6 @@
# File Management
->  **Note:**
+>  **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.
## Modules to Import
@@ -15,7 +15,7 @@ import fileio from '@ohos.fileio';
None
-## Note
+## Guidelines
Before using this module to perform operations on a file or directory, obtain the absolute path of the file or directory. For details, see [getOrCreateLocalDir of the Context module](js-apis-Context.md).
@@ -42,6 +42,8 @@ stat(path: string): Promise<Stat>
Asynchronously obtains file information. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -68,6 +70,8 @@ stat(path:string, callback:AsyncCallback<Stat>): void
Asynchronously obtains file information. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -88,6 +92,8 @@ statSync(path:string): Stat
Synchronously obtains file information.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -112,6 +118,8 @@ opendir(path: string): Promise<Dir>
Asynchronously opens a directory. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -138,6 +146,8 @@ opendir(path: string, callback: AsyncCallback<Dir>): void
Asynchronously opens a directory. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -148,7 +158,7 @@ Asynchronously opens a directory. This method uses a callback to return the resu
```js
fileio.opendir(path, function (err, dir) {
// Example code in Dir struct
- // Use read/readSync/close
+ // Use read/readSync/close.
});
```
@@ -159,6 +169,8 @@ opendirSync(path: string): Dir
Synchronously opens a directory.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
@@ -184,11 +196,13 @@ access(path: string, mode?: number): Promise<void>
Asynchronously checks whether the current process can access a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | mode | number | No| Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.|
+ | mode | number | No| Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.|
- Return value
| Type| Description|
@@ -207,15 +221,17 @@ Asynchronously checks whether the current process can access a file. This method
## fileio.access
-access(path: String, mode?: number, callback: AsyncCallback<void>): void
+access(path: string, mode: number, callback: AsyncCallback<void>): void
Asynchronously checks whether the current process can access a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | mode | number | No| Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.|
+ | mode | number | No| Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.|
| callback | AsyncCallback<void> | Yes| Callback invoked when the file is asynchronously checked.|
- Example
@@ -232,12 +248,13 @@ accessSync(path: string, mode?: number): void
Synchronously checks whether the current process can access the specified file.
+**System capability**: SystemCapability.FileManagement.File.FileIO
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | mode | number | No| Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.|
+ | mode | number | No| Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.|
- Example
```js
@@ -255,6 +272,8 @@ close(fd: number):Promise<void>
Asynchronously closes a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -282,6 +301,8 @@ close(fd: number, callback:AsyncCallback<void>): void
Asynchronously closes a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -303,6 +324,8 @@ closeSync(fd: number): void
Synchronously closes a file.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -320,6 +343,8 @@ close(): Promise<void>
Asynchronously closes the stream. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Return value
| Type| Description|
| -------- | -------- |
@@ -341,6 +366,8 @@ close(callback: AsyncCallback<void>): void
Asynchronously closes the stream. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -360,12 +387,14 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise<voi
Asynchronously copies a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | string \| number | Yes| Path or file descriptor of the file to copy.|
| dest | string \| number | Yes| Path or file descriptor of the new file.|
- | mode | number | No| Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
+ | mode | number | No| Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
- Return value
| Type| Description|
@@ -384,16 +413,18 @@ Asynchronously copies a file. This method uses a promise to return the result.
## fileio.copyFile
-copyFile(src:string | number, dest:string | number, mode?: number, callback: AsyncCallbak<void>): void
+copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback<void>): void
Asynchronously copies a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | string \| number | Yes| Path or file descriptor of the file to copy.|
| dest | string \| number | Yes| Path or file descriptor of the new file.|
- | mode | number | No| Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
+ | mode | number | No| Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
| callback | AsyncCallback<void> | Yes| Callback invoked when the file is copied asynchronously.|
- Example
@@ -406,16 +437,18 @@ Asynchronously copies a file. This method uses a callback to return the result.
## fileio.copyFileSync
-fileio.copyFileSync(src:string | number, dest:string | number, mode?:number): void
+copyFileSync(src: string | number, dest: string | number, mode?: number): void
Synchronously copies a file.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| src | string \| number | Yes| Path or file descriptor of the file to copy.|
| dest | string \| number | Yes| Path or file descriptor of the new file.|
- | mode | number | No| Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
+ | mode | number | No| Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
- Example
```js
@@ -429,12 +462,13 @@ mkdir(path:string, mode?: number): Promise<void>
Asynchronously creates a directory. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the directory to create.|
- | mode | number | No| Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | mode | number | No| Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
- Return value
| Type| Description|
@@ -453,15 +487,17 @@ Asynchronously creates a directory. This method uses a promise to return the res
## fileio.mkdir
-mkdir(path:string, mode?:number, callback:AsyncCallbak<void>): void
+mkdir(path: string, mode: number, callback: AsyncCallback<void>): void
Asynchronously creates a directory. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the directory to create.|
- | mode | number | No| Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | mode | number | No| Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
| callback | AsyncCallback<void> | Yes| Callback invoked when the directory is created asynchronously.|
- Example
@@ -476,15 +512,17 @@ Asynchronously creates a directory. This method uses a callback to return the re
## fileio.mkdirSync
-fileio.mkdirSync(path: string, mode?: number): void
+mkdirSync(path: string, mode?: number): void
Synchronously creates a directory.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the directory to create.|
- | mode | number | No| Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | mode | number | No| Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
- Example
```js
@@ -498,17 +536,19 @@ open(path: string, flags?: number, mode?: number): Promise<number>
Asynchronously opens a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | flags | number | No| Option for opening a file. You must specify one of the following options. By default, the file is opened in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
You can also specify the following options, separated using a bitwise OR operator (|). By default, no extra option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.
- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.|
- | mode | number | No| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | flags | number | No| Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.
- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.|
+ | mode | number | No| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
- Return value
| Type| Description|
| -------- | -------- |
- | Promise<number> | Promise used to return the file descriptor of the file opened.|
+ | Promise<number> | File descriptor of the file opened.|
- Example
```js
@@ -526,12 +566,14 @@ open(path: string, flags: number, mode: number, callback: AsyncCallback<numbe
Asynchronously opens a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | flags | number | Yes| Option for opening a file. You must specify one of the following options. By default, the file is opened in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
You can also specify the following options, separated using a bitwise OR operator (|). By default, no extra option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.
- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.|
- | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | flags | number | Yes| Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.
- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.|
+ | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
| callback | AsyncCallback <void> | Yes| Callback invoked when the file is open asynchronously.|
- Example
@@ -548,12 +590,14 @@ openSync(path:string, flags?:number, mode?:number): number
Synchronously opens a file.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | flags | number | No| Option for opening a file. You must specify one of the following options. By default, the file is opened in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
You can also specify the following options, separated using a bitwise OR operator (|). By default, no extra option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.
- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.|
- | mode | number | No| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.
The file permissions of newly created files are affected by **umask**, which is set as the process starts. Currently, the modification of **umask** is not open.
+ | flags | number | No| Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.
- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.|
+ | mode | number | No| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.
The file permissions on newly created files are affected by umask, which is set as the process starts. Currently, the modification of umask is not open.|
- Return value
| Type| Description|
@@ -568,21 +612,27 @@ Synchronously opens a file.
## fileio.read
-read(fd: number, buffer: ArrayBuffer, options?: Object): Promise<Readout>
+read(fd: number, buffer: ArrayBuffer, options?: {
+ offset?: number;
+ length?: number;
+ position?: number;
+}): Promise<ReadOut>
Asynchronously reads data from a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the file to read.|
| buffer | ArrayBuffer | Yes| Buffer used to store the file data read.|
- | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to be read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to be read in the file. By default, data is read from the current position.|
+ | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.|
- Return value
| Type| Description|
| -------- | -------- |
- | Promise<[Readout](#readout)> | Promise used to return the data read.|
+ | Promise<[ReadOut](#readout)> | Data read.|
- Example
```js
@@ -598,17 +648,23 @@ Asynchronously reads data from a file. This method uses a promise to return the
## fileio.read
-read(fd: number, buffer: ArrayBuffer, options?: Object, callback: AsyncCallback<Readout>): void
+read(fd: number, buffer: ArrayBuffer, options: {
+ offset?: number;
+ length?: number;
+ position?: number;
+}, callback: AsyncCallback<ReadOut>): void
Asynchronously reads data from a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the file to read.|
| buffer | ArrayBuffer | Yes| Buffer used to store the file data read.|
- | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to be read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to be read in the file. By default, data is read from the current position.|
- | callback | AsyncCallback<[Readout](#readout)> | Yes| Callback invoked when the data is read asynchronously.|
+ | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.|
+ | callback | AsyncCallback<[ReadOut](#readout)> | Yes| Callback invoked when the data is read asynchronously.|
- Example
```js
@@ -624,16 +680,22 @@ Asynchronously reads data from a file. This method uses a callback to return the
## fileio.readSync
-readSync(fd: number, buffer: ArrayBuffer, options?: Object): number
+readSync(fd: number, buffer: ArrayBuffer, options?: {
+ offset?: number;
+ length?: number;
+ position?: number;
+}): number
Synchronously reads data from a file.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the file to read.|
| buffer | ArrayBuffer | Yes| Buffer used to store the file data read.|
- | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to be read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to be read in the file. By default, data is read from the current position.|
+ | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.|
- Return value
| Type| Description|
@@ -654,6 +716,8 @@ rmdir(path: string): Promise<void>
Asynchronously deletes a directory. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -680,6 +744,8 @@ rmdir(path: string, callback:AsyncCallback<void>): void
Asynchronously deletes a directory. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -694,12 +760,14 @@ Asynchronously deletes a directory. This method uses a callback to return the re
```
-## fileio.rmdirSync
+## fileio.rmdirSync7+
-rmdirSync(path:string)
+rmdirSync(path: string): void
Synchronously deletes a directory.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -717,6 +785,8 @@ unlink(path:string): Promise<void>
Asynchronously deletes a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -743,6 +813,8 @@ unlink(path:string, callback:AsyncCallback<void>): void
Asynchronously deletes a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -765,6 +837,8 @@ unlinkSync(path: string): void
Synchronously deletes a file.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -778,21 +852,28 @@ Synchronously deletes a file.
## fileio.write
-write(fd: number, buffer: ArrayBuffer | string, options?: Object): Promise<number>
+write(fd: number, buffer: ArrayBuffer | string, options?: {
+ offset?: number;
+ length?: number;
+ position?: number;
+ encoding?: string;
+}): Promise<number>
Asynchronously writes data into a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the file to write.|
| buffer | ArrayBuffer \| string | Yes| Data to write. It can be a string or data from a buffer.|
- | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
+ | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
- Return value
| Type| Description|
| -------- | -------- |
- | Promise<number> | Promise used to return the length of the data written in the file.|
+ | Promise<number> | Length of the data written in the file.|
- Example
```js
@@ -807,16 +888,23 @@ Asynchronously writes data into a file. This method uses a promise to return the
## fileio.write
-write(fd:number, buffer:ArrayBuffer | string,options?:Object, callback:AsyncCallback<number>): void
+write(fd: number, buffer: ArrayBuffer | string, options: {
+ offset?: number;
+ length?: number;
+ position?: number;
+ encoding?: string;
+}, callback: AsyncCallback<number>): void
Asynchronously writes data into a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the file to write.|
| buffer | ArrayBuffer \| string | Yes| Data to write. It can be a string or data from a buffer.|
- | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
+ | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
| callback | AsyncCallback<number> | Yes| Callback invoked when the data is written asynchronously.|
- Example
@@ -832,16 +920,23 @@ Asynchronously writes data into a file. This method uses a callback to return th
## fileio.writeSync
-writeSync(fd: number, buffer: ArrayBuffer | string, options?:Object): number
+writeSync(fd: number, buffer: ArrayBuffer | string, options?: {
+ offset?: number;
+ length?: number;
+ position?: number;
+ encoding?: string;
+}): number
Synchronously writes data into a file.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the file to write.|
| buffer | ArrayBuffer \| string | Yes| Data to write. It can be a string or data from a buffer.|
- | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
+ | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
- Return value
| Type| Description|
@@ -861,6 +956,8 @@ hash(path: string, algorithm: string): Promise<string>
Asynchronously calculates the hash value of a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -884,10 +981,12 @@ Asynchronously calculates the hash value of a file. This method uses a promise t
## fileio.hash
-hash(psth:string, algorithm:string, callback:AsyncCallback<string>): void
+hash(path: string, algorithm: string, callback: AsyncCallback<string>): void
Asynchronously calculates the hash value of a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -911,11 +1010,13 @@ chmod(path: string, mode: number):Promise<void>
Asynchronously changes the file permissions based on its path. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
- Return value
| Type| Description|
@@ -938,11 +1039,13 @@ chmod(path: string, mode: number, callback: AsyncCallback<void>): void
Asynchronously changes the file permissions based on its path. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
| callback | AsyncCallback<void> | Yes| Callback invoked when the file permissions are changed asynchronously.|
- Example
@@ -959,11 +1062,13 @@ chmodSync(path: string, mode: number): void
Synchronously changes the file permissions based on its path.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
- Example
```js
@@ -977,6 +1082,8 @@ fstat(fd: number): Promise<Stat>
Asynchronously obtains file status information based on the file descriptor. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -985,7 +1092,7 @@ Asynchronously obtains file status information based on the file descriptor. Thi
- Return value
| Type| Description|
| -------- | -------- |
- | Promise<[Stat](#stat)> | Promise used to return the file status information.|
+ | Promise<[Stat](#stat)> | Promise used to return the file status information obtained.|
- Example
```js
@@ -1003,6 +1110,8 @@ fstat(fd: number, callback: AsyncCallback<Stat>): void
Asynchronously obtains file status information based on the file descriptor. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1024,6 +1133,8 @@ fstatSync(fd: number): Stat
Synchronously obtains file status information based on the file descriptor.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1043,10 +1154,12 @@ Synchronously obtains file status information based on the file descriptor.
## fileio.ftruncate7+
-ftruncate(fd: number, len: number): Promise<void>
+ftruncate(fd: number, len?: number): Promise<void>
Asynchronously truncates a file based on the file descriptor. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1062,7 +1175,7 @@ Asynchronously truncates a file based on the file descriptor. This method uses a
```js
let fd = fileio.openSync(path);
fileio.ftruncate(fd, 5).then(function(err) {
- console.info("File truncated successfully");
+ console.info("File truncated successfully.");
}).catch(function(err){
console.info("Failed to truncate the file. Error:"+ err);
});
@@ -1075,6 +1188,8 @@ ftruncate(fd: number, len: number, callback:AsyncCallback<void>): void
Asynchronously truncates a file based on the file descriptor. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1096,6 +1211,8 @@ ftruncateSync(fd: number, len?: number): void
Synchronously truncates a file based on the file descriptor.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1110,10 +1227,12 @@ Synchronously truncates a file based on the file descriptor.
## fileio.truncate7+
-truncate(path: string, len: number): Promise<void>
+truncate(path: string, len?: number): Promise<void>
Asynchronously truncates a file based on its path. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1128,7 +1247,7 @@ Asynchronously truncates a file based on its path. This method uses a promise to
- Example
```js
fileio.truncate(path, len).then(function(){
- console.info("File truncated successfully");
+ console.info("File truncated successfully.");
}).catch(function(err){
console.info("Failed to truncate the file. Error:"+ err);
});
@@ -1141,6 +1260,8 @@ truncate(path: string, len: number, callback:AsyncCallback<void>): void
Asynchronously truncates a file based on its path. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1158,10 +1279,12 @@ Asynchronously truncates a file based on its path. This method uses a callback t
## fileio.truncateSync7+
-truncateSync(fpath: string, len?: number): void
+truncateSync(path: string, len?: number): void
Synchronously truncates a file based on the file path.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1176,15 +1299,21 @@ Synchronously truncates a file based on the file path.
## fileio.readText7+
-readText(filePath: string, options?:Object): Promise<string>
+readText(filePath: string, options?: {
+ position?: number;
+ length?: number;
+ encoding?: string;
+}): Promise<string>
Asynchronously reads the text of a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| filePath | string | Yes| Absolute path of the file to read.|
- | options | Object | No| The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to be read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.|
+ | options | Object | No| The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.|
- Return value
| Type| Description|
@@ -1203,15 +1332,21 @@ Asynchronously reads the text of a file. This method uses a promise to return th
## fileio.readText7+
-readText(filePath: string, options?:Object, callback:AsyncCallback<string>): void
+readText(filePath: string, options: {
+ position?: number;
+ length?: number;
+ encoding?: string;
+}, callback: AsyncCallback<string>): void
Asynchronously reads the text of a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| filePath | string | Yes| Absolute path of the file to read.|
- | options | Object | No| The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to be read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.|
+ | options | Object | No| The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.|
| callback | AsyncCallback<string> | Yes| Callback invoked when the file is read asynchronously.|
- Example
@@ -1224,20 +1359,26 @@ Asynchronously reads the text of a file. This method uses a callback to return t
## fileio.readTextSync7+
-readTextSync(filePath: string, options?:Object): string
+readTextSync(filePath: string, options?: {
+ position?: number;
+ length?: number;
+ encoding?: string;
+}): string
Synchronously reads the text of a file.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| filePath | string | Yes| Absolute path of the file to read.|
- | options | Object | No| The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to be read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.|
+ | options | Object | No| The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.|
- Return value
| Type| Description|
| -------- | -------- |
- | string| Content of the file read.|
+ | <string>| Content of the file read.|
- Example
```js
@@ -1251,6 +1392,8 @@ lstat(path: string): Promise<Stat>
Asynchronously obtains link status information. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1259,7 +1402,7 @@ Asynchronously obtains link status information. This method uses a promise to re
- Return value
| Type| Description|
| -------- | -------- |
- | Promise<[Stat](#stat)> | Promise used to return the link status.|
+ | Promise<[Stat](#stat)> | Promise used to return the link status obtained.|
- Example
```js
@@ -1277,6 +1420,8 @@ lstat(path:string, callback:AsyncCallback<Stat>): void
Asynchronously obtains link status information. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1287,7 +1432,7 @@ Asynchronously obtains link status information. This method uses a callback to r
```js
fileio.lstat(path, function (err, stat) {
// Do something.
- ));
+ });
```
@@ -1297,6 +1442,8 @@ lstatSync(path:string): Stat
Synchronously obtains link status information.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1305,7 +1452,7 @@ Synchronously obtains link status information.
- Return value
| Type| Description|
| -------- | -------- |
- | [Stat](#stat) | Link status information.|
+ | [Stat](#stat) | Link status obtained.|
- Example
```js
@@ -1315,20 +1462,26 @@ Synchronously obtains link status information.
## fileio.read7+
-read(buffer: ArrayBuffer, options?: Object): Promise<Readout>
+read(buffer: ArrayBuffer, options?: {
+ position?: number;
+ offset?: number;
+ length?: number;
+}): Promise<ReadOut>
Asynchronously reads data from a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| buffer | ArrayBuffer | Yes| Buffer used to store the file data read.|
- | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to be read. It is optional. The default value is the buffer length minus the offset.|
+ | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.|
- Return value
| Type| Description|
| -------- | -------- |
- | Promise<[Readout](#readout)> | Promise used to return the data read.|
+ | Promise<[ReadOut](#readout)> | Data read.|
- Example
```js
@@ -1342,16 +1495,22 @@ Asynchronously reads data from a file. This method uses a promise to return the
## fileio.read7+
-read(buffer: ArrayBuffer, options?: Object, callback: AsyncCallback<Readout>): void
+read(buffer: ArrayBuffer, options: {
+ position?: number;
+ offset?: number;
+ length?: number;
+}, callback: AsyncCallback<ReadOut>): void
Asynchronously reads data from a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| buffer | ArrayBuffer | Yes| Buffer used to store the file data read.|
- | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to be read. It is optional. The default value is the buffer length minus the offset.|
- | callback | AsyncCallback<[Readout](#readout)> | Yes| Callback invoked when the data is read asynchronously from the file.|
+ | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.|
+ | callback | AsyncCallback<[ReadOut](#readout)> | Yes| Callback invoked when the data is read asynchronously from the file.|
- Example
```js
@@ -1370,6 +1529,8 @@ rename(oldPath: string, newPath: string): Promise<void>
Asynchronously renames a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1397,6 +1558,8 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): v
Asynchronously renames a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1417,6 +1580,8 @@ renameSync(oldPath: string, newPath: string): void
Synchronously renames a file.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1435,6 +1600,8 @@ fsync(fd: number): Promise<void>
Asynchronously synchronizes a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1461,6 +1628,8 @@ fsync(fd: number, callback: AsyncCallback<void>): void
Asynchronously synchronizes a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1479,7 +1648,9 @@ Asynchronously synchronizes a file. This method uses a callback to return the re
fsyncSync(fd: number): void
-Synchronizes a file in synchronous mode.
+Synchronizes a file in synchronous mode.
+
+**System capability**: SystemCapability.FileManagement.File.FileIO
- Parameters
| Name| Type| Mandatory| Description|
@@ -1498,6 +1669,8 @@ fdatasync(fd: number): Promise<void>
Asynchronously synchronizes data in a file. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1524,6 +1697,8 @@ fdatasync(fd: number, callback:AsyncCallback<void>): void
Asynchronously synchronizes data in a file. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1544,6 +1719,8 @@ fdatasyncSync(fd: number): void
Synchronizes data in a file in synchronous mode.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1561,6 +1738,8 @@ symlink(target: string, srcPath: string): Promise<void>
Asynchronously creates a symbolic link based on a path. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1588,6 +1767,8 @@ symlink(target: string, srcPath: string, callback: AsyncCallback<void>): v
Asynchronously creates a symbolic link based on a path. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1609,6 +1790,8 @@ symlinkSync(target: string, srcPath: string): void
Synchronously creates a symbolic link based on a specified path.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1627,6 +1810,8 @@ chown(path: string, uid: number, gid: number): Promise<void>
Asynchronously changes the file owner based on its path. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1642,7 +1827,7 @@ Asynchronously changes the file owner based on its path. This method uses a prom
- Example
```js
let stat = fileio.statSync(path);
- fileio.chown(path, stat.uid, stat.gid)).then(function(){
+ fileio.chown(path, stat.uid, stat.gid).then(function(){
console.info("chown successfully");
}).catch(function(err){
console.info("chown failed with error:"+ err);
@@ -1656,6 +1841,8 @@ chown(path: string, uid: number, gid: number, callback: AsyncCallback<void>
Asynchronously changes the file owner based on its path. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1679,6 +1866,8 @@ chownSync(path: string, uid: number, gid: number): void
Synchronously changes the file owner based on its path.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1699,6 +1888,8 @@ mkdtemp(prefix: string): Promise<string>
Asynchronously creates a temporary directory. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1707,7 +1898,7 @@ Asynchronously creates a temporary directory. This method uses a promise to retu
- Return value
| Name| Description|
| -------- | -------- |
- | Promise<string> | Promise used to return the unique path generated.|
+ | Promise<string> | Unique path generated.|
- Example
```js
@@ -1725,6 +1916,8 @@ mkdtemp(prefix: string, callback: AsyncCallback<string>): void
Asynchronously creates a temporary directory. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1745,6 +1938,8 @@ mkdtempSync(prefix: string): string
Synchronously creates a temporary directory.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -1767,11 +1962,13 @@ fchmod(fd: number, mode: number): Promise<void>
Asynchronously changes the file permissions based on the file descriptor. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the target file.|
- | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
- Return value
| Name| Description|
@@ -1794,11 +1991,13 @@ fchmod(fd: number, mode: number, callback: AsyncCallback<void>): void
Asynchronously changes the file permissions based on the file descriptor. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the target file.|
- | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
| callback | AsyncCallback <void> | Yes| Callback invoked when the file permissions are changed asynchronously.|
- Example
@@ -1811,15 +2010,17 @@ Asynchronously changes the file permissions based on the file descriptor. This m
## fileio.fchmodSync7+
-fchmodSync(existingPath: string, newPath: string): void
+fchmodSync(fd: number, mode: number): void
Synchronously changes the file permissions based on the file descriptor.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the target file.|
- | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
+ | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.|
- Example
```js
@@ -1833,11 +2034,13 @@ createStream(path: string, mode: string): Promise<Stream>
Asynchronously opens a stream based on the file path. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
+ | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
- Return value
| Type| Description|
@@ -1860,11 +2063,13 @@ createStream(path: string, mode: string, callback: AsyncCallback<Stream>):
Asynchronously opens a stream based on the file path. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
+ | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
| callback | AsyncCallback<[Stream](#stream7)> | Yes| Callback invoked when the stream is open asynchronously.|
- Example
@@ -1881,16 +2086,18 @@ createStreamSync(path: string, mode: string): Stream
Synchronously opens a stream based on the file path.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| path | string | Yes| Absolute path of the target file.|
- | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
+ | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
- Return value
| Name| Description|
| -------- | -------- |
- | [Stream](#stream7) | Stream obtained.|
+ | [Stream](#stream7) | Stream opened.|
- Example
```js
@@ -1904,11 +2111,13 @@ fdopenStream(fd: number, mode: string): Promise<Stream>
Asynchronously opens a stream based on the file descriptor. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the target file.|
- | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
+ | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
- Return value
| Name| Description|
@@ -1918,7 +2127,7 @@ Asynchronously opens a stream based on the file descriptor. This method uses a p
- Example
```js
fileio.fdopenStream(fd, mode).then(function(stream){
- console.info("openStream successfully"+);
+ console.info("openStream successfully");
}).catch(function(err){
console.info("openStream failed with error:"+ err);
});
@@ -1931,11 +2140,13 @@ fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): v
Asynchronously opens a stream based on the file descriptor. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the target file.|
- | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
+ | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
| callback | AsyncCallback <[Stream](#stream7)> | Yes| Callback invoked when the stream is open asynchronously.|
- Example
@@ -1952,16 +2163,18 @@ fdopenStreamSync(fd: number, mode: string): Stream
Synchronously opens a stream based on the file descriptor.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fd | number | Yes| File descriptor of the target file.|
- | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
+ | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
- Return value
| Name| Description|
| -------- | -------- |
- | [Stream](#stream7) | Stream operation result.|
+ | [Stream](#stream7) | Stream opened.|
- Example
```js
@@ -1975,6 +2188,8 @@ fchown(fd: number, uid: number, gid: number): Promise<void>
Asynchronously changes the file owner based on the file descriptor. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -2004,6 +2219,8 @@ fchown(fd: number, uid: number, gid: number, callback: AsyncCallback<void>
Asynchronously changes the file owner based on the file descriptor. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -2027,6 +2244,8 @@ fchownSync(fd: number, uid: number, gid: number): void
Synchronously changes the file owner based on the file descriptor.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -2047,6 +2266,8 @@ lchown(path: string, uid: number, gid: number): Promise<void>
Asynchronously changes the file owner based on the file path, changes the owner of the symbolic link (not the referenced file), and returns the result in a promise.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -2076,6 +2297,8 @@ lchown(path: string, uid: number, gid: number, callback: AsyncCallback<void&g
Asynchronously changes the file owner based on the file path, changes the owner of the symbolic link (not the referenced file), and returns the result in a callback.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -2099,6 +2322,8 @@ lchownSync(path: string, uid: number, gid: number): void
Synchronously changes the file owner based on the file path and changes the owner of the symbolic link (not the referenced file).
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -2119,11 +2344,13 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe
Asynchronously listens for the changes of a file or directory. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| filename | string | Yes| Absolute path of the target file.|
- | events | Number | Yes| - **1**: : The file or directory is renamed.
- **2**: The file or directory is modified.
- **3**: The file or directory is modified and renamed.|
+ | events | Number | Yes| - **1**: The file or directory is renamed.
- **2**: The file or directory is modified.
- **3**: The file or directory is modified and renamed.|
| callback | AsyncCallback<number > | Yes| Called each time a change is detected.|
- Return value
@@ -2143,6 +2370,8 @@ Asynchronously listens for the changes of a file or directory. This method uses
Obtains the file read result. This class applies only to the **read()** method.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| bytesRead | number | Yes| Yes| Length of the data read.|
@@ -2154,6 +2383,7 @@ Obtains the file read result. This class applies only to the **read()** method.
Provides detailed file information. Before calling a method of the **Stat** class, use the [stat()](#fileiostat) method synchronously or asynchronously to create a **Stat** instance.
+**System capability**: SystemCapability.FileManagement.File.FileIO
### Attributes
@@ -2161,7 +2391,7 @@ Provides detailed file information. Before calling a method of the **Stat** clas
| -------- | -------- | -------- | -------- | -------- |
| dev | number | Yes| No| Major device number.|
| ino | number | Yes| No| File ID. Different files on the same device have different **ino**s.|
-| mode | number | Yes| No| File type and permissions. The first four bits indicate the file type, and the last 12 bits indicate the permissions. The bit fields are described as follows:
- **0o170000**: mask used to obtain the file type.
- **0o140000**: The file is a socket.
- **0o120000**: The file is a symbolic link.
- **0o100000**: The file is a regular file.
- **0o060000**: The file is a block device.
- **0o040000**: The file is a directory.
- **0o020000**: The file is a character device.
- **0o010000**: The file is a named pipe (FIFO).
- **0o0700**: mask used to obtain the owner permissions.
- **0o0400**: The owner has the permission to read a regular file or a directory entry.
- **0o0200**: The owner has the permission to write a regular file or create and delete a directory entry.
- **0o0100**: The owner has the permission to execute a regular file or search for the specified path in a directory.
- **0o0070**: mask used to obtain the user group permissions.
- **0o0040**: The user group has the permission to read a regular file or a directory entry.
- **0o0020**: The user group has the permission to write a regular file or create and delete a directory entry.
- **0o0010**: The user group has the permission to execute a regular file or search for the specified path in a directory.
- **0o0007**: mask used to obtain the permissions of other users.
- **0o0004**: Other users have the permission to read a regular file or a directory entry.
- **0o0002**: Other users have the permission to write a regular file or create and delete a directory entry.
- **0o0001**: Other users have the permission to execute a regular file or search for the specified path in a directory.|
+| mode | number | Yes| No| File type and permissions. The first four bits indicate the file type, and the last 12 bits indicate the permissions. The bit fields are described as follows:
- **0o170000**: mask used to obtain the file type.
- **0o140000**: The file is a socket.
- **0o120000**: The file is a symbolic link.
- **0o100000**: The file is a regular file.
- **0o060000**: The file is a block device.
- **0o040000**: The file is a directory.
- **0o020000**: The file is a character device.
- **0o010000**: The file is a named pipe (FIFO).
- **0o0700**: mask used to obtain the owner permissions.
- **0o0400**: The owner has the permission to read a regular file or a directory entry.
- **0o0200**: The owner has the permission to write a regular file or create and delete a directory entry.
- **0o0100**: The owner has the permission to execute a regular file or search for the specified path in a directory.
- **0o0070**: mask used to obtain the user group permissions.
- **0o0040**: The user group has the permission to read a regular file or a directory entry.
- **0o0020**: The user group has the permission to write a regular file or create and delete a directory entry.
- **0o0010**: The user group has the permission to execute a regular file or search for the specified path in a directory.
- **0o0007**: mask used to obtain the permissions of other users.
- **0o0004**: Other users have the permission to read a regular file or a directory entry.
- **0o0002**: Other users have the permission to write a regular file or create and delete a directory entry.
- **0o0001**: Other users have the permission to execute a regular file or search for the specified path in a directory.|
| nlink | number | Yes| No| Number of hard links in the file.|
| uid | number | Yes| No| User ID, that is ID of the file owner.|
| gid | number | Yes| No| Group ID, that is, ID of the user group of the file.|
@@ -2179,6 +2409,8 @@ isBlockDevice(): boolean
Checks whether the current directory entry is a block special file. A block special file supports access by block only, and it is cached when accessed.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Return value
| Type| Description|
| -------- | -------- |
@@ -2196,6 +2428,8 @@ isCharacterDevice(): boolean
Checks whether the current directory entry is a character special file. A character special file supports random access, and it is not cached when accessed.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Return value
| Type| Description|
| -------- | -------- |
@@ -2213,6 +2447,8 @@ isDirectory(): boolean
Checks whether a directory entry is a directory.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Return value
| Type| Description|
| -------- | -------- |
@@ -2230,6 +2466,8 @@ isFIFO(): boolean
Checks whether the current directory entry is a named pipe (or FIFO). Named pipes are used for inter-process communication.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Return value
| Type| Description|
| -------- | -------- |
@@ -2247,6 +2485,8 @@ isFile(): boolean
Checks whether a directory entry is a regular file.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Return value
| Type| Description|
| -------- | -------- |
@@ -2264,6 +2504,8 @@ isSocket(): boolean
Checks whether a directory entry is a socket.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Return value
| Type| Description|
| -------- | -------- |
@@ -2281,6 +2523,8 @@ isSymbolicLink(): boolean
Checks whether a directory entry is a symbolic link.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Return value
| Type| Description|
| -------- | -------- |
@@ -2299,10 +2543,12 @@ Listens for the changes of a file. You can call the **Watcher.stop()** method sy
### stop7+
-stop(): void
+stop(): Promise<void>
Asynchronously stops **watcher**. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Example
```js
fileio.stop();
@@ -2311,10 +2557,12 @@ Asynchronously stops **watcher**. This method uses a promise to return the resul
### stop7+
-stop(callback: AsyncCallback): void
+stop(callback: AsyncCallback<void>): void
Asynchronously stops **watcher**. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.File.FileIO
+
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
@@ -2326,488 +2574,3 @@ Asynchronously stops **watcher**. This method uses a callback to return the resu
// Do something.
});
```
-## Stream7+
-
-File stream. Before calling a method of the **Stream** class, use the **createStream()** method synchronously or asynchronously to create a **Stream** instance.
-
-
-### close7+
-
-close(): Promise<void>
-
-Asynchronously closes the stream. This method uses a promise to return the result.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the stream close result.|
-
-- Example
- ```js
- let ss= fileio.createStreamSync(path);
- ss.close().then(function(){
- console.info("close fileStream successfully");
- }).catch(function(err){
- console.info("close fileStream failed with error:"+ err);
- });
- ```
-
-
-### close7+
-
-close(callback: AsyncCallback<void>): void
-
-Asynchronously closes the stream. This method uses a callback to return the result.
-
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<void> | Yes| Callback invoked when the stream is closed asynchronously.|
-
-- Example
- ```js
- let ss= fileio.createStreamSync(path);
- ss.close(function (err) {
- // do something
- });
- ```
-
-
-### closeSync7+
-
-closeSync(): void
-
-Synchronously closes the stream.
-
-- Example
- ```js
- let ss= fileio.createStreamSync(path);
- ss.closeSync();
- ```
-
-
-### flush7+
-
-flush(): Promise<void>
-
-Asynchronously flushes the stream. This method uses a promise to return the result.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the stream flushing result.|
-
-- Example
- ```js
- let ss= fileio.createStreamSync(path);
- ss.flush().then(function (){
- console.info("flush successfully");
- }).catch(function(err){
- console.info("flush failed with error:"+ err);
- });
- ```
-
-
-### flush7+
-
-flush(callback: AsyncCallback<void>): void
-
-Asynchronously flushes the stream. This method uses a callback to return the result.
-
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<void> | Yes| Callback invoked when the stream is asynchronously flushed.|
-
-- Example
- ```js
- let ss= fileio.createStreamSync(path);
- ss.flush(function (err) {
- // do something
- });
- ```
-
-
-### flushSync7+
-
-flushSync(): void
-
-Synchronously flushes the stream.
-
-- Example
- ```js
- let ss= fileio.createStreamSync(path);
- ss.flushSync();
- ```
-
-
-### write7+
-
-write(buffer: ArrayBuffer | string, options?: Object): Promise<number>
-
-Asynchronously writes data into the stream. This method uses a promise to return the result.
-
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | buffer | ArrayBuffer \| string | Yes| Data to write. It can be a string or data from a buffer.|
- | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<number> | Promise used to return the length of the data written in the file.|
-
-- Example
- ```js
- let ss= fileio.createStreamSync(fpath, "r+");
- ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number){
- console.info("write successfully:"+ number);
- }).catch(function(err){
- console.info("write failed with error:"+ err);
- });
- ```
-
-
-### write7+
-
-write(buffer:ArrayBuffer | string,options?:Object, callback:AsyncCallback<number>): void
-
-Asynchronously writes data into the stream. This method uses a callback to return the result.
-
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | buffer | ArrayBuffer \| string | Yes| Data to write. It can be a string or data from a buffer.|
- | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
- | callback | AsyncCallback<number> | Yes| Callback invoked when the data is written asynchronously.|
-
-- Example
- ```js
- let ss= fileio.createStreamSync(fpath, "r+");
- ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) {
- if (!err) {
- // do something
- console.log(bytesWritten);
- }
- });
- ```
-
-
-### writeSync7+
-
-writeSync(buffer: ArrayBuffer | string, options?:Object): number
-
-Synchronously writes data into the stream.
-
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | buffer | ArrayBuffer \| string | Yes| Data to write. It can be a string or data from a buffer.|
- | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | number | Length of the data written in the file.|
-
-- Example
- ```js
- let ss= fileio.createStreamSync(fpath,"r+");
- let num = ss.writeSync("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'});
- ```
-
-
-### read7+
-
-read(buffer: ArrayBuffer, options?: Object): Promise<Readout>
-
-Asynchronously reads data from the stream. This method uses a promise to return the result.
-
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | buffer | ArrayBuffer | Yes| Buffer used to store the file read.|
- | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to be read in the file. By default, data is read from the current position.|
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<[Readout](#readout)> | Promise used to return the data read.|
-
-- Example
- ```js
- let ss = fileio.createStreamSync(fpath, "r+");
- ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readout){
- console.info("read data successfully");
- }).catch(function(err){
- console.info("read data failed with error:"+ err);
- });
- ```
-
-
-### read7+
-
-read(buffer: ArrayBuffer, options?: Object, callback: AsyncCallback<Readout>): void
-
-Asynchronously reads data from the stream. This method uses a callback to return the result.
-
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | buffer | ArrayBuffer | Yes| Buffer used to store the file read.|
- | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to be read in the file. By default, data is read from the current position.|
- | callback | AsyncCallback<[Readout](#readout)> | Yes| Callback invoked when data is read asynchronously from the stream.|
-
-- Example
- ```js
- let ss = fileio.createStreamSync(fpath, "r+");
- ss.read(new ArrayBuffer(4096),{offset: 1, length: 5, position: 5},function (err, readOut) {
- if (!err) {
- // do something
- }
- });
- ```
-
-
-### readSync7+
-
-readSync(buffer: ArrayBuffer, options?: Object): number
-
-Synchronously reads data from the stream.
-
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | buffer | ArrayBuffer | Yes| Buffer used to store the file read.|
- | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to be read in the file. By default, data is read from the current position.|
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | number | Length of the data read.|
-
-- Example
- ```js
- let ss = fileio.createStreamSync(fpath, "r+");
- let num = ss.readSync(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5});
- ```
-
-
-## Dir
-
-Manages directories. Before calling a method of the **Dir** class, use the [opendir()](#fileioopendir) method synchronously or asynchronously to create a **Dir** instance.
-
-
-### read
-
-read(): Promise<Dirent>
-
-Asynchronously reads the next directory entry. This method uses a promise to return the result.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<[Dirent](#dirent)> | Directory entry that is read asynchronously.|
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- dir.read().then(function (dirent){
- console.info("read successfully:"+ dirent.name);
- }).catch(function(err){
- console.info("read failed with error:"+ err);
- });
- ```
-
-
-### read
-
-read(callback: AsyncCallback<Dirent>): void
-
-Asynchronously reads the next directory entry. This method uses a callback to return the result.
-
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<[Dirent](#dirent)> | Yes| Callback invoked when the next directory entry is asynchronously read.|
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- dir.read(function (err, dirent) {
- if (!err) {
- // do something
- console.log(dirent.name)
- }
- });
- ```
-
-
-### readSync
-
-readSync(): Dirent
-
-Synchronously reads the next directory entry.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | [Dirent](#dirent) | Directory entry read.|
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- let dirent = dir.readSync();
- ```
-
-
-### closeSync
-
-closeSync(): void
-
-Closes a directory. After a directory is closed, the file descriptor in Dir will be released and no directory entry can be read from Dir.
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- dir.closeSync();
- ```
-
-
-## Dirent
-
-Provides information about files and directories. Before calling a method of the **Dirent** class, use the [dir.read()](#read) method synchronously or asynchronously to create a **Dirent** instance.
-
-
-### Attributes
-
-| Name| Type| Readable| Writable| Description|
-| -------- | -------- | -------- | -------- | -------- |
-| name | string | Yes| No| Directory entry name.|
-
-
-### isBlockDevice
-
-isBlockDevice(): boolean
-
-Checks whether the current directory entry is a block special file. A block special file supports access by block only, and it is cached when accessed.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | boolean | Whether the directory entry is a block special file.|
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- let isBLockDevice = dir.readSync().isBlockDevice();
- ```
-
-
-### isCharacterDevice
-
-isCharacterDevice(): boolean
-
-Checks whether a directory entry is a character special file. A character special file supports random access, and it is not cached when accessed.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | boolean | Whether the directory entry is a character special file.|
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- let isCharacterDevice = dir.readSync().isCharacterDevice();
- ```
-
-
-### isDirectory
-
-isDirectory(): boolean
-
-Checks whether a directory entry is a directory.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | boolean | Whether the directory entry is a directory.|
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- let isDirectory = dir.readSync().isDirectory();
- ```
-
-
-### isFIFO
-
-isFIFO(): boolean
-
-Checks whether the current directory entry is a named pipe (or FIFO). Named pipes are used for inter-process communication.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | boolean | Whether the directory entry is a FIFO.|
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- let isFIFO = dir.readSync().isFIFO();
- ```
-
-
-### isFile
-
-isFile(): boolean
-
-Checks whether a directory entry is a regular file.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | boolean | Whether the directory entry is a regular file.|
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- let isFile = dir.readSync().isFile();
- ```
-
-
-### isSocket
-
-isSocket(): boolean
-
-Checks whether a directory entry is a socket.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | boolean | Whether the directory entry is a socket.|
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- let isSocket = dir.readSync().isSocket();
- ```
-
-
-### isSymbolicLink
-
-isSymbolicLink(): boolean
-
-Checks whether a directory entry is a symbolic link.
-
-- Return value
- | Type| Description|
- | -------- | -------- |
- | boolean | Whether the directory entry is a symbolic link.|
-
-- Example
- ```js
- let dir = fileio.opendirSync(dpath);
- let isSymbolicLink = dir.readSync().isSymbolicLink();
- ```
diff --git a/en/application-dev/reference/apis/js-apis-filemanager.md b/en/application-dev/reference/apis/js-apis-filemanager.md
index d00b9f63e3d442127d4663ec7bc02f0644ddb60b..18891f758ae42915da893256ebf027564cd92d6b 100644
--- a/en/application-dev/reference/apis/js-apis-filemanager.md
+++ b/en/application-dev/reference/apis/js-apis-filemanager.md
@@ -1,22 +1,22 @@
# Public File Access and Management
> **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 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.
+>- This is a system API and cannot be called by third-party applications. Currently, it can be called only by **filepicker**.
## Modules to Import
```js
-import filemanager from 'ohos.filemanager';
+import filemanager from '@ohos.fileManager';
```
-## System Capabilities
-
-SystemCapability.FileManagement.FileManagerService
-
## filemanager.getRoot
getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]>
Obtains information about the files in the first-level directory in asynchronous mode. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.FileManagerService
+
- Parameters
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
@@ -48,12 +48,14 @@ getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback<FileInfo[]>)
Obtains information about the files in the first-level directory in asynchronous mode. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.FileManagerService
+
- Parameters
- | Name| Type| Mandatory| Description|
+ | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- |
- | dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.|
- | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes| Callback invoked to return the file information obtained.|
+ | dev | [DevInfo](#devinfo) | No | Device name. The default value is **local**, which is the only value supported.|
+ | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the file information obtained. |
- Example
@@ -73,6 +75,8 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
Obtains information about the files in the second-level directory in asynchronous mode. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.FileManagerService
+
- Parameters
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
@@ -90,10 +94,10 @@ Obtains information about the files in the second-level directory in asynchronou
- Error
| Error Info| Error Code|Description|
- | -- | --- | -- |
- | No such file or directory | 2 | The directory or file of the specified URI does not exist.|
- | No such process | 3 | Failed to obtain the FMS service.|
- | Not a directory | 20 | The object specified by the URI is not a directory.|
+ | -- | --- | -- |
+ |No such file or directory | 2 | The directory or file of the specified URI does not exist.|
+ |No such process | 3 | Failed to obtain the FMS service.|
+ |Not a directory | 20 | The object specified by the URI is not a directory.|
```js
// Obtain all files in the directory.
@@ -106,8 +110,7 @@ filemanager.listFile(media_path, "file")
console.log(JSON.Stringify(fileInfo))
}
}
-})
-.catch((err) => {
+}).catch((err) => {
console.log(err)
})
```
@@ -117,23 +120,25 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
Obtains information about the files in the second-level directory in asynchronous mode. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.FileManagerService
+
- Parameters
- | Name| Type| Mandatory| Description|
+ | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
- | type | string | Yes| Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
- | path | string | Yes| URI of the directory to query.|
+ | type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
+ | path | string | Yes | URI of the directory to query. |
| dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.|
| offset | number | No| Start position from which the files are to query.|
| count | number | No| Number of files to query.|
- | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes| Callback invoked to return the file information obtained.|
+ | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the file information obtained. |
- Error
- | Error Info| Error Code| Description|
+ | Error Info | Error Code| Description |
| ------------------------- | ------ | ------------------------- |
- | No such file or directory | 2 | The directory or file of the specified URI does not exist.|
- | No such process | 3 | Failed to obtain the FMS service.|
- | Not a directory | 20 | The object specified by the URI is not a directory.|
+ |No such file or directory | 2 | The directory or file of the specified URI does not exist.|
+ |No such process | 3 | Failed to obtain the FMS service. |
+ |Not a directory | 20 | The object specified by the URI is not a directory.|
```js
// Call listFile() and getRoot() to obtain the file UIRs.
@@ -153,6 +158,8 @@ filemanager.createFile(path : string, filename : string, options? : {dev? : DevI
Creates a file in the specified path in asynchronous mode. This method uses a promise to return the result.
+**System capability**: SystemCapability.FileManagement.FileManagerService
+
- Parameters
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
@@ -177,7 +184,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr
```js
// Create a file.
let media_path = file.uri // Obtain the file URI using listFile() and getRoot().
-let name = "xxx.jpg" // File name extension of the file to be saved.
+let name = "xxx.jpg" // File to be saved.
filemanager.createFile(media_path, name)
.then((uri) => {
// The URI of the file created is returned.
@@ -193,29 +200,31 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac
Creates a file in the specified path in asynchronous mode. This method uses a callback to return the result.
+**System capability**: SystemCapability.FileManagement.FileManagerService
+
- Parameters
- | Name| Type| Mandatory| Description|
+ | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- |
- | filename | string | Yes| Name of the file to create.|
- | path | string | Yes| URI of the file to create.|
+ | filename | string | Yes | Name of the file to create. |
+ | path | string | Yes | URI of the file to create. |
| dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.|
- | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes| Callback invoked to return the URI of the file created.|
+ | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the file information obtained. |
- Error
- | Error Info| Error Code| Description|
+ | Error Info | Error Code| Description |
| ------------------------- | ------ | ------------------------- |
- | Operation not permitted | 1 | A file with the same name already exists.|
+ | Operation not permitted | 1 | A file with the same name already exists. |
| No such file or directory | 2 | The directory or file of the specified URI does not exist.|
- | No such process | 3 | Failed to obtain the FMS service.|
+ | No such process | 3 | Failed to obtain the FMS service. |
| Not a directory | 20 | The object specified by the URI is not a directory.|
```js
// Create a file.
// Call listFile() and getRoot() to obtain the file URI.
let media_path = file.uri
-// File name extension of file to be saved.
+// File to be saved.
let name = "xxx.jpg"
filemanager.createFile(media_path, name, (err, uri) => {
// The URI of the file created is returned.
@@ -225,6 +234,8 @@ filemanager.createFile(media_path, name, (err, uri) => {
## FileInfo
Defines the file information returned by **getRoot()** or **listFile()**.
+**System capability**: SystemCapability.FileManagement.FileManagerService
+
### Attributes
| Name| Type| Readable| Writable| Description|
@@ -239,6 +250,8 @@ Defines the file information returned by **getRoot()** or **listFile()**.
## DevInfo
Defines the device type.
+**System capability**: SystemCapability.FileManagement.FileManagerService
+
### Attributes
| Name| Type| Readable| Writable| Description|
diff --git a/en/application-dev/reference/apis/js-apis-formbindingdata.md b/en/application-dev/reference/apis/js-apis-formbindingdata.md
index cf59cffd6eaf7cdd36176d0a8426627a7dd3620c..54470f52311e717a64d6ce1a98f5f427d557913c 100644
--- a/en/application-dev/reference/apis/js-apis-formbindingdata.md
+++ b/en/application-dev/reference/apis/js-apis-formbindingdata.md
@@ -1,6 +1,6 @@
# FormBindingData
->  **Note:**
+>  **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -19,33 +19,39 @@ createFormBindingData(obj?: Object | string): FormBindingData
Creates a **FormBindingData** object.
-- Parameters
+**System capability**: SystemCapability.Ability.Form
- | 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.|
+**Parameters**
+| 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.|
-- Return value
+**Return value**
- | Type| Description|
- | ----------------------------------- | --------------------------------------- |
- | [FormBindingData](#formbindingdata) | **FormBindingData** object created based on the passed data.|
+| Type | Description |
+| ----------------------------------- | --------------------------------------- |
+| [FormBindingData](#formbindingdata) | **FormBindingData** object created based on the passed data.|
+**Example**
-- Example
-
- ```
+ ```js
let obj = {"temperature": "21°"};
let formBindingDataObj = formBindingData.createFormBindingData(obj);
```
-## FormBindingData
+## formBindingData.FormBindingData
+
+data: Object
Describes a **FormBindingData** object.
-| Name| Type| Description|
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Description |
| ---- | -------------- | ------------------------------------------------------------ |
-| obj | 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.|
+| 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.|
diff --git a/en/application-dev/reference/apis/js-apis-formextension.md b/en/application-dev/reference/apis/js-apis-formextension.md
index ee3e0f92b41b9edc4d28eab38dc63c4722119230..a96feb9ef29393127bc1916a9a4a13ea7eba1817 100644
--- a/en/application-dev/reference/apis/js-apis-formextension.md
+++ b/en/application-dev/reference/apis/js-apis-formextension.md
@@ -1,7 +1,7 @@
# FormExtension
>  **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 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.
Provides **FormExtension** APIs.
@@ -17,9 +17,9 @@ None
## Attributes
-| Name| Type| Readable| Writable| Description|
+| Name | Type | Readable| Writable| Description |
| ------- | ------------------------------------------------------- | ---- | ---- | --------------------------------------------------- |
-| context | [FormExtensionContext](js-apis-formextensioncontext.md) | Yes| No| Context of the **FormExtension**. This class is inherited from **ExtensionContext**.|
+| context | [FormExtensionContext](js-apis-formextensioncontext.md) | Yes | No | Context of the **FormExtension**. This class is inherited from **ExtensionContext**.
**System capability**: SystemCapability.Ability.Form|
## onCreate
@@ -27,21 +27,23 @@ onCreate(want: Want): formBindingData.FormBindingData
Called to notify the widget provider that a **Form** instance (widget) has been created.
-- Parameters
+**System capability**: SystemCapability.Ability.Form
- | Name| Type| Mandatory| Description|
+**Parameters**
+
+ | Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
- | want | [Want](js-apis-featureAbility.md#want) | Yes| Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
+ | want | [Want](js-apis-featureAbility.md#want) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
-- Return value
+**Return value**
- | Type| Description|
+ | Type | Description |
| ------------------------------------------------------------ | ----------------------------------------------------------- |
| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.|
-- Example
+**Example**
- ```
+ ```js
export default class MyFormExtension extends FormExtension {
onCreate(want) {
console.log('FormExtension onCreate, want:' + want.abilityName);
@@ -55,19 +57,21 @@ Called to notify the widget provider that a **Form** instance (widget) has been
}
```
-## onCastToNormal
+## FormExtension.onCastToNormal
onCastToNormal(formId: string): void
Called to notify the widget provider that a temporary widget has been converted to a normal one.
-- Parameters
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
- | Name| Type| Mandatory| Description|
+ | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------ |
- | formId | string | Yes| ID of the widget that requests to be converted to a normal one.|
+ | formId | string | Yes | ID of the widget that requests to be converted to a normal one.|
-- Example
+**Example**
```
export default class MyFormExtension extends FormExtension {
@@ -77,21 +81,23 @@ Called to notify the widget provider that a temporary widget has been converted
}
```
-## onUpdate
+## FormExtension.onUpdate
onUpdate(formId: string): void
Called to notify the widget provider that a widget has been updated. After obtaining the latest data, the caller invokes **updateForm** of the [FormExtensionContext](js-apis-formextensioncontext.md) class to update the widget data.
-- Parameters
+**System capability**: SystemCapability.Ability.Form
- | Name| Type| Mandatory| Description|
+**Parameters**
+
+ | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
- | formId | string | Yes| ID of the widget that requests to be updated.|
+ | formId | string | Yes | ID of the widget that requests to be updated.|
-- Example
+**Example**
- ```
+ ```js
export default class MyFormExtension extends FormExtension {
onUpdate(formId) {
console.log('FormExtension onUpdate, formId:' + formId);
@@ -105,21 +111,23 @@ Called to notify the widget provider that a widget has been updated. After obtai
}
```
-## onVisibilityChange
+## FormExtension.onVisibilityChange
onVisibilityChange(newStatus: { [key: string]: number }): void
Called to notify the widget provider of the change of visibility.
-- Parameters
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
- | Name| Type| Mandatory| Description|
+ | Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ---------------------------- |
- | newStatus | { [key: string]: number } | Yes| ID and visibility status of the widget to be changed.|
+ | newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.|
-- Example
+**Example**
- ```
+ ```js
export default class MyFormExtension extends FormExtension {
onVisibilityChange(newStatus) {
console.log('FormExtension onVisibilityChange, newStatus:' + newStatus);
@@ -137,22 +145,24 @@ Called to notify the widget provider of the change of visibility.
}
```
-## onEvent
+## FormExtension.onEvent
onEvent(formId: string, message: string): void
Called to instruct the widget provider to receive and process the widget event.
-- Parameters
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
- | Name| Type| Mandatory| Description|
+ | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------- |
- | formId | string | Yes| ID of the widget that requests the event.|
- | message | string | Yes| Event message.|
+ | formId | string | Yes | ID of the widget that requests the event.|
+ | message | string | Yes | Event message. |
-- Example
+**Example**
- ```
+ ```js
export default class MyFormExtension extends FormExtension {
onEvent(formId, message) {
console.log('FormExtension onEvent, formId:' + formId + ", message:" + message);
@@ -160,24 +170,50 @@ Called to instruct the widget provider to receive and process the widget event.
}
```
-## onDestroy
+## FormExtension.onDestroy
onDestroy(formId: string): void
Called to notify the widget provider that a **Form** instance (widget) has been destroyed.
-- Parameters
+**System capability**: SystemCapability.Ability.Form
- | Name| Type| Mandatory| Description|
+**Parameters**
+
+ | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
- | formId | string | Yes| ID of the widget to be destroyed.|
+ | formId | string | Yes | ID of the widget to be destroyed.|
-- Example
+**Example**
- ```
+ ```js
export default class MyFormExtension extends FormExtension {
onDestroy(formId) {
console.log('FormExtension onDestroy, formId:' + formId);
}
}
```
+
+## FormExtension.onConfigurationUpdated
+
+onConfigurationUpdated(config: Configuration): void;
+
+Called when the configuration of the environment where the ability is running is updated.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | config | [Configuration](#section188911144124715) | Yes| New configuration.|
+
+**Example**
+
+ ```js
+ class MyFormExtension extends MyFormExtension {
+ onConfigurationUpdated(config) {
+ console.log('onConfigurationUpdated, config:' + JSON.stringify(config));
+ }
+ }
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-formextensioncontext.md b/en/application-dev/reference/apis/js-apis-formextensioncontext.md
index b4cf3bca0a580270658be8d19ce0fd4a7cf3b403..faa3bd6c6f82018ca61c9ba1f008dbc1e72dae9f 100644
--- a/en/application-dev/reference/apis/js-apis-formextensioncontext.md
+++ b/en/application-dev/reference/apis/js-apis-formextensioncontext.md
@@ -1,53 +1,57 @@
# FormExtensionContext
->  **Note:**
+>  **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.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
-## updateForm
+## FormExtensionContext.updateForm
updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void
Updates a widget. This method uses a callback to return the result.
-- Parameters
+**System capability**: SystemCapability.Ability.Form
- | Name| Type| Mandatory| Description|
+**Parameters**
+
+ | Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
- | formId | string | Yes| ID of the widget that requests to be updated.|
- | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes| New data of the widget.|
- | callback | AsyncCallback\ | Yes| Callback used to return the result indicating whether the method is successfully called.|
+ | formId | string | Yes | ID of the widget that requests to be updated. |
+ | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. |
+ | callback | AsyncCallback\ | Yes | Callback used to return the result indicating whether the method is successfully called.|
-- Example
+**Example**
- ```
+ ```js
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2, (data)=>{
console.log('FormExtension context updateForm, data:' + data);
});
```
-## updateForm
+## FormExtensionContext.updateForm
updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\
Updates a widget. This method uses a promise to return the result.
-- Parameters
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
- | Name| Type| Mandatory| Description|
+ | Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | ------------------ |
- | formId | string | Yes| ID of the widget that requests to be updated.|
- | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes| New data of the widget.|
+ | formId | string | Yes | ID of the widget that requests to be updated.|
+ | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. |
-- Return value
+**Return value**
- | Type| Description|
+ | Type | Description |
| -------------- | --------------------------------- |
| Promise\ | Promise returned with the result indicating whether the method is successfully called.|
-- Example
+**Example**
```
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md
index 7a604fdd852e43c09c418312c6797ea96e7fc6e0..f262500a4c6100e3d5a6eef9e9fe2705390321ee 100644
--- a/en/application-dev/reference/apis/js-apis-i18n.md
+++ b/en/application-dev/reference/apis/js-apis-i18n.md
@@ -83,7 +83,7 @@ Checks whether the localized script for the specified language is displayed from
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the localized script is displayed from right to left, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.|
- Example
```
@@ -111,6 +111,73 @@ Obtains the system language.
```
+## i18n.setSystemLanguage
+
+setSystemLanguage(language: string): boolean
+
+Sets the system language.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Parameters
+ | Name| Type| Description|
+ | -------- | -------- | -------- |
+ | language | string | Language ID.|
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+
+- Example
+ ```
+ i18n.setSystemLanguage('zh');
+ ```
+
+
+## i18n.getSystemLanguages
+
+getSystemLanguages(): Array
+
+Obtains the list of system languages.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | Array | List of the IDs of system languages.|
+
+- Example
+ ```
+ i18n.getSystemLanguages();
+ ```
+
+
+## i18n.getSystemCountries
+
+getSystemCountries(language: string): Array
+
+Obtains the list of countries and regions supported for the specified language.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Parameters
+ | Name| Type| Description|
+ | -------- | -------- | -------- |
+ | language | string | Language ID.|
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | Array | List of the IDs of the countries and regions supported for the specified language.|
+
+- Example
+ ```
+ i18n.getSystemCountries('zh');
+ ```
+
+
## i18n.getSystemRegion
getSystemRegion(): string
@@ -130,6 +197,30 @@ Obtains the system region.
```
+## i18n.setSystemRegion
+
+setSystemRegion(region: string): boolean
+
+Sets the system region.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Parameters
+ | Name| Type| Description|
+ | -------- | -------- | -------- |
+ | region | string | Region ID.|
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+
+- Example
+ ```
+ i18n.setSystemRegion();
+ ```
+
+
## i18n.getSystemLocale
getSystemLocale(): string
@@ -149,6 +240,55 @@ Obtains the system locale.
```
+## i18n.setSystemLocale
+
+setSystemLocale(locale: string): boolean
+
+Sets the system locale.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Parameters
+ | Name| Type| Description|
+ | -------- | -------- | -------- |
+ | locale | string | System locale ID, for example, **zh-CN**.|
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+
+- Example
+ ```
+ i18n.setSystemLocale('zh-CN');
+ ```
+
+
+## i18n.isSuggested
+
+isSuggested(language: string, region?: string): boolean
+
+Checks whether the system language matches the specified region.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Parameters
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | language | string | Yes| Valid language ID, for example, **zh**.|
+ | region | string | No| Valid region ID, for example, **CN**.|
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the system language matches the specified region; returns **false** otherwise.|
+
+- Example
+ ```
+ i18n.isSuggested('zh', 'CN');
+ ```
+
+
## i18n.getCalendar8+
getCalendar(locale: string, type? : string): Calendar
@@ -161,7 +301,7 @@ Obtains a **Calendar** object.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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
| Type| Description|
@@ -295,7 +435,7 @@ Obtains the start day of a week for this **Calendar** object.
- Return value
| Type| Description|
| -------- | -------- |
- | number | Start day of a week. The value **1** indicates Sunday, and value **7** indicates Saturday.|
+ | number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
- Example
```
@@ -315,7 +455,7 @@ Sets the start day of a week for this **Calendar** object.
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | value | number | No| Start day of a week. The value **1** indicates Sunday, and value **7** indicates Saturday.|
+ | value | number | No| Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
- Example
```
@@ -375,7 +515,7 @@ Obtains the value of the specified field in the **Calendar** object.
- Parameters
| 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
| Type| Description|
@@ -431,7 +571,7 @@ Checks whether the specified date in this **Calendar** object is a weekend.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the date is a weekend, and value **false** indicates a weekday.|
+ | boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.|
- Example
```
@@ -482,7 +622,7 @@ Checks whether the format of the specified phone number is valid.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates the phone number format is valid, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.|
- Example
```
@@ -520,21 +660,23 @@ Formats a phone number.
Defines the options for this PhoneNumberFormat object.
+**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| type | string | Yes| Yes| Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.
**System capability**: SystemCapability.Global.I18n|
+| type | string | Yes| Yes| Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.|
## UnitInfo8+
Defines the measurement unit information.
+**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| 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**.
**System capability**: SystemCapability.Global.I18n|
+| measureSystem | string | Yes| Yes| Measurement system. The value can be **SI**, **US**, or **UK**.|
## Util8+
@@ -568,12 +710,9 @@ Converts one measurement unit into another and formats the unit based on the spe
```
-## IndexUtil8+
-
-
-### getInstance8+
+## getInstance8+
-getInstance(): IndexUtil
+getInstance(locale?:string): IndexUtil
Creates an **IndexUtil** object.
@@ -595,6 +734,9 @@ Creates an **IndexUtil** object.
```
+## IndexUtil8+
+
+
### getIndexList8+
getIndexList(): Array<string>
@@ -617,7 +759,7 @@ Obtains the index list for this **locale** object.
### addLocale8+
-addLocale(locale: string)
+addLocale(locale: string): void
Adds the index of the new **locale** object to the index list.
@@ -679,7 +821,7 @@ Checks whether the input character string is composed of digits.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the input character is a digit, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the input character is a digit; returns **false** otherwise.|
- Example
```
@@ -703,7 +845,7 @@ Checks whether the input character is a space.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the input character is a space, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the input character is a space; returns **false** otherwise.|
- Example
```
@@ -727,7 +869,7 @@ Checks whether the input character is a white space.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the input character is a white space, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the input character is a white space; returns **false** otherwise.|
- Example
```
@@ -751,7 +893,7 @@ Checks whether the input character is of the right to left (RTL) language.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the input character is of the RTL language, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.|
- Example
```
@@ -775,7 +917,7 @@ Checks whether the input character is an ideographic character.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the input character is an ideographic character, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.|
- Example
```
@@ -799,7 +941,7 @@ Checks whether the input character is a letter.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the input character is a letter, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the input character is a letter; returns **false** otherwise.|
- Example
```
@@ -823,7 +965,7 @@ Checks whether the input character is a lowercase letter.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the input character is a lowercase letter, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.|
- Example
```
@@ -847,7 +989,7 @@ Checks whether the input character is an uppercase letter.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value true indicates that the input character is an uppercase letter, and value false indicates the opposite.|
+ | boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.|
- Example
```
@@ -1105,7 +1247,7 @@ Checks whether the position specified by the offset is a text boundary. If **tru
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the position specified by the offset is a text boundary, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.|
- Example
```
@@ -1127,7 +1269,7 @@ Checks whether the 24-hour clock is used.
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the 24-hour clock is used, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.|
- Example
```
@@ -1146,12 +1288,12 @@ Sets the 24-hour clock.
- Parameters
| 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 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
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the 24-hour clock is enabled, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.|
- Example
```
@@ -1177,7 +1319,7 @@ Adds a preferred language to the specified position on the preferred language li
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the preferred language is successfully added, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.|
- Example
```
@@ -1188,9 +1330,9 @@ Adds a preferred language to the specified position on the preferred language li
```
-## i18n.removeDisplayLanguage8+
+## i18n.removePreferredLanguage8+
-removeDisplayLanguage(index: number): boolean
+removePreferredLanguage(index: number): boolean
Deletes a preferred language from the specified position on the preferred language list.
@@ -1204,7 +1346,7 @@ Deletes a preferred language from the specified position on the preferred langua
- Return value
| Type| Description|
| -------- | -------- |
- | boolean | The value **true** indicates that the preferred language is deleted, and value **false** indicates the opposite.|
+ | boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.|
- Example
```
@@ -1218,14 +1360,14 @@ Deletes a preferred language from the specified position on the preferred langua
getPreferredLanguageList(): Array
-Obtains the preferred language list.
+Obtains the list of preferred languages.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
- | Array | Preferred language list.|
+ | Array | List of preferred languages.|
- Example
```
@@ -1237,16 +1379,129 @@ Obtains the preferred language list.
getFirstPreferredLanguage(): string
-Obtains the preferred language that best matches the HAP resource.
+Obtains the first language in the preferred language list.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
- | string | Preferred language that best matches the HAP resource.|
+ | string | First language in the preferred language list.|
- Example
```
var firstPreferredLanguage = i18n.getFirstPreferredLanguage();
```
+
+
+## i18n.getTimeZone8+
+
+getTimeZone(zoneID?: string): TimeZone
+
+Obtains the **TimeZone** object corresponding to the specified time zone ID.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Parameters
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | zondID | string | No| Time zone ID.|
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | TimeZone | **TimeZone** object corresponding to the time zone ID.|
+
+- Example
+ ```
+ var timezone = i18n.getTimeZone();
+ ```
+
+
+## RelativeTimeFormat8+
+
+
+### getID8+
+
+getID(): string
+
+Obtains the ID of the specified **TimeZone** object.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | string | Time zone ID corresponding to the **TimeZone** object.|
+
+- Example
+ ```
+ var timezone = i18n.getTimeZone();
+ timezone.getID();
+ ```
+
+
+### getDisplayName8+
+
+getDisplayName(locale?: string, isDST?: boolean): string
+
+Obtains the representation of a **TimeZone** object in the specified locale.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Parameters
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | locale | string | No| System locale ID.|
+ | isDST | boolean | No| Whether to consider DST when obtaining the representation of the **TimeZone** object.|
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | string | Representation of the **TimeZone** object in the specified locale.|
+
+- Example
+ ```
+ var timezone = i18n.getTimeZone();
+ timezone.getDisplayName("zh-CN", false);
+ ```
+
+
+### getRawOffset8+
+
+getRawOffset(): number
+
+Obtains the offset between the time zone represented by a **TimeZone** object and the UTC time zone.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.|
+
+- Example
+ ```
+ var timezone = i18n.getTimeZone();
+ timezone.getRawOffset();
+ ```
+
+
+### getOffset8+
+
+getOffset(date?: number): number
+
+Obtains the offset between the time zone represented by a **TimeZone** object and the UTC time zone at a certain time point.
+
+**System capability**: SystemCapability.Global.I18n
+
+- Return value
+ | Type| Description|
+ | -------- | -------- |
+ | number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point.|
+
+- Example
+ ```
+ var timezone = i18n.getTimeZone();
+ timezone.getOffset(1234567890);
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md
new file mode 100644
index 0000000000000000000000000000000000000000..8a112fc22b0502bbf128227c82a4f5122bec99e1
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-image.md
@@ -0,0 +1,1157 @@
+Image Processing
+==========
+
+> **NOTE**
+> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+
+ Modules to Import
+---------
+
+```
+import image from '@ohos.multimedia.image';
+```
+
+## image.createPixelMap8+
+createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions): Promise\
+
+Creates a **PixelMap** object. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Image
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------ | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
+| colors | ArrayBuffer | Yes | Color array. |
+| opts | [InitializetionOptions](#InitializationOptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
+
+**Return value**
+
+| Type | Description |
+| -------------------------------- | -------------- |
+| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object created.|
+
+**Example**
+
+```js
+image.createPixelMap(Color, opts)
+ .then((pixelmap) => {
+ expect(pixelmap !== null).assertTrue()
+ done()
+ })
+```
+
+## image.createPixelMap8+
+
+createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions) callback: AsyncCallback\): void
+
+Creates a **PixelMap** object. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Image
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------ | ---- | -------------------- |
+| colors | ArrayBuffer | Yes | Color array. |
+| opts | [InitializetionOptions](#InitializationOptions8) | Yes | Pixel properties. |
+| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object obtained.|
+
+**Example**
+
+```js
+image.createPixelMap(Color, opts, (pixelmap) => {
+ expect(pixelmap !== null).assertTrue()
+ done()
+ })
+```
+
+## PixelMap7+
+
+Provides APIs to read or write image pixel map data and obtain image pixel map information. Before calling any API in **PixelMap**, you must use **createPixelMap** to create a **PixelMap** object.
+
+ ### Attributes
+
+| Name | Type | Readable| Writable| Description |
+| ----------------------- | ------- | ---- | ---- | ------------------------------------------------------------ |
+| isEditable7+ | boolean | Yes | No | Whether the image pixel map is editable.
**System capability**: SystemCapability.Multimedia.Image|
+
+### readPixelsToBuffer7+
+
+readPixelsToBuffer(dst: ArrayBuffer): Promise\
+
+Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Image
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ----------- | ---- | ------------------------------------------------------------ |
+| dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written.|
+
+**Return value**
+
+| Type | Description |
+| :------------- | :---------------------------------------------- |
+| Promise\ | Promise used to return the operation result. If the operation fails, an error message is returned.|
+
+**Example**
+
+```js
+pixelmap.readPixelsToBuffer(readBuffer).then(() => {
+ var bufferArr = new Uint8Array(readBuffer)
+ var res = true
+ for (var i = 0; i < bufferArr.length; i++) {
+ if (res) {
+ if (bufferArr[i] !== 0) {
+ res = false
+ console.info('TC_020 Success')
+ expect(true).assertTrue()
+ done()
+ break
+ }
+ }
+ }
+ if (res) {
+ console.info('TC_020 buffer is all empty')
+ expect(false).assertTrue()
+ done()
+ }
+ })
+```
+
+### readPixelsToBuffer