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**. -> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE** +> ![icon-notice.gif](../public_sys-resources/icon-notice.gif) **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**. + + ![en-us_image_0000001241693881](figures/en-us_image_0000001241693881.png) + +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**. + + ![en-us_image_0000001196654004](figures/en-us_image_0000001196654004.png) + +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**. + + ![en-us_image_0000001241733907](figures/en-us_image_0000001241733907.png) 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 + ![en-us_image_0000001226521897](figures/en-us_image_0000001226521897.png) + +- 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 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## 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 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## 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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -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 > ![icon-note.gif](public_sys-resources/icon-note.gif) **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 > ![icon-note.gif](public_sys-resources/icon-note.gif) **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 @@ -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +# Bluetooth + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > > The 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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. The 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 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The APIs of this module are system APIs and cannot be called by third-party applications. + +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 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## 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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> +> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The APIs of this module are system APIs and cannot be called by third-party applications. ## Modules to Import @@ -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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API 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) +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## 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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 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 >![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** ->The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +>- The 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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API version 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 > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The 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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API version 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() + } + }) +``` + +### readPixelsToBuffer7+ + +readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\): void + +Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses a callback 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.| +| callback | AsyncCallback\ | Yes | Callback used to return the operation result. If the operation fails, an error message is returned. | + +**Example** + +```js +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 + } + } + } + if (res) { + console.info('TC_020-1 buffer is all empty') + expect(false).assertTrue() + done() + } + }) +``` + +### readPixels7+ + +readPixels(area: PositionArea): Promise\ + +Reads pixel map data in an area. This API uses a promise to return the data read. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------------------------ | ---- | ------------------------ | +| area | [PositionArea](#positionarea7) | Yes | Area from which the image pixel map data will be read.| + +**Return value** + +| Type | Description | +| :------------- | :-------------------------------------------------- | +| Promise\ | Promise used to return the operation result. If the operation fails, an error message is returned.| + +**Example** + +```js +pixelmap.readPixels(area).then((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 buffer ' + bufferArr[i]); + if(res) { + if (bufferArr[i] == 0) { + res = false; + console.info('TC_021 Success'); + expect(true).assertTrue(); + done(); + break; + } + } + } + if (res) { + console.info('TC_021 buffer is all empty'); + expect(false).assertTrue() + done(); + } + } + }) +``` + +### readPixels7+ + +readPixels(area: PositionArea, callback: AsyncCallback\): void + +Reads image pixel map data in an area. This API uses a callback to return the data read. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------ | ---- | ------------------------------ | +| area | [PositionArea](#positionarea7) | Yes | Area from which the image pixel map data will be read. | +| callback | AsyncCallback\ | Yes | Callback used to return the operation result. If the operation fails, an error message is returned.| + +**Example** + +```js +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; + } + } + } +``` + +### writePixels7+ + +writePixels(area: PositionArea): Promise\ + +Writes image pixel map data to an area. This API uses a promise to return the operation result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------------------------ | ---- | -------------------- | +| area | [PositionArea](#PositionArea7) | Yes | Area to which the 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.writePixels(area).then(() => { + console.log("Succeeded in writing pixels."); +}).catch((err) => { + console.error("Failed to write pixels."); +}); +``` + +### writePixels7+ + +writePixels(area: PositionArea, callback: AsyncCallback\): void + +Writes image pixel map data to an area. This API uses a callback to return the operation result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------------ | ---- | ------------------------------ | +| area | [PositionArea](#PositionArea7) | Yes | Area to which the pixel map data will be written. | +| callback: | AsyncCallback\ | Yes | Callback used to return the operation result. If the operation fails, an error message is returned.| + +**Example** + +```js +pixelmap.writePixels(area, () => { + const readArea = { + pixels: new ArrayBuffer(20), + offset: 0, + stride: 8, + region: { size: { height: 1, width: 2 }, x: 0, y: 0 }, + } + }) +``` + +### writeBufferToPixels7+ + +writeBufferToPixels(src: ArrayBuffer): Promise\ + +Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ----------- | ---- | -------------- | +| src | ArrayBuffer | Yes | Buffer from which the image data will be read.| + +**Return value** + +| Type | Description | +| -------------- | ----------------------------------------------- | +| Promise\ | Promise used to return the operation result. If the operation fails, an error message is returned.| + +**Example** + +```js +pixelMap.writeBufferToPixels(colorBuffer).then(() => { + console.log("Succeeded in writing data from a buffer to a PixelMap."); +}).catch((err) => { + console.error("Failed to write data from a buffer to a PixelMap."); +}); +``` + +### writeBufferToPixels7+ + +writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\): void + +Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses a callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------ | +| src | ArrayBuffer | Yes | Buffer from which the image data will be read. | +| callback | AsyncCallback\ | Yes | Callback used to return the operation result. If the operation fails, an error message is returned.| + +**Example** + +```js +pixelMap.writeBufferToPixels(colorBuffer, function(err) { + if (err) { + console.error("Failed to write data from a buffer to a PixelMap."); + return; + } + console.log("Succeeded in writing data from a buffer to a PixelMap."); +}); +``` + +### getImageInfo7+ + +getImageInfo(): Promise\ + +Obtains pixel map information about this image. This API uses a promise to return the information. + +**System capability**: SystemCapability.Multimedia.Image + +**Return value** + +| Type | Description | +| --------------------------------- | ----------------------------------------------------------- | +| Promise\<[ImageInfo](#imageinfo)> | Promise used to return the pixel map information. If the operation fails, an error message is returned.| + +**Example** + +```js +pixelMap.getImageInfo().then(function(info) { + console.log("Succeeded in obtaining the image pixel map information."); +}).catch((err) => { + console.error("Failed to obtain the image pixel map information."); +}); +``` + +### getImageInfo7+ + +getImageInfo(callback: AsyncCallback\): void + +Obtains pixel map information about this image. This API uses a callback to return the information. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\<[ImageInfo](#imageinfo)> | Yes | Callback used to return the pixel map information. If the operation fails, an error message is returned.| + +**Example** + +```js +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 == 1).assertTrue() + done() + } else { + console.info('TC_024-1 imageInfo is empty') + expect(false).assertTrue() + done() + } + }) +``` + +### getBytesNumberPerRow7+ + +getBytesNumberPerRow(): number + +Obtains the number of bytes in each line of the image pixel map. + +**System capability**: SystemCapability.Multimedia.Image + +**Return value** + +| Type | Description | +| ------ | -------------------- | +| number | Number of bytes in each line.| + +**Example** + +```js +pixelmap.getBytesNumberPerRow().then((num) => { + console.info('TC_025 num is ' + num) + expect(num == expectNum).assertTrue() + done() + }) +``` + +### getPixelBytesNumber7+ + +getPixelBytesNumber(): number + +Obtains the total number of bytes of the image pixel map. + +**System capability**: SystemCapability.Multimedia.Image + +**Return value** + +| Type | Description | +| ------ | -------------------- | +| number | Total number of bytes.| + +**Example** + +```js +pixelmap.getPixelBytesNumber().then((num) => { + console.info('TC_026 num is ' + num) + expect(num == expectNum).assertTrue() + done() + }) +``` + +### release7+ + +release():Promise\ + +Releases this **PixelMap** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Return value** + +| Type | Description | +| -------------- | ------------------ | +| Promise\ | Promise used to return the operation result.| + +**Example** + +```js +pixelmap.release() + expect(true).assertTrue() + done() +``` + +### release7+ + +release(callback: AsyncCallback\): void + +Releases this **PixelMap** object. This API uses a callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------ | +| callback | AsyncCallback\ | Yes | Callback used to return the operation result.| + +**Example** + +```js +pixelmap.release(()=>{ + expect(true).assertTrue(); + console.log('TC_027-1 success'); + done(); + }) +``` + +## image.createImageSource + +createImageSource(uri: string): ImageSource + +Creates an **ImageSource** instance based on the URI. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------------------- | +| uri | string | Yes | Image source URI. Currently, only the local absolute path is supported.| + +**Return value** + +| Type | Description | +| --------------------------- | --------------------------------------- | +| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **null** otherwise.| + +**Example** + +```js +const imageSourceApi = image.createImageSource('/data/local/tmp/test.jpg') +``` + +## image.createImageSource7+ + +createImageSource(fd: number): ImageSource + +Creates an **ImageSource** instance based on the file descriptor. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------- | +| fd | number | Yes | File descriptor.| + +**Return value** + +| Type | Description | +| --------------------------- | --------------------------------------- | +| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **null** otherwise.| + +**Example** + +```js +const imageSourceApi = image.createImageSource(0) +``` + +## ImageSource + +Provides APIs to obtain image information. Before calling any API in **ImageSource**, you must use **createImageSource** to create an **ImageSource** instance. + +### Attributes + +| Name | Type | Readable| Writable| Description | +| ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | +| supportedFormats | Array\ | Yes | No | Supported image formats, including png, jpeg, wbmp, bmp, gif, webp, and heif.
**System capability**: SystemCapability.Multimedia.Image| + +### getImageInfo + +getImageInfo(index: number, callback: AsyncCallback\): void + +Obtains information about an image with the specified index. This API uses a callback to return the information. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ---------------------------------------- | +| index | number | Yes | Index of the image. | +| callback | AsyncCallback<[ImageInfo](#imageinfo)> | Yes | Callback used to return the image information.| + +**Example** + +```js +it('TC_046', 0, async function (done) { + const imageSourceApi = image.createImageSource('/sdcard/test.jpg'); + if (imageSourceApi == null) { + console.info('TC_046 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.getImageInfo(0,(error, imageInfo) => { + console.info('TC_046 imageInfo'); + expect(imageInfo !== null).assertTrue(); + done(); + }) + } + }) +``` + +### getImageInfo + +getImageInfo(callback: AsyncCallback\): void + +Obtains information about this image. This API uses a callback to return the information. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback<[ImageInfo](#imageinfo)> | Yes | Callback used to return the image information.| + +**Example** + +```js +imageSourceApi.getImageInfo(imageInfo => { + console.info('TC_045 imageInfo'); + expect(imageInfo !== null).assertTrue(); + done(); + }) +``` + +### getImageInfo + +getImageInfo(index?: number): Promise\ + +Obtains information about an image with the specified index. This API uses a promise to return the image information. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----- | ------ | ---- | ------------------------------------- | +| index | number | No | Index of the image. If this parameter is not set, the default value **0** is used.| + +**Return value** + +| Type | Description | +| -------------------------------- | ---------------------- | +| Promise<[ImageInfo](#imageinfo)> | Promise used to return the image information.| + +**Example** + +```js +imageSourceApi.getImageInfo(0) + .then(imageInfo => { + console.info('TC_047 imageInfo'); + expect(imageInfo !== null).assertTrue(); + done(); + }) +``` + +### getImageProperty7+ + +getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\ + +Obtains the value of a property with the specified index in this image. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image + + **Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------------------------------------------- | ---- | ------------------------------------ | +| key | string | Yes | Name of the property. | +| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | No | Image properties, including the image index and default property value.| + +**Return value** + +| Type | Description | +| ---------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the property value. If the operation fails, the default value is returned.| + +**Example** + +```js +const w = imageSourceApi.getImageProperty("ImageWidth") +``` + +### getImageProperty7+ + +getImageProperty(key:string, callback: AsyncCallback\): void + +Obtains the value of a property with the specified index in this image. This API uses a callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image + + **Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| key | string | Yes | Name of the property. | +| callback | AsyncCallback\ | Yes | Callback used to return the property value. If the operation fails, the default value is returned.| + +**Example** + +```js +const w = imageSourceApi.getImageProperty("ImageWidth",w=>{}) +``` + +### getImageProperty7+ + +getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCallback\): void + +Obtains the value of a property in this image. This API uses a callback to return the property value in a string. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | +| key | string | Yes | Name of the property. | +| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | Yes | Image properties, including the image index and default property value. | +| callback | AsyncCallback\ | Yes | Callback used to return the property value. If the operation fails, the default value is returned.| + +**Example** + +```js + imageSourceApi.getImageProperty("ImageWidth",PropertyOptions,(w)=>{}) +``` + +### createPixelMap7+ + +createPixelMap(index: number, options: DecodingOptions, callback: AsyncCallback\): void + +Creates a **PixelMap** object based on image decoding parameters. This API uses a callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------- | ------------------------------------- | ---- | -------------------- | +| options | [DecodingOptions](#decodingoptions7) | Yes | Image decoding parameters. | +| index | number | Yes | Image index. | +| AsyncCallback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the operation result.| + +**Example** + +```js +imageSourceApi.createPixelMap().then(pixelmap => { + console.info('TC_050-11 createPixelMap '); + expect(pixelmap !== null ).assertTrue(); + done(); + }) +``` + +### createPixelMap7+ + +createPixelMap(options: DecodingOptions, callback: AsyncCallback\): void + +Creates a **PixelMap** object based on image decoding parameters. This API uses a callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------- | ---- | -------------------- | +| options | [DecodingOptions](#decodingoptions7) | Yes | Image decoding parameters. | +| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the operation result.| + +**Example** + +```js +let decodingOptions = { + sampleSize:1, + editable: true, + desiredSize:{ width:1, height:2}, + rotateDegrees:10, + desiredPixelFormat:1, + desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 }, + }; + imageSourceApi.createPixelMap(0,decodingOptions, pixelmap => { + console.info('TC_050-1 createPixelMap '); + expect(pixelmap !== null ).assertTrue(); + done(); + }) +``` + +### createPixelMap7+ + +createPixelMap(opts: DecodingOptions, callback: AsyncCallback\): void + +Creates a **PixelMap** object based on image decoding parameters. This API uses a callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------- | ---- | -------------------- | +| opts | [DecodingOptions](#decodingoptions7) | Yes | Image decoding parameters. | +| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the operation result.| + +**Example** + +```js +let decodingOptions = { + sampleSize:1, + editable: true, + desiredSize:{ width:1, height:2}, + rotateDegrees:10, + desiredPixelFormat:1, + desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 }, + index:1 + }; + imageSourceApi.createPixelMap(decodingOptions, pixelmap => { + console.info('TC_050-1 createPixelMap '); + expect(pixelmap !== null ).assertTrue(); + done(); + }) +``` + +### release + +release(callback: AsyncCallback\): void + +Releases this **ImageSource** instance. This API uses a callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ---------------------------------- | +| callback | AsyncCallback\ | Yes | Callback invoked for instance release. If the operation fails, an error message is returned.| + +**Example** + +```js +imageSourceApi.release(() => { + console.info('TC_044-1 Success'); + expect(true).assertTrue(); + done(); + }) + } +``` + +### release + +release(): Promise\ + +Releases this **ImageSource** instance. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise\ | Promise used to return the operation result.| + +**Example** + +```js + imageSourceApi.release(() => { + console.info('TC_044-1 Success'); + expect(true).assertTrue(); + done(); + }) +``` + +## image.createImagePacker + +createImagePacker(): ImagePacker + +Creates an **ImagePacker** instance. + +**System capability**: SystemCapability.Multimedia.Image + +**Return value** + +| Type | Description | +| ----------- | ---------------------- | +| ImagePacker | **ImagePacker** instance created.| + +**Example** + +```js +const imagePackerApi = image.createImagePacker(); +``` + +## ImagePacker + +Provide APIs to pack images. Before calling any API in **ImagePacker**, you must use **createImagePacker** to create an **ImagePacker** instance. + +### Attributes + +| Name | Type | Readable| Writable| Description | +| ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | +| supportedFormats | Array\ | Yes | No | Supported image format, which can be jpeg.
**System capability**: SystemCapability.Multimedia.Image| + +### packing + +packing(source: ImageSource, option: PackingOption, callback: AsyncCallback>): void + +Packs an image. This API uses a callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------- | ---- | ---------------------------------- | +| source | [ImageSource](#imagesource) | Yes | Image to pack. | +| option | [PackingOption](#packingoption) | Yes | Option for image packing. | +| callback | AsyncCallback> | Yes | Callback used to return the packed data.| + +**Example** + +```js +let packOpts = { format:["image/jpeg"], quality:98 } + imagePackerApi.packing(imageSourceApi, packOpts, data => { + console.info('TC_062-1 finished'); + expect(data !== null).assertTrue(); + done(); + }) +``` + +### packing + +packing(source: ImageSource, option: PackingOption): Promise> + +Packs an image. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------------------------- | ---- | -------------- | +| source | [ImageSource](#imagesource) | Yes | Image to pack.| +| option | [PackingOption](#packingoption) | Yes | Option for image packing.| + +**Return value** + +| Type | Description | +| :---------------------- | :-------------------------------------------- | +| Promise> | Promise used to return the packed data.| + +**Example** + +```js +let packOpts = { format:["image/jpeg"], quality:98 } + imagePackerApi.packing(imageSourceApi, packOpts) + .then( data => { + console.info('TC_062 finished'); + expect(data !== null).assertTrue(); + done(); + }) +``` + +### release + +release(callback: AsyncCallback\): void + +Releases this **ImagePacker** instance. This API uses a callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------ | +| callback | AsyncCallback\ | Yes | Callback invoked for instance release. If the operation fails, an error message is returned.| + +**Example** + +```js +imagePackerApi.release(()=>{ + console.info('TC_063-1 release'); + expect(true).assertTrue(); + done(); +``` + +### release + +release(): Promise\ + +Releases this **ImagePacker** instance. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image + +**Return value** + +| Type | Description | +| :------------- | :------------------------------------------------------ | +| Promise\ | Promise used to return the instance release result. If the operation fails, an error message is returned.| + +**Example** + +```js +imagePackerApi.release(); + console.info('TC_063 release'); + expect(true).assertTrue(); + done(); +``` + +## PositionArea7+ + +Describes area information in an image. + +**System capability**: SystemCapability.Multimedia.Image + +| Name | Type | Readable| Writable| Description | +| ------ | ------------------ | ---- | ---- | -------------------- | +| pixels | ArrayBuffer | Yes | No | Pixels of the image. | +| offset | number | Yes | No | Offset for data reading. | +| stride | number | Yes | No | Number of bytes to read. | +| region | [Region](#region8) | Yes | No | Region to read or write.| + +## **ImageInfo** + +Describes image information. + +**System capability**: SystemCapability.Multimedia.Image + +| Name| Type | Readable| Writable| Description | +| ---- | ------------- | ---- | ---- | ---------- | +| size | [Size](#size) | Yes | Yes | Image size.| + +## Size + +Describes the size of an image. + +**System capability**: SystemCapability.Multimedia.Image + +| Name | Type | Readable| Writable| Description | +| ------ | ------ | ---- | ---- | -------------- | +| height | number | Yes | Yes | Image height.| +| width | number | Yes | Yes | Image width.| + +## PixelMapFormat7+ + +Enumerates pixel map formats. + +**System capability**: SystemCapability.Multimedia.Image + +| Name | Default Value| Description | +| --------- | ------ | ----------------- | +| UNKNOWN | 0 | Unknown format. | +| RGBA_8888 | 3 | RGBA_8888.| +| RGB_565 | 2 | RGB_565. | + +## AlphaType8+ + +Enumerates alpha types. + +**System capability**: SystemCapability.Multimedia.Image + +| Name | Default Value| Description | +| -------- | ------ | ----------------------- | +| UNKNOWN | 0 | Unknown alpha type. | +| OPAQUE | 1 | There is no alpha or the image is fully transparent.| +| PREMUL | 2 | Premultiplied alpha. | +| UNPREMUL | 3 | Unpremultiplied alpha, that is, straight alpha. | + +## ScaleMode8+ + +Enumerates scale modes. + +**System capability**: SystemCapability.Multimedia.Image + +| Name | Default Value| Description | +| --------------- | ------ | -------------------------------------------------- | +| CENTER_CROP | 1 | Scales the image so that it fills the requested bounds of the target and crops the extra.| +| FIT_TARGET_SIZE | 2 | Reduces the image size to the dimensions of the target. | + +## InitializationOptions8+ + +**System capability**: SystemCapability.Multimedia.Image + +| Name | Type | Readable| Writable| Description | +| ----------- | ---------------------------------- | ---- | ---- | -------------- | +| alphaType | [AlphaType](#alphatype8) | Yes | Yes | Alpha type. | +| editable | boolean | Yes | Yes | Whether the image is editable. | +| pixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format. | +| scaleMode | [ScaleMode](#scalemode8) | Yes | Yes | Scale mode. | +| size | [Size](#size) | Yes | Yes | Image size.| + +## DecodingOptions7+ + +Describes the decoding options. + +**System capability**: SystemCapability.Multimedia.Image + +| Name | Type | Readable| Writable| Description | +| ------------------ | ---------------------------------- | ---- | ---- | ---------------- | +| sampleSize | number | Yes | Yes | Thumbnail sampling size.| +| rotateDegrees | number | Yes | Yes | Rotation angle. | +| editable | boolean | Yes | Yes | Whether the image is editable. | +| desiredSize | [Size](#size) | Yes | Yes | Expected output size. | +| desiredRegion | [Region](#region8) | Yes | Yes | Region to decode. | +| desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format for decoding.| +| index | numer | Yes | Yes | Index of the image to decode. | + +## Region8+ + +Describes region information. + +**System capability**: SystemCapability.Multimedia.Image + +| Name| Type | Readable| Writable| Description | +| ---- | ------------- | ---- | ---- | ---------- | +| size | [Size](#size) | Yes | Yes | Region size.| +| x | number | Yes | Yes | X coordinate of the region.| +| y | number | Yes | Yes | Y coordinate of the region.| + +## PackingOption + +Describes the option for image packing. + +**System capability**: SystemCapability.Multimedia.Image + +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | -------------- | +| format | string | Yes | Yes | Format of the packed image. | +| quality | number | Yes | Yes | Quality of the packed image.| + +## GetImagePropertyOptions7+ + +Describes image properties. + +**System capability**: SystemCapability.Multimedia.Image + +| Name | Type | Readable| Writable| Description | +| ------------ | ------ | ---- | ---- | ------------ | +| index | number | Yes | Yes | Index of an image. | +| defaultValue | string | Yes | Yes | Default property value.| + +## PropertyKey7+ + +Describes the exchangeable image file format (Exif) information of an image. + +| Name | Default Value | Description | +| ----------------- | ----------------- | -------------------- | +| BITS_PER_SAMPLE | "BitsPerSample" | Number of bytes in each pixel. | +| ORIENTATION | "Orientation" | Image orientation. | +| IMAGE_LENGTH | "ImageLength" | Image length. | +| IMAGE_WIDTH | "ImageWidth" | Image width. | +| GPS_LATITUDE | "GPSLatitude" | Image latitude. | +| GPS_LONGITUDE | "GPSLongitude" | Image longitude. | +| GPS_LATITUDE_REF | "GPSLatitudeRef" | Latitude reference, for example, N or S.| +| GPS_LONGITUDE_REF | "GPSLongitudeRef" | Longitude reference, for example, W or E.| diff --git a/en/application-dev/reference/apis/js-apis-inputconsumer.md b/en/application-dev/reference/apis/js-apis-inputconsumer.md new file mode 100644 index 0000000000000000000000000000000000000000..3e9a9af045b92543f5e9221b5ffa199c4bf9b054 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inputconsumer.md @@ -0,0 +1,82 @@ +# Combination Key + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> - The APIs of this module are system APIs and cannot be called by third-party applications. + + +## Modules to Import + + +``` +import inputConsumer from '@ohos.multimodalInput.inputConsumer'; +``` + + +## inputConsumer.on + +on(type: "key", keyOption: KeyOption, callback: Callback<KeyOption>): void + +Enables listening for combination key events. When a combination key event that meets the specified conditions occurs, **keyOption** will be passed as an input parameter to **callback**. + +**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer + + **Parameters** + | Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the key input event to listen for. Only **key** is supported. | +| keyOption | [KeyOption](#keyoption) | Yes | Key option, which specifies the condition for combination key input. | +| callback | Callback<KeyOption> | Yes | Callback function. When a key input event that meets the specified options occurs, **keyOption** will be passed as an input parameter to **callback**. | + + **Example** + +``` +let keyOption = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} +let callback = function(keyOption) { + console.info("preKeys: " + keyOption.preKeys, "finalKey: " + keyOption.finalKey, + "isFinalKeyDown: " + keyOption.isFinalKeyDown, "finalKeyDownDuration: " + keyOption.finalKeyDownDuration) +} +inputConsumer.on('key', keyOption, callback); +``` + + +## inputConsumer.off + +off(type: "key", keyOption: KeyOption, callback: Callback<KeyOption>): void + +Stops listening for combination key events. + +**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer + + **Parameters** + | Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the key input event to listen for. Only **key** is supported. | +| keyOption | [KeyOption](#keyoption) | Yes | Key option passed to the key input event when listening starts. | +| callback | Callback<KeyOption> | Yes | Callback function passed to the key input event with the key option when listening starts. | + + **Example** + +``` +let keyOption = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} +let callback = function(keyOption) { + console.info("preKeys: " + keyOption.preKeys, "finalKey: " + keyOption.finalKey, + "isFinalKeyDown: " + keyOption.isFinalKeyDown, "finalKeyDownDuration: " + keyOption.finalKeyDownDuration) +} +inputConsumer.off('key', keyOption, callback); +``` + + +## KeyOption + +Defines the key options that are met when a combination key input event occurs. + + **System capability**: SystemCapability.MultimodalInput.Input.InputConsumer + | Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| preKeys | Array | Yes | Array of precedent keys. This parameter can be left empty. There is no requirement on the sequence of precedent keys. | +| finalKey | Number | Yes | Final key in the combination key. This parameter cannot be left blank. | +| isFinalKeyDown | boolean | Yes | Indicates whether the final key is pressed or released. By default, the final key is pressed. | +| finalKeyDownDuration | Number | Yes | Duration for pressing the final key. By default, there is no requirement on the duration. | diff --git a/en/application-dev/reference/apis/js-apis-inputdevice.md b/en/application-dev/reference/apis/js-apis-inputdevice.md new file mode 100644 index 0000000000000000000000000000000000000000..0913e6e3ce52acbcf57959768599dde89fed4d87 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inputdevice.md @@ -0,0 +1,109 @@ +# Input Device + + +The input device management module is used to listen for the connection, disconnection, and updates of input devices and display information about input devices. For example, it can be used to listen for mouse insertion and removal and obtain information such as the ID, name, and pointer speed of the mouse. + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + + +``` +import inputDevice from '@ohos.multimodalInput.inputDevice'; +``` + + +## inputDevice.getDeviceIds + +getDeviceIds(callback: AsyncCallback<Array<number>>): void + +Obtains the IDs of all input devices. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + + **Parameters** + | Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<Array<number>> | Yes | Callback used to return the result. | + + **Example** + +``` +data: { + deviceIds: Array, +}, +callback: function(ids) { + this.deviceIds = ids; +}, +testGetDeviceIds: function () { + console.info("InputDeviceJsTest---start---testGetDeviceIds"); + inputDevice.getDeviceIds(this.callback); + console.info("InputDeviceJsTest---end---testGetDeviceIds"); +} +``` + + +## inputDevice.getDevice + +getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): void + +Obtains the information about an input device. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + + **Parameters** + | Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| deviceId | number | Yes | ID of the input device whose information is to be obtained. | +| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | Yes | Callback used to return the **InputDeviceData** object. | + + **Example** + +``` +InputDeviceData { + deviceId : 0, + name : "NA", + sources : Array, + axisRanges : Array, +}, +callback: function(deviceData) { + this.InputDeviceData = deviceData; +}, +testGetDevice: function () { + // The example is used to obtain the information about the device whose ID is 1. + console.info("InputDeviceJsTest---start---testGetDevice"); + inputDevice.getDevice(1, this.callback); + console.info("InputDeviceJsTest---end---testGetDevice"); +} +``` + + +## InputDeviceData + +Defines the information about an input device. + + **System capability**: SystemCapability.MultimodalInput.Input.InputDevice + | Name | Type | Description | +| -------- | -------- | -------- | +| id | number | Unique identifier of an input device. If the same physical device is repeatedly inserted and removed, its ID changes. | +| name | string | Name of the input device. | +| sources | Array<[SourceType](#sourcetype)> | Source types of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad. | + + +## SourceType + +Enumerates the input source types. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + + | Name | Type | Description | +| -------- | -------- | -------- | +| keyboard | string | The input device is a keyboard. | +| touchscreen | string | The input device is a touchscreen. | +| mouse | string | The input device is a mouse. | +| trackball | string | The input device is a trackball. | +| touchpad | string | The input device is a touchpad. | +| joystick | string | The input device is a joystick. | diff --git a/en/application-dev/reference/apis/js-apis-inputmonitor.md b/en/application-dev/reference/apis/js-apis-inputmonitor.md new file mode 100644 index 0000000000000000000000000000000000000000..b5cee97142e6e57dc15a967f0e99eea21eb05224 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inputmonitor.md @@ -0,0 +1,142 @@ +# Input Monitor + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> - The APIs of this module are system APIs and cannot be called by third-party applications. + + +## Modules to Import + + +``` +import inputMonitor from '@ohos.multimodalInput.inputMonitor'; +``` + + +## Required Permissions + +ohos.permission.INPUT_MONITORING + + +## inputMonitor.on + +on(type: "touch", receiver: TouchEventReceiver): void + +Starts listening for global input events. + +**Required permissions**: ohos.permission.INPUT_MONITORING + +**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor + + **Parameters** + | Parameter | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the input event. Currently, only **touch** events are supported. | +| receiver | [TouchEventReceiver](#toucheventreceiver) | Yes | Callback used to return the touch event. | + + **Example** + +``` +callback: function (value) { + if (checkEvent(value)) { + // The event meets the service requirement and is consumed. + return true; + } else { + // The event does not meet the service requirement and is not consumed. + return false; + } +}, +testOn: function () { + console.info("InputMonitorJsTest---start---testOn"); + inputMonitor.on( + "touch", + this.callback + ); + console.info("InputMonitorJsTest---end---testOn"); +} +``` + + +## inputMonitor.off + +off(type: "touch", receiver: TouchEventReceiver): void + +Stops listening for global input events. + +**Required permissions**: ohos.permission.INPUT_MONITORING + +**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor + + **Parameters** + | Parameter | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| type | string | Yes | Type of the input event. Currently, only **touch** events are supported. | +| receiver | [TouchEventReceiver](#toucheventreceiver) | No | Callback used to return the touch event. | + + **Example** + +``` +callback: function (value) { + if (checkEvent(value)) { + // The event meets the service requirement and is consumed. + return true; + } else { + // The event does not meet the service requirement and is not consumed. + return false; + } +}, +testOff: function () { + console.info("InputMonitorJsTest---start---testOff"); + inputMonitor.off( + "touch", + this.callback + ); + console.info("InputMonitorJsTest---end---testOff"); +} +``` + + +## TouchEventReceiver + +Represents the class of the callback used to return the touch event. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite. + + +### (touchEvent: TouchEvent): Boolean + +Represents the callback used to return the touch event. You need to define the name of the callback function in the correct format. Ensure that the input parameter is of the **TouchEvent** type, and the return value is of the **Boolean** type. + +**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor + + **Parameters** +| Parameter | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | Yes | Callback used to return the touch event. | + + **Return value** + | Type | Description | +| -------- | -------- | +| Boolean | Result indicating whether the touch event has been consumed by the input monitor. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite. | + + **Example** + +``` +callback: function (value) {// Implementation of the (touchEvent:TouchEvent): Boolean API. + if (checkEvent(value)) { + // The event meets the service requirement and is consumed. + return true; + } else { + // The event does not meet the service requirement and is not consumed. + return false; + } +}, +testOff: function () { + console.info("InputMonitorJsTest---start---testOff"); + inputMonitor.off( + "touch", + this.callback + ); + console.info("InputMonitorJsTest---end---testOff"); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index 719154b9fcaf6c484cdf5b7c195be310d1c96c0e..8843ab1880e04594ebe4946acb4246fafa914eed 100644 --- a/en/application-dev/reference/apis/js-apis-intl.md +++ b/en/application-dev/reference/apis/js-apis-intl.md @@ -18,23 +18,39 @@ import Intl from '@ohos.intl'; ### Attributes +**System capability**: SystemCapability.Global.I18n + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| language | string | Yes| No| Language associated with the locale, for example, **zh**.
**System capability**: SystemCapability.Global.I18n| -| script | string | Yes| No| Script type of the language, for example, **Hans**.
**System capability**: SystemCapability.Global.I18n| -| region | string | Yes| No| Region associated with the locale, for example, **CN**.
**System capability**: SystemCapability.Global.I18n| -| baseName | string | Yes| No| Basic key information about the locale, which consists of the language, script, and region, for example, **zh-Hans-CN**.
**System capability**: SystemCapability.Global.I18n| -| caseFirst | string | Yes| No| Whether case is taken into account for the locale's collation rules. The value can be **upper**, **lower**, or **false**.
**System capability**: SystemCapability.Global.I18n| -| calendar | string | Yes| No| Calendar for the locale. The value can be any of the following: buddhist, chinese, coptic, dangi, ethioaa, ethiopic, gregory, hebrew, indian, islamic, islamic-umalqura, islamic-tbla, islamic-civil, islamic-rgsa, iso8601, japanese, persian, roc, islamicc.
**System capability**: SystemCapability.Global.I18n| -| collation | string | Yes| No| Rule for sorting regions. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, zhuyin.
**System capability**: SystemCapability.Global.I18n| -| hourCycle | string | Yes| No| Time system for the locale. The value can be any of the following: h12, h23, h11, and h24.
**System capability**: SystemCapability.Global.I18n| -| numberingSystem | string | Yes| No| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.
**System capability**: SystemCapability.Global.I18n| -| numeric | boolean | Yes| No| Whether to apply special collation rules for numeric characters.
**System capability**: SystemCapability.Global.I18n| +| language | string | Yes| No| Language associated with the locale, for example, **zh**.| +| script | string | Yes| No| Script type of the language, for example, **Hans**.| +| region | string | Yes| No| Region associated with the locale, for example, **CN**.| +| baseName | string | Yes| No| Basic key information about the locale, which consists of the language, script, and region, for example, **zh-Hans-CN**.| +| caseFirst | string | Yes| No| Whether case is taken into account for the locale's collation rules. The value can be **upper**, **lower**, or **false**.| +| calendar | string | Yes| No| Calendar for the locale. The value can be any of the following: **buddhist**, **chinese**, **coptic**, **dangi**, **ethioaa**, **ethiopic**, **gregory**, **hebrew**, **indian**, **islamic**, **islamic-umalqura**, **islamic-tbla**, **islamic-civil**, **islamic-rgsa**, **iso8601**, **japanese**, **persian**, **roc**, **islamicc**.| +| collation | string | Yes| No| Rule for sorting regions. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **searchjl**, **stroke**, **trad**, **unihan**, **zhuyin**.| +| hourCycle | string | Yes| No| Time system for the locale. The value can be any of the following: **h12**, **h23**, **h11**, **h24**.| +| numberingSystem | string | Yes| No| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.| +| numeric | boolean | Yes| No| Whether to apply special collation rules for numeric characters.| + + +### constructor8+ + +constructor() + +Creates a Locale object. + +**System capability**: SystemCapability.Global.I18n + +- Example + ``` + var locale = new Intl.Locale(); + ``` ### constructor -constructor(locale: string, options?: options) +constructor(locale: string, options?: LocaleOptions) Creates a Locale object. @@ -44,7 +60,7 @@ Creates a Locale object. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | locale | string | Yes| A string containing locale information, including the language, optional script, and region.| - | options | options | No| Options for creating the **Locale** object.| + | options | LocaleOptions | No| Options for creating the **Locale** object.| - Example ``` @@ -112,32 +128,42 @@ Minimizes information of the **Locale** object. If the script and locale informa ``` +## LocaleOptions + +Represents the locale options. + +**System capability**: SystemCapability.Global.I18n + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| calendar | string | Yes| Yes| Calendar for the locale. The calue can be any of the following: **buddhist**, **chinese**, **coptic**, **dangi**, **ethioaa**, **ethiopic**, **gregory**, **hebrew**, **indian**, **islamic**, **islamic-umalqura**, **islamic-tbla**, **islamic-civil**, **islamic-rgsa**, **iso8601**, **japanese**, **persian**, **roc**, **islamicc**.| +| collation | string | Yes| Yes| Collation rule. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **emoji**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **search**, **searchjl**, **standard**, **stroke**, **trad**, **unihan**, **zhuyin**.| +| hourCycle | string | Yes| Yes| Time system for the locale. The value can be any of the following: **h11**, **h12**, **h23**, **h24**.| +| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.| +| numeric | boolean | Yes| Yes| Whether to use the 12-hour clock.| +| caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.| + + ## DateTimeFormat -### constructor +### constructor8+ -constructor(locale: string, options?: DateTimeOptions) +constructor() Creates a **DateTimeOptions** object for the specified locale. **System capability**: SystemCapability.Global.I18n -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | locale | string | Yes| A string containing locale information, including the language, optional script, and region.| - | options | [DateTimeOptions](#datetimeoptions) | No| Options for creating a **DateTimeFormat** object.| - - Example ``` - var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' }); + var datefmt= new Intl.DateTimeFormat(); ``` ### constructor -constructor(locales: Array<string>, options?: DateTimeOptions) +constructor(locale: string | Array, options?: DateTimeOptions) Creates a **DateTimeOptions** object for the specified locale. @@ -146,9 +172,15 @@ Creates a **DateTimeOptions** object for the specified locale. - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | locales | Array<string> | Yes| An array of strings containing locale information.| + | locale | string \| Array | Yes| A string containing locale information, including the language, optional script, and region.| | options | [DateTimeOptions](#datetimeoptions) | No| Options for creating a **DateTimeFormat** object.| +- Example + ``` + var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' }); + ``` + + - Example ``` var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); @@ -183,7 +215,7 @@ Formats the specified date and time. ### formatRange -formatRange(fromDate: Date, toDate: Date): string +formatRange(startDate: Date, endDate: Date): string Formats the specified date range. @@ -233,69 +265,65 @@ Obtains the formatting options for **DateTimeFormat** object. Provides the options for the **DateTimeFormat** object. +**System capability**: SystemCapability.Global.I18n + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.
**System capability**: SystemCapability.Global.I18n| -| dateStyle | string | Yes| Yes| Date display format. The value can be **long**, **short**, **medium**, or **full**.
**System capability**: SystemCapability.Global.I18n| -| timeStyle | string | Yes| Yes| Time display format. The value can be **long**, **short**, **medium**, or **full**.
**System capability**: SystemCapability.Global.I18n| -| hourCycle | string | Yes| Yes| Time system for the locale. The value can be any of the following: h11, h12, h23, h24.
**System capability**: SystemCapability.Global.I18n| -| timeZone | string | Yes| Yes| Time zone represented by a valid IANA time zone ID.
**System capability**: SystemCapability.Global.I18n| -| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.
**System capability**: SystemCapability.Global.I18n| -| hour12 | boolean | Yes| Yes| Whether to use the 12-hour clock.
**System capability**: SystemCapability.Global.I18n| -| weekday | string | Yes| Yes| Workday display format. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| -| era | string | Yes| Yes| Era display format. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| -| year | string | Yes| Yes| Year display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| -| month | string | Yes| Yes| Month display format. The value can be any of the following: numeric, 2-digit, long, short, narrow.
**System capability**: SystemCapability.Global.I18n| -| day | string | Yes| Yes| Day display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| -| hour | string | Yes| Yes| Hour display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| -| minute | string | Yes| Yes| Minute display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| -| second | string | Yes| Yes| Seconds display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| -| timeZoneName | string | Yes| Yes| Localized representation of a time zone name.
**System capability**: SystemCapability.Global.I18n| -| dayPeriod | string | Yes| Yes| Time period display format. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| -| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| -| formatMatcher | string | Yes| Yes| Format matching algorithm. The value can be **basic** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.| +| dateStyle | string | Yes| Yes| Date display format. The value can be **long**, **short**, **medium**, or **full**.| +| timeStyle | string | Yes| Yes| Time display format. The value can be **long**, **short**, **medium**, or **full**.| +| hourCycle | string | Yes| Yes| Time system for the locale. The value can be any of the following: **h11**, **h12**, **h23**, **h24**.| +| timeZone | string | Yes| Yes| Time zone represented by a valid IANA time zone ID.| +| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.| +| hour12 | boolean | Yes| Yes| Whether to use the 12-hour clock.| +| weekday | string | Yes| Yes| Workday display format. The value can be **long**, **short**, or **narrow**.| +| era | string | Yes| Yes| Era display format. The value can be **long**, **short**, or **narrow**.| +| year | string | Yes| Yes| Year display format. The value can be **numeric** or **2-digit**. | +| month | string | Yes| Yes| Month display format. The value can be any of the following: **numeric**, **2-digit**, **long**, **short**, **narrow**.| +| day | string | Yes| Yes| Day display format. The value can be **numeric** or **2-digit**.| +| hour | string | Yes| Yes| Hour display format. The value can be **numeric** or **2-digit**.| +| minute | string | Yes| Yes| Minute display format. The value can be **numeric** or **2-digit**.| +| second | string | Yes| Yes| Seconds display format. The value can be **numeric** or **2-digit**.| +| timeZoneName | string | Yes| Yes| Localized representation of a time zone name.| +| dayPeriod | string | Yes| Yes| Time period display format. The value can be **long**, **short**, or **narrow**.| +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.| +| formatMatcher | string | Yes| Yes| Format matching algorithm. The value can be **basic** or **best fit**.| ## NumberFormat -### constructor +### constructor8+ -constructor(locale: string, options?: NumberOptions) +constructor() Creates a **NumberFormat** object for the specified locale. **System capability**: SystemCapability.Global.I18n -Parameters -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| locale | string | Yes| A string containing locale information, including the language, optional script, and region.| -| options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.| - - Example ``` - var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"}); + var numfmt = new Intl.NumberFormat(); ``` ### constructor -constructor(locales: Array<string>, options?: NumberOptions) +constructor(locale: string | Array, options?: NumberOptions) Creates a **NumberFormat** object for the specified locale. **System capability**: SystemCapability.Global.I18n -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | locales | Array<string> | Yes| An array of strings containing locale information.| - | options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.| +Parameters +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| locale | string \| Array | Yes| A string containing locale information, including the language, optional script, and region.| +| options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.| - Example ``` - var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); + var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"}); ``` @@ -350,27 +378,29 @@ Obtains the options of the **NumberFormat** object. Provides the device capability. +**System capability**: SystemCapability.Global.I18n + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.
**System capability**: SystemCapability.Global.I18n| -| currency | string | Yes| Yes| Currency unit, for example, **EUR**, **CNY**, or **USD**.
**System capability**: SystemCapability.Global.I18n| -| currencySign | string | Yes| Yes| Currency unit symbol. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.
**System capability**: SystemCapability.Global.I18n| -| currencyDisplay | string | Yes| Yes| Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.
**System capability**: SystemCapability.Global.I18n| -| unit | string | Yes| Yes| Unit name, for example, **meter**, **inch**, or **hectare**.
**System capability**: SystemCapability.Global.I18n| -| unitDisplay | string | Yes| Yes| Unit display format. The value can be **long**, **short**, or **medium**.
**System capability**: SystemCapability.Global.I18n| -| unitUsage | string | Yes| Yes| Unit usage scenario. The value can be any of the following: default, area-land-agricult, area-land-commercl, area-land-residntl, length-person, length-person-small, length-rainfall, length-road, length-road-small, length-snowfall, length-vehicle, length-visiblty, length-visiblty-small, length-person-informal, length-person-small-informal, length-road-informal, speed-road-travel, speed-wind, temperature-person, temperature-weather, volume-vehicle-fuel.
**System capability**: SystemCapability.Global.I18n| -| signDisplay | string | Yes| Yes| Number sign display format. The value can be **auto**, **never**, always**, or **expectZero**.
**System capability**: SystemCapability.Global.I18n| -| compactDisplay | string | Yes| Yes| Compact display format. The value can be **long** or **short**.
**System capability**: SystemCapability.Global.I18n| -| notation | string | Yes| Yes| Number formatting specification. The value can be **standard**, **scientific**, engineering**, or **compact**.
**System capability**: SystemCapability.Global.I18n| -| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| -| style | string | Yes| Yes| Number display format. The value can be **decimal**, **currency**, **percent**, or **unit**.
**System capability**: SystemCapability.Global.I18n| -| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.
**System capability**: SystemCapability.Global.I18n| -| useGrouping | boolean | Yes| Yes| Whether to use grouping for display.
**System capability**: SystemCapability.Global.I18n| -| miniumumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| -| miniumumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **1** to **20**.
**System capability**: SystemCapability.Global.I18n| -| maxiumumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| -| miniumumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| -| maxiumumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.| +| currency | string | Yes| Yes| Currency unit, for example, **EUR**, **CNY**, or **USD**.| +| currencySign | string | Yes| Yes| Currency unit symbol. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.| +| currencyDisplay | string | Yes| Yes| Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.| +| unit | string | Yes| Yes| Unit name, for example, **meter**, **inch**, or **hectare**.| +| unitDisplay | string | Yes| Yes| Unit display format. The value can be **long**, **short**, or **medium**.| +| unitUsage | string | Yes| Yes| Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.| +| signDisplay | string | Yes| Yes| Number sign display format. The value can be **auto**, **never**, always**, or **expectZero**.| +| compactDisplay | string | Yes| Yes| Compact display format. The value can be **long** or **short**.| +| notation | string | Yes| Yes| Number formatting specification. The value can be **standard**, **scientific**, engineering**, or **compact**.| +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.| +| style | string | Yes| Yes| Number display format. The value can be **decimal**, **currency**, **percent**, or **unit**.| +| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.| +| useGrouping | boolean | Yes| Yes| Whether to use grouping for display.| +| minimumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.| +| minimumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**.| +| maximumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.| +| minimumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.| +| maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.| ## Collator8+ @@ -392,7 +422,7 @@ Creates a Collator object. ### constructor8+ -constructor(locale: string | Array<string>, options?: CollatorOptions) +constructor(locale: string | Array, options?: CollatorOptions) Creates a Collator object. @@ -402,12 +432,12 @@ Creates a Collator object. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | locale | string\|Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| + | locale | string \| Array | Yes| A string containing locale information, including the language, optional script, and region.| | options | [CollatorOptions](#collatoroptions) | No| Options for creating a **Collator** object.| - Example ``` - var collator = new Intl.Collator("zh-CN", {"localeMatcher": "lookup", "usage": "sort"}); + var collator = new Intl.Collator("zh-CN", {localeMatcher: "lookup", usage: "sort"}); ``` @@ -461,15 +491,17 @@ Returns properties reflecting the locale and collation options of a **Collator** Represents the properties of a **Collator** object. +**System capability**: SystemCapability.Global.I18n + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| -| usage | string | Yes| Yes| Whether the comparison is for sorting or for searching. The value can be **sort** or **search**.
**System capability**: SystemCapability.Global.I18n| -| sensitivity | string | Yes| Yes| Differences in the strings that lead to non-zero return values. The value can be **base**, **accent**, **case**, or **variant**.
**System capability**: SystemCapability.Global.I18n| -| ignorePunctuation | boolean | Yes| Yes| Whether punctuation is ignored. The value can be **true** or **false**.
**System capability**: SystemCapability.Global.I18n| -| collation | string | Yes| Yes| Rule for sorting regions. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, zhuyin.
**System capability**: SystemCapability.Global.I18n| -| numeric | boolean | Yes| Yes| Whether numeric collation is used. The value can be **true** or **false**.
**System capability**: SystemCapability.Global.I18n| -| caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.
**System capability**: SystemCapability.Global.I18n| +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.| +| usage | string | Yes| Yes| Whether the comparison is for sorting or for searching. The value can be **sort** or **search**.| +| sensitivity | string | Yes| Yes| Differences in the strings that lead to non-zero return values. The value can be **base**, **accent**, **case**, or **variant**.| +| ignorePunctuation | boolean | Yes| Yes| Whether punctuation is ignored. The value can be **true** or **false**.| +| collation | string | Yes| Yes| Rule for sorting regions. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **searchjl**, **stroke**, **trad**, **unihan**, **zhuyin**.| +| numeric | boolean | Yes| Yes| Whether numeric collation is used. The value can be **true** or **false**.| +| caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.| ## PluralRules8+ @@ -491,7 +523,7 @@ Create a **PluralRules** object. ### constructor8+ -constructor(locale: string | Array<string>, options?: PluralRulesOptions) +constructor(locale: string | Array, options?: PluralRulesOptions) Create a **PluralRules** object. @@ -500,7 +532,7 @@ Create a **PluralRules** object. Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| locale | string\|Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| +| locale | string \| Array | Yes| A string containing locale information, including the language, optional script, and region.| | options | [PluralRulesOptions](#pluralrulesoptions) | No| Options for creating a **PluralRules** object.| - Example @@ -525,7 +557,7 @@ Obtains a string that represents the singular-plural type of the specified numbe - Return value | Type| Description| | -------- | -------- | - | string | Singular-plural type. The value can be any of the following: one, two, few, many, others.| + | string | Singular-plural type. The value can be any of the following: **one**, **two**, **few**, **many**, **others**.| - Example ``` @@ -538,15 +570,17 @@ Obtains a string that represents the singular-plural type of the specified numbe Represents the properties of a **PluralRules** object. +**System capability**: SystemCapability.Global.I18n + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| -| type | string | Yes| Yes| Sorting type. The value can be **cardinal** or **ordinal**.
**System capability**: SystemCapability.Global.I18n| -| minimumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| -| minimumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**.
**System capability**: SystemCapability.Global.I18n| -| maximumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| -| minimumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| -| maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.| +| type | string | Yes| Yes| Sorting type. The value can be **cardinal** or **ordinal**.| +| minimumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.| +| minimumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**.| +| maximumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.| +| minimumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.| +| maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.| ## RelativeTimeFormat8+ @@ -568,7 +602,7 @@ Creates a **RelativeTimeFormat** object. ### constructor8+ -constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions) +constructor(locale: string | Array, options?: RelativeTimeFormatInputOptions) Creates a **RelativeTimeFormat** object. @@ -577,7 +611,7 @@ Creates a **RelativeTimeFormat** object. Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| locale | string\|Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| +| locale | string \| Array | Yes| A string containing locale information, including the language, optional script, and region.| | options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | No| Options for creating a **RelativeTimeFormat** object.| - Example @@ -588,7 +622,7 @@ Parameters ### format8+ -format(value: numeric, unit: string): string +format(value: number, unit: string): string Formats the value and unit based on the specified locale and formatting options. @@ -597,8 +631,8 @@ Formats the value and unit based on the specified locale and formatting options. - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | value | numeric | Yes| Value to format.| - | unit | string | Yes| Unit to format. The value can be any of the following: year, quarter, month, week, day, hour, minute, second.| + | value | number | Yes| Value to format.| + | unit | string | Yes| Unit to format. The value can be any of the following: **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, **second**.| - Return value | Type| Description| @@ -614,7 +648,7 @@ Formats the value and unit based on the specified locale and formatting options. ### formatToParts8+ -formatToParts(value: numeric, unit: string): Array<Object> +formatToParts(value: number, unit: string): Array Returns an array of RelativeTimeFormat objects in parts for locale-aware formatting. @@ -623,13 +657,13 @@ Returns an array of RelativeTimeFormat objects in parts for locale-aware formatt - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | value | numeric | Yes| Value to format.| - | unit | string | Yes| Unit to format. The value can be any of the following: year, quarter, month, week, day, hour, minute, second.| + | value | number | Yes| Value to format.| + | unit | string | Yes| Unit to format. The value can be any of the following: **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, **second**.| - Return value | Type| Description| | -------- | -------- | - | Array<Object> | An array of **RelativeTimeFormat** objects in parts.| + | Array | An array of **RelativeTimeFormat** objects in parts.| - Example ``` @@ -662,20 +696,24 @@ Obtains the formatting options for **RelativeTimeFormat** objects. Represents the properties of a **RelativeTimeFormat** object. +**System capability**: SystemCapability.Global.I18n + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| -| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.
**System capability**: SystemCapability.Global.I18n| -| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.| +| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.| +| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.| ## RelativeTimeFormatResolvedOptions8+ Represents the properties of a **RelativeTimeFormat** object. +**System capability**: SystemCapability.Global.I18n + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| locale | string | Yes| Yes| A string containing locale information, including the language, optional script, and region.
**System capability**: SystemCapability.Global.I18n| -| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.
**System capability**: SystemCapability.Global.I18n| -| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| -| numberingSystem | string | Yes| Yes| Numbering system.
**System capability**: SystemCapability.Global.I18n| +| locale | string | Yes| Yes| A string containing locale information, including the language, optional script, and region.| +| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.| +| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.| +| numberingSystem | string | Yes| Yes| Numbering system.| diff --git a/en/application-dev/reference/apis/js-apis-medialibrary.md b/en/application-dev/reference/apis/js-apis-medialibrary.md new file mode 100644 index 0000000000000000000000000000000000000000..219f699cdd68b377a94846c4aeadb1341c713ece --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-medialibrary.md @@ -0,0 +1,2219 @@ +# Media Library Management + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version. + +## Modules to Import +``` +import mediaLibrary from '@ohos.multimedia.medialibrary'; +``` + +## mediaLibrary.getMediaLibrary + +getMediaLibrary(context: Context): MediaLibrary + +Obtains a **MediaLibrary** instance, which is used to access and modify personal data of users. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------- | ---- | ------------------------------------------------------------ | +| context | Context | Yes | Context of the ability. This parameter is optional for API version 7 and earlier versions, but mandatory for API version 8 and later versions.| + +**Return value** + +| Type | Description | +| ----------------------------- | :--------- | +| [MediaLibrary](#medialibrary) | **MediaLibrary** instance.| + +**Example** + +``` +import featureAbility from '@ohos.ability.featureAbility'; + +var context = featureAbility.getContext() +var media = mediaLibrary.getMediaLibrary(context); +``` +## MediaLibrary + +### getFileAssets8+ + + +getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileResult>): void + +Obtains file assets (also called files). This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | --------------------------------- | +| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files. | +| callback | AsyncCallback<[FetchFileResult](#fetchfileresult8)> | Yes | Asynchronous callback of **FetchFileResult**.| + +**Example** + +``` +let fileKeyObj = mediaLibrary.FileKey +let imageType = mediaLibrary.MediaType.IMAGE +let imagesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], +}; +mediaLibrary.getFileAssets(imagesfetchOp, (error, fetchFileResult) => { + if (fetchFileResult != undefined) { + console.info('mediaLibraryTest : ASSET_CALLBACK fetchFileResult success'); + fetchFileResult.getAllObject((err, fileAssetList) => { + if (fileAssetList != undefined) { + fileAssetList.forEach(getAllObjectInfo); + } + }); + } +}); +``` +### getFileAssets8+ + +getFileAssets(options: MediaFetchOptions): Promise<FetchFileResult> + +Obtains file assets. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------------------------------- | ---- | ------------ | +| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files.| + +**Return value** + +| Type | Description | +| ------------------------------------ | -------------- | +| [FetchFileResult](#fetchfileresult8) | Result set of the file retrieval operation.| + +**Example** + +``` +let fileKeyObj = mediaLibrary.FileKey +let imageType = mediaLibrary.MediaType.IMAGE +let imagesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], +}; +mediaLibrary.getFileAssets(imagesfetchOp).then(function(fetchFileResult){ + console.info("getFileAssets successfully:"+ JSON.stringify(dir)); +}).catch(function(err){ + console.info("getFileAssets failed with error:"+ err); +}); +``` + +### on8+ + +on(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange', callback: Callback<void>): void + +Subscribes to the media library changes. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Media type.
'deviceChange': registered device change
'albumChange': album change
'imageChange': image file change
'audioChange': audio file change
'videoChange': video file change
'fileChange': file change
'remoteFileChange': file change on the registered device| +| callback | callback<void> | Yes | Void callback. | + +**Example** + +``` +mediaLibrary.on('imageChange', () => { + // image file had changed, do something +}) +``` +### off8+ + +off(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange', callback?: Callback<void>): void + +Unsubscribes from the media library changes. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Media type.
'deviceChange': registered device change
'albumChange': album change
'imageChange': image file change
'audioChange': audio file change
'videoChange': video file change
'fileChange': file change
'remoteFileChange': file change on the registered device| +| callback | callback<void> | No | Void callback. | + +**Example** + +``` +mediaLibrary.off('imageChange', () => { + // stop listening success +}) +``` + +### createAsset 8+ + +createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback<FileAsset>): void + +Creates a media asset. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------------- | ---- | ------------------------------------------------------------ | +| mediaType | [MediaType](#mediatype) | Yes | Media type. | +| displayName | string | Yes | Display file name. | +| relativePath | string | Yes | Path for storing the file. You can use [getPublicDirectory](#getpublicdirectory8) to obtain the paths for storing different types of files.| +| callback | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Asynchronous callback for **FileAsset**. | + +**Example** + +``` +async function example() { + // Create an image file in callback mode. + let mediaType = mediaLibrary.MediaType.IMAGE; + let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; + const path = await media.getPublicDirectory(DIR_IMAGE); + mediaLibrary.createAsset(mediaType, 'imageCallBack.jpg', path + 'myPicture/', (err, fileAsset) => { + if (fileAsset != undefined) { + console.info('createAsset successfully, message = ' + err); + } else { + console.info('createAsset failed, message = ' + err); + } + }); +} +``` + +### createAsset8+ + +createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise<FileAsset> + +Creates a media asset. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ----------------------- | ---- | ------------------------------------------------------------ | +| mediaType | [MediaType](#mediatype) | Yes | Media type. | +| displayName | string | Yes | Display file name. | +| relativePath | string | Yes | Relative path. You can use [getPublicDirectory](#getpublicdirectory8) to obtain the relative path of the level-1 directory of different types of media files.| + +**Return value** + +| Type | Description | +| ------------------------ | ----------------- | +| [FileAsset](#fileasset8) | Media data (FileAsset).| + +**Example** + +``` +async function example() { + // Create an image file in promise mode + let mediaType = mediaLibrary.MediaType.IMAGE; + let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; + const path = await media.getPublicDirectory(DIR_IMAGE); + mediaLibrary.createAsset(mediaType, "image01.jpg", path + 'myPicture/').then (function (asset) { + console.info("createAsset successfully:"+ JSON.stringify(asset)); + }).catch(function(err){ + console.info("createAsset failed with error:"+ err); + }); +} +``` + +### getPublicDirectory8+ + +getPublicDirectory(type: DirectoryType, callback: AsyncCallback<string>): void + +Obtains a public directory. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------- | ---- | ------------------------- | +| type | [DirectoryType](#directorytype) | Yes | Type of the public directory. | +| callback | AsyncCallback<string> | Yes | Callback used to return the public directory.| + +**Example** + +``` +let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; +media.getPublicDirectory(DIR_CAMERA, (err, dicResult) => { + if (dicResult == 'Camera/') { + console.info('mediaLibraryTest : getPublicDirectory passed'); + } else { + console.info('mediaLibraryTest : getPublicDirectory failed'); + } +}); +``` + +### getPublicDirectory8+ + +getPublicDirectory(type: DirectoryType): Promise<string> + +Obtains a public directory. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------------------------- | ---- | ------------ | +| type | [DirectoryType](#directorytype) | Yes | Type of the public directory.| + +**Return value** + +| Type | Description | +| --------------- | ---------------- | +| Promise | Promise used to return the public directory.| + +**Example** + +``` +async function example() { + let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; + const dicResult = await media.getPublicDirectory(DIR_CAMERA); + if (dicResult == 'Camera/') { + console.info('MediaLibraryTest : getPublicDirectory'); + } else { + console.info('MediaLibraryTest : getPublicDirectory failed'); + } +} +``` + +### getAlbums8+ + +getAlbums(options: MediaFetchOptions, callback: AsyncCallback): void + +Obtains the albums. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------- | ---- | --------------------------- | +| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the albums. | +| callback | AsyncCallback<Array<[Album](#album8)>> | Yes | Callback used to return the albums.| + +**Example** + +``` +let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], +}; +mediaLibrary.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => { + if (albumList != undefined) { + const album = albumList[0]; + console.info('album.albumName = ' + album.albumName); + console.info('album.count = ' + album.count); + } else { + console.info('getAlbum fail, message = ' + err); + } +}) +``` + +### getAlbums8+ + +getAlbums(options: MediaFetchOptions): Promise + +Obtains the albums. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------------------------------- | ---- | ------------ | +| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the albums.| + +**Return value** + +| Type | Description | +| -------------------------------- | ------------- | +| Promise> | Promise used to return the albums.| + +**Example** + +``` +let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], +}; +mediaLibrary.getAlbums(AlbumNoArgsfetchOp).then(function(albumList){ + console.info("getAlbums successfully:"+ JSON.stringify(albumList)); +}).catch(function(err){ + console.info("getAlbums failed with error:"+ err); +}); +``` + +### release8+ + +release(callback: AsyncCallback<void>): void + +Releases this **MediaLibrary** instance. +Call this API when you no longer need to use the APIs in the **MediaLibrary** instance. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| + +**Example** + +``` +var media = mediaLibrary.getMediaLibrary(context); +media.release((err) => { + // do something +}); +``` + +### release8+ + +release(): Promise<void> + +Releases this **MediaLibrary** instance. +Call this API when you no longer need to use the APIs in the **MediaLibrary** instance. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| ------------------- | --------------------------------- | +| Promise<void> | Promise used to return the execution result.| + +**Example** + +``` +var media = mediaLibrary.getMediaLibrary(context); +media.release() +``` + +### storeMediaAsset + +storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback<string>): void + +Stores a media asset. This API uses an asynchronous callback to return the URI that stores the media asset. + +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.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------- | ---- | ------------------------------------------- | +| option | [MediaAssetOption](#mediaassetoption) | Yes | Media asset option. | +| callback | AsyncCallback<string> | Yes | Callback used to return the URI that stores the media asset.| + +**Example** + + ``` +let option = { + src : "file:///data/data/ohos.xxx.yyy/files/image.png", + mimeType : "image/jpeg", + relativePath : "imageDir/image2/" +}; +mediaLibrary.getMediaLibrary().storeMediaAsset(option, (err, value) => { + if (err) { + console.log("An error occurred when storing the media asset."); + return; + } + console.log("Media asset stored. "); + // Obtain the URI that stores the media asset. +}); + ``` + + +### storeMediaAsset + +storeMediaAsset(option: MediaAssetOption): Promise<string> + +Stores a media asset. This API uses a promise to return the URI that stores the media asset. + +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.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------------------------------- | ---- | -------------- | +| option | [MediaAssetOption](#mediaassetoption) | Yes | Media asset option.| + +**Return value** + +| Type | Description | +| --------------------- | ---------------------------------------------- | +| Promise<string> | Promise used to return the URI that stores the media asset.| + +**Example** + + ``` +let option = { + src : "file:///data/data/ohos.xxx.yyy/files/image.jpg", + mimeType : "image/jpeg", + relativePath : "imageDir/image2/" +}; +mediaLibrary.getMediaLibrary().storeMediaAsset(option).then((value) => { + console.log("Media asset stored."); + // Obtain the URI that stores the media asset. +}).catch((err) => { + console.log("An error occurred when storing the media assets."); +}); + ``` + + +### startImagePreview + +startImagePreview(images: Array<string>, index: number, callback: AsyncCallback<void>): void + +Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **dataability://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result. + +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.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | --------------------------------------------------- | +| images | Array<string> | Yes | URIs of the images to preview. The value can start with either **https://** or **dataability://**.| +| index | number | Yes | Index of the first image to preview. | +| callback | AsyncCallback<void> | Yes | Callback used to return the image preview result. If the preview fails, an error message is returned. | + +**Example** + + ``` +let images = [ + "dataability:///media/external/images/media/50", + "dataability:///media/external/images/media/55" +]; +let images = [ + "https://media.xxxx.com/image1.jpg", + "https://media.xxxx.com/image2.jpg" +]; +let index = 1; +mediaLibrary.getMediaLibrary().startImagePreview(images, index, (err) => { + if (err) { + console.log("An error occurred when previewing the images."); + return; + } + console.log("Succeeded in previewing the images."); +}); + ``` + + +### startImagePreview + +startImagePreview(images: Array<string>, callback: AsyncCallback<void>): void + +Starts image preview. This API can be used to preview local images whose URIs start with **dataability://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result. + +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.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | --------------------------------------------------- | +| images | Array<string> | Yes | URIs of the images to preview. The value can start with either **https://** or **dataability://**.| +| callback | AsyncCallback<void> | Yes | Callback used to return the image preview result. If the preview fails, an error message is returned. | + +**Example** + + ``` +let images = [ + "dataability:///media/external/images/media/50", + "dataability:///media/external/images/media/55" +]; +let images = [ + "https://media.xxxx.com/image1.jpg", + "https://media.xxxx.com/image2.jpg" +]; +mediaLibrary.getMediaLibrary().startImagePreview(images, (err) => { + if (err) { + console.log("An error occurred when previewing the images."); + return; + } + console.log("Succeeded in previewing the images."); +}); + ``` + + +### startImagePreview + +startImagePreview(images: Array<string>, index?: number): Promise<void> + +Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with dataability:// or online images whose URIs start with https://. It uses a promise to return the execution result. + +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.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------------- | ---- | --------------------------------------------------- | +| images | Array<string> | Yes | URIs of the images to preview. The value can start with either **https://** or **dataability://**.| +| index | number | No | Index of the first image to preview. If this parameter is not specified, the default value **0** is used. | + +**Return value** + +| Type | Description | +| ------------------- | ------------------------------------------------------- | +| Promise<void> | Promise used to return the image preview result. If the preview fails, an error message is returned.| + +**Example** + + ``` +let images = [ + "dataability:///media/external/images/media/50", + "dataability:///media/external/images/media/55" +]; +let images = [ + "https://media.xxxx.com/image1.jpg", + "https://media.xxxx.com/image2.jpg" +]; +let index = 1; +mediaLibrary.getMediaLibrary().startImagePreview(images, index).then(() => { + console.log("Succeeded in previewing the images."); +}).catch((err) => { + console.log("An error occurred when previewing the images."); +}); + ``` + + +### startMediaSelect + +startMediaSelect(option: MediaSelectOption, callback: AsyncCallback<Array<string>>): void + +Starts media selection. This API uses an asynchronous callback to return the list of URIs that store the selected media assets. + +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.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------- | +| option | [MediaSelectOption](#mediaselectoption) | Yes | Media selection option. | +| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the list of URIs (starting with **dataability://**) that store the selected media assets.| + +**Example** + + ``` +let option = { + type : "image", + count : 2 +}; +mediaLibrary.getMediaLibrary().startMediaSelect(option, (err, value) => { + if (err) { + console.log("An error occurred when selecting the media asset."); + return; + } + console.log("Media asset selected."); + // Obtain the media selection value. +}); + ``` + + +### startMediaSelect + +startMediaSelect(option: MediaSelectOption): Promise<Array<string>> + +Starts media selection. This API uses a promise to return the list of URIs that store the selected media assets. + +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.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | --------------------------------------- | ---- | -------------- | +| option | [MediaSelectOption](#mediaselectoption) | Yes | Media selection option.| + +**Return value** + +| Type | Description | +| ---------------------------------- | ------------------------------------------------------------ | +| Promise<Array<string>> | Promise used to return the list of URIs (starting with **dataability://**) that store the selected media assets.| + +**Example** + + ``` +let option = { + type : "image", + count : 2 +}; +mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => { + console.log("Media asset selected."); + // Obtain the media selection value. +}).catch((err) => { + console.log("An error occurred when selecting the media assets."); +}); + + ``` + +## FileAsset8+ + +Provides APIs for encapsulating file asset attributes. + +### Attributes + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +| Name | Type | Readable| Writable| Description | +| ------------ | ----------------------- | ---- | ---- | ------------------------------------------------------ | +| id | number | Yes | No | File asset ID. | +| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. | +| mimeType | string | Yes | No | Extended file attributes. | +| mediaType | [MediaType](#mediatype) | Yes | No | Media type. | +| displayName | string | Yes | Yes | Display file name, including the file name extension. | +| title | string | Yes | Yes | Title in the file. | +| relativePath | string | Yes | Yes | Relative public directory of the file. | +| parent | number | Yes | No | Parent directory ID. | +| size | number | Yes | No | File size, in bytes. | +| dateAdded | number | Yes | No | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.) | +| dateModified | number | Yes | No | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.) | +| dateTaken | number | Yes | No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) | +| artist | string | Yes | No | Artist of the file. | +| audioAlbum | string | Yes | No | Audio album. | +| width | number | Yes | No | Image width, in pixels. | +| height | number | Yes | No | Image height, in pixels. | +| orientation | number | Yes | Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees).| +| duration | number | Yes | No | Duration, in seconds. | +| albumId | number | Yes | No | ID of the album to which the file belongs. | +| albumUri | string | Yes | No | URI of the album to which the file belongs. | +| albumName | string | Yes | No | Name of the album to which the file belongs. | + + +### isDirectory8+ + +isDirectory(callback: AsyncCallback<boolean>): void + +Checks whether this file asset is a directory. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ----------------------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the file asset is a directory.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isDirectory((err, isDirectory) => { + // do something + }); +} +``` + +### isDirectory8+ + +isDirectory():Promise<boolean> + +Checks whether this file asset is a directory. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| ---------------------- | ---------------------------------------- | +| Promise<boolean> | Promise used to return whether the file asset is a directory.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isDirectory().then(function(isDirectory){ + console.info("isDirectory result:"+ isDirectory); + }).catch(function(err){ + console.info("isDirectory failed with error:"+ err); + }); +} +``` + +### commitModify8+ + +commitModify(callback: AsyncCallback<void>): void + +Commits the modification of this file asset to the database. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Void callback.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.title = 'newtitle'; + asset.commitModify(() => { + console.info('commitModify success'); + }); +} +``` + +### commitModify8+ + +commitModify(): Promise<void> + +Commits the modification of this file asset to the database. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| ------------------- | ------------- | +| Promise<void> | Void promise.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.title = 'newtitle'; + asset.commitModify(); +} +``` + +### open8+ + +open(mode: string, callback: AsyncCallback<number>): void + +Opens this file asset. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA (when **mode** is set to **r**) and ohos.permission.WRITE_MEDIA (when **mode** is set to **w**) + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | -------------------------------------------------------- | +| mode | string | Yes | Mode of opening the file, for example, **r** (read-only), **w** (write-only), and **rw** (read-write).| +| callback | AsyncCallback<number> | Yes | Callback used to return the file handle. | + +**Example** + +``` +async function example() { + let mediaType = mediaLibrary.MediaType.IMAGE; + let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; + const path = await media.getPublicDirectory(DIR_IMAGE); + asset = await media.createAsset(mediaType, "image00003.jpg", path); + asset.open('rw', (openError, fd) => { + if(fd > 0){ + asset.close(fd); + }else{ + console.info('File Open Failed!' + openError); + } + }); +} +``` + +### open8+ + +open(mode: string): Promise<number> + +Opens this file asset. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA (when **mode** is set to **r**) and ohos.permission.WRITE_MEDIA (when **mode** is set to **w**) + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------------------------- | +| mode | string | Yes | Mode of opening the file, for example, **r** (read-only), **w** (write-only), and **rw** (read-write).| + +**Return value** + +| Type | Description | +| --------------------- | ------------------- | +| Promise<number> | Promise used to return the file handle.| + +**Example** + +``` +async function example() { + let mediaType = mediaLibrary.MediaType.IMAGE; + let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; + const path = await media.getPublicDirectory(DIR_IMAGE); + asset = await media.createAsset(mediaType, "image00003.jpg", path); + asset.open('rw') + .then((fd) => { + console.info('File fd!' + fd); + }) + .catch((err) => { + console.info('File err!' + err); + }); +} +``` + +### close8+ + +close(fd: number, callback: AsyncCallback<void>): void + +Closes this file asset. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA ('r' enabled) and ohos.permission.WRITE_MEDIA ('w' enabled) + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| fd | number | Yes | File descriptor.| +| callback | AsyncCallback<void> | Yes | Void callback.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.close(fd, (closeErr) => { + if (closeErr != undefined) { + console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); + console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); + } else { + console.info("=======asset.close success====>"); + } + }); +} +``` + +### close8+ + +close(fd: number): Promise<void> + +Closes this file asset. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA ('r' enabled) and ohos.permission.WRITE_MEDIA ('w' enabled) + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------- | +| fd | number | Yes | File descriptor.| + +**Return value** + +| Type | Description | +| ------------------- | ------------- | +| Promise<void> | Void promise.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.close(fd).then((closeErr) => { + if (closeErr != undefined) { + console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); + console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); + + } else { + console.info("=======asset.close success====>"); + } + }); +} +``` + +### getThumbnail8+ + +getThumbnail(callback: AsyncCallback<image.PixelMap>): void + +Obtains the thumbnail of this file asset. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------- | ---- | ------------------------ | +| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return the pixel map of the thumbnail.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.getThumbnail((err, pixelmap) => { + console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); + }); +} +``` + +### getThumbnail8+ + +getThumbnail(size: Size, callback: AsyncCallback<image.PixelMap>): void + +Obtains the thumbnail of this file asset, with the thumbnail size passed. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------- | ---- | ------------------------ | +| size | [Size](#size8) | Yes | Size of the thumbnail. | +| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return the pixel map of the thumbnail.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.getThumbnail(size, (err, pixelmap) => { + console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); + }); +} +``` + +### getThumbnail8+ + +getThumbnail(size?: Size): Promise<image.PixelMap> + +Obtains the thumbnail of this file asset, with the thumbnail size passed. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | -------------- | ---- | ---------- | +| size | [Size](#size8) | No | Size of the thumbnail.| + +**Return value** + +| Type | Description | +| ----------------------------- | --------------------------- | +| Promise<image.PixelMap> | Promise to return the pixel map of the thumbnail.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.getThumbnail(size, (err, pixelmap) => { + console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); + }); +} +``` + +### favorite8+ + +favorite(isFavorite: boolean, callback: AsyncCallback<void>): void + +Favorites or unfavorites this file asset. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | ---------------------------------------------------------- | +| isFavorite | boolean | Yes | Whether to favorite or unfavorite the file. The value **true** means to favorite the file, and **false** means to unfavorite the file.| +| callback | AsyncCallback<void> | Yes | Void callback. | + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.favorite(true,function(err){ + // do something + }); +} +``` + +### favorite8+ + +favorite(isFavorite: boolean): Promise<void> + +Favorites or unfavorites this file asset. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------- | ---- | ---------------------------------------------------------- | +| isFavorite | boolean | Yes | Whether to favorite or unfavorite the file. The value **true** means to favorite the file, and **false** means to unfavorite the file.| + +**Return value** + +| Type | Description | +| ------------------- | ------------- | +| Promise<void> | Void promise.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.favorite(true).then(function() { + console.info("favorite successfully"); + }).catch(function(err){ + console.info("favorite failed with error:"+ err); + }); +} +``` + +### isFavorite8+ + +isFavorite(callback: AsyncCallback<boolean>): void + +Checks whether this file asset is favorited. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ---------------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the file asset is favorited.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isFavorite((err, isFavorite) => { + if (isFavorite) { + console.info('FileAsset is favorite'); + }else{ + console.info('FileAsset is not favorite'); + } + }); +} +``` + +### isFavorite8+ + +isFavorite():Promise<boolean> + +Checks whether this file asset is favorited. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| ---------------------- | ----------------------------- | +| Promise<boolean> | Promise used to return whether the file asset is favorited.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isFavorite().then(function(isFavorite){ + console.info("isFavorite result:"+ isFavorite); + }).catch(function(err){ + console.info("isFavorite failed with error:"+ err); + }); +} +``` + +### trash8+ + +trash(isTrash: boolean, callback: AsyncCallback<void>): void + +Moves this file asset to the trash. This API uses an asynchronous callback to return the result. + +Files in the trash are not actually deleted. You can set **isTrash** to **false** to restore the files from the trash. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------ | +| isTrash | boolean | Yes | Whether to move the file asset to the trash. The value **true** means to move the file asset to the trash, and **false** means the opposite.| +| callback | AsyncCallback<void> | Yes | Void callback. | + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.trash(true, trashCallBack); + function trashCallBack(err, trash) { + console.info('mediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK trash'); + } +} +``` + +### trash8+ + +trash(isTrash: boolean): Promise<void> + +Moves this file asset to the trash. This API uses a promise to return the result. + +Files in the trash are not actually deleted. You can set **isTrash** to **false** to restore the files from the trash. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------- | ---- | ------------------ | +| isTrash | boolean | Yes | Whether to move the file asset to the trash. The value **true** means to move the file asset to the trash, and **false** means the opposite.| + +**Return value** + +| Type | Description | +| ------------------- | ------------- | +| Promise<void> | Void promise.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.trash(true).then(function() { + console.info("trash successfully"); + }).catch(function(err){ + console.info("trash failed with error:"+ err); + }); +} +``` + +### isTrash8+ + +isTrash(callback: AsyncCallback<boolean>): void + +Checks whether this file asset is in the trash. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ------------------------------ | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the file asset is in the trash. If the file asset is in the trash, **true** will be returned; otherwise, **false** will be returned.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isTrash(isTrashCallBack); + function isTrashCallBack(err, isTrash) { + if (isTrash == true) { + console.info('mediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash = ' + isTrash); + asset.trash(true, trashCallBack); + + } else { + console.info('mediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull = ' + err); + console.info('mediaLibraryTest : ASSET_CALLBACK isTrash : FAIL'); + + } + } +} +``` + +### isTrash8+ + +isTrash():Promise<boolean> + +Checks whether this file asset is in the trash. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| ------------------- | --------------------------------- | +| Promise<void> | Promise used to return whether the file asset is in the trash. If the file asset is in the trash, **true** will be returned; otherwise, **false** will be returned.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isTrash().then(function(isTrash){ + console.info("isTrash result:"+ isTrash); + }).catch(function(err){ + console.info("isTrash failed with error:"+ err); + }); +} +``` + +## FetchFileResult8+ + +Implements the result set of the file retrieval operation. + +### getCount8+ + +getCount(): number + +Obtains the total number of files in the result set. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| ------ | ---------------- | +| number | Total number of files.| + +**Example** + +``` +async function example() { + let getFileCountOneOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getFileCountOneOp); + const fetchCount = fetchFileResult.getCount(); +} +``` + +### isAfterLast8+ + +isAfterLast(): boolean + +Checks whether the cursor is in the last row of the result set. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| ------- | ----------------------------------------------------------- | +| boolean | Returns **true** if the cursor is in the last row of the result set; returns *false** otherwise.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + const fetchCount = fetchFileResult.getCount(); + console.info('mediaLibraryTest : count:' + fetchCount); + let fileAsset = await fetchFileResult.getFirstObject(); + for (var i = 1; i < fetchCount; i++) { + fileAsset = await fetchFileResult.getNextObject(); + if(i == fetchCount - 1) { + console.info('mediaLibraryTest : isLast'); + var result = fetchFileResult.isAfterLast(); + console.info('mediaLibraryTest : isAfterLast:' + result); + console.info('mediaLibraryTest : isAfterLast end'); + fetchFileResult.close(); + + } + } +} +``` + +### close8+ + +close(): void + +Releases and invalidates this **FetchFileResult** instance. Other APIs cannot be invoked after the instance is released. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.close(); +} +``` + +### getFirstObject8+ + +getFirstObject(callback: AsyncCallback<FileAsset>): void + +Obtains the first file asset in the result set. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------- | ---- | ------------------------------------------- | +| callback | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Callback used to return the first file asset.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getFirstObject((err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getFirstObject8+ + +getFirstObject(): Promise<FileAsset> + +Obtains the first file asset in the result set. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| --------------------------------------- | ------------------------ | +| Promise<[FileAsset](#fileasset8)> | Promise used to return the file asset.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getFirstObject().then(function(fileAsset){ + console.info("getFirstObject successfully:"+ JSON.stringify(fileAsset)); + }).catch(function(err){ + console.info("getFirstObject failed with error:"+ err); + }); +} +``` + +### getNextObject8+ + + getNextObject(callback: AsyncCallback<FileAsset>): void + +Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | --------------------------------------------- | ---- | ----------------------------------------- | +| callbacke | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Callback used to return the next file asset.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getNextObject((err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getNextObject8+ + + getNextObject(): Promise<FileAsset> + +Obtains the next file asset in the result set. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise<[FileAsset](#fileasset8)> | Promise used to return the next file asset.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + const fetchCount = fetchFileResult.getCount(); + console.info('mediaLibraryTest : count:' + fetchCount); + fileAsset = await fetchFileResult.getNextObject(); +} +``` + +### getLastObject8+ + +getLastObject(callback: AsyncCallback<FileAsset>): void + +Obtains the last file asset in the result set. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------- | ---- | --------------------------- | +| callback | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Callback used to return the last file asset.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getLastObject((err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getLastObject8+ + +getLastObject(): Promise<FileAsset> + +Obtains the last file asset in the result set. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise<[FileAsset](#fileasset8)> | Promise used to return the next file asset.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + let lastObject = await fetchFileResult.getLastObject(); +} +``` + +### getPositionObject8+ + +getPositionObject(index: number, callback: AsyncCallback<FileAsset>): void + +Obtains a file asset with the specified index in the result set. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------- | ---- | --------------------------- | +| index | number | Yes | Index of the file asset to obtain. The value starts from **0**.| +| callback | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Callback used to return the last file asset.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getPositionObject(0, (err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getPositionObject8+ + +getPositionObject(index: number): Promise<FileAsset> + +Obtains a file asset with the specified index in the result set. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----- | ------ | ---- | --------------------------- | +| index | number | Yes | Index of the file asset to obtain. The value starts from **0**.| + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise<[FileAsset](#fileasset8)> | Promise used to return the next file asset.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getPositionObject(1, (err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getAllObject8+ + +getAllObject(callback: AsyncCallback<Array<FileAsset>>): void + +Obtains all the file assets in the result set. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------- | ---- | ------------------------------- | +| callback | AsyncCallback> | Yes | Callback used to return the file assets.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getAllObject((err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getAllObject8+ + +getAllObject(): Promise<Array<FileAsset>> + +Obtains all the file assets in the result set. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| ---------------------------------------- | --------------------- | +| Promise> | Promise used to return the file assets.| + +**Example** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + var data = fetchFileResult.getAllObject(); +} +``` + +## Album8+ + +Provides APIs to implement a physical album. + +### **Attributes** + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +| Name | Type| Readable| Writable| Description | +| ------------ | ------ | ---- | ---- | -------------- | +| albumId | number | Yes | No | Album ID. | +| albumName | string | Yes | Yes | Album name. | +| albumUri | string | Yes | No | Album URI. | +| dateModified | number | Yes | No | Date when the album was modified. | +| count | number | Yes | No | Number of files in the album.| +| relativePath | string | Yes | No | Relative path of the album. | +| coverUri | string | Yes | No | URI of the cover file of the album. | + +### commitModify8+ + +commitModify(callback: AsyncCallback<void>): void + +Commits the modification of the album attributes to the database. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Void callback.| + +**Example** + +``` +async function example() { + let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], + }; + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + album.albumName = 'hello'; + album.commitModify((err) => { + if (err) { + console.error('Failed '); + return; + } + console.log('Modify successful.'); + }) +} +``` + +### commitModify8+ + +commitModify(): Promise<void> + +Commits the modification of the album attributes to the database. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| ------------------- | ----------------- | +| Promise<void> | Void promise.| + +**Example** + +``` +async function example() { + let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], + }; + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + album.albumName = 'hello'; + album.commitModify().then(function() { + console.info("commitModify successfully"); + }).catch(function(err){ + console.info("commitModify failed with error:"+ err); + }); +} +``` + +### getFileAssets8+ + +getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileResult>): void + +Obtains the file assets in this album. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | --------------------------------- | +| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files. | +| callback | AsyncCallback<[FetchFileResult](#fetchfileresult8)> | Yes | Callback used to return the file assets.| + +**Example** + +``` +async function example() { + let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], + }; + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + album.getFileAssets(fileNoArgsfetchOp, getFileAssetsCallBack); + function getFileAssetsCallBack(err, fetchFileResult) { + // do something + } +} +``` + +### getFileAssets8+ + + getFileAssets(options?: MediaFetchOptions): Promise<FetchFileResult> + +Obtains the file assets in this album. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------------------------------- | ---- | ------------ | +| options | [MediaFetchOptions](#mediafetchoptions8) | No | Options for fetching the files.| + +**Return value** + +| Type | Description | +| --------------------------------------------- | ----------------------- | +| Promise<[FetchFileResult](#fetchfileresult8)> | Promise used to return the file assets.| + +**Example** + +``` +async function example() { + let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], + }; + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + album.getFileAssets(fileNoArgsfetchOp).then(function(albumFetchFileResult){ + console.info("getFileAssets successfully:"+ JSON.stringify(albumFetchFileResult)); + }).catch(function(err){ + console.info("getFileAssets failed with error:"+ err); + }); +} +``` + +## PeerInfo8+ + +Describes information about a registered device. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +| Name | Type | Readable| Writable| Description | +| ---------- | ---------- | ---- | ---- | ---------------- | +| deviceName | string | Yes | No | Name of the registered device. | +| networkId | string | Yes | No | Network ID of the registered device.| +| deviceType | DeviceType | Yes | No | Type of the registered device. | +| isOnline | boolean | Yes | No | Whether the registered device is online. | + + + +MediaType +--------- + +Enumerates media types. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +| Name | Default Value | Description| +| ----- | ------ | ---- | +| FILE | 0 | File.| +| IMAGE | 1 | Image.| +| VIDEO | 2 | Video.| +| AUDIO | 3 | Audio.| + +FileKey +------- + +Enumerates key file information. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +| Name | Default Value | Description | +| ------------- | ------------------- | ---------------------------------------------------------- | +| ID | file_id | File ID. | +| RELATIVE_PATH | relative_path | Relative public directory of the file. | +| DISPLAY_NAME | display_name | Display file name. | +| PARENT | parent | Parent directory ID. | +| MIME_TYPE | mime_type | Extended file attributes. | +| MEDIA_TYPE | media_type | Media type. | +| SIZE | size | File size, in bytes. | +| DATE_ADDED | date_added | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.) | +| DATE_MODIFIED | date_modified | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.) | +| DATE_TAKEN | date_taken | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) | +| TITLE | title | Title in the file. | +| ARTIST | artist | Artist of the file. | +| AUDIOALBUM | audio_album | Audio album. | +| DURATION | duration | Duration, in seconds. | +| WIDTH | width | Image width, in pixels. | +| HEIGHT | height | Image height, in pixels. | +| ORIENTATION | orientation | Image display direction (clockwise rotation angle, for example, 0, 90, and 180, in degrees).| +| ALBUM_ID | bucket_id | ID of the album to which the file belongs. | +| ALBUM_NAME | bucket_display_name | Name of the album to which the file belongs. | + +DirectoryType +------------- + +Enumerates directory types. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +| Name | Default Value | Description | +| ------------- | ------ | ------------------ | +| DIR_CAMERA | 0 | Directory of camera files.| +| DIR_VIDEO | 1 | Directory of video files. | +| DIR_IMAGE | 2 | Directory of image files. | +| DIR_AUDIO | 3 | Directory of audio files. | +| DIR_DOCUMENTS | 4 | Directory of documents. | +| DIR_DOWNLOAD | 5 | Download directory. | + +DeviceType +----------- + +Enumerates device types. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +| Name | Default Value | Description | +| ------------ | ------ | ---------- | +| TYPE_UNKNOWN | 0 | Unknown.| +| TYPE_LAPTOP | 1 | Laptop.| +| TYPE_PHONE | 2 | Phone. | +| TYPE_TABLET | 3 | Tablet. | +| TYPE_WATCH | 4 | Smart watch. | +| TYPE_CAR | 5 | Vehicle-mounted device. | +| TYPE_TV | 6 | TV. | + +## MediaFetchOptions8+ + +Describes options for fetching media files. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +| Name | Type | Readable| Writable| Mandatory| Description | +| ------------- | ------------------- | ---- | ---- | ---- | ------------------------------------------------------------ | +| selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey) are used as the column names of the conditions. Example:
selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?',| +| selectionArgs | Array<string> | Yes | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.
Example:
selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], | +| order | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey) are used as the columns for sorting the search results. Example:
Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"
Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"| +| uri | string | Yes | Yes | No | File URI. | +| networkId | string | Yes | Yes | No | Network ID of the registered device. | +| extendArgs | string | Yes | Yes | No | Extended parameters for fetching the files. Currently, no extended parameters are available. | + +## Size8+ + +Describes the image size. + +| Name | Type | Readable| Writable| Description | +| ------ | ------ | ---- | ---- | ---------------- | +| width | number | Yes | Yes | Image width, in pixels.| +| height | number | Yes | Yes | Image height, in pixels.| + +## MediaAssetOption + +Implements the media asset option. + +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.Multimedia.MediaLibrary.Core + + +| Name | Type | Mandatory| Description | +| ------------ | ------ | ---- | ------------------------------------------------------------ | +| src | string | Yes | URI of the media library. | +| mimeType | string | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.
Example: 'image/\*' and 'video/\*'.| +| relativePath | string | No | Custom path for storing media assets. If this parameter is unspecified, media assets are stored in the default path. For example, if you set this parameter to **imageDir/image2/**, the media assets will be stored in **default/imageDir/image2/**, where **default** represents the default path.| + +## MediaSelectOption + +Describes media selection option. + +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.Multimedia.MediaLibrary.Core + +| Name | Type | Mandatory| Description | +| ----- | ------ | ---- | ------------------------------ | +| type | string | Yes | Media type, which can be **image** and **video**.| +| count | number | Yes | Maximum number of media assets that can be selected. | diff --git a/en/application-dev/reference/apis/js-apis-missionManager.md b/en/application-dev/reference/apis/js-apis-missionManager.md new file mode 100644 index 0000000000000000000000000000000000000000..05cd4970141c802aa4577dd02b5b86aafd1603f8 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-missionManager.md @@ -0,0 +1,649 @@ +# missionManager + + +> **NOTE** +> The initial APIs of this module are supported since API version 8. + + +Provides mission management. You can use the APIs to lock, unlock, and clear missions, and switch a mission to the foreground. + + +## Modules to Import + + +``` +import missionManager from '@ohos.application.missionManager' +``` + + +## missionManager.registerMissionListener + +function registerMissionListener(listener: MissionListener): number; + +Registers a listener to observe the mission status. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | listener | MissionListener | Yes| Listener to register.| + +**Return value** + + | Type| Description| + | -------- | -------- | + | number | Returns the index of the listener, which is created by the system and allocated when the mission status listener is registered. Each listener has a unique index.| + +**Example** + + ```js + var listener = { + onMissionCreated: this.onMissionCreatedCallback, + onMissionDestroyed: this.onMissionDestroyedCallback, + onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback, + onMissionMovedToFront: this.onMissionMovedToFrontCallback + }; + console.log("registerMissionListener") + var listenerid = missionManager.registerMissionListener(listener); + + ``` + + +## missionManager.unregisterMissionListener + +function unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>): void; + +Unregisters a mission status listener. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + var listener = { + onMissionCreated: this.onMissionCreatedCallback, + onMissionDestroyed: this.onMissionDestroyedCallback, + onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback, + onMissionMovedToFront: this.onMissionMovedToFrontCallback + }; + console.log("registerMissionListener") + var listenerid = missionManager.registerMissionListener(listener); + + missionManager.unregisterMissionListener(listenerid, (error) => { + console.log("unregisterMissionListener"); + }) + ``` + + +## missionManager.unregisterMissionListener + +function unregisterMissionListener(listenerId: number): Promise<void>; + +Unregisters a mission status listener. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.| + +**Example** + + ```js + var listener = { + onMissionCreated: this.onMissionCreatedCallback, + onMissionDestroyed: this.onMissionDestroyedCallback, + onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback, + onMissionMovedToFront: this.onMissionMovedToFrontCallback + }; + console.log("registerMissionListener") + var listenerid = missionManager.registerMissionListener(listener); + + await missionManager.unregisterMissionListener(listenerid).catch(function (err){ + console.log(err); + }); + ``` + + +## missionManager.getMissionInfo + +function getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<MissionInfo>): void; + +Obtains the information of a given mission. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| + | missionId | number | Yes| Mission ID.| + | callback | AsyncCallback<MissionInfo> | Yes| Callback used to return the mission information obtained.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => { + console.log("getMissionInfo is called, error.code = " + error.code) + console.log("mission.missionId = " + mission.missionId); + console.log("mission.runningState = " + mission.runningState); + console.log("mission.lockedState = " + mission.lockedState); + console.log("mission.timestamp = " + mission.timestamp); + console.log("mission.label = " + mission.label); + console.log("mission.iconPath = " + mission.iconPath); + } + ``` + + +## missionManager.getMissionInfo + +function getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>; + +Obtains the information of a given mission. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| + | missionId | number | Yes| Mission ID.| + +**Return value** + + | Type| Description| + | -------- | -------- | + | [MissionInfo](js-apis-application-MissionInfo.md) | Promise used to return the mission information obtained.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + var mission = await missionManager.getMissionInfo("", id).catch(function (err){ + console.log(err); + }); + ``` + + +## missionManager.getMissionInfos + +function getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Array<MissionInfo>>): void; + +Obtains information of all missions. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| + | numMax | number | Yes| Maximum number of missions whose information can be obtained.| + | callback | AsyncCallback<Array<[MissionInfo](js-apis-application-MissionInfo.md)>> | Yes| Callback used to return the array of mission information obtained.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + }) + ``` + + +## missionManager.getMissionInfos + +function getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionInfo>>; + +Obtains information of all missions. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| + | numMax | number | Yes| Maximum number of missions whose information can be obtained.| + +**Return value** + + | Type| Description| + | -------- | -------- | + | Array<MissionInfo> | Promise used to return the array of mission information obtained.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + console.log(err); + }); + ``` + + +## missionManager.getMissionSnapShot + +function getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback<MissionSnapshot>): void; + +Obtains the snapshot of a given mission. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| + | missionId | number | Yes| Mission ID.| + | callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + var id = missions[0].missionId; + + missionManager.getMissionSnapShot("", id, (error, snapshot) => { + console.log("getMissionSnapShot is called, error.code = " + error.code); + console.log("bundleName = " + snapshot.ability.bundleName); + }) + }) + ``` + + +## missionManager.getMissionSnapShot + +function getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnapshot>; + +Obtains the snapshot of a given mission. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| + | missionId | number | Yes| Mission ID.| + +**Return value** + + | Type| Description| + | -------- | -------- | + | MissionSnapshot | Promise used to return the snapshot information obtained.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + console.log(err); + }); + console.log("size = " + allMissions.length); + console.log("missions = " + JSON.stringify(allMissions)); + var id = allMissions[0].missionId; + var snapshot = await missionManager.getMissionSnapShot("", id).catch(function (err){ + console.log(err); + }); + ``` + + +## missionManager.lockMission + +function lockMission(missionId: number, callback: AsyncCallback<void>): void; + +Locks a given mission. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | missionId | number | Yes| Mission ID.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + var id = missions[0].missionId; + + missionManager.lockMission(id).then(() => { + console.log("lockMission is called "); + }); + }); + ``` + + +## missionManager.lockMission + +function lockMission(missionId: number): Promise<void>; + +Locks a given mission. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | missionId | number | Yes| Mission ID.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + console.log(err); + }); + console.log("size = " + allMissions.length); + console.log("missions = " + JSON.stringify(allMissions)); + var id = allMissions[0].missionId; + + await missionManager.lockMission(id).catch(function (err){ + console.log(err); + }); + ``` + + +## missionManager.unlockMission + +function unlockMission(missionId: number, callback: AsyncCallback<void>): void; + +Unlocks a given mission. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | missionId | number | Yes| Mission ID.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + var id = missions[0].missionId; + + missionManager.unlockMission(id).then(() => { + console.log("unlockMission is called "); + }); + }); + ``` + + +## missionManager.unlockMission + +function unlockMission(missionId: number): Promise<void>; + +Unlocks a given mission. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | missionId | number | Yes| Mission ID.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + console.log(err); + }); + console.log("size = " + allMissions.length); + console.log("missions = " + JSON.stringify(allMissions)); + var id = allMissions[0].missionId; + + await missionManager.lockMission(id).catch(function (err){ + console.log(err); + }); + await missionManager.unlockMission(id).catch(function (err){ + console.log(err); + }); + ``` + + +## missionManager.clearMission + +function clearMission(missionId: number, callback: AsyncCallback<void>): void; + +Clears a given mission, regardless of whether it is locked. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | missionId | number | Yes| Mission ID.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + var id = missions[0].missionId; + + missionManager.clearMission(id).then(() => { + console.log("clearMission is called "); + }); + }); + ``` + + +## missionManager.clearMission + +function clearMission(missionId: number): Promise<void>; + +Clears a given mission, regardless of whether it is locked. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | missionId | number | Yes| Mission ID.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + console.log(err); + }); + console.log("size = " + allMissions.length); + console.log("missions = " + JSON.stringify(allMissions)); + var id = allMissions[0].missionId; + + await missionManager.clearMission(id).catch(function (err){ + console.log(err); + }); + ``` + + +## missionManager.clearAllMissions + +function clearAllMissions(callback: AsyncCallback<void>): void; + +Clears all unlocked missions. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.clearAllMissions().then(() => { + console.log("clearAllMissions is called "); + }); + ``` + + +## missionManager.clearAllMissions + +function clearAllMissions(): Promise<void>; + +Clears all unlocked missions. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + await missionManager.clearAllMissions().catch(function (err){ + console.log(err); + }); + ``` + + +## missionManager.moveMissionToFront + +function moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void; + +Switches a given mission to the foreground. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | missionId | number | Yes| Mission ID.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + var id = missions[0].missionId; + + missionManager.moveMissionToFront(id).then(() => { + console.log("moveMissionToFront is called "); + }); + }); + ``` + + +## missionManager.moveMissionToFront + +function moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback<void>): void; + +Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | missionId | number | Yes| Mission ID.| + | options | StartOptions | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + var id = missions[0].missionId; + + missionManager.moveMissionToFront(id,{windowMode : 101}).then(() => { + console.log("moveMissionToFront is called "); + }); + }); + ``` + + +## missionManager.moveMissionToFront + +function moveMissionToFront(missionId: number, options?: StartOptions): Promise<void>; + +Switches a given mission to the foreground. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | missionId | number | Yes| Mission ID.| + | options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| + +**Example** + + ```js + import missionManager from '@ohos.application.missionManager' + + var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + console.log(err); + }); + console.log("size = " + allMissions.length); + console.log("missions = " + JSON.stringify(allMissions)); + var id = allMissions[0].missionId; + + await missionManager.moveMissionToFront(id).catch(function (err){ + console.log(err); + }); + ``` diff --git a/en/application-dev/reference/apis/js-apis-net-connection.md b/en/application-dev/reference/apis/js-apis-net-connection.md index 9d04af32345f913b519ce9645d66a80ff4d92191..7e14306d2f67145b4e0d28d6fc532cb925729175 100644 --- a/en/application-dev/reference/apis/js-apis-net-connection.md +++ b/en/application-dev/reference/apis/js-apis-net-connection.md @@ -1,7 +1,7 @@ # Network Connection Management -> **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. @@ -17,7 +17,7 @@ getDefaultNet(callback: AsyncCallback\): void Obtains the default active data network. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core @@ -42,11 +42,11 @@ getDefaultNet(): Promise\ Obtains the default active data network. This API uses a promise to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core -**Return Value** +**Return value** | Type | Description | | --------------------------------- | ------------------------------------- | @@ -91,7 +91,7 @@ Checks whether the default data network is activated. This API uses a promise to **System capability**: SystemCapability.Communication.NetManager.Core -**Return Value** +**Return value** | Type | Description | | ----------------- | ----------------------------------------------- | @@ -111,7 +111,7 @@ getAllNets(callback: AsyncCallback<Array<NetHandle>>): void Obtains the list of all active data networks. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core @@ -136,11 +136,11 @@ getAllNets(): Promise<Array<NetHandle>> Obtains the list of all active data networks. This API uses a promise to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core -**Return Value** +**Return value** | Type| Description| | -------- | -------- | | Promise<Array<[NetHandle](#nethandle)>> | Promise used to return the result.| @@ -157,9 +157,9 @@ connection.getAllNets().then(function (nets) { getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\): void -Obtains connection properties of the network corresponding to given network handle. This API uses an asynchronous callback to return the result. +Obtains connection properties of the network corresponding to the **netHandle**. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core @@ -185,9 +185,9 @@ connection.getDefaultNet().then(function (netHandle) { getConnectionProperties(netHandle: NetHandle): Promise\ -Obtains connection properties of the network corresponding to **netHandle**. This API uses a promise to return the result. +Obtains connection properties of the network corresponding to the **netHandle**. This API uses a promise to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core @@ -197,7 +197,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi | --------- | ----------------------- | ---- | ---------------- | | netHandle | [NetHandle](#nethandle) | Yes | Network handle.| -**Return Value** +**Return value** | Type | Description | | ------------------------------------------------------- | --------------------------------- | @@ -217,9 +217,9 @@ connection.getDefaultNet().then(function (netHandle) { getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\): void -Obtains capability information of the network corresponding to **netHandle**. This API uses an asynchronous callback to return the result. +Obtains capability information of the network corresponding to the **netHandle**. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core @@ -245,9 +245,9 @@ connection.getDefaultNet().then(function (netHandle) { getNetCapabilities(netHandle: NetHandle): Promise\ -Obtains capability information of the network corresponding to **netHandle**. This API uses a promise to return the result. +Obtains capability information of the network corresponding to the **netHandle**. This API uses a promise to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core @@ -257,7 +257,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th | --------- | ----------------------- | ---- | ---------------- | | netHandle | [NetHandle](#nethandle) | Yes | Network handle.| -**Return Value** +**Return value** | Type | Description | | --------------------------------------------- | --------------------------------- | @@ -279,7 +279,7 @@ reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): v Reports connection of the data network. This API uses an asynchronous callback to return the result. -** Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET +**Required permissions** : ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET **System capability**: SystemCapability.Communication.NetManager.Core @@ -306,7 +306,7 @@ reportNetConnected(netHandle: NetHandle): Promise<void> Reports connection of the data network. This API uses a promise to return the result. -** Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET +**Required permissions**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET **System capability**: SystemCapability.Communication.NetManager.Core @@ -315,7 +315,7 @@ Reports connection of the data network. This API uses a promise to return the re | -------- | -------- | -------- | -------- | | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| -**Return Value** +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| @@ -337,7 +337,7 @@ reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>) Reports disconnection of the data network. This API uses an asynchronous callback to return the result. -** Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET +**Required permissions**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET **System capability**: SystemCapability.Communication.NetManager.Core @@ -364,7 +364,7 @@ reportNetDisconnected(netHandle: NetHandle): Promise<void> Reports disconnection of the data network. This API uses a promise to return the result. -** Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET +**Required permissions**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET **System capability**: SystemCapability.Communication.NetManager.Core @@ -373,7 +373,7 @@ Reports disconnection of the data network. This API uses a promise to return the | -------- | -------- | -------- | -------- | | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| -**Return Value** +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| @@ -394,7 +394,7 @@ getAddressesByName(host: string, callback: AsyncCallback\>): Resolves the host name by using the default network to obtain all IP addresses. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core @@ -402,7 +402,7 @@ Resolves the host name by using the default network to obtain all IP addresses. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| +| host | string | Yes | Host name to resolve.| | callback | AsyncCallback\> | Yes | Callback used to return the result. | **Example** @@ -421,7 +421,7 @@ getAddressesByName(host: string): Promise\> Resolves the host name by using the default network to obtain all IP addresses. This API uses a promise to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core @@ -429,13 +429,13 @@ Resolves the host name by using the default network to obtain all IP addresses. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| +| host | string | Yes | Host name to resolve.| -**Return Value** +**Return value** | Type | Description | | ------------------------------------------- | ----------------------------- | -| Promise\> | Promise used to return the result.| +| Promise\> | Promise used to return the IP addresses obtained.| **Example** @@ -461,7 +461,7 @@ Obtains the handle of the network specified by **netSpecifier**. | netSpecifier | [NetSpecifier](#netspecifier) | No | Network specifier. If this parameter is not set, the default network is used. | | timeout | number | No | Timeout interval for obtaining the network specified by **netSpecifier**. This parameter is valid only when **netSpecifier** is set.| -**Return Value** +**Return value** | Type | Description | | ------------------------------- | -------------------- | @@ -520,7 +520,7 @@ Registers a listener for **netCapabilitiesChange** events. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed to **netCapabilitiesChange**.
**netCapabilitiesChange**: event indicating that he network capabilities have changed.| +| type | string | Yes | Event type. The value is fixed to **netCapabilitiesChange**.
**netCapabilitiesChange**: event indicating that the network capabilities have changed.| | callback | Callback<{ netHandle: [NetHandle](#nethandle), netCap: [NetCapabilities](#netcapabilities) }> | Yes | Callback used to return the result. | **Example** @@ -630,7 +630,7 @@ register(callback: AsyncCallback\): void Registers a listener for network status changes. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**Required permissions**: ohos.permission.GET_NETWORK_INFO **System capability**: SystemCapability.Communication.NetManager.Core @@ -674,15 +674,15 @@ netConnection.unregister(function (error) { Defines the handle of the data network. -Before invoking NetHandle APIs, call **getNetHandle** to obtain a **NetHandle** object. +Before invoking **NetHandle** APIs, call **getNetHandle** to obtain a **NetHandle** object. **System capability**: SystemCapability.Communication.NetManager.Core -### Parameters +### Attributes | Name| Type | Description | | ------ | ------ | ------------------------- | -| netId | number | Network ID. The value must be greater than or equal to 100.| +| netId | number | Network ID. The value must be greater than or equal to **100**.| ### bindSocket @@ -731,7 +731,7 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses | ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | socketParam | TCPSocket \| UDPSocket | Yes | **TCPSocket** or **UDPSocket** object.| -**Return Value** +**Return value** | Type | Description | | ------------------- | --------------------------- | | Promise<void> | Promise used to return the result.| @@ -767,7 +767,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| +| host | string | Yes | Host name to resolve.| | callback | AsyncCallback\> | Yes | Callback used to return the result. | **Example** @@ -794,9 +794,9 @@ Resolves the host name by using the corresponding network to obtain all IP addre | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| +| host | string | Yes | Host name to resolve.| -**Return Value** +**Return value** | Type | Description | | ------------------------------------------- | ----------------------------- | @@ -825,7 +825,7 @@ Resolves the host name by using the corresponding network to obtain the first IP | Name | Type | Mandatory| Description | | -------- | ----------------------------------------- | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| +| host | string | Yes | Host name to resolve.| | callback | AsyncCallback\<[NetAddress](#netaddress)> | Yes | Callback used to return the result. | **Example** @@ -852,9 +852,9 @@ Resolves the host name by using the corresponding network to obtain the first IP | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| +| host | string | Yes | Host name to resolve.| -**Return Value** +**Return value** | Type | Description | | ----------------------------------- | ------------------------------- | @@ -901,7 +901,7 @@ Defines the network capability. **System capability**: SystemCapability.Communication.NetManager.Core -| Name | Value | Description | +| Name | Value α | Description | | ------------------------ | ---- | ---------------------- | | NET_CAPABILITY_MMS | 0 | The network can connect to the carrier's Multimedia Messaging Service Center (MMSC) to send and receive multimedia messages.| | NET_CAPABILITY_NOT_METERED | 11 | The network traffic is not metered.| @@ -915,7 +915,7 @@ Defines the network type. **System capability**: SystemCapability.Communication.NetManager.Core -| Name | Value | Description | +| Name | Value α | Description | | --------------- | ---- | ----------- | | BEARER_CELLULAR | 0 | Cellular network | | BEARER_WIFI | 1 | Wi-Fi network| @@ -938,7 +938,7 @@ Defines the network connection properties. ## LinkAddress -Network link information. +Defines network link information. **System capability**: SystemCapability.Communication.NetManager.Core @@ -949,7 +949,7 @@ Network link information. ## RouteInfo -Network route information. +Defines network route information. **System capability**: SystemCapability.Communication.NetManager.Core @@ -971,4 +971,4 @@ Defines the network address. | ------- | ------ | ------------------------------ | | address | string | Network address. | | family | number | Address family identifier. The value is **1** for IPv4 and **2** for IPv6. The default value is **1**.| -| port | number | Port number. The value ranges from **0** to **65535**. | +| port | number | Port number. The value range is 0 to 65535. | diff --git a/en/application-dev/reference/apis/js-apis-osAccount.md b/en/application-dev/reference/apis/js-apis-osAccount.md index c85c006e1149df12f4c965243b5ad91fce573480..b25a77fed056edecae307315c3c4eecf06dbc218 100644 --- a/en/application-dev/reference/apis/js-apis-osAccount.md +++ b/en/application-dev/reference/apis/js-apis-osAccount.md @@ -10,33 +10,34 @@ import account_osAccount from '@ohos.account.osAccount'; ``` -## System Capabilities - -SystemCapability.Account.OsAccount - ## account_osAccount.getAccountManager getAccountManager(): AccountManager Obtains an **AccountManager** instance. -- Return value - | Type| Description| - | -------- | -------- | - | [AccountManager](#accountmanager) | **AccountManager** instance obtained.| +**System capability**: SystemCapability.Account.OsAccount -- Example +**Return Value** +| Type | Description | +| --------------------------------- | ------------------------ | +| [AccountManager](#accountmanager) | Obtains an **AccountManager** instance.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); ``` ## OsAccountType Enumerates OS account types. - | Name| Default Value| Description| - | -------- | -------- | -------- | - | ADMIN | 0 | Administrator account| - | NORMAL | 1 | Normal account| - | GUEST | 2 | Guest account| + +**System capability**: SystemCapability.Account.OsAccount + +| Name | Default Value| Description | +| ------ | ------ | ------------ | +| ADMIN | 0 | Administrator account| +| NORMAL | 1 | Normal account | +| GUEST | 2 | Guest account | ## AccountManager @@ -48,17 +49,18 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void Activates an OS account. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | -------- | ------------------- | ---- | -------------------- | - | localId | number | Yes | ID of the OS account to activate.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +**Parameters** -- Example - - Activate OS account 100. - +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------- | +| localId | number | Yes | ID of the OS account to activate.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example**: Activate OS account 100. ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -73,22 +75,23 @@ activateOsAccount(localId: number): Promise<void> Activates an OS account. This method uses a promise to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | ------- | ------ | ---- | ------------ | - | localId | number | Yes | ID of the OS account to activate.| +**Parameters** -- Return value +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | -------------------- | +| localId | number | Yes | ID of the OS account to activate.| - | Type | Description | - | :------------ | :---------------------------------- | - | Promise<void> | Promise used to return the result.| +**Return Value** -- Example - - Activate OS account 100. - +| Type | Description | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise used to return the result.| + +**Example**: Activate OS account 100. ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -105,13 +108,15 @@ isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void Checks whether multiple OS accounts are supported. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------- | ---- | ------------------------------ | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | --------------------------------------------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -127,13 +132,15 @@ isMultiOsAccountEnable(): Promise<boolean> Checks whether multiple OS accounts are supported. This method uses a promise to return the result. -- Return value +**System capability**: SystemCapability.Account.OsAccount - | Type | Description | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.| +**Return Value** -- Example +| Type | Description | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -150,17 +157,19 @@ isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): voi Checks whether an OS account is activated. This method uses an asynchronous callback to return the result. -- Parameters +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | -------- | ---------------------- | ---- | ------------------------------ | - | localId | number | Yes | ID of the target OS account. | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ------------------------------------------------- | +| localId | number | Yes | ID of the target OS account. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.| + +**Example**: Check whether OS account 100 is activated. - Check whether OS account 100 is activated. - ``` const accountManager = account_osAccount.getAccountManager(); var osLocalId = 100; @@ -176,22 +185,24 @@ isOsAccountActived(localId: number): Promise<boolean> Checks whether an OS account is activated. This method uses a promise to return the result. -- Parameters +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | ------- | ------ | ---- | ------------ | - | localId | number | Yes | ID of the target OS account.| +**Parameters** -- Return value +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------ | +| localId | number | Yes | ID of the target OS account.| - | Type | Description | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.| +**Return Value** -- Example +| Type | Description | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.| + +**Example**: Check whether OS account 100 is activated. - Check whether OS account 100 is activated. - ``` const accountManager = account_osAccount.getAccountManager(); var osLocalId = 100; @@ -208,18 +219,20 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async Checks whether the specified constraint is enabled for an OS account. This method uses an asynchronous callback to return the result. -- Parameters +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | ---------- | ---------------------- | ---- | ------------------------------ | - | localId | number | Yes | ID of the target OS account.| - | [constraint](#constraints) | string | Yes | Constraint specified.| - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| ---------- | ---------------------------- | ---- | ------------------------------------------------- | +| localId | number | Yes | ID of the target OS account. | +| constraint | string | Yes | [Constraint](#constraints) specified. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.| + +** Example**: Check whether OS account 100 is forbidden to use Wi-Fi. - Check whether OS account 100 is forbidden to use Wi-Fi. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -235,23 +248,25 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boo Checks whether the specified constraint is enabled for an OS account. This method uses a promise to return the result. -- Parameters +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | ---------- | ------ | ---- | ---------------- | - | localId | number | Yes | ID of the target OS account.| - | [constraint](#constraints)| string | Yes | Constraint specified.| +**Parameters** -- Return value +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------------------------- | +| localId | number | Yes | ID of the target OS account. | +| constraint | string | Yes | [Constraint](#constraints) specified.| - | Type | Description | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.| +**Return Value** -- Example +| Type | Description | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.| + +** Example**: Check whether OS account 100 is forbidden to use Wi-Fi. - Check whether OS account 100 is forbidden to use Wi-Fi. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -268,13 +283,15 @@ isTestOsAccount(callback: AsyncCallback<boolean>): void Checks whether this OS account is a test account. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------- | ---- | ------------------------------------------ | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ----------------------------------------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -290,13 +307,15 @@ isTestOsAccount(): Promise<boolean> Checks whether this OS account is a test account. This method uses a promise to return the result. -- Return value +**System capability**: SystemCapability.Account.OsAccount - | Type | Description | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.| +**Return Value** -- Example +| Type | Description | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -313,13 +332,15 @@ isOsAccountVerified(callback: AsyncCallback<boolean>): void Checks whether this OS account has been verified. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------- | ---- | ---------------------------------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ------------------------------------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -335,14 +356,16 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo Checks whether an OS account has been verified. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | -------- | ---------------------- | ---- | ---------------------------------- | - | localId | number | No | ID of the target OS account. | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ------------------------------------------- | +| localId | number | No | ID of the target OS account. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -354,23 +377,25 @@ Checks whether an OS account has been verified. This method uses an asynchronous ### isOsAccountVerified -isOsAccountVerified(localId: number?): Promise<boolean> +isOsAccountVerified(localId?: number): Promise<boolean> Checks whether an OS account has been verified. This method uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | ------- | ------ | ---- | ------------ | - | localId | number | No | ID of the target OS account.| +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------------ | +| localId | number | No | ID of the target OS account.| -- Return value +**Return Value** - | Type | Description | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.| +| Type | Description | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -387,21 +412,27 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void Removes an OS account. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. - | Name | Type | Mandatory| Description | - | -------- | ------------------- | ---- | ------------------------ | - | localId | number | Yes | ID of the OS account to remove. | - | callback | AsyncCallback<void> | Yes | Callback used to return the result.| +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS -- Example +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------- | +| localId | number | Yes | ID of the OS account to remove.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); var createIocalId; osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ createIocalId = osAccountInfo.localId; - )}; + }); accountManager.removeOsAccount(createIocalId, (err)=>{ console.log("removeOsAccount err:" + JSON.stringify(err)); }); @@ -413,26 +444,32 @@ removeOsAccount(localId: number): Promise<void> Removes an OS account. This method uses a promise to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | ------- | ------ | ---- | ------------ | - | localId | number | Yes | ID of the OS account to remove.| +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | -------------------- | +| localId | number | Yes | ID of the OS account to remove.| -- 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 accountManager = account_osAccount.getAccountManager(); var createIocalId; osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ createIocalId = osAccountInfo.localId; - )}; + }); createIocalId = osAccount.localId; accountManager.removeOsAccount(createIocalId).then(() => { console.log('removeOsAccount Success'); @@ -445,21 +482,25 @@ Removes an OS account. This method uses a promise to return the result. setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean,callback: AsyncCallback<void>): void -Sets or removes constraints for an OS account. This method uses an asynchronous callback to return the result. +Sets or removes constraints for an OS account. + +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount -- Parameters +**Parameters** - | Name | Type | Mandatory| Description | - | ----------- | ------------------- | ---- | ------------------------------- | - | localId | number | Yes | ID of the target OS account. | - | [constraints](constraints)| Array<string> | Yes | List of constraints to set or remove. | - | enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. | - | callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| ----------- | ------------------------- | ---- | -------------------------------------------- | +| localId | number | Yes | ID of the target OS account. | +| constraints | Array<string> | Yes | List of [constraints](#constraints) to set or remove.| +| enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | -- Example +** Example**: Disable Wi-Fi for OS account 100. - Disable Wi-Fi for OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -472,26 +513,30 @@ Sets or removes constraints for an OS account. This method uses an asynchronous setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean): Promise<void> -Sets or removes constraints for an OS account. This method uses a promise to return the result. +Sets or removes constraints for an OS account. -- Parameters +This is a system API and cannot be called by third-party applications. - | Name | Type | Mandatory| Description | - | ----------- | ------------- | ---- | ----------------------- | - | localId | number | Yes | ID of the target OS account. | - | [constraints](constraints)| Array<string> | Yes | List of constraints to set or remove.| - | enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints.| +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS -- Return value +**System capability**: SystemCapability.Account.OsAccount - | Type | Description | - | :------------ | :---------------------------------- | - | Promise<void> | Promise used to return the result.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| ----------- | ------------------- | ---- | -------------------------------------------- | +| localId | number | Yes | ID of the target OS account. | +| constraints | Array<string> | Yes | List of [constraints](#constraints) to set or remove.| +| enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. | + +**Return Value** + +| Type | Description | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise used to return the result.| + +**Example**: Remote the constraint on the use of Wi-Fi for OS account 100. - Remove the constraint on Wi-Fi for OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -508,18 +553,20 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback< Sets a name for an OS account. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | :-------- | ------------------- | ---- | ------------------------ | - | localId | number | Yes | ID of the target OS account. | - | localName | string | Yes | Account name to set. | - | callback | AsyncCallback<void> | Yes | Callback used to return the result.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| :-------- | ------------------------- | ---- | ------------ | +| localId | number | Yes | ID of the target OS account.| +| localName | string | Yes | Account name to set. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example**: Set the name of OS account 100 to **demoName**. - Set the name of OS account 100 to **demoName**. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -535,23 +582,25 @@ setOsAccountName(localId: number, localName: string): Promise<void> Sets a name for an OS account. This method uses a promise to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | --------- | ------ | ---- | ----------------------- | - | localId | number | Yes | ID of the target OS account. | - | localName | string | Yes | Account name to set.| +**Parameters** -- Return value +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ------------ | +| localId | number | Yes | ID of the target OS account.| +| localName | string | Yes | Account name 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**: Set the name of OS account 100 to **demoName**. - Set the name of OS account 100 to **demoName**. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -569,13 +618,17 @@ getCreatedOsAccountsCount(callback: AsyncCallback<number>): void Obtains the number of OS accounts created. This method uses an asynchronous callback to return the result. -- Parameters +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | -------- | --------------------- | ---- | ------------------------------ | - | callback | AsyncCallback<number> | Yes | Callback used to return the number of OS accounts created.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ------------------------------------------ | +| callback | AsyncCallback<number> | Yes | Callback used to return the number of OS accounts created.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -591,13 +644,17 @@ getCreatedOsAccountsCount(): Promise<number> Obtains the number of OS accounts created. This method uses a promise to return the result. -- Return value +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount + +**Return Value** - | Type | Description | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise used to return the number of OS accounts created.| +| Type | Description | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise used to return the number of OS accounts created.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -614,13 +671,15 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void Obtains the ID of the OS account to which the current process belongs. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | -------- | --------------------- | ---- | ----------------------------------------- | - | callback | AsyncCallback<number> | Yes | Callback used to return the account ID obtained.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | -------------------------------------------------- | +| callback | AsyncCallback<number> | Yes | Callback used to return the account ID obtained.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -636,13 +695,15 @@ getOsAccountLocalIdFromProcess(): Promise<number> Obtains the ID of the OS account to which the current process belongs. This method uses a promise to return the result. -- Return value +**System capability**: SystemCapability.Account.OsAccount + +**Return Value** - | Type | Description | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise used to return the account ID obtained.| +| Type | Description | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise used to return the account ID obtained.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -659,17 +720,17 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): Obtains the OS account ID based on the process UID. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | -------- | --------------------- | ---- | --------------------------------------- | - | uid | number | Yes | Process UID.| - | callback | AsyncCallback<number> | Yes | Callback used to return the OS account ID obtained.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | --------------------------------------------- | +| uid | number | Yes | Process UID. | +| callback | AsyncCallback<number> | Yes | Callback used to return the OS account ID obtained.| + +**Example**: Obtain the ID of the OS account whose process UID is **12345678**. - Obtain the ID of the OS account whose process UID is **12345678**. - ``` const accountManager = account_osAccount.getAccountManager(); let uid = 12345678; @@ -685,22 +746,22 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number> Obtains the OS account ID based on the process UID. This method uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------------- | - | uid | number | Yes | Process UID.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | --------- | +| uid | number | Yes | Process UID.| -- Return value +**Return Value** - | Type | Description | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise used to return the OS account ID obtained.| +| Type | Description | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise used to return the OS account ID obtained.| -- Example +**Example**: Obtain the ID of the OS account whose process UID is **12345678**. - Obtain the ID of the OS account whose process UID is **12345678**. - ``` const accountManager = account_osAccount.getAccountManager(); let uid = 12345678; @@ -711,20 +772,24 @@ Obtains the OS account ID based on the process UID. This method uses a promise t }); ``` -### getOsAccountLocalIdFromDomain +### getOsAccountLocalIdFromDomain8+ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void Obtains the OS account ID based on domain account information. This method uses an asynchronous callback to return the result. -- Parameters +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS - | Name | Type | Mandatory| Description | - | -------- | --------------------- | ---- | --------------------------------------- | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. | - | callback | AsyncCallback<number> | Yes | Callback used to return the ID of the OS account associated with the domain account.| +**System capability**: SystemCapability.Account.OsAccount -- Example +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | -------------------------------------------- | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. | +| callback | AsyncCallback<number> | Yes | Callback used to return the ID of the OS account associated with the domain account.| + +**Example** ``` var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; @@ -735,25 +800,29 @@ Obtains the OS account ID based on domain account information. This method uses }); ``` -### getOsAccountLocalIdFromDomain +### getOsAccountLocalIdFromDomain8+ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number> Obtains the OS account ID based on domain account information. This method uses a promise to return the result. -- Parameters +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------------- | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information.| +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | ------------ | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information.| -- Return value +**Return Value** - | Type | Description | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise used to return the ID of the OS account associated with the domain account.| +| Type | Description | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise used to return the ID of the OS account associated with the domain account.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -771,13 +840,17 @@ queryMaxOsAccountNumber(callback: AsyncCallback<number>): void Obtains the maximum number of OS accounts that can be created. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. - | Name | Type | Mandatory| Description | - | -------- | --------------------- | ---- | ---------------------------------- | - | callback | AsyncCallback<number> | Yes | Callback used to return the maximum number of OS accounts that can be created.| +**System capability**: SystemCapability.Account.OsAccount -- Example +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ------------------------------------------------ | +| callback | AsyncCallback<number> | Yes | Callback used to return the maximum number of OS accounts that can be created.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -793,13 +866,17 @@ queryMaxOsAccountNumber(): Promise<number> Obtains the maximum number of OS accounts that can be created. This method uses a promise to return the result. -- Return value +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.Account.OsAccount + +**Return Value** - | Type | Description | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise used to return the maximum number of OS accounts that can be created.| +| Type | Description | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise used to return the maximum number of OS accounts that can be created.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -814,19 +891,21 @@ Obtains the maximum number of OS accounts that can be created. This method uses getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<string>>): void -Obtains all constraints of an OS account. This method uses an asynchronous callback to return the result. +Obtains all constraints enabled for an OS account. This method uses an asynchronous callback to return the result. -- Parameters +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS - | Name | Type | Mandatory| Description | - | -------- | ---------------------------- | ---- | ---------------------------------- | - | localId | number | Yes | ID of the target OS account. | - | callback | AsyncCallback<Array<string>> | Yes | Callback used to return all constraints obtained.| +**System capability**: SystemCapability.Account.OsAccount -- Example +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ | +| localId | number | Yes | ID of the target OS account. | +| callback | AsyncCallback<Array<string>> | Yes | Callback used to return all [constraints](#constraints) obtained.| + +** Example**: Obtain all constraints of OS account 100. - Obtain all constraints of OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -840,24 +919,26 @@ Obtains all constraints of an OS account. This method uses an asynchronous callb getOsAccountAllConstraints(localId: number): Promise<Array<string>> -Obtains all constraints of an OS account. This method uses a promise to return the result. +Obtains all constraints enabled for an OS account. This method uses a promise to return the result. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS -- Parameters +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | ------- | ------ | ---- | ------------ | - | localId | number | Yes | ID of the target OS account.| +**Parameters** -- Return value +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------ | +| localId | number | Yes | ID of the target OS account.| - | Type | Description | - | :--------------------- | :---------------------------------- | - | Promise<Array<string>> | Promise used to return the constraints obtained.| +**Return Value** -- Example +| Type | Description | +| :--------------------------------- | :----------------------------------------------------------- | +| Promise<Array<string>> | Promise used to return the [constraints](#constraints) obtained.| + +** Example**: Obtain all constraints of OS account 100. - Obtain all constraints of OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -874,13 +955,17 @@ queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>& Obtains information about all the OS accounts created. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | -------- | ----------------------------------- | ---- | -------------------------------- | - | callback | AsyncCallback<Array<[OsAccountInfo](#osaccountinfo)>> | Yes | Callback used to return information about OS accounts created.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| callback | AsyncCallback<Array<[OsAccountInfo](#osaccountinfo)>> | Yes | Callback used to return information about OS accounts created.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -896,13 +981,17 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>> Obtains information about all the OS accounts created. This method uses a promise to return the result. -- Return value +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.Account.OsAccount - | Type | Description | - | :---------------------------- | :---------------------------------- | - | Promise<Array<[OsAccountInfo](#osaccountinfo)>> | Promise used to return information about OS accounts created.| +**Return Value** -- Example +| Type | Description | +| :---------------------------------------------------------- | :----------------------------------------------------------- | +| Promise<Array<[OsAccountInfo](#osaccountinfo)>> | Promise used to return information about OS accounts created.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -913,19 +1002,21 @@ Obtains information about all the OS accounts created. This method uses a promis }); ``` -### queryActivatedOsAccountIds +### queryActivatedOsAccountIds8+ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void Obtains information about all activated OS accounts. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | ----------------------------------- | ---- | -------------------------------- | - | callback | AsyncCallback<Array<number>> | Yes | Callback used to return information about activated OS accounts.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ | +| callback | AsyncCallback<Array<number>> | Yes | Callback used to return information about activated OS accounts.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -938,19 +1029,21 @@ Obtains information about all activated OS accounts. This method uses an asynchr }); ``` -### queryActivatedOsAccountIds +### queryActivatedOsAccountIds8+ queryActivatedOsAccountIds(): Promise<Array<number>> Obtains information about all activated OS accounts. This method uses a promise to return the result. -- Return value +**System capability**: SystemCapability.Account.OsAccount - | Type | Description | - | :---------------------------- | :---------------------------------- | - | Promise<Array<number>> | Promise used to return information about activated OS accounts.| +**Return Value** -- Example +| Type | Description | +| :--------------------------------- | :----------------------------------------------------------- | +| Promise<Array<number>> | Promise used to return information about activated OS accounts.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -967,15 +1060,21 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback& Creates an OS account. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS - | Name | Type | Mandatory| Description | - | :-------- | ---------------------------- | ---- | -------------------- | - | localName | string | Yes | Name of the OS account to create. | - | type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. | - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | Yes | Callback used to return the OS account created.| +**System capability**: SystemCapability.Account.OsAccount -- Example +**Parameters** + +| Name | Type | Mandatory| Description | +| :-------- | ---------------------------------------------------- | ---- | ------------------------------------------ | +| localName | string | Yes | Name of the OS account to create. | +| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | Yes | Callback used to return the OS account created.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -991,20 +1090,26 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf Creates an OS account. This method uses a promise to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | --------- | ------------- | ---- | ---------------- | - | localName | string | Yes | Name of the OS account to create.| - | type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.| +**Parameters** -- Return value +| Name | Type | Mandatory| Description | +| --------- | ------------------------------- | ---- | ---------------------- | +| localName | string | Yes | Name of the OS account to create.| +| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.| - | Type | Description | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise used to return the OS account created.| +**Return Value** -- Example +| Type | Description | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise used to return the OS account created.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1015,21 +1120,27 @@ Creates an OS account. This method uses a promise to return the result. }); ``` -### createOsAccountForDomain +### createOsAccountForDomain8+ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>): void Creates an OS account and associates it with the specified domain account. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | :-------- | ---------------------------- | ---- | -------------------- | - | type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. | - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | Yes | Callback used to return the OS account created.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| :--------- | ---------------------------------------------------- | ---- | ------------------------------------------ | +| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | Yes | Callback used to return the OS account created.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1040,26 +1151,32 @@ Creates an OS account and associates it with the specified domain account. This }); ``` -### createOsAccountForDomain +### createOsAccountForDomain8+ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise<OsAccountInfo> Creates an OS account and associates it with the specified domain account. This method uses a promise to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | --------- | ------------- | ---- | ---------------- | - | type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.| - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information.| +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | ---------------------- | +| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.| +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. | -- Return value +**Return Value** - | Type | Description | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise used to return the OS account created.| +| Type | Description | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise used to return the OS account created.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1077,13 +1194,17 @@ queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void Obtains information about the OS account to which the current process belongs. This method uses an asynchronous callback to return the result. -- Parameters +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS - | Name | Type | Mandatory| Description | - | -------- | ---------------------------- | ---- | -------------------------- | - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | Yes | Callback used to return information about the OS account obtained.| +**System capability**: SystemCapability.Account.OsAccount -- Example +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | Yes | Callback used to return information about the OS account obtained.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1099,13 +1220,17 @@ queryCurrentOsAccount(): Promise<OsAccountInfo> Obtains information about the OS account to which the current process belongs. This method uses a promise to return the result. -- Return value +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount + +**Return Value** - | Type | Description | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise used to return information about the OS account obtained.| +| Type | Description | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise used to return information about the OS account obtained.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1122,17 +1247,21 @@ queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo> Obtains information about an OS account. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. - | Name | Type | Mandatory| Description | - | -------- | ---------------------------- | ---- | -------------------------- | - | localId | number | Yes | ID of the target OS account.| - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | Yes | Callback used to return the OS account information obtained.| +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION -- Example +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------- | +| localId | number | Yes | ID of the target OS account. | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | Yes | Callback used to return the OS account information obtained.| + +**Example**: Query information about OS account 100. - Query information about OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -1148,22 +1277,26 @@ queryOsAccountById(localId: number): Promise<OsAccountInfo> Obtains information about an OS account. This method uses a promise to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS and ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION - | Name | Type | Mandatory| Description | - | -------- | ---------------------------- | ---- | -------------------------- | - | localId | number | Yes | ID of the target OS account.| +**System capability**: SystemCapability.Account.OsAccount -- Return value +**Parameters** - | Type | Description | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise used to return the OS account information obtained.| +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | -------------------- | +| localId | number | Yes | ID of the target OS account.| -- Example +**Return Value** + +| Type | Description | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise used to return the OS account information obtained.| + +**Example**: Query information about OS account 100. - Query information about OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -1180,13 +1313,15 @@ getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void Obtains the type of the OS account to which the current process belongs. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------------- | ---- | ---------------------------------------- | - | callback | AsyncCallback<[OsAccountType](#osaccounttype)> | Yes | Callback used to return the OS account type.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- | +| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | Yes | Callback used to return the OS account type.| -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1202,13 +1337,15 @@ getOsAccountTypeFromProcess(): Promise<OsAccountType> Obtains the type of the OS account to which the current process belongs. This method uses a promise to return the result. -- Return value +**System capability**: SystemCapability.Account.OsAccount - | Type | Description | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountType](#osaccounttype)> | Promise used to return the OS account type.| +**Return Value** -- Example +| Type | Description | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountType](#osaccounttype)> | Promise used to return the OS account type.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1225,13 +1362,17 @@ getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void Obtains the ID of this distributed virtual device. This method uses an asynchronous callback to return the result. -- Parameters +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | -------- | --------------------- | ---- | ---------------------------- | - | callback | AsyncCallback<string> | Yes | Callback used to return the device ID obtained.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ------------------------------------ | +| callback | AsyncCallback<string> | Yes | Callback used to return the device ID obtained.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1247,13 +1388,17 @@ getDistributedVirtualDeviceId(): Promise<string> Obtains the ID of this distributed virtual device. This method uses a promise to return the result. -- Return value +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Account.OsAccount - | Type | Description | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise used to return the device ID obtained.| +**Return Value** -- Example +| Type | Description | +| :-------------------- | :----------------------------------------------------------- | +| Promise<string> | Promise used to return the device ID obtained.| + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1270,17 +1415,21 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>) Obtains the profile photo of an OS account. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------- | ---- | ------------------------ | - | localId | number | Yes | ID of the target OS account. | - | callback | AsyncCallback<string> | Yes | Callback used to return the profile photo obtained.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ---------------------------------------- | +| localId | number | Yes | ID of the target OS account. | +| callback | AsyncCallback<string> | Yes | Callback used to return the profile photo obtained.| -- Example +**Example**: Obtain the profile photo of OS account 100. - Obtain the profile photo of OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -1296,22 +1445,26 @@ getOsAccountProfilePhoto(localId: number): Promise<string> Obtains the profile photo of an OS account. This method uses a promise to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. - | Name | Type | Mandatory| Description | - | ------- | ------ | ---- | ------------ | - | localId | number | Yes | ID of the target OS account.| +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS -- Return value +**System capability**: SystemCapability.Account.OsAccount - | Type | Description | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise used to return the profile photo obtained.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------ | +| localId | number | Yes | ID of the target OS account.| + +**Return Value** + +| Type | Description | +| :-------------------- | :----------------------------------------------------------- | +| Promise<string> | Promise used to return the profile photo obtained.| + +**Example**: Obtain the profile photo of OS account 100. - Obtain the profile photo of OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -1328,18 +1481,22 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback Sets a profile photo for an OS account. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS - | Name | Type | Mandatory| Description | - | -------- | ------------------- | ---- | ------------------------ | - | localId | number | Yes | ID of the target OS account. | - | photo | string | Yes | Profile photo information. | - | callback | AsyncCallback<void> | Yes | Callback used to return the result.| +**System capability**: SystemCapability.Account.OsAccount -- Example +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------ | +| localId | number | Yes | ID of the target OS account.| +| photo | string | Yes | Profile photo information. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example**: Set a profile photo for OS account 100. - Set a profile photo for OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -1358,23 +1515,27 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void> Sets a profile photo for an OS account. This method uses a promise to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS - | Name | Type | Mandatory| Description | - | ------- | ------ | ---- | ------------ | - | localId | number | Yes | ID of the target OS account.| - | photo | string | Yes | Profile photo information. | +**System capability**: SystemCapability.Account.OsAccount -- Return value +**Parameters** - | Type | Description | - | :------------ | :---------------------------------- | - | Promise<void> | Promise used to return the result.| +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------ | +| localId | number | Yes | ID of the target OS account.| +| photo | string | Yes | Profile photo information. | -- Example +**Return Value** + +| Type | Description | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise used to return the result.| + +**Example**: Set a profile photo for OS account 100. - Set a profile photo for OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -1389,23 +1550,23 @@ Sets a profile photo for an OS account. This method uses a promise to return the }); ``` -### getOsAccountLocalIdBySerialNumber +### getOsAccountLocalIdBySerialNumber8+ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void Obtains the OS account ID based on the SN. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | ------------ | --------------------- | ---- | ------------------------------ | - | serialNumber | number | Yes | Account SN. | - | callback | AsyncCallback<number> | Yes | Callback used to return the OS account ID obtained.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| ------------ | --------------------------- | ---- | ------------------------------------------------ | +| serialNumber | number | Yes | Account SN. | +| callback | AsyncCallback<number> | Yes | Callback used to return the OS account ID obtained.| + +**Example**: Obtain the ID of the OS account whose SN is **12345**. - Obtain the ID of the OS account whose SN is 12345. - ``` const accountManager = account_osAccount.getAccountManager(); var serialNumber = 12345; @@ -1415,28 +1576,28 @@ Obtains the OS account ID based on the SN. This method uses an asynchronous call }); ``` -### getOsAccountLocalIdBySerialNumber +### getOsAccountLocalIdBySerialNumber8+ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> Obtains the OS account ID based on the SN. This method uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | ------------ | ------ | ---- | ---------- | - | serialNumber | number | Yes | Account SN.| +| Name | Type | Mandatory| Description | +| ------------ | ------ | ---- | ---------- | +| serialNumber | number | Yes | Account SN.| -- Return value +**Return Value** - | Type | Description | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise used to return the OS account ID obtained.| +| Type | Description | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise used to return the OS account ID obtained.| -- Example +**Example**: Obtain the ID of the OS account whose SN is **12345**. - Obtain the ID of the OS account whose SN is 12345. - ``` const accountManager = account_osAccount.getAccountManager(); var serialNumber = 12345; @@ -1447,23 +1608,23 @@ Obtains the OS account ID based on the SN. This method uses a promise to return }); ``` -### getSerialNumberByOsAccountLocalId +### getSerialNumberByOsAccountLocalId8+ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void Obtains the SN of an OS account based on the account ID. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | -------- | --------------------- | ---- | ------------------------------ | - | localId | number | Yes | ID of the target OS account. | - | callback | AsyncCallback<number> | Yes | Callback used to return the account SN obtained.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ------------------------------------------ | +| localId | number | Yes | ID of the target OS account. | +| callback | AsyncCallback<number> | Yes | Callback used to return the account SN obtained.| + +**Example**: Obtain the SN of OS account 100. - Obtain the SN of the OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -1473,28 +1634,28 @@ Obtains the SN of an OS account based on the account ID. This method uses an asy }); ``` -### getSerialNumberByOsAccountLocalId +### getSerialNumberByOsAccountLocalId8+ getSerialNumberByOsAccountLocalId(localId: number): Promise<number> Obtains the SN of an OS account based on the account ID. This method uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | ------- | ------ | ---- | ------------ | - | localId | number | Yes | ID of the target OS account.| +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------ | +| localId | number | Yes | ID of the target OS account.| -- Return value +**Return Value** - | Type | Description | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise used to return the account SN obtained.| +| Type | Description | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise used to return the account SN obtained.| -- Example +**Example**: Obtain the SN of OS account 100. - Obtain the SN of the OS account 100. - ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -1511,15 +1672,21 @@ on(type: 'activate' | 'activating', name: string, callback: Callback<number&g Subscribes to OS account changes. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION + +**System capability**: SystemCapability.Account.OsAccount - | Name | Type | Mandatory| Description | - | -------- | -------------------------- | ---- | ------------------------ | - | type | 'activate' \| 'activating' | Yes | Type of the event to subscribe to. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated. | - | name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes.| - | callback | Callback<number> | Yes | Callback used to return the OS account ID and status changes.| +**Parameters** -- Example +| Name | Type | Mandatory| Description | +| -------- | -------------------------- | ---- | ------------------------------------------------------------ | +| type | 'activate' \| 'activating' | Yes | Type of the event to subscribe to. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated.| +| name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes. | +| callback | Callback<number> | Yes | Callback used to return the OS account ID and status changes. | + +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1535,15 +1702,21 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number Unsubscribes from the OS account changes. This method uses an asynchronous callback to return the result. -- Parameters +This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------- | ---- | ---------------------------- | - | type | 'activate' \| 'activating' | Yes | Type of the event to unsubscribe from. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated. | - | name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes, and must be the same as the value passed by **on()**.| - | callback | Callback<number> | No | Callback used to return the OS account changes. By default, **0** is returned.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------- | ---- | ------------------------------------------------------------ | +| type | 'activate' \| 'activating' | Yes | Type of the event to unsubscribe from. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated.| +| name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes, and must be the same as the value passed by **on()**.| +| callback | Callback<number> | No | Callback used to return the OS account changes. By default, **0** is returned. | -- Example +**Example** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1555,44 +1728,50 @@ Unsubscribes from the OS account changes. This method uses an asynchronous callb ## OsAccountInfo Defines information about an OS account. -| Name | Type | Mandatory| Description | -| ----------------- | ---------------------------------- | ---- | ------------------------ | -| localId | number | Yes | ID of the target OS account. | -| localName | string | Yes | OS account name. | -| type | [OsAccountType](#osaccounttype) | Yes | OS account type. | -| [constraints](constraints) | Array<string> | No | Constraints on the OS account. | -| isVerified | boolean | Yes | Whether the OS account is verified. | -| photo | string | No | Profile photo of the OS account. | -| createTime | number | Yes | Time when the OS account was created. | -| lastLoginTime | number | No | Last login time of the OS account.| -| serialNumber | number | Yes | SN of the OS account. | -| isActived | boolean | Yes | Whether the OS account is activated. | -| isCreateCompleted | boolean | Yes | Whether the OS account information is complete. | -| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | No | Distributed account information. | -| domainInfo | [DomainAccountInfo](#domainaccountinfo) | No | Domain account information. | + +**System capability**: SystemCapability.Account.OsAccount + +| Name | Type | Mandatory| Description | +| ----------------- | ------------------------------------------------------------ | ---- | --------------------------------- | +| localId | number | Yes | ID of the target OS account. | +| localName | string | Yes | OS account name. | +| type | [OsAccountType](#osaccounttype) | Yes | OS account type. | +| constraints | Array<string> | No | [Constraints](#constraints) on the OS account.| +| isVerified | boolean | Yes | Whether the OS account is verified. | +| photo | string | No | Profile photo of the OS account. | +| createTime | number | Yes | Time when the OS account was created. | +| lastLoginTime | number | No | Last login time of the OS account. | +| serialNumber | number | Yes | SN of the OS account. | +| isActived | boolean | Yes | Whether the OS account is activated. | +| isCreateCompleted | boolean | Yes | Whether the OS account information is complete. | +| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | No | Distributed account information. | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | No | Domain account information. | ## DomainAccountInfo -Defines the domain account information. -| Name | Type | Mandatory| Description | -| ----------------- | ---------------------------------- | ---- | ------------------------ | -| domain | string | Yes | Domain name. | -| accountName | string | Yes | Domain account name. | +Domain account information. + +**System capability**: SystemCapability.Account.OsAccount + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ---------- | +| domain | string | Yes | Domain name. | +| accountName | string | Yes | Domain account name.| ## Constraints -| Constraint| Description| -| ----------------- | ------------------- | -| constraint.wifi | A user is not allowed to use Wi-Fi.| -| constraint.wifi.set | A user is not allowed to change Wi-Fi settings.| -| constraint.locale.set | A user is not allowed to change the device language.| -| constraint.app.accounts | A user is not allowed to add or delete app accounts.| -| constraint.apps.install | A user is not allowed to install apps.| -| constraint.apps.uninstall | A user is not allowed to uninstall apps.| -| constraint.location.shared | A user is not allowed to enable location sharing.| -| constraint.unknown.sources.install | A user is not allowed to install apps from unknown sources.| +| Constraint | Description | +| ------------------------------------- | ------------------------------ | +| constraint.wifi | A user is not allowed to use Wi-Fi. | +| constraint.wifi.set | A user is not allowed to change Wi-Fi settings. | +| constraint.locale.set | A user is not allowed to change the device language. | +| constraint.app.accounts | A user is not allowed to add or delete app accounts. | +| constraint.apps.install | A user is not allowed to install apps. | +| constraint.apps.uninstall | A user is not allowed to uninstall apps. | +| constraint.location.shared | A user is not allowed to enable location sharing. | +| constraint.unknown.sources.install | A user is not allowed to install apps from unknown sources. | | constraint.global.unknown.app.install | All users are not allowed to install apps from unknown sources.| -| constraint.bluetooth.set | A user is not allowed to configure Bluetooth.| -| constraint.bluetooth | The use of Bluetooth is prohibited on the device. +| constraint.bluetooth.set | A user is not allowed to configure Bluetooth. | +| constraint.bluetooth | The use of Bluetooth is prohibited on the device.| | constraint.bluetooth.share | Bluetooth sharing is prohibited.| | constraint.usb.file.transfer | A user is not allowed to transfer files over USB.| | constraint.credentials.set | A user is not allowed to configure user credentials.| diff --git a/en/application-dev/reference/apis/js-apis-particleAbility.md b/en/application-dev/reference/apis/js-apis-particleAbility.md index 84d4281dd8e8c1faa843cd92856f75c54d5d5d50..6fd96f25e11de096e58c69c98706febbbde9af95 100644 --- a/en/application-dev/reference/apis/js-apis-particleAbility.md +++ b/en/application-dev/reference/apis/js-apis-particleAbility.md @@ -1,5 +1,8 @@ # ParticleAbility Module +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Constraints The ParticleAbility module is used to perform operations on abilities of the Data and Service types. @@ -12,13 +15,11 @@ import particleAbility from '@ohos.ability.particleAbility' ## particleAbility.startAbility -startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\: void - -Starts a particle ability. This method uses a callback to return the result. +startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\): void -**System capabilities** +Starts a particle ability. This API uses an asynchronous callback to return the result. -SystemCapability.Ability.AbilityRuntime.FAModel +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **Parameters** @@ -57,16 +58,11 @@ particleAbility.startAbility( ## particleAbility.startAbility -**System capabilities** - -SystemCapability.Ability.AbilityRuntime.FAModel +startAbility(parameter: StartAbilityParameter): Promise; -startAbility(parameter: StartAbilityParameter): Promise\ -Starts a particle ability. This method uses a promise to return the result. +Starts a particle ability. This API uses a promise to return the result. -**System capabilities** - -SystemCapability.Ability.AbilityRuntime.FAModel +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **Parameters** @@ -74,7 +70,9 @@ SystemCapability.Ability.AbilityRuntime.FAModel | Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | ----------------- | | parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| + **Return value** + | Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| @@ -109,11 +107,9 @@ particleAbility.startAbility( terminateSelf(callback: AsyncCallback\): void -Terminates this particle ability. This method uses a callback to return the result. +Terminates this particle ability. This API uses an asynchronous callback to return the result. -**System capabilities** - -SystemCapability.Ability.AbilityRuntime.FAModel +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **Parameters** @@ -138,13 +134,12 @@ particleAbility.terminateSelf( terminateSelf(): Promise\ -Terminates this particle ability. This method uses a promise to return the result. - -**System capabilities** +Terminates this particle ability. This API uses a promise to return the result. -SystemCapability.Ability.AbilityRuntime.FAModel +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **Return value** + | Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| @@ -166,9 +161,7 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper Obtains a **dataAbilityHelper** object. -**System capabilities** - -SystemCapability.Ability.AbilityRuntime.FAModel +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **Parameters** @@ -190,91 +183,25 @@ var uri = ""; particleAbility.acquireDataAbilityHelper(uri) ``` -## StartAbilityParameter - -| 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 - -| Name | Readable/Writable| Type | Mandatory| Description | -| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| deviceId | Read-only | string | No | ID of the device running the ability to start.
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, numbers are passed in. 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 the **Want** object.
System capabilities: SystemCapability.Ability.AbilityBase | -| entities | Read-only | Array\ | No | List of entities.
System capabilities: SystemCapability.Ability.AbilityBase | - -## flags - -| Name | Value | 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| - -## 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**. - -Defines special attributes of an ability, for example, **featureAbility.AbilityStartSetting.BOUNDS_KEY**. - -| Name | Value | Description | -| --------------- | --------------- | -------------------------- | -| BOUNDS_KEY | "abilityBounds" | Ability window size.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | -| WINDOW_MODE_KEY | "windowMode" | Ability window display mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | -| DISPLAY_ID_KEY | "displayId" | Display device ID.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| - -## AbilityWindowConfiguration - -Defines the window display modes of a Page ability, for example, **featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED**. - -| Name | Value| Description | -| --------------------------- | ---- | ---------- | -| WINDOW_MODE_UNDEFINED | 0 | The Page ability is in an undefined window display mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | -| WINDOW_MODE_FULLSCREEN | 1 | The Page ability is in full screen mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | -| WINDOW_MODE_SPLIT_PRIMARY | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| -| WINDOW_MODE_SPLIT_SECONDARY | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| -| WINDOW_MODE_FLOATING | 102 | The Page ability is displayed in floating window mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | - ## particleAbility.startBackgroundRunning startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback<void>): void; -Requests a continuous task from the system. This method uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) +Requests a continuous task from the system. This API uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) -**System capabilities** +**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask +**Parameters** -- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | id | number | Yes| Notification ID of a continuous task.| | request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.| - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + + **Example** -- **Example** ```js import notification from '@ohos.notification'; import particleAbility from '@ohos.ability.particleAbility'; @@ -323,24 +250,25 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { startBackgroundRunning(id: number, request: NotificationRequest): Promise<void> -**System capabilities** - -SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask +**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -Requests a continuous task from the system. This method uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) +Requests a continuous task from the system. This API uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | id | number | Yes| Notification ID of a continuous task.| | request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.| **Return value** + | Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| -- **Example** +**Example** + ```js import notification from '@ohos.notification'; import particleAbility from '@ohos.ability.particleAbility'; @@ -385,18 +313,18 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { cancelBackgroundRunning(callback: AsyncCallback<void>): void; -Requests to cancel a continuous task from the system. This method uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) +Requests to cancel a continuous task from the system. This API uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) -**System capabilities** +**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + **Parameters** -- **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + + **Example** -- **Example** ```js import particleAbility from '@ohos.ability.particleAbility'; @@ -416,18 +344,18 @@ particleAbility.cancelBackgroundRunning(callback); cancelBackgroundRunning(): Promise<void>; -Requests to cancel a continuous task from the system. This method uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) - -**System capabilities** +Requests to cancel a continuous task from the system. This API uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) -SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask +**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **Return value** + | Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| -- **Example** + **Example** + ```js import particleAbility from '@ohos.ability.particleAbility'; @@ -438,3 +366,154 @@ particleAbility.cancelBackgroundRunning().then(() => { }); ``` + + +## particleAbility.connectAbility + +connectAbility(request: Want, options:ConnectOptions): number + +Connects this ability to a specific Service ability. This API uses a callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | -------------- | ---- | ---------------------------- | +| request | [Want](#want) | Yes | Service ability to connect.| +| options | ConnectOptions | Yes | Callback used to return the result. | + +**Example** + +```js + function onConnectCallback(element, remote){ + console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); + } + function onDisconnectCallback(element){ + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + } + function onFailedCallback(code){ + console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) + } + var connId = particleAbility.connectAbility( + { + bundleName: "com.ix.ServiceAbility", + abilityName: "ServiceAbilityA", + }, + { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback, + }, + ); + + particleAbility.disconnectAbility(connId).then((error,data)=>{ + console.log('particleAbilityTest result errCode : ' + error.code + " data: " + data); + }); + + +``` + + +## particleAbility.disconnectAbility + +disconnectAbility(connection: number, callback:AsyncCallback): void; + +Disconnects this ability from the Service ability. This API uses a callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + +**Example** + +```js + function onConnectCallback(element, remote){ + console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); + } + function onDisconnectCallback(element){ + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + } + function onFailedCallback(code){ + console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) + } + var connId = particleAbility.connectAbility( + { + bundleName: "com.ix.ServiceAbility", + abilityName: "ServiceAbilityA", + }, + { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback, + }, + ); + var result = particleAbility.disconnectAbility(connId, + (error,data) => { + console.log('particleAbilityTest DisConnectJsSameBundleName result errCode : ' + error.code + " data: " + data) + }, + ); + +``` + + +## particleAbility.disconnectAbility + +disconnectAbility(connection: number): Promise; + +Disconnects this ability from the Service ability. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel + +**Return value** + +| Type | Description | +| -------------- | ------------------------- | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +function onConnectCallback(element, remote){ + console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); + } + function onDisconnectCallback(element){ + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + } + function onFailedCallback(code){ + console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) + } + var connId = particleAbility.connectAbility( + { + bundleName: "com.ix.ServiceAbility", + abilityName: "ServiceAbilityA", + }, + { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback, + }, + ); + + particleAbility.disconnectAbility(connId).then((error,data)=>{ + console.log('particleAbilityTest result errCode : ' + error.code + " data: " + data); + }); + +``` + +## ErrorCode + +Enumerates error codes. + +| Name | Value | Description | +| ----------------------------- | ---- | ------------------------------------------------------------ | +| INVALID_PARAMETER | -1 | Invalid parameter.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel| + + + + + diff --git a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md index 413bd6246b8ada2a2a0d64d66e5897090ec6d80c..20f6b7859945481356f504b2bc8b64b41cdd58ff 100644 --- a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md +++ b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md @@ -9,7 +9,9 @@ Provides the permission request result. ## Attributes +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| permissions | Array<string> | Yes| No| Permissions requested.
System capability: SystemCapability.Ability.AbilityRuntime.Core| -| authResults | Array<number> | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite.
System capability: SystemCapability.Ability.AbilityRuntime.Core| +| permissions | Array<string> | Yes| No| Permissions requested.| +| authResults | Array<number> | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite. | diff --git a/en/application-dev/reference/apis/js-apis-process.md b/en/application-dev/reference/apis/js-apis-process.md index 7edbfd41dd53f609bfb3062ead40ba85fdbe0008..1e1e66595fc9c4fcc03fa48f6ca9de4a15214689 100755 --- a/en/application-dev/reference/apis/js-apis-process.md +++ b/en/application-dev/reference/apis/js-apis-process.md @@ -350,7 +350,7 @@ var pres = process.getEnvironmentVar("PATH") ## process.runCmd -runCmd(command: string, options?: { timeout : number, killSignal : number | string, maxBuffer : number }) : ChildProcess +runCmd(command: string, options?: { timeout : number, killSignal : number | string, maxBuffer : number }): ChildProcess Forks a new process to run a shell command and returns the **ChildProcess** object. @@ -527,7 +527,7 @@ var time = process.uptime(); ## process.kill -kill(pid: number, signal: number ): boolean +kill(signal: number, pid: number): boolean Sends a signal to the specified process to terminate it. diff --git a/en/application-dev/reference/apis/js-apis-processrunninginfo.md b/en/application-dev/reference/apis/js-apis-processrunninginfo.md index 5f1e7c420e7402bbc6c8b631c16c05b527710edf..5306bc6697e98fd3f749953a795077dd5d02a2ec 100644 --- a/en/application-dev/reference/apis/js-apis-processrunninginfo.md +++ b/en/application-dev/reference/apis/js-apis-processrunninginfo.md @@ -14,7 +14,7 @@ The process running information is obtained through an **appManager** instance. -``` +```js import appManager from '@ohos.application.appManager'; appManager.getProcessRunningInfos((error,data) => { console.log("getProcessRunningInfos error: " + error.code + " data: " + JSON.stringify(data)); @@ -24,9 +24,11 @@ appManager.getProcessRunningInfos((error,data) => { ## Attributes +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| pid | number | Yes| No| Process ID.
System capability: SystemCapability.Ability.AbilityRuntime.Core| -| uid | number | Yes| No| User ID.
System capability: SystemCapability.Ability.AbilityRuntime.Core| -| processName | string | Yes| No| Process name.
System capability: SystemCapability.Ability.AbilityRuntime.Core| -| bundleNames | Array<string> | Yes| No| Names of all bundles running in the process.
System capability: SystemCapability.Ability.AbilityRuntime.Core| +| pid | number | Yes| No| Process ID.| +| uid | number | Yes| No| User ID.| +| processName | string | Yes| No| Process name.| +| bundleNames | Array<string> | Yes| No| Names of all bundles running in the process.| diff --git a/en/application-dev/reference/apis/js-apis-reminderAgent.md b/en/application-dev/reference/apis/js-apis-reminderAgent.md index 17834ad52509eed7f2f2ee928bdb5267c0f17030..c3ee9fdace8184109ddb62d58be87c3c30d99ac7 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgent.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgent.md @@ -457,7 +457,7 @@ Adds a reminder notification slot. This method uses an asynchronous callback to

slot

-

NotificationSlot

+

NotificationSlot

Yes

@@ -515,7 +515,7 @@ Adds a reminder notification slot. This method uses a promise to return the resu

slot

-

NotificationSlot

+

NotificationSlot

Yes

@@ -581,7 +581,7 @@ Removes a **NotificationSlot** instance of a specified type. This method uses

slotType

-

notification.SlotType

+

notification.SlotType

Yes

@@ -633,7 +633,7 @@ Removes a **NotificationSlot** instance of a specified type. This method uses

slotType

-

notification.SlotType

+

notification.SlotType

Yes

@@ -972,7 +972,7 @@ Defines the reminder to publish.

slotType

-

notification.SlotType

+

notification.SlotType

No

diff --git a/en/application-dev/reference/apis/js-apis-resource-manager.md b/en/application-dev/reference/apis/js-apis-resource-manager.md index 011b9cc217a06a07416cb37cc689d093f86c3947..5205bc6c9bdf5cbb741258be4425d032fab454a7 100644 --- a/en/application-dev/reference/apis/js-apis-resource-manager.md +++ b/en/application-dev/reference/apis/js-apis-resource-manager.md @@ -1,1329 +1,786 @@ -# Resource Manager +# Resource Management +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import +## Modules to Import ``` import resourceManager from '@ohos.resourceManager'; ``` -## Required Permissions - -None - -## resourceManager.getResourceManager - -getResourceManager\(callback: AsyncCallback\): void - -Obtains the **ResourceManager** object of the current application. This method uses a callback to return the result. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<ResourceManager>

-

Yes

-

Asynchronous callback used to return the ResourceManager object.

-
- - -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - mgr.getString(0x1000000, (error, value) => { - if (error != null) { - console.log(value); - } else { - console.log(value); - } - }); - }); - ``` - - -## resourceManager.getResourceManager - -getResourceManager\(bundleName: string, callback: AsyncCallback\): void - -Obtains the **ResourceManager** object of the specified application. This method uses a callback to return the result. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

bundleName

-

string

-

Yes

-

Bundle name of the specified application.

-

callback

-

AsyncCallback<ResourceManager>

-

Yes

-

Asynchronous callback used to return the ResourceManager object.

-
- -- Example - - ``` - resourceManager.getResourceManager("com.example.myapplication", (error, mgr) => { - }); - ``` - - -## resourceManager.getResourceManager - -getResourceManager\(\): Promise - -Obtains the **ResourceManager** object of the current application. This method uses a promise to return the result. - -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<ResourceManager>

-

Promise used to return the ResourceManager object.

-
- -- Example - - ``` - resourceManager.getResourceManager().then(mgr => { - mgr.getString(0x1000000, (error, value) => { - if (error != null) { - console.log(value); - } else { - console.log(value); - } - }); - }).catch(error => { - console.log(error); - }); - ``` - - -## resourceManager.getResourceManager - -getResourceManager\(bundleName: string\): Promise - -Obtains the **ResourceManager** object of the specified application. This method uses a promise to return the result. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

bundleName

-

string

-

Yes

-

Bundle name of the specified application.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<ResourceManager>

-

Promise used to return the ResourceManager object.

-
- -- Example - - ``` - resourceManager.getResourceManager("com.example.myapplication").then(mgr => { - - }).catch(error => { - - }); - ``` - - -## Direction - -Enumerates screen directions. - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

DIRECTION_VERTICAL

-

0

-

Portrait

-

DIRECTION_HORIZONTAL

-

1

-

Landscape

-
- -## DeviceType - -Enumerates device types. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

DEVICE_TYPE_PHONE

-

0x00

-

Phone

-

DEVICE_TYPE_TABLET

-

0x01

-

Tablet

-

DEVICE_TYPE_CAR

-

0x02

-

Head unit

-

DEVICE_TYPE_PC

-

0x03

-

PC

-

DEVICE_TYPE_TV

-

0x04

-

Smart TV

-

DEVICE_TYPE_WEARABLE

-

0x06

-

Wearable

-
- -## ScreenDensity - -Enumerates screen density types. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

SCREEN_SDPI

-

120

-

Screen density with small-scale dots per inch (SDPI).

-

SCREEN_MDPI

-

160

-

Screen density with medium-scale dots per inch (MDPI)

-

SCREEN_LDPI

-

240

-

Screen density with large-scale dots per inch (LDPI).

-

SCREEN_XLDPI

-

320

-

Screen density with extra-large-scale dots per inch (XLDPI).

-

SCREEN_XXLDPI

-

480

-

Screen density with extra-extra-large-scale dots per inch (XXLDPI).

-

SCREEN_XXXLDPI

-

640

-

Screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI).

-
- -## Configuration - -Provides the device configuration. - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

direction

-

Direction

-

Yes

-

No

-

Screen direction of the current device.

-

locale

-

string

-

Yes

-

No

-

Current system language.

-
- -## DeviceCapability - -Provides the device capability. - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

screenDensity

-

ScreenDensity

-

Yes

-

No

-

Screen density of the current device.

-

deviceType

-

DeviceType

-

Yes

-

No

-

Type of the current device.

-
- -## ResourceManager - -Provides the capability of accessing application resources. - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The methods involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm. ->- Resource files are defined in the **resources** directory of the project. You can obtain the resource ID from **$r\(resource address\).id**, for example, **$r\(?app.string.test?\).id**. - -### getString - -getString\(resId: number, callback: AsyncCallback\): void - -Obtains the string corresponding to the specified resource ID. This method uses a callback to return the result. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

resId

-

number

-

Yes

-

Resource ID.

-

callback

-

AsyncCallback<string>

-

Yes

-

Asynchronous callback used to return the obtained string.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getString($r('app.string.test').id, (error, value) => { - if (error != null) { - console.log(value); - } else { - console.log(value); - } - }); - }); - ``` - - -### getString - -getString\(resId: number\): Promise +## resourceManager.getResourceManager + +getResourceManager(callback: AsyncCallback<ResourceManager>): void + +Obtains the **ResourceManager** object of this application. This method uses a callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes| Callback used to return the **ResourceManager** object obtained.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + if (error != null) { + console.log("error occurs" + error); + return; + } + mgr.getString(0x1000000, (error, value) => { + if (error != null) { + console.log(value); + } else { + console.log(value); + } + }); + }); + ``` + + +## resourceManager.getResourceManager + +getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManager>): void + +Obtains the **ResourceManager** object of an application. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | bundleName | string | Yes| Bundle name of the target application.| + | callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes| Callback used to return the **ResourceManager** object obtained.| + +- Example + ``` + resourceManager.getResourceManager("com.example.myapplication", (error, mgr) => { + }); + ``` + + +## resourceManager.getResourceManager + +getResourceManager(): Promise<ResourceManager> + +Obtains the **ResourceManager** object of this application. This method uses a promise to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained.| + +- Example + ``` + resourceManager.getResourceManager().then(mgr => { + mgr.getString(0x1000000, (error, value) => { + if (error != null) { + console.log(value); + } else { + console.log(value); + } + }); + }).catch(error => { + console.log(error); + }); + ``` + + +## resourceManager.getResourceManager + +getResourceManager(bundleName: string): Promise<ResourceManager> + +Obtains the **ResourceManager** object of an application. This method uses a promise to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | bundleName | string | Yes| Bundle name of the target application.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained.| + +- Example + ``` + resourceManager.getResourceManager("com.example.myapplication").then(mgr => { + + }).catch(error => { + + }); + ``` + + +## Direction + +Enumerates the screen directions. + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| DIRECTION_VERTICAL | 0 | Portrait
**System capability**: SystemCapability.Global.ResourceManager| +| DIRECTION_HORIZONTAL | 1 | Landscape
**System capability**: SystemCapability.Global.ResourceManager| + + +## DeviceType + +Enumerates the device types. + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| DEVICE_TYPE_PHONE | 0x00 | Mobile phone.
**System capability**: SystemCapability.Global.ResourceManager| +| DEVICE_TYPE_TABLET | 0x01 | Tablet.
**System capability**: SystemCapability.Global.ResourceManager| +| DEVICE_TYPE_CAR | 0x02 | Automobile.
**System capability**: SystemCapability.Global.ResourceManager| +| DEVICE_TYPE_PC | 0x03 | Computer.
**System capability**: SystemCapability.Global.ResourceManager| +| DEVICE_TYPE_TV | 0x04 | TV.
**System capability**: SystemCapability.Global.ResourceManager| +| DEVICE_TYPE_WEARABLE | 0x06 | Wearable.
**System capability**: SystemCapability.Global.ResourceManager| + + +## ScreenDensity + +Enumerates the screen density types. + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| SCREEN_SDPI | 120 | Screen density with small-scale dots per inch (SDPI).
**System capability**: SystemCapability.Global.ResourceManager| +| SCREEN_MDPI | 160 | Screen density with medium-scale dots per inch (MDPI).
**System capability**: SystemCapability.Global.ResourceManager| +| SCREEN_LDPI | 240 | Screen density with large-scale dots per inch (LDPI).
**System capability**: SystemCapability.Global.ResourceManager| +| SCREEN_XLDPI | 320 | Screen density with extra-large-scale dots per inch (XLDPI).
**System capability**: SystemCapability.Global.ResourceManager| +| SCREEN_XXLDPI | 480 | Screen density with extra-extra-large-scale dots per inch (XXLDPI).
**System capability**: SystemCapability.Global.ResourceManager| +| SCREEN_XXXLDPI | 640 | Screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI).
**System capability**: SystemCapability.Global.ResourceManager| + + +## Configuration + +Defines the device configuration. + + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| direction | [Direction](#direction) | Yes| No| Screen direction of the device.
**System capability**: SystemCapability.Global.ResourceManager| +| locale | string | Yes| No| Current system language.
**System capability**: SystemCapability.Global.ResourceManager| + + +## DeviceCapability + +Defines the device capability. + + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| screenDensity | [ScreenDensity](#screendensity) | Yes| No| Screen density of the device.
**System capability**: SystemCapability.Global.ResourceManager| +| deviceType | [DeviceType](#devicetype) | Yes| No| Type of the device.
**System capability**: SystemCapability.Global.ResourceManager| + + +## RawFileDescriptor8+ + +Defines the descriptor information of the raw file. +
**System capability**: SystemCapability.Global.ResourceManager + +| Name| Type| Description| +| -------- | -------- | -------- | +| fd | number | Descriptor of a raw file.| +| offset | number | Offset to the start position of the raw file.| +| length | number | Length of the raw file.| + + +## ResourceManager + +Defines the capability of accessing application resources. + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> - The methods involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm. +> +> - Resource files are defined in the **resources** directory of the project. You can obtain the resource ID using **$r(resource address).id**, for example, **$r('app.string.test').id**. + + +### getString + +getString(resId: number, callback: AsyncCallback<string>): void + +Obtains the string corresponding to the specified resource ID. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | resId | number | Yes| Resource ID.| + | callback | AsyncCallback<string> | Yes| Callback used to return the string obtained.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getString($r('app.string.test').id, (error, value) => { + if (error != null) { + console.log(value); + } else { + console.log(value); + } + }); + }); + ``` + + +### getString + +getString(resId: number): Promise<string> Obtains the string corresponding to the specified resource ID. This method uses a promise to return the result. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

resId

-

number

-

Yes

-

Resource ID.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<string>

-

String corresponding to the resource ID.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getString($r('app.string.test').id).then(value => { - console.log(value); - }).catch(error => { - console.log("getstring promise " + error); - }); - }); - ``` - - -### getStringArray - -getStringArray\(resId: number, callback: AsyncCallback\>\): void - -Obtains the array of strings corresponding to the specified resource ID. This method uses a callback to return the result. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

resId

-

number

-

Yes

-

Resource ID.

-

callback

-

AsyncCallback<Array<string>>

-

Yes

-

Asynchronous callback used to return the obtained array of strings.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getStringArray($r('app.strarray.test').id, (error, value) => { - if (error != null) { - console.log(value); - } else { - console.log(value); - } - }); - }); - ``` - - -### getStringArray - -getStringArray\(resId: number\): Promise\> +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | resId | number | Yes| Resource ID.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<string> | Promise used to return the string obtained.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getString($r('app.string.test').id).then(value => { + console.log(value); + }).catch(error => { + console.log("getstring promise " + error); + }); + }); + ``` + + +### getStringArray + +getStringArray(resId: number, callback: AsyncCallback<Array<string>>): void + +Obtains the array of strings corresponding to the specified resource ID. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | resId | number | Yes| Resource ID.| + | callback | AsyncCallback<Array<string>> | Yes| Callback used to return the obtained array of strings.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getStringArray($r('app.strarray.test').id, (error, value) => { + if (error != null) { + console.log(value); + } else { + console.log(value); + } + }); + }); + ``` + + +### getStringArray + +getStringArray(resId: number): Promise<Array<string>> Obtains the array of strings corresponding to the specified resource ID. This method uses a promise to return the result. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

resId

-

number

-

Yes

-

Resource ID.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<Array<string>>

-

Array of strings corresponding to the specified resource ID.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getStringArray($r('app.strarray.test').id).then(value => { - console.log(value); - }).catch(error => { - console.log("getstring promise " + error); - }); - }); - ``` - - -### getMedia - -getMedia\(resId: number, callback: AsyncCallback\): void - -Obtains the content of the media file corresponding to the specified resource ID. This method uses a callback to return the result. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

resId

-

number

-

Yes

-

Resource ID.

-

callback

-

AsyncCallback<Uint8Array>

-

Yes

-

Asynchronous callback used to return the content of the obtained media file.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getMedia($r('app.media.test').id, (error, value) => { - if (error != null) { - console.log(value); - } else { - console.log(value); - } - }); - }); - ``` - - -### getMedia - -getMedia\(resId: number\): Promise +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | resId | number | Yes| Resource ID.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<Array<string>> | Promise used to return the array of strings obtained.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getStringArray($r('app.strarray.test').id).then(value => { + console.log(value); + }).catch(error => { + console.log("getstring promise " + error); + }); + }); + ``` + + +### getMedia + +getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void + +Obtains the content of the media file corresponding to the specified resource ID. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | resId | number | Yes| Resource ID.| + | callback | AsyncCallback<Uint8Array> | Yes| Callback used to return the content of the media file obtained.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getMedia($r('app.media.test').id, (error, value) => { + if (error != null) { + console.log(value); + } else { + console.log(value); + } + }); + }); + ``` + + +### getMedia + +getMedia(resId: number): Promise<Uint8Array> Obtains the content of the media file corresponding to the specified resource ID. This method uses a promise to return the result. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

resId

-

number

-

Yes

-

Resource ID.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<Uint8Array>

-

Promise used to return the content of the obtained media file.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getMedia($r('app.media.test').id).then(value => { - console.log(value); - }).catch(error => { - console.log("getstring promise " + error); - }); - }); - ``` - - -### getMediaBase64 - -getMediaBase64\(resId: number, callback: AsyncCallback\): void - -Obtains the Base64 code of the image corresponding to the specified resource ID. This method uses a callback to return the result. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

resId

-

number

-

Yes

-

Resource ID.

-

callback

-

AsyncCallback<string>

-

Yes

-

Asynchronous callback used to return the obtained Base64 code of the image.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getMediaBase64($r('app.media.test').id, (error, value) => { - if (error != null) { - console.log(value); - } else { - console.log(value); - } - }); - }); - ``` - - -### getMediaBase64 - -getMediaBase64\(resId: number\): Promise +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | resId | number | Yes| Resource ID.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<Uint8Array> | Promise used to return the content of the media file obtained.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getMedia($r('app.media.test').id).then(value => { + console.log(value); + }).catch(error => { + console.log("getstring promise " + error); + }); + }); + ``` + + +### getMediaBase64 + +getMediaBase64(resId: number, callback: AsyncCallback<string>): void + +Obtains the Base64 code of the image corresponding to the specified resource ID. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | resId | number | Yes| Resource ID.| + | callback | AsyncCallback<string> | Yes| Callback used to return the Base64 code of the image obtained.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getMediaBase64($r('app.media.test').id, (error, value) => { + if (error != null) { + console.log(value); + } else { + console.log(value); + } + }); + }); + ``` + + +### getMediaBase64 + +getMediaBase64(resId: number): Promise<string> Obtains the Base64 code of the image corresponding to the specified resource ID. This method uses a promise to return the result. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

resId

-

number

-

Yes

-

Resource ID.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<string>

-

Promise used to return the obtained Base64 code of the image.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getMediaBase64($r('app.media.test').id).then(value => { - console.log(value); - }).catch(error => { - console.log("getstring promise " + error); - }); - }); - ``` - - -### getConfiguration - -getConfiguration\(callback: AsyncCallback\): void - -Obtains the device configuration. This method uses a callback to return the result. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<Configuration>

-

Yes

-

Asynchronous callback used to return the obtained device configuration.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getConfiguration((error, value) => { - if (error != null) { - console.log(value); - } else { - console.log(value); - } - }); - }); - ``` - - -### getConfiguration - -getConfiguration\(\): Promise +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | resId | number | Yes| Resource ID.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<string> | Promise used to return the Base64 code of the image obtained.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getMediaBase64($r('app.media.test').id).then(value => { + console.log(value); + }).catch(error => { + console.log("getstring promise " + error); + }); + }); + ``` + + +### getConfiguration + +getConfiguration(callback: AsyncCallback<Configuration>): void + +Obtains the device configuration. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[Configuration](#configuration)> | Yes| Callback used to return the obtained device configuration.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getConfiguration((error, value) => { + if (error != null) { + console.log(value); + } else { + console.log(value); + } + }); + }); + ``` + + +### getConfiguration + +getConfiguration(): Promise<Configuration> Obtains the device configuration. This method uses a promise to return the result. -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<Configuration>

-

Promise used to return the device configuration.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getConfiguration().then(value => { - console.log(value); - }).catch(error => { - console.log("getstring promise " + error); - }); - }); - ``` - - -### getDeviceCapability - -getDeviceCapability\(callback: AsyncCallback\): void - -Obtains the device capability. This method uses a callback to return the result. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<DeviceCapability>

-

Yes

-

Asynchronous callback used to return the obtained device capability.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getDeviceCapability((error, value) => { - if (error != null) { - console.log(value); - } else { - console.log(value); - } - }); - }); - ``` - - -### getDeviceCapability - -getDeviceCapability\(\): Promise +**System capability**: SystemCapability.Global.ResourceManager + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<[Configuration](#configuration)> | Promise used to return the device configuration.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getConfiguration().then(value => { + console.log(value); + }).catch(error => { + console.log("getstring promise " + error); + }); + }); + ``` + + +### getDeviceCapability + +getDeviceCapability(callback: AsyncCallback<DeviceCapability>): void + +Obtains the device capability. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes| Callback used to return the obtained device capability.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getDeviceCapability((error, value) => { + if (error != null) { + console.log(value); + } else { + console.log(value); + } + }); + }); + ``` + + +### getDeviceCapability + +getDeviceCapability(): Promise<DeviceCapability> Obtains the device capability. This method uses a promise to return the result. -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<DeviceCapability>

-

Promise used to return the obtained device capability.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getDeviceCapability().then(value => { - console.log(value); - }).catch(error => { - console.log("getstring promise " + error); - }); - }); - ``` - - -### getPluralString - -getPluralString\(resId: number, num: number, callback: AsyncCallback\): void - -Obtains the specified number of singular-plural strings corresponding to the specified resource ID. This method uses a callback to return the result. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

resId

-

number

-

Yes

-

Resource ID.

-

num

-

number

-

Yes

-

Number that determines the plural or singular form.

-

callback

-

AsyncCallback<string>

-

Yes

-

Asynchronous callback used to return the obtained singular-plural string.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getPluralString($r("app.plural.test").id, 1, (error, value) => { - if (error != null) { - console.log(value); - } else { - console.log(value); - } - }); - }); - ``` - - -### getPluralString - -getPluralString\(resId: number, num: number\): Promise +**System capability**: SystemCapability.Global.ResourceManager -Obtains the specified number of singular-plural strings corresponding to the specified resource ID. This method uses a promise to return the result. +- Return value + | Type| Description| + | -------- | -------- | + | Promise<[DeviceCapability](#devicecapability)> | Promise used to return the obtained device capability.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getDeviceCapability().then(value => { + console.log(value); + }).catch(error => { + console.log("getstring promise " + error); + }); + }); + ``` + + +### getPluralString -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

resId

-

number

-

Yes

-

Resource ID.

-

num

-

number

-

Yes

-

Number that determines the plural or singular form.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<string>

-

Promise used to return the obtained singular-plural string.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getPluralString($r("app.plural.test").id, 1).then(value => { - console.log(value); - }).catch(error => { - console.log("getstring promise " + error); - }); - }); - ``` - - -### getRawFile8+ - -getRawFile\(path: string, callback: AsyncCallback\): void - -Obtains the content of rawfile in the specified path. This method uses an asynchronous callback to return the result. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

path

-

string

-

Yes

-

Path of the rawfile.

-

callback

-

AsyncCallback<Uint8Array>

-

Yes

-

Asynchronous callback used to return the rawfile content, in byte arrays.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getRawFile("test.xml", (error, value) => { - if (error != null) { - console.log(value); - } else { - console.log(value); - } - }); - }); - ``` - - -### getRawFile8+ - -getRawFile\(path: string\): Promise - -Obtains the content of the rawfile in the specified path. This method uses a promise to return the result. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

path

-

string

-

Yes

-

Path of the rawfile.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<Uint8Array>

-

Promise used to return the rawfile content, in byte arrays.

-
- -- Example - - ``` - resourceManager.getResourceManager((error, mgr) => { - mgr.getRawFile("test.xml").then(value => { - console.log(value); - }).catch(error => { - console.log("getrawfile promise " + error); - }); - }); - ``` +getPluralString(resId: number, num: number, callback: AsyncCallback<string>): void + +Obtains the specified number of singular-plural strings corresponding to the specified resource ID. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | resId | number | Yes| Resource ID.| + | num | number | Yes| Number that determines the plural or singular form.| + | callback | AsyncCallback<string> | Yes| Callback used to return the singular-plural string obtained.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getPluralString($r("app.plural.test").id, 1, (error, value) => { + if (error != null) { + console.log(value); + } else { + console.log(value); + } + }); + }); + ``` + + +### getPluralString + +getPluralString(resId: number, num: number): Promise<string> + +Obtains the specified number of singular-plural strings corresponding to the specified resource ID. This method uses a promise to return the result. +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | resId | number | Yes| Resource ID.| + | num | number | Yes| Number that determines the plural or singular form.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<string> | Promise used to return the singular-plural string obtained.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getPluralString($r("app.plural.test").id, 1).then(value => { + console.log(value); + }).catch(error => { + console.log("getstring promise " + error); + }); + }); + ``` + +### getRawFile8+ + +getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void + +Obtains the content of the raw file in the specified path. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | path | string | Yes| Path of the raw file.| + | callback | AsyncCallback<Uint8Array> | Yes| Callback used to return the raw file content, in byte arrays.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getRawFile("test.xml", (error, value) => { + if (error != null) { + console.log(value); + } else { + console.log(value); + } + }); + }); + ``` + +### getRawFile8+ + +getRawFile(path: string): Promise<Uint8Array> + +Obtains the content of the raw file in the specified path. This method uses a promise to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | path | string | Yes| Path of the raw file.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<Uint8Array> | Promise used to return the raw file content, in byte arrays.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getRawFile("test.xml").then(value => { + console.log(value); + }).catch(error => { + console.log("getrawfile promise " + error); + }); + }); + ``` + +### getRawFileDescriptor8+ + +getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor>): void + +Obtains the descriptor of the raw file in the specified path. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | path | string | Yes| Path of the raw file.| + | callback | AsyncCallback<[RawFileDescriptor](#RawFileDescriptor8+)> | Yes| Callback used to return the raw file descriptor.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getRawFileDescriptor("test.xml", (error, value) => { + if (error != null) { + console.log(value); + } else { + let fd = value.fd; + let offset = value.offset; + let length = value.length; + } + }); + }); + ``` + +### getRawFileDescriptor8+ + +getRawFileDescriptor(path: string): Promise<RawFileDescriptor> + +Obtains the descriptor of the raw file in the specified path. This method uses a promise to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | path | string | Yes| Path of the raw file.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<[RawFileDescriptor](#RawFileDescriptor8+)> | Promise used to return the raw file descriptor.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.getRawFileDescriptor("test.xml").then(value => { + let fd = value.fd; + let offset = value.offset; + let length = value.length; + }).catch(error => { + console.log("getRawFileDescriptor promise " + error); + }); + }); + ``` + +### closeRawFileDescriptor8+ + +closeRawFileDescriptor(path: string, callback: AsyncCallback<void>): void + +Closes the descriptor of the raw file in the specified path. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | path | string | Yes| Path of the raw file.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.closeRawFileDescriptor("test.xml", (error, value) => { + if (error != null) { + console.log(value); + } + }); + }); + ``` + +### closeRawFileDescriptor8+ + +closeRawFileDescriptor(path: string): Promise<void> + +Closes the descriptor of the raw file in the specified path. This method uses a promise to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | path | string | Yes| Path of the raw file.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<void> | No value is returned.| + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.closeRawFileDescriptor("test.xml").then(value => { + console.log(value); + }).catch(error => { + console.log("closeRawFileDescriptor promise " + error); + }); + }); + ``` + +### release7+ + +release(); + +Releases the created **resourceManager**. + +**System capability**: SystemCapability.Global.ResourceManager + +- Example + ``` + resourceManager.getResourceManager((error, mgr) => { + mgr.release((error, value) => { + if (error != null) { + console.log(value); + } + }); + }); + ``` diff --git a/en/application-dev/reference/apis/js-apis-runninglock.md b/en/application-dev/reference/apis/js-apis-runninglock.md index 6c73a1029c2cda00cf2af0f22ca141e71bf1f1d5..b2d01bd6da98d2781c3c6116af2b0a4817b6a47b 100644 --- a/en/application-dev/reference/apis/js-apis-runninglock.md +++ b/en/application-dev/reference/apis/js-apis-runninglock.md @@ -1,6 +1,6 @@ # Running Lock -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. The Running Lock module provides APIs for creating, querying, holding, and releasing running locks. @@ -19,9 +19,9 @@ Enumerates the types of **RunningLock** objects. **System capability:** SystemCapability.PowerManager.PowerManager.Core -| Name | Default Value | Description | +| Name | Default Value | Description | | ------------------------ | ---- | ------------------- | -| BACKGROUND | 1 | A lock that prevents the system from hibernating when the screen is off.| +| BACKGROUND | 1 | A lock that prevents the system from hibernating when the screen is off. | | PROXIMITY_SCREEN_CONTROL | 2 | A lock that determines whether to turn on or off the screen based on the distance away from the screen.| diff --git a/en/application-dev/reference/apis/js-apis-service-extension-context.md b/en/application-dev/reference/apis/js-apis-service-extension-context.md index 1c1d2b615a5b9344fab4247aa3b3e84b963c3a0b..ce5ab6b95a4e75fc5a5aa65ae37f75cdd0e0587c 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-service-extension-context.md @@ -9,25 +9,22 @@ Implements the context that provides the capabilities and APIs of **ServiceExten ## startAbility - startAbility(want: Want, callback: AsyncCallback<void>): void; +Starts an ability. This API uses a callback to return the result. -Starts an ability. This method 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 ability to start, such as the ability name and bundle name.| - | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the method is successfully called.| + | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| -- Example - ``` +**Example** + + ```js let want = { "bundleName": "com.example.myapp", "abilityName": "com.example.myapp.MyAbility" @@ -38,28 +35,29 @@ SystemCapability.Ability.AbilityRuntime.Core ``` -## startAbility +## ServiceExtensionContext.startAbility startAbility(want: Want): 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 ability to start, such as the ability name and bundle name.| -- 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 let want = { "bundleName": "com.example.myapp", "abilityName": "com.example.myapp.MyAbility" @@ -72,46 +70,46 @@ SystemCapability.Ability.AbilityRuntime.Core ``` -## terminateSelf +## ServiceExtensionContext.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> | No| Callback used to return the result indicating whether the method is successfully called.| + | callback | AsyncCallback<void> | No| 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 +## ServiceExtensionContext.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) => { @@ -120,29 +118,30 @@ SystemCapability.Ability.AbilityRuntime.Core ``` -## connectAbility +## ServiceExtensionContext.connectAbility connectAbility(want: Want, options: ConnectOptions): number; Connects this ability to a Service ability. -**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 ability to connect to, such as the ability name and bundle name.| | options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.| -- Return value +**Return value** + | Type| Description| | -------- | -------- | | number | A number, based on which the connection will be interrupted.| -- Example - ``` +**Example** + + ```js let want = { "bundleName": "com.example.myapp", "abilityName": "com.example.myapp.MyAbility" @@ -156,52 +155,53 @@ SystemCapability.Ability.AbilityRuntime.Core ``` -## disconnectAbility +## ServiceExtensionContext.disconnectAbility disconnectAbility(connection: number, callback:AsyncCallback<void>): void; -Disconnects this ability from the Service ability. This method uses a callback to return the result. +Disconnects this ability from the Service 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| | -------- | -------- | -------- | -------- | | connection | number | Yes| Number returned after **connectAbility** is called.| - | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the method is successfully called.| + | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| -- Example - ``` +**Example** + + ```js this.context.disconnectAbility(connection, (err) => { // connection is the return value of connectAbility. console.log('terminateSelf result:' + JSON.stringfy(err)); }); ``` -## disconnectAbility +## ServiceExtensionContext.disconnectAbility disconnectAbility(connection: number): Promise<void>; -Disconnects this ability from the Service ability. This method uses a promise to return the result. +Disconnects this ability from the Service 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| | -------- | -------- | -------- | -------- | | connection | number | Yes| Number returned after **connectAbility** is called.| -- 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.disconnectAbility(connection).then((data) => { // connection is the return value of connectAbility. console.log('success:' + JSON.stringfy(data)); }).catch((error) => { @@ -214,8 +214,10 @@ SystemCapability.Ability.AbilityRuntime.Core Defines the **ConnectOptions** data structure. +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + | Name| Description| | -------- | -------- | -| onConnect(elementName:ElementName, remote:IRemoteObject) | Called when this ability is connected to a Service ability.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| -| onDisconnect(elementName:ElementName) | Called when the peer service is abnormal or killed.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| -| onFailed(code: number) | Called when the connection fails.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| +| onConnect(elementName:ElementName, remote:IRemoteObject) | Called when this ability is connected to a Service ability.| +| onDisconnect(elementName:ElementName) | Called when the peer service is abnormal or killed.| +| onFailed(code: number) | Called when the connection fails.| diff --git a/en/application-dev/reference/apis/js-apis-service-extension.md b/en/application-dev/reference/apis/js-apis-service-extension.md index 0a6b357e97fad6ee1474e6925067361d78e0c6a1..76b55db35209bcf3b6bcbfc97f3d7d974dc05db2 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension.md +++ b/en/application-dev/reference/apis/js-apis-service-extension.md @@ -23,7 +23,7 @@ None | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.| +| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core| ## onCreate @@ -32,17 +32,17 @@ onCreate(want: Want): void; Called when an extension is created to initialize the service logic. -**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 related to this extension, including the ability name and bundle name.| -- Example - ``` +**Example** + + ```js class ServiceExt extends ServiceExtension { onCreate(want) { console.log('onCreate, want:' + want.abilityName); @@ -57,12 +57,11 @@ onDestroy(): void; Called when this extension is destroyed to clear resources. -**System capabilities** +**System capability**: SystemCapability.Ability.AbilityRuntime.Core -SystemCapability.Ability.AbilityRuntime.Core +**Example** -- Example - ``` + ```js class ServiceExt extends ServiceExtension { onDestroy() { console.log('onDestroy'); @@ -77,18 +76,18 @@ onRequest(want: Want, startId: number): void; Called after **onCreate** is invoked when an ability is started by calling **startAbility**. The value of **startId** is incremented for each ability that is started. -**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 related to this extension, including the ability name and bundle name.| | startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.| -- Example - ``` +**Example** + + ```js class ServiceExt extends ServiceExtension { onRequest(want, startId) { console.log('onRequest, want:' + want.abilityName); @@ -103,22 +102,23 @@ onConnect(want: Want): rpc.RemoteObject; Called after **onCreate** is invoked when an ability is started by calling **connectAbility**. A **RemoteObject** object is returned for communication with the client. -**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 related to this extension, including the ability name and bundle name.| -- Return value +**Return value** + | Type| Description| | -------- | -------- | | rpc.RemoteObject | A **RemoteObject** object used for communication with the client.| -- Example - ``` +**Example** + + ```js import rpc from '@ohos.rpc' class StubTest extends rpc.RemoteObject{ constructor(des) { @@ -142,17 +142,17 @@ onDisconnect(want: Want): void; Called when the ability is disconnected. -**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 related to this extension, including the ability name and bundle name.| -- Example - ``` +**Example** + + ```js class ServiceExt extends ServiceExtension { onDisconnect(want) { console.log('onDisconnect, want:' + want.abilityName); diff --git a/en/application-dev/reference/apis/js-apis-statfs.md b/en/application-dev/reference/apis/js-apis-statfs.md index 487903b87178466ff990eea4a8518a8fe58242ce..137f4cbc55ee2a9e0631e9f94e0244730a14ac87 100644 --- a/en/application-dev/reference/apis/js-apis-statfs.md +++ b/en/application-dev/reference/apis/js-apis-statfs.md @@ -1,6 +1,6 @@ # statfs -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -9,7 +9,7 @@ import statfs from '@ohos.statfs'; ``` -## 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). @@ -21,27 +21,25 @@ For example, if the application directory obtained by using **getOrCreateLocalDi let path = dir + "xxx.txt"; ``` -## System Capabilities - -SystemCapability.FileManagement.File.FileIO - ## statfs.getFreeBytes getFreeBytes(path:string):Promise<number> Obtains the number of free bytes of the specified file system in asynchronous mode. This method uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.FileManagement.File.FileIO + +- **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------- | - | path | string | Yes| File path of the file system.| + | path | string | Yes | File path of the file system.| -- Return values +- Return value - | Type| Description| + | Type | Description | | --------------------- | -------------- | - | Promise<number> | Number of free bytes obtained.| + | Promise<number> | Promise used to return the number of free bytes obtained.| - Example @@ -60,38 +58,42 @@ getFreeBytes(path:string, callback:AsyncCallback<number>): void Obtains the number of free bytes of the specified file system in asynchronous mode. This method uses a callback to return the result. -- Parameters +**System capability**: SystemCapability.FileManagement.File.FileIO - | Name| Type| Mandatory| Description| +- **Parameters** + + | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ---------------------------- | - | path | string | Yes| File path of the file system.| - | callback | AsyncCallback<number> | Yes| Callback invoked to return the number of free bytes obtained.| + | path | string | Yes | File path of the file system.| + | callback | AsyncCallback<number> | Yes | Callback invoked to return the number of free bytes obtained.| - Example ```js statfs.getFreeBytes(path, function(err, number){ - // Do something. + //do something }); ``` ## statfs.getTotalBytes -getTotalBytes.(path:string):Promise<number> +getTotalBytes(path: string): Promise<number> Obtains the total number of bytes of the specified file system in asynchronous mode. This method uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.FileManagement.File.FileIO + +- **Parameters** - | Name| Type| Mandatory| Description| + | Name| Type | Mandatory| Description | | ---- | ------ | ---- | ---------------------------- | - | path | string | Yes| File path of the file system.| + | path | string | Yes | File path of the file system.| -- Return values +- Return value - | Type| Description| + | Type | Description | | --------------------- | ------------ | - | Promise<number> | Total number of bytes obtained.| + | Promise<number> | Promise used to return the total number of bytes obtained.| - Example @@ -106,21 +108,23 @@ Obtains the total number of bytes of the specified file system in asynchronous m ## statfs.getTotalBytes -getTotalBytes(path:string, callback:AsyncCallback<number>): void +getTotalBytes(path: string, callback: AsyncCallback<number>): void Obtains the total number of bytes of the specified file system in asynchronous mode. This method uses a callback to return the result. -- Parameters +**System capability**: SystemCapability.FileManagement.File.FileIO + +- **Parameters** - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ---------------------------- | - | path | string | Yes| File path of the file system.| - | callback | AsyncCallback<number> | Yes| Callback invoked to return the total number of bytes obtained.| + | path | string | Yes | File path of the file system.| + | callback | AsyncCallback<number> | Yes | Callback invoked to return the total number of bytes obtained. | - Example ```js statfs.getTotalBytes(path, function(err, number){ - // Do something. + //do something }); ``` diff --git a/en/application-dev/reference/apis/js-apis-storage-statistics.md b/en/application-dev/reference/apis/js-apis-storage-statistics.md index 91690344eefbab65a7023f9cb7b8561a7626d657..cf3f8347a415bde8aa969e6d9585d8d3f69dd643 100644 --- a/en/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/en/application-dev/reference/apis/js-apis-storage-statistics.md @@ -1,34 +1,33 @@ # App Storage Statistics -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> -> The initial APIs of this module are supported since API version 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. ## Modules to Import ```js -import storagestatistics from "@ohos.storagestatistics"; +import storagestatistics from "@ohos.storageStatistics"; ``` -## System Capabilities - -SystemCapability.FileManagement.StorageService.SpatialStatistics - ## storagestatistics.getTotalSizeOfVolume getTotalSizeOfVolume(volumeUuid: string): Promise<number> Asynchronously obtains the total space of the specified volume. This method uses a promise to return the result. +**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics + - Parameters - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description| | ---------- | ------ | ---- | ---- | - | volumeUuid | string | Yes| Universally unique identifier (UUID) of the volume.| + | volumeUuid | string | Yes | UUID of the volume.| - Return value - | Type| Description| + | Type | Description | | --------------------- | ---------------- | | Promise<number> | Promise used to return the total space of the volume.| @@ -49,12 +48,14 @@ getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):v Asynchronously obtains the total space of the specified volume. This method uses a callback to return the result. +**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics + - Parameters - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description | | ---------- | ------------------------------------ | ---- | -------------------------- | - | volumeUuid | string | Yes| UUID of the volume.| - | callback | callback:AsyncCallback<number> | Yes| Callback invoked to return the total space of the volume.| + | volumeUuid | string | Yes | UUID of the volume. | + | callback | callback:AsyncCallback<number> | Yes | Callback invoked to return the total space of the volume.| - Example @@ -62,9 +63,10 @@ Asynchronously obtains the total space of the specified volume. This method uses let uuid = ""; storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){ // Do something + console.info("getTotalSizeOfVolume successfully:"+ number); }); ``` - + ## storagestatistics.getFreeSizeOfVolume @@ -73,15 +75,17 @@ getFreeSizeOfVolume(volumeUuid: string): Promise<number> Asynchronously obtains the available space of the specified volume. This method uses a promise to return the result. +**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics + - Parameters - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description| | ---------- | ------ | ---- | ---- | - | volumeUuid | string | Yes| UUID of the volume.| + | volumeUuid | string | Yes | UUID of the volume.| - Return value - | Type| Description| + | Type | Description | | --------------------- | ------------------ | | Promise<number> | Promise used to return the available space of the volume.| @@ -103,12 +107,14 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):vo Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result. +**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics + - Parameters - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description | | ---------- | ------------------------------------ | ---- | ---------------------------- | - | volumeUuid | string | Yes| UUID of the volume.| - | callback | callback:AsyncCallback<number> | Yes| Callback invoked to return the available space of the volume.| + | volumeUuid | string | Yes | UUID of the volume. | + | callback | callback:AsyncCallback<number> | Yes | Callback invoked to return the available space of the volume.| - Example @@ -116,34 +122,35 @@ Asynchronously obtains the available space of the specified volume. This method let uuid = ""; storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){ // Do something + console.info("getFreeSizeOfVolume successfully:"+ number); }); ``` ## storagestatistics.getBundleStats -getBundleStats(volumeUuid: string, packageName:String, ): Promise<BundleStats> +getBundleStats(packageName: string): Promise<BundleStats> -Asynchronously obtains the bundle status on the specified volume. This method uses a promise to return the result. +Obtains the bundle status. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics - Parameters - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description | | ----------- | ------ | ---- | -------- | - | volumeUuid | string | Yes| UUID of the volume.| - | packageName | string | Yes| Bundle name of the app.| - + | packageName | string | Yes | Bundle name of the app.| + - Return value - | Type| Description| + | Type | Description | | ------------------------------------------ | -------------------------- | | Promise<[Bundlestats](#bundlestats)> | Promise used to return the bundle status on the volume.| - Example ```js - let uuid = ""; let packageName = ""; - storagestatistics.getBundleStats(uuid, packageName).then(function(BundleStats){ + storagestatistics.getBundleStats(packageName).then(function(BundleStats){ console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); }).catch(function(err){ console.info("getBundleStats failed with error:"+ err); @@ -152,33 +159,37 @@ Asynchronously obtains the bundle status on the specified volume. This method us ## storagestatistics.getBundleStats -getBundleStats(volumeUuid: string, callback:AsyncCallback<BundleStats>):void +getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>): void -Asynchronously obtains the bundle status on the specified volume. This method uses a callback to return the result. +Obtains the bundle status. This method uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics - | Name| Type| Mandatory| Description| - | ---------- | --------------------------------------------------------- | ---- | ------------------------------------ | - | volumeUuid | string | Yes| UUID of the volume.| - | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | Yes| Callback invoked to return the bundle status on the volume.| +- Parameters + | Name | Type | Mandatory| Description | + | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | + | packageName | string | Yes | Bundle name of the app.| + | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | Yes | Callback invoked to return the bundle status on the volume.| + - Example ```js - let uuid = ""; let packageName = ""; - storagestatistics.getBundleStats(uuid, packageName, function(error, BundleStats){ + storagestatistics.getBundleStats(packageName, function(error, BundleStats){ // Do something + console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); }); ``` -## BundleStats +## BundleStats9+ + +**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics ### Attributes -| Name| Type| Description| +| Name | Type | Description | | --------- | ------ | -------------- | -| appSize | number | Size of the app.| -| cacheSize | number | Size of the cached data.| -| dataSize | number | Total data size of the app.| +| appSize9+ | number | Size of the app. | +| cacheSize9+ | number | Size of the cached data. | +| dataSize9+ | number | Total data size of the app.| diff --git a/en/application-dev/reference/apis/js-apis-system-parameter.md b/en/application-dev/reference/apis/js-apis-system-parameter.md index e67af5f5bc98eb7582421d2c1ef3d27c635e9fcf..29c1e580b1e2ac03e9c0cb88922d3a640485d8bf 100644 --- a/en/application-dev/reference/apis/js-apis-system-parameter.md +++ b/en/application-dev/reference/apis/js-apis-system-parameter.md @@ -13,7 +13,7 @@ import parameter from '@ohos.systemParameter' ## parameter.getSync -getSync(key: string, def?: string) +getSync(key: string, def?: string): string Obtains the value of the attribute with the specified key. @@ -46,7 +46,7 @@ try { ## parameter.get -get(key: string, callback: AsyncCallback<string>) +get(key: string, callback: AsyncCallback<string>): void Obtains the value of the attribute with the specified key. This API uses an asynchronous callback to return the result. @@ -77,7 +77,7 @@ try { ## parameter.get -get(key: string, def: string, callback: AsyncCallback<string>) +get(key: string, def: string, callback: AsyncCallback<string>): void Obtains the value of the attribute with the specified key. This API uses an asynchronous callback to return the result. @@ -110,7 +110,7 @@ try { ## parameter.get -get(key: string, def?: string) +get(key: string, def?: string): Promise<string> Obtains the value of the attribute with the specified key. This API uses a promise to return the result. @@ -147,7 +147,7 @@ try { ## parameter.setSync -setSync(key: string, value: string) +setSync(key: string, value: string): void Sets a value for the attribute with the specified key. @@ -173,7 +173,7 @@ try { ## parameter.set(key: string, value: string, callback: AsyncCallback<void>) -set(key: string, value: string, callback: AsyncCallback<void>) +set(key: string, value: string, callback: AsyncCallback<void>): void Sets a value for the attribute with the specified key. This API uses an asynchronous callback to return the result. @@ -205,7 +205,7 @@ try { ## parameter.set(key: string, def?: string) -set(key: string, def?: string) +set(key: string, def?: string): Promise<string> Sets a value for the attribute with the specified key. This API uses a promise to return the result. diff --git a/en/application-dev/reference/apis/js-apis-update.md b/en/application-dev/reference/apis/js-apis-update.md index 3dbd1691e8dff68ae28eb0faa725fd5d4e3ec9bd..a9a417c88513e0d39dd5f6fa68892574b7a62d0b 100644 --- a/en/application-dev/reference/apis/js-apis-update.md +++ b/en/application-dev/reference/apis/js-apis-update.md @@ -1,5 +1,8 @@ # Update +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. + The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications. There are two types of updates: SD card update and over the air (OTA) update. @@ -17,15 +20,13 @@ import update from '@ohos.update' None -## Obtaining an Updater Object - -### update.getUpdater +## update.getUpdater getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater Obtains the **Updater** object for local update. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** @@ -34,7 +35,7 @@ Obtains the **Updater** object for local update. | upgradeFile | string | Yes | Update file.| | updateType | [UpdateTypes](#updatetypes) | Yes | Update type.| -**Return value** +**Return Value** | Type | Description | | ------------------- | -------- | @@ -50,13 +51,13 @@ try { } ``` -### update.getUpdaterForOther +## update.getUpdaterForOther getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater Obtains the **Updater** object for the device to be updated. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** @@ -66,7 +67,7 @@ Obtains the **Updater** object for the device to be updated. | device | string | Yes | Device to be updated.| | updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | -**Return value** +**Return Value** | Type | Description | | ------------------- | -------- | @@ -82,13 +83,13 @@ try { } ``` -### update.getUpdaterFromOther +## update.getUpdaterFromOther getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater Obtains the **Updater** object from another device for the device to be updated. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** @@ -98,7 +99,7 @@ Obtains the **Updater** object from another device for the device to be updated. | device | string | Yes | Device to be updated.| | updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | -**Return value** +**Return Value** | Type | Description | | ------------------- | -------- | @@ -120,15 +121,15 @@ try { getNewVersionInfo(callback: AsyncCallback\): void -Obtains the new version information. This function uses an asynchronous callback to return the result. +Obtains the new version information. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | ------------------ | -| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information.| +| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the result.| **Example** @@ -145,15 +146,15 @@ update.getNewVersionInfo(info => { getNewVersionInfo(): Promise\ -Obtains the new version information. This function uses a promise to return the result. +Obtains the new version information. This API uses a promise to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService -**Return value** +**Return Value** | Type | Description | | ------------------------------------------- | ------------------------- | -| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.| +| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.| **Example** @@ -171,15 +172,15 @@ updater.getNewVersionInfo().then(value => { checkNewVersion(callback: AsyncCallback\): void -Checks whether the current version is the latest. This function uses an asynchronous callback to return the result. +Checks whether the current version is the latest. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------ | -| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information.| +| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the result.| **Example** @@ -196,15 +197,15 @@ update.checkNewVersion(info => { checkNewVersion(): Promise\ -Checks whether the current version is the latest. This function uses a promise to return the result. +Checks whether the current version is the latest. This API uses a promise to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService -**Return value** +**Return Value** | Type | Description | | ------------------------------------------- | ------------------------- | -| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.| +| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.| **Example** @@ -224,7 +225,7 @@ verifyUpdatePackage(upgradeFile: string, certsFile: string): void Verifies whether the update package is valid. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** @@ -246,15 +247,15 @@ update.verifyUpdatePackage("XXX", "XXX"); rebootAndCleanUserData(): Promise\ -Reboots the device and clears the user partition data. This function uses a promise to return the result. +Reboots the device and clears the user partition data. This API uses a promise to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService -**Return value** +**Return Value** | Type | Description | | ---------------- | ------------------------------- | -| Promise\ | Promise used to return the execution result.| +| Promise\ | Promise used to return the result.| **Example** @@ -270,15 +271,15 @@ update.rebootAndCleanUserData().then(result => { rebootAndCleanUserData(callback: AsyncCallback\): void -Reboots the device and clears the user partition data. This function uses an asynchronous callback to return the result. +Reboots the device and clears the user partition data. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** | Name | Type | Mandatory| Description | | -------- | -------- | ---- | ---------------------- | -| callback | AsyncCallback\| Yes | Callback used to return the execution result.| +| callback | AsyncCallback\| Yes | Callback used to return the result.| **Example** @@ -292,15 +293,15 @@ update.rebootAndCleanUserData(result => { applyNewVersion(): Promise\ -Installs the update package. This function uses a promise to return the result. +Installs the update package. This API uses a promise to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService -**Return value** +**Return Value** | Type | Description | | ---------------- | ------------------------------- | -| Promise\ | Promise used to return the execution result.| +| Promise\ | Promise used to return the result.| **Example** @@ -316,15 +317,15 @@ update.applyNewVersion().then(result => { applyNewVersion(callback: AsyncCallback\): void -Installs the update package. This function uses an asynchronous callback to return the result. +Installs the update package. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** | Name | Type | Mandatory| Description | | -------- | -------- | ---- | ---------------------- | -| callback| AsyncCallback\| Yes | Callback used to return the execution result.| +| callback | AsyncCallback\| Yes | Callback used to return the result.| **Example** @@ -340,7 +341,7 @@ download(): void Downloads the new version and displays the download process. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Example** @@ -359,7 +360,7 @@ updater.upgrade():void Starts an update. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Example** @@ -376,16 +377,16 @@ updater.upgrade(); setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\): void -Sets the update policy. This function uses an asynchronous callback to return the result. +Sets the update policy. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** | Name | Type | Mandatory| Description | | -------- | ----------------------------- | ---- | ------------ | | policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.| -| callback | AsyncCallback\ | Yes | Callback used to return the execution result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -407,9 +408,9 @@ update.setUpdatePolicy(policy, result => { setUpdatePolicy(policy: UpdatePolicy): Promise\ -Sets the update policy. This function uses a promise to return the result. +Sets the update policy. This API uses a promise to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** @@ -417,11 +418,11 @@ Sets the update policy. This function uses a promise to return the result. | ------ | ----------------------------- | ---- | ------------ | | policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.| -**Return value** +**Return Value** | Type | Description | | ---------------- | ----------------------- | -| Promise\ | Promise used to return the execution result.| +| Promise\ | Promise used to return the result.| **Example** @@ -444,15 +445,15 @@ update.setUpdatePolicy(policy).then(result => getUpdatePolicy(callback: AsyncCallback\): void -Obtains the update policy. This function uses an asynchronous callback to return the result. +Obtains the update policy. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------------------------- | ---- | -------------------- | -| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the update policy.| +| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the result.| **Example** @@ -469,15 +470,15 @@ update.getUpdatePolicy(policy => { getUpdatePolicy(): Promise\ -Obtains the update policy. This function uses a promise to return the result. +Obtains the update policy. This API uses a promise to return the result. -**System capability**: SystemCapability.Updater.update_service +**System capability**: SystemCapability.Update.UpdateService -**Return value** +**Return Value** | Type | Description | | --------------------------------------- | --------------------------- | -| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the update policy.| +| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the result.| **Example** @@ -495,85 +496,101 @@ update.getUpdatePolicy().then(value => { Enumerates update types. +**System capability**: SystemCapability.Update.UpdateService + | Name| Description | | ------ | -------- | -| OTA | OTA update.
**System capability**: SystemCapability.Updater.update_service| -| patch | Patch update.
**System capability**: SystemCapability.Updater.update_service| +| OTA | OTA update. | +| patch | Patch update.| ## PackageTypes Enumerates update package types. +**System capability**: SystemCapability.Update.UpdateService + | Name | Default Value| Description | | -------------------- | ------ | -------------- | -| PACKAGE_TYPE_NORMAL | 1 | Common update package.
**System capability**: SystemCapability.Updater.update_service| -| PACKAGE_TYPE_BASE | 2 | Basic update package.
**System capability**: SystemCapability.Updater.update_service| -| PACKAGE_TYPE_CUST | 3 | Custom update package.
**System capability**: SystemCapability.Updater.update_service| -| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package.
**System capability**: SystemCapability.Updater.update_service| -| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.
**System capability**: SystemCapability.Updater.update_service| -| PACKAGE_TYPE_VERSION | 6 | Version update package.
**System capability**: SystemCapability.Updater.update_service| -| PACKAGE_TYPE_PATCH | 7 | Patch package.
**System capability**: SystemCapability.Updater.update_service| +| PACKAGE_TYPE_NORMAL | 1 | Common update package. | +| PACKAGE_TYPE_BASE | 2 | Basic update package. | +| PACKAGE_TYPE_CUST | 3 | Custom update package. | +| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package. | +| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.| +| PACKAGE_TYPE_VERSION | 6 | Version update package. | +| PACKAGE_TYPE_PATCH | 7 | Patch packages | ## InstallMode Enumerates update modes. +**System capability**: SystemCapability.Update.UpdateService + | Name | Default Value| Description | | ------------------- | ------ | -------- | -| INSTALL_MODE_NORMAL | 0 | Normal update.
**System capability**: SystemCapability.Updater.update_service| -| INSTALL_MODE_NIGHT | 1 | Update at night.
**System capability**: SystemCapability.Updater.update_service| -| INSTALL_MODE_AUTO | 2 | Automatic update.
**System capability**: SystemCapability.Updater.update_service| +| INSTALL_MODE_NORMAL | 0 | Normal update.| +| INSTALL_MODE_NIGHT | 1 | Update at night.| +| INSTALL_MODE_AUTO | 2 | Automatic update.| ## NewVersionStatus Enumerates new version check results. +**System capability**: SystemCapability.Update.UpdateService + | Name | Default Value| Description | | ------------------- | ------ | ---------------- | -| VERSION_STATUS_ERR | -1 | System error while checking for the new version.
**System capability**: SystemCapability.Updater.update_service| -| VERSION_STATUS_NEW | 0 | New version detected.
**System capability**: SystemCapability.Updater.update_service| -| VERSION_STATUS_NONE | 1 | No new version detected.
**System capability**: SystemCapability.Updater.update_service| -| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version.
**System capability**: SystemCapability.Updater.update_service| +| VERSION_STATUS_ERR | -1 | System error while checking for the new version. | +| VERSION_STATUS_NEW | 0 | New version detected. | +| VERSION_STATUS_NONE | 1 | No new version detected.| +| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version. | ## UpdatePolicy Defines the update policy. +**System capability**: SystemCapability.Update.UpdateService + | Name | Type | Mandatory| Description | | ------------------- | --------------------------- | ---- | -------------- | -| autoDownload | bool | Yes | Automatic update switch.
**System capability**: SystemCapability.Updater.update_service| -| installMode | [InstallMode](#installmode) | Yes | Update mode.
**System capability**: SystemCapability.Updater.update_service| -| autoUpgradeInterval | Array\ | Yes | Period of time for automatic update.
**System capability**: SystemCapability.Updater.update_service| +| autoDownload | bool | Yes | Automatic update switch. | +| installMode | [InstallMode](#installmode) | Yes | Installation mode. | +| autoUpgradeInterval | Array\ | Yes | Period of time for automatic update.| ## NewVersionInfo Defines the new version information. +**System capability**: SystemCapability.Update.UpdateService + | Name | Type | Mandatory| Description | | --------------- | ------------------------------------------- | ---- | -------- | -| status | [NewVersionStatus](#newversionstatus) | Yes | Update status.
**System capability**: SystemCapability.Updater.update_service| -| errMsg | string | Yes | Error message.
**System capability**: SystemCapability.Updater.update_service| -| checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result.
**System capability**: SystemCapability.Updater.update_service| -| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes | Version description information.
**System capability**: SystemCapability.Updater.update_service| +| status | [NewVersionStatus](#newversionstatus) | Yes | Update status.| +| errMsg | string | Yes | Error message.| +| checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result.| +| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes | Version description information.| ## CheckResult Defines the version check result. +**System capability**: SystemCapability.Update.UpdateService + | Name | Type | Mandatory| Description | | ------------- | ----------------------------- | ---- | ------------ | -| versionName | string | Yes | Version name.
**System capability**: SystemCapability.Updater.update_service| -| versionCode | number | Yes | Version code.
**System capability**: SystemCapability.Updater.update_service| -| size | number | Yes | Version size.
**System capability**: SystemCapability.Updater.update_service| -| verifyInfo | string | Yes | Version verification information.
**System capability**: SystemCapability.Updater.update_service| -| packageType | [PackageTypes](#packagetypes) | Yes | Version type.
**System capability**: SystemCapability.Updater.update_service| -| descriptionId | string | Yes | Version description information.
**System capability**: SystemCapability.Updater.update_service| +| versionName | string | Yes | Version name. | +| versionCode | number | Yes | Version code. | +| size | number | Yes | Version size. | +| verifyInfo | string | Yes | Version verification information.| +| packageType | [PackageTypes](#packagetypes) | Yes | Version type. | +| descriptionId | string | Yes | Version description information.| ## DescriptionInfo Defines the version description information. +**System capability**: SystemCapability.Update.UpdateService + | Name | Type| Mandatory| Description | | ------------- | -------- | ---- | ----------------- | -| descriptionId | string | Yes | Version ID information.
**System capability**: SystemCapability.Updater.update_service| -| content | string | Yes | Version changelog information.
**System capability**: SystemCapability.Updater.update_service| +| descriptionId | string | Yes | Version ID information.| +| content | string | Yes | Version changelog information.| diff --git a/en/application-dev/reference/apis/js-apis-url.md b/en/application-dev/reference/apis/js-apis-url.md old mode 100644 new mode 100755 index 6ca9f8ae9b4bce6bef3140ad7ed762f43ffffe68..a679841ee2324fe8c4b2b672866b92c4fec0ee3e --- a/en/application-dev/reference/apis/js-apis-url.md +++ b/en/application-dev/reference/apis/js-apis-url.md @@ -113,7 +113,7 @@ console.log(params.getAll('fod')) // Output ["1","3"]. ### entries -entries(): IterableIterator<[string, string]> +entries(): IterableIterator<[string, string]> Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively. @@ -135,7 +135,7 @@ for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pair ### forEach -forEach(callbackfn: (value: string, key: string, searchParams: Object) => void, thisArg?: Object): void +forEach(callbackfn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void Traverses the key-value pairs in the **URLSearchParams** instance by using a callback. diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index f1a9eb0b869a9d95da5dea30f93e64bbaf891a13..8f24f6a17a4f5bbac42b8b6ddbe48711b80af4ab 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -147,7 +147,7 @@ Processes an asynchronous function and returns a promise version. ### constructor -constructor(encoding?: string, options?: { fatal?: boolean;ignoreBOM?: boolean }) +constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean },) A constructor used to create a **TextDecoder** object. @@ -174,7 +174,7 @@ A constructor used to create a **TextDecoder** object. ### decode -decode(input: Unit8Array, options?: {stream?: false}): string +decode(input: Uint8Array, options?: { stream?: false }): string Decodes the input content. @@ -1108,7 +1108,7 @@ class Temperature{ ### constructor8+ -constructor(lowerObj: ScopeType,upperObje: ScopeType) +constructor(lowerObj: ScopeType, upperObj: ScopeType) A constructor used to create a **Scope** object with the specified upper and lower limits. @@ -2321,7 +2321,7 @@ Checks whether the input value is a string object. ### isSymbolObjec8+ -isSymbolObjec(value: Object): boolean +isSymbolObject(value: Object): boolean Checks whether the input value is a symbol object. diff --git a/en/application-dev/reference/apis/js-apis-volumemanager.md b/en/application-dev/reference/apis/js-apis-volumemanager.md index 736d206d573b17b20d1cdd1bb4a1f6f80ee93c6b..0b5491d66aad03a77512c492f96b31f264b05da5 100644 --- a/en/application-dev/reference/apis/js-apis-volumemanager.md +++ b/en/application-dev/reference/apis/js-apis-volumemanager.md @@ -1,28 +1,27 @@ # Volume Management -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> -> The initial APIs of this module are supported since API version 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. ## Modules to Import ```js -import volumemanager from "@ohos.volumemanager"; +import volumemanager from "@ohos.volumeManager"; ``` -## System Capabilities +## volumemanager.getAllVolumes9+ -SystemCapability.FileManagement.StorageService.Volume - -## volumemanager.getAllVolumes - -getAllVolumes(): Promise<Volume[]> +getAllVolumes(): Promise<Array<Volume>> Asynchronously obtains information about all available volumes. This method uses a promise to return the result. +**System capability**: SystemCapability.FileManagement.StorageService.Volume + - Return value - | Type| Description| + | Type | Description | | ---------------------------------- | -------------------------- | | Promise<[Volume](#volume)[]> | Promise used to return the execution result.| @@ -34,17 +33,19 @@ Asynchronously obtains information about all available volumes. This method uses }); ``` -## volumemanager.getAllVolumes +## volumemanager.getAllVolumes9+ -getAllVolumes(callback:AsyncCallback<Volume[]>):void +getAllVolumes(callback: AsyncCallback<Array<Volume>>): void Asynchronously obtains information about all available volumes. This method uses a callback to return the result. +**System capability**: SystemCapability.FileManagement.StorageService.Volume + - Parameters - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------------------------ | - | callback | callback:AsyncCallback<[Volume](#volume)[]> | Yes| Callback invoked to return the volume information obtained.| + | callback | callback:AsyncCallback<[Volume](#volume)[]> | Yes | Callback invoked to return the volume information obtained.| - Example @@ -56,21 +57,23 @@ Asynchronously obtains information about all available volumes. This method uses ``` -## volumemanager.mount +## volumemanager.mount9+ mount(volumeId: string): Promise<boolean> Asynchronously mounts a volume. This method uses a promise to return the result. +**System capability**: SystemCapability.FileManagement.StorageService.Volume + - Parameters - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description| | -------- | ------ | ---- | ---- | - | volumeId | string | Yes| Volume ID.| + | volumeId | string | Yes | Volume ID.| - Return value - | Type| Description| + | Type | Description | | ---------------------- | ---------- | | Promise<boolean> | Promise used to return the execution result.| @@ -83,18 +86,20 @@ Asynchronously mounts a volume. This method uses a promise to return the result. }); ``` -## volumemanager.mount +## volumemanager.mount9+ mount(volumeId: string, callback:AsyncCallback<boolean>):void -Asynchronously mounts a volume. This method uses a callback to return the result. +Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result. + +**System capability**: SystemCapability.FileManagement.StorageService.Volume - Parameters - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description | | -------- | ------------------------------------- | ---- | -------------------- | - | volumeId | string | Yes| Volume ID.| - | callback | callback:AsyncCallback<boolean> | Yes| Callback invoked to return the execution result.| + | volumeId | string | Yes | Volume ID. | + | callback | callback:AsyncCallback<boolean> | Yes | Callback invoked to return the execution result.| - Example @@ -105,21 +110,23 @@ Asynchronously mounts a volume. This method uses a callback to return the result }); ``` -## volumemanager.unmount +## volumemanager.unmount9+ unmount(volumeId: string): Promise<boolean> Asynchronously unmounts a volume. This method uses a promise to return the result. +**System capability**: SystemCapability.FileManagement.StorageService.Volume + - Parameters - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description| | -------- | ------ | ---- | ---- | - | volumeId | string | Yes| Volume ID.| + | volumeId | string | Yes | Volume ID.| - Return value - | Type| Description| + | Type | Description | | ---------------------- | ---------- | | Promise<boolean> | Promise used to return the execution result.| @@ -132,18 +139,20 @@ Asynchronously unmounts a volume. This method uses a promise to return the resul }); ``` -## volumemanager.unmount +## volumemanager.unmount9+ unmount(volumeId: string, callback:AsyncCallback<boolean>):void Asynchronously unmounts a volume. This method uses a callback to return the result. +**System capability**: SystemCapability.FileManagement.StorageService.Volume + - Parameters - | Name| Type| Mandatory| Description| + | Name | Type | Mandatory| Description | | -------- | ------------------------------------- | ---- | -------------------- | - | volumeId | string | Yes| Volume ID.| - | callback | callback:AsyncCallback<boolean> | Yes| Callback invoked to return the execution result.| + | volumeId | string | Yes | Volume ID. | + | callback | callback:AsyncCallback<boolean> | Yes | Callback invoked to return the execution result.| - Example @@ -154,15 +163,17 @@ Asynchronously unmounts a volume. This method uses a callback to return the resu }); ``` -## Volume +## Volume9+ + +**System capability**: SystemCapability.FileManagement.StorageService.Volume ### Attributes -| Name| Type| Description| +| Name | Type | Description | | ----------- | ------- | -------------------- | -| id | number | Volume ID.| -| uuid | string | Universally unique identifier (UUID) of the volume.| -| description | string | Description of the volume.| -| removeAble | boolean | Whether the volume is a removable storage device.| -| state | int | Current volume status.| -| path | string | Mount address of the volume.| +| id9+ | number | Volume ID. | +| uuid9+ | string | Universally unique identifier (UUID) of the volume. | +| description9+ | string | Description of the volume. | +| removable9+ | boolean | Whether the volume is a removable storage device.| +| state9+ | int | Current volume status. | +| path9+ | string | Mount address of the volume. | diff --git a/en/application-dev/reference/apis/js-apis-workScheduler.md b/en/application-dev/reference/apis/js-apis-workScheduler.md index bc4e6f32cd9b9258f6b5ef18f0ae0c91797e6613..770f833363445e40fa738a4347ff68444125b3f6 100644 --- a/en/application-dev/reference/apis/js-apis-workScheduler.md +++ b/en/application-dev/reference/apis/js-apis-workScheduler.md @@ -11,365 +11,330 @@ import workScheduler from '@ohos.workScheduler' ``` ## workScheduler.startWork -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler +startWork(work: WorkInfo): boolean -- **API** -workScheduler.startWork(work: WorkInfo): boolean - -- **Description** Instructs the **WorkSchedulerService** to add the specified task to the execution queue. -- **Parameters** +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | work | WorkInfo | Yes| Task to be added to the execution queue.| +**Parameters** -- **Return value** +| Name | Type | Mandatory | Description | +| ---- | --------------------- | ---- | -------------- | +| work | [WorkInfo](#workinfo) | Yes | Task to be added to the execution queue.| - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the task is added to the execution queue; returns **false** otherwise.| +**Return value** -- **Example** +| Type | Description | +| ------- | -------------------------------- | +| boolean | Returns **true** if the task is added to the execution queue; returns **false** otherwise.| - ``` - let workInfo = { - workId: 1, - batteryLevel:50, - batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, - isRepeat: false, - isPersisted: true, - bundleName: "com.example.myapplication", - abilityName: "MyExtension" - } - var res = workScheduler.startWork(workInfo); - console.info("workschedulerLog res:" + res); - ``` +**Example** -## workScheduler.stopWork -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler +``` + let workInfo = { + workId: 1, + batteryLevel:50, + batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, + isRepeat: false, + isPersisted: true, + bundleName: "com.example.myapplication", + abilityName: "MyExtension" + } + var res = workScheduler.startWork(workInfo); + console.info("workschedulerLog res:" + res); +``` -- **API** +## workScheduler.stopWork stopWork(work: WorkInfo, needCancel?: boolean): boolean -- **Description** Instructs the **WorkSchedulerService** to stop the specified task. -- **Parameters** +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | work | WorkInfo | Yes| Task to stop.| - |needCancel|boolean| Yes| Whether to cancel the task.| +**Parameters** -- **Return value** +| Name | Type | Mandatory | Description | +| ---------- | --------------------- | ---- | ---------- | +| work | [WorkInfo](#workinfo) | Yes | Task to stop. | +| needCancel | boolean | Yes | Whether to cancel the task.| - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +**Return value** -- **Example** +| Type | Description | +| ------- | ----------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| - ``` - let workInfo = { - workId: 1, - batteryLevel:50, - batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, - isRepeat: false, - isPersisted: true, - bundleName: "com.example.myapplication", - abilityName: "MyExtension" - } - var res = workScheduler.stopWork(workInfo, false); - console.info("workschedulerLog res:" + res); - ``` +**Example** -## workScheduler.getWorkStatus -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler +``` + let workInfo = { + workId: 1, + batteryLevel:50, + batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, + isRepeat: false, + isPersisted: true, + bundleName: "com.example.myapplication", + abilityName: "MyExtension" + } + var res = workScheduler.stopWork(workInfo, false); + console.info("workschedulerLog res:" + res); +``` -- **API** -getWorkStatus(workId: number, callback : AsyncCallback): void +## workScheduler.getWorkStatus +getWorkStatus(workId: number, callback : AsyncCallback\): void -- **Description** -Obtains the latest task status. This method uses an asynchronous callback to return the result. +Obtains the latest task status. This API uses an asynchronous callback to return the result. -- **Parameters** +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | workId | number | Yes| Task ID.| - |callback|AsyncCallback| Yes| Callback used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.| +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | ------------------------------------- | ---- | ---------------------------------------- | +| workId | number | Yes | Task ID. | +| callback | AsyncCallback\<[WorkInfo](#workinfo)> | Yes | Callback used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.| -- **Example** +**Example** - ``` - workScheduler.getWorkStatus(50, (err, res) => { - if (err) { - console.info('workschedulerLog getWorkStatus failed, because:' + err.data); - } else { - for (let item in res) { - console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); - } +``` + workScheduler.getWorkStatus(50, (err, res) => { + if (err) { + console.info('workschedulerLog getWorkStatus failed, because:' + err.data); + } else { + for (let item in res) { + console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); } - }); - ``` + } + }); +``` ## workScheduler.getWorkStatus -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler +getWorkStatus(workId: number): Promise\ -- **API** -getWorkStatus(workID: number): Promise +Obtains the latest task status. This API uses a promise to return the result. -- **Description** -Obtains the latest task status. This method uses a promise to return the result. +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler -- **Parameters** +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | workId | number | Yes| Task ID.| +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | -------- | +| workId | number | Yes | Task ID.| -- **Return value** +**Return value** - | Type| Description| - | -------- | -------- | - | Promise | Promise used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.| +| Type | Description | +| ------------------------------- | ---------------------------------------- | +| Promise\<[WorkInfo](#workinfo)> | Promise used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.| -- **Example** +**Example** - ``` - workScheduler.getWorkStatus(50).then((res) => { - for (let item in res) { - console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); - } - }).catch((err) => { - console.info('workschedulerLog getWorkStatus failed, because:' + err.data); - }) - ``` +``` + workScheduler.getWorkStatus(50).then((res) => { + for (let item in res) { + console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); + } + }).catch((err) => { + console.info('workschedulerLog getWorkStatus failed, because:' + err.data); + }) +``` ## workScheduler.obtainAllWorks -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler - -- **API** -obtainAllWorks(callback : AsyncCallback): Array +obtainAllWorks(callback : AsyncCallback\): Array\ -- **Description** -Obtains all tasks associated with this application. This method uses an asynchronous callback to return the result. +Obtains all tasks associated with this application. This API uses an asynchronous callback to return the result. -- **Parameters** +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - |callback|AsyncCallback| Yes| Callback used to return all tasks associated with the current application.| +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return all tasks associated with the current application.| -- **Return value** +**Return value** - | Type| Description| - | -------- | -------- | - | Array | All tasks associated with the current application.| +| Type | Description | +| ----------------------------- | --------------- | +| Array\<[WorkInfo](#workinfo)> | All tasks associated with the current application.| -- **Example** +**Example** - ``` - workScheduler.obtainAllWorks((err, res) =>{ - if (err) { - console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); - } else { - console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); - } - }); - ``` +``` + workScheduler.obtainAllWorks((err, res) =>{ + if (err) { + console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); + } else { + console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); + } + }); +``` ## workScheduler.obtainAllWorks -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler +obtainAllWorks(): Promise> -- **API** -obtainAllWorks(): Promise> +Obtains all tasks associated with this application. This API uses a promise to return the result. -- **Description** -Obtains all tasks associated with this application. This method uses a promise to return the result. +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler -- **Return value** +**Return value** - | Type| Description| - | -------- | -------- | - | Promise> | Promise used to return all tasks associated with the current application.| +| Type | Description | +| -------------------------------------- | ------------------------------ | +| Promise> | Promise used to return all tasks associated with the current application.| -- **Example** +**Example** - ``` - workScheduler.obtainAllWorks().then((res) => { - console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); - }).catch((err) => { - console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); - }) - ``` +``` + workScheduler.obtainAllWorks().then((res) => { + console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); + }).catch((err) => { + console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); + }) +``` ## workScheduler.stopAndClearWorks -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler - -- **API** stopAndClearWorks(): boolean -- **Description** Stops and cancels all tasks associated with the current application. -- **Example** +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler + +**Example** - ``` - let res = workScheduler.stopAndClearWorks(); - console.info("workschedulerLog res:" + res); - ``` +``` + let res = workScheduler.stopAndClearWorks(); + console.info("workschedulerLog res:" + res); +``` ## workScheduler.isLastWorkTimeOut -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler +isLastWorkTimeOut(workId: number, callback : AsyncCallback\): boolean -- **API** -isLastWorkTimeOut(workId: number, callback : AsyncCallback): boolean +Checks whether the last execution of the specified task timed out. This API uses an asynchronous callback to return the result. -- **Description** -Checks whether the last execution of the specified task timed out. This method uses an asynchronous callback to return the result. +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler -- **Parameters** +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | workId | number | Yes| Task ID.| - |callback|AsyncCallback| Yes| Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ---------------------------------------- | +| workId | number | Yes | Task ID. | +| callback | AsyncCallback\ | Yes | Callback used to return the result.| -- **Return value** +**Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.| +| Type | Description | +| ------- | ---------------------------------------- | +| boolean | Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.| -- **Example** +**Example** - ``` - workScheduler.isLastWorkTimeOut(500, (err, res) =>{ - if (err) { - console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); - } else { - console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); - } - }); - ``` +``` + workScheduler.isLastWorkTimeOut(500, (err, res) =>{ + if (err) { + console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); + } else { + console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); + } + }); +``` ## workScheduler.isLastWorkTimeOut -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler +isLastWorkTimeOut(workId: number): Promise\ -- **API** -isLastWorkTimeOut(workId: number): Promise +Checks whether the last execution of the specified task timed out. This API uses a promise to return the result. -- **Description** -Checks whether the last execution of the specified task timed out. This method uses a promise to return the result. +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler -- **Parameters** +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | workId | number | Yes| Task ID.| +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | -------- | +| workId | number | Yes | Task ID.| -- **Return value** +**Return value** - | Type| Description| - | -------- | -------- | - | Promise | Promise used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.| +| Type | Description | +| ----------------- | ---------------------------------------- | +| Promise\ | Promise used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.| -- **Example** +**Example** - ``` - workScheduler.isLastWorkTimeOut(500) - .then(res => { - console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); - }) - .catch(err => { - console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); - }); +``` + workScheduler.isLastWorkTimeOut(500) + .then(res => { + console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); }) - ``` - -## workScheduler.WorkInfo -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler + .catch(err => { + console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); + }); +``` +## WorkInfo Provides detailed information about the task. -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -|workId |number |Yes|Task ID.| -|bundleName |string |Yes| Name of the Work Scheduler task bundle.| -|abilityName | string| Yes| Name of the component to be notified by a Work Scheduler callback.| -|networkType | NetworkType| No| Network type.| -|isCharging | bool| No|Whether the device is charging.| -|chargerType | ChargingType| No|Charging type.| -|batteryLevel | number| No|Battery level.| -|batteryStatus| BatteryStatus| No|Battery status.| -|storageRequest|StorageRequest| No|Storage status.| -|isRepeat|boolean|No|Whether the task is repeated.| -|repeatCycleTime |number|No|Repeat interval.| -|repeatCount |number|No|Number of repeat times.| - -## workScheduler.NetworkType -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler - +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler + +| Name | Type | Mandatory | Description | +| --------------- | --------------------------------- | ---- | ---------------- | +| workId | number | Yes | Task ID. | +| bundleName | string | Yes | Name of the Work Scheduler task bundle. | +| abilityName | string | Yes | Name of the component to be notified by a Work Scheduler callback.| +| networkType | [NetworkType](#networktype) | No | Network type. | +| isCharging | boolean | No | Whether the device is charging. | +| chargerType | [ChargingType](#chargingtype) | No | Charging type. | +| batteryLevel | number | No | Battery level. | +| batteryStatus | [BatteryStatus](#batterystatus) | No | Battery status. | +| storageRequest | [StorageRequest](#storagerequest) | No | Storage status. | +| isRepeat | boolean | No | Whether the task is repeated. | +| repeatCycleTime | number | No | Repeat interval. | +| repeatCount | number | No | Number of repeat times. | + +## NetworkType Enumerates the network types that can trigger the task. -|Name|Default Value|Description| -| -------- | -------- | -------- | -|NETWORK_TYPE_ANY |0 |Any network type.| -|NETWORK_TYPE_MOBILE |1| Mobile network.| -|NETWORK_TYPE_WIFI |2 |Wi-Fi network.| -|NETWORK_TYPE_BLUETOOTH |3 |Bluetooth network.| -|NETWORK_TYPE_WIFI_P2P |4 |Wi-Fi P2P network.| -|NETWORK_TYPE_ETHERNET |5 |Ethernet.| +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler -## workScheduler.ChargingType -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler +| Name | Default Value | Description | +| ---------------------- | ---- | ----------------------- | +| NETWORK_TYPE_ANY | 0 | Any network type. | +| NETWORK_TYPE_MOBILE | 1 | Mobile network. | +| NETWORK_TYPE_WIFI | 2 | Wi-Fi network. | +| NETWORK_TYPE_BLUETOOTH | 3 | Bluetooth network.| +| NETWORK_TYPE_WIFI_P2P | 4 | Wi-Fi P2P network. | +| NETWORK_TYPE_ETHERNET | 5 | Ethernet. | +## ChargingType Enumerates the charging types that can trigger the task. -|Name|Default Value|Description| -| -------- | -------- | -------- | -|CHARGING_PLUGGED_ANY |0| Any charging type.| -|CHARGING_PLUGGED_AC |1 |DC charging.| -|CHARGING_PLUGGED_USB |2 |USB charging.| -|CHARGING_PLUGGED_WIRELESS |3| Wireless charging.| +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler -## workScheduler.BatteryStatus -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler +| Name | Default Value | Description | +| ------------------------- | ---- | -------------------- | +| CHARGING_PLUGGED_ANY | 0 | Any charging type.| +| CHARGING_PLUGGED_AC | 1 | DC charging. | +| CHARGING_PLUGGED_USB | 2 | USB charging. | +| CHARGING_PLUGGED_WIRELESS | 3 | Wireless charging. | +## BatteryStatus Enumerates the battery status that can trigger the task. -|Name|Default Value|Description| -| -------- | -------- | -------- | -|BATTERY_STATUS_LOW |0 |A low battery alert is displayed.| -|BATTERY_STATUS_OKAY |1| The battery level is restored from low to normal.| -|BATTERY_STATUS_LOW_OR_OKAY |2 |The battery level is restored from low to normal, or a low battery alert is displayed.| +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler -## workScheduler.StorageRequest -- **System capability** -SystemCapability.ResourceSchedule.WorkScheduler +| Name | Default Value | Description | +| -------------------------- | ---- | -------------------------- | +| BATTERY_STATUS_LOW | 0 | A low battery alert is displayed. | +| BATTERY_STATUS_OKAY | 1 | The battery level is restored from low to normal. | +| BATTERY_STATUS_LOW_OR_OKAY | 2 | The battery level is restored from low to normal, or a low battery alert is displayed.| +## StorageRequest Enumerates the storage status that can trigger the task. - |Name|Default Value|Description| +**System capability**: SystemCapability.ResourceSchedule.WorkScheduler + + |Name |Default Value |Description| | -------- | -------- | -------- | |STORAGE_LEVEL_LOW |0 |The storage space is insufficient. |STORAGE_LEVEL_OKAY |1 |The storage space is restored from insufficient to normal. - |STORAGE_LEVEL_LOW_OR_OKAY |2 |The storage space is restored from insufficient to normal, or the storage space is insufficient. \ No newline at end of file + |STORAGE_LEVEL_LOW_OR_OKAY |2 |The storage space is restored from insufficient to normal, or the storage space is insufficient. diff --git a/en/application-dev/reference/apis/js-apis-zlib.md b/en/application-dev/reference/apis/js-apis-zlib.md new file mode 100644 index 0000000000000000000000000000000000000000..0a6cd0200e8e87cfcebbf473fb343922314d89de --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-zlib.md @@ -0,0 +1,161 @@ +# Zip Module (JavaScript SDK APIs) + +## Constraints +None +## Modules to Import +import zlib from '@ohos.zlib' +## zlib.zipFile +zipFile(inFile:string, outFile:string, options: Options): Promise; +Zips a file. This API uses a promise to return the result. + +**System capability**: SystemCapability.BundleManager.Zlib + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ----------------------------------- | ---- | ------------------------------------------- | +| inFile | string | Yes | Path of the folder or file to zip. | +| outFile | string | Yes | Path of the zipped file. The file name extension is .zip.| +| options | [Options](#options)| No | Optional parameters for the zip operation. | + +**Return value** + +| Type | Description | +| -------------- | ---------------------------------------------------- | +| Promise\ | Returns **ERROR_CODE_OK** if the operation is successful; returns **ERROR_CODE_ERRNO** otherwise.| + +**Example 1** + +```javascript + +// Zip a file. +import zlib from '@ohos.zlib' +var inFile = "/xxx/filename.xxx"; +var outFile = "/xxx/xxx.zip"; +var options = {}; +options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; +options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; +options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; + +zlib.zipFile(inFile, outFile, options).then((data) => { + if (data == zlib.ErrorCode.ERROR_CODE_OK) { + console.log("zipFile OK"); + } else { + console.log("zipFile NG"); + } +}).catch((err)=>{ + console.log("catch((err)=>" + err); +}); + +``` + +**Example 2** + +``` +// Zip a folder. +import zlib from '@ohos.zlib' +var inFile = "/xxx/xxx"; +var outFile = "/xxx/xxx.zip"; +var options = {}; +options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; +options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; +options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; + +zlib.zipFile(inFile , unzipDir, options).then((data) => { + if (data == zlib.ErrorCode.ERROR_CODE_OK) { + console.log("zipFile OK"); + } else { + console.log("zipFile NG"); + } +}).catch((err)=>{ + console.log("catch((err)=>" + err); +}); +``` + +## zlib.unzipFile + +unzipFile(inFile:string, outFile:string, options: Options): Promise; + +Unzips a file. This API uses a promise to return the result. + +**System capability**: SystemCapability.BundleManager.Zlib + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ----------------------------------- | ---- | ----------------------------------- | +| inFile | string | Yes | Path of the file to unzip. The file name extension is .zip.| +| outFile | string | Yes | Path of the unzipped file. | +| options | [Options](#options)| No | Optional parameters for the unzip operation. | + +**Return value** + +| Type | Description | +| -------------- | ------------------------------------------------------------ | +| Promise\ | Returns **ERROR_CODE_OK** if the operation is successful; returns **ERROR_CODE_ERRNO** otherwise.| + +**Example** + +```javascript +// Unzip a file. +import zlib from '@ohos.zlib' +var inFile = "/xx/xxx.zip"; +var outFile = "/xxx"; + +var options = {}; +options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; +options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; +options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; + +zlib.unzipFile(inFile, outFile, options).then((data) => { + if (data == zlib.ErrorCode.ERROR_CODE_OK) { + console.log("unzipFile OK"); + } else { + console.log("unzipFile NG"); + } +}).catch((err)=>{ + console.log("catch((err)=>" + err); +}) + +``` + +## options + +| Name | | +| --------------------------- | ------------------------------------------------------------ | +| level?: CompressLeve | See [zip.CompressLevel](#zip.CompressLevel).| +| memLevel?: MemLevel | See [zip.MemLevel](#zip.MemLevel) | +| strategy?: CompressStrategy | See [zip.CompressStrategy](#zip.CompressStrategy)| + +## zip.MemLevel + +| MEM_LEVEL_MIN | Minimum memory used by the **zip** API during compression.| +| ----------------- | -------------------------------- | +| MEM_LEVEL_MAX | Maximum memory used by the **zip** API during compression.| +| MEM_LEVEL_DEFAULT | Default memory used by the **zip** API during compression.| + +## Zip.CompressLevel + +| Name | Description | +| --------------------------------------- | ----------------- | +| COMPRESS_LEVEL_NO_COMPRESSION : 0 | Compress level 0 that indicates uncompressed.| +| COMPRESS_LEVEL_BEST_SPEED : 1 | Compression level 1 that gives the best speed. | +| COMPRESS_LEVEL_BEST_COMPRESSION :9 | Compression level 9 that gives the best compression. | +| COMPRESS_LEVEL_DEFAULT_COMPRESSION : -1| Default compression level. | + +## Zip.CompressStrategy + +| Name | Description | +| -------------------------------------- | ------------------------ | +| COMPRESS_STRATEGY_DEFAULT_STRATEGY : 0 | Default compression strategy. | +| COMPRESS_STRATEGY_FILTERED : 1 | Filtered compression strategy.| +| COMPRESS_STRATEGY_HUFFMAN_ONLY : 2 | Huffman coding compression strategy. | +| OMPRESS_STRATEGY_RLE : 3 | RLE compression strategy. | +| COMPRESS_STRATEGY_FIXED : 4 | Fixed compression strategy. | + +## zip.ErrorCode + +| Name | Description | +| -------------------- | ------------ | +| ERROR_CODE_OK: 0 | The API is successfully called.| +| ERROR_CODE_ERRNO:- 1 | Failed to call the API.| diff --git a/en/application-dev/reference/arkui-ts/Readme-EN.md b/en/application-dev/reference/arkui-ts/Readme-EN.md index a2d58f71786278b09b5e9389fcffa367022b0005..92e6008b08061bba04d6a39085e5b21f30f4d0be 100644 --- a/en/application-dev/reference/arkui-ts/Readme-EN.md +++ b/en/application-dev/reference/arkui-ts/Readme-EN.md @@ -1,4 +1,4 @@ -# reference/arkui-ts +# TypeScript-based Declarative Development Paradigm - Components - Universal Components @@ -58,6 +58,7 @@ - [Gauge](ts-basic-components-gauge.md) - [Image](ts-basic-components-image.md) - [ImageAnimator](ts-basic-components-imageanimator.md) + - [LoadingProgress](ts-basic-components-loadingprogress.md) - [Progress](ts-basic-components-progress.md) - [QRCode](ts-basic-components-qrcode.md) - [Radio](ts-basic-components-radio.md) diff --git a/en/application-dev/reference/arkui-ts/figures/sidebarcontainer.png b/en/application-dev/reference/arkui-ts/figures/sidebarcontainer.png new file mode 100644 index 0000000000000000000000000000000000000000..1cbb01859041e2028d76b49db655148cf4eb3062 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/sidebarcontainer.png differ diff --git a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index 3daa690bb4484fe6aab78edb71dfe0f116a12208..d6c76db8635c77b616b0fe09484abe45349d86a6 100644 --- a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -13,9 +13,9 @@ Use **RenderingContext** to draw rectangles, text, images, and other objects on CanvasRenderingContext2D(setting: RenderingContextSetting) - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | setting | [RenderingContextSettings](#renderingcontextsettings) | Yes | - | See RenderingContextSettings. | + | Name | Type | Mandatory | Default Value | Description | + | ------- | ---------------------------------------- | --------- | ------------- | ----------------------------- | + | setting | [RenderingContextSettings](#renderingcontextsettings) | Yes | - | See RenderingContextSettings. | ### RenderingContextSettings @@ -25,33 +25,33 @@ RenderingContextSettings(antialias?: bool) Configures the settings of a **CanvasRenderingContext2D** object, including whether to enable antialiasing. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | antialias | bool | No | false | Whether antialiasing is enabled. | + | Name | Type | Mandatory | Default Value | Description | + | --------- | ---- | --------- | ------------- | -------------------------------- | + | antialias | bool | No | false | Whether antialiasing is enabled. | ## Attributes -| Name | Type | Default Value | Description | -| -------- | -------- | -------- | -------- | -| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Style used to fill an area.
- When the type is **<color>**, this attribute indicates the fill color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | -| [lineWidth](#linewidth) | number | - | Line width. | -| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Stroke style.
- When the type is **<color>**, this attribute indicates the stroke color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | -| [lineCap](#linecap) | string | 'butt' | Style of the line endpoints. The options are as follows:
- **'butt'**: The endpoints of the line are squared off.
- **'round'**: The endpoints of the line are rounded.
- **'square'**: The endpoints of the line are squared off by adding a box with an equal width and half the height of the line's thickness. | -| [lineJoin](#linejoin) | string | 'miter' | Style of the shape used to join line segments. The options are as follows:
- **'round'**: The shape used to join line segments is a rounded corner with the radius equal to the line width.
- **'bevel'**: The shape used to join line segments is a beveled corner. The rectangular corner of each line is independent.
- **'miter'**: The shape used to join line segments is a mitered corner. The corner is formed by extending the outside edges of the lines until they meet. You can adjust the effect of this attribute using **miterLimit**. | -| [miterLimit](#miterlimit) | number | 10 | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet. | -| [font](#font) | string | 'normal normal 14px sans-serif' | Font style.
Syntax: ctx.font='font-size font-family'
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family.
Syntax: ctx.font='font-style font-weight font-size font-family'
- (Optional) **font-style**: font style. Available values are **'normal'** and **'italic'**.
- (Optional) **font-weight**: font weight. Available values are as follows: **'normal'**, **'bold'**, **'bolder'**, **'lighter'**, **100**, **200**, **300**, **400**, **500**, **600**, **700**, **800**, **900**
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family. Available values are **'sans-serif'**, **'serif'**, and **'monospace'**. | -| [textAlign](#textalign) | string | 'left' | Text alignment mode. Available values are as follows:
- **'left'**: The text is left-aligned.
- **'right'**: The text is right-aligned.
- **'center'**: The text is center-aligned.
- **'start'**: The text is aligned with the start bound.
- **'end'**: The text is aligned with the end bound.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> In the **ltr** layout mode, the value **'start'** equals **'left'**. In the **rtl** layout mode, the value **'start'** equals **'right'**. | -| [textBaseline](#textbaseline) | string | 'alphabetic' | Horizontal alignment mode of text. Available values are as follows:
- **'alphabetic'**: The text baseline is the normal alphabetic baseline.
- **'top'**: The text baseline is on the top of the text bounding box.
- **'hanging'**: The text baseline is a hanging baseline over the text.
- **'middle'**: The text baseline is in the middle of the text bounding box.
- **'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.
- **'bottom'**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line. | -| [globalAlpha](#globalalpha) | number | - | Opacity. **0.0**: completely transparent; **1.0**: completely opaque. | -| [lineDashOffset](#linedashoffset) | number | 0.0 | Offset of the dashed line. The precision is float. | -| [globalCompositeOperation](#globalcompositeoperation) | string | 'source-over' | Composition operation type. Available values are as follows: **'source-over'**, **'source-atop'**, **'source-in'**, **'source-out'**, **'destination-over'**, **'destination-atop'**, **'destination-in'**, **'destination-out'**, **'lighter'**, **'copy'**, and **'xor'**. | -| [shadowBlur](#shadowblur) | number | 0.0 | Blur level during shadow drawing. A larger value indicates a more blurred effect. The precision is float. | -| [shadowColor](#shadowcolor) | <color> | - | Shadow color. | -| [shadowOffsetX](#shadowoffsetx) | number | - | X-axis shadow offset relative to the original object. | -| [shadowOffsetY](#shadowoffsety) | number | - | Y-axis shadow offset relative to the original object. | -| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | true | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite. | -| imageSmoothingQuality | string | 'low' | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**. | +| Name | Type | Default Value | Description | +| ---------------------------------------- | ---------------------------------------- | ------------------------------- | ---------------------------------------- | +| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Style used to fill an area.
- When the type is **<color>**, this attribute indicates the fill color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | +| [lineWidth](#linewidth) | number | - | Line width. | +| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Stroke style.
- When the type is **<color>**, this attribute indicates the stroke color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | +| [lineCap](#linecap) | string | 'butt' | Style of the line endpoints. The options are as follows:
- **'butt'**: The endpoints of the line are squared off.
- **'round'**: The endpoints of the line are rounded.
- **'square'**: The endpoints of the line are squared off by adding a box with an equal width and half the height of the line's thickness. | +| [lineJoin](#linejoin) | string | 'miter' | Style of the shape used to join line segments. The options are as follows:
- **'round'**: The shape used to join line segments is a rounded corner with the radius equal to the line width.
- **'bevel'**: The shape used to join line segments is a beveled corner. The rectangular corner of each line is independent.
- **'miter'**: The shape used to join line segments is a mitered corner. The corner is formed by extending the outside edges of the lines until they meet. You can adjust the effect of this attribute using **miterLimit**. | +| [miterLimit](#miterlimit) | number | 10 | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet. | +| [font](#font) | string | 'normal normal 14px sans-serif' | Font style.
Syntax: ctx.font='font-size font-family'
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family.
Syntax: ctx.font='font-style font-weight font-size font-family'
- (Optional) **font-style**: font style. Available values are **'normal'** and **'italic'**.
- (Optional) **font-weight**: font weight. Available values are as follows: **'normal'**, **'bold'**, **'bolder'**, **'lighter'**, **100**, **200**, **300**, **400**, **500**, **600**, **700**, **800**, **900**
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family. Available values are **'sans-serif'**, **'serif'**, and **'monospace'**. | +| [textAlign](#textalign) | string | 'left' | Text alignment mode. Available values are as follows:
- **'left'**: The text is left-aligned.
- **'right'**: The text is right-aligned.
- **'center'**: The text is center-aligned.
- **'start'**: The text is aligned with the start bound.
- **'end'**: The text is aligned with the end bound.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> In the **ltr** layout mode, the value **'start'** equals **'left'**. In the **rtl** layout mode, the value **'start'** equals **'right'**. | +| [textBaseline](#textbaseline) | string | 'alphabetic' | Horizontal alignment mode of text. Available values are as follows:
- **'alphabetic'**: The text baseline is the normal alphabetic baseline.
- **'top'**: The text baseline is on the top of the text bounding box.
- **'hanging'**: The text baseline is a hanging baseline over the text.
- **'middle'**: The text baseline is in the middle of the text bounding box.
- **'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.
- **'bottom'**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line. | +| [globalAlpha](#globalalpha) | number | - | Opacity. **0.0**: completely transparent; **1.0**: completely opaque. | +| [lineDashOffset](#linedashoffset) | number | 0.0 | Offset of the dashed line. The precision is float. | +| [globalCompositeOperation](#globalcompositeoperation) | string | 'source-over' | Composition operation type. Available values are as follows: **'source-over'**, **'source-atop'**, **'source-in'**, **'source-out'**, **'destination-over'**, **'destination-atop'**, **'destination-in'**, **'destination-out'**, **'lighter'**, **'copy'**, and **'xor'**. | +| [shadowBlur](#shadowblur) | number | 0.0 | Blur level during shadow drawing. A larger value indicates a more blurred effect. The precision is float. | +| [shadowColor](#shadowcolor) | <color> | - | Shadow color. | +| [shadowOffsetX](#shadowoffsetx) | number | - | X-axis shadow offset relative to the original object. | +| [shadowOffsetY](#shadowoffsety) | number | - | Y-axis shadow offset relative to the original object. | +| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | true | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite. | +| imageSmoothingQuality | string | 'low' | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**. | > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The value of the **<color>** type can be in 'rgb(255, 255, 255)', 'rgba(255, 255, 255, 1.0)', or '\#FFFFFF' format. @@ -439,19 +439,19 @@ struct LineDashOffset { ### globalCompositeOperation -| Name | Description | -| -------- | -------- | -| source-over | Displays the new drawing above the existing drawing. This attribute is used by default. | -| source-atop | Displays the new drawing on the top of the existing drawing. | -| source-in | Displays the new drawing inside the existing drawing. | -| source-out | Displays the part of the new drawing that is outside of the existing drawing. | +| Name | Description | +| ---------------- | ---------------------------------------- | +| source-over | Displays the new drawing above the existing drawing. This attribute is used by default. | +| source-atop | Displays the new drawing on the top of the existing drawing. | +| source-in | Displays the new drawing inside the existing drawing. | +| source-out | Displays the part of the new drawing that is outside of the existing drawing. | | destination-over | Displays the existing drawing above the new drawing. | | destination-atop | Displays the existing drawing on the top of the new drawing. | -| destination-in | Displays the existing drawing inside the new drawing. | -| destination-out | Displays the part of the existing drawing that is outside of the new drawing. | -| lighter | Displays both the new drawing and the existing drawing. | -| copy | Displays the new drawing and neglects the existing drawing. | -| xor | Combines the new drawing and existing drawing using the XOR operation. | +| destination-in | Displays the existing drawing inside the new drawing. | +| destination-out | Displays the part of the existing drawing that is outside of the new drawing. | +| lighter | Displays both the new drawing and the existing drawing. | +| copy | Displays the new drawing and neglects the existing drawing. | +| xor | Combines the new drawing and existing drawing using the XOR operation. | ``` @@ -659,15 +659,15 @@ fillRect(x: number, y: number, w: number, h: number): void Fills a rectangle on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | - | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | - | width | number | Yes | 0 | Width of the rectangle. | - | height | number | Yes | 0 | Height of the rectangle. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | - Example - + ``` @Entry @Component @@ -701,15 +701,15 @@ strokeRect(x: number, y: number, w: number, h: number): void Draws an outlined rectangle on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | - | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | - | width | number | Yes | 0 | Width of the rectangle. | - | height | number | Yes | 0 | Height of the rectangle. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | - Example - + ``` @Entry @Component @@ -742,15 +742,15 @@ clearRect(x: number, y: number, w: number, h: number): void Clears the content in a rectangle on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | - | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | - | width | number | Yes | 0 | Width of the rectangle. | - | height | number | Yes | 0 | Height of the rectangle. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | - Example - + ``` @Entry @Component @@ -785,14 +785,14 @@ fillText(text: string, x: number, y: number): void Draws filled text on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | text | string | Yes | "" | Text to draw. | - | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | - | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | text | string | Yes | "" | Text to draw. | + | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | + | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | - Example - + ``` @Entry @Component @@ -826,14 +826,14 @@ strokeText(text: string, x: number, y: number): void Draws a text stroke on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | text | string | Yes | "" | Text to draw. | - | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | - | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | text | string | Yes | "" | Text to draw. | + | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | + | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | - Example - + ``` @Entry @Component @@ -867,22 +867,22 @@ measureText(text: string): TextMetrics Returns a **TextMetrics** object used to obtain the width of specified text. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | text | string | Yes | "" | Text to be measured. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | -------------------- | + | text | string | Yes | "" | Text to be measured. | - Return value - | Type | Description | - | -------- | -------- | - | TextMetrics | **TextMetrics** object. | + | Type | Description | + | ----------- | ----------------------- | + | TextMetrics | **TextMetrics** object. | - **TextMetrics** attributes - | Name | Type | Description | - | -------- | -------- | -------- | - | width | number | Width of the text. | + | Name | Type | Description | + | ----- | ------ | ------------------ | + | width | number | Width of the text. | - Example - + ``` @Entry @Component @@ -917,19 +917,19 @@ stroke(path?: Path2D): void Strokes a path. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | path | [Path2D](ts-components-canvas-path2d.md) | No | null | A **Path2D** path to draw. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ---------------------------------------- | --------- | ------------- | -------------------------- | + | path | [Path2D](ts-components-canvas-path2d.md) | No | null | A **Path2D** path to draw. | - Example - + ``` @Entry @Component struct Stroke { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -959,14 +959,14 @@ beginPath(): void Creates a drawing path. - Example - + ``` @Entry @Component struct BeginPath { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -998,20 +998,20 @@ moveTo(x: number, y: number): void Moves a drawing path to a target position on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the target position. | - | y | number | Yes | 0 | Y-coordinate of the target position. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ------------------------------------ | + | x | number | Yes | 0 | X-coordinate of the target position. | + | y | number | Yes | 0 | Y-coordinate of the target position. | - Example - + ``` @Entry @Component struct MoveTo { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1041,20 +1041,20 @@ lineTo(x: number, y: number): void Connects the current point to a target position using a straight line. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the target position. | - | y | number | Yes | 0 | Y-coordinate of the target position. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ------------------------------------ | + | x | number | Yes | 0 | X-coordinate of the target position. | + | y | number | Yes | 0 | Y-coordinate of the target position. | - Example - + ``` @Entry @Component struct LineTo { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1084,14 +1084,14 @@ closePath(): void Draws a closed path. - Example - + ``` @Entry @Component struct ClosePath { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1123,13 +1123,13 @@ createPattern(image: ImageBitmap, repetition: string): void Creates a pattern for image filling based on a specified source image and repetition mode. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Source image. For details, see ImageBitmap. | - | repetition | string | Yes | "" | Repetition mode. The value can be **'repeat'**, **'repeat-x'**, **'repeat-y'**, or **'no-repeat'**. | + | Name | Type | Mandatory | Default Value | Description | + | ---------- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- | + | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Source image. For details, see ImageBitmap. | + | repetition | string | Yes | "" | Repetition mode. The value can be **'repeat'**, **'repeat-x'**, **'repeat-y'**, or **'no-repeat'**. | - Example - + ``` @Entry @Component @@ -1137,7 +1137,7 @@ Creates a pattern for image filling based on a specified source image and repeti private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1166,24 +1166,24 @@ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, Draws a cubic bezier curve on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | cp1x | number | Yes | 0 | X-coordinate of the first parameter of the bezier curve. | - | cp1y | number | Yes | 0 | Y-coordinate of the first parameter of the bezier curve. | - | cp2x | number | Yes | 0 | X-coordinate of the second parameter of the bezier curve. | - | cp2y | number | Yes | 0 | Y-coordinate of the second parameter of the bezier curve. | - | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | - | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | cp1x | number | Yes | 0 | X-coordinate of the first parameter of the bezier curve. | + | cp1y | number | Yes | 0 | Y-coordinate of the first parameter of the bezier curve. | + | cp2x | number | Yes | 0 | X-coordinate of the second parameter of the bezier curve. | + | cp2y | number | Yes | 0 | Y-coordinate of the second parameter of the bezier curve. | + | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | + | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | - Example - + ``` @Entry @Component struct BezierCurveTo { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1213,15 +1213,15 @@ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void Draws a quadratic curve on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | cpx | number | Yes | 0 | X-coordinate of the bezier curve parameter. | - | cpy | number | Yes | 0 | Y-coordinate of the bezier curve parameter. | - | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | - | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | cpx | number | Yes | 0 | X-coordinate of the bezier curve parameter. | + | cpy | number | Yes | 0 | Y-coordinate of the bezier curve parameter. | + | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | + | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | - Example - + ``` @Entry @Component @@ -1257,24 +1257,24 @@ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, Draws an arc on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the center point of the arc. | - | y | number | Yes | 0 | Y-coordinate of the center point of the arc. | - | radius | number | Yes | 0 | Radius of the arc. | - | startAngle | number | Yes | 0 | Start radian of the arc. | - | endAngle | number | Yes | 0 | End radian of the arc. | - | anticlockwise | boolean | No | false | Whether to draw the arc counterclockwise. | + | Name | Type | Mandatory | Default Value | Description | + | ------------- | ------- | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the center point of the arc. | + | y | number | Yes | 0 | Y-coordinate of the center point of the arc. | + | radius | number | Yes | 0 | Radius of the arc. | + | startAngle | number | Yes | 0 | Start radian of the arc. | + | endAngle | number | Yes | 0 | End radian of the arc. | + | anticlockwise | boolean | No | false | Whether to draw the arc counterclockwise. | - Example - + ``` @Entry @Component struct Arc { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1303,23 +1303,23 @@ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void Draws an arc based on the radius and points on the arc. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x1 | number | Yes | 0 | X-coordinate of the first point on the arc. | - | y1 | number | Yes | 0 | Y-coordinate of the first point on the arc. | - | x2 | number | Yes | 0 | X-coordinate of the second point on the arc. | - | y2 | number | Yes | 0 | Y-coordinate of the second point on the arc. | - | radius | number | Yes | 0 | Radius of the arc. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | x1 | number | Yes | 0 | X-coordinate of the first point on the arc. | + | y1 | number | Yes | 0 | Y-coordinate of the first point on the arc. | + | x2 | number | Yes | 0 | X-coordinate of the second point on the arc. | + | y2 | number | Yes | 0 | Y-coordinate of the second point on the arc. | + | radius | number | Yes | 0 | Radius of the arc. | - Example - + ``` @Entry @Component struct ArcTo { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1348,27 +1348,27 @@ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number Draws an ellipse in the specified rectangular region. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the ellipse center. | - | y | number | Yes | 0 | Y-coordinate of the ellipse center. | - | radiusX | number | Yes | 0 | Ellipse radius on the x-axis. | - | radiusY | number | Yes | 0 | Ellipse radius on the y-axis. | - | rotation | number | Yes | 0 | Rotation angle of the ellipse, in radians. | - | startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse, in radians. | - | endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse, in radians. | - | anticlockwise | boolean | No | false | Whether to draw the ellipse in the counterclockwise direction. | + | Name | Type | Mandatory | Default Value | Description | + | ------------- | ------- | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the ellipse center. | + | y | number | Yes | 0 | Y-coordinate of the ellipse center. | + | radiusX | number | Yes | 0 | Ellipse radius on the x-axis. | + | radiusY | number | Yes | 0 | Ellipse radius on the y-axis. | + | rotation | number | Yes | 0 | Rotation angle of the ellipse, in radians. | + | startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse, in radians. | + | endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse, in radians. | + | anticlockwise | boolean | No | false | Whether to draw the ellipse in the counterclockwise direction. | - Example - + ``` @Entry @Component struct CanvasExample { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1397,22 +1397,22 @@ rect(x: number, y: number, width: number, height: number): void Creates a rectangle. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | - | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | - | width | number | Yes | 0 | Width of the rectangle. | - | height | number | Yes | 0 | Height of the rectangle. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | - Example - + ``` @Entry @Component struct CanvasExample { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1440,14 +1440,14 @@ fill(): void Fills the area inside a closed path. - Example - + ``` @Entry @Component struct Fill { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1475,14 +1475,14 @@ clip(): void Sets the current path to a clipping path. - Example - + ``` @Entry @Component struct Clip { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1513,19 +1513,19 @@ rotate(rotate: number): void Rotates a canvas clockwise around its coordinate axes. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | rotate | number | Yes | 0 | Clockwise rotation angle. You can use **Math.PI / 180** to convert the angle to a radian. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | rotate | number | Yes | 0 | Clockwise rotation angle. You can use **Math.PI / 180** to convert the angle to a radian. | - Example - + ``` @Entry @Component struct Rotate { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1553,20 +1553,20 @@ scale(x: number, y: number): void Scales a canvas based on scale factors. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | Horizontal scale factor. | - | y | number | Yes | 0 | Vertical scale factor. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ------------------------ | + | x | number | Yes | 0 | Horizontal scale factor. | + | y | number | Yes | 0 | Vertical scale factor. | - Example - + ``` @Entry @Component struct Scale { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1596,30 +1596,30 @@ Defines a transformation matrix. To transform a graph, you only need to set para > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The following formulas calculate coordinates of the transformed graph. **x** and **y** represent coordinates before transformation, and **x'** and **y'** represent coordinates after transformation. -> +> > - x' = scaleX \* x + skewY \* y + translateX -> +> > - y' = skewX \* x + scaleY \* y + translateY - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | scaleX | number | Yes | 0 | X-axis scale. | - | skewX | number | Yes | 0 | X-axis skew. | - | skewY | number | Yes | 0 | Y-axis skew. | - | scaleY | number | Yes | 0 | Y-axis scale. | - | translateX | number | Yes | 0 | X-axis translation. | - | translateY | number | Yes | 0 | Y-axis translation. | + | Name | Type | Mandatory | Default Value | Description | + | ---------- | ------ | --------- | ------------- | ------------------- | + | scaleX | number | Yes | 0 | X-axis scale. | + | skewX | number | Yes | 0 | X-axis skew. | + | skewY | number | Yes | 0 | Y-axis skew. | + | scaleY | number | Yes | 0 | Y-axis scale. | + | translateX | number | Yes | 0 | X-axis translation. | + | translateY | number | Yes | 0 | Y-axis translation. | - Example - + ``` @Entry @Component struct Transform { private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: RenderingContext = new RenderingContext(this.settings) - + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1653,24 +1653,24 @@ setTransform(scaleX: number, skewX: number, skewY: number, scale: number, transl Resets the existing transformation matrix and creates a new transformation matrix by using the same parameters as the **transform()** function. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | scaleX | number | Yes | 0 | X-axis scale. | - | skewX | number | Yes | 0 | X-axis skew. | - | skewY | number | Yes | 0 | Y-axis skew. | - | scaleY | number | Yes | 0 | Y-axis scale. | - | translateX | number | Yes | 0 | X-axis translation. | - | translateY | number | Yes | 0 | Y-axis translation. | + | Name | Type | Mandatory | Default Value | Description | + | ---------- | ------ | --------- | ------------- | ------------------- | + | scaleX | number | Yes | 0 | X-axis scale. | + | skewX | number | Yes | 0 | X-axis skew. | + | skewY | number | Yes | 0 | Y-axis skew. | + | scaleY | number | Yes | 0 | Y-axis scale. | + | translateX | number | Yes | 0 | X-axis translation. | + | translateY | number | Yes | 0 | Y-axis translation. | - Example - + ``` @Entry @Component struct SetTransform { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1701,20 +1701,20 @@ translate(x: number, y: number): void Moves the origin of the coordinate system. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-axis translation. | - | y | number | Yes | 0 | Y-axis translation. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ------------------- | + | x | number | Yes | 0 | X-axis translation. | + | y | number | Yes | 0 | Y-axis translation. | - Example - + ``` @Entry @Component struct Translate { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1747,21 +1747,21 @@ drawImage(image: ImageBitmap, sx: number, sy: number, sWidth: number, sHeight: n Draws an image. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Image resource. For details, see ImageBitmap | - | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | - | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | - | sWidth | number | No | 0 | Target width to crop the source image. | - | sHeight | number | No | 0 | Target height to crop the source image. | - | dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. | - | dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas. | - | dWidth | number | No | 0 | Width of the drawing area. | - | dHeight | number | No | 0 | Height of the drawing area. | + | Name | Type | Mandatory | Default Value | Description | + | ------- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- | + | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Image resource. For details, see ImageBitmap | + | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | + | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | + | sWidth | number | No | 0 | Target width to crop the source image. | + | sHeight | number | No | 0 | Target height to crop the source image. | + | dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. | + | dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas. | + | dWidth | number | No | 0 | Width of the drawing area. | + | dHeight | number | No | 0 | Height of the drawing area. | - Example - + ``` @Entry @Component @@ -1795,10 +1795,10 @@ createImageData(width: number, height: number): Object Creates an **ImageData** object. For details, see [ImageData](ts-components-canvas-imagebitmap.md). - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | width | number | Yes | 0 | Width of the **ImageData** object. | - | height | number | Yes | 0 | Height of the **ImageData** object. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ----------------------------------- | + | width | number | Yes | 0 | Width of the **ImageData** object. | + | height | number | Yes | 0 | Height of the **ImageData** object. | ### createImageData @@ -1808,9 +1808,9 @@ createImageData(imageData: Object): Object Creates an **ImageData** object. For details, see [ImageData](ts-components-canvas-imagebitmap.md). - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | imagedata | Object | Yes | null | **ImageData** object with the same width and height copied from the original **ImageData** object. | + | Name | Type | Mandatory | Default Value | Description | + | --------- | ------ | --------- | ------------- | ---------------------------------------- | + | imagedata | Object | Yes | null | **ImageData** object with the same width and height copied from the original **ImageData** object. | ### getImageData @@ -1819,12 +1819,12 @@ getImageData(sx: number, sy: number, sw: number, sh: number): Object Creates an [ImageData](ts-components-canvas-imagebitmap.md) object with pixels in the specified area on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area. | - | sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area. | - | sw | number | Yes | 0 | Width of the output area. | - | sh | number | Yes | 0 | Height of the output area. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area. | + | sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area. | + | sw | number | Yes | 0 | Width of the output area. | + | sh | number | Yes | 0 | Height of the output area. | ### putImageData @@ -1834,25 +1834,25 @@ putImageData(imageData: Object, dx: number, dy: number, dirtyX?: number, dirtyY? Puts the [ImageData](ts-components-canvas-imagebitmap.md) onto a rectangular area on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | imagedata | Object | Yes | null | **ImageData** object with pixels to put onto the canvas. | - | dx | number | Yes | 0 | X-axis offset of the rectangular area on the canvas. | - | dy | number | Yes | 0 | Y-axis offset of the rectangular area on the canvas. | - | dirtyX | number | No | 0 | X-axis offset of the upper left corner of the rectangular area relative to that of the source image. | - | dirtyY | number | No | 0 | Y-axis offset of the upper left corner of the rectangular area relative to that of the source image. | - | dirtyWidth | number | No | Width of the **ImageData** object | Width of the rectangular area to crop the source image. | - | dirtyHeight | number | No | Height of the **ImageData** object | Height of the rectangular area to crop the source image. | + | Name | Type | Mandatory | Default Value | Description | + | ----------- | ------ | --------- | ---------------------------------- | ---------------------------------------- | + | imagedata | Object | Yes | null | **ImageData** object with pixels to put onto the canvas. | + | dx | number | Yes | 0 | X-axis offset of the rectangular area on the canvas. | + | dy | number | Yes | 0 | Y-axis offset of the rectangular area on the canvas. | + | dirtyX | number | No | 0 | X-axis offset of the upper left corner of the rectangular area relative to that of the source image. | + | dirtyY | number | No | 0 | Y-axis offset of the upper left corner of the rectangular area relative to that of the source image. | + | dirtyWidth | number | No | Width of the **ImageData** object | Width of the rectangular area to crop the source image. | + | dirtyHeight | number | No | Height of the **ImageData** object | Height of the rectangular area to crop the source image. | - Example - + ``` @Entry @Component struct PutImageData { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1886,14 +1886,14 @@ restore(): void Restores the saved drawing context. - Example - + ``` @Entry @Component struct CanvasExample { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1918,14 +1918,14 @@ save(): void Saves the current drawing context. - Example - + ``` @Entry @Component struct CanvasExample { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Canvas(this.context) @@ -1950,15 +1950,15 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void Creates a linear gradient. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x0 | number | Yes | 0 | X-coordinate of the start point. | - | y0 | number | Yes | 0 | Y-coordinate of the start point. | - | x1 | number | Yes | 0 | X-coordinate of the end point. | - | y1 | number | Yes | 0 | Y-coordinate of the end point. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | -------------------------------- | + | x0 | number | Yes | 0 | X-coordinate of the start point. | + | y0 | number | Yes | 0 | Y-coordinate of the start point. | + | x1 | number | Yes | 0 | X-coordinate of the end point. | + | y1 | number | Yes | 0 | Y-coordinate of the end point. | - Example - + ``` @Entry @Component @@ -1974,9 +1974,9 @@ Creates a linear gradient. .backgroundColor('#ffff00') .onReady(() =>{ var grad = this.context.createLinearGradient(50,0, 300,100) - this.grad.addColorStop(0.0, 'red') - this.grad.addColorStop(0.5, 'white') - this.grad.addColorStop(1.0, 'green') + grad.addColorStop(0.0, 'red') + grad.addColorStop(0.5, 'white') + grad.addColorStop(1.0, 'green') this.context.fillStyle = grad this.context.fillRect(0, 0, 500, 500) }) @@ -1997,17 +1997,17 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, Creates a linear gradient. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x0 | number | Yes | 0 | X-coordinate of the center of the start circle. | - | y0 | number | Yes | 0 | Y-coordinate of the center of the start circle. | - | r0 | number | Yes | 0 | Radius of the start circle, which must be a non-negative finite number. | - | x1 | number | Yes | 0 | X-coordinate of the center of the end circle. | - | y1 | number | Yes | 0 | Y-coordinate of the center of the end circle. | - | r1 | number | Yes | 0 | Radius of the end circle, which must be a non-negative finite number. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | x0 | number | Yes | 0 | X-coordinate of the center of the start circle. | + | y0 | number | Yes | 0 | Y-coordinate of the center of the start circle. | + | r0 | number | Yes | 0 | Radius of the start circle, which must be a non-negative finite number. | + | x1 | number | Yes | 0 | X-coordinate of the center of the end circle. | + | y1 | number | Yes | 0 | Y-coordinate of the center of the end circle. | + | r1 | number | Yes | 0 | Radius of the end circle, which must be a non-negative finite number. | - Example - + ``` @Entry @Component @@ -2023,9 +2023,9 @@ Creates a linear gradient. .backgroundColor('#ffff00') .onReady(() =>{ var grad = this.context.createRadialGradient(200,200,50, 200,200,200) - this.grad.addColorStop(0.0, 'red') - this.grad.addColorStop(0.5, 'white') - this.grad.addColorStop(1.0, 'green') + grad.addColorStop(0.0, 'red') + grad.addColorStop(0.5, 'white') + grad.addColorStop(1.0, 'green') this.context.fillStyle = grad this.context.fillRect(0, 0, 500, 500) }) diff --git a/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md new file mode 100644 index 0000000000000000000000000000000000000000..6dc717fffb5d69c1174cca33b0cc2a9433438f37 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -0,0 +1,114 @@ +# SideBarContainer + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +The **\** component contains a sidebar and content area as its child components. The sidebar is the first child component and can be shown or hidden as needed. The content area is the second child component. + + +## Required Permissions + +None + + +## Child Components + +Supported + + +## APIs + +SideBarContainer( type?: SideBarContainerType ) + +- Parameters + | Name| Type| Mandatory| Default Value| Description| + | -------- | -------- | -------- | -------- | -------- | + | type | SideBarContainerType | No| SideBarContainerType.Embed | Display type of the sidebar.| + +- SideBarContainerType enums + | Name| Description| + | -------- | -------- | + | Embed | The sidebar is embedded in the component and displayed side by side with the content area.| + | Overlay | The sidebar is displayed overlaid on the content area.| + +## Attributes + +| Name| Type| Default Value| Description| +| -------- | -------- | -------- | -------- | +| showSideBar | boolean | true | Whether to display the sidebar.| +| controlButton | ButtonStyle | - | Attributes of the sidebar control button.| +| showControlButton | boolean | true | Whether to display the sidebar control button.| +| sideBarWidth | number | 200 | Width of the sidebar.| +| minSideBarWidth | number | 200 | Minimum width of the sidebar.| +| maxSideBarWidth | number | 280 | Maximum width of the sidebar.| + +- ButtonStyle + | Name| Type| Mandatory| Default Value| Description| + | -------- | -------- | -------- | -------- | -------- | + | left | number | No| 16 | Spacing between the sidebar control button and the left of the container.| + | top | number | No| 48 | Spacing between the sidebar control button and the top of the container.| + | width | number | No| 32 | Width of the sidebar control button.| + | height | number | No| 32 | Height of the sidebar control button.| + | icons | {
shown: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,
hidden: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,
switching?: string \| PixelMap \| [Resource](../../ui/ts-types.md)
} | No| - | Icons of the sidebar control button.

- **shown**: icon of the control button when the sidebar is shown.
- **hidden**: icon of the control button when the sidebar is hidden.
- **switching**: icon of the control button when the sidebar is switching between the shown and hidden states.| + + + + +## Events + +| Name| Description| +| -------- | -------- | +| onChange(callback: (value: boolen) => void) | Triggered when the status of the sidebar switches between shown and hidden.

The value **true** means that the sidebar is shown, and **false** means that the sidebar is hidden.| + + +## Example + +``` +@Entry +@Component +struct SideBarContainerExample { + normalIcon : Resource = $r("app.media.user") + selectedIcon: Resource = $r("app.media.userFull") + @State arr: number[] = [1, 2, 3] + @State current: number = 1 + + build() { + SideBarContainer(SideBarContainerType.Embed) + { + Column() { + ForEach(this.arr, (item, index) => { + Column({ space: 5 }) { + Image(this.current === item ? this.selectedIcon : this.normalIcon).width(64).height(64) + Text("Index0" + item) + .fontSize(25) + .fontColor(this.current === item ? '#0A59F7' : '#999') + .fontFamily('source-sans-pro,cursive,sans-serif') + } + .onClick(() => { + this.current = item + }) + }, item => item) + }.width('100%') + .justifyContent(FlexAlign.SpaceEvenly) + .backgroundColor('#19000000') + RowSplit() { + Column(){ + Text('Split page one').fontSize(30) + }.justifyContent(FlexAlign.Center) + Column(){ + Text('Split page two').fontSize(30) + }.justifyContent(FlexAlign.Center) + }.width('100%') + } + .sideBarWidth(240) + .minSideBarWidth(210) + .maxSideBarWidth(260) + .onChange((value: boolean) => { + console.info('status:' + value) + }) + } +} +``` + +![](figures/sidebarcontainer.png) diff --git a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index 0792160d1a9da08ea1fb4190a5d83df3e02069d8..d0002ed9e23d81e0318212e3485a64d78f5c6cae 100644 --- a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -13,35 +13,35 @@ Use **OffscreenCanvasRenderingContext2D** to draw rectangles, images, and text o OffscreenCanvasRenderingContext2D(width: number, height: number, setting: RenderingContextSettings) - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | width | number | Yes | - | Width of the offscreen canvas. | - | height | number | Yes | - | Height of the offscreen canvas. | - | setting | [RenderingContextSettings](ts-canvasrenderingcontext2d.md#renderingcontextsettings) | Yes | - | See RenderingContextSettings. | + | Name | Type | Mandatory | Default Value | Description | + | ------- | ---------------------------------------- | --------- | ------------- | ------------------------------- | + | width | number | Yes | - | Width of the offscreen canvas. | + | height | number | Yes | - | Height of the offscreen canvas. | + | setting | [RenderingContextSettings](ts-canvasrenderingcontext2d.md#renderingcontextsettings) | Yes | - | See RenderingContextSettings. | ## Attributes -| Name | Type | Default Value | Description | -| -------- | -------- | -------- | -------- | -| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Style used to fill an area.
- When the type is **<color>**, this attribute indicates the fill color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | -| [lineWidth](#linewidth) | number | - | Line width. | -| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Stroke style.
- When the type is **<color>**, this attribute indicates the stroke color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | -| [lineCap](#linecap) | string | 'butt' | Style of the line endpoints. The options are as follows:
- **'butt'**: The endpoints of the line are squared off.
- **'round'**: The endpoints of the line are rounded.
- **'square'**: The endpoints of the line are squared off by adding a box with an equal width and half the height of the line's thickness. | -| [lineJoin](#linejoin) | string | 'miter' | Style of the shape used to join line segments. The options are as follows:
- **'round'**: The shape used to join line segments is a rounded corner with the radius equal to the line width.
- **'bevel'**: The shape used to join line segments is a beveled corner. The rectangular corner of each line is independent.
- **'miter'**: The shape used to join line segments is a mitered corner. The corner is formed by extending the outside edges of the lines until they meet. You can adjust the effect of this attribute using **miterLimit**. | -| [miterLimit](#miterlimit) | number | 10 | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet. | -| [font](#font) | string | 'normal normal 14px sans-serif' | Font style.
Syntax: ctx.font='font-size font-family'
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family.
Syntax: ctx.font='font-style font-weight font-size font-family'
- (Optional) **font-style**: specifies the font style. Available values are **'normal'** and **'italic'**.
- (Optional) **font-weight**: font weight. Available values are as follows: **'normal'**, **'bold'**, **'bolder'**, **'lighter'**, **100**, **200**, **300**, **400**, **500**, **600**, **700**, **800**, **900**
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family. Available values are **'sans-serif'**, **'serif'**, and **'monospace'**. | -| [textAlign](#textalign) | string | 'left' | Text alignment mode. Available values are as follows:
- **'left'**: The text is left-aligned.
- **'right'**: The text is right-aligned.
- **'center'**: The text is center-aligned.
- **'start'**: The text is aligned with the start bound.
- **'end'**: The text is aligned with the end bound.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> In the **ltr** layout mode, the value **start** equals **left**. In the **rtl** layout mode, the value **start** equals **right**. | -| [textBaseline](#textbaseline) | string | 'alphabetic' | Horizontal alignment mode of text. Available values are as follows:
- **'alphabetic'**: The text baseline is the normal alphabetic baseline.
- **'top'**: The text baseline is on the top of the text bounding box.
- **'hanging'**: The text baseline is a hanging baseline over the text.
- **'middle'**: The text baseline is in the middle of the text bounding box.
- **'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.
- **'bottom'**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line. | -| [globalAlpha](#globalalpha) | number | - | Opacity. **0.0**: completely transparent; **1.0**: completely opaque. | -| [lineDashOffset](#linedashoffset) | number | 0.0 | Offset of the dashed line. The precision is float. | -| [globalCompositeOperation](#globalcompositeoperation) | string | 'source-over' | Composition operation type. Available values are as follows: **'source-over'**, **'source-atop'**, **'source-in'**, **'source-out'**, **'destination-over'**, **'destination-atop'**, **'destination-in'**, **'destination-out'**, **'lighter'**, **'copy'**, and **'xor'**. | -| [shadowBlur](#shadowblur) | number | 0.0 | Blur level during shadow drawing. A larger value indicates a more blurred effect. The precision is float. | -| [shadowColor](#shadowcolor) | <color> | - | Shadow color. | -| [shadowOffsetX](#shadowoffsetx) | number | - | X-axis shadow offset relative to the original object. | -| [shadowOffsetY](#shadowoffsety) | number | - | Y-axis shadow offset relative to the original object. | -| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | true | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite. | -| imageSmoothingQuality | string | 'low' | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**. | +| Name | Type | Default Value | Description | +| ---------------------------------------- | ---------------------------------------- | ------------------------------- | ---------------------------------------- | +| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Style used to fill an area.
- When the type is **<color>**, this attribute indicates the fill color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | +| [lineWidth](#linewidth) | number | - | Line width. | +| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Stroke style.
- When the type is **<color>**, this attribute indicates the stroke color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | +| [lineCap](#linecap) | string | 'butt' | Style of the line endpoints. The options are as follows:
- **'butt'**: The endpoints of the line are squared off.
- **'round'**: The endpoints of the line are rounded.
- **'square'**: The endpoints of the line are squared off by adding a box with an equal width and half the height of the line's thickness. | +| [lineJoin](#linejoin) | string | 'miter' | Style of the shape used to join line segments. The options are as follows:
- **'round'**: The shape used to join line segments is a rounded corner with the radius equal to the line width.
- **'bevel'**: The shape used to join line segments is a beveled corner. The rectangular corner of each line is independent.
- **'miter'**: The shape used to join line segments is a mitered corner. The corner is formed by extending the outside edges of the lines until they meet. You can adjust the effect of this attribute using **miterLimit**. | +| [miterLimit](#miterlimit) | number | 10 | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet. | +| [font](#font) | string | 'normal normal 14px sans-serif' | Font style.
Syntax: ctx.font='font-size font-family'
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family.
Syntax: ctx.font='font-style font-weight font-size font-family'
- (Optional) **font-style**: specifies the font style. Available values are **'normal'** and **'italic'**.
- (Optional) **font-weight**: font weight. Available values are as follows: **'normal'**, **'bold'**, **'bolder'**, **'lighter'**, **100**, **200**, **300**, **400**, **500**, **600**, **700**, **800**, **900**
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family. Available values are **'sans-serif'**, **'serif'**, and **'monospace'**. | +| [textAlign](#textalign) | string | 'left' | Text alignment mode. Available values are as follows:
- **'left'**: The text is left-aligned.
- **'right'**: The text is right-aligned.
- **'center'**: The text is center-aligned.
- **'start'**: The text is aligned with the start bound.
- **'end'**: The text is aligned with the end bound.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> In the **ltr** layout mode, the value **start** equals **left**. In the **rtl** layout mode, the value **start** equals **right**. | +| [textBaseline](#textbaseline) | string | 'alphabetic' | Horizontal alignment mode of text. Available values are as follows:
- **'alphabetic'**: The text baseline is the normal alphabetic baseline.
- **'top'**: The text baseline is on the top of the text bounding box.
- **'hanging'**: The text baseline is a hanging baseline over the text.
- **'middle'**: The text baseline is in the middle of the text bounding box.
- **'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.
- **'bottom'**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line. | +| [globalAlpha](#globalalpha) | number | - | Opacity. **0.0**: completely transparent; **1.0**: completely opaque. | +| [lineDashOffset](#linedashoffset) | number | 0.0 | Offset of the dashed line. The precision is float. | +| [globalCompositeOperation](#globalcompositeoperation) | string | 'source-over' | Composition operation type. Available values are as follows: **'source-over'**, **'source-atop'**, **'source-in'**, **'source-out'**, **'destination-over'**, **'destination-atop'**, **'destination-in'**, **'destination-out'**, **'lighter'**, **'copy'**, and **'xor'**. | +| [shadowBlur](#shadowblur) | number | 0.0 | Blur level during shadow drawing. A larger value indicates a more blurred effect. The precision is float. | +| [shadowColor](#shadowcolor) | <color> | - | Shadow color. | +| [shadowOffsetX](#shadowoffsetx) | number | - | X-axis shadow offset relative to the original object. | +| [shadowOffsetY](#shadowoffsety) | number | - | Y-axis shadow offset relative to the original object. | +| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | true | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite. | +| imageSmoothingQuality | string | 'low' | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**. | > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The value of the **<color>** type can be in 'rgb(255, 255, 255)', 'rgba(255, 255, 255, 1.0)', or '\#FFFFFF' format. @@ -462,19 +462,19 @@ struct LineDashOffset { ### globalCompositeOperation -| Name | Description | -| -------- | -------- | -| source-over | Displays the new drawing above the existing drawing. This attribute is used by default. | -| source-atop | Displays the new drawing on the top of the existing drawing. | -| source-in | Displays the new drawing inside the existing drawing. | -| source-out | Displays the part of the new drawing that is outside of the existing drawing. | +| Name | Description | +| ---------------- | ---------------------------------------- | +| source-over | Displays the new drawing above the existing drawing. This attribute is used by default. | +| source-atop | Displays the new drawing on the top of the existing drawing. | +| source-in | Displays the new drawing inside the existing drawing. | +| source-out | Displays the part of the new drawing that is outside of the existing drawing. | | destination-over | Displays the existing drawing above the new drawing. | | destination-atop | Displays the existing drawing on the top of the new drawing. | -| destination-in | Displays the existing drawing inside the new drawing. | -| destination-out | Displays the part of the existing drawing that is outside of the new drawing. | -| lighter | Displays both the new drawing and the existing drawing. | -| copy | Displays the new drawing and neglects the existing drawing. | -| xor | Combines the new drawing and existing drawing using the XOR operation. | +| destination-in | Displays the existing drawing inside the new drawing. | +| destination-out | Displays the part of the existing drawing that is outside of the new drawing. | +| lighter | Displays both the new drawing and the existing drawing. | +| copy | Displays the new drawing and neglects the existing drawing. | +| xor | Combines the new drawing and existing drawing using the XOR operation. | ``` @@ -702,15 +702,15 @@ fillRect(x: number, y: number, w: number, h: number): void Fills a rectangle on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | - | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | - | width | number | Yes | 0 | Width of the rectangle. | - | height | number | Yes | 0 | Height of the rectangle. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | - Example - + ``` @Entry @Component @@ -747,15 +747,15 @@ strokeRect(x: number, y: number, w: number, h: number): void Draws an outlined rectangle on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | - | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | - | width | number | Yes | 0 | Width of the rectangle. | - | height | number | Yes | 0 | Height of the rectangle. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | - Example - + ``` @Entry @Component @@ -791,15 +791,15 @@ clearRect(x: number, y: number, w: number, h: number): void Clears the content in a rectangle on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | - | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | - | width | number | Yes | 0 | Width of the rectangle. | - | height | number | Yes | 0 | Height of the rectangle. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | - Example - + ``` @Entry @Component @@ -837,14 +837,14 @@ fillText(text: string, x: number, y: number): void Draws filled text on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | text | string | Yes | "" | Text to draw. | - | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | - | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | text | string | Yes | "" | Text to draw. | + | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | + | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | - Example - + ``` @Entry @Component @@ -881,14 +881,14 @@ strokeText(text: string, x: number, y: number): void Draws a text stroke on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | text | string | Yes | "" | Text to draw. | - | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | - | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | text | string | Yes | "" | Text to draw. | + | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | + | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | - Example - + ``` @Entry @Component @@ -925,22 +925,22 @@ measureText(text: string): TextMetrics Returns a **TextMetrics** object used to obtain the width of specified text. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | text | string | Yes | "" | Text to be measured. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | -------------------- | + | text | string | Yes | "" | Text to be measured. | - Return value - | Type | Description | - | -------- | -------- | - | TextMetrics | **TextMetrics** object. | + | Type | Description | + | ----------- | ----------------------- | + | TextMetrics | **TextMetrics** object. | - **TextMetrics** attributes - | Name | Type | Description | - | -------- | -------- | -------- | - | width | number | Width of the text. | + | Name | Type | Description | + | ----- | ------ | ------------------ | + | width | number | Width of the text. | - Example - + ``` @Entry @Component @@ -978,12 +978,12 @@ stroke(path?: Path2D): void Strokes a path. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | path | [Path2D](ts-components-canvas-path2d.md) | No | null | A **Path2D** path to draw. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ---------------------------------------- | --------- | ------------- | -------------------------- | + | path | [Path2D](ts-components-canvas-path2d.md) | No | null | A **Path2D** path to draw. | - Example - + ``` @Entry @Component @@ -1022,7 +1022,7 @@ beginPath(): void Creates a drawing path. - Example - + ``` @Entry @Component @@ -1063,13 +1063,13 @@ moveTo(x: number, y: number): void Moves a drawing path to a target position on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the target position. | - | y | number | Yes | 0 | Y-coordinate of the target position. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ------------------------------------ | + | x | number | Yes | 0 | X-coordinate of the target position. | + | y | number | Yes | 0 | Y-coordinate of the target position. | - Example - + ``` @Entry @Component @@ -1108,13 +1108,13 @@ lineTo(x: number, y: number): void Connects the current point to a target position using a straight line. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the target position. | - | y | number | Yes | 0 | Y-coordinate of the target position. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ------------------------------------ | + | x | number | Yes | 0 | X-coordinate of the target position. | + | y | number | Yes | 0 | Y-coordinate of the target position. | - Example - + ``` @Entry @Component @@ -1153,7 +1153,7 @@ closePath(): void Draws a closed path. - Example - + ``` @Entry @Component @@ -1194,13 +1194,13 @@ createPattern(image: ImageBitmap, repetition: string): CanvasPattern Creates a pattern for image filling based on a specified source image and repetition mode. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Source image. For details, see ImageBitmap. | - | repetition | string | Yes | "" | Repetition mode. The value can be **'repeat'**, **'repeat-x'**, **'repeat-y'**, or **'no-repeat'**. | + | Name | Type | Mandatory | Default Value | Description | + | ---------- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- | + | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Source image. For details, see ImageBitmap. | + | repetition | string | Yes | "" | Repetition mode. The value can be **'repeat'**, **'repeat-x'**, **'repeat-y'**, or **'no-repeat'**. | - Example - + ``` @Entry @Component @@ -1239,17 +1239,17 @@ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, Draws a cubic bezier curve on the canvas. - Name - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | cp1x | number | Yes | 0 | X-coordinate of the first parameter of the bezier curve. | - | cp1y | number | Yes | 0 | Y-coordinate of the first parameter of the bezier curve. | - | cp2x | number | Yes | 0 | X-coordinate of the second parameter of the bezier curve. | - | cp2y | number | Yes | 0 | Y-coordinate of the second parameter of the bezier curve. | - | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | - | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | cp1x | number | Yes | 0 | X-coordinate of the first parameter of the bezier curve. | + | cp1y | number | Yes | 0 | Y-coordinate of the first parameter of the bezier curve. | + | cp2x | number | Yes | 0 | X-coordinate of the second parameter of the bezier curve. | + | cp2y | number | Yes | 0 | Y-coordinate of the second parameter of the bezier curve. | + | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | + | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | - Example - + ``` @Entry @Component @@ -1288,15 +1288,15 @@ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void Draws a quadratic curve on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | cpx | number | Yes | 0 | X-coordinate of the bezier curve parameter. | - | cpy | number | Yes | 0 | Y-coordinate of the bezier curve parameter. | - | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | - | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | cpx | number | Yes | 0 | X-coordinate of the bezier curve parameter. | + | cpy | number | Yes | 0 | Y-coordinate of the bezier curve parameter. | + | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | + | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | - Example - + ``` @Entry @Component @@ -1335,17 +1335,17 @@ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, Draws an arc on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the center point of the arc. | - | y | number | Yes | 0 | Y-coordinate of the center point of the arc. | - | radius | number | Yes | 0 | Radius of the arc. | - | startAngle | number | Yes | 0 | Start radian of the arc. | - | endAngle | number | Yes | 0 | End radian of the arc. | - | anticlockwise | boolean | No | false | Whether to draw the arc counterclockwise. | + | Name | Type | Mandatory | Default Value | Description | + | ------------- | ------- | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the center point of the arc. | + | y | number | Yes | 0 | Y-coordinate of the center point of the arc. | + | radius | number | Yes | 0 | Radius of the arc. | + | startAngle | number | Yes | 0 | Start radian of the arc. | + | endAngle | number | Yes | 0 | End radian of the arc. | + | anticlockwise | boolean | No | false | Whether to draw the arc counterclockwise. | - Example - + ``` @Entry @Component @@ -1383,16 +1383,16 @@ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void Draws an arc based on the radius and points on the arc. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x1 | number | Yes | 0 | X-coordinate of the first point on the arc. | - | y1 | number | Yes | 0 | Y-coordinate of the first point on the arc. | - | x2 | number | Yes | 0 | X-coordinate of the second point on the arc. | - | y2 | number | Yes | 0 | Y-coordinate of the second point on the arc. | - | radius | number | Yes | 0 | Radius of the arc. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | x1 | number | Yes | 0 | X-coordinate of the first point on the arc. | + | y1 | number | Yes | 0 | Y-coordinate of the first point on the arc. | + | x2 | number | Yes | 0 | X-coordinate of the second point on the arc. | + | y2 | number | Yes | 0 | Y-coordinate of the second point on the arc. | + | radius | number | Yes | 0 | Radius of the arc. | - Example - + ``` @Entry @Component @@ -1430,20 +1430,20 @@ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number Draws an ellipse in the specified rectangular region. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the ellipse center. | - | y | number | Yes | 0 | Y-coordinate of the ellipse center. | - | radiusX | number | Yes | 0 | Ellipse radius on the x-axis. | - | radiusY | number | Yes | 0 | Ellipse radius on the y-axis. | - | rotation | number | Yes | 0 | Rotation angle of the ellipse, in radians. | - | startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse, in radians. | - | endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse, in radians. | - | anticlockwise | boolean | No | false | Whether to draw the ellipse in the counterclockwise direction. | + | Name | Type | Mandatory | Default Value | Description | + | ------------- | ------- | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the ellipse center. | + | y | number | Yes | 0 | Y-coordinate of the ellipse center. | + | radiusX | number | Yes | 0 | Ellipse radius on the x-axis. | + | radiusY | number | Yes | 0 | Ellipse radius on the y-axis. | + | rotation | number | Yes | 0 | Rotation angle of the ellipse, in radians. | + | startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse, in radians. | + | endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse, in radians. | + | anticlockwise | boolean | No | false | Whether to draw the ellipse in the counterclockwise direction. | - Example - + ``` @Entry @Component @@ -1481,15 +1481,15 @@ rect(x: number, y: number, width: number, height: number): void Creates a rectangle. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | - | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | - | width | number | Yes | 0 | Width of the rectangle. | - | height | number | Yes | 0 | Height of the rectangle. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | - Example - + ``` @Entry @Component @@ -1526,7 +1526,7 @@ fill(): void Fills the area inside a closed path. - Example - + ``` @Entry @Component @@ -1563,7 +1563,7 @@ clip(): void Sets the current path to a clipping path. - Example - + ``` @Entry @Component @@ -1603,12 +1603,12 @@ rotate(rotate: number): void Rotates a canvas clockwise around its coordinate axes. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | rotate | number | Yes | 0 | Clockwise rotation angle. You can use **Math.PI / 180** to convert the angle to a radian. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ---------------------------------------- | + | rotate | number | Yes | 0 | Clockwise rotation angle. You can use **Math.PI / 180** to convert the angle to a radian. | - Example - + ``` @Entry @Component @@ -1645,13 +1645,13 @@ scale(x: number, y: number): void Scales a canvas based on scale factors. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | Horizontal scale factor. | - | y | number | Yes | 0 | Vertical scale factor. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ------------------------ | + | x | number | Yes | 0 | Horizontal scale factor. | + | y | number | Yes | 0 | Vertical scale factor. | - Example - + ``` @Entry @Component @@ -1690,23 +1690,23 @@ Defines a transformation matrix. To transform a graph, you only need to set para > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The following formulas calculate coordinates of the transformed graph. **x** and **y** represent coordinates before transformation, and **x'** and **y'** represent coordinates after transformation. -> +> > - x' = scaleX \* x + skewY \* y + translateX -> +> > - y' = skewX \* x + scaleY \* y + translateY - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | scaleX | number | Yes | 0 | X-axis scale. | - | skewX | number | Yes | 0 | X-axis skew. | - | skewY | number | Yes | 0 | Y-axis skew. | - | scaleY | number | Yes | 0 | Y-axis scale. | - | translateX | number | Yes | 0 | X-axis translation. | - | translateY | number | Yes | 0 | Y-axis translation. | + | Name | Type | Mandatory | Default Value | Description | + | ---------- | ------ | --------- | ------------- | ------------------- | + | scaleX | number | Yes | 0 | X-axis scale. | + | skewX | number | Yes | 0 | X-axis skew. | + | skewY | number | Yes | 0 | Y-axis skew. | + | scaleY | number | Yes | 0 | Y-axis scale. | + | translateX | number | Yes | 0 | X-axis translation. | + | translateY | number | Yes | 0 | Y-axis translation. | - Example - + ``` @Entry @Component @@ -1749,17 +1749,17 @@ setTransform(scaleX: number, skewX: number, skewY: number, scale: number, transl Resets the existing transformation matrix and creates a new transformation matrix by using the same parameters as the **transform()** function. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | scaleX | number | Yes | 0 | X-axis scale. | - | skewX | number | Yes | 0 | X-axis skew. | - | skewY | number | Yes | 0 | Y-axis skew. | - | scaleY | number | Yes | 0 | Y-axis scale. | - | translateX | number | Yes | 0 | X-axis translation. | - | translateY | number | Yes | 0 | Y-axis translation. | + | Name | Type | Mandatory | Default Value | Description | + | ---------- | ------ | --------- | ------------- | ------------------- | + | scaleX | number | Yes | 0 | X-axis scale. | + | skewX | number | Yes | 0 | X-axis skew. | + | skewY | number | Yes | 0 | Y-axis skew. | + | scaleY | number | Yes | 0 | Y-axis scale. | + | translateX | number | Yes | 0 | X-axis translation. | + | translateY | number | Yes | 0 | Y-axis translation. | - Example - + ``` @Entry @Component @@ -1799,13 +1799,13 @@ translate(x: number, y: number): void Moves the origin of the coordinate system. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x | number | Yes | 0 | X-axis translation. | - | y | number | Yes | 0 | Y-axis translation. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ------------------- | + | x | number | Yes | 0 | X-axis translation. | + | y | number | Yes | 0 | Y-axis translation. | - Example - + ``` @Entry @Component @@ -1847,21 +1847,21 @@ drawImage(image: ImageBitmap, sx: number, sy: number, sWidth: number, sHeight: n Draws an image. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Image resource. For details, see ImageBitmap. | - | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | - | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | - | sWidth | number | No | 0 | Target width to crop the source image. | - | sHeight | number | No | 0 | Target height to crop the source image. | - | dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. | - | dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas. | - | dWidth | number | No | 0 | Width of the drawing area. | - | dHeight | number | No | 0 | Height of the drawing area. | + | Name | Type | Mandatory | Default Value | Description | + | ------- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- | + | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Image resource. For details, see ImageBitmap. | + | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | + | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | + | sWidth | number | No | 0 | Target width to crop the source image. | + | sHeight | number | No | 0 | Target height to crop the source image. | + | dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. | + | dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas. | + | dWidth | number | No | 0 | Width of the drawing area. | + | dHeight | number | No | 0 | Height of the drawing area. | - Example - + ``` @Entry @Component @@ -1898,10 +1898,10 @@ createImageData(width: number, height: number): Object Creates an **ImageData** object based on the specified width and height. For details, see [ImageData](ts-components-canvas-imagebitmap.md). - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | width | number | Yes | 0 | Width of the **ImageData** object. | - | height | number | Yes | 0 | Height of the **ImageData** object. | + | Name | Type | Mandatory | Default Value | Description | + | ------ | ------ | --------- | ------------- | ----------------------------------- | + | width | number | Yes | 0 | Width of the **ImageData** object. | + | height | number | Yes | 0 | Height of the **ImageData** object. | ### createImageData @@ -1911,9 +1911,9 @@ createImageData(imageData: ImageData): Object Creates an **ImageData** object by copying an existing **ImageData** object. For details, see [ImageData](ts-components-canvas-imagebitmap.md). - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | imagedata | [ImageData](ts-components-canvas-imagebitmap.md) | Yes | null | **ImageData** object to copy. | + | Name | Type | Mandatory | Default Value | Description | + | --------- | ---------------------------------------- | --------- | ------------- | ----------------------------- | + | imagedata | [ImageData](ts-components-canvas-imagebitmap.md) | Yes | null | **ImageData** object to copy. | ### getImageData @@ -1923,12 +1923,12 @@ getImageData(sx: number, sy: number, sw: number, sh: number): Object Creates an [ImageData](ts-components-canvas-imagebitmap.md) object with pixels in the specified area on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area. | - | sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area. | - | sw | number | Yes | 0 | Width of the output area. | - | sh | number | Yes | 0 | Height of the output area. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area. | + | sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area. | + | sw | number | Yes | 0 | Width of the output area. | + | sh | number | Yes | 0 | Height of the output area. | ### putImageData @@ -1938,18 +1938,18 @@ putImageData(imageData: Object, dx: number, dy: number, dirtyX?: number, dirtyY? Puts the [ImageData](ts-components-canvas-imagebitmap.md) onto a rectangular area on the canvas. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | imagedata | Object | Yes | null | **ImageData** object with pixels to put onto the canvas. | - | dx | number | Yes | 0 | X-axis offset of the rectangular area on the canvas. | - | dy | number | Yes | 0 | Y-axis offset of the rectangular area on the canvas. | - | dirtyX | number | No | 0 | X-axis offset of the upper left corner of the rectangular area relative to that of the source image. | - | dirtyY | number | No | 0 | Y-axis offset of the upper left corner of the rectangular area relative to that of the source image. | - | dirtyWidth | number | No | Width of the **ImageData** object | Width of the rectangular area to crop the source image. | - | dirtyHeight | number | No | Height of the **ImageData** object | Height of the rectangular area to crop the source image. | + | Name | Type | Mandatory | Default Value | Description | + | ----------- | ------ | --------- | ---------------------------------- | ---------------------------------------- | + | imagedata | Object | Yes | null | **ImageData** object with pixels to put onto the canvas. | + | dx | number | Yes | 0 | X-axis offset of the rectangular area on the canvas. | + | dy | number | Yes | 0 | Y-axis offset of the rectangular area on the canvas. | + | dirtyX | number | No | 0 | X-axis offset of the upper left corner of the rectangular area relative to that of the source image. | + | dirtyY | number | No | 0 | Y-axis offset of the upper left corner of the rectangular area relative to that of the source image. | + | dirtyWidth | number | No | Width of the **ImageData** object | Width of the rectangular area to crop the source image. | + | dirtyHeight | number | No | Height of the **ImageData** object | Height of the rectangular area to crop the source image. | - Example - + ``` @Entry @Component @@ -1992,7 +1992,7 @@ restore(): void Restores the saved drawing context. - Example - + ``` @Entry @Component @@ -2026,7 +2026,7 @@ save(): void Saves the current drawing context. - Example - + ``` @Entry @Component @@ -2060,15 +2060,15 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void Creates a linear gradient. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x0 | number | Yes | 0 | X-coordinate of the start point. | - | y0 | number | Yes | 0 | Y-coordinate of the start point. | - | x1 | number | Yes | 0 | X-coordinate of the end point. | - | y1 | number | Yes | 0 | Y-coordinate of the end point. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | -------------------------------- | + | x0 | number | Yes | 0 | X-coordinate of the start point. | + | y0 | number | Yes | 0 | Y-coordinate of the start point. | + | x1 | number | Yes | 0 | X-coordinate of the end point. | + | y1 | number | Yes | 0 | Y-coordinate of the end point. | - Example - + ``` @Entry @Component @@ -2085,9 +2085,9 @@ Creates a linear gradient. .backgroundColor('#ffff00') .onReady(() =>{ var grad = this.offContext.createLinearGradient(50,0, 300,100) - this.grad.addColorStop(0.0, 'red') - this.grad.addColorStop(0.5, 'white') - this.grad.addColorStop(1.0, 'green') + grad.addColorStop(0.0, 'red') + grad.addColorStop(0.5, 'white') + grad.addColorStop(1.0, 'green') this.offContext.fillStyle = grad this.offContext.fillRect(0, 0, 500, 500) var image = this.offContext.transferToImageBitmap() @@ -2110,17 +2110,17 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, Creates a linear gradient. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | x0 | number | Yes | 0 | X-coordinate of the center of the start circle. | - | y0 | number | Yes | 0 | Y-coordinate of the center of the start circle. | - | r0 | number | Yes | 0 | Radius of the start circle, which must be a non-negative finite number. | - | x1 | number | Yes | 0 | X-coordinate of the center of the end circle. | - | y1 | number | Yes | 0 | Y-coordinate of the center of the end circle. | - | r1 | number | Yes | 0 | Radius of the end circle, which must be a non-negative finite number. | + | Name | Type | Mandatory | Default Value | Description | + | ---- | ------ | --------- | ------------- | ---------------------------------------- | + | x0 | number | Yes | 0 | X-coordinate of the center of the start circle. | + | y0 | number | Yes | 0 | Y-coordinate of the center of the start circle. | + | r0 | number | Yes | 0 | Radius of the start circle, which must be a non-negative finite number. | + | x1 | number | Yes | 0 | X-coordinate of the center of the end circle. | + | y1 | number | Yes | 0 | Y-coordinate of the center of the end circle. | + | r1 | number | Yes | 0 | Radius of the end circle, which must be a non-negative finite number. | - Example - + ``` @Entry @Component @@ -2137,9 +2137,9 @@ Creates a linear gradient. .backgroundColor('#ffff00') .onReady(() =>{ var grad = this.offContext.createRadialGradient(200,200,50, 200,200,200) - this.grad.addColorStop(0.0, 'red') - this.grad.addColorStop(0.5, 'white') - this.grad.addColorStop(1.0, 'green') + grad.addColorStop(0.0, 'red') + grad.addColorStop(0.5, 'white') + grad.addColorStop(1.0, 'green') this.offContext.fillStyle = grad this.offContext.fillRect(0, 0, 500, 500) var image = this.offContext.transferToImageBitmap() diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-click.md b/en/application-dev/reference/arkui-ts/ts-universal-events-click.md index f69971a1e257683180bd89129e51e92727ee1a4f..85f747e8f45c5094683abdd91b52e08effbad07e 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -28,6 +28,28 @@ None | target8+ | EventTarget | Target element that is clicked. | | timestamp | number | Timestamp of the event. | +- EventTarget8+ attributes + + | Name | Type | Description | + | -------- | -------- | -------- | + | area | Area | Area information of the target element.| + +- Area8+ attributes + + | Name | Type | Description | + | -------- | -------- | -------- | + | width | number | Width of the target element, in vp. | + | height | number | Height of the target element, in vp. | + | pos | Position | Position of the upper left corner of the target element relative to that of the parent element. | + | globalPos | Position | Position of the upper left corner of the target element relative to that of the page. | + +- Position8+ attributes + + | Name | Type | Description | + | -------- | -------- | -------- | + | x | number | X-coordinate, in vp. | + | y | number | Y-coordinate, in vp. | + ## Example diff --git a/en/application-dev/security/hapsigntool-guidelines.md b/en/application-dev/security/hapsigntool-guidelines.md index e3293428015fed2753049e723aef671a9935f9de..b01a3f124a6eeb40e1febc82ca7669a7e789eb60 100644 --- a/en/application-dev/security/hapsigntool-guidelines.md +++ b/en/application-dev/security/hapsigntool-guidelines.md @@ -19,7 +19,7 @@ The hapsigner tool is implemented based on the Public Key Infrastructure (PKI). The CSR contains the public key, subject, and private key signature of a certificate. Before applying for a certificate, you must generate a CSR based on the key pair and submit the CSR to the Certificate Authority (CA). - Certificate - OpenHarmony uses the RFC5280 standard to build the X.509 certificate trust system. The OpenHarmony certificates used for application signatures are classified into the root CA certificate, subordinate CA certificate, and application or profile signing certificate. The application signing certificate indicates the identity of the application developer, which ensures the traceability of the source of the applications. The profile signing certificate is used to verify the signature of the profile, which ensures the integrity of the profile. + OpenHarmony uses the RFC5280 standard to build the X.509 certificate trust system. The OpenHarmony certificates used for application signatures are classified into the root CA certificate, intermediate CA certificate, and end-entity certificate (application or profile signing certificate). The application signing certificate indicates the identity of the application developer, which ensures the traceability of the source of the applications. The profile signing certificate is used to verify the signature of the profile, which ensures the integrity of the profile. - HAP @@ -61,7 +61,7 @@ The hapsigner tool is implemented based on the Public Key Infrastructure (PKI). ### When to Use -The OpenHarmony system has a built-in KeyStore (KS) file named **OpenHarmony.p12**. This file contains the root CA certificate, subordinate CA certificate, and application or profile signing certificate information. The hapsigner tool signs the OpenHarmony applications based on this KS file. +The OpenHarmony system has a built-in KeyStore (KS) file named **OpenHarmony.p12**. This file contains the root CA certificate, intermediate CA certificate, and end-entity certificate information. The hapsigner tool signs the OpenHarmony applications based on this KS file. The usage of hapsigner varies depending on whether an application signing certificate is available. @@ -102,9 +102,9 @@ The usage of hapsigner varies depending on whether an application signing certif ├── -keystorePwd # KS password. It is optional. ├── -outFile # CSR to generate. It is optional. If you do not specify this parameter, the CSR is output to the console. -5. Generate a root CA or subordinate CA certificate. +5. Generate a root CA or intermediate CA certificate. - generate-ca: Generate a root CA or subordinate CA certificate. If the key does not exist, generate a key together with the certificate. + generate-ca: Generate a root CA or intermediate CA certificate. If the key does not exist, generate a key together with the certificate. ├── -keyAlias # Key alias. It is mandatory. ├── -keyPwd # Key password. It is optional. ├── -keyAlg # Key algorithm, which can be RSA or ECC. It is mandatory. @@ -139,7 +139,7 @@ The usage of hapsigner varies depending on whether an application signing certif ├── -keystorePwd # KS password. It is optional. ├── -outForm # Format of the certificate to generate. It is optional. The value can be cert or certChain. The default value is certChain. ├── -rootCaCertFile # Root CA certificate, which is mandatory when outForm is certChain. - ├── -subCaCertFile # Subordinate CA certificate, which is mandatory when outForm is certChain. + ├── -subCaCertFile # Intermediate CA certificate, which is mandatory when outForm is certChain. ├── -outFile # Certificate file (certificate or certificate chain) to generate. It is optional. The file is output to the console if this parameter is not specified. 7. Generate a profile debug or release certificate. @@ -159,7 +159,7 @@ The usage of hapsigner varies depending on whether an application signing certif ├── -keystorePwd # KS password. It is optional. ├── -outForm # Format of the certificate to generate. It is optional. The value can be cert or certChain. The default value is certChain. ├── -rootCaCertFile # Root CA certificate, which is mandatory when outForm is certChain. - ├── -subCaCertFile # Subordinate CA certificate, which is mandatory when outForm is certChain. + ├── -subCaCertFile # Intermediate CA certificate, which is mandatory when outForm is certChain. ├── -outFile # Certificate file (certificate or certificate chain) to generate. It is optional. The file is output to the console if this parameter is not specified. 8. Generate a common certificate, which can be used to generate a custom certificate. @@ -196,7 +196,7 @@ The usage of hapsigner varies depending on whether an application signing certif ├── -mode # Signing mode, which can be localSign or remoteSign. It is mandatory. ├── -keyAlias # Key alias. It is mandatory. ├── -keyPwd # Key password. It is optional. - ├── -profileCertFile # Profile signing certificate (certificate chain, in application or profile certificate, subordinate CA certificate, and root certificate order). It is mandatory. + ├── -profileCertFile # Profile signing certificate (certificate chain, in the end-entity certificate, intermediate CA certificate, and root certificate order). It is mandatory. ├── -inFile # Raw profile template in JSON format (developtools_hapsigner/autosign/UnsgnedReleasedProfileTemplate.json). It is mandatory. ├── -signAlg # Signature algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. ├── -keystoreFile # KS file, in JKS or P12 format. It is mandatory if the signing mode is localSign. @@ -207,15 +207,15 @@ The usage of hapsigner varies depending on whether an application signing certif verify-profile: Verify the provisioning profile signature. ├── -inFile # Signed provisioning profile, in p7b format. It is mandatory. - ├── -outFil # Verification result file (including the verification result and profile content), in json format. It is optional. The file is output to the console if this parameter is not specified. + ├── -outFile # Verification result file (including the verification result and profile content), in json format. It is optional. The file is output to the console if this parameter is not specified. 11. Sign a HAP. sign-app: Sign a HAP. ├── -mode # Signing mode, which can be localSign, remoteSign, or remoteResign. It is mandatory. ├── -keyAlias # Key alias. It is mandatory. - ├──-keyPwd # Key password. It is optional. - ├── -appCertFile # Application signing certificate (certificate chain in application or profile certificate, subordinate CA certificate, and root certificate order). It is mandatory. + ├── -keyPwd # Key password. It is optional. + ├── -appCertFile # Application signing certificate (certificate chain, in the end-entity certificate, intermediate CA certificate, and root certificate order). It is mandatory. ├── -profileFile # Singed provisioning profile, in p7b format. It is mandatory. ├── -profileSigned # Whether the profile is signed. The value 1 means signed, and value 0 means unsigned. The default value is 1. It is optional. ├── -inForm # Raw file, in .zip (default) or .bin format. It is optional. @@ -245,8 +245,8 @@ The process of signing a HAP is as follows: > **Precautions**
> > For security purposes, the ECC algorithm is recommended for generating key pairs for application signing signatures. The RSA algorithm is not recommended.
-> You are advised to place the HAP, profile, KS file **OpenHarmony.p12**, root CA certificate, subordinate CA certificate, and hapsigner in the same directory for easy operation. -> The **developtools_hapsigner/autosign/result/** directory has the following files:
- OpenHarmony KS file **OpenHarmony.p12**
- Root CA certificate **rootCA.cer**
- Subordinate CA certificate **subCA.cer**
- Profile signing certificate **OpenHarmonyProfileRelease.pem** +> You are advised to place the HAP, profile, KS file **OpenHarmony.p12**, root CA certificate, intermediate CA certificate, and hapsigner in the same directory for easy operation. +> The **developtools_hapsigner/autosign/result/** directory has the following files:
- OpenHarmony KS file **OpenHarmony.p12**
- Root CA certificate **rootCA.cer**
- Intermediate CA certificate **subCA.cer**
- Profile signing certificate **OpenHarmonyProfileRelease.pem** **1. Generate a key pair for the application signing certificate.** @@ -273,7 +273,7 @@ The command parameters are described as follows: **2. Generate an application signing certificate.** -Use the local subordinate CA certificate to issue an application signing certificate. +Use the local intermediate CA certificate to issue an application signing certificate. Example: @@ -285,13 +285,13 @@ The command parameters are described as follows: generate-app-cert: Generate an application signing certificate. ├── -keyAlias # Key alias, which must be the same as that in the previous step. ├── -signAlg # Signature algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. - ├── -issuer # Issuer of the certificate. Enter the issuer of the subordinate CA certificate. It is mandatory and cannot be changed. - ├── -issuerKeyAlias # Key alias of the issuer. Enter the key alias of the subordinate CA certificate. It is mandatory and cannot be changed. + ├── -issuer # Issuer of the certificate. Enter the issuer of the intermediate CA certificate. It is mandatory and cannot be changed. + ├── -issuerKeyAlias # Key alias of the issuer. Enter the key alias of the intermediate CA certificate. It is mandatory and cannot be changed. ├── -subject # Subject of the certificate. Enter the subject in the same sequence specified in the command. This parameter is mandatory. - ├── -issuerKeyPwd # Key password of the issuer. Enter the key password of the subordinate CA certificate. It is mandatory and cannot be changed. In this example, it is 123456. + ├── -issuerKeyPwd # Key password of the issuer. Enter the key password of the intermediate CA certificate. It is mandatory and cannot be changed. In this example, it is 123456. ├── -keystoreFile # KS file. Use OpenHarmony.p12. It is mandatory and cannot be changed. ├── -rootCaCertFile # Root certificate. It is mandatory and cannot be changed. - ├── -subCaCertFile # Subordinate CA certificate. It is mandatory and cannot be changed. + ├── -subCaCertFile # Intermediate CA certificate. It is mandatory and cannot be changed. ├── -outForm # Format of the certificate file to generate. certChain is recommended. ├── -outFile # File to generate. It is optional. The file is output to the console if this parameter is not specified. ├── -keyPwd # Key password. It is optional. It is the key password set when the key pair is generated. @@ -344,7 +344,7 @@ The command parameters are described as follows: ├──-keyAlias # Key alias, which must be the same as the alias of the key pair generated. This parameter is mandatory. ├── -signAlg # Signature algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. ├── -mode # Signing mode, which must be localSign. It is mandatory. - ├── -appCertFile # Application signing certificate (certificate chain, in application signing certificate, subordinate CA certificate, and root certificate order). Enter the application signing certificate generated. This parameter is mandatory. + ├── -appCertFile # Application signing certificate (certificate chain, in the end-entity certificate, intermediate CA certificate, and root certificate order). Enter the application signing certificate generated. This parameter is mandatory. ├── -profileFile # Signed provisioning profile in p7b format. Enter the profile generated. This parameter is mandatory. ├── -inFile # Raw application package. It is mandatory. ├── -keystoreFile # KS file, which must be the same as the KS file generated. It is mandatory and cannot be changed. diff --git a/en/application-dev/ui/figures/loadingProgress.png b/en/application-dev/ui/figures/loadingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..afc52b1a469c858e3029282e193b684114803db0 Binary files /dev/null and b/en/application-dev/ui/figures/loadingProgress.png differ diff --git a/en/application-dev/ui/ts-basic-components-loadingprogress.md b/en/application-dev/ui/ts-basic-components-loadingprogress.md new file mode 100644 index 0000000000000000000000000000000000000000..2550e50bee09c3ba09580a996a7fb4e171abe13f --- /dev/null +++ b/en/application-dev/ui/ts-basic-components-loadingprogress.md @@ -0,0 +1,44 @@ +# LoadingProgress + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component is used to display the loading progress. + +## Required Permissions + +None + +## Child Components + +None + +## APIs + +LoadingProgress() + +Creates a **LoadingProgress** instance. + +## Attributes + +| Name | Type | Default Value | Description | +| ----- | ----- | ------------- | ---------------------------------------- | +| color | Color | - | Foreground color of the loading progress bar. | + +## Example + +``` +@Entry +@Component +struct LoadingProgressExample { + build() { + Column({ space: 5 }) { + Text('Orbital LoadingProgress ').fontSize(9).fontColor(0xCCCCCC).width('90%') + LoadingProgress() + .color(Color.Blue) + }.width('100%').margin({ top: 5 }) + } +} +``` + +![zh-cn_image_0000001198839004](figures/loadingProgress.png) \ No newline at end of file diff --git a/en/application-dev/application-dev-website.md b/en/application-dev/website.md similarity index 96% rename from en/application-dev/application-dev-website.md rename to en/application-dev/website.md index e96f78041b8ee0ff2c80c2ac2218a77f559e1b3c..98d9ffe250c4827420553b7c348c085f1f7c5626 100644 --- a/en/application-dev/application-dev-website.md +++ b/en/application-dev/website.md @@ -1,29 +1,6 @@ # Application Development - [Application Development Overview](application-dev-guide.md) -- Learn About OpenHarmony - - [OpenHarmony Project](../OpenHarmony-Overview.md) - - [Glossary ](../device-dev/glossary/glossary.md) - - [OpenHarmony Release Notes](../release-notes/Readme.md) - - OpenHarmony 3.x Releases - - - [OpenHarmony v3.1 Beta (2021-12-31)](../release-notes/OpenHarmony-v3.1-beta.md) - - [OpenHarmony v3.0.1 LTS (2022-01-12)](../release-notes/OpenHarmony-v3.0.1-LTS.md) - - [OpenHarmony v3.0 LTS (2021-09-30)](../release-notes/OpenHarmony-v3.0-LTS.md) - - - OpenHarmony 2.x Releases - - - [OpenHarmony v2.2 beta2 (2021-08-04)](../release-notes/OpenHarmony-v2.2-beta2.md) - - [OpenHarmony 2.0 Canary (2021-06-01)](../release-notes/OpenHarmony-2-0-Canary.md) - - - OpenHarmony 1.x Releases - - - [OpenHarmony v1.1.4 LTS (2022-02-11)](../release-notes/OpenHarmony-v1-1-4-LTS.md) - - [OpenHarmony v1.1.3 LTS (2021-09-30)](../release-notes/OpenHarmony-v1-1-3-LTS.md) - - [OpenHarmony v1.1.2 LTS (2021-08-04)](../release-notes/OpenHarmony-v1.1.2-LTS.md) - - [OpenHarmony 1.1.1 LTS (2021-06-22)](../release-notes/OpenHarmony-1-1-1-LTS.md) - - [OpenHarmony 1.1.0 LTS (2021-04-01)](../release-notes/OpenHarmony-1-1-0-LTS.md) - - [OpenHarmony 1.0 (2020-09-10)](../release-notes/OpenHarmony-1-0.md) - Quick Start - [Getting Started with Application Development](quick-start/Readme-EN.md) - [DevEco Studio \(OpenHarmony\) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) @@ -569,6 +546,4 @@ - [Nonlinear Container TreeMap](reference/apis/js-apis-treemap.md) - [Nonlinear Container TreeSet](reference/apis/js-apis-treeset.md) - [Nonlinear Container LightWeightMap](reference/apis/js-apis-lightweightmap.md) - - [Nonlinear Container LightWeightSet](reference/apis/js-apis-lightweightset.md) -- Contribution - - [How to Contribute](../contribute/documentation-contribution.md) \ No newline at end of file + - [Nonlinear Container LightWeightSet](reference/apis/js-apis-lightweightset.md) \ No newline at end of file diff --git a/en/application-dev/windowmanager/Readme-EN.md b/en/application-dev/windowmanager/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..188b3d734af30592e6a886093e8193636cae6357 --- /dev/null +++ b/en/application-dev/windowmanager/Readme-EN.md @@ -0,0 +1,12 @@ +# Window Manager + +* Window + * [Window Overview](window-overview.md) + * [Window Development](window-guidelines.md) +* Display + * [Display Overview](display-overview.md) + * [Display Development](display-guidelines.md) +* Screenshot + * [Screenshot Overview](screenshot-overview.md) + * [Screenshot Development](screenshot-guidelines.md) + diff --git a/en/application-dev/windowmanager/display-guidelines.md b/en/application-dev/windowmanager/display-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..818d6dc3fa769d894c37754840ec7711f141c40c --- /dev/null +++ b/en/application-dev/windowmanager/display-guidelines.md @@ -0,0 +1,24 @@ +# Display Development + +## When to Use + +An application can obtain the default display object or all display objects by calling the **Display** APIs. + +## Available APIs + +For details about the APIs, see [Display](../reference/apis/js-apis-display.md). + +### How to Develop + +Call **getDefaultDisplay(): Promise** to obtain the default display object. An example code snippet is as follows: + +```js +import display from '@ohos.display' // Import the module. + +let disp; // disp is used to save the default display object. +display.getDefaultDisplay().then((disp) => { + console.log('display.getDefaultDisplay success, display :' + JSON.stringify(disp)); +}, (err) => { + console.log('display.getDefaultDisplay failed, error : ' + JSON.stringify(err)); +}) +``` diff --git a/en/application-dev/windowmanager/display-overview.md b/en/application-dev/windowmanager/display-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..702ff0961e6111f0d73f16f81e52cf7fcaca444f --- /dev/null +++ b/en/application-dev/windowmanager/display-overview.md @@ -0,0 +1,7 @@ +# Display Overview + +The **Display** APIs present the window layout of an application. The display attributes include the display ID, name, active status, state, refresh rate, rotation angle, width, height, pixel density, font scaling factor, and exact physical dots per inch. + +## Basic Concepts + +**Display**: a screen visible to an application. It can be used as a window container. It is an abstract concept that is different from a physical screen. diff --git a/en/application-dev/windowmanager/screenshot-guidelines.md b/en/application-dev/windowmanager/screenshot-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..a5023d76ec0645511de1c9a0a5f39779363a5729 --- /dev/null +++ b/en/application-dev/windowmanager/screenshot-guidelines.md @@ -0,0 +1,37 @@ +# Screenshot Development + +## When to Use + +You can specify a display device to take screenshots, with screenshot parameters specified. + +## Available APIs + +For details about the APIs, see [Screenshot](../reference/apis/js-apis-screenshot.md). + +## How to Develop + +Call **save(options?: ScreenshotOptions): Promise** to take a screenshot. In this API, **options** is a predefined screenshot parameter. If **options** is unspecified, the entire screen is captured by default. An example code snippet is as follows: + +```js +import screenshot from '@ohos.screenshot' // Import the module. + +// Set screenshot parameters. +var ScreenshotOptions = { + "screenRect": { + "left": 200, + "top": 100, + "width": 200, + "height": 200}, + "imageSize": { + "width": 300, + "height": 300}, + "rotation": 0 +}; + +let image; // image is used to save the screenshot. +screenshot.save(ScreenshotOptions).then((image) => { + console.log('screenshot.save success, screenshot image :' + JSON.stringify(image)); +}, (err) => { + console.log('screenshot.save failed, error : ' + JSON.stringify(err)); +}) +``` diff --git a/en/application-dev/windowmanager/screenshot-overview.md b/en/application-dev/windowmanager/screenshot-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..8f1a485a711e031dfc9762fb803d41c55c4380fd --- /dev/null +++ b/en/application-dev/windowmanager/screenshot-overview.md @@ -0,0 +1,7 @@ +# Screenshot Overview + +The screenshot APIs, with parameters, enable you to take screenshots on display devices. + +## Basic Concepts + +Screenshot: provides the screenshot capability. diff --git a/en/application-dev/windowmanager/window-guidelines.md b/en/application-dev/windowmanager/window-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..0f265cb868132595fb4311c07dae0ecd69934207 --- /dev/null +++ b/en/application-dev/windowmanager/window-guidelines.md @@ -0,0 +1,108 @@ +# Window Development + +# When to Use +The interface layer of the window runs in the application process. It loads the page layout and provides APIs. +By calling these APIs, you can create and destroy a window, set the position and size of a window, and enter the immersive mode (full-screen mode). + +## Available APIs +For details about the APIs, see [Window](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-window.md). + +**Table 1** Main window APIs + +| API | Description | +| :----------------------------------------------------------- | :--------------------------------------------- | +| create(id: string, type: WindowType, callback: AsyncCallback\): void | Creates a subwindow. | +| moveTo(x: number, y: number): Promise\ | Moves the window position. A positive value of **x** indicates that the window moves to the right, and a positive value of **y** indicates that the window moves downwards.| +| resetSize(width: number, height: number): Promise\ | Changes the window size. | +| hide(): Promise\ | Hides the window. | +| destroy(): Promise\ | Destroys the window. | + +## How to Develop + +### Creating a Main Window + +Currently, the main window is automatically created when the application is started. The declaration period, hiding, and destruction of the main window are managed by the application. +###Creating a Subwindow +You can call **create** to create a subwindow. The sample code is as follows: + +``` + import window from '@ohos.window'; + var windowClass = null; + let promise = window.create("subWindow", window.WindowType.TYPE_APP); + promise.then((data)=> { + windowClass = data; + console.info('SubWindow created. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); + }); +``` + +### Obtaining a Window Object + +- Call **getTopWindow** to obtain the top window of the application. The sample code is as follows: + +``` + var windowClass = null; + let promise = window.getTopWindow(); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + }) +``` + +- You can also call **find** to obtain created subwindows in the application. The sample code is as follows: + +``` + var windowClass = null; + let promise = window.find("subWindow"); + promise.then((data)=> { + windowClass = data; + console.info('window found. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); + }); +``` + +### Hiding and Destroying a Window + +After a window object is obtained, you can call **hide** and **destroy** to hide and destroy the window object, respectively. The sample code is as follows: + +``` + let promise = windowClass.hide(); + promise.then((data)=> { + console.info('window hidden. Data: ' + JSON.stringify(data)) + windowClass.destroy((err, data) => { + if (err.code) { + console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) + }) + }).catch((err)=>{ + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); + }) +``` + +### Enabling the Full-Screen Mode + +After a window object is obtained, + +- call **setFullScreen** to enable the full-screen mode for the window. + +The sample code is as follows: + +``` +import window from '@ohos.window'; +.onClick(async () => { + try { + const win = await window.getTopWindow() + await win.setFullScreen(true) + } catch (err) { + console.log(`setFullScreen fail, code = ${err.code}`) + } +}) +``` + +For the complete code, see [immersive](https://gitee.com/openharmony/windowmanager/tree/master/AppDemo/window/immersive). diff --git a/en/application-dev/windowmanager/window-overview.md b/en/application-dev/windowmanager/window-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..dee6a1730aeec73764782d1534e2d17109663fa8 --- /dev/null +++ b/en/application-dev/windowmanager/window-overview.md @@ -0,0 +1,18 @@ +# Window Overview + +The Window Manager subsystem provides basic capabilities of window and display management. It is the basis for UI display. +The Window Manager subsystem enables multiple applications to use the same physical screen for display and interaction. For each application, you only need to implement the interaction interface in the allocated display area. A window acts as a display container of the application interface, and the Window Manager subsystem organizes the interaction interfaces into a form visible to end users. + +## Basic Concepts + +**Immersive** + +The colors of the application interface, status bar, and navigation bar are the same to achieve the visual integrity. + +## Working Principles + +To display a UI on a screen, the application and system need to request a window object from the Window Manager subsystem. This object generally represents a rectangular area on the screen and has attributes such as the position, width, height, and overlay layer. The object also loads the root node of the UI framework in the interface. The UI of the application is loaded and displayed in the window through the root node. + +## Constraints + +Except the **on** and **off** APIs used for callback subscription and unsubscription, all other window APIs are asynchronous interfaces. diff --git a/en/contribute/template/js-template.md b/en/contribute/template/js-template.md index ea6dd159ab5a5840822797ef4f7f9f360e9eb2d4..3db27cbb7917bb597e2e39086ed68e520b7a9ca5 100644 --- a/en/contribute/template/js-template.md +++ b/en/contribute/template/js-template.md @@ -25,7 +25,7 @@ > 0.8 - **Deprecated content**: Do not delete the deprecated content directly from the document. Instead, suffix **deprecated** as a superscript to the content, and use the greater-than symbol (>) to introduce the substitute method plus the corresponding link. > Example: abandonmentMethod(deprecated) > -> > Discarded. This change is effective since API version 7. You are advised to use [newMethod](#newMethod) instead. +> > This APIs is no longer maintained since API version 7. You are advised to use [newMethod](#newMethod) instead. > > 0.9 - For **empty APIs that will be implemented only in the MR version**, add the following information to the interface description: > This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. diff --git a/en/device-dev/Readme-EN.md b/en/device-dev/Readme-EN.md index 804761547c1e51f3035264003702f54f82d4358a..a1314487576ae099dae3498a38d0549ee016a5fc 100644 --- a/en/device-dev/Readme-EN.md +++ b/en/device-dev/Readme-EN.md @@ -1,8 +1,8 @@ # Device +- [Device Development Overview](device-dev-guide.md) - Learn About OpenHarmony - [OpenHarmony Community](../OpenHarmony-Overview.md) - - [OpenHarmony OS](../readme.md) - [Glossary](glossary/glossary.md) - [Release Notes](../release-notes/Readme.md) - Quick Start diff --git a/en/device-dev/bundles/Readme-EN.md b/en/device-dev/bundles/Readme-EN.md index b95e0adea8e0b365a0c1a7736a77c8a8a1643ac2..3dd1fea2823e1f25a09b0233a632a61f028fb216 100644 --- a/en/device-dev/bundles/Readme-EN.md +++ b/en/device-dev/bundles/Readme-EN.md @@ -1,11 +1,5 @@ -# Bundle Development +# Bundles -- [Development Specifications](bundles-standard-rules.md) -- [Development Guidelines](bundles-guide.md) - - [Bundle Development](bundles-guide-overview.md) - - [Preparations](bundles-guide-prepare.md) - - [Bundle Development](bundles-guide-develop.md) -- [HPM User Guide](bundles-demo.md) - - [Introduction](bundles-demo-hpmdescription.md) - - [Preparations](bundles-demo-environment.md) - - [Development Example](bundles-demo-devsample.md) \ No newline at end of file +- [HPM Part Overview](hpm-part-about.md) +- [HPM Part Development](hpm-part-development.md) +- [HPM Part Reference](hpm-part-reference.md) diff --git a/en/device-dev/bundles/bundles-demo-devsample.md b/en/device-dev/bundles/bundles-demo-devsample.md deleted file mode 100644 index 51b24597883c985b44ce7f06c8f17db36ebeec77..0000000000000000000000000000000000000000 --- a/en/device-dev/bundles/bundles-demo-devsample.md +++ /dev/null @@ -1,54 +0,0 @@ -# Development Example - -The following uses the Hi3861 platform as an example to describe how to install and build bundles by using the hpm. - -1. Run the following commands to create a directory \(its name can be customized\) and create a default project based on the dist template: - - ``` - mkdir test3861 - cd test3861 - hpm init -t dist myproduct - ``` - - If the following information is displayed, the project is created: - - ``` - Initialization finished. - ``` - -2. Run the following command to install the **hispark\_pegasus** distribution: - - ``` - hpm install @ohos/hispark_pegasus - ``` - - If the following information is displayed, the installation is successful: - - ``` - Installed. - ``` - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >If you are using the Hi3516 platform, run the following command: - >``` - >hpm install @ohos/hispark_taurus - >``` - >If you are using the Hi3518 platform, run the following command: - >``` - >hpm install @ohos/hispark_aries - >``` - -3. Run the following command to build and package bundles: - - ``` - hpm dist - ``` - - If the building is successful, the following information is displayed: - - ``` - {{name}}: distribution building completed. - ``` - -4. Check the result in the **./out** directory. You can burn the distribution into the corresponding development board for testing. - diff --git a/en/device-dev/bundles/bundles-demo-environment.md b/en/device-dev/bundles/bundles-demo-environment.md deleted file mode 100644 index 1c73ff4b5cdf26909ca3b5b358308eebd8d8db60..0000000000000000000000000000000000000000 --- a/en/device-dev/bundles/bundles-demo-environment.md +++ /dev/null @@ -1,134 +0,0 @@ -# Configuring the Compilation Environment - -![](figure/3516dv300.png) - -## Linux Server - -Prepare a 64-bit Linux server running Ubuntu 16.04 or later. \(Currently, the compilation in the Windows environment is not fully supported.\) - -Configure Ubuntu to use bash as the Linux system shell, by performing the following: - -``` -ls -l $(which sh) -# If the file does not point to bash, modify the file using either of the provided methods. -# Method 1: Run the following command and select no: -dpkg-reconfigure dash -# Method 2: Run the following commands to delete /bin/sh and then create a new symbolic link to bash: -rm -f /bin/sh -ln -s bash /bin/sh -``` - -## Node.js - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->If the **Node.js** version of the source is outdated, run the following command before running **apt-get install**: ->``` ->curl -L https://deb.nodesource.com/setup_12.x | bash ->``` - -You are advised to install Node.js 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\). - -``` -sudo apt-get install nodejs -sudo apt-get install npm -``` - -Run the following commands to view **Node.js** and npm versions: - -``` -node --version # Check the Node.js version. -npm --version # Check the npm version. -``` - -## Installing hpm-cli Tool - -Install the **hpm-cli** command line tool by using the npm \(default source: https://registry.npmjs.org/\) provided by **Node.js**. - -``` -npm install -g @ohos/hpm-cli -``` - -After **hpm-cli** is installed, run the following command to view the default hpm configurations: - -``` -hpm config -``` - -You can modify the default configurations as required. The following lists common hpm configurations: - -``` -registry = https://hpm.harmonyos.com # Address of the hpm registry. This is mandatory for downloading bundles. -strictSsl = true # Enable strict SSL verification as HTTPS is used for connection. -http_proxy = http://your-proxy-server:port # Configure the HTTP proxy. -https_proxy = http://your-proxy-server:port # Configure the HTTPS proxy. -``` - -For details about **hpm-cli** commands, see [HPM Commands](bundles-standard-rules.md). - -## Python Environment - -Run the following commands to install Python later than 3.7: - -``` -sudo apt-get install python3.8 -sudo apt-get install python3-pip -sudo pip3 install setuptools -sudo pip3 install kconfiglib # Install kconfiglib 13.2.0 or later. -``` - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The preceding method is applicable to Hi3518 and Hi3516 platforms. For Hi3861, run the following commands to install the Python environment: ->``` ->sudo apt-get install python3.8 ->sudo apt-get install python3-pip ->sudo pip3 install setuptools ->sudo pip3 install kconfiglib # Install kconfiglib 13.2.0 or later. ->sudo pip3 install pycryptodome ->sudo pip3 install six --upgrade --ignore-installed six ->sudo pip3 install ecdsa ->``` - -If both Python2 and Python3 have been installed in the current system, run the following commands to set the default Python to Python3: - -``` -ll `which python` -rm /usr/bin/python -ln -s python3.8 /usr/bin/python -``` - -## File Packaging Tool - -Run the following commands to install the tool: - -``` -which mkfs.vfat # If mkfs.vfat is not found, run the following command: -sudo apt-get install dosfstools -which mcopy # If mcopy is not found, run the following command: -sudo apt-get install mtools -``` - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->Both Hi3518 and Hi3516 platforms require the file packaging tool. For Hi3861, the tool is not required. - -## SCons - -1. Start a Linux server. -2. Run the following command to install the SCons installation package: - - ``` - python3 -m pip install scons - ``` - -3. Run the following command to check whether SCons is successfully installed. If the installation is successful, the query result shown in [Figure 1](#fig235815252492) is displayed. - - ``` - scons -v - ``` - - **Figure 1** Successful installation \(SCons version requirement: 3.0.4 or later\) - ![](figure/successful-installation-(scons-version-requirement-3-0-4-or-later)-28.png "successful-installation-(scons-version-requirement-3-0-4-or-later)-28") - - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->SCons is required for the Hi3861 platform, but not for the Hi3518 or Hi3516 platform. - diff --git a/en/device-dev/bundles/bundles-demo-hpmdescription.md b/en/device-dev/bundles/bundles-demo-hpmdescription.md deleted file mode 100644 index da9a147ee4ba26955b73bb9ad8fec5e49b155c71..0000000000000000000000000000000000000000 --- a/en/device-dev/bundles/bundles-demo-hpmdescription.md +++ /dev/null @@ -1,6 +0,0 @@ -# Introduction - -HarmonyOS package manager \(hpm\) manages and distributes OpenHarmony bundles. It offers you a tool set to obtain and customize OpenHarmony source code and perform operations such as installation, building, packaging, and upgrade. - -This document describes how to use the hpm to install, build, and package OpenHarmony bundles. - diff --git a/en/device-dev/bundles/bundles-demo.md b/en/device-dev/bundles/bundles-demo.md deleted file mode 100644 index b4ba3900262b936883a748ddfd385b6464de26e0..0000000000000000000000000000000000000000 --- a/en/device-dev/bundles/bundles-demo.md +++ /dev/null @@ -1,9 +0,0 @@ -# HPM User Guide - -- **[Introduction](bundles-demo-hpmdescription.md)** - -- **[Configuring the Compilation Environment](bundles-demo-environment.md)** - -- **[Development Example](bundles-demo-devsample.md)** - - diff --git a/en/device-dev/bundles/bundles-guide-develop.md b/en/device-dev/bundles/bundles-guide-develop.md deleted file mode 100644 index efa3450cc1e0a4fb235bc000aba63421fe8e623c..0000000000000000000000000000000000000000 --- a/en/device-dev/bundles/bundles-guide-develop.md +++ /dev/null @@ -1,378 +0,0 @@ -# Developing Bundles - -You can use any of the following methods to develop OpenHarmony bundles: - -- Create a new bundle from scratch. -- Define an existing source code project as a bundle. - -## Creating a Bundle - -Generally, you can find commonly used bundles on the [HPM](https://hpm.harmonyos.com/#/en/home) website. If they cannot meet your requirements, you can develop a bundle on your own. - -You can publish bundles in the HPM repository if you like, so that your peers have an option to use them. - -Assume that you are planning to create a new bundle **my-bundle** in **D:/source**. Run the **hpm init** command to create the scaffold code for this bundle. For example, you can go to **D:/source** and run the following command: - -``` -hpm init -t default -d demo mybundle -``` - -The **'default'** template will be used to create a bundle named **mybundle** in the **demo** directory in **D:/source**. - -``` -demo -├── headers # Header file (example) -│ └── main.h -└── src # Source code (example) -│ └─ main.c -├── bundle.json # Metadata declaration file -└── LICENSE # License agreement -└── Makefile # Compilation description file (example) -└── README.md # Readme file - -``` - -Then, complete your coding based on service requirements and generate the build script. Finally, use **git** to commit your code \(including the **bundle.json** file\) to the code hosting repository, such as gitee. - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->``` ->hpm init -t {templatename} -d {dir} {name} ->``` ->- **-t \{templatename\}** indicates the template name. ->- **-d \{dir\}** indicates the path for storing the bundle to be created. ->- **name** indicates the name of the bundle to be created. - -The hpm provides a few default templates. More templates are available on the HPM server. You can run the **hpm search -t template** command to search for a template stored on the server. - -![](figure/en-us_image_0000001134127844.png) - -## Defining an Existing Project as a Bundle - -If you have a code project and need to distribute it on the HPM platform, run the following command in the current project directory, for example, **mybundle2**: - -``` -hpm init -``` - -1. Enter a bundle name \(**mybundle2** as an example\) and press **Enter**. -2. Enter the version and description. A **bundle.json** file will be generated in the current directory. -3. Open the** bundle.json** file as you like. - - ``` - $ hpm init - Your bundle will be created in directory ~\demo\mybundle2 - ? bundle name mybundel2 - ? version 1.0.0 - ... - Initialization finished. - ``` - - -1. Modify other information \(such as the author, code repository, code directory, command script, and dependent bundles\) in **bundle.json**. An example is shown below: - - ``` - { - "name": "mybundle2", - "version": "1.0.0", - "publishAs": "code-segment", - "dirs":{ - ".":["README.md"], - "src":["test.c"], - "header":["header/test.h" ], - "src/common":["src/common/foobar.txt"] - }, - "scripts": { - "build": "make -${args}" - }, - "dependencies": { - "@ohos/cjson": "^1.0.0", - "@ohos/foobar": "^1.2.0" - } - } - ``` - - -## Releasing the Bundle on the HPM Platform - -To release a bundle on the HPM platform, you need to obtain an account and create an organization \(or join an existing organization\). For details, see the online help on the [HPM](https://hpm.harmonyos.com/#/en/home) website. - -After that, generate a public key on the local PC based on your invitation code \(which can be obtained on the **My profile** page on the HPM website\), and configure the public key on the **My profile** page. - -``` -hpm config set loginUser {your-invitation-code} -hpm gen-keys -``` - -The generated file will be stored in **\~\\Users\\yourname\\.hpm\\key**. Copy the content in the public key file **publicKey\_your-account.pem** to the SSH public key on your **My profile** page. - -After finishing the preceding operations, you then have the permission to release bundles in your organization. - -In the directory where the bundle is located, run the following command to package and release the bundle: - -``` -hpm publish -``` - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- To avoid bundle name conflicts, name a released bundle in the format of **@org\_name/bundle\_name**. ->- Your account must also be a member of **org\_name** so that you can release or update bundles in the organization. ->- The released bundles take effect only after security and content reviews. - -## Referencing a Bundle - -Generally, when developing a project, you may need to reference other bundles in order to accelerate development of specific functions. Installing dependencies could be a good way. - -Go to the HPM website, search for bundles that meet your service requirements by keywords, and then introduce the bundles to your project. - -Run the following command in your bundle project. Make sure that the project directory contains the **bundle.json** file. - -``` -$ hpm install @scope/the_bundle -``` - -The referenced bundle will be installed under **ohos\_bundle** in the directory where your project is located. The directory structure is as follows: - -``` -project -├── ohos_bundle -│ └── scope -│ └─ the_bundle # <--- Referenced bundle -└── src -│ └─ main.c -├── bundle.json # Metadata declaration file -└── LICENSE -└── Makefile -└── README.md -``` - -Open the **bundle.json** file. You will see that the bundle has been introduced to the dependencies of your project. - -``` -{ -"dependencies": { - "@scope/the_bundle": "^1.0.0" - } -} -``` - -You can also edit the dependencies of multiple bundles in this file at a time. - -``` -{ -"dependencies": { - "@scope/the_bundle1": "^1.0.0", - "@scope/the_bundle2": "^2.0.0", - "@scope/the_bundle3": "^3.0.0", - "@scope/the_bundle4": "^1.1.0" - } -} -``` - -Run the **hpm install** command again to download and install all bundles that have not been installed. - -## Installing a Bundle Globally - -If the referenced bundle is one shared by multiple projects, for example, the compiler toolchain, you can install it globally. - -Run the following command in your bundle project. Make sure that the project directory contains the **bundle.json** file. - -``` -$ hpm install -g @scope/the_tool -``` - -The referenced bundle will be installed in the directory specified by the **globalRepo** parameter of the **hpm config** command. - -``` -~\.hpm\global -│ └── scope -│ └─ the_tool # <--- Referenced bundle -``` - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- For a bundle installed in a project, you can reference it using the environment variable **DEP\_SCOPE\_bundle\_name** when running the hpm compilation command. ->For example, after you run **hpm i @opensource/gn** to install a bundle, you can edit the build script in the **bundle.json** file as follows: ->``` ->"scripts": { -> "build": "${DEP_OPENSOURCE_gn}/gn --version" -> }, ->``` ->Then, you can run the **hpm build** command to call GN functions. ->- For a globally installed bundle, you can directly call the bundle using an environment variable or reference the bundle using the **$\{key\}/tool\_name** parameter when running the **hpm config set key value** command. For example: ->``` ->hpm i -g @ohos/opensource/gn ->hpm config BUILD_SYS_GN ~/.hpm/global/ohos_bundles/opensource/gn ->``` ->You can edit the build script in the **bundle.json** file as follows: ->``` ->"scripts": { -> "build": "${BUILD_SYS_GN}/gn --version" -> }, ->``` ->Then, you can run the **hpm build** command to call GN functions. - -## Compiling a Bundle - -If the bundle code can be independently compiled once you finish coding, you can configure build tools and scripts to generate binary files. - -The hpm supports command integration so that you can select any build tool \(such as **make**, **gcc**, and **gn**\) suitable for your project. You only need to define the **build** command in the **scripts** in the **bundle.json** file of your project, and then you run the hpm command **build** to perform building. - -## Defining the Build Script - -This section uses how to build an executable file **helloworld** in the **app** directory as an example. - -``` -app -├── BUILD.gn -├── include -│ └── helloworld.h -└── src - └── helloworld.c -``` - -Create a **BUILD.gn** file in the same directory as **helloworld.c**. - -``` -touch BUILD.gn -vim BUILD.gn -``` - -The following is an example of **BUILD.gn** for your reference: - -``` -executable("hello_world") { - sources = [ - "src/helloworld.c" - ] - - include_dirs = [ - "include" - ] -} -``` - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->- **executable** is a built-in template of **gn**. You can run the **gn help executable** command to view how to use this template. ->- **sources** represents the source code path, and **include\_dirs** represents the header file path. - -## Executing the Build Script - -Run the following command: - -``` -hpm build -``` - -After all building operations are complete, the message "build succeed" is displayed. You need to check the building result. - -![](figure/en-us_image_0000001051770876.png) - -## Defining a Distribution - -This process states the dependent bundles and how to compile and link the bundles to generate image files. - -This section uses the hb compilation framework as an example. - -## Defining Scripts - -An example definition in the **bundle.json** file is as follows: - -\{ - -"name": "@your/dist\_name", - -"version": "2.2.0", - -"publishAs": "distribution", - -"description": "describe it", - -"scripts": \{ - -"config\_hb": "hb set -root $DEP\_BUNDLE\_BASE", - -"dist": "PATH=/root/.local/bin:$\{DEP\_OHOS\_gn\}:$\{DEP\_OHOS\_ninja\}/ninja:$\{DEP\_OHOS\_llvm\}/llvm/bin:$\{DEP\_OHOS\_hc\_gen\}/hc-gen:$\{PATH\} && ./scripts/dist.sh" - -\}, - -"envs": \{ - -"debug": false - -\}, - -"dirs": \{ - -"scripts": "scripts/\*" - -\}, - -"dependencies": \{ - -"@ohos/build\_lite": "2.2.0", - -"@ohos/gn": "1.1.1", - -"@ohos/llvm": "1.1.1", - -"@ohos/hc\_gen": "1.1.0", - -"@ohos/ninja": "1.1.0", - -... - -\}, - -"ohos": \{ - -"os": "2.2-Beta", - -"board": "hi3516", - -"kernel": "liteos-a" - -\}, - -"keywords": \[ "hispark", "hi3516" \], - -"repository": "https://gitee.com/openharmony/your-project", - -"license": "Apache V2" - -\} - -## Building a Distribution - -Run the following command in the root directory of the current distribution: - -``` -hpm dist -``` - -The **hpm-cli** tool automatically starts compilation. After the compilation is complete, an image file will be generated, as shown below: - -``` -out -|-xxdist.img -|-xx.file -``` - -Burning - -The build result of the distribution can be burnt into devices, for example, by using the **hiburn** tool. You need to configure burning parameters in the **bundle.json** file of the distribution. - -``` -"scripts": { - "flash": "{$DEP_HIBURN}/hiburn" -}, -``` - -Set the path of the **hiburn** tool and set burning parameters. For details, see the **hiburn** tool guide. - -``` -hpm config set DEP_HIBURN {hiburn_path} -hpm run flash -``` - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The preceding example describes only how to define the **bundle.json** file. The burning tool is subject to the actual development board. - diff --git a/en/device-dev/bundles/bundles-guide-overview.md b/en/device-dev/bundles/bundles-guide-overview.md deleted file mode 100644 index 0b2ed40a84f3725f8c611e0944998ee8916e14be..0000000000000000000000000000000000000000 --- a/en/device-dev/bundles/bundles-guide-overview.md +++ /dev/null @@ -1,39 +0,0 @@ -# Overview - - -This section describes the bundle-specific concepts in HarmonyOS. It uses an example to step you through how to create, develop, build, release, and install a bundle using the **hpm-cli** tool. - -## Bundle - -A bundle is a term used in HarmonyOS to indicate a distribution. A bundle is equivalent to a package and it usually contains the following contents: - -- Distributed binary file \(binary type\) -- Distributed source code file \(source code/code snippet type\) -- Build script \(distribution type\) -- Bundle description files: - - **bundle.json**: metadata declaration \(name, version, dependency, etc.\) - - **LICENSE**: license agreement - - **README.md**: readme file - - **CHANGELOG.md**: change log \(optional\) - - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->Bundles can be classified into the following types: binary, source code, code snippet, template, plug-in, distribution, and so on. A bundle can depend on other bundles. The dependency relationship can be represented by a directed acyclic graph \(DAG\). - -After you release a bundle on the [HPM](https://hpm.harmonyos.com/#/en/home) platform, other developers can download, install, and use the bundle through the HarmonyOS Package Manager \(hpm\). - -A bundle must be uniquely named in the format **@scope/name** in the namespace. Independent evolution is supported for each bundle. - -## Distribution - -A distribution is a complete HarmonyOS release that integrates various bundles, including drivers, kernels, frameworks, and applications. A distribution can also be distributed on the [HPM](https://hpm.harmonyos.com/#/en/home) platform through bundles. - ->![](../public_sys-resources/icon-note.gif) **NOTE:** ->The metadata of a distribution describes only the dependent bundles and build script compilation methods. It does not cover binary images of the distribution. When downloading a distribution, you also need to download the dependent bundles. You can obtain the system image file for burning only after finishing installation and compilation. ->A distribution is inheritable. Specifically, you can add bundles to or delete bundles from an existing distribution to create your own distribution. - -**Figure 1** Relationship between bundles and a distribution - - -![](figure/bundle-distribution.png) - diff --git a/en/device-dev/bundles/bundles-guide-prepare.md b/en/device-dev/bundles/bundles-guide-prepare.md deleted file mode 100644 index a0ee4d7714a74b64ecdc5e5b31cc217ff30ddcce..0000000000000000000000000000000000000000 --- a/en/device-dev/bundles/bundles-guide-prepare.md +++ /dev/null @@ -1,69 +0,0 @@ -# Installing hpm-cli Tool - -To develop a bundle, you first need to install the HarmonyOS Package Manager \(hpm\), a cross-platform command line tool developed based on Node.js. To run the hpm, you need to install Node.js, and then install the hpm using the Node Package Manager \(npm\). - -## Installing Node.js and hpm - -1. Install **Node.js**. - - Download **Node.js** from its official website and install it on your local PC. - - You are advised to install [Node.js](https://nodejs.org/) 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\). - -2. Install the **hpm-cli** tool using **npm** delivered with **Node.js**. Run the following command: - - ``` - npm install -g @ohos/hpm-cli - ``` - -3. Run the following command to check whether the installation is successful. If an hpm version is displayed, the installation is successful. - - ``` - hpm -V or hpm --version - ``` - -4. \(Optional\) Run the following command to upgrade the hpm version if needed: - - ``` - npm update -g @ohos/hpm-cli - ``` - - -## \(Optional\) Configuring hpm - -After the **hpm-cli** tool is installed, run the following command to view the hpm configuration if you need to modify the configuration information, such as proxy and shell: - -``` -hpm config -``` - -Default hpm configurations are displayed upon successful command execution. You can modify the default configurations as required. The following lists common hpm configurations: - -``` -registry = https://hpm.harmonyos.com -### login Settings -# loginUser = invitation_code - -#### Path Settings -shellPath = C:\WINDOWS\System32\cmd.exe -# shellPath = C:\Program Files\Git\bin\sh.exe -# globalRepo = C:\Users\username\.hpm\global - -#### Network Settings -# no_proxy = *.server.com -# http_proxy = http://user:pwd@proxy_server:port -# https_proxy = http://user:pwd@proxy_server:port -# strictSsl = true - -#### Other Settings -# privateSupport = true|false -# ignoreBundles = @ohos/llvm,@ohos/gn, -# OSPlatform = Auto|linux|darwin|win32 -``` - -For details about **hpm-cli** commands, see [HPM Commands](bundles-guide-overview.md). - -## Downloading OpenHarmony Code - -For details, see [Source Code Acquisition](../get-code/sourcecode-acquire.md). - diff --git a/en/device-dev/bundles/bundles-guide.md b/en/device-dev/bundles/bundles-guide.md deleted file mode 100644 index 6325fe827448e69e2bfaaaaf788a110025484456..0000000000000000000000000000000000000000 --- a/en/device-dev/bundles/bundles-guide.md +++ /dev/null @@ -1,9 +0,0 @@ -# HPM Bundle Development Guidelines - -- **[Overview](bundles-guide-overview.md)** - -- **[Installing hpm-cli Tool](bundles-guide-prepare.md)** - -- **[Developing Bundles](bundles-guide-develop.md)** - - diff --git a/en/device-dev/bundles/bundles-standard-rules.md b/en/device-dev/bundles/bundles-standard-rules.md deleted file mode 100644 index edd766e0bde314cd32406c1ea32c47b133f835a4..0000000000000000000000000000000000000000 --- a/en/device-dev/bundles/bundles-standard-rules.md +++ /dev/null @@ -1,528 +0,0 @@ -# HPM Bundle Development Specifications - -## Overview - -This document describes the basic concepts of a bundle and how to define it in compliance with specifications. - -### Definition - -OpenHarmony software is developed on a per-bundle basis. In terms of the operating system, all software running on OpenHarmony are bundles. Generally, bundles are classified into the following types based on their application scopes: - -- Board-level bundles: device hardware-specific bundles, such as **board**, **arch**, and **mcu** -- System-level bundles: a set of bundles with independent features, such as the kernel, file system, and framework -- Application-level bundles: applications that provide services to users, such as **wifi\_iot** and **ip\_camera** - -Bundles are designed for reuse purposes. Any reusable modules can be defined as bundles. They are classified into the following types based on their forms: - -- Source code -- Binary system -- Code snippet -- Distribution - -### Bundle Division Rules - -In principle, bundles should be grouped at a fine-grained granularity as much as possible to achieve maximum reuse. The following factors are taken into account regarding bundle division: - -- Independence: Bundles provide relatively independent features and can be independently built. Each bundle is capable of providing its own APIs and services for external systems. -- Coupling: If a bundle must depend on another bundle to provide services, they can be coupled to one bundle. -- Correlation: If a group of bundles jointly implement a feature, and if other bundles never depend on them, the group of bundles can be combined into one bundle. - -### Bundle Dependency - -A bundle dependency can be mandatory or optional. - -- Mandatory dependency: If bundle A must depend on bundle B to implement a feature \(the APIs or services specific to bundle B must be invoked\), bundle B is a mandatory dependency of bundle A. -- Optional dependency: If bundle C or bundle D is required for bundle A to implement a feature and bundle C and bundle D are interchangeable, bundle C and bundle D are optional dependencies of bundle A. - -## Bundle Composition - -A bundle contains the following: - -- **src** directory for storing code files or code library of the bundle -- **ohos\_bundles** folder for storing dependent bundles \(It is automatically generated during bundle installation, without the need to submit to the code library.\) -- **README.md** file for describing the bundle -- **bundle.json** file for declaring metadata of the bundle -- **LICENSE** file for open-source code - - ``` - my-bundle - |_ohos_bundles - |_src - |_bundle.json - |_README.md - |_LICENSE - ``` - - -### Code Files - -Bundle code files are the same as those in a common code directory. The only difference lies in the open APIs \(declared in header files\) of a bundle, which are likely to be referenced by other bundles and need to be declared in **dirs** of **bundle.json**. - -### README File - -**README.md** is a bundle self-description file using the markdown syntax. For details, see [Syntax Reference](https://www.markdownguide.org/getting-started/). - -To help you easily find and use the desired bundle on the HarmonyOS Package Manager \(HPM\) platform, a **README** file is provided in the root directory of each bundle. - -The **README** file may include instructions on how to install, configure, and use the instance code in the bundle, as well as any other information helpful to you. - -The **README** file is available in the bundle details page of the HPM platform. - -### Metadata Description File - -The **bundle.json** file describes the metadata of a bundle. Each bundle has its own **bundle.json** file. - -``` -{ - "name": "@myorg/demo-bundle", - "version": "1.0.0", - "license": "MIT", - "description": "bundle description", - "keywords": ["hos"], - "tags": ["applications", "drivers"], - "author": {"name":"","email":"","url":""}, - "contributors":[{"name":"","email":"","url":""},{"name":"","email":"","url":""}], - "homepage": "http://www.foo.bar.com", - "repository": "https://git@gitee.com:foo/bar.git", - "publishAs": "code-segment", - "segment":{ - "destPath":"/the/dest/path" - }, - "dirs": { - "src": ["src/**/*.c"], - "headers": ["headers/**/*.h"], - "bin": ["bin/**/*.o"] - }, - "scripts": { - "build": "make" - }, - "envs": {}, - "ohos": { - "os": "2.0.0", - "board": "hi3516", - "kernel": "liteos-a" - }, - "rom": "10240", - "ram": "1024", - "dependencies": { - "@myorg/net":"1.0.0" - } -} -``` - -Each **bundle.json** file has the following fields: - -- **name**: a bundle name, which starts with @ and is separated by /, for example, **@myorg/mybundle** - -- **version**: a bundle version number, for example, 1.0.0. The version number must comply with the Semantic Versioning Specification \(SemVer\) standards. - -- **description**: a brief description of a bundle -- **dependencies**: bundles on which this bundle depends. - -- **envs**: parameters required for bundle compilation, including global parameters and dependency parameters. - -- **scripts**: commands executable to a bundle, such as commands for compiling, building, testing, and burning - -- **publishAs**: bundle publishing type, which can be **source**, **binary**, **distribution**, or **code-segment** - -- **segment**: destination path of the code-segment bundle. That is, the destination path of the files contained in the bundle package after the bundle is installed. -- **dirs**: directory structure \(such as the header file\) generated for publishing - -- **ram&rom**: statistical information about the estimated read-only memory \(ROM\) and random access memory \(RAM\) usage -- **ohos**: mappings among OpenHarmony versions, development boards, and kernels, separated by commas \(,\). -- Extended information: author, home page, code repository, license, tags, and keywords -- **base** \(only for a distribution\): a base distribution which others inherit from. - -## Bundle Management - -### Dependency - -A basic **bundle.json** file needs to be enriched by bundle dependencies to implement more complex features. Bundle names and version numbers should be defined in the **dependencies** field of **bundle.json**. - -``` -{ - "name": "my-bundle", - "version": "1.0.0", - "dependencies": { - "net": "1.0.0" - } -} -``` - -In the preceding example, the **my-bundle** bundle depends on the **net 1.0.0** bundle. After you globally install the hpm-cli tool, run the following command to obtain bundle dependencies from the remote repository: - -``` -hpm install -``` - -Bundle dependencies are then stored in the **ohos\_bundles** folder in the root directory of the current bundle. A tree structure illustrating the bundle and its dependencies will be generated. You need to run the following command in the root directory of the bundle: - -``` -username@server MINGW64 /f/showcase/demo/demo -$ hpm list -+--demo@1.0.0 -| +--@example/media@1.0.2 -| +--@demo/sport_hi3518ev300_liteos_a@1.0.0 -| | +--@demo/app@4.0.1 -| | | +--@demo/build@4.0.1 -| | | +--@demo/arm_harmonyeabi_gcc@4.0.0 -| | +--@demo/liteos_a@4.0.0 -| | | +--@demo/third_party_fatfs@4.0.0 -| | | +--@demo/arm_harmonyeabi_gcc@4.0.0 -| | +--@demo/init@4.0.0 -| | +--@demo/dist_tools@4.0.0 -``` - -Alternatively, you can run the following command to view the dependencies of the current bundle in a visualized way: - -``` -hpm ui -``` - -A web service is started on the local host \(by default, the browser is open and the project page is displayed\). Click the project dependency icon on the sidebar. The list of dependent bundles is displayed. Click the button on the right to switch to the tree view. The bundle dependencies are displayed as shown in the following figure. - -**Figure 1** Bundle dependencies - - -![](figure/en-us_image_0000001173313501.png) - -### HPM Command Reference - -You can use the hpm-cli tool to manage the lifecycle of a bundle. The following table describes available HPM commands. \(You can run the **hpm -h** command to get the command details\). - -**Table 1** HPM commands - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Function

-

Command Line

-

Description

-

Querying version information

-

hpm -V or hpm --version

-

Displays the hpm-cli version number.

-

Querying help information

-

hpm -h or hpm --version

-

Displays the command list and help information.

-

hpm -h

-

Displays command help information.

-

Creating a project

-

-

hpm init bundle

-

Create a bundle project.

-

hpm init -t template

-

Creates a scaffolding project from a template.

-

Installing bundles

-

-

hpm install or hpm i

-

Installs dependent bundles in the bundle.json file.

-

hpm install bundle@version

-

Installs bundles of a specified version.

-

Uninstalling bundles

-

-

hpm uninstall bundle

-

Uninstalls dependent bundles.

-

hpm remove or hpm rm bundlename

-

Removes dependent bundles.

-

Viewing information

-

-

hpm list or hpm ls

-

Displays the bundle tree of available bundles and distributions.

-

hpm dependencies

-

Generates the dependency relationship data of a bundle or distribution. (This command is also integrated in the HPM UI to display the bundle dependencies intuitively.)

-

Searching for bundles

-

hpm search name

-

Searches for bundles. --json is used to specify the search result in JSON format, and -type is used to set the target type, which can be bundle, distribution, or code-segment.

-

Setting HPM configuration items

-

hpm config set key value

-

Sets configuration items, such as the server address and network proxy.

-

hpm config delete key

-

Deletes configurations.

-

Updating bundle versions

-

-

hpm update

-

Updates the versions of dependent bundles.

-

hpm check-update

-

Checks whether version updates are available to dependent bundles.

-

Building

-

-

hpm build

-

Builds a bundle or distribution.

-

hpm dist

-

Builds a distribution. The build depends on the dist script in scripts of bundle.json.

-

Packing

-

hpm pack

-

Packs dependencies of local bundles.

-

Burning

-

hpm run flash

-

Burns the firmware. The firmware burning depends on the flash script in scripts of bundle.json.

-

Publishing

-

hpm publish

-

Publishes a bundle, which must be unique in the repository and has a unique version. (An account is required for login.)

-

Running extended commands

-

hpm run

-

Runs the commands in scripts defined in bundle.json. Multiple commands can be executed at a time by using &&.

-

Decompressing

-

hpm extract

-

Decompresses files in zip, tar, tgz, or .tar.gz format.

-

Restarting GUI

-

hpm ui

-

Starts the HPM UI locally. You can use the -p parameter to specify a port. On the Windows platform, the default browser is used to open the HPM UI.

-

Changing language

-

hpm lang

-

Alternates between Chinese and English on the CLI and UI.

-

Converting to HPM format

-

hpm x2h

-

Converts a Maven or NPM package to an HPM package and publishes it to the HPM.

-

Code segment restoration or cleanup

-

hpm code clean|restore

-

Clears or restores the dependent code segment (code-segment). That is, copy or delete the code segment based on segment.destPath.

-

Generating a key

-

hpm gen-keys

-

Generates a public-private key pair and configures the public key on the HPM server, which enables password-free hpm-cli login for bundle publishing.

-

Generating third-party open source notice

-

hpm gen-notice

-

Generates a file providing the notice on third-party open source by combining the description of each bundle.

-
- -## Bundle Version - -### Version Number Naming Specifications - -Each version name allows only lowercase letters, which can be separated by hyphens \(-\) or underscores \(\_\). For example, **bundle** and **my\_bundle** are allowed. - -A bundle version number is in the format of _major version number_._minor version number_._revision version number_ or _major version number_._minor version number_._revision version number_-_pre-release version number_, for example, **1.0.0** and **1.0.0-beta**. For details, see [https://semver.org](https://semver.org/). - -### Version Publishing - -You should upload bundles to the remote repository so that your peers have an option to use them. You can run the following command to upload the bundles: - -``` -hpm publish -``` - -After this command is executed, the system checks the bundle dependencies and downloads the missing dependencies. If the bundles you uploaded are in binary, the system compiles the entire bundle, generates a binary file, packs the file, and uploads it. If the bundles you uploaded are in another format, the system packs the bundle file in compliance with the defined packing rules and then uploads the file. - -Note: To publish a bundle, you need an HPM account for login. After logging in to the HPM platform, register with an organization and apply for authentication. After successful authentication, you will have the permission to publish the bundle. - -## Distribution - -A distribution refers to an image file of an executable OpenHarmony solution composed of a group of bundles. It contains many dependent bundles and provides scripts to illustrate how to compile and link these bundles. - -Generally, a distribution does not require code but contains only the **bundle.json** description \(**publishAs** set to **distribution**\) and some compilation scripts. - -As system-provided environment variables are required during distribution compiling, run the **dist** command in **scripts**. - -``` -{ - "publishAs":"distribution", - "scripts": { - "dist": "script compile command" - } -} -``` - -Run the following command: - -``` -hpm dist -``` - -As it is rather complex to redefine the functionality of a distribution, OpenHarmony allows inheritance from a distribution so that you can make a tailored distribution based on the existing functionality. To inherit from a distribution, you need to define the **base** field in **bundle.json**. - -``` -{ - "base": { - "name": "dist_wifi_iot", - "version": "1.0.0" - } -} -``` - -In this example, the current bundle inherits from the **Bundledist-wifi-iot 1.0.0** bundle of the distribution. - -Each distribution consists of many dependent bundles, which are represented by the **dependencies** field in **bundle.json**. Some dependencies are mandatory, and others can be added or removed required. In the **bundle.json** file, bundle names prefixed with a question mark \(?\) represent optional dependent bundles. If you want to inherit from a distribution involving such bundles, you can remove them and then add other bundles. - -``` -{ - "dependencies": { - "?my_bundle": "1.0.0" - } -} -``` - -In this example, **my\_bundle** is an optional dependent bundle that can be removed by using the keyword **excludes**. - -``` -{ - "excludes": [ "my_bundle" ] -} -``` - -The removed **my-bundle** will not be involved in the build process. If you forcibly remove mandatory dependent bundles, an error message will be displayed. - -## Environment Variables - -During bundle compilation, system-provided environment variables are required to define the output and link the required binary files. These variables are injected into the context for executing scripts based on service requirements. Therefore, their values can be directly obtained from the scripts. The following environment variables are available: - -Global variables are defined by the **envs** attribute in **bundle.json**. All dependent bundles can obtain the values of global variables. - -``` -{ - "envs": { - "compileEnv": "arm" - } -} -``` - -Different parameters can be passed to bundles when introducing dependencies so that the compilation of dependent bundles can meet the requirements of the current bundle. The parameters defined in the dependencies can be obtained from the context for executing the corresponding scripts. - -``` -{ - "dependencies": { - "my-bundle": { - "version": "1.0.0", - "mode": "debug" - } - } -} -``` - -When linking to a binary file, the bundle needs to know the file path regarding the dependencies. Therefore, the path \(as an environment variable\) is passed to the bundle for compiling. - -The passed environment variable is in **DEP\__BundleName_** format, where **BundleName** indicates the name of the dependent bundle, for example, **DEP\_first\_bundle**. - -Tags can be defined to group dependent bundles. You can obtain the path of a group of dependent bundles based on their tag. A tag starts with a number sign \(\#\) and is defined as follows: - -``` -{ - "dependencies": { - "#tool": { - "first-bundle": "1.0.0", - "second-bundle": "1.0.0" - }, - "#drivers": { - "xx-bundle": "1.0.0", - "yy-bundle": "1.0.0" - } - } -} -``` - -There are two fixed environment variables: - -- **DEP\_OHOS\_BUNDLES**: path of the **ohos\_bundles** folder -- **DEP\_BUNDLE\_BASE**: path of the outermost bundle - diff --git a/en/device-dev/bundles/bundles.md b/en/device-dev/bundles/bundles.md deleted file mode 100644 index 668b3d43e0ec27085952971fdd4512d53ba763e3..0000000000000000000000000000000000000000 --- a/en/device-dev/bundles/bundles.md +++ /dev/null @@ -1,9 +0,0 @@ -# Bundle Development - -- **[Bundle Development Specifications](bundles-standard-rules.md)** - -- **[Development Guidelines](bundles-guide.md)** - -- **[HPM User Guide](bundles-demo.md)** - - diff --git a/en/device-dev/bundles/figure/3516dv300.png b/en/device-dev/bundles/figure/3516dv300.png deleted file mode 100644 index c4636401a20e37794d8ec28dc173e9308b2b72db..0000000000000000000000000000000000000000 Binary files a/en/device-dev/bundles/figure/3516dv300.png and /dev/null differ diff --git a/en/device-dev/bundles/figure/bundle-distribution.png b/en/device-dev/bundles/figure/bundle-distribution.png deleted file mode 100644 index 08d9dccdd2371b02f2732d0e4eb4ad9871dccdbe..0000000000000000000000000000000000000000 Binary files a/en/device-dev/bundles/figure/bundle-distribution.png and /dev/null differ diff --git a/en/device-dev/bundles/figure/en-us_image_0000001134127844.png b/en/device-dev/bundles/figure/en-us_image_0000001134127844.png deleted file mode 100644 index 8988fc2cf8e2d7218a5812764e0022226fec4d53..0000000000000000000000000000000000000000 Binary files a/en/device-dev/bundles/figure/en-us_image_0000001134127844.png and /dev/null differ diff --git a/en/device-dev/bundles/figure/en-us_image_0000001173313501.png b/en/device-dev/bundles/figure/en-us_image_0000001173313501.png deleted file mode 100644 index 52f943be7f91caa887bff689f6c37040858fa8ce..0000000000000000000000000000000000000000 Binary files a/en/device-dev/bundles/figure/en-us_image_0000001173313501.png and /dev/null differ diff --git a/en/device-dev/bundles/figure/successful-installation-(scons-version-requirement-3-0-4-or-later)-28.png b/en/device-dev/bundles/figure/successful-installation-(scons-version-requirement-3-0-4-or-later)-28.png deleted file mode 100644 index e66ca6ffae9aec5f4f5b97ceccf2e37792e95f18..0000000000000000000000000000000000000000 Binary files a/en/device-dev/bundles/figure/successful-installation-(scons-version-requirement-3-0-4-or-later)-28.png and /dev/null differ diff --git a/zh-cn/device-dev/bundles/figures/zh-cn_image_0000001195369804.png b/en/device-dev/bundles/figures/en-us_image_0000001195369804.png similarity index 100% rename from zh-cn/device-dev/bundles/figures/zh-cn_image_0000001195369804.png rename to en/device-dev/bundles/figures/en-us_image_0000001195369804.png diff --git a/en/device-dev/bundles/figures/en-us_image_0000001217486680.png b/en/device-dev/bundles/figures/en-us_image_0000001217486680.png new file mode 100644 index 0000000000000000000000000000000000000000..3e258d86dfd084187119825d8bce2c62536fea26 Binary files /dev/null and b/en/device-dev/bundles/figures/en-us_image_0000001217486680.png differ diff --git a/en/device-dev/bundles/figures/en-us_image_0000001240409717.png b/en/device-dev/bundles/figures/en-us_image_0000001240409717.png new file mode 100644 index 0000000000000000000000000000000000000000..56e46425e9c54866e9fb737257c5fb7a35204284 Binary files /dev/null and b/en/device-dev/bundles/figures/en-us_image_0000001240409717.png differ diff --git a/en/device-dev/bundles/figure/en-us_image_0000001051770876.png b/en/device-dev/bundles/figures/en-us_image_0000001262166533.png similarity index 100% rename from en/device-dev/bundles/figure/en-us_image_0000001051770876.png rename to en/device-dev/bundles/figures/en-us_image_0000001262166533.png diff --git a/en/device-dev/bundles/hpm-part-about.md b/en/device-dev/bundles/hpm-part-about.md new file mode 100644 index 0000000000000000000000000000000000000000..29a89964a1e66ee36f61d7b4f569b2008de5a16d --- /dev/null +++ b/en/device-dev/bundles/hpm-part-about.md @@ -0,0 +1,73 @@ +# HPM Part Overview + + +This section describes the basic concepts related to HPM Part in OpenHarmony. + + +## Introduction to HPM Part + + +### HPM Part Category + +An HPM Part is used as a distribution unit in OpenHarmony. There are two types of HPM Parts: + +- **Part/Module-level HPM Part**: used to achieve module or part reusability. The distributed content can be source code or binary files. Generally, such an HPM Part corresponds to a code repository and is a release of the code repository. + +- **Distribution-level HPM Part**: used to describe an OS distribution. It consists of a list of dependent parts and scripts for building the distribution. The distribution contains various components (such as the driver, kernel, framework, and applications) of a complete OS. The image generated after the build can be used for burning. + + +### HPM Part Composition + +An HPM Part consists of two types of files: description file and content file. + +The table below lists the description files. + + **Table 1** Description files + +| File Name| Description | Mandatory | +| -------- | -------- | -------- | +| bundle.json | Metadata declaration file| Yes| +| README.md | Readme file| Yes| +| LICENSE | License file| Yes| +| CHANGEME.md | Change log file| No| + +The content files can be any of the following: + +- Binary file of the distributed part + +- Source code file of the distributed part + +- Build script file + + + **Figure 1** Relationship between the part/module-level HPM Part and distribution-level HPM Part + + ![en-us_image_0000001195369804](figures/en-us_image_0000001195369804.png) + + +## Introduction to HPM + +OpenHarmony Package Manager (HPM) is an open collaboration platform that connects consumers and providers. HPM Parts are objects managed by HPM. + +Through this platform, the provider can publish HPM Parts and the consumer can download and use HPM Parts. + +- The provider declares the attributes of an HPM Part and publishes it to the platform. + +- The consumer declares the dependencies in the HPM Part of the specified version to obtain the required resources. + +The HPM platform matches the requirements of the provider and consumer. + + + **Figure 2** HPM functions + + ![en-us_image_0000001240409717](figures/en-us_image_0000001240409717.png) + +**HPM consists of the following:** + +- **hpm-cli: a cross-platform command line tool released in [@ohos/hpm-cli](https://www.npmjs.com/package/@ohos/hpm-cli)** + + The hpm-cli tool offers a series of commands for creating, building, installing, packing, running, and publishing HPM Parts. You can use these commands to manage the lifecycle of the HPM Parts. + +- **[DevEco Marketplace](https://repo.harmonyos.com): a resource repository on the server** + + On [DevEco Marketplace](https://repo.harmonyos.com), you can register, store, and search for HPM Parts by category. Each HPM Part has a page providing access to its readme file, dependencies, historical versions, change history, license, download volume, and source code repository address. You can publish HPM Parts to this resource repository. diff --git a/en/device-dev/bundles/hpm-part-development.md b/en/device-dev/bundles/hpm-part-development.md new file mode 100644 index 0000000000000000000000000000000000000000..b00b0739c06c29fb4b784fbaa9bed53c5ad0ee52 --- /dev/null +++ b/en/device-dev/bundles/hpm-part-development.md @@ -0,0 +1,442 @@ +# HPM Part Development + + +## HPM Part Development Overview + +You can search for common development resources on [DevEco Marketplace](https://repo.harmonyos.com) and import required resources to your projects through dependencies. If you cannot find the desired resources there, develop the resources on your own and publish them in the form of an HPM Part. To develop HPM Parts, install the hpm-cli tool first. + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> You are advised to perform the following operations on Ubuntu 18.04 or later. + + +## Installing hpm-cli + +The hpm-cli tool is developed based on Node.js. Therefore, you must install Node.js and then use npm to install hpm-cli. + + +### Installing Node.js and hpm-cli + +1. Install Node.js. + Download Node.js from its official website and install it on your local PC. + + You are advised to install the latest LTS version (not earlier than 12.x) of [Node.js](https://nodejs.org/). + +2. Install the hpm-cli tool using **npm** delivered with **Node.js**. Run the following command: + + ``` + npm install -g @ohos/hpm-cli + ``` + +3. Run the following command to check whether the installation is successful. If a hpm version is displayed, the installation is successful. + + ``` + hpm -V or hpm --version + ``` + +4. (Optional) Run the following command to update the hpm version if needed: + + ``` + npm update -g @ohos/hpm-cli + ``` + + +### (Optional) Configuring hpm-cli + +After hpm-cli is installed, run the following command to view the hpm configuration: + + +``` +hpm config +``` + + The default hpm configuration is displayed upon successful command execution. You can modify the default configuration as required. The following lists the common hpm configuration: + +``` +registry = https://hpm.harmonyos.com +### login Settings +# loginUser = invitation_code + +#### Path Settings +shellPath = C:\WINDOWS\System32\cmd.exe +# shellPath = C:\Program Files\Git\bin\sh.exe +# globalRepo = C:\Users\username\.hpm\global + +#### Network Settings +# no_proxy = *.server.com +# http_proxy = http://user:pwd@proxy_server:port +# https_proxy = http://user:pwd@proxy_server:port +# strictSsl = true + +#### Other Settings +# privateSupport = true|false +# ignoreBundles = @ohos/llvm,@ohos/gn, +# OSPlatform = Auto|linux|darwin|win32 +``` + + +## Creating an HPM Part + +You can create an HPM Part by using a template or define an existing project as an HPM Part. + + +### Creating an HPM Part Using a Template + +1. Run the following command to create a directory: + + ``` + hpm init -t default mybundle + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** + > -In the preceding command, **default** indicates that the **default** template is used. You can use another template such as **simple** or **dist**. + + The generated directory structure is as follows: + + ``` + / + ├── headers # Header file (example) + │ └── main.h + └── src # Source code (example) + │ └─ main.c + ├── bundle.json # Metadata declaration file + └── LICENSE # License + └── Makefile # Build description file (example) + └── README.md # Readme file + + ``` + +2. Write the code and build script of the HPM Part. + + ``` + hpm init -t {templatename} -d {dir} {name} + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** + > - -**t {templatename}** indicates the template name. + > + > - -**d {dir}** indicates the path for storing the HPM Part to be created. + > + > - **name** indicates the name of the HPM Part to be created. + +The hpm-cli tool provides a few default templates. More templates are available on [DevEco Marketplace](https://repo.harmonyos.com). You can run the **hpm search -t template** command to search for a template stored on [DevEco Marketplace](https://repo.harmonyos.com). + +![zh-cn_image_0000001217486680](figures/zh-cn_image_0000001217486680.png) + + +### Defining an Existing Project as an HPM Part + +If you have a code project and need to distribute it on the HPM platform, run the following command in the project directory, for example, **mybundle2**: + + +``` +hpm init +``` + +1. Enter an HPM Part name (**mybundle2** for example) and press **Enter**. + +2. Enter the version and description. A **bundle.json** file will be generated in the current directory. + +3. Open the **bundle.json** file. + + ``` + $ hpm init + Your bundle will be created in directory ~\demo\mybundle2 + ? bundle name mybundle2 + ? version 1.0.0 + ... + Initialization finished. + ``` + +4. Modify other information (such as the author, code repository, code directories, scripts, and dependencies) in **bundle.json**. An example is shown below: + + ``` + { + "name": "mybundle2", + "version": "1.0.0", + "publishAs": "code-segment", + "dirs":{ + ".":["README.md"], + "src":["test.c"], + "header":["header/test.h" ], + "src/common":["src/common/foobar.txt"] + }, + "scripts": { + "build": "make -${args}" + }, + "dependencies": { + "@ohos/cjson": "^1.0.0", + "@ohos/foobar": "^1.2.0" + } + } + ``` + + +## Defining a Distribution + +In the distribution metadata file, define the dependent HPM Parts and how to build and link them to generate image files. + +The following uses the **bundle.json** file as an example. In this example, the **dist** command uses the **hb** framework. + + +``` +{ +"name": "@your/dist_name", +"version": "2.2.0", +"publishAs": "distribution", +"description": "describe it", +"scripts": { +"config_hb": "hb set -root $DEP_BUNDLE_BASE", +"dist": "PATH=/root/.local/bin:${DEP_OHOS_gn}:${DEP_OHOS_ninja}/ninja:${DEP_OHOS_llvm}/llvm/bin:${DEP_OHOS_hc_gen}/hc-gen:${PATH} && ./scripts/dist.sh" +}, +"envs": { +"debug": false +}, +"dirs": { +"scripts": "scripts/*" +}, +"dependencies": { +"@ohos/build_lite": "2.2.0", +"@ohos/gn": "1.1.1", +"@ohos/llvm": "1.1.1", +"@ohos/hc_gen": "1.1.0", +"@ohos/ninja": "1.1.0", +...... +}, +"ohos": { +"os": "2.2-Beta", +"board": "hi3516", +"kernel": "liteos-a" +}, +"keywords": [ "hispark", "hi3516" ], +"repository": "https://gitee.com/openharmony/your-project", +"license": "Apache V2" +} +``` + + +## Building an HPM Part + +If the code of an HPM Part can be independently built, you can configure the build tool and scripts to generate binary files. + +The hpm-cli tool supports command integration so that you can select any build tool (such as make, gcc, and gn) suitable for your project. You only need to define the **build** command in **scripts** in the **bundle.json** file of your project, and then run the **hpm build** command to start the build. + + +### Defining the Build Script + +This section describes how to build an executable file named **helloworld** in the **app** directory. + + +``` +app +├── BUILD.gn +├── include +│ └── helloworld.h +└── src + └── helloworld.c +``` + +Create a **BUILD.gn** file in the same directory as **helloworld.c**. + + +``` +touch BUILD.gn +vim BUILD.gn +``` + +The following is an example of **BUILD.gn**: + + +``` +executable("hello_world") { + sources = [ + "src/helloworld.c" + ] + + include_dirs = [ + "include" + ] +} +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> - **executable** is a built-in template of gn. You can run the **gn help executable** command to view how to use this template. +> +> - **sources** represents the source code path, and **include_dirs** represents the header file path. + + +### Executing the Build Script + +Run the following command to start the build: + + +``` +hpm build +``` + +After all build operations are complete, the message "build succeed" is displayed. You need to check the build result. + +![zh-cn_image_0000001262166533](figures/zh-cn_image_0000001262166533.png) + + +### Building an Image + +Run the following command in the root directory of the current distribution: + + +``` +hpm dist +``` + +The hpm-cli tool automatically starts the build. After the build is complete, an image file will be generated, as shown below: + + +``` +out +|-xxdist.img +|-xx.file +``` + + +## Publishing an HPM Part + +To publish an HPM Part, you must obtain an account and create an organization (or join an existing organization). For details, see the online help on [DevEco Marketplace](https://repo.harmonyos.com). + +After that, generate a public key on the local PC based on your invitation code (which can be obtained on the **My profile** page on [DevEco Marketplace](https://repo.harmonyos.com)), and configure the public key on the **My profile** page. + + +``` +hpm config set loginUser {your-invitation-code} +hpm gen-keys +``` + +The generated file will be stored in **~\Users\yourname\.hpm\key**. Copy the content in the public key file **publicKey_your-account.pem** to the SSH public key on your **My profile** page. + +Now you have the permission to publish HPM Parts in your organization. + +In the directory where the HPM Part is located, run the following command to pack and publish the HPM Part: + + +``` +hpm publish +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> - To avoid HPM Part name conflicts, name an HPM Part in the format of **\@org_name/bundle_name**. +> +> - Your account must also be a member of **org_name** so that you can publish or update HPM Parts in the organization. +> +> - The published HPM Parts take effect only after security and content reviews. + + +## Using an HPM Part + + +### Using a Part + +When developing a project, you usually need to reference other HPM Parts to accelerate development of specific functions. Installing dependencies could be a good way. + +Visit [DevEco Marketplace](https://repo.harmonyos.com), search for HPM Parts that meet your service requirements by keywords, and then introduce them to your project. The typical operation procedure is as follows: + +1. Run the **hpm init** command to create a bundle description file named **bundle.json**, which contains dependencies and other metadata such as the name and version. + +2. Run the **hpm install ** command to install the dependency. The dependency will be written into the **dependencies** field in **bundle.json**. + +3. Reference the header file in the code to implement the function. + +4. Run the **hpm build** command to perform build and output the build result. + + Run the following command in your project. Make sure that the project directory contains the **bundle.json** file. + +``` +$ hpm install @scope/the_bundle +``` + + The referenced HPM Part will be installed under **ohos_bundle** in the directory where your project is located. The directory structure is as follows: + +``` +project +├── ohos_bundle +│ └── scope +│ └─ the_bundle # <--- Referenced HPM Part +└── src +│ └─ main.c +├── bundle.json # Metadata declaration file +└── LICENSE +└── Makefile +└── README.md +``` + +Open the **bundle.json** file. You will see that the HPM Part has been introduced to the dependencies of your project. + + +``` +{ +"dependencies": { + "@scope/the_bundle": "^1.0.0" + } +} +``` + +You can edit the dependencies of multiple HPM Parts in this file. + + +``` +{ +"dependencies": { + "@scope/the_bundle1": "^1.0.0", + "@scope/the_bundle2": "^2.0.0", + "@scope/the_bundle3": "^3.0.0", + "@scope/the_bundle4": "^1.1.0" + } +} +``` + +Run the **hpm install** command again to download and install all HPM Parts that have not been installed. + + +### Installing Global HPM Parts + +If the referenced HPM Part is shared by multiple projects, for example, the compiler toolchain, you can install it globally. + + Run the following command in your project. Make sure that the project directory contains the **bundle.json** file. + +``` +$ hpm install -g @scope/the_tool +``` + + The referenced HPM Part will be installed in the directory specified by the **globalRepo** parameter of the **hpm config** command. + +``` +~\.hpm\global\ohos_bundles +│ └── scope +│ └─ the_tool # <--- Referenced HPM Part +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> - For an HPM Part installed in a project, you can reference it using the environment variable **DEP_SCOPE_bundle_name** when running the hpm build command. +> For example, after you run **hpm i \@opensource/gn** to install an HPM Part, edit the build script in the **bundle.json** file as follows: +> +> ``` +> "scripts": { +> "build": "${DEP_OPENSOURCE_gn}/gn --version" +> }, +> ``` +> +> Then, you can run the **hpm build** command to call gn functions. +> +> - For a globally installed HPM Part, you can directly call the HPM Part using an environment variable or reference the HPM Part using the **${key}/tool_name** parameter in the **hpm config set key value** command. Example: +> +> ``` +> hpm i -g @ohos/opensource/gn +> hpm config BUILD_SYS_GN ~/.hpm/global/ohos_bundles/opensource/gn +> ``` +> +> You can edit the build script in the **bundle.json** file as follows: +> +> ``` +> "scripts": { +> "build": "${BUILD_SYS_GN}/gn --version" +> }, +> ``` +> +> Then, you can run the **hpm build** command to call gn functions. diff --git a/en/device-dev/bundles/hpm-part-reference.md b/en/device-dev/bundles/hpm-part-reference.md new file mode 100644 index 0000000000000000000000000000000000000000..758dc8cea9eb0196c5cd90a4a63c5b0ec1441e24 --- /dev/null +++ b/en/device-dev/bundles/hpm-part-reference.md @@ -0,0 +1,314 @@ +# HPM Part Reference + + +This section describes the HPM Part division rules, HPM Part types, HPM Part composition, metadata fields, and common CLI commands. + + +### HPM Part Division Rules + +In principle, HPM Parts should be grouped at a fine-grained granularity to achieve maximum reuse. The following factors are taken into account: + +- Independence: HPM Parts provide relatively independent features and can be independently built. Each HPM Part is capable of providing its own APIs and services for external systems. + +- Coupling: If an HPM Part must depend on another one to provide services, they can be coupled to one HPM Part. + +- Correlation: If a group of HPM Parts jointly implement a feature, and if other HPM Parts never depend on them, the group of HPM Parts can be combined into one HPM Part. + + +### HPM Part Type + +HPM Parts are introduced for reuse purposes. + + **Table 1** HPM Part types + +| Item| Description| +| -------- | -------- | +| source | Distributed in the form of source code. It is depended by the target project, and can be compiled independently.| +| binary | Distributed in binary mode. It does not contain source code, such as build tools.| +| code-segment | Distributed in the form of code snippets and cannot be compiled independently. After the installation, it is restored to the specified directory and participates in other code build in the target project.| +| distribution | Distributed as a distribution and dependent on other HPM Parts. It does not contain source code (except build scripts). The build output is system images.| +| template | Distributed as a template and used by the **hpm init** command to create a template.| +| plugin | Distributed as a plugin of hpm-cli to provide more functions.| + + +### HPM Part Composition + +An HPM Part contains the following: + +- **src** directory for storing code files or code library of the HPM Part. + +- **ohos_bundles** folder for storing dependent HPM Parts. The folder is automatically generated during HPM Part installation and does not need to be committed to the code library. + +- **README.md** file for describing the HPM Part. + +- **bundle.json** file for declaring metadata of the HPM Part. + +- LICENSE file for open-source code. + + ``` + my-bundle + |_ohos_bundles + |_headers + |_src + |_bundle.json + |_README.md + |_LICENSE + ``` + + +### src Source Code + +HPM Part code files are the same as those in a common code directory. The only difference lies in the open APIs (declared in header files) provided by HPM Parts, which will be referenced by other HPM Parts and must be declared in **dirs** of **bundle.json**. + + +### README File + +To help consumers find your HPM Part on [DevEco Marketplace](https://repo.harmonyos.com) and use it more conveniently, include a **README.md** file in the root directory of the HPM Part. + +**README.md** is a file written using the markdown syntax. + +The **README.md** file may include instructions on how to install, configure, and use the sample code in the HPM Part, as well as any other information helpful to the consumers. + +The Readme file will be displayed on the homepage of the HPM Part on [DevEco Marketplace](https://repo.harmonyos.com). + + +## bundle.json File + +The **bundle.json** file describes the metadata of an HPM Part. Each HPM Part has its own **bundle.json** file. The file content is as follows: + + +``` +{ + "name": "@myorg/demo-bundle", + "version": "1.0.0", + "license": "MIT", + "description": "bundle description", + "keywords": ["hos"], + "tags": ["applications", "drivers"], + "author": {"name":"","email":"","url":""}, + "contributors":[{"name":"","email":"","url":""},{"name":"","email":"","url":""}], + "homepage": "http://www.foo.bar.com", + "repository": "https://git@gitee.com:foo/bar.git", + "private": false, + "publishAs": "code-segment", + "segment":{ + "destPath":"/the/dest/path" + }, + "dirs": { + "src": ["src/**/*.c"], + "headers": ["headers/**/*.h"], + "bin": ["bin/**/*.o"] + }, + "scripts": { + "build": "make" + }, + "envs": {}, + "ohos": { + "os": "2.0.0", + "board": "hi3516", + "kernel": "liteos-a" + }, + "rom": "10240", + "ram": "1024", + "dependencies": { + "@myorg/net":"1.0.0" + } +} +``` + +Each **bundle.json** file has the following fields: + +- **name**: an HPM Part name, which starts with the at sign (@) and is separated with the organization name by the slash (/), for example, **\@myorg/mybundle**. + +- **version**: version of the HPM Part, for example, 1.0.0. The version must comply with the Semantic Versioning Specification (SemVer) standards. + +- **description**: a brief description of the HPM Part. + +- **dependencies**: dependent HPM Parts. + +- **envs**: parameters required for building the HPM Part, including global parameters and dependency parameters. + +- **scripts**: commands executable to the HPM Part, such as commands for compiling, building, testing, and burning. + +- **publishAs**: HPM Part publishing type, which can be **source**, **binary**, **distribution**, or **code-segment**. + +- **segment**: destination path of the code-segment HPM Part, that is, the destination path of the files contained in the HPM Part after the HPM Part is installed. + +- **dirs**: directory structure (such as the header file) generated for publishing. + +- **ram** and **rom**: statistical information about the estimated read-only memory (ROM) and random access memory (RAM) usage. + +- **ohos**: mappings among OpenHarmony versions, development boards, and kernels, separated by commas (,). + +- Extended information: author, home page, code repository, license, tags, and keywords. + +- For a distribution-level HPM Part, you can define the inheritance relationship and use the **base** field to describe the basic distribution and version that are inherited from. + +- **private**: indicates whether an HPM Part is private. A private HPM Part cannot be found by other organizations. The default value is **false**. + + +## HPM CLI Commands + +You can use the hpm-cli tool to manage the lifecycle of an HPM Part. The following table describes available hpm-cli commands. You can run the **hpm -h** command to get the command details. + + **Table 2** Commands available on hpm-cli + +| Command Type| Command Line| Description| +| -------- | -------- | -------- | +| Querying version information| **hpm -V** or **hpm --version**| Displays the version of the hpm-cli tool.| +| Querying help information| **hpm -h** or **hpm --version**| Displays the command list and help information.| +| hpm -h | Displays command help information.| +| Creating a project| hpm init bundle | Creates an HPM Part project.| +| hpm init -t template | Creates a scaffolding project from a template.| +| Installing HPM Parts| **hpm install** or **hpm i**| Installs dependent HPM Parts in the bundle.json file.| +| hpm install bundle\@version | Installs HPM Parts of a specified version.| +| Uninstalling HPM Parts| hpm uninstall bundle | Uninstalls dependent HPM Parts.| +| **hpm remove** or **hpm rm bundlename**| Uninstalls dependent HPM Parts.| +| Viewing information| **hpm list** or **hpm ls**| Displays the dependency tree of the HPM part.| +| hpm dependencies | Generates the dependency relationship data of the HPM Part. (This command is also integrated in the **hpm ui** command. After you run the hpm ui command, a hpm UI is displayed with the dependencies.)| +| Searching for HPM Parts| hpm search name | Searches for HPM Parts. **--json** is used to specify the search result in JSON format, and **-type** is used to set the target type, which can be **part**, **distribution**, or **code-segment**.| +| Setting HPM configuration items| hpm config set key value | Sets configuration items, such as the server address and network proxy.| +| hpm config delete key | Deletes configurations.| +| Updating HPM Part versions| hpm update | Updates the versions of dependent HPM Parts.| +| hpm check-update | Checks whether version updates are available to dependent HPM Parts.| +| Building| hpm build | Builds an HPM Part.| +| hpm dist | Builds a distribution. The build depends on the **dist** script in **scripts** of **bundle.json**.| +| Packing | hpm pack | Packs dependencies of local HPM Parts.| +| Burning| hpm run flash | Burns the firmware. The firmware burning depends on the **flash** script in **scripts** of **bundle.json**.| +| Publishing| hpm publish | Publishes an HPM Part, which must be unique in the repository and has a unique version. (An account is required for login.)| +| Running of extended commands| hpm run | Runs the commands in **scripts** defined in **bundle.json**. Multiple commands can be executed at a time by using **&&**.| +| Decompressing| hpm extract | Decompresses files in zip, tar, tgz, or .tar.gz format.| +| Starting UI| hpm ui | Starts the hpm UI locally. You can use the **-p** parameter to specify a port. On the Windows platform, the default browser is used to open the HPM UI.| +| Changing language| hpm lang | Alternates between Chinese and English on the CLI and UI.| +| Converting to HPM format| hpm x2h | Converts a Maven or npm package to an HPM Part and publishes it on the HPM platform.| +| Code segment restoration or cleanup| hpm code clean\|restore | Clears or restores the dependent code segment, which is equivalent to copying or deleting the code segment based on **segment.destPath**.| +| Generating a key| hpm gen-keys | Generates a public-private key pair and configures the public key on [DevEco Marketplace](https://repo.harmonyos.com), which enables password-free hpm-cli login for HPM Part publishing.| +| Generation of the third-party open source notice| hpm gen-notice | Generates a file providing the notice on third-party open source by combining the description of each HPM Part.| + + +## About Dependency + +HPM Part dependencies are classified as mandatory and optional dependencies. + +- Mandatory dependency: If HPM Part A must depend on HPM Part B to implement a feature (the APIs or services specific to HPM Part B must be called), HPM Part B is a mandatory dependency of HPM Part A. + +- Optional dependency: If either HPM Part C or D is required for HPM Part A to implement a feature, and if HPM Parts C and D are interchangeable, HPM Parts C and D are optional dependencies of HPM Part A. + + +``` +"dependencies": { + "@myorg/core":"1.0.0", + "?@myorg/plugin1":"1.0.0", + "?@myorg/plugin2":"1.1.0" + } +``` + +HPM Part dependencies can also be classified as compilation and development dependencies. + +- Compilation dependency: dependency required for runtime. + +- Development dependency: dependency required in non-runtime scenarios, such as static check, build, packing, test, and formatting tools. + + +``` +"dependencies": { + "@myorg/core":"1.0.0" + }, +"devDependencies": { + "@myorg/tool":"1.0.0" + } +``` + + Tags can be defined to group dependent HPM Parts. You can obtain the path of a group of dependent HPM Parts based on their tag. A tag starts with a number sign (#) and is defined as follows: + +``` +{ + "dependencies": { + "#tool": { + "first_bundle": "1.0.0", + "second_bundle": "1.0.0" + }, + "#drivers": { + "xx_bundle": "1.0.0", + "yy_bundle": "1.0.0" + } + } +} +``` + +HPM Part dependencies (including indirect dependencies) can be displayed by running the **hpm list** command or on the hpm UI, which is started by running the **hpm ui** command. + + +``` +$ hpm list ++--demo@1.0.0 +| +--@huawei/media@1.0.2 +| +--@demo/sport_hi3518ev300_liteos_a@1.0.0 +| | +--@demo/app@4.0.1 +| | | +--@demo/build@4.0.1 +| | | +--@demo/arm_harmonyeabi_gcc@4.0.0 +| | +--@demo/liteos_a@4.0.0 +| | | +--@demo/third_party_fatfs@4.0.0 +| | | +--@demo/arm_harmonyeabi_gcc@4.0.0 +| | +--@demo/init@4.0.0 +| | +--@demo/dist_tools@4.0.0 +``` + + +## About Environment Variables + +During HPM Part building, system-provided environment variables are required to define the output and link the required binary files. + +These variables are injected into the context for executing scripts based on service requirements. + +Therefore, their values can be directly obtained from the scripts. The following environment variables are available: + +**Built-in environment variables** + +- **DEP_OHOS_BUNDLES**: path of the **ohos_bundles** folder + +- **DEP_BUNDLE_BASE**: path of the outermost HPM Part + +**Global environment variables** + +Global environment variables are defined by the **envs** attribute in **bundle.json**. You can obtain the values of global environment variables from all independent HPM Parts. + + +``` +{ + "envs": { + "compileEnv": "arm" + } +} +``` + +Different parameters can be passed to HPM Parts when introducing dependencies so that the compilation of dependent HPM Parts can meet the requirements of the current HPM Part. The parameters defined in the dependencies can be obtained from the context for executing the corresponding scripts. + + +``` +{ + "dependencies": { + "my-bundle": { + "version": "1.0.0", + "mode": "debug" + } + } +} +``` + +When linking to a binary file, the HPM Part needs to know the file path regarding the dependencies. Therefore, you need to pass the path as an environment variable to the HPM Part for building. + +The passed environment variable is in **DEP\_BundleName** format, where **BundleName** indicates the name of the dependent HPM Part, for example, **DEP\_first\_bundle**. + + +## About Naming and Version Number + +1. The name must be lowercase letters or digits and can be separated by underscores (\_), for example, **bundle**, **my\_bundle**, and **json2**. + +2. Name of an HPM Part published to [DevEco Marketplace](https://repo.harmonyos.com) must start with the at sign (@) and is separated with the organization name by a slash (/), for example, **@my_org/part_name**. + +3. The organization name and part name must be unique and distinguishably different with other names. + +4. Names should be easy to understand. + +5. An HPM Part version must be in the format of ***majorVersion***.***minorVersion***.***revisionVersion*** or ***majorVersion***.***minorVersion***.***revisionVersion***-***pre-releaseVersion***, for example, **1.0.0** and **1.0.0-beta**. For details, see [https://semver.org](https://semver.org/). diff --git a/zh-cn/device-dev/bundles/public_sys-resources/icon-caution.gif b/en/device-dev/bundles/public_sys-resources/icon-caution.gif similarity index 100% rename from zh-cn/device-dev/bundles/public_sys-resources/icon-caution.gif rename to en/device-dev/bundles/public_sys-resources/icon-caution.gif diff --git a/zh-cn/device-dev/bundles/public_sys-resources/icon-danger.gif b/en/device-dev/bundles/public_sys-resources/icon-danger.gif similarity index 100% rename from zh-cn/device-dev/bundles/public_sys-resources/icon-danger.gif rename to en/device-dev/bundles/public_sys-resources/icon-danger.gif diff --git a/zh-cn/device-dev/bundles/public_sys-resources/icon-note.gif b/en/device-dev/bundles/public_sys-resources/icon-note.gif similarity index 100% rename from zh-cn/device-dev/bundles/public_sys-resources/icon-note.gif rename to en/device-dev/bundles/public_sys-resources/icon-note.gif diff --git a/zh-cn/device-dev/bundles/public_sys-resources/icon-notice.gif b/en/device-dev/bundles/public_sys-resources/icon-notice.gif similarity index 100% rename from zh-cn/device-dev/bundles/public_sys-resources/icon-notice.gif rename to en/device-dev/bundles/public_sys-resources/icon-notice.gif diff --git a/zh-cn/device-dev/bundles/public_sys-resources/icon-tip.gif b/en/device-dev/bundles/public_sys-resources/icon-tip.gif similarity index 100% rename from zh-cn/device-dev/bundles/public_sys-resources/icon-tip.gif rename to en/device-dev/bundles/public_sys-resources/icon-tip.gif diff --git a/zh-cn/device-dev/bundles/public_sys-resources/icon-warning.gif b/en/device-dev/bundles/public_sys-resources/icon-warning.gif similarity index 100% rename from zh-cn/device-dev/bundles/public_sys-resources/icon-warning.gif rename to en/device-dev/bundles/public_sys-resources/icon-warning.gif diff --git a/en/device-dev/get-code/gettools-acquire.md b/en/device-dev/get-code/gettools-acquire.md index 6c06f41669bfdb21965dcfe7d4095613a676861b..15c242defe4dddc26856e1a8132ff1e5c0df07f8 100644 --- a/en/device-dev/get-code/gettools-acquire.md +++ b/en/device-dev/get-code/gettools-acquire.md @@ -166,7 +166,7 @@ Files generated during building are stored in the **out/{device_name}/** direc ## HPM-based Docker Environment -**docker\_dist** is a template component in the [HPM](https://hpm.harmonyos.com/#/en/home) system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and [hpm-cli](../bundles/bundles-guide-prepare.md) development environments, perform the following steps to access the Docker environment: +**docker\_dist** is a template component in the [HPM](https://hpm.harmonyos.com/#/en/home) system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and [hpm-cli](../bundles/hpm-part-development.md) development environments, perform the following steps to access the Docker environment: ### Setting Up the Docker Environment diff --git a/en/device-dev/get-code/sourcecode-acquire.md b/en/device-dev/get-code/sourcecode-acquire.md index 205d59463d81f2ed33a64f46f3b652836821e4ca..4561cc2511ddf645fb2b4e5a533d85ef6bf93f83 100644 --- a/en/device-dev/get-code/sourcecode-acquire.md +++ b/en/device-dev/get-code/sourcecode-acquire.md @@ -8,7 +8,7 @@ The open-source code repositories are available at [https://openharmony.gitee.c ## Overview of Source Code Acquisition -This document describes how to acquire OpenHarmony source code and provides its directory structure. The OpenHarmony code is open to you as [bundles](../bundles/bundles-standard-rules.md), which can be obtained in any of the following ways: +You can use any of the following methods to acquire the OpenHarmony source code: - **Method 1**: Acquire the source code from the Gitee code repository. You can use the **repo** or **git** tool to download the latest code from the code repository. - **Method 2**: Acquire the source code from [DevEco Marketplace](https://repo.harmonyos.com/#/en/home). Visit [DevEco Marketplace](https://repo.harmonyos.com/#/en/home), search for your desired open-source distribution, and download the bundle list \(or customize bundles and download the bundle list\). Then use **hpm-cli** to download and install the bundles and compilation toolchain on your local PC. diff --git a/en/device-dev/kernel/Readme-EN.md b/en/device-dev/kernel/Readme-EN.md index db98e9eb28138d478a802bbc7d057acc82dbe8ae..767d2dec0d26babadafbd99c08c9fa1dbdaf4ad1 100644 --- a/en/device-dev/kernel/Readme-EN.md +++ b/en/device-dev/kernel/Readme-EN.md @@ -144,8 +144,8 @@ - [Magic Key](kernel-small-debug-shell-magickey.md) - [User-Space Exception Information](kernel-small-debug-shell-error.md) - [Trace](kernel-small-debug-trace.md) - - [perf](kernel-mini-memory-perf) - - [LMS](kernel-small-memory-lms) + - [perf](kernel-mini-memory-perf.md) + - [LMS](kernel-small-memory-lms.md) - [Process Commissioning](kernel-small-debug-process.md) - [CPUP](kernel-small-debug-process-cpu.md) - [Memory Debugging](kernel-small-debug-memory.md) diff --git a/en/device-dev/subsystems/subsys-application-framework-envbuild.md b/en/device-dev/subsystems/subsys-application-framework-envbuild.md index bf8f8616f24a1f8d18793c365caa395166c27294..ce4868dc56950e71499b7e24654b859c665ee22c 100644 --- a/en/device-dev/subsystems/subsys-application-framework-envbuild.md +++ b/en/device-dev/subsystems/subsys-application-framework-envbuild.md @@ -3,5 +3,5 @@ - Development board: Hi3516D V300 - [Download the source code](../get-code/sourcecode-acquire.md) -- Build the application framework. +- [Build the application framework](../../readme/bundle-management.md). diff --git a/en/device-dev/subsystems/subsys-build-mini-lite.md b/en/device-dev/subsystems/subsys-build-mini-lite.md index ce9e330cd78711067f1d4af027c1f2beab8be6a0..c12b28c3d9c5a7135ead0f12462397f953409c6f 100644 --- a/en/device-dev/subsystems/subsys-build-mini-lite.md +++ b/en/device-dev/subsystems/subsys-build-mini-lite.md @@ -1,4 +1,4 @@ -# Building Guidelines for Mini and Small Systems +# Building Mini and Small Systems ## Overview diff --git a/en/device-dev/subsystems/subsys-build-standard-large.md b/en/device-dev/subsystems/subsys-build-standard-large.md index 0dfffb12b8c42485646329fbecd5f72a86b6a34e..d47fbd1d235b46617d2471201eb874f9b557f4d1 100644 --- a/en/device-dev/subsystems/subsys-build-standard-large.md +++ b/en/device-dev/subsystems/subsys-build-standard-large.md @@ -1,4 +1,4 @@ -# Building Guidelines for Standard Systems +# Building a Standard System ## Overview diff --git a/en/device-dev/subsystems/subsys-build.md b/en/device-dev/subsystems/subsys-build.md index b8aa6b81f76ee323182ed22af9ad3db1afb6114f..8bbf1247ff453b5ae36058be1879ed81224ed4da 100644 --- a/en/device-dev/subsystems/subsys-build.md +++ b/en/device-dev/subsystems/subsys-build.md @@ -1,9 +1,9 @@ # Compilation and Building -- **[Building Guidelines for Mini and Small Systems](subsys-build-mini-lite.md)** +- **[Building Mini and Small Systems](subsys-build-mini-lite.md)** -- **[Building Guidelines for Standard Systems](subsys-build-standard-large.md)** +- **[Building a Standard System](subsys-build-standard-large.md)** - **[Build System Coding Specifications and Best Practices](subsys-build-gn-coding-style-and-best-practice.md)** - +- **[Building the Kconfig Visual Configuration](subsys-build-gn-kconfig-visual-config-guid.md)** diff --git a/en/device-dev/subsystems/subsys-data-storage-guide.md b/en/device-dev/subsystems/subsys-data-storage-guide.md index 152935dc1a60c17cfda5ba745e98321ec3a2c912..b04c82592a0266a05103a60be2752fa4c4530930 100644 --- a/en/device-dev/subsystems/subsys-data-storage-guide.md +++ b/en/device-dev/subsystems/subsys-data-storage-guide.md @@ -165,7 +165,7 @@ Use the following APIs to delete a **Preferences** instance or data file. Subscribe to data changes and invoke the callback: ``` C++ std::shared_ptr counter = - std::shared_ptr(new PreferencesObserverCounter()); + std::make_shared(); pref->RegisterObserver(counter); // Register a callback to return data changes. pref->PutString(PreferencesTest::KEY_TEST_STRING_ELEMENT, "test"); diff --git a/en/device-dev/subsystems/subsys-toolchain-bytrace-guide.md b/en/device-dev/subsystems/subsys-toolchain-bytrace-guide.md index e3b542ac9197dbf8c93ccee723232403aff3bed5..c1609bcb2ea5f0b04a15c632a4997c309c7d5fe7 100644 --- a/en/device-dev/subsystems/subsys-toolchain-bytrace-guide.md +++ b/en/device-dev/subsystems/subsys-toolchain-bytrace-guide.md @@ -1,4 +1,4 @@ -# bytrace Usage Guidelines +# bytrace ## Overview diff --git a/en/device-dev/subsystems/subsys-toolchain-hdc-guide.md b/en/device-dev/subsystems/subsys-toolchain-hdc-guide.md index 3c72f79eac135f35b8e2a125cd3ede923fc3db05..70b52ef61d1b7279111d01d0a93d0494353519d7 100644 --- a/en/device-dev/subsystems/subsys-toolchain-hdc-guide.md +++ b/en/device-dev/subsystems/subsys-toolchain-hdc-guide.md @@ -1,4 +1,4 @@ -# hdc\_std Usage Guidelines +# hdc\_std hdc\_std \(OpenHarmony Device Connector\) is a command line tool provided by OpenHarmony for debugging. With this tool, you can interact with real devices or simulators from a Windows or Linux OS. diff --git a/en/device-dev/subsystems/subsys-toolchain.md b/en/device-dev/subsystems/subsys-toolchain.md index bf65f5f78a4fbf2f28777bf3222476597f987311..ebb14d2e60dc493893241f8d308df7c8a8d93deb 100644 --- a/en/device-dev/subsystems/subsys-toolchain.md +++ b/en/device-dev/subsystems/subsys-toolchain.md @@ -1,7 +1,9 @@ # R&D Tools -- **[bytrace Usage Guidelines](subsys-toolchain-bytrace-guide.md)** +- **[bytrace](subsys-toolchain-bytrace-guide.md)** -- **[hdc\_std Usage Guidelines](subsys-toolchain-hdc-guide.md)** +- **[hdc\_std](subsys-toolchain-hdc-guide.md)** + +- **[hiperf](subsys-toolchain-hiperf.md)** diff --git a/en/device-dev/subsystems/subsys-utils-faqs.md b/en/device-dev/subsystems/subsys-utils-faqs.md index 0f1ed0e9f06e62e99e05c81ea78333f80bffd007..d6999a44741c163643eaf0b39123cfefe29ffb57 100644 --- a/en/device-dev/subsystems/subsys-utils-faqs.md +++ b/en/device-dev/subsystems/subsys-utils-faqs.md @@ -15,6 +15,6 @@ The compiled executable program is run directly without being converted to an ap Call the **UtilsSetEnv** function of the KV store to set the data storage path. ``` -UtilsSetEnv("/storage/com.huawei.kv"); +UtilsSetEnv("/storage/com.example.kv"); ``` diff --git a/en/device-dev/website.md b/en/device-dev/website.md new file mode 100644 index 0000000000000000000000000000000000000000..53019a18f1c6c90400102c5675168086dd1174a1 --- /dev/null +++ b/en/device-dev/website.md @@ -0,0 +1,344 @@ +- - # Device + + - [Device Development Guide](device-dev-guide.md) + - Quick Start + - Mini and Small Systems + - [Overview](quick-start/quickstart-lite-overview.md) + - Introduction + - [Hi3861 Development Board](quick-start/quickstart-lite-introduction-hi3861.md) + - [Hi3516 Development Board](quick-start/quickstart-lite-introduction-hi3516.md) + - [Hi3518 Development Board](quick-start/quickstart-lite-introduction-hi3518.md) + - Environment Setup + - [Overview](quick-start/quickstart-lite-env-setup-overview.md) + - [Setting Up Windows Development Environment](quick-start/quickstart-lite-env-setup-windows.md) + - [Setting Up Ubuntu Development Environment](quick-start/quickstart-lite-env-setup-linux.md) + - [FAQs](quick-start/quickstart-lite-env-setup-faqs.md) + - How to Develop + - Hi3861 + - [Setting Up the Environment](quick-start/quickstart-lite-steps-hi3861-setting.md) + - [Setting Up WLAN Connection](quick-start/quickstart-lite-steps-hi3861-connection.md) + - [Running a Hello World Program](quick-start/quickstart-lite-steps-hi3861-running.md) + - [FAQs](quick-start/quickstart-lite-steps-hi3861-faqs.md) + - Hi3516 + - [Setting Up the Environment](quick-start/quickstart-lite-steps-hi3516-setting.md) + - [Running a Hello OHOS Program](quick-start/quickstart-lite-steps-hi3516-running.md) + - [Developing a Driver](quick-start/quickstart-lite-steps-hi3516-program.md) + - [FAQs](quick-start/quickstart-lite-steps-hi3516-faqs.md) + - Hi3518 + - [Setting Up the Environment](quick-start/quickstart-lite-steps-hi3518-setting.md) + - [Running a Hello OHOS Program](quick-start/quickstart-lite-steps-hi3518-running.md) + - [FAQs](quick-start/quickstart-lite-steps-hi3518-faqs.md) + - Standard System + - [Introduction](quick-start/quickstart-standard-overview.md) + - [Setting Up Windows Development Environment](quick-start/quickstart-standard-windows-environment.md) + - [Setting Up Ubuntu Development Environment in Docker Mode](quick-start/quickstart-standard-docker-environment.md) + - [Setting Up Ubuntu Development Environment with Installation Package](quick-start/quickstart-standard-package-environment.md) + - [Burning Images](quick-start/quickstart-standard-burn.md) + - [Running an Image](quick-start/quickstart-standard-running.md) + - [FAQs](quick-start/quickstart-standard-faqs.md) + - Compatibility and Security + - [Privacy Protection](security/security-privacy-protection.md) + - [Security Guidelines](security/security-guidelines-overall.md) + - Porting + - Mini System SoC Porting Guide + - Porting Preparations + - [Before You Start](porting/oem_transplant_chip_prepare_knows.md) + - [Building Adaptation Process](porting/porting-chip-prepare-process.md) + - Kernel Porting + - [Overview](porting/porting-chip-kernel-overview.md) + - [Basic Kernel Adaptation](porting/porting-chip-kernel-adjustment.md) + - [Kernel Porting Verification](porting/porting-chip-kernel-verify.md) + - Board-Level OS Porting + - [Overview](porting/porting-chip-board-overview.md) + - [Board-Level Driver Adaptation](porting/porting-chip-board-driver.md) + - [Implementation of APIs at the HAL](porting/porting-chip-board-hal.md) + - [System Modules](porting/porting-chip-board-component.md) + - [lwIP Module Adaptation](porting/porting-chip-board-lwip.md) + - [Third-party Module Adaptation](porting/porting-chip-board-bundle.md) + - [XTS](porting/porting-chip-board-xts.md) + - [FAQ](porting/porting-chip-faqs.md) + - Small System SoC Porting Guide + - Porting Preparations + - [Before You Start](porting/porting-smallchip-prepare-needs.md) + - [Compilation and Building](porting/porting-smallchip-prepare-building.md) + - Kernel Porting + - [LiteOS Cortex-A](porting/porting-smallchip-kernel-a.md) + - [Linux Kernel](porting/porting-smallchip-kernel-linux.md) + - Driver Porting + - [Overview](porting/porting-smallchip-driver-overview.md) + - [Platform Driver Porting](porting/porting-smallchip-driver-plat.md) + - [Device Driver Porting](porting/porting-smallchip-driver-oom.md) + - Standard System SoC Porting Guide + - [Standard System Porting Guide](porting/standard-system-porting-guide.md) + - [A Method for Rapidly Porting the OpenHarmony Linux Kernel](porting/porting-linux-kernel.md) + - Third-Party Library Porting Guide for Mini and Small Systems + - [Overview](porting/porting-thirdparty-overview.md) + - [Porting a Library Built Using CMake](porting/porting-thirdparty-cmake.md) + - [Porting a Library Built Using Makefile](porting/porting-thirdparty-makefile.md) + - Subsystem Development + - Kernel + - Kernel for Mini Systems + - [Kernel Overview](kernel/kernel-mini-overview.md) + - Basic Kernel + - [Interrupt Management](kernel/kernel-mini-basic-interrupt.md) + - [Task Management](kernel/kernel-mini-basic-task.md) + - Memory Management + - [Basic Concepts](kernel/kernel-mini-basic-memory-basic.md) + - [Static Memory](kernel/kernel-mini-basic-memory-static.md) + - [Dynamic Memory](kernel/kernel-mini-basic-memory-dynamic.md) + - Kernel Communication Mechanisms + - [Event](kernel/kernel-mini-basic-ipc-event.md) + - [Mutex](kernel/kernel-mini-basic-ipc-mutex.md) + - [Queue](kernel/kernel-mini-basic-ipc-queue.md) + - [Semaphore](kernel/kernel-mini-basic-ipc-sem.md) + - [Time Management](kernel/kernel-basic-mini-time.md) + - [Software Timer](kernel/kernel-mini-basic-soft.md) + - Extended Components + - [C++ Support](kernel/kernel-mini-extend-support.md) + - [CPUP](kernel/kernel-mini-extend-cpup.md) + - [Dynamic Loading](kernel/kernel-mini-extend-dynamic-loading.md) + - File System + - [FAT](kernel/kernel-mini-extend-file-fat.md) + - [LittleFS](kernel/kernel-mini-extend-file-lit.md) + - Kernel Debugging + - Memory Debugging + - [Memory Information Statistics](kernel/kernel-mini-memory-debug-mes.md) + - [Memory Leak Check](kernel/kernel-mini-imemory-debug-det.md) + - [Memory Corruption Check](kernel/kernel-mini-memory-debug-cet.md) + - [Exception Debugging](kernel/kernel-mini-memory-exception.md) + - [Trace](kernel/kernel-mini-memory-trace.md) + - [LMS](kernel/kernel-mini-memory-lms.md) + - Appendix + - [Kernel Coding Specification](kernel/kernel-mini-appx-code.md) + - Basic Data Structure + - [Doubly Linked List](kernel/kernel-mini-appx-data-list.md) + - Standard Libraries + - [CMSIS Support](kernel/kernel-mini-appx-lib-cmsis.md) + - [POSIX Support](kernel/kernel-mini-appx-lib-posix.md) + - Kernel for Small Systems + - [Kernel Overview](kernel/kernel-small-overview.md) + - Kernel Startup + - [Startup in Kernel Space](kernel/kernel-small-start-kernel.md) + - [Startup in User Space](kernel/kernel-small-start-user.md) + - Basic Kernel + - [Interrupt and Exception Handling](kernel/kernel-small-basic-interrupt.md) + - Process Management + - [Process](kernel/kernel-small-basic-process-process.md) + - [Task](kernel/kernel-small-basic-process-thread.md) + - [Scheduler](kernel/kernel-small-basic-process-scheduler.md) + - Memory Management + - [Heap Memory Management](kernel/kernel-small-basic-memory-heap.md) + - [Physical Memory Management](kernel/kernel-small-basic-memory-physical.md) + - [Virtual Memory Management](kernel/kernel-small-basic-memory-virtual.md) + - [Virtual-to-Physical Mapping](kernel/kernel-small-basic-inner-reflect.md) + - Kernel Communication Mechanisms + - [Event](kernel/kernel-small-basic-trans-event.md) + - [Semaphore](kernel/kernel-small-basic-trans-semaphore.md) + - [Mutex](kernel/kernel-small-basic-trans-mutex.md) + - [Queue](kernel/kernel-small-basic-trans-queue.md) + - [RW Lock](kernel/kernel-small-basic-trans-rwlock.md) + - [Futex](kernel/kernel-small-basic-trans-user-mutex.md) + - [Signal](kernel/kernel-small-basic-trans-user-signal.md) + - [Time Management](kernel/kernel-small-basic-time.md) + - [Software Timer](kernel/kernel-small-basic-softtimer.md) + - [Atomic Operation](kernel/kernel-small-basic-atomic.md) + - Extension Components + - [System Call](kernel/kernel-small-bundles-system.md) + - [Dynamic Loading and Linking](kernel/kernel-small-bundles-linking.md) + - [Virtual Dynamic Shared Object](kernel/kernel-small-bundles-share.md) + - [LiteIPC](kernel/kernel-small-bundles-ipc.md) + - File Systems + - [Virtual File System](kernel/kernel-small-bundles-fs-virtual.md) + - Supported File Systems + - [FAT](kernel/kernel-small-bundles-fs-support-fat.md) + - [JFFS2](kernel/kernel-small-bundles-fs-support-jffs2.md) + - [NFS](kernel/kernel-small-bundles-fs-support-nfs.md) + - [Ramfs](kernel/kernel-small-bundles-fs-support-ramfs.md) + - [procfs](kernel/kernel-small-bundles-fs-support-procfs.md) + - [File System Adaptation](kernel/kernel-small-bundles-fs-new.md) + - Debugging and Tools + - Shell + - [Introduction to the Shell](kernel/kernel-small-debug-shell-overview.md) + - [Shell Command Development Guidelines](kernel/kernel-small-debug-shell-guide.md) + - [Shell Command Programming Example](kernel/kernel-small-debug-shell-build.md) + - Shell Command Reference + - System Commands + - [cpup](kernel/kernel-small-debug-shell-cmd-cpup.md) + - [date](kernel/kernel-small-debug-shell-cmd-date.md) + - [dmesg](kernel/kernel-small-debug-shell-cmd-dmesg.md) + - [exec](kernel/kernel-small-debug-shell-cmd-exec.md) + - [free](kernel/kernel-small-debug-shell-cmd-free.md) + - [help](kernel/kernel-small-debug-shell-cmd-help.md) + - [hwi](kernel/kernel-small-debug-shell-cmd-hwi.md) + - [kill](kernel/kernel-small-debug-shell-cmd-kill.md) + - [log](kernel/kernel-small-debug-shell-cmd-log.md) + - [memcheck](kernel/kernel-small-debug-shell-cmd-memcheck.md) + - [oom](kernel/kernel-small-debug-shell-cmd-oom.md) + - [pmm](kernel/kernel-small-debug-shell-cmd-pmm.md) + - [reset](kernel/kernel-small-debug-shell-cmd-reset.md) + - [sem](kernel/kernel-small-debug-shell-cmd-sem.md) + - [stack](kernel/kernel-small-debug-shell-cmd-stack.md) + - [su](kernel/kernel-small-debug-shell-cmd-su.md) + - [swtmr](kernel/kernel-small-debug-shell-cmd-swtmr.md) + - [systeminfo](kernel/kernel-small-debug-shell-cmd-sysinfo.md) + - [task](kernel/kernel-small-debug-shell-cmd-task.md) + - [uname](kernel/kernel-small-debug-shell-cmd-uname.md) + - [vmm](kernel/kernel-small-debug-shell-cmd-vmm.md) + - [watch](kernel/kernel-small-debug-shell-cmd-watch.md) + - File Commands + - [cat](kernel/kernel-small-debug-shell-file-cat.md) + - [cd](kernel/kernel-small-debug-shell-file-cd.md) + - [chgrp](kernel/kernel-small-debug-shell-file-chgrp.md) + - [chmod](kernel/kernel-small-debug-shell-file-chmod.md) + - [chown](kernel/kernel-small-debug-shell-file-chown.md) + - [cp](kernel/kernel-small-debug-shell-file-cp.md) + - [format](kernel/kernel-small-debug-shell-file-format.md) + - [ls](kernel/kernel-small-debug-shell-file-ls.md) + - [lsfd](kernel/kernel-small-debug-shell-file-lsfd.md) + - [mkdir](kernel/kernel-small-debug-shell-file-mkdir.md) + - [mount](kernel/kernel-small-debug-shell-file-mount.md) + - [partinfo](kernel/kernel-small-debug-shell-file-partinfo.md) + - [partition](kernel/kernel-small-debug-shell-file-partition.md) + - [pwd](kernel/kernel-small-debug-shell-file-pwd.md) + - [rm](kernel/kernel-small-debug-shell-file-rm.md) + - [rmdir](kernel/kernel-small-debug-shell-file-rmdir.md) + - [statfs](kernel/kernel-small-debug-shell-file-statfs.md) + - [sync](kernel/kernel-small-debug-shell-file-sync.md) + - [touch](kernel/kernel-small-debug-shell-file-touch.md) + - [writeproc](kernel/kernel-small-debug-shell-file-write.md) + - [umount](kernel/kernel-small-debug-shell-file-umount.md) + - Network Commands + - [arp](kernel/kernel-small-debug-shell-net-arp.md) + - [dhclient](kernel/kernel-small-debug-shell-net-dhclient.md) + - [ifconfig](kernel/kernel-small-debug-shell-net-ifconfig.md) + - [ipdebug](kernel/kernel-small-debug-shell-net-ipdebug.md) + - [netstat](kernel/kernel-small-debug-shell-net-netstat.md) + - [ntpdate](kernel/kernel-small-debug-shell-net-ntpdate.md) + - [ping](kernel/kernel-small-debug-shell-net-ping.md) + - [ping6](kernel/kernel-small-debug-shell-net-ping6.md) + - [telnet](kernel/kernel-small-debug-shell-net-telnet.md) + - [tftp](kernel/kernel-small-debug-shell-net-tftp.md) + - [Magic Key](kernel/kernel-small-debug-shell-magickey.md) + - [User-Space Exception Information](kernel/kernel-small-debug-shell-error.md) + - [Trace](kernel/kernel-small-debug-trace.md) + - [perf](kernel/kernel-mini-memory-perf) + - [LMS](kernel/kernel-small-memory-lms) + - Process Commissioning + - [CPUP](kernel/kernel-small-debug-process-cpu.md) + - Memory Debugging + - [Memory Information Statistics](kernel/kernel-small-debug-memory-info.md) + - [Memory Leak Check](kernel/kernel-small-debug-memory-leak.md) + - [Memory Corruption Check](kernel/kernel-small-debug-memory-corrupt.md) + - User-Mode Memory Debugging + - [Basic Concepts](kernel/kernel-small-debug-user-concept.md) + - [Working Principles](kernel/kernel-small-debug-user-function.md) + - Usage + - [API Description](kernel/kernel-small-debug-user-guide-api.md) + - How to Use + - [Calling APIs](kernel/kernel-small-debug-user-guide-use-api.md) + - [Using the CLI](kernel/kernel-small-debug-user-guide-use-cli.md) + - [Typical Memory Problems](kernel/kernel-small-debug-user-faqs.md) + - Other Kernel Debugging Methods + - [Dying Gasp](kernel/kernel-small-debug-trace-other-lastwords.md) + - [Common Fault Locating Methods](kernel/kernel-small-debug-trace-other-faqs.md) + - Appendix + - Basic Data Structure + - [Doubly Linked List](kernel/kernel-small-apx-dll.md) + - [Bitwise Operation](kernel/kernel-small-apx-bitwise.md) + - [Standard Library](kernel/kernel-small-apx-library.md) + - Kernel for Standard Systems + - [Linux Kernel Overview](kernel/kernel-standard-overview.md) + - [Applying Patches on OpenHarmony Development Boards](kernel/kernel-standard-patch.md) + - [Guidelines for Building the Linux Kernel](kernel/kernel-standard-build.md) + - Driver + - HDF + - [HDF Overview](driver/driver-hdf-overview.md) + - [Driver Development](driver/driver-hdf-development.md) + - [Driver Service Management](driver/driver-hdf-servicemanage.md) + - [Driver Message Mechanism Management](driver/driver-hdf-message-management.md) + - [Driver Configuration Management](driver/driver-hdf-manage.md) + - [HDF Development Example](driver/driver-hdf-sample.md) + - Platform Driver Development + - [ADC](driver/driver-platform-adc-develop.md) + - [GPIO](driver/driver-platform-gpio-develop.md) + - [HDMI](driver/driver-platform-hdmi-develop.md) + - [I2C](driver/driver-platform-i2c-develop.md) + - [I3C](driver/driver-platform-i3c-develop.md) + - [MIPI DSI](driver/driver-platform-mipidsi-develop.md) + - [MMC](driver/driver-platform-mmc-develop.md) + - [PWM](driver/driver-platform-pwm-develop.md) + - [RTC](driver/driver-platform-rtc-develop.md) + - [SDIO](driver/driver-platform-sdio-develop.md) + - [SPI](driver/driver-platform-spi-develop.md) + - [UART](driver/driver-platform-uart-develop.md) + - [Watchdog](driver/driver-platform-watchdog-develop.md) + - Platform Driver Usage + - [ADC](driver/driver-platform-adc-des.md) + - [GPIO](driver/driver-platform-gpio-des.md) + - [HDMI](driver/driver-platform-hdmi-des.md) + - [I2C](driver/driver-platform-i2c-des.md) + - [I3C](driver/driver-platform-i3c-des.md) + - [MIPI DSI](driver/driver-platform-mipidsi-des.md) + - [PWM](driver/driver-platform-pwm-des.md) + - [RTC](driver/driver-platform-rtc-des.md) + - [SDIO](driver/driver-platform-sdio-des.md) + - [SPI](driver/driver-platform-spi-des.md) + - [UART](driver/driver-platform-uart-des.md) + - [Watchdog](driver/driver-platform-watchdog-des.md) + - Peripheral Driver Usage + - [LCD](driver/driver-peripherals-lcd-des.md) + - [Touchscreen](driver/driver-peripherals-touch-des.md) + - [Sensor](driver/driver-peripherals-sensor-des.md) + - [WLAN](driver/driver-peripherals-external-des.md) + - [Audio](driver/driver-peripherals-audio-des.md) + - [USB](driver/driver-peripherals-usb-des.md) + - [Camera](driver/driver-peripherals-camera-des.md) + - [Compilation and Building](subsystems/subsys-build.md) + - [Distributed Remote Startup](subsystems/subsys-remote-start.md) + - [Graphics](subsystems/subsys-graphics.md) [Multimedia](subsystems/subsys-multimedia.md) + - [Utils](subsystems/subsys-utils.md) + - [AI Framework](subsystems/subsys-aiframework.md) + - [Data Management](subsystems/subsys-data.md) + - [Sensor](subsystems/subsys-sensor.md) + - [USB](subsystems/subsys-usbservice.md) + - [Application Framework](subsystems/subsys-application-framework.md) + - [OTA Upgrade](subsystems/subsys-ota-guide.md) + - [Telephony Service](subsystems/subsys-tel.md) + - [Security](subsystems/subsys-security.md) + - [Startup](subsystems/subsys-boot.md) + - [DFX](subsystems/subsys-dfx.md) + - Featured Topics + - [HPM Bundle](bundles/Readme-EN.md) + - [Development Specifications](bundles/bundles-standard-rules.md) + - Development Guidelines + - [Bundle Development](bundles/bundles-guide-overview.md) + - [Preparations](bundles/bundles-guide-prepare.md) + - [Bundle Development](bundles/bundles-guide-develop.md) + - HPM User Guide + - [Introduction](bundles/bundles-demo-hpmdescription.md) + - [Preparations](bundles/bundles-demo-environment.md) + - [Development Example](bundles/bundles-demo-devsample.md) + - Device Development Examples + - [Mini- and Small-System Devices](guide/device-lite.md) + - [Standard-System Devices](guide/device-standard.md) + - Debugging + - [Test Subsystem](subsystems/subsys-testguide-test.md) + - [R&D Tools](subsystems/subsys-toolchain.md) + - XTS Certification + - [XTS](subsystems/subsys-xts-guide.md) + - Tools + - [Docker Environment](get-code/gettools-acquire.md) + - [IDE](get-code/gettools-ide.md) + - Hands-On Tutorials + - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) + - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) + - References + - [FAQs](faqs/Readme-EN.md) + - [Overview of FAQs](faqs/faqs-overview.md) + - [Environment Setup](faqs/faqs-environment-setup.md) + - [Compilation and Building Subsystem](faqs/faqs-building.md) + - [Burning](faqs/faqs-burning.md) + - [Kernel](faqs/faqs-kernel.md) + - [Porting](faqs/faqs-porting.md) + - [Startup](faqs/faqs-startup.md) + - [System Applications](faqs/faqs-system-applications.md) \ No newline at end of file diff --git a/en/readme/figures/en-us_architecture-of-telephony-subsystem.png b/en/readme/figures/en-us_architecture-of-telephony-subsystem.png index 5a79ea900765c63116a2bcecfe33ac7eb7d9c24a..80d325eccc9911da696fc8176d47b0a25991297b 100755 Binary files a/en/readme/figures/en-us_architecture-of-telephony-subsystem.png and b/en/readme/figures/en-us_architecture-of-telephony-subsystem.png differ diff --git a/en/website-directory.md b/en/website-directory.md deleted file mode 100644 index a8be57bf1225286780a9111c88c35cc05fa1e789..0000000000000000000000000000000000000000 --- a/en/website-directory.md +++ /dev/null @@ -1,1915 +0,0 @@ -# OpenHarmony - -——>——> Learn About the OpenHarmony Community - -——>——>——> [OpenHarmony](OpenHarmony-Overview.md) - -——>——>——> Learn About the OpenHarmony OS - -——>——>——>——>[Kernel](readme/kernel.md) - -——>——>——>——>[Driver](readme/driver.md) - -——>——>——>——>[ARK Runtime](readme/ark-runtime.md) - -——>——>——>——>[DFX](readme/dfx-subsystem.md) - -——>——>——>——>[JS UI Framework](readme/js-ui-framework.md) - -——>——>——>——>[Misc Services](readme/misc-services.md) - -——>——>——>——>[XTS](readme/xts.md) - -——>——>——>——>[Common Event and Notification](readme/common-event-notification.md) - -——>——>——>——>[Globalization](readme/globalization.md) - -——>——>——>——>[utils](readme/utils.md) - -——>——>——>——>[Distributed Scheduler](readme/distributed-scheduler.md) - -——>——>——>——>[Distributed Data Management](readme/distributed-data-management.md) - -——>——>——>——>[Distributed File](readme/distributed-file.md) - -——>——>——>——>[DSoftBus](readme/dsoftbus.md) - -——>——>——>——>[Update](readme/update.md) - -——>——>——>——>[Startup](readme/startup.md) - -——>——>——>——>[Graphics](readme/graphics.md) - -——>——>——>——>[Multimodal Input](readme/multimodal-input.md) - -——>——>——>——>[Multimedia](readme/multimedia.md) - -——>——>——>——>[Account](readme/account.md) - -——>——>——>——>[Pan-Sensor](readme/pan-sensor.md) - -——>——>——>——>[Test](readme/test.md) - -——>——>——>——>[Power Management](readme/power-management.md) - -——>——>——>——>[Telephony](readme/telephony.md) - -——>——>——>——>[System Apps](readme/system-apps.md) - -——>——>——>——>[Programming Language Runtime](readme/programming-language-runtime.md) - -——>——>——>——>[AI](readme/ai.md) - -——>——>——> [Glossary](device-dev/glossary/glossary.md) - -——>——>——> [OpenHarmony Release Notes](release-notes/Readme.md) - -——>——> Quick Start - -——>——>——>[Mini and Small Systems](device-dev/quick-start/quickstart-lite.md) - -——>——>——>——>[Overview of Mini and Small Systems](device-dev/quick-start/quickstart-lite-overview.md) - -——>——>——>——>[Environment Setup for Mini and Small Systems](device-dev/quick-start/quickstart-lite-env-setup.md) - -——>——>——>——>——>[Environment Setup Overview](device-dev/quick-start/quickstart-lite-env-setup-overview.md) - -——>——>——>——>——>[Environment Setup FAQs](device-dev/quick-start/quickstart-lite-env-setup-faqs.md) - -——>——>——>——>[Running Hello World](device-dev/quick-start/quickstart-lite-steps.md) - -——>——>——>——>——>[Hi3861 Development Board](device-dev/quick-start/quickstart-lite-steps-hi3861.md) - -——>——>——>——>——>——>[Setting Up the Environment](device-dev/quick-start/quickstart-lite-steps-hi3861-setting.md) - -——>——>——>——>——>——>[Running a Hello World Program](device-dev/quick-start/quickstart-lite-steps-hi3816-running.md) - -——>——>——>——>——>——>[FAQs](device-dev/quick-start/quickstart-lite-steps-hi3861-faqs.md) - -——>——>——>——>——>[Hi3516 Development Board](device-dev/quick-start/quickstart-lite-steps-hi3516.md) - -——>——>——>——>——>——>[Setting Up the Environment](device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md) - -——>——>——>——>——>——>[Running a Hello OHOS Program](device-dev/quick-start/quickstart-lite-steps-hi3516-running.md) - -——>——>——>——>——>——>[FAQs](device-dev/quick-start/quickstart-lite-steps-hi3516-faqs.md) - -——>——>——>——>——>[Hi3518 Development Board](device-dev/quick-start/quickstart-lite-steps-hi3518.md) - -——>——>——>——>——>——>[Setting Up the Environment](device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md) - -——>——>——>——>——>——>[Running a Hello OHOS Program](device-dev/quick-start/quickstart-lite-steps-hi3518-running.md) - -——>——>——>——>——>——>[FAQs](device-dev/quick-start/quickstart-lite-steps-hi3518-faqs.md) - -——>——>——>——>[Introduction](device-dev/quick-start/quickstart-lite-introduction.md) - -——>——>——>——>——>[Hi3861 Development Board](device-dev/quick-start/quickstart-lite-introduction-hi3861.md) - -——>——>——>——>——>[Hi3516 Development Board](device-dev/quick-start/quickstart-lite-introduction-hi3516.md) - -——>——>——>——>——>[Hi3518 Development Board](device-dev/quick-start/quickstart-lite-introduction-hi3518.md) - -——>——>——>[Standard System](device-dev/quick-start/quickstart-standard.md) - -——>——>——>——>[Standard System Introduction](device-dev/quick-start/quickstart-standard-overview.md) - -——>——>——>——>[Running an Image](device-dev/quick-start/quickstart-standard-running.md) - -——>——>——>——>[FAQs](device-dev/quick-start/quickstart-standard-faqs.md) - -——>——> Compatibility and Security - -——>——>——> [Privacy and Security](device-dev/security/security.md) - -——>——>——>——> [Privacy Protection](device-dev/security/security-privacy-protection.md) - -——>——>——>——> [Security Guidelines](device-dev/security/security-guidelines-overall.md) - -——>——> Porting - -——>——>——>[Mini System SoC Porting Guide](device-dev/porting/porting-minichip.md) - -——>——>——>——>[Porting Preparations](device-dev/porting/porting-chip-prepare.md) - -——>——>——>——>——>[Before You Start](device-dev/porting/oem_transplant_chip_prepare_knows.md) - -——>——>——>——>——>[Building Adaptation Process](device-dev/porting/porting-chip-prepare-process.md) - -——>——>——>——>[Kernel Porting](device-dev/porting/porting-chip-kernel.md) - -——>——>——>——>——>[Overview](device-dev/porting/porting-chip-kernel-overview.md) - -——>——>——>——>——>[Basic Kernel Adaptation](device-dev/porting/porting-chip-kernel-adjustment.md) - -——>——>——>——>——>[Kernel Porting Verification](device-dev/porting/porting-chip-kernel-verify.md) - -——>——>——>——>[Board-Level OS Porting](device-dev/porting/porting-chip-board.md) - -——>——>——>——>——>[Overview](device-dev/porting/porting-chip-board-overview.md) - -——>——>——>——>——>[Board-Level Driver Adaptation](device-dev/porting/porting-chip-board-driver.md) - -——>——>——>——>——>[Implementation of APIs at the HAL](device-dev/porting/porting-chip-board-hal.md) - -——>——>——>——>——>[System Modules](device-dev/porting/porting-chip-board-component.md) - -——>——>——>——>——>[lwIP Module Adaptation](device-dev/porting/porting-chip-board-lwip.md) - -——>——>——>——>——>[Third-party Module Adaptation](device-dev/porting/porting-chip-board-bundle.md) - -——>——>——>——>——>[XTS](device-dev/porting/porting-chip-board-xts.md) - -——>——>——>——>[FAQs](device-dev/porting/porting-chip-faqs.md) - -——>——>——>[Small System SoC Porting Guide](device-dev/porting/porting-smallchip.md) - -——>——>——>——>[Porting Preparations](device-dev/porting/porting-smallchip-prepare.md) - -——>——>——>——>——>[Before You Start](device-dev/porting/porting-smallchip-prepare-needs.md) - -——>——>——>——>——>[Compilation and Building](device-dev/porting/porting-smallchip-prepare-building.md) - -——>——>——>——>[Kernel Porting](device-dev/porting/porting-smallchip-kernel.md) - -——>——>——>——>——>[LiteOS Cortex-A](device-dev/porting/porting-smallchip-kernel-a.md) - -——>——>——>——>——>[Linux Kernel](device-dev/porting/porting-smallchip-kernel-linux.md) - -——>——>——>——>[Driver Porting](device-dev/porting/porting-smallchip-driver.md) - -——>——>——>——>——>[Overview](device-dev/porting/porting-smallchip-driver-overview.md) - -——>——>——>——>——>[Platform Driver Porting](device-dev/porting/porting-smallchip-driver-plat.md) - -——>——>——>——>——>[Device Driver Porting](device-dev/porting/porting-smallchip-driver-oom.md) - -——>——>——>[Standard System Porting Guide](device-dev/porting/standard-system-porting-guide.md) - -——>——>——>——>[Standard System Porting Guide](device-dev/porting/standard-system-porting-guide.md) - -——>——>——>——>[A Method for Rapidly Porting the OpenHarmony Linux Kernel](device-dev/porting/porting-linux-kernel.md) - -——>——>——>[Third-Party Library Porting Guide for Mini and Small Systems](device-dev/porting/porting-thirdparty.md) - -——>——>——>——>[Overview](device-dev/porting/porting-thirdparty-overview.md) - -——>——>——>——>[Porting a Library Built Using CMake](device-dev/porting/porting-thirdparty-cmake.md) - -——>——>——>——>[Porting a Library Built Using Makefile](device-dev/porting/porting-thirdparty-makefile.md) - -——>——> Subsystem Development - -——>——>——> [Kernel](device-dev/kernel/kernel.md) - -——>——>——>——> [Kernel for the Mini System](device-dev/kernel/kernel-mini.md) - -——>——>——>——>——> [Kernel Overview](device-dev/kernel/kernel-mini-overview.md) - -——>——>——>——>——> [Basic Kernel](device-dev/kernel/kernel-mini-basic.md) - -——>——>——>——>——>——> [Interrupt Management](device-dev/kernel/kernel-mini-basic-interrupt.md) - -——>——>——>——>——>——> [Task Management](device-dev/kernel/kernel-mini-basic-task.md) - -——>——>——>——>——>——> [Memory Management](device-dev/kernel/kernel-mini-basic-memory.md) - -——>——>——>——>——>——>——> [Basic Concepts](device-dev/kernel/kernel-mini-basic-memory-basic.md) - -——>——>——>——>——>——>——> [Static Memory](device-dev/kernel/kernel-mini-basic-memory-static.md) - -——>——>——>——>——>——>——> [Dynamic Memory](device-dev/kernel/kernel-mini-basic-memory-dynamic.md) - -——>——>——>——>——>——> [Kernel Communication Mechanisms](device-dev/kernel/kernel-mini-basic-ipc.md) - -——>——>——>——>——>——>——> [Event](device-dev/kernel/kernel-mini-basic-ipc-event.md) - -——>——>——>——>——>——>——> [Mutex](device-dev/kernel/kernel-mini-basic-ipc-mutex.md) - -——>——>——>——>——>——>——> [Queue](device-dev/kernel/kernel-mini-basic-ipc-queue.md) - -——>——>——>——>——>——>——> [Semaphore](device-dev/kernel/kernel-mini-basic-ipc-sem.md) - -——>——>——>——>——>——> [Time Management](device-dev/kernel/kernel-basic-mini-time.md) - -——>——>——>——>——>——> [Software Timer](device-dev/kernel/kernel-mini-basic-soft.md) - -——>——>——>——>——> [Extended Components](device-dev/kernel/kernel-mini-extend.md) - -——>——>——>——>——>——> [C++ Support](device-dev/kernel/kernel-mini-extend-support.md) - -——>——>——>——>——>——> [CPUP](device-dev/kernel/kernel-mini-extend-cpup.md) - -——>——>——>——>——>——> [Dynamic Loading](kernel-mini-extend-dynamic-loading.md) - -——>——>——>——>——>——> [File System](device-dev/kernel/kernel-mini-extend-file.md) - -——>——>——>——>——>——>——> [FAT](device-dev/kernel/kernel-mini-extend-file-fat.md) - -——>——>——>——>——>——>——> [LittleFS](device-dev/kernel/kernel-mini-extend-file-lit.md) - -——>——>——>——>——> [Kernel Debugging](device-dev/kernel/kernel-memory-inner.md) - -——>——>——>——>——>——> [Memory Debugging](device-dev/kernel/kernel-mini-memory-debug.md) - -——>——>——>——>——>——>——> [Memory Information Statistics](device-dev/kernel/kernel-mini-memory-debug-mes.md) - -——>——>——>——>——>——>——> [Memory Leak Check](device-dev/kernel/kernel-mini-imemory-debug-det.md) - -——>——>——>——>——>——>——> [Memory Corruption Check](device-dev/kernel/kernel-mini-memory-debug-cet.md) - -——>——>——>——>——>——> [Exception Debugging](device-dev/kernel/kernel-mini-memory-exception.md) - -——>——>——>——>——>——> [Trace](device-dev/kernel/kernel-mini-memory-trace.md) - -——>——>——>——>——>——> [LMS](device-dev/kernel/kernel-mini-debug-lms.md) - -——>——>——>——>——> [Appendix](device-dev/kernel/kernel-mini-app.md) - -——>——>——>——>——>——> [Kernel Coding Specification](device-dev/kernel/kernel-mini-appx-code.md) - -——>——>——>——>——>——> [Basic Data Structure](device-dev/kernel/kernel-mini-appx-data.md) - -——>——>——>——>——>——>——> [Doubly Linked List](device-dev/kernel/kernel-mini-appx-data-list.md) - -——>——>——>——>——>——> [Standard Libraries](device-dev/kernel/kernel-mini-appx-lib.md) - -——>——>——>——>——>——>——> [CMSIS Support](device-dev/kernel/kernel-mini-appx-lib-cmsis.md) - -——>——>——>——>——>——>——> [POSIX Support](device-dev/kernel/kernel-mini-appx-lib-posix.md) - -——>——>——>——> [Kernel for the Small System](device-dev/kernel/kernel-small.md) - -——>——>——>——>——> [Kernel Overview](device-dev/kernel/kernel-small-overview.md) - -——>——>——>——>——> [Kernel Startup](device-dev/kernel/kernel-small-start.md) - -——>——>——>——>——>——> [Startup in Kernel Mode](device-dev/kernel/kernel-small-start-kernel.md) - -——>——>——>——>——>——> [Startup in User Mode](device-dev/kernel/kernel-small-start-user.md) - -——>——>——>——>——> [Basic Kernel](device-dev/kernel/kernel-small-basics.md) - -——>——>——>——>——>——> [Interrupt and Exception Handling](device-dev/kernel/kernel-small-basic-interrupt.md) - -——>——>——>——>——>——> [Process Management](device-dev/kernel/kernel-small-basic-process.md) - -——>——>——>——>——>——>——> [Process](device-dev/kernel/kernel-small-basic-process-process.md) - -——>——>——>——>——>——>——> [Task](device-dev/kernel/kernel-small-basic-process-thread.md) - -——>——>——>——>——>——>——> [Scheduler](device-dev/kernel/kernel-small-basic-process-scheduler.md) - -——>——>——>——>——>——> [Memory Management](device-dev/kernel/kernel-small-basic-memory.md) - -——>——>——>——>——>——>——> [Heap Memory Management](device-dev/kernel/kernel-small-basic-memory-heap.md) - -——>——>——>——>——>——>——> [Physical Memory Management](device-dev/kernel/kernel-small-basic-memory-physical.md) - -——>——>——>——>——>——>——> [Virtual Memory Management](device-dev/kernel/kernel-small-basic-memory-virtual.md) - -——>——>——>——>——>——>——> [Virtual-to-Physical Mapping](device-dev/kernel/kernel-small-basic-inner-reflect.md) - -——>——>——>——>——>——> [Kernel Communication Mechanisms](device-dev/kernel/kernel-small-basic-trans.md) - -——>——>——>——>——>——>——> [Event](device-dev/kernel/kernel-small-basic-trans-event.md) - -——>——>——>——>——>——>——> [Semaphore](device-dev/kernel/kernel-small-basic-trans-semaphore.md) - -——>——>——>——>——>——>——> [Mutex](device-dev/kernel/kernel-small-basic-trans-mutex.md) - -——>——>——>——>——>——>——> [Queue](device-dev/kernel/kernel-small-basic-trans-queue.md) - -——>——>——>——>——>——>——> [RW Lock](device-dev/kernel/kernel-small-basic-trans-rwlock.md) - -——>——>——>——>——>——>——> [Futex](device-dev/kernel/kernel-small-basic-trans-user-mutex.md) - -——>——>——>——>——>——>——> [Signal](device-dev/kernel/kernel-small-basic-trans-user-signal.md) - -——>——>——>——>——>——> [Time Management](device-dev/kernel/kernel-small-basic-time.md) - -——>——>——>——>——>——> [Software Timer](device-dev/kernel/kernel-small-basic-softtimer.md) - -——>——>——>——>——>——> [Atomic Operation](device-dev/kernel/kernel-small-basic-atomic.md) - -——>——>——>——>——> [Extended Components](device-dev/kernel/kernel-small-bundles.md) - -——>——>——>——>——>——> [System Call](device-dev/kernel/kernel-small-bundles-system.md) - -——>——>——>——>——>——> [Dynamic Loading and Linking](device-dev/kernel/kernel-small-bundles-linking.md) - -——>——>——>——>——>——> [Virtual Dynamic Shared Object](device-dev/kernel/kernel-small-bundles-share.md) - -——>——>——>——>——>——> [LiteIPC](device-dev/kernel/kernel-small-bundles-ipc.md) - -——>——>——>——>——>——> [File Systems](device-dev/kernel/kernel-small-bundles-fs.md) - -——>——>——>——>——>——>——> [Virtual File System](device-dev/kernel/kernel-small-bundles-fs-virtual.md) - -——>——>——>——>——>——>——> [Supported File Systems](device-dev/kernel/kernel-small-bundles-fs-support.md) - -——>——>——>——>——>——>——>——> [FAT](device-dev/kernel/kernel-small-bundles-fs-support-fat.md) - -——>——>——>——>——>——>——>——> [JFFS2](device-dev/kernel/kernel-small-bundles-fs-support-jffs2.md) - -——>——>——>——>——>——>——>——> [NFS](device-dev/kernel/kernel-small-bundles-fs-support-nfs.md) - -——>——>——>——>——>——>——>——> [Ramfs](device-dev/kernel/kernel-small-bundles-fs-support-ramfs.md) - -——>——>——>——>——>——>——>——> [procfs](device-dev/kernel/kernel-small-bundles-fs-support-procfs.md) - -——>——>——>——>——>——>——> [File System Adaptation](device-dev/kernel/kernel-small-bundles-fs-new.md) - -——>——>——>——>——> [Debugging and Tools](device-dev/kernel/kernel-small-debug.md) - -——>——>——>——>——>——> [Shell](device-dev/kernel/kernel-small-debug-shell.md) - -——>——>——>——>——>——>——> [Introduction to the Shell](device-dev/kernel/kernel-small-debug-shell-overview.md) - -——>——>——>——>——>——>——> [Shell Command Development Guidelines](device-dev/kernel/kernel-small-debug-shell-guide.md) - -——>——>——>——>——>——>——> [Shell Command Programming Example](device-dev/kernel/kernel-small-debug-shell-build.md) - -——>——>——>——>——>——>——> [Shell Command Reference](device-dev/kernel/kernel-small-debug-shell-details.md) - -——>——>——>——>——>——>——>——> [System Commands](device-dev/kernel/kernel-small-debug-shell-cmd.md) - -——>——>——>——>——>——>——>——>——> [cpup](device-dev/kernel/kernel-small-debug-shell-cmd-cpup.md) - -——>——>——>——>——>——>——>——>——> [date](device-dev/kernel/kernel-small-debug-shell-cmd-date.md) - -——>——>——>——>——>——>——>——>——> [dmesg](device-dev/kernel/kernel-small-debug-shell-cmd-dmesg.md) - -——>——>——>——>——>——>——>——>——> [exec](device-dev/kernel/kernel-small-debug-shell-cmd-exec.md) - -——>——>——>——>——>——>——>——>——> [free](device-dev/kernel/kernel-small-debug-shell-cmd-free.md) - -——>——>——>——>——>——>——>——>——> [help](device-dev/kernel/kernel-small-debug-shell-cmd-help.md) - -——>——>——>——>——>——>——>——>——> [hwi](device-dev/kernel/kernel-small-debug-shell-cmd-hwi.md) - -——>——>——>——>——>——>——>——>——> [kill](device-dev/kernel/kernel-small-debug-shell-cmd-kill.md) - -——>——>——>——>——>——>——>——>——> [log](device-dev/kernel/kernel-small-debug-shell-cmd-log.md) - -——>——>——>——>——>——>——>——>——> [memcheck](device-dev/kernel/kernel-small-debug-shell-cmd-memcheck.md) - -——>——>——>——>——>——>——>——>——> [oom](device-dev/kernel/kernel-small-debug-shell-cmd-oom.md) - -——>——>——>——>——>——>——>——>——> [pmm](device-dev/kernel/kernel-small-debug-shell-cmd-pmm.md) - -——>——>——>——>——>——>——>——>——> [reset](device-dev/kernel/kernel-small-debug-shell-cmd-reset.md) - -——>——>——>——>——>——>——>——>——> [sem](device-dev/kernel/kernel-small-debug-shell-cmd-sem.md) - -——>——>——>——>——>——>——>——>——> [stack](device-dev/kernel/kernel-small-debug-shell-cmd-stack.md) - -——>——>——>——>——>——>——>——>——> [su](device-dev/kernel/kernel-small-debug-shell-cmd-su.md) - -——>——>——>——>——>——>——>——>——> [swtmr](device-dev/kernel/kernel-small-debug-shell-cmd-swtmr.md) - -——>——>——>——>——>——>——>——>——> [systeminfo](device-dev/kernel/kernel-small-debug-shell-cmd-sysinfo.md) - -——>——>——>——>——>——>——>——>——> [task](device-dev/kernel/kernel-small-debug-shell-cmd-task.md) - -——>——>——>——>——>——>——>——>——> [uname](device-dev/kernel/kernel-small-debug-shell-cmd-uname.md) - -——>——>——>——>——>——>——>——>——> [vmm](device-dev/kernel/kernel-small-debug-shell-cmd-vmm.md) - -——>——>——>——>——>——>——>——>——> [watch](device-dev/kernel/kernel-small-debug-shell-cmd-watch.md) - -——>——>——>——>——>——>——>——>——>[reboot](device-dev/kernel/kernel-small-debug-shell-cmd-reboot.md) - -——>——>——>——>——>——>——>——>——>[top](device-dev/kernel/kernel-small-debug-shell-cmd-top.md) - -——>——>——>——>——>——>——>——> [File Commands](device-dev/kernel/kernel-small-debug-shell-file.md) - -——>——>——>——>——>——>——>——>——> [cat](device-dev/kernel/kernel-small-debug-shell-file-cat.md) - -——>——>——>——>——>——>——>——>——> [cd](device-dev/kernel/kernel-small-debug-shell-file-cd.md) - -——>——>——>——>——>——>——>——>——> [chgrp](device-dev/kernel/kernel-small-debug-shell-file-chgrp.md) - -——>——>——>——>——>——>——>——>——> [chmod](device-dev/kernel/kernel-small-debug-shell-file-chmod.md) - -——>——>——>——>——>——>——>——>——> [chown](device-dev/kernel/kernel-small-debug-shell-file-chown.md) - -——>——>——>——>——>——>——>——>——> [cp](device-dev/kernel/kernel-small-debug-shell-file-cp.md) - -——>——>——>——>——>——>——>——>——> [format](device-dev/kernel/kernel-small-debug-shell-file-format.md) - -——>——>——>——>——>——>——>——>——> [ls](device-dev/kernel/kernel-small-debug-shell-file-ls.md) - -——>——>——>——>——>——>——>——>——> [lsfd](device-dev/kernel/kernel-small-debug-shell-file-lsfd.md) - -——>——>——>——>——>——>——>——>——> [mkdir](device-dev/kernel/kernel-small-debug-shell-file-mkdir.md) - -——>——>——>——>——>——>——>——>——> [mount](device-dev/kernel/kernel-small-debug-shell-file-mount.md) - -——>——>——>——>——>——>——>——>——> [partinfo](device-dev/kernel/kernel-small-debug-shell-file-partinfo.md) - -——>——>——>——>——>——>——>——>——> [partition](device-dev/kernel/kernel-small-debug-shell-file-partition.md) - -——>——>——>——>——>——>——>——>——> [pwd](device-dev/kernel/kernel-small-debug-shell-file-pwd.md) - -——>——>——>——>——>——>——>——>——> [rm](device-dev/kernel/kernel-small-debug-shell-file-rm.md) - -——>——>——>——>——>——>——>——>——> [rmdir](device-dev/kernel/kernel-small-debug-shell-file-rmdir.md) - -——>——>——>——>——>——>——>——>——> [statfs](device-dev/kernel/kernel-small-debug-shell-file-statfs.md) - -——>——>——>——>——>——>——>——>——> [sync](device-dev/kernel/kernel-small-debug-shell-file-sync.md) - -——>——>——>——>——>——>——>——>——> [touch](device-dev/kernel/kernel-small-debug-shell-file-touch.md) - -——>——>——>——>——>——>——>——>——> [writeproc](device-dev/kernel/kernel-small-debug-shell-file-write.md) - -——>——>——>——>——>——>——>——>——> [umount](device-dev/kernel/kernel-small-debug-shell-file-umount.md) - -——>——>——>——>——>——>——>——>——>[du](device-dev/kernel/kernel-small-debug-shell-file-du.md) - -——>——>——>——>——>——>——>——>——>[mv](device-dev/kernel/kernel-small-debug-shell-file-mv.md) - -——>——>——>——>——>——>——>——> [Network Commands](device-dev/kernel/kernel-small-debug-shell-net.md) - -——>——>——>——>——>——>——>——>——> [arp](device-dev/kernel/kernel-small-debug-shell-net-arp.md) - -——>——>——>——>——>——>——>——>——> [dhclient](device-dev/kernel/kernel-small-debug-shell-net-dhclient.md) - -——>——>——>——>——>——>——>——>——> [ifconfig](device-dev/kernel/kernel-small-debug-shell-net-ifconfig.md) - -——>——>——>——>——>——>——>——>——> [ipdebug](device-dev/kernel/kernel-small-debug-shell-net-ipdebug.md) - -——>——>——>——>——>——>——>——>——> [netstat](device-dev/kernel/kernel-small-debug-shell-net-netstat.md) - -——>——>——>——>——>——>——>——>——> [ntpdate](device-dev/kernel/kernel-small-debug-shell-net-ntpdate.md) - -——>——>——>——>——>——>——>——>——> [ping](device-dev/kernel/kernel-small-debug-shell-net-ping.md) - -——>——>——>——>——>——>——>——>——> [ping6](device-dev/kernel/kernel-small-debug-shell-net-ping6.md) - -——>——>——>——>——>——>——>——>——> [telnet](device-dev/kernel/kernel-small-debug-shell-net-telnet.md) - -——>——>——>——>——>——>——>——>——> [tftp](device-dev/kernel/kernel-small-debug-shell-net-tftp.md) - -——>——>——>——>——>——>——> [Magic Key](device-dev/kernel/kernel-small-debug-shell-magickey.md) - -——>——>——>——>——>——>——> [User-Mode Exception Information](device-dev/kernel/kernel-small-debug-shell-error.md) - -——>——>——>——>——>——> [Trace](device-dev/kernel/kernel-small-debug-trace.md) - -——>——>——>——>——>——> [Process Commissioning](device-dev/kernel/kernel-small-debug-process.md) - -——>——>——>——>——>——>——> [CPUP](device-dev/kernel/kernel-small-debug-process-cpu.md) - -——>——>——>——>——>——> [Kernel-Mode Memory Debugging](device-dev/kernel/kernel-small-debug-memory.md) - -——>——>——>——>——>——>——> [Memory Information Statistics](device-dev/kernel/kernel-small-debug-memory-info.md) - -——>——>——>——>——>——>——> [Memory Leak Check](device-dev/kernel/kernel-small-debug-memory-leak.md) - -——>——>——>——>——>——>——> [Memory Corruption Check](device-dev/kernel/kernel-small-debug-memory-corrupt.md) - -——>——>——>——>——>——>[User-Mode Memory Debugging](device-dev/kernel/kernel-small-debug-user.md) - -——>——>——>——>——>——>——>[Basic Concepts](device-dev/kernel/kernel-small-debug-user-concept.md) - -——>——>——>——>——>——>——>[Working Principles](device-dev/kernel/kernel-small-debug-user-function.md) - -——>——>——>——>——>——>——>[Usage](device-dev/kernel/kernel-small-debug-user-guide.md) - -——>——>——>——>——>——>——>——>[API Description](device-dev/kernel/kernel-small-debug-user-guide-api.md) - -——>——>——>——>——>——>——>——>[How to Use](device-dev/kernel/kernel-small-debug-user-guide-use.md) - -——>——>——>——>——>——>——>——>——>[Calling APIs](device-dev/kernel/kernel-small-debug-user-guide-use-api.md) - -——>——>——>——>——>——>——>——>——>[Using the CLI](device-dev/kernel/kernel-small-debug-user-guide-use-cli.md) - -——>——>——>——>——>——>——>[Typical Memory Problems](device-dev/kernel/kernel-small-debug-user-faqs.md) - -——>——>——>——>——>——> [Other Kernel Debugging Methods](device-dev/kernel/kernel-small-debug-other.md) - -——>——>——>——>——>——>——> [Dying Gasp](device-dev/kernel/kernel-small-debug-trace-other-lastwords.md) - -——>——>——>——>——>——>——> [Common Fault Locating Methods](device-dev/kernel/kernel-small-debug-trace-other-faqs.md) - -——>——>——>——>——> [Appendix](device-dev/kernel/kernel-small-apx.md) - -——>——>——>——>——>——> [Basic Data Structure](device-dev/kernel/kernel-small-apx-structure.md) - -——>——>——>——>——>——>——> [Doubly Linked List](device-dev/kernel/kernel-small-apx-dll.md) - -——>——>——>——>——>——>——> [Bitwise Operation](device-dev/kernel/kernel-small-apx-bitwise.md) - -——>——>——>——>——>——> [Standard Library](device-dev/kernel/kernel-small-apx-library.md) - -——>——>——>——> [Kernel for Standard System](device-dev/kernel/kernel-standard.md) - -——>——>——>——>——> [Linux Kernel Overview](device-dev/kernel/kernel-standard-overview.md) - -——>——>——>——>——> [Guidelines for Using Patches on OpenHarmony Development Boards](device-dev/kernel/kernel-standard-patch.md) - -——>——>——>——>——> [Guidelines for Compiling and Building the Linux Kernel](device-dev/kernel/kernel-standard-build.md) - -——>——>——> [Driver](device-dev/driver/driver.md) - -——>——>——>——>[HDF](device-dev/driver/driver-hdf.md) - -——>——>——>——>——>[HDF Overview](device-dev/driver/driver-hdf-overview.md) - -——>——>——>——>——>[Driver Development](device-dev/driver/driver-hdf-development.md) - -——>——>——>——>——>[Driver Service Management](device-dev/driver/driver-hdf-servicemanage.md) - -——>——>——>——>——>[Driver Message Mechanism Management](device-dev/driver/driver-hdf-message-management.md) - -——>——>——>——>——>[Driver Configuration Management](device-dev/driver/driver-hdf-manage.md) - -——>——>——>——>——>[HDF Development Example](device-dev/driver/driver-hdf-sample.md) - -——>——>——>——>[Platform Driver Development](device-dev/driver/driver-develop.md) - -——>——>——>——>——>[ADC](device-dev/driver/driver-platform-adc-develop.md) - -——>——>——>——>——>[GPIO](device-dev/driver/driver-platform-gpio-develop.md) - -——>——>——>——>——>[HDMI](device-dev/driver/driver-platform-hdmi-develop.md) - -——>——>——>——>——>[I2C](device-dev/driver/driver-platform-i2c-develop.md) - -——>——>——>——>——>[I3C](device-dev/driver/driver-platform-i3c-develop.md) - -——>——>——>——>——>[MIPI CSI](device-dev/driver/driver-platform-mipicsi-develop.md) - -——>——>——>——>——>[MIPI DSI](device-dev/driver/driver-platform-mipidsi-develop.md) - -——>——>——>——>——>[MMC](device-dev/driver/driver-platform-mmc-develop.md) - -——>——>——>——>——>[PWM](device-dev/driver/driver-platform-pwm-develop.md) - -——>——>——>——>——>[RTC](device-dev/driver/driver-platform-rtc-develop.md) - -——>——>——>——>——>[SDIO](device-dev/driver/driver-platform-sdio-develop.md) - -——>——>——>——>——>[SPI](device-dev/driver/driver-platform-spi-develop.md) - -——>——>——>——>——>[UART](device-dev/driver/driver-platform-uart-develop.md) - -——>——>——>——>——>[Watchdog](device-dev/driver/driver-platform-watchdog-develop.md) - -——>——>——>——>[Driver Platform Usage](device-dev/driver/driver-platform.md) - -——>——>——>——>——>[ADC](device-dev/driver/driver-platform-adc-des.md) - -——>——>——>——>——>[GPIO](device-dev/driver/driver-platform-gpio-des.md) - -——>——>——>——>——>[HDMI](device-dev/driver/driver-platform-hdmi-des.md) - -——>——>——>——>——>[I2C](device-dev/driver/driver-platform-i2c-des.md) - -——>——>——>——>——>[I3C](device-dev/driver/driver-platform-i3c-des.md) - -——>——>——>——>——>[MIPI CSI](device-dev/driver/driver-platform-mipicsi-des.md) - -——>——>——>——>——>[MIPI DSI](device-dev/driver/driver-platform-mipidsi-des.md) - -——>——>——>——>——>[PWM](device-dev/driver/driver-platform-pwm-des.md) - -——>——>——>——>——>[RTC](device-dev/driver/driver-platform-rtc-des.md) - -——>——>——>——>——>[SDIO](device-dev/driver/driver-platform-sdio-des.md) - -——>——>——>——>——>[SPI](device-dev/driver/driver-platform-spi-des.md) - -——>——>——>——>——>[UART](device-dev/driver/driver-platform-uart-des.md) - -——>——>——>——>——>[Watchdog](device-dev/driver/driver-platform-watchdog-des.md) - -——>——>——>——>[Peripheral Driver Usage](device-dev/driver/driver-peripherals.md) - -——>——>——>——>——>[LCD](device-dev/driver/driver-peripherals-lcd-des.md) - -——>——>——>——>——>[Touchscreen](device-dev/driver/driver-peripherals-touch-des.md) - -——>——>——>——>——>[Sensor](device-dev/driver/driver-peripherals-sensor-des.md) - -——>——>——>——>——>[WLAN](device-dev/driver/driver-peripherals-external-des.md) - -——>——>——>——>——>[Audio](device-dev/driver/driver-peripherals-audio-des.md) - -——>——>——>——>——>[USB](device-dev/driver/driver-peripherals-usb-des.md) - -——>——>——>——>——>[Camera](device-dev/driver/driver-peripherals-camera-des.md) - -——>——>——> [Compilation and Building](device-dev/subsystems/subsys-build.md) - -——>——>——>——> [Building Guidelines for Mini and Small Systems](device-dev/subsystems/subsys-build-mini-lite.md) - -——>——>——>——> [Building Guidelines for Standard Systems](device-dev/subsystems/subsys-build-standard-large.md) - -——>——>——>——>[Build System Coding Specifications and Best Practices](device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md) - -——>——>——> [Distributed Remote Startup](device-dev/subsystems/subsys-remote-start.md) - -——>——>——> [Graphics](device-dev/subsystems/subsys-graphics.md) - -——>——>——>——> [Graphics](device-dev/subsystems/subsys-graphics-overview.md) - -——>——>——>——> [Development Guidelines on Container Components](device-dev/subsystems/subsys-graphics-container-guide.md) - -——>——>——>——> [Development Guidelines on Layout Container Components](device-dev/subsystems/subsys-graphics-layout-guide.md) - -——>——>——>——> [Development Guidelines on Common Components](device-dev/subsystems/subsys-graphics-common-guide.md) - -——>——>——>——> [Development Guidelines on Animators](device-dev/subsystems/subsys-graphics-animation-guide.md) - -——>——>——> [Multimedia](device-dev/subsystems/subsys-multimedia.md) - -——>——>——>——> [Camera](device-dev/subsystems/subsys-multimedia-camera.md) - -——>——>——>——>——> [Overview](device-dev/subsystems/subsys-multimedia-camera-overview.md) - -——>——>——>——>——> [Development Guidelines on Photographing](device-dev/subsystems/subsys-multimedia-camera-photo-guide.md) - -——>——>——>——>——> [Development Guidelines on Video Recording](device-dev/subsystems/subsys-multimedia-camera-record-guide.md) - -——>——>——>——>——> [Development Guidelines on Previewing](device-dev/subsystems/subsys-multimedia-camera-preview-guide.md) - -——>——>——>——> [Audio/Video](device-dev/subsystems/subsys-multimedia-video.md) - -——>——>——>——>——> [Overview](device-dev/subsystems/subsys-multimedia-video-overview.md) - -——>——>——>——>——> [Development Guidelines on Media Playback](device-dev/subsystems/subsys-multimedia-video-play-guide.md) - -——>——>——>——>——> [Development Guidelines on Media Recording](device-dev/subsystems/subsys-multimedia-video-record-guide.md) - -——>——>——> [Utils](device-dev/subsystems/subsys-utils.md) - -——>——>——>——> [Utils Overview](device-dev/subsystems/subsys-utils-overview.md) - -——>——>——>——> [Utils Development Guidelines](device-dev/subsystems/subsys-utils-guide.md) - -——>——>——>——> [Utils FAQ](device-dev/subsystems/subsys-utils-faqs.md) - -——>——>——> [AI Framework](device-dev/subsystems/subsys-aiframework.md) - -——>——>——>——> [AI Engine Framework](device-dev/subsystems/subsys-aiframework-guide.md) - -——>——>——>——> [Development Environment](device-dev/subsystems/subsys-aiframework-envbuild.md) - -——>——>——>——> [Technical Specifications](device-dev/subsystems/subsys-aiframework-tech.md) - -——>——>——>——>——> [Code Management](device-dev/subsystems/subsys-aiframework-tech-codemanage.md) - -——>——>——>——>——> [Naming](device-dev/subsystems/subsys-aiframework-tech-name.md) - -——>——>——>——>——> [API Development](device-dev/subsystems/subsys-aiframework-tech-interface.md) - -——>——>——>——> [Development Guidelines](device-dev/subsystems/subsys-aiframework-devguide.md) - -——>——>——>——>——> [SDK](device-dev/subsystems/subsys-aiframework-devguide-sdk.md) - -——>——>——>——>——> [Plug-in](device-dev/subsystems/subsys-aiframework-devguide-plugin.md) - -——>——>——>——>——> [Configuration File](device-dev/subsystems/subsys-aiframework-devguide-conf.md) - -——>——>——>——> [Development Examples](device-dev/subsystems/subsys-aiframework-demo.md) - -——>——>——>——>——> [KWS SDK](device-dev/subsystems/subsys-aiframework-demo-sdk.md) - -——>——>——>——>——> [KWS Plug-in](device-dev/subsystems/subsys-aiframework-demo-plugin.md) - -——>——>——>——>——> [KWS Configuration File](device-dev/subsystems/subsys-aiframework-demo-conf.md) - -——>——>——> [Sensor](device-dev/subsystems/subsys-sensor.md) - -——>——>——>——> [Sensor Overview](device-dev/subsystems/subsys-sensor-overview.md) - -——>——>——>——> [Sensor Usage Guidelines](device-dev/subsystems/subsys-sensor-guide.md) - -——>——>——>——> [Sensor Usage Example](device-dev/subsystems/subsys-sensor-demo.md) - -——>——>——> [Application Framework](device-dev/subsystems/subsys-application-framework.md) - -——>——>——>——> [Overview](device-dev/subsystems/subsys-application-framework-overview.md) - -——>——>——>——> [Setting Up a Development Environment](device-dev/subsystems/subsys-application-framework-envbuild.md) - -——>——>——>——> [Development Guidelines](device-dev/subsystems/subsys-application-framework-guide.md) - -——>——>——>——> [Development Example](device-dev/subsystems/subsys-application-framework-demo.md) - -——>——>——> [OTA Update](device-dev/subsystems/subsys-ota-guide.md) - -——>——>——>[Telephony Service](device-dev/subsystems/subsys-tel.md) - -——>——>——> [Security](device-dev/subsystems/subsys-security.md) - -——>——>——>——> [Overview](device-dev/subsystems/subsys-security-overview.md) - -——>——>——>——> [Development Guidelines on Application Signature Verification](device-dev/subsystems/subsys-security-sigverify.md) - -——>——>——>——> [Development Guidelines on Application Permission Management](device-dev/subsystems/subsys-security-rightmanagement.md) - -——>——>——>——> [Development Guidelines on IPC Authentication](device-dev/subsystems/subsys-security-communicationverify.md) - -——>——>——> [Startup](device-dev/subsystems/subsys-boot.md) - -——>——>——>——> [Startup](device-dev/subsystems/subsys-boot-overview.md) - -——>——>——>——> [init Module](device-dev/subsystems/subsys-boot-init.md) - -——>——>——>——> [appspawn Module](device-dev/subsystems/subsys-boot-appspawn.md) - -——>——>——>——> [bootstrap Module](device-dev/subsystems/subsys-boot-bootstrap.md) - -——>——>——>——> [syspara Module](device-dev/subsystems/subsys-boot-syspara.md) - -——>——>——>——> [FAQs](device-dev/subsystems/subsys-boot-faqs.md) - -——>——>——>——> [Reference](device-dev/subsystems/subsys-boot-ref.md) - -——>——>——> [DFX](device-dev/subsystems/subsys-dfx.md) - -——>——>——>——>[DFX Overview](device-dev/subsystems/subsys-dfx-overview.md) - -——>——>——>——>[HiLog Development](device-dev/subsystems/subsys-dfx-hilog-rich.md) - -——>——>——>——>[HiLog_Lite Development](device-dev/subsystems/subsys-dfx-hilog-lite.md) - -——>——>——>——>[HiTrace Development](device-dev/subsystems/subsys-dfx-hitrace.md) - -——>——>——>——>[HiCollie Development](device-dev/subsystems/subsys-dfx-hicollie.md) - -——>——>——>——>[HiSysEvent Development](device-dev/subsystems/subsys-dfx-hisysevent.md) - -——>——>——>——>——>[HiSysEvent Logging Configuration](device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md) - -——>——>——>——>——>[HiSysEvent Logging](device-dev/subsystems/subsys-dfx-hisysevent-logging.md) - -——>——>——>——>——>[HiSysEvent Listening](device-dev/subsystems/subsys-dfx-hisysevent-listening.md) - -——>——>——>——>——>[HiSysEvent Query](device-dev/subsystems/subsys-dfx-hisysevent-query.md) - -——>——>——>——>——>[HiSysEvent Tool Usage](device-dev/subsystems/subsys-dfx-hisysevent-tool.md) - -——>——> Featured Topics - -——>——>——> [Bundle Development](device-dev/bundles/bundles.md) - -——>——>——>——> [Bundle Development Specifications](device-dev/bundles/oem_bundle_standard_des.md) - -——>——>——>——> [Development Guidelines](device-dev/bundles/bundles-guide.md) - -——>——>——>——>——> [Overview](device-dev/bundles/bundles-guide-overview.md) - -——>——>——>——>——> [Installing hpm-cli Tool](device-dev/bundles/bundles-guide-prepare.md) - -——>——>——>——>——> [Developing Bundles](device-dev/bundles/bundles-guide-develop.md) - -——>——>——>——> [HPM User Guide](device-dev/bundles/bundles-demo.md) - -——>——>——>——>——> [Introduction](device-dev/bundles/bundles-demo-hpmdescription.md) - -——>——>——>——>——> [Configuring the Compilation Environment](device-dev/bundles/bundles-demo-environment.md) - -——>——>——>——>——> [Development Example](device-dev/bundles/bundles-demo-devsample.md) - -——>——> Device Development Examples - -——>——>——> [Mini- and Small-System Devices](device-dev/guide/device-lite.md) - -——>——>——>——> [WLAN-connected Products](device-dev/guide/device-wlan.md) - -——>——>——>——>——> [LED Peripheral Control](device-dev/guide/device-wlan-led-control.md) - -——>——>——>——>——> [Third-Party SDK Integration](device-dev/guide/device-wlan-sdk.md) - -——>——>——>——> [Cameras Without a Screen](device-dev/guide/device-iotcamera.md) - -——>——>——>——>——> [Camera Control](device-dev/guide/device-iotcamera-control.md) - -——>——>——>——>——>——> [Overview](device-dev/guide/device-iotcamera-control-overview.md) - -——>——>——>——>——>——> [Development Guidelines](device-dev/guide/device-iotcamera-control-demo.md) - -——>——>——>——>——>——>——> [Photographing](device-dev/guide/device-iotcamera-control-demo-photodevguide.md) - -——>——>——>——>——>——>——> [Video Recording](device-dev/guide/device-iotcamera-control-demo-videodevguide.md) - -——>——>——>——>——>——> [Use Case](device-dev/guide/device-iotcamera-control-example.md) - -——>——>——>——> [Cameras with a Screen](device-dev/guide/device-camera.md) - -——>——>——>——>——> [Screen and Camera Control](device-dev/guide/device-camera-control.md) - -——>——>——>——>——>——> [Overview](device-dev/guide/device-camera-control-overview.md) - -——>——>——>——>——>——> [Development Guidelines](device-dev/guide/device-camera-control-demo.md) - -——>——>——>——>——>——>——> [Photographing](device-dev/guide/device-camera-control-demo-photoguide.md) - -——>——>——>——>——>——>——> [Video Recording](device-dev/guide/device-camera-control-demo-videoguide.md) - -——>——>——>——>——>——>——> [Previewing](device-dev/guide/device-camera-control-demo-previewguide.md) - -——>——>——>——>——>——> [Use Case](device-dev/guide/device-camera-control-example.md) - -——>——>——>——>——> [Visual Application Development](device-dev/guide/device-camera-visual.md) - -——>——>——>——>——>——> [Overview](device-dev/guide/device-camera-visual-overview.md) - -——>——>——>——>——>——> [Preparations](device-dev/guide/device-camera-visual-prepare.md) - -——>——>——>——>——>——> [Adding Pages](device-dev/guide/device-camera-visual-addpage.md) - -——>——>——>——>——>——> [Building the Home Page](device-dev/guide/device-camera-visual-firstpage.md) - -——>——>——>——>——>——> [Building the Details Page](device-dev/guide/device-camera-visual-details.md) - -——>——>——>——>——>——> [Debugging and Packaging](device-dev/guide/device-camera-visual-debug.md) - -——>——>——>——>——>——> [Running on the Device](device-dev/guide/device-camera-visual-run.md) - -——>——>——>——>——>——> [FAQs]](device-dev/guide/device-camera-visual-faqs.md) - -——>——>——> [Standard-System Devices](device-dev/guide/device-standard.md) - -——>——>——>——> [Development Guidelines on Clock Apps](device-dev/guide/device-clock-guide.md) - -——>——>——>——> [Development Example for Platform Drivers](device-dev/guide/device-driver-demo.md) - -——>——>——>——> [Development Example for Peripheral Drivers](device-dev/guide/device-outerdriver-demo.md) - -——>——> Application Development - -——>——>——> [Getting Started](application-dev/quick-start) - -——>——>——>——> [Preparations](application-dev/quick-start/start-overview.md) - -——>——>——>——> [Getting Started with JavaScript](application-dev/quick-start/start-with-js.md) - -——>——>——> ArkUI - -——>——>——>——> JavaScript-based Web-like Development Paradigm - -——>——>——>——>——> [Overview](application-dev/ui/ui-js-overview.md) - -——>——>——>——>——> Framework - -——>——>——>——>——>——> [File Organization](application-dev/ui/js-framework-file.md) - -——>——>——>——>——>——> ["js" Tag](application-dev/ui/js-framework-js-tag.md) - -——>——>——>——>——>——> [app.js](application-dev/ui/js-framework-js-file.md) - -——>——>——>——>——>——> Syntax - -——>——>——>——>——>——>——> [HML](application-dev/ui/js-framework-syntax-hml.md) - -——>——>——>——>——>——>——> [CSS](application-dev/ui/js-framework-syntax-css.md) - -——>——>——>——>——>——>——> [JavaScript](application-dev/ui/js-framework-syntax-js.md) - -——>——>——>——>——>——> [Lifecycle](application-dev/ui/js-framework-lifecycle.md) - -——>——>——>——>——>——> [Resource Limitations and Access](application-dev/ui/js-framework-resource-restriction.md) - -——>——>——>——>——>——> [Multi-Language Capability](application-dev/ui/js-framework-multiple-languages.md) - -——>——>——>——>——> Building the UI - -——>——>——>——>——>——> [Component Overview](application-dev/ui/ui-js-building-ui-component.md) - -——>——>——>——>——>——> Building the Layout - -——>——>——>——>——>——>——> [Layout Description](application-dev/ui/ui-js-building-ui-layout-intro.md) - -——>——>——>——>——>——>——> [Adding Title and Paragraph Text](application-dev/ui/ui-js-building-ui-layout-text.md) - -——>——>——>——>——>——>——> [Adding an Image](application-dev/ui/ui-js-building-ui-layout-image.md) - -——>——>——>——>——>——>——> [Adding a Comment](application-dev/ui/ui-js-building-ui-layout-comment.md) - -——>——>——>——>——>——>——> [Adding a Container](application-dev/ui/ui-js-building-ui-layout-external-container.md) - -——>——>——>——>——>——> [Adding Interactions](application-dev/ui/ui-js-building-ui-interactions.md) - -——>——>——>——>——>——> [Developing Animations](application-dev/ui/ui-js-building-ui-animation.md) - -——>——>——>——>——>——> [Defining Events](application-dev/ui/ui-js-building-ui-event.md) - -——>——>——>——>——>——> [Defining Page Routes](application-dev/ui/ui-js-building-ui-routes.md) - -——>——>——>——>——> Common Component Development Guidelines - -——>——>——>——>——>——> [Text](application-dev/ui/ui-js-components-text.md) - -——>——>——>——>——>——> [Input](application-dev/ui/ui-js-components-input.md) - -——>——>——>——>——>——> [Button](application-dev/ui/ui-js-components-button.md) - -——>——>——>——>——>——> [List](application-dev/ui/ui-js-components-list.md) - -——>——>——>——>——>——> [Picker](application-dev/ui/ui-js-components-picker.md) - -——>——>——>——>——>——> [Dialog](application-dev/ui/ui-js-components-dialog.md) - -——>——>——>——>——>——> [Form](application-dev/ui/ui-js-components-form.md) - -——>——>——>——>——>——> [Stepper](application-dev/ui/ui-js-components-stepper.md) - -——>——>——>——>——>——> [Tabs](application-dev/ui/ui-js-component-tabs.md) - -——>——>——>——>——>——> [Image](application-dev/ui/ui-js-components-images.md) - -——>——>——>——>——> Animation Development Guidelines - -——>——>——>——>——>——> CSS Animation - -——>——>——>——>——>——>——> [Defining Attribute Style Animations](application-dev/ui/ui-js-animate-attribute-style.md) - -——>——>——>——>——>——>——> [Defining Animations with the transform Attribute](application-dev/ui/ui-js-animate-transform.md) - -——>——>——>——>——>——>——> [Defining Animations with the background-position Attribute](application-dev/ui/ui-js-animate-background-position-style.md) - -——>——>——>——>——>——> JS Animation - -——>——>——>——>——>——>——> [Component Animation](application-dev/ui/ui-js-animate-component.md) - -——>——>——>——>——>——>——> Interpolator Animation - -——>——>——>——>——>——>——>——> [Animation Effect](application-dev/ui/ui-js-animate-dynamic-effects.md) - -——>——>——>——>——>——>——>——> [Animation Frame](application-dev/ui/ui-js-animate-frame.md) - -——>——>——>——>——> [Custom Components](application-dev/ui/ui-js-custom-components.md) - -——>——>——>——> TypeScript-based Declarative Development Paradigm - -——>——>——>——>——> [Overview](application-dev/ui/ui-ts-overview.md) - -——>——>——>——>——> Framework Overview - -——>——>——>——>——>——> File Organization - -——>——>——>——>——>——>——> [Directory Structure](application-dev/ui/ts-framework-directory.md) - -——>——>——>——>——>——>——> [Rules for Accessing Application Code Files](application-dev/ui/ts-framework-file-access-rules.md) - -——>——>——>——>——>——> ["js" Tag](application-dev/ui/ts-framework-js-tag.md) - -——>——>——>——>——>——> Resource Access - -——>——>——>——>——>——>——> [Media Resource Types](application-dev/ui/ts-media-resource-type.md) - -——>——>——>——>——>——> [Pixel Units](application-dev/ui/ts-pixel-units.md) - -——>——>——>——>——>——> [Types](application-dev/ui/ts-types.md) - -——>——>——>——>——> Declarative Syntax - -——>——>——>——>——>——> [Overview](application-dev/ui/ts-syntax-intro.md) - -——>——>——>——>——>——> General UI Description Specifications - -——>——>——>——>——>——>——> [Basic Concepts](application-dev/ui/ts-general-ui-concepts.md) - -——>——>——>——>——>——>——> Declarative UI Description Specifications - -——>——>——>——>——>——>——>——> [Configuration Without Parameters](application-dev/ui/ts-parameterless-configuration.md) - -——>——>——>——>——>——>——>——> [Configuration with Mandatory Parameters](application-dev/ui/ts-configuration-with-mandatory-parameters.md) - -——>——>——>——>——>——>——>——> [Attribute Configuration](application-dev/ui/ts-attribution-configuration.md) - -——>——>——>——>——>——>——>——> [Event Configuration](application-dev/ui/ts-event-configuration.md) - -——>——>——>——>——>——>——>——> [Child Component Configuration](application-dev/ui/ts-child-component-configuration.md) - -——>——>——>——>——>——>——> Componentization - -——>——>——>——>——>——>——>——> [@Component](application-dev/ui/ts-component-based-component.md) - -——>——>——>——>——>——>——>——> [@Entry](application-dev/ui/ts-component-based-entry.md) - -——>——>——>——>——>——>——>——> [@Preview](application-dev/ui/ts-component-based-preview.md) - -——>——>——>——>——>——>——>——> [@Builder](application-dev/ui/ts-component-based-builder.md) - -——>——>——>——>——>——>——>——> [@Extend](application-dev/ui/ts-component-based-extend.md) - -——>——>——>——>——>——>——>——> [@CustomDialog](application-dev/ui/ts-component-based-customdialog.md) - -——>——>——>——>——>——> About UI State Management - -——>——>——>——>——>——>——> [Basic Concepts](application-dev/ui/ts-ui-state-mgmt-concepts.md) - -——>——>——>——>——>——>——> Managing Component States - -——>——>——>——>——>——>——>——> [@State](application-dev/ui/ts-component-states-state.md) - -——>——>——>——>——>——>——>——> [@Prop](application-dev/ui/ts-component-states-prop.md) - -——>——>——>——>——>——>——>——> [@Link](application-dev/ui/ts-component-states-link.md) - -——>——>——>——>——>——>——> Managing Application States - -——>——>——>——>——>——>——>——> Interfaces - -——>——>——>——>——>——>——>——>——> [AppStorage](application-dev/ui/ts-application-states-appstorage.md) - -——>——>——>——>——>——>——>——>——> [PersistentStorage](application-dev/ui/ts-application-states-apis-persistentstorage.md) - -——>——>——>——>——>——>——>——>——> [Environment](application-dev/ui/ts-application-states-apis-environment.md) - -——>——>——>——>——>——>——>——> [Synchronization Between AppStorage and Components](application-dev/ui/ts-application-states-storagelink-storageprop.md) - -——>——>——>——>——>——>——> Managing Other States - -——>——>——>——>——>——>——>——> [@Observed and @ObjectLink](application-dev/ui/ts-other-states-observed-objectlink.md) - -——>——>——>——>——>——>——>——> [@Consume and @Provide](application-dev/ui/ts-other-states-consume-provide.md) - -——>——>——>——>——>——>——>——> [@Watch](application-dev/ui/ts-other-states-watch.md) - -——>——>——>——>——>——> About Rendering Control Syntax - -——>——>——>——>——>——>——> [if/else](application-dev/ui/ts-rending-control-syntax-if-else.md) - -——>——>——>——>——>——>——> [ForEach](application-dev/ui/ts-rending-control-syntax-foreach.md) - -——>——>——>——>——>——>——> [LazyForEach](application-dev/ui/ts-rending-control-syntax-lazyforeach.md) - -——>——>——>——>——>——> About @Component - -——>——>——>——>——>——>——> [build Function](application-dev/ui/ts-function-build.md) - -——>——>——>——>——>——>——> [Initialization of Custom Components' Member Variables](application-dev/ui/ts-custom-component-initialization.md) - -——>——>——>——>——>——>——> [Custom Component Lifecycle Callbacks](application-dev/ui/ts-custom-component-lifecycle-callbacks.md) - -——>——>——>——>——>——>——> [Component Creation and Re-initialization](application-dev/ui/ts-component-creation-re-initialization.md) - -——>——>——>——>——>——> About Syntactic Sugar - -——>——>——>——>——>——>——> [@Decorator](application-dev/ui/ts-syntactic-sugar-decorator.md) - -——>——>——>——>——>——>——> [Chain Call](application-dev/ui/ts-syntactic-sugar-chaining.md) - -——>——>——>——>——>——>——> [struct](application-dev/ui/ts-syntactic-sugar-struct.md) - -——>——>——>——>——>——>——> [Instantiating a struct Without the new Keyword](application-dev/ui/ts-instantiating-a-struct-without-new-keyword.md) - -——>——>——>——>——>——>——> [Using a Separate Line for New Component](application-dev/ui/ts-using-a-separate-line-for-new-component.md) - -——>——>——>——>——>——>——> [Restrictions on Using TypeScript for Generators](application-dev/ui/ts-restrictions-for-generators.md) - -——>——>——>——>——> Experiencing the Declarative UI - -——>——>——>——>——>——> [Creating a Declarative UI Project](application-dev/ui/ui-ts-creating-project.md) - -——>——>——>——>——>——> [Getting to Know Components](application-dev/ui/ui-ts-components.md) - -——>——>——>——>——>——> [Creating a Simple Page](application-dev/ui/ui-ts-creating-simple-page.md) - -——>——>——>——>——> Defining Page Layout and Connection - -——>——>——>——>——>——> [Building a Food Data Model](application-dev/ui/ui-ts-building-data-model.md) - -——>——>——>——>——>——> [Building a Food Category List Layout](application-dev/ui/ui-ts-building-category-list-layout.md) - -——>——>——>——>——>——> [Building a Food Category Grid Layout](application-dev/ui/ui-ts-building-category-grid-layout.md) - -——>——>——>——>——>——> [Implementing Page Redirection and Data Transmission](application-dev/ui/ui-ts-page-redirection-data-transmission.md) - -——>——>——> Media - -——>——>——>——> Audio - -——>——>——>——>——> [Audio Overview](application-dev/media/audio-overview.md) - -——>——>——>——>——> [Audio Playback Development](application-dev/media/audio-playback.md) - -——>——>——>——>——> [Audio Management Development](application-dev/media/audio-management.md) - -——>——>——>——>——> [Audio Recording Development](application-dev/media/audio-recorder.md) - -——>——>——>——>——> [Audio Playback Development Using AudioRenderer](application-dev/media/audio-renderer.md) - -——>——>——>——>——> [Audio Recorder Development Using AudioCapturer](application-dev/media/audio-capturer.md) - -——>——>——> User Authentication - -——>——>——>——> [User Authentication Overview](application-dev/security/userauth-overview.md) - -——>——>——>——> [User Authentication Development](application-dev/security/userauth-guidelines.md) - -——>——>——> IPC & RPC - -——>——>——>——> [IPC & RPC Overview](application-dev/connectivity/ipc-rpc-overview.md) - -——>——>——>——> [IPC & RPC Development Guidelines](application-dev/connectivity/ipc-rpc-development-guideline.md) - -——>——>——>——> [Subscribing to State Changes of a Remote Object](application-dev/connectivity/subscribe-remote-state.md) - -——>——>——> Data Management - -——>——>——>——> Distributed Data Service - -——>——>——>——> [Distributed Data Service Overview](application-dev/database/database-mdds-overview.md) - -——>——>——>——> [Distributed Data Service Development](application-dev/database/database-mdds-guidelines.md) - -——>——>——>——> Relational Database Overview - -——>——>——>——> [RDB Overview](application-dev/database/database-relational-overview.md) - -——>——>——>——> [RDB Development](application-dev/database/database-relational-guidelines.md) - -——>——>——>——> Lightweight Data Store - -——>——>——>——> [Lightweight Data Store Overview](application-dev/database/database-preference-overview.md) - -——>——>——>——> [Lightweight Data Store Development](application-dev/database/database-preference-guidelines.md) - -——>——>——> USB Service - -——>——>——>——> [USB Service Overview](application-dev/usb/usb-overview.md) - -——>——>——>——> [USB Service Development](application-dev/usb/usb-guidelines.md) - -——>——>——> DFX - -——>——>——>——> [Overview of Application Event Logging](application-dev/dfx/hiappevent-overview.md) - -——>——>——>——> [Development Guidelines on Application Event Logging](application-dev/dfx/hiappevent-guidelines.md) - -——>——>——> [DevEco Studio \(OpenHarmony\) User Guide](application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md) - -——>——>——>——> [Overview](application-dev/quick-start/deveco-studio-overview.md) - -——>——>——>——> [Version Change History](application-dev/quick-start/deveco-studio-release-notes.md) - -——>——>——>——> [Configuring the OpenHarmony SDK](application-dev/quick-start/configuring-openharmony-sdk.md) - -——>——>——>——> [Creating an OpenHarmony Project](application-dev/quick-start/create-openharmony-project.md) - -——>——>——>——>——> [Using the Project Wizard to Create a Project](application-dev/quick-start/use-wizard-to-create-project.md) - -——>——>——>——>——> [Importing a Sample to Create a Project](application-dev/quick-start/import-sample-to-create-project.md) - -——>——>——>——> [Configuring the OpenHarmony App Signature](application-dev/quick-start/configuring-openharmony-app-signature.md) - -——>——>——>——> [Installing and Running Your OpenHarmony App](application-dev/quick-start/installing-openharmony-app.md) - -——>——> Debugging - -——>——>——> [Test Subsystem](device-dev/subsystems/subsys-testguide-test.md) - -——>——>——> [R&D Tools](device-dev/subsystems/subsys-toolchain.md) - -——>——>——>——> [bytrace Usage Guidelines](device-dev/subsystems/subsys-toolchain-bytrace-guide.md) - -——>——>——>——> [hdc\_std Usage Guidelines](device-dev/subsystems/subsys-toolchain-hdc-guide.md) - -——>——> XTS Certification - -——>——>——> [XTS](device-dev/subsystems/subsys-xts-guide.md) - -——>——> Tools - -——>——>——> [Docker Environment](device-dev/get-code/gettools-acquire.md) - -——>——>——> [IDE](device-dev/get-code/gettools-ide.md) - -——>——> References - -——>——>——> [JS APIs](application-dev/reference/apis/Readme-EN.md) - -——>——>——>——> Ability Framework - -——>——>——>——>——> [FeatureAbility Module](application-dev/reference/apis/js-apis-featureAbility.md) - -——>——>——>——>——> [ParticleAbility Module](application-dev/reference/apis/js-apis-particleAbility.md) - -——>——>——>——>——> [DataAbilityHelper Module](application-dev/reference/apis/js-apis-dataAbilityHelper.md) - -——>——>——>——>——> [DataUriUtils Module](application-dev/reference/apis/js-apis-DataUriUtils.md) - -——>——>——>——>——> [Bundle Module](application-dev/reference/apis/js-apis-Bundle.md) - -——>——>——>——>——> [CommonEvent Module](application-dev/reference/apis/js-apis-commonEvent.md) - -——>——>——>——>——> [Notification Module](application-dev/reference/apis/js-apis-notification.md) - -——>——>——>——>——> [Context Module](application-dev/reference/apis/js-apis-Context.md) - -——>——>——>——> Resource Management - -——>——>——>——>——> [Resource Manager](application-dev/reference/apis/js-apis-resource-manager.md) - -——>——>——>——>——> [Internationalization \(i18n\) ](application-dev/reference/apis/js-apis-i18n.md) - -——>——>——>——>——> [Internationalization \(intl\) ](application-dev/reference/apis/js-apis-intl.md) - -——>——>——>——> Media - -——>——>——>——>——> [Audio Management](application-dev/reference/apis/js-apis-audio.md) - -——>——>——>——>——> [Media](application-dev/reference/apis/js-apis-media.md) - -——>——>——>——> Security - -——>——>——>——>——> [User Authentication](application-dev/reference/apis/js-apis-useriam-userauth.md) - -——>——>——>——>——> [Access Control](application-dev/reference/apis/js-apis-abilityAccessCtrl.md) - -——>——>——>——> Data Management - -——>——>——>——>——> [Lightweight Storage](application-dev/reference/apis/js-apis-data-preferences.md) - -——>——>——>——>——> [Lightweight Storage (deprecated since 8)](application-dev/reference/apis/js-apis-data-storage.md) - -——>——>——>——>——> [Distributed Data Management](application-dev/reference/apis/js-apis-distributed-data.md) - -——>——>——>——>——> [Relational Database](application-dev/reference/apis/js-apis-data-rdb.md) - -——>——>——>——>——> [Result Set](application-dev/reference/apis/js-apis-data-resultset.md) - -——>——>——>——>——> [DataAbilityPredicates](application-dev/reference/apis/js-apis-data-ability.md) - -——>——>——>——>——> [Settings](application-dev/reference/apis/js-apis-settings.md) - -——>——>——>——> File Management - -——>——>——>——>——> [File Management](application-dev/reference/apis/js-apis-fileio.md) - -——>——>——>——>——> [Statfs](application-dev/reference/apis/js-apis-statfs.md) - -——>——>——>——>——> [Environment](application-dev/reference/apis/js-apis-environment.md) - -——>——>——>——>——> [Public File Access and Management](application-dev/reference/apis/js-apis-filemanager.md) - -——>——>——>——>——> [App Storage Statistics](application-dev/reference/apis/js-apis-storage-statistics.md) - -——>——>——>——>——> [Volume Management](application-dev/reference/apis/js-apis-volumemanager.md) - -——>——>——>——> Account Management - -——>——>——>——>——> [Distributed Account Management](application-dev/reference/apis/js-apis-distributed-account.md) - -——>——>——>——>——> [Application Account Management](application-dev/reference/apis/js-apis-appAccount.md) - -——>——>——>——> Telephony Service - -——>——>——>——>——> [Call](application-dev/reference/apis/js-apis-call.md) - -——>——>——>——>——> [SMS](application-dev/reference/apis/js-apis-sms.md) - -——>——>——>——>——> [SIM Management](application-dev/reference/apis/js-apis-sim.md) - -——>——>——>——>——> [Radio](application-dev/reference/apis/js-apis-radio.md) - -——>——>——>——>——> [observer](application-dev/reference/apis/js-apis-observer.md) - -——>——>——>——>——> [Cellular Data](application-dev/reference/apis/js-apis-telephony-data.md) - -——>——>——>——> Network and Connectivity - -——>——>——>——>——> [WLAN](application-dev/reference/apis/js-apis-wifi.md) - -——>——>——>——>——> [Bluetooth](application-dev/reference/apis/js-apis-bluetooth.md) - -——>——>——>——> Device Management - -——>——>——>——>——> [Sensor](application-dev/reference/apis/js-apis-sensor.md) - -——>——>——>——>——> [Vibrator](application-dev/reference/apis/js-apis-vibrator.md) - -——>——>——>——>——> [Brightness](application-dev/reference/apis/js-apis-brightness.md) - -——>——>——>——>——> [Battery Info](application-dev/reference/apis/js-apis-battery-info.md) - -——>——>——>——>——> [Power Management](application-dev/reference/apis/js-apis-power.md) - -——>——>——>——>——> [Thermal Management](application-dev/reference/apis/js-apis-thermal.md) - -——>——>——>——>——> [Running Lock](application-dev/reference/apis/js-apis-runninglock.md) - -——>——>——>——>——> [Device Info](application-dev/reference/apis/js-apis-device-info.md) - -——>——>——>——>——> [systemParameter](application-dev/reference/apis/js-apis-system-parameter.md) - -——>——>——>——>——> [Device Management](application-dev/reference/apis/js-apis-device-manager.md) - -——>——>——>——>——> [Window](application-dev/reference/apis/js-apis-window.md) - -——>——>——>——>——> [Display](application-dev/reference/apis/js-apis-display.md) - -——>——>——>——>——> [Update](application-dev/reference/apis/js-apis-update.md) - -——>——>——>——>——> [USB](application-dev/reference/apis/js-apis-usb.md) - -——>——>——>——> Basic Features - -——>——>——>——>——> [Application Context](application-dev/reference/apis/js-apis-basic-features-app-context.md) - -——>——>——>——>——> [Console Logs](application-dev/reference/apis/js-apis-basic-features-logs.md) - -——>——>——>——>——> [Page Routing](application-dev/reference/apis/js-apis-basic-features-routes.md) - -——>——>——>——>——> [Pop-up Window](application-dev/reference/apis/js-apis-basic-features-pop-up.md) - -——>——>——>——>——> [Application Configuration](application-dev/reference/apis/js-apis-basic-features-configuration.md) - -——>——>——>——>——> [Timer](application-dev/reference/apis/js-apis-basic-features-timer.md) - -——>——>——>——>——> [Setting the System Time](application-dev/reference/apis/js-apis-system-time.md) - -——>——>——>——>——> [Animation](application-dev/reference/apis/js-apis-basic-features-animator.md) - -——>——>——>——>——> [WebGL](application-dev/reference/apis/js-apis-webgl.md) - -——>——>——>——>——> [WebGL2](application-dev/reference/apis/js-apis-webgl2.md) - -——>——>——>——>——> [Screenshot](application-dev/reference/apis/js-apis-screenshot.md) - -——>——>——>——> DFX - -——>——>——>——>——> [HiAppEvent](application-dev/reference/apis/js-apis-hiappevent.md) - -——>——>——>——>——> [Performance Tracing](application-dev/reference/apis/js-apis-hitracemeter.md) - -——>——>——>——>——> [Fault Logger](application-dev/reference/apis/js-apis-faultLogger.md) - -——>——>——>——>——> [Distributed Call Chain Tracing](application-dev/reference/apis/js-apis-hitracechain.md) - -——>——>——>——>——> [HiLog](application-dev/reference/apis/js-apis-hilog.md) - -——>——>——>——>——> [HiChecker](application-dev/reference/apis/js-apis-hichecker.md) - -——>——>——>——>——> [HiDebug](application-dev/reference/apis/js-apis-hidebug.md) - -——>——>——>——> Language Base Class Library - -——>——>——>——>——> [Obtaining Process Information](application-dev/reference/apis/js-apis-process.md) - -——>——>——>——>——> [URL String Parsing](application-dev/reference/apis/js-apis-url.md) - -——>——>——>——>——> [URI String Parsing](application-dev/reference/apis/js-apis-uri.md) - -——>——>——>——>——> [Util](application-dev/reference/apis/js-apis-util.md) - -——>——>——>——>——> [XML Parsing and Generation](application-dev/reference/apis/js-apis-xml.md) - -——>——>——>——>——> [XML-to-JavaScript Conversion](application-dev/reference/apis/js-apis-convertxml.md) - -——>——>——>——>——> [Worker Startup](application-dev/reference/apis/js-apis-worker.md) - -——>——>——>——>——> [Linear Container ArrayList](application-dev/reference/apis/js-apis-arraylist.md) - -——>——>——>——>——> [Linear Container Deque](application-dev/reference/apis/js-apis-deque.md) - -——>——>——>——>——> [Linear Container List](application-dev/reference/apis/js-apis-list.md) - -——>——>——>——>——> [Linear Container LinkedList](application-dev/reference/apis/js-apis-linkedlist.md) - -——>——>——>——>——> [Linear Container Queue](application-dev/reference/apis/js-apis-queue.md) - -——>——>——>——>——> [Linear Container Stack](application-dev/reference/apis/js-apis-stack.md) - -——>——>——>——>——> [Linear Container Vector](application-dev/reference/apis/js-apis-vector.md) - -——>——>——>——>——> [Nonlinear Container HashSet](application-dev/reference/apis/js-apis-hashset.md) - -——>——>——>——>——> [Nonlinear Container HashMap](application-dev/reference/apis/js-apis-hashmap.md) - -——>——>——>——>——> [Nonlinear Container PlainArray](application-dev/reference/apis/js-apis-plainarray.md) - -——>——>——>——>——> [Nonlinear Container TreeMap](application-dev/reference/apis/js-apis-treemap.md) - -——>——>——>——>——> [Nonlinear Container TreeSet](application-dev/reference/apis/js-apis-treeset.md) - -——>——>——>——>——> [Nonlinear Container LightWeightMap](application-dev/reference/apis/js-apis-lightweightmap.md) - -——>——>——>——>——> [Nonlinear Container LightWeightSet](application-dev/reference/apis/js-apis-lightweightset.md) - -——>——>——> ArkUI Component References - -——>——>——>——> [TypeScript-based Declarative Development Paradigm](application-dev/reference/arkui-js/Readme-EN.md) - -——>——>——>——>——> Components - -——>——>——>——>——>——> Common - -——>——>——>——>——>——>——> [Universal Attributes](application-dev/reference/arkui-js/js-components-common-attributes.md) - -——>——>——>——>——>——>——> [Universal Styles](application-dev/reference/arkui-js/js-components-common-styles.md) - -——>——>——>——>——>——>——> [Universal Events](application-dev/reference/arkui-js/js-components-common-events.md) - -——>——>——>——>——>——>——> [Universal Methods](application-dev/reference/arkui-js/js-components-common-methods.md) - -——>——>——>——>——>——>——> [Animation Styles](application-dev/reference/arkui-js/js-components-common-animation.md) - -——>——>——>——>——>——>——> [Gradient Styles](application-dev/reference/arkui-js/js-components-common-gradient.md) - -——>——>——>——>——>——>——> [Transition Styles](application-dev/reference/arkui-js/js-components-common-transition.md) - -——>——>——>——>——>——>——> [Media Query](application-dev/reference/arkui-js/js-components-common-mediaquery.md) - -——>——>——>——>——>——>——> [Custom Font Styles](application-dev/reference/arkui-js/js-components-common-customizing-font.md) - -——>——>——>——>——>——>——> [Atomic Layout](application-dev/reference/arkui-js/js-components-common-atomic-layout.md) - -——>——>——>——>——>——> Container Component - -——>——>——>——>——>——>——> [badge](application-dev/reference/arkui-js/js-components-container-badge.md) - -——>——>——>——>——>——>——> [dialog](application-dev/reference/arkui-js/js-components-container-dialog.md) - -——>——>——>——>——>——>——> [div](application-dev/reference/arkui-js/js-components-container-div.md) - -——>——>——>——>——>——>——> [form](application-dev/reference/arkui-js/js-components-container-form.md) - -——>——>——>——>——>——>——> [list](application-dev/reference/arkui-js/js-components-container-list.md) - -——>——>——>——>——>——>——> [list-item](application-dev/reference/arkui-js/js-components-container-list-item.md) - -——>——>——>——>——>——>——> [list-item-group](application-dev/reference/arkui-js/js-components-container-list-item-group.md) - -——>——>——>——>——>——>——> [panel](application-dev/reference/arkui-js/js-components-container-panel.md) - -——>——>——>——>——>——>——> [popup](application-dev/reference/arkui-js/js-components-container-popup.md) - -——>——>——>——>——>——>——> [refresh](application-dev/reference/arkui-js/js-components-container-refresh.md) - -——>——>——>——>——>——>——> [stack](application-dev/reference/arkui-js/js-components-container-stack.md) - -——>——>——>——>——>——>——> [stepper](application-dev/reference/arkui-js/js-components-container-stepper.md) - -——>——>——>——>——>——>——> [stepper-item](application-dev/reference/arkui-js/js-components-container-stepper-item.md) - -——>——>——>——>——>——>——> [swiper](application-dev/reference/arkui-js/js-components-container-swiper.md) - -——>——>——>——>——>——>——> [tabs](application-dev/reference/arkui-js/js-components-container-tabs.md) - -——>——>——>——>——>——>——> [tab-bar](application-dev/reference/arkui-js/js-components-container-tab-bar.md) - -——>——>——>——>——>——>——> [tab-content](application-dev/reference/arkui-js/js-components-container-tab-content.md) - -——>——>——>——>——>——> Basic Components - -——>——>——>——>——>——>——> [button](application-dev/reference/arkui-js/js-components-basic-button.md) - -——>——>——>——>——>——>——> [chart](application-dev/reference/arkui-js/js-components-basic-chart.md) - -——>——>——>——>——>——>——> [divider](application-dev/reference/arkui-js/js-components-basic-divider.md) - -——>——>——>——>——>——>——> [image](application-dev/reference/arkui-js/js-components-basic-image.md) - -——>——>——>——>——>——>——> [image-animator](application-dev/reference/arkui-js/js-components-basic-image-animator.md) - -——>——>——>——>——>——>——> [input](application-dev/reference/arkui-js/js-components-basic-input.md) - -——>——>——>——>——>——>——> [label](application-dev/reference/arkui-js/js-components-basic-label.md) - -——>——>——>——>——>——>——> [marquee](application-dev/reference/arkui-js/js-components-basic-marquee.md) - -——>——>——>——>——>——>——> [menu](application-dev/reference/arkui-js/js-components-basic-menu.md) - -——>——>——>——>——>——>——> [option](application-dev/reference/arkui-js/js-components-basic-option.md) - -——>——>——>——>——>——>——> [picker](application-dev/reference/arkui-js/js-components-basic-picker.md) - -——>——>——>——>——>——>——> [picker-view](application-dev/reference/arkui-js/js-components-basic-picker-view.md) - -——>——>——>——>——>——>——> [piece](application-dev/reference/arkui-js/js-components-basic-piece.md) - -——>——>——>——>——>——>——> [progress](application-dev/reference/arkui-js/js-components-basic-progress.md) - -——>——>——>——>——>——>——> [qrcode](application-dev/reference/arkui-js/js-components-basic-qrcode.md) - -——>——>——>——>——>——>——> [rating](application-dev/reference/arkui-js/js-components-basic-rating.md) - -——>——>——>——>——>——>——> [richtext](application-dev/reference/arkui-js/js-components-basic-richtext.md) - -——>——>——>——>——>——>——> [search](application-dev/reference/arkui-js/js-components-basic-search.md) - -——>——>——>——>——>——>——> [select](application-dev/reference/arkui-js/js-components-basic-select.md) - -——>——>——>——>——>——>——> [slider](application-dev/reference/arkui-js/js-components-basic-slider.md) - -——>——>——>——>——>——>——> [span](application-dev/reference/arkui-js/js-components-basic-span.md) - -——>——>——>——>——>——>——> [switch](application-dev/reference/arkui-js/js-components-basic-switch.md) - -——>——>——>——>——>——>——> [text](application-dev/reference/arkui-js/js-components-basic-text.md) - -——>——>——>——>——>——>——> [textarea](application-dev/reference/arkui-js/js-components-basic-textarea.md) - -——>——>——>——>——>——>——> [toolbar](application-dev/reference/arkui-js/js-components-basic-toolbar.md) - -——>——>——>——>——>——>——> [toolbar-item](application-dev/reference/arkui-js/js-components-basic-toolbar-item.md) - -——>——>——>——>——>——>——> [toggle](application-dev/reference/arkui-js/js-components-basic-toggle.md) - -——>——>——>——>——>——> Media Components - -——>——>——>——>——>——>——> [video](application-dev/reference/arkui-js/js-components-media-video.md) - -——>——>——>——>——>——> Canvas Components - -——>——>——>——>——>——>——> [canvas](application-dev/reference/arkui-js/js-components-canvas-canvas.md) - -——>——>——>——>——>——>——> [CanvasRenderingContext2D](application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) - -——>——>——>——>——>——>——> [Image](application-dev/reference/arkui-js/js-components-canvas-image.md) - -——>——>——>——>——>——>——> [CanvasGradient](application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md) - -——>——>——>——>——>——>——> [ImageData](application-dev/reference/arkui-js/js-components-canvas-imagedata.md) - -——>——>——>——>——>——>——> [Path2D](application-dev/reference/arkui-js/js-components-canvas-path2d.md) - -——>——>——>——>——>——>——> [ImageBitmap](application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md) - -——>——>——>——>——>——>——> [OffscreenCanvas](application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md) - -——>——>——>——>——>——>——> [OffscreenCanvasRenderingContext2D](application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) - -——>——>——>——>——>——> Grid - -——>——>——>——>——>——>——> [Basic Concepts](application-dev/reference/arkui-js/js-components-grid-basic-concepts.md) - -——>——>——>——>——>——>——> [grid-container](application-dev/reference/arkui-js/js-components-grid-container.md) - -——>——>——>——>——>——>——> [grid-row](application-dev/reference/arkui-js/js-components-grid-row.md) - -——>——>——>——>——>——>——> [grid-col](application-dev/reference/arkui-js/js-components-grid-col.md) - -——>——>——>——>——>——> SVG Components - -——>——>——>——>——>——>——> [Universal Attributes](application-dev/reference/arkui-js/js-components-svg-common-attributes.md) - -——>——>——>——>——>——>——> [svg](application-dev/reference/arkui-js/js-components-svg.md) - -——>——>——>——>——>——>——> [rect](application-dev/reference/arkui-js/js-components-svg-rect.md) - -——>——>——>——>——>——>——> [circle](application-dev/reference/arkui-js/js-components-svg-circle.md) - -——>——>——>——>——>——>——> [ellipse](application-dev/reference/arkui-js/js-components-svg-ellipse.md) - -——>——>——>——>——>——>——> [path](application-dev/reference/arkui-js/js-components-svg-path.md) - -——>——>——>——>——>——>——> [line](application-dev/reference/arkui-js/js-components-svg-line.md) - -——>——>——>——>——>——>——> [polyline](application-dev/reference/arkui-js/js-components-svg-polyline.md) - -——>——>——>——>——>——>——> [polygon](application-dev/reference/arkui-js/js-components-svg-polygon.md) - -——>——>——>——>——>——>——> [text](application-dev/reference/arkui-js/js-components-svg-text.md) - -——>——>——>——>——>——>——> [tspan](application-dev/reference/arkui-js/js-components-svg-tspan.md) - -——>——>——>——>——>——>——> [textPath](application-dev/reference/arkui-js/js-components-svg-textpath.md) - -——>——>——>——>——>——>——> [animate](application-dev/reference/arkui-js/js-components-svg-animate.md) - -——>——>——>——>——>——>——> [animateMotion](application-dev/reference/arkui-js/js-components-svg-animatemotion.md) - -——>——>——>——>——>——>——> [animateTransform](application-dev/reference/arkui-js/js-components-svg-animatetransform.md) - -——>——>——>——>——> Custom Components - -——>——>——>——>——>——> [Basic Usage](application-dev/reference/arkui-js/js-components-custom-basic-usage.md) - -——>——>——>——>——>——> [Custom Events](application-dev/reference/arkui-js/js-components-custom-events.md) - -——>——>——>——>——>——> [props](application-dev/reference/arkui-js/js-components-custom-props.md) - -——>——>——>——>——>——> [Event Parameter](application-dev/reference/arkui-js/js-components-custom-event-parameter.md) - -——>——>——>——>——>——> [slot](application-dev/reference/arkui-js/js-components-custom-slot.md) - -——>——>——>——>——>——> [Lifecycle Definition](application-dev/reference/arkui-js/js-components-custom-lifecycle.md) - -——>——>——>——>——> [Appendix](application-dev/reference/arkui-js/js-appendix.md) - -——>——>——>——>——>——> [Type Attributes](application-dev/reference/arkui-js/js-appendix-types.md) - -——>——>——>——> [TypeScript-based Declarative Development Paradigm](application-dev/reference/arkui-ts/Readme-EN.md) - -——>——>——>——>——> Components - -——>——>——>——>——>——> Universal Components - -——>——>——>——>——>——>——> [Universal Events](application-dev/reference/arkui-ts/ts-universal-events.md) - -——>——>——>——>——>——>——>——> [Click Event](application-dev/reference/arkui-ts/ts-universal-events-click.md) - -——>——>——>——>——>——>——>——> [Touch](application-dev/reference/arkui-ts/ts-universal-events-touch.md) - -——>——>——>——>——>——>——>——> [Show/Hide Event](application-dev/reference/arkui-ts/ts-universal-events-show-hide.md) - -——>——>——>——>——>——>——>——> [Key Event](application-dev/reference/arkui-ts/ts-universal-events-key.md) - -——>——>——>——>——>——>——>——>[Component Area Change Event](application-dev/reference/arkui-ts/ts-universal-events-component-area-change.md) - -——>——>——>——>——>——>——> Universal Attributes - -——>——>——>——>——>——>——>——> [Size](application-dev/reference/arkui-ts/ts-universal-attributes-size.md) - -——>——>——>——>——>——>——>——> [Location](application-dev/reference/arkui-ts/ts-universal-attributes-location.md) - -——>——>——>——>——>——>——>——> [Layout Constraints](application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md) - -——>——>——>——>——>——>——>——> [Flex Layout](application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md) - -——>——>——>——>——>——>——>——> [Border Configuration](application-dev/reference/arkui-ts/ts-universal-attributes-border.md) - -——>——>——>——>——>——>——>——> [Background](application-dev/reference/arkui-ts/ts-universal-attributes-background.md) - -——>——>——>——>——>——>——>——> [Opacity](application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md) - -——>——>——>——>——>——>——>——> [Visibility](application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md) - -——>——>——>——>——>——>——>——> [Enable/Disable](application-dev/reference/arkui-ts/ts-universal-attributes-enable.md) - -——>——>——>——>——>——>——>——> [Overlay](application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md) - -——>——>——>——>——>——>——>——> [Z-order Control](application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md) - -——>——>——>——>——>——>——>——> [Transformation](application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md) - -——>——>——>——>——>——>——>——> [Image Effect Configuration](application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md) - -——>——>——>——>——>——>——>——> [Shape Clipping](application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) - -——>——>——>——>——>——>——>——> [Text Style](application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md) - -——>——>——>——>——>——>——>——> [Grid](application-dev/reference/arkui-ts/ts-universal-attributes-grid.md) - -——>——>——>——>——>——>——>——> [Gradient Color](application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md) - -——>——>——>——>——>——>——>——> [Popup Control](application-dev/reference/arkui-ts/ts-universal-attributes-popup.md) - -——>——>——>——>——>——>——>——> [Menu Control](application-dev/reference/arkui-ts/ts-universal-attributes-menu.md) - -——>——>——>——>——>——>——>——>[Click Control](application-dev/reference/arkui-ts/ts-universal-attributes-touchable.md) - -——>——>——>——>——>——>——>——>[Touch Target](application-dev/reference/arkui-ts/ts-universal-attributes-response-region.md) - -——>——>——>——>——>——>——> Gesture Processing - -——>——>——>——>——>——>——>——> [Gesture Binding Methods](application-dev/reference/arkui-ts/ts-gesture-settings.md) - -——>——>——>——>——>——>——>——> Basic Gestures - -——>——>——>——>——>——>——>——>——> [TapGesture](application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md) - -——>——>——>——>——>——>——>——>——> [LongPressGesture](application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md) - -——>——>——>——>——>——>——>——>——> [PanGesture](application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md) - -——>——>——>——>——>——>——>——>——> [PinchGesture](application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md) - -——>——>——>——>——>——>——>——>——> [RotationGesture](application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md) - -——>——>——>——>——>——>——>——>——> [SwipeGesture](application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md) - -——>——>——>——>——>——>——>——> [Combined Gestures](application-dev/reference/arkui-ts/ts-combined-gestures.md) - -——>——>——>——>——>——> Basic Components - -——>——>——>——>——>——>——> [Blank](application-dev/reference/arkui-ts/ts-basic-components-blank.md) - -——>——>——>——>——>——>——> [Button](application-dev/reference/arkui-ts/ts-basic-components-button.md) - -——>——>——>——>——>——>——> [DataPanel](application-dev/reference/arkui-ts/ts-basic-components-datapanel.md) - -——>——>——>——>——>——>——> [Divider](application-dev/reference/arkui-ts/ts-basic-components-divider.md) - -——>——>——>——>——>——>——>[Gauge](application-dev/reference/arkui-ts/ts-basic-components-gauge.md) - -——>——>——>——>——>——>——> [Image](application-dev/reference/arkui-ts/ts-basic-components-image.md) - -——>——>——>——>——>——>——> [ImageAnimator](application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md) - -——>——>——>——>——>——>——> [Progress](application-dev/reference/arkui-ts/ts-basic-components-progress.md) - -——>——>——>——>——>——>——> [QRCode](application-dev/reference/arkui-ts/ts-basic-components-qrcode.md) - -——>——>——>——>——>——>——> [Rating](application-dev/reference/arkui-ts/ts-basic-components-rating.md) - -——>——>——>——>——>——>——> [Span](application-dev/reference/arkui-ts/ts-basic-components-span.md) - -——>——>——>——>——>——>——> [Slider](application-dev/reference/arkui-ts/ts-basic-components-slider.md) - -——>——>——>——>——>——>——> [Text](application-dev/reference/arkui-ts/ts-basic-components-text.md) - -——>——>——>——>——>——>——> [TextArea](application-dev/reference/arkui-ts/ts-basic-components-textarea.md) - -——>——>——>——>——>——>——> [TextInput](application-dev/reference/arkui-ts/ts-basic-components-textinput.md) - -——>——>——>——>——>——>——> [Toggle](application-dev/reference/arkui-ts/ts-basic-components-toggle.md) - -——>——>——>——>——>——> Container Components - -——>——>——>——>——>——>——> [AlphabetIndexer](application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md) - -——>——>——>——>——>——>——> [Badge](application-dev/reference/arkui-ts/ts-container-badge.md) - -——>——>——>——>——>——>——> [Column](application-dev/reference/arkui-ts/ts-container-column.md) - -——>——>——>——>——>——>——> [ColumnSplit](application-dev/reference/arkui-ts/ts-container-columnsplit.md) - -——>——>——>——>——>——>——> [Counter](application-dev/reference/arkui-ts/ts-container-counter.md) - -——>——>——>——>——>——>——> [Flex](application-dev/reference/arkui-ts/ts-container-flex.md) - -——>——>——>——>——>——>——> [GridContainer](application-dev/reference/arkui-ts/ts-container-gridcontainer.md) - -——>——>——>——>——>——>——> [Grid](application-dev/reference/arkui-ts/ts-container-grid.md) - -——>——>——>——>——>——>——> [GridItem](application-dev/reference/arkui-ts/ts-container-griditem.md) - -——>——>——>——>——>——>——> [List](application-dev/reference/arkui-ts/ts-container-list.md) - -——>——>——>——>——>——>——> [ListItem](application-dev/reference/arkui-ts/ts-container-listitem.md) - -——>——>——>——>——>——>——> [Navigator](application-dev/reference/arkui-ts/ts-container-navigator.md) - -——>——>——>——>——>——>——> [Navigation](application-dev/reference/arkui-ts/ts-container-navigation.md) - -——>——>——>——>——>——>——> [Panel](application-dev/reference/arkui-ts/ts-container-panel.md) - -——>——>——>——>——>——>——> [Row](application-dev/reference/arkui-ts/ts-container-row.md) - -——>——>——>——>——>——>——> [RowSplit](application-dev/reference/arkui-ts/ts-container-rowsplit.md) - -——>——>——>——>——>——>——> [Scroll](application-dev/reference/arkui-ts/ts-container-scroll.md) - -——>——>——>——>——>——>——> [ScrollBar](application-dev/reference/arkui-ts/ts-container-scrollbar.md) - -——>——>——>——>——>——>——> [Stack](application-dev/reference/arkui-ts/ts-container-stack.md) - -——>——>——>——>——>——>——> [Swiper](application-dev/reference/arkui-ts/ts-container-swiper.md) - -——>——>——>——>——>——>——> [Tabs](application-dev/reference/arkui-ts/ts-container-tabs.md) - -——>——>——>——>——>——>——> [TabContent](application-dev/reference/arkui-ts/ts-container-tabcontent.md) - -——>——>——>——>——>——>——> [Stepper](application-dev/reference/arkui-ts/ts-container-stepper.md) - -——>——>——>——>——>——>——> [StepperItem](application-dev/reference/arkui-ts/ts-container-stepperitem.md) - -——>——>——>——>——>——> Drawing Components - -——>——>——>——>——>——>——> [Circle](application-dev/reference/arkui-ts/ts-drawing-components-circle.md) - -——>——>——>——>——>——>——> [Ellipse](application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md) - -——>——>——>——>——>——>——> [Line](application-dev/reference/arkui-ts/ts-drawing-components-line.md) - -——>——>——>——>——>——>——> [Polyline](application-dev/reference/arkui-ts/ts-drawing-components-polyline.md) - -——>——>——>——>——>——>——> [Polygon](application-dev/reference/arkui-ts/ts-drawing-components-polygon.md) - -——>——>——>——>——>——>——> [Path](application-dev/reference/arkui-ts/ts-drawing-components-path.md) - -——>——>——>——>——>——>——> [Rect](application-dev/reference/arkui-ts/ts-drawing-components-rect.md) - -——>——>——>——>——>——>——> [Shape](application-dev/reference/arkui-ts/ts-drawing-components-shape.md)‘ - -——>——>——>——>——>——> Canvas Components - -——>——>——>——>——>——>——>[Canvas](application-dev/reference/arkui-ts/ts-components-canvas-canvas.md) - -——>——>——>——>——>——>——>[Lottie](application-dev/reference/arkui-ts/ts-components-canvas-lottie.md) - -——>——>——>——>——>——>——>[Path2D](application-dev/reference/arkui-ts/ts-components-canvas-path2d.md) - -——>——>——>——>——>——>——>[CanvasGradient](application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md) - -——>——>——>——>——>——>——>[ImageBitmap](application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md) - -——>——>——>——>——>——>——>[ImageData](application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md) - -——>——>——>——>——> Animation - -——>——>——>——>——>——> [Attribute Animation](application-dev/reference/arkui-ts/ts-animatorproperty.md) - -——>——>——>——>——>——> [Explicit Animation](application-dev/reference/arkui-ts/ts-explicit-animation.md) - -——>——>——>——>——>——> Transition Animation - -——>——>——>——>——>——>——> [Page Transition](application-dev/reference/arkui-ts/ts-page-transition-animation.md) - -——>——>——>——>——>——>——> [Component Transition](application-dev/reference/arkui-ts/ts-transition-animation-component.md) - -——>——>——>——>——>——>——> [Transition of Shared Elements](application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md) - -——>——>——>——>——>——> [Motion Path Animation](application-dev/reference/arkui-ts/ts-motion-path-animation.md) - -——>——>——>——>——>——> [Matrix Transformation](application-dev/reference/arkui-ts/ts-matrix-transformation.md) - -——>——>——>——>——>——> [Interpolation Calculation](application-dev/reference/arkui-ts/ts-interpolation-calculation.md) - -——>——>——>——>——> Global UI Methods - -——>——>——>——>——>——> [Alert Dialog Box](application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md) - -——>——>——>——>——>——> [Custom Dialog box](application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md) - -——>——>——>——>——>——> [Image Cache](application-dev/reference/arkui-ts/ts-methods-image-cache.md) - -——>——>——>——>——>——> [Media Query](application-dev/reference/arkui-ts/ts-methods-media-query.md) - -——>——>——>——>——>——> [List Selection Dialog Box](application-dev/reference/arkui-ts/ts-methods-action-sheet.md) - -——>——>——>——>——> Appendix - -——>——>——>——>——>——> [Built-in Enums](application-dev/reference/arkui-ts/ts-appendix-enums.md) - -——>——>——>[Directory Structure](application-dev/quick-start/package-structure.md) - -——>——>——> FAQs-Device Management - -——>——>——>——>[Overview of FAQs](device-dev/faqs/faqs-overview.md) - -——>——>——>——>[Environment Setup](device-dev/faqs/faqs-environment-setup.md) - -——>——>——>——>[Compilation and Building Subsystem](device-dev/faqs/faqs-building.md) - -——>——>——>——>[Burning](device-dev/faqs/faqs-burning.md) - -——>——>——>——>[Kernel](device-dev/faqs/faqs-kernel.md) - -——>——>——>——>[Porting](device-dev/faqs/faqs-porting.md) - -——>——>——>——>[Startup](device-dev/faqs/faqs-startup.md) - -——>——>——>——>[System Applications](device-dev/faqs/faqs-system-applications.md) - -——>——> Contribution - -——>——>——>[Contribution](contribute/contribution.md) - -——>——>——> [Code of Conduct](contribute/code-of-conduct.md) - -——>——>——>[Code Contribution](contribute/code-contribution.md) - -——>——>——>[Contribution Process](contribute/contribution-process.md) - -——>——>——> [Documentation Contribution](contribute/documentation-contribution.md) - -——>——>——>——>[Writing Instructions](contribute/writing-instructions.md) - -——>——>——>——>[Writing Documents for a Release](contribute/docs-release-process.md) - -——>——>——>[Communication in Community](contribute/communication-in-community.md) - -——>——>——>[FAQ](contribute/FAQ.md) diff --git a/en/website.md b/en/website.md new file mode 100644 index 0000000000000000000000000000000000000000..40f4427b9262c95e75d1378605b54c894dc95c1e --- /dev/null +++ b/en/website.md @@ -0,0 +1,515 @@ +- [Application Development Overview](application-dev-guide.md) +- Quick Start + - [Getting Started with Application Development](quick-start/Readme-EN.md) + - DevEco Studio (OpenHarmony) User Guide + - [Overview](quick-start/deveco-studio-overview.md) + - [Version Change History](quick-start/deveco-studio-release-notes.md) + - [Configuring the OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) + - [Creating an OpenHarmony Project](quick-start/create-openharmony-project.md) + - [Using the Project Wizard to Create a Project](quick-start/use-wizard-to-create-project.md) + - [Importing a Sample to Create a Project](quick-start/import-sample-to-create-project.md) + - [Configuring the OpenHarmony App Signature](quick-start/configuring-openharmony-app-signature.md) + - [Installing and Running Your OpenHarmony App](quick-start/installing-openharmony-app.md) + - [Directory Structure](quick-start/package-structure.md) +- Development + - UI + - JavaScript-based Web-Like Development Paradigm + - [Overview](ui/ui-js-overview.md) + - Framework + - [File Organization](ui/js-framework-file.md) + - ["js" Tag](ui/js-framework-js-tag.md) + - [app.js](ui/js-framework-js-file.md) + - Syntax + - [HML](ui/js-framework-syntax-hml.md) + - [CSS](ui/js-framework-syntax-css.md) + - [JavaScript](ui/js-framework-syntax-js.md) + - [Lifecycle](ui/js-framework-lifecycle.md) + - [Resource Limitations and Access](ui/js-framework-resource-restriction.md) + - [Multi-Language Capability](ui/js-framework-multiple-languages.md) + - Building the UI + - [Component Overview](ui/ui-js-building-ui-component.md) + - Building the Layout + - [Layout Description](ui/ui-js-building-ui-layout-intro.md) + - [Adding Title and Paragraph Text](ui/ui-js-building-ui-layout-text.md) + - [Adding an Image](ui/ui-js-building-ui-layout-image.md) + - [Adding a Comment](ui/ui-js-building-ui-layout-comment.md) + - [Adding a Container](ui/ui-js-building-ui-layout-external-container.md) + - [Adding Interactions](ui/ui-js-building-ui-interactions.md) + - [Developing Animations](ui/ui-js-building-ui-animation.md) + - [Defining Events](ui/ui-js-building-ui-event.md) + - [Defining Page Routes](ui/ui-js-building-ui-routes.md) + - Common Component Development Guidelines + - [Text](ui/ui-js-components-text.md) + - [Input](ui/ui-js-components-input.md) + - [Button](ui/ui-js-components-button.md) + - [List](ui/ui-js-components-list.md) + - [Picker](ui/ui-js-components-picker.md) + - [Dialog](ui/ui-js-components-dialog.md) + - [Form](ui/ui-js-components-form.md) + - [Stepper](ui/ui-js-components-stepper.md) + - [Tabs](ui/ui-js-component-tabs.md) + - [Image](ui/ui-js-components-images.md) + - Animation Development Guidelines + - CSS Animation + - [Defining Attribute Style Animations](ui/ui-js-animate-attribute-style.md) + - [Defining Animations with the transform Attribute](ui/ui-js-animate-transform.md) + - [Defining Animations with the background-position Attribute](ui/ui-js-animate-background-position-style.md) + - JS Animation + - [Component Animation](ui/ui-js-animate-component.md) + - Interpolator Animation + - [Animation Effect](ui/ui-js-animate-dynamic-effects.md) + - [Animation Frame](ui/ui-js-animate-frame.md) + - [Custom Components](ui/ui-js-custom-components.md) + - TypeScript-based Declarative Development Paradigm + - [Overview](ui/ui-ts-overview.md) + - Framework Overview + - File Organization + - [Directory Structure](ui/ts-framework-directory.md) + - [Rules for Accessing Application Code Files](ui/ts-framework-file-access-rules.md) + - ["js" Tag](ui/ts-framework-js-tag.md) + - Resource Access + - [Media Resource Types](ui/ts-media-resource-type.md) + - [Pixel Units](ui/ts-pixel-units.md) + - [Types](ui/ts-types.md) + - Declarative Syntax + - [Overview](ui/ts-syntax-intro.md) + - General UI Description Specifications + - [Basic Concepts](ui/ts-general-ui-concepts.md) + - Declarative UI Description Specifications + - [Parameterless Configuration](ui/ts-parameterless-configuration.md) + - [Configuration with Mandatory Parameters](ui/ts-configuration-with-mandatory-parameters.md) + - [Attribution Configuration](ui/ts-attribution-configuration.md) + - [Event Configuration](ui/ts-event-configuration.md) + - [Child Component Configuration](ui/ts-child-component-configuration.md) + - Componentization + - [@Component](ui/ts-component-based-component.md) + - [@Entry](ui/ts-component-based-entry.md) + - [@Preview](ui/ts-component-based-preview.md) + - [@Builder](ui/ts-component-based-builder.md) + - [@Extend](ui/ts-component-based-extend.md) + - [@CustomDialog](ui/ts-component-based-customdialog.md) + - About UI State Management + - [Basic Concepts](ui/ts-ui-state-mgmt-concepts.md) + - Managing Component States + - [@State](ui/ts-component-states-state.md) + - [@Prop](ui/ts-component-states-prop.md) + - [@Link](ui/ts-component-states-link.md) + - Managing Application States + - [AppStorage](ui/ts-application-states-appstorage.md) + - [PersistentStorage](ui/ts-application-states-apis-persistentstorage.md) + - [Environment](ui/ts-application-states-apis-environment.md) + - Managing Other States + - [@observed and @objectLink](ui/ts-other-states-observed-objectlink.md) + - [@Consume and @Provide](ui/ts-other-states-consume-provide.md) + - [@Watch](ui/ts-other-states-watch.md) + - About Rendering Control Syntax + - [if/else](ui/ts-rending-control-syntax-if-else.md) + - [ForEach](ui/ts-rending-control-syntax-foreach.md) + - [LazyForEach](ui/ts-rending-control-syntax-lazyforeach.md) + - About @Component + - [build Function](ui/ts-function-build.md) + - [Custom Component Initialization](ui/ts-custom-component-initialization.md) + - [Custom Component Lifecycle Callbacks](ui/ts-custom-component-lifecycle-callbacks.md) + - [Example: Component Creation and Re-Initialization](ui/ts-component-creation-re-initialization.md) + - [Syntactic Sugar](ui/ts-syntactic-sugar.md) + - Experiencing the Declarative UI + - [Creating a Declarative UI Project](ui/ui-ts-creating-project.md) + - [Getting to Know Components](ui/ui-ts-components.md) + - [Creating a Simple Page](ui/ui-ts-creating-simple-page.md) + - Defining Page Layout and Connection + - [Building a Food Data Model](ui/ui-ts-building-data-model.md) + - [Building a Food Category List Layout](ui/ui-ts-building-category-list-layout.md) + - [Building a Food Category Grid Layout](ui/ui-ts-building-category-grid-layout.md) + - [Implementing Page Redirection and Data Transmission](ui/ui-ts-page-redirection-data-transmission.md) + - Basic Functions + - Agent-Powered Scheduled Reminders + - [Overview](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) + - [Development Guidelines](background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md) + - Background Task Management + - [Background Task Management Overview](background-task-management/background-task-overview.md) + - [Background Task Management Development](background-task-management/background-task-dev-guide.md) + - WebGL + - [WebGL Overview](webgl/webgl-overview.md) + - [WebGL Development](webgl/webgl-guidelines.md) + - Media + - Audio + - [Audio Overview](media/audio-overview.md) + - [Audio Playback Development](media/audio-playback.md) + - [Audio Playback Development Using AudioRenderer](media/audio-renderer.md) + - [Audio Recording Development](media/audio-recorder.md) + - [Audio Recorder Development Using AudioCapturer](media/audio-capturer) + - Video + - [Video Playback Development](media/video-playback.md) + - [Video Recording Development](media/video-recorder.md) + - Security + - User Authentication + - [User Authentication Overview](security/userauth-overview.md) + - [User Authentication Development](security/userauth-guidelines.md) + - Connectivity + - IPC & RPC + - [IPC & RPC Overview](connectivity/ipc-rpc-overview.md) + - [IPC & RPC Development Guidelines](connectivity/ipc-rpc-development-guideline.md) + - [Subscribing to State Changes of a Remote Object](connectivity/subscribe-remote-state.md) + - Data Management + - Distributed Data Service + - [Distributed Data Service Overview](database/database-mdds-overview.md) + - [Distributed Data Service Development](database/database-mdds-guidelines.md) + - Relational Database Overview + - [RDB Overview](database/database-relational-overview.md) + - [RDB Development](database/database-relational-guidelines.md) + - Lightweight Data Store + - [Lightweight Data Store Overview](database/database-preference-overview.md) + - [Lightweight Data Store Development](database/database-preference-guidelines.md) + - Device + - USB Service + - [USB Service Overview](device/usb-overview.md) + - [USB Service Development](device/usb-guidelines.md) + - Location + - [Location Overview](device/device-location-overview.md) + - [Obtaining Device Location Information](device/device-location-info.md) + - [Geocoding and Reverse Geocoding Capabilities](device/device-location-geocoding.md) + - DFX + - Application Event Logging + - [Overview of Application Event Logging](dfx/hiappevent-overview.md) + - [Development Guidelines on Application Event Logging](dfx/hiappevent-guidelines.md) +- Tools + - DevEco Studio (OpenHarmony) User Guide + - [Overview](quick-start/deveco-studio-overview.md) + - [Version Change History](quick-start/deveco-studio-release-notes.md) + - [Configuring the OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) + - [Creating an OpenHarmony Project](quick-start/create-openharmony-project.md) + - [Configuring the OpenHarmony App Signature](quick-start/configuring-openharmony-app-signature.md) + - [Installing and Running Your OpenHarmony App](quick-start/installing-openharmony-app.md) +- Hands-On Tutorials + - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) +- API References + - Compent Reference (JavaScript-based Web-like Development Paradigm) + - [Components](reference/arkui-js/js-components.md) + - [Common](reference/arkui-js/js-components-common.md) + - [Universal Attributes](reference/arkui-js/js-components-common-attributes.md) + - [Universal Styles](reference/arkui-js/js-components-common-styles.md) + - [Universal Events](reference/arkui-js/js-components-common-events.md) + - [Universal Methods](reference/arkui-js/js-components-common-methods.md) + - [Animation Styles](reference/arkui-js/js-components-common-animation.md) + - [Gradient Styles](reference/arkui-js/js-components-common-gradient.md) + - [Transition Styles](reference/arkui-js/js-components-common-transition.md) + - [Custom Font Styles](reference/arkui-js/js-components-common-customizing-font.md) + - [Atomic Layout](reference/arkui-js/js-components-common-atomic-layout.md) + - [Container Component](reference/arkui-js/js-components-container.md) + - [badge](reference/arkui-js/js-components-container-badge.md) + - [dialog](reference/arkui-js/js-components-container-dialog.md) + - [div](reference/arkui-js/js-components-container-div.md) + - [form](reference/arkui-js/js-components-container-form.md) + - [list](reference/arkui-js/js-components-container-list.md) + - [list-item](reference/arkui-js/js-components-container-list-item.md) + - [list-item-group](reference/arkui-js/js-components-container-list-item-group.md) + - [panel](reference/arkui-js/js-components-container-panel.md) + - [popup](reference/arkui-js/js-components-container-popup.md) + - [refresh](reference/arkui-js/js-components-container-refresh.md) + - [stack](reference/arkui-js/js-components-container-stack.md) + - [stepper](reference/arkui-js/js-components-container-stepper.md) + - [stepper-item](reference/arkui-js/js-components-container-stepper-item.md) + - [swiper](reference/arkui-js/js-components-container-swiper.md) + - [tabs](reference/arkui-js/js-components-container-tabs.md) + - [tab-bar](reference/arkui-js/js-components-container-tab-bar.md) + - [tab-content](reference/arkui-js/js-components-container-tab-content.md) + - [Basic Components](reference/arkui-js/js-components-basic.md) + - [button](reference/arkui-js/js-components-basic-button.md) + - [chart](reference/arkui-js/js-components-basic-chart.md) + - [divider](reference/arkui-js/js-components-basic-divider.md) + - [image](reference/arkui-js/js-components-basic-image.md) + - [image-animator](reference/arkui-js/js-components-basic-image-animator.md) + - [input](reference/arkui-js/js-components-basic-input.md) + - [label](reference/arkui-js/js-components-basic-label.md) + - [marquee](reference/arkui-js/js-components-basic-marquee.md) + - [menu](reference/arkui-js/js-components-basic-menu.md) + - [option](reference/arkui-js/js-components-basic-option.md) + - [picker](reference/arkui-js/js-components-basic-picker.md) + - [picker-view](reference/arkui-js/js-components-basic-picker-view.md) + - [piece](reference/arkui-js/js-components-basic-piece.md) + - [progress](reference/arkui-js/js-components-basic-progress.md) + - [qrcode](reference/arkui-js/js-components-basic-qrcode.md) + - [rating](reference/arkui-js/js-components-basic-rating.md) + - [richtext](reference/arkui-js/js-components-basic-richtext.md) + - [search](reference/arkui-js/js-components-basic-search.md) + - [select](reference/arkui-js/js-components-basic-select.md) + - [slider](reference/arkui-js/js-components-basic-slider.md) + - [span](reference/arkui-js/js-components-basic-span.md) + - [switch](reference/arkui-js/js-components-basic-switch.md) + - [text](reference/arkui-js/js-components-basic-text.md) + - [textarea](reference/arkui-js/js-components-basic-textarea.md) + - [toolbar](reference/arkui-js/js-components-basic-toolbar.md) + - [toolbar-item](reference/arkui-js/js-components-basic-toolbar-item.md) + - [toggle](reference/arkui-js/js-components-basic-toggle.md) + - [Media Components](reference/arkui-js/js-components-media.md) + - [video](reference/arkui-js/js-components-media-video.md) + - [Canvas Components](reference/arkui-js/js-components-canvas.md) + - [canvas](reference/arkui-js/js-components-canvas-canvas.md) + - [CanvasRenderingContext2D](reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) + - [Image](reference/arkui-js/js-components-canvas-image.md) + - [CanvasGradient](reference/arkui-js/js-components-canvas-canvasgradient.md) + - [ImageData](reference/arkui-js/js-components-canvas-imagedata.md) + - [Path2D](reference/arkui-js/js-components-canvas-path2d.md) + - [ImageBitmap](reference/arkui-js/js-components-canvas-imagebitmap.md) + - [OffscreenCanvas](reference/arkui-js/js-components-canvas-offscreencanvas.md) + - [OffscreenCanvasRenderingContext2D](reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) + - [Grid](reference/arkui-js/js-components-grid.md) + - [Basic Concepts](reference/arkui-js/js-components-grid-basic-concepts.md) + - [grid-container](reference/arkui-js/js-components-grid-container.md) + - [grid-row](reference/arkui-js/js-components-grid-row.md) + - [grid-col](reference/arkui-js/js-components-grid-col.md) + - [SVG Components](reference/arkui-js/js-svg.md) + - [Universal Attributes](reference/arkui-js/js-components-svg-common-attributes.md) + - [svg](reference/arkui-js/js-components-svg.md) + - [rect](reference/arkui-js/js-components-svg-rect.md) + - [circle](reference/arkui-js/js-components-svg-circle.md) + - [ellipse](reference/arkui-js/js-components-svg-ellipse.md) + - [path](reference/arkui-js/js-components-svg-path.md) + - [line](reference/arkui-js/js-components-svg-line.md) + - [polyline](reference/arkui-js/js-components-svg-polyline.md) + - [polygon](reference/arkui-js/js-components-svg-polygon.md) + - [text](reference/arkui-js/js-components-svg-text.md) + - [tspan](reference/arkui-js/js-components-svg-tspan.md) + - [textPath](reference/arkui-js/js-components-svg-textpath.md) + - [animate](reference/arkui-js/js-components-svg-animate.md) + - [animateMotion](reference/arkui-js/js-components-svg-animatemotion.md) + - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) + - [Custom Components](reference/arkui-js/js-components-custom.md) + - [Basic Usage](reference/arkui-js/js-components-custom-basic-usage.md) + - [Custom Events](reference/arkui-js/js-components-custom-events.md) + - [props](reference/arkui-js/js-components-custom-props.md) + - [Event Parameter](reference/arkui-js/js-components-custom-event-parameter.md) + - [slot](reference/arkui-js/js-components-custom-slot.md) + - [Lifecycle Definition](reference/arkui-js/js-components-custom-lifecycle.md) + - [Appendix](reference/arkui-js/js-appendix.md) + - [Type Attributes](reference/arkui-js/js-appendix-types.md) + - Compent Reference (TypeScript-based Declarative Development Paradigm) + - [Components](reference/arkui-ts/ts-components.md) + - [Universal Components](reference/arkui-ts/ts-universal-components.md) + - [Universal Events](reference/arkui-ts/ts-universal-events.md) + - [Click Event](reference/arkui-ts/ts-universal-events-click.md) + - [Touch](reference/arkui-ts/ts-universal-events-touch.md) + - [Show/Hide Event](reference/arkui-ts/ts-universal-events-show-hide.md) + - [Key Event](reference/arkui-ts/ts-universal-events-key.md) + - [Component Area Change Event](reference/arkui-ts/ts-universal-events-component-area-change.md) + - [Universal Attributes](reference/arkui-ts/ts-universal-attributes.md) + - [Size](reference/arkui-ts/ts-universal-attributes-size.md) + - [Location](reference/arkui-ts/ts-universal-attributes-location.md) + - [Layout Constraints](reference/arkui-ts/ts-universal-attributes-layout-constraints.md) + - [Flex Layout](reference/arkui-ts/ts-universal-attributes-flex-layout.md) + - [Border Configuration](reference/arkui-ts/ts-universal-attributes-border.md) + - [Background](reference/arkui-ts/ts-universal-attributes-background.md) + - [Opacity](reference/arkui-ts/ts-universal-attributes-opacity.md) + - [Visibility](reference/arkui-ts/ts-universal-attributes-visibility.md) + - [Enable/Disable](reference/arkui-ts/ts-universal-attributes-enable.md) + - [Overlay](reference/arkui-ts/ts-universal-attributes-overlay.md) + - [Z-order Control](reference/arkui-ts/ts-universal-attributes-z-order.md) + - [Transformation](reference/arkui-ts/ts-universal-attributes-transformation.md) + - [Image Effect Configuration](reference/arkui-ts/ts-universal-attributes-image-effect.md) + - [Shape Clipping](reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) + - [Text Style](reference/arkui-ts/ts-universal-attributes-text-style.md) + - [Grid](reference/arkui-ts/ts-universal-attributes-grid.md) + - [Gradient Color](reference/arkui-ts/ts-universal-attributes-gradient-color.md) + - [Popup Control](reference/arkui-ts/ts-universal-attributes-popup.md) + - [Menu Control](reference/arkui-ts/ts-universal-attributes-menu.md) + - [Click Control](reference/arkui-ts/ts-universal-attributes-touchable.md) + - [Touch Target](reference/arkui-ts/ts-universal-attributes-response-region.md) + - [Gesture Processing](reference/arkui-ts/ts-gesture-processing.md) + - [Gesture Binding Methods](reference/arkui-ts/ts-gesture-settings.md) + - [Basic Gestures](reference/arkui-ts/ts-basic-gestures.md) + - [TapGesture](reference/arkui-ts/ts-basic-gestures-tapgesture.md) + - [LongPressGesture](reference/arkui-ts/ts-basic-gestures-longpressgesture.md) + - [PanGesture](reference/arkui-ts/ts-basic-gestures-pangesture.md) + - [PinchGesture](reference/arkui-ts/ts-basic-gestures-pinchgesture.md) + - [RotationGesture](reference/arkui-ts/ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](reference/arkui-ts/ts-basic-gestures-swipegesture.md) + - [Combined Gestures](reference/arkui-ts/ts-combined-gestures.md) + - [Basic Components](reference/arkui-ts/ts-basic-components.md) + - [Blank](reference/arkui-ts/ts-basic-components-blank.md) + - [Button](reference/arkui-ts/ts-basic-components-button.md) + - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) + - [Divider](reference/arkui-ts/ts-basic-components-divider.md) + - [Gauge](reference/arkui-ts/ts-basic-components-gauge.md) + - [Image](reference/arkui-ts/ts-basic-components-image.md) + - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) + - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) + - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) + - [Progress](reference/arkui-ts/ts-basic-components-progress.md) + - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) + - [Rating](reference/arkui-ts/ts-basic-components-rating.md) + - [Select](reference/arkui-ts/ts-basic-components-select.md) + - [Slider](reference/arkui-ts/ts-basic-components-slider.md) + - [Span](reference/arkui-ts/ts-basic-components-span.md) + - [Text](reference/arkui-ts/ts-basic-components-text.md) + - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) + - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) + - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) + - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) + - [Container Components](reference/arkui-ts/ts-components-container.md) + - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) + - [Badge](reference/arkui-ts/ts-container-badge.md) + - [Column](reference/arkui-ts/ts-container-column.md) + - [ColumnSplit](reference/arkui-ts/ts-container-columnsplit.md) + - [Counter](reference/arkui-ts/ts-container-counter.md) + - [Flex](reference/arkui-ts/ts-container-flex.md) + - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) + - [Grid](reference/arkui-ts/ts-container-grid.md) + - [GridItem](reference/arkui-ts/ts-container-griditem.md) + - [List](reference/arkui-ts/ts-container-list.md) + - [ListItem](reference/arkui-ts/ts-container-listitem.md) + - [Navigator](reference/arkui-ts/ts-container-navigator.md) + - [Navigation](reference/arkui-ts/ts-container-navigation.md) + - [Panel](reference/arkui-ts/ts-container-panel.md) + - [Row](reference/arkui-ts/ts-container-row.md) + - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) + - [Scroll](reference/arkui-ts/ts-container-scroll.md) + - [ScrollBar](reference/arkui-ts/ts-container-scrollbar.md) + - [Stack](reference/arkui-ts/ts-container-stack.md) + - [Swiper](reference/arkui-ts/ts-container-swiper.md) + - [Tabs](reference/arkui-ts/ts-container-tabs.md) + - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) + - [Refresh](reference/arkui-ts/ts-container-refresh.md) + - [Drawing Components](reference/arkui-ts/ts-drawing-components.md) + - [Circle](reference/arkui-ts/ts-drawing-components-circle.md) + - [Ellipse](reference/arkui-ts/ts-drawing-components-ellipse.md) + - [Line](reference/arkui-ts/ts-drawing-components-line.md) + - [Polyline](reference/arkui-ts/ts-drawing-components-polyline.md) + - [Polygon](reference/arkui-ts/ts-drawing-components-polygon.md) + - [Path](reference/arkui-ts/ts-drawing-components-path.md) + - [Rect](reference/arkui-ts/ts-drawing-components-rect.md) + - [Shape](reference/arkui-ts/ts-drawing-components-shape.md) + - [Canvas Components](reference/arkui-ts/ts-components-canvas.md) + - [Canvas](reference/arkui-ts/ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D](reference/arkui-ts/ts-canvasrenderingcontext2d.md) + - [OffscreenCanvasRenderingConxt2D](reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md) + - [Lottie](reference/arkui-ts/ts-components-canvas-lottie.md) + - [Path2D](reference/arkui-ts/ts-components-canvas-path2d.md) + - [CanvasGradient](reference/arkui-ts/ts-components-canvas-canvasgradient.md) + - [ImageBitmap](reference/arkui-ts/ts-components-canvas-imagebitmap.md) + - [ImageData](reference/arkui-ts/ts-components-canvas-imagedata.md) + - [Animation](reference/arkui-ts/ts-animation.md) + - [Attribute Animation](reference/arkui-ts/ts-animatorproperty.md) + - [Explicit Animation](reference/arkui-ts/ts-explicit-animation.md) + - [Transition Animation](reference/arkui-ts/ts-transition-animation.md) + - [Page Transition](reference/arkui-ts/ts-page-transition-animation.md) + - [Component Transition](reference/arkui-ts/ts-transition-animation-component.md) + - [Transition of Shared Elements](reference/arkui-ts/ts-transition-animation-shared-elements.md) + - [Motion Path Animation](reference/arkui-ts/ts-motion-path-animation.md) + - [Matrix Transformation](reference/arkui-ts/ts-matrix-transformation.md) + - [Interpolation Calculation](reference/arkui-ts/ts-interpolation-calculation.md) + - [Global UI Methods](reference/arkui-ts/ts-global-ui-methods.md) + - [Alert Dialog Box](reference/arkui-ts/ts-methods-alert-dialog-box.md) + - [Custom Dialog box](reference/arkui-ts/ts-methods-custom-dialog-box.md) + - [Image Cache](reference/arkui-ts/ts-methods-image-cache.md) + - [Media Query](reference/arkui-ts/ts-methods-media-query.md) + - [List Selection Dialog Box](reference/arkui-ts/ts-methods-action-sheet.md) + - [Appendix](reference/arkui-ts/ts-appendix.md) + - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) + - APIs + - Ability Framework + - [FeatureAbility Module](reference/apis/js-apis-featureAbility.md) + - [ParticleAbility Module](reference/apis/js-apis-particleAbility.md) + - [DataAbilityHelper Module](reference/apis/js-apis-dataAbilityHelper.md) + - [DataUriUtils Module](reference/apis/js-apis-DataUriUtils.md) + - [Bundle Module](reference/apis/js-apis-Bundle.md) + - [Context Module](reference/apis/js-apis-Context.md) + - Event Notification + - [CommonEvent Module](reference/apis/js-apis-commonEvent.md) + - [Notification Module](reference/apis/js-apis-notification.md) + - [Reminder Agent](reference/apis/js-apis-reminderAgent.md) + - Resource Management + - [Resource Manager](reference/apis/js-apis-resource-manager.md) + - [Internationalization (intl)](reference/apis/js-apis-intl.md) + - [Internationalization (i18n)](reference/apis/js-apis-i18n.md) + - Media + - [Audio Management](reference/apis/js-apis-audio.md) + - [Media](reference/apis/js-apis-media.md) + - Security + - [User Authentication](reference/apis/js-apis-useriam-userauth.md) + - [Access Control](reference/apis/js-apis-abilityAccessCtrl.md) + - Data Management + - [Lightweight Storage (deprecated since 8)](reference/apis/js-apis-data-storage.md) + - [Distributed Data Management](reference/apis/js-apis-distributed-data.md) + - [Relational Database](reference/apis/js-apis-data-rdb.md) + - [Result Set](reference/apis/js-apis-data-resultset.md) + - [DataAbilityPredicates](reference/apis/js-apis-data-ability.md) + - [Settings](reference/apis/js-apis-settings.md) + - File Management + - [File Management](reference/apis/js-apis-fileio.md) + - [Statfs](reference/apis/js-apis-statfs.md) + - [Environment](reference/apis/js-apis-environment.md) + - [Public File Access and Management](reference/apis/js-apis-filemanager.md) + - [App Storage Statistics](reference/apis/js-apis-storage-statistics.md) + - [Volume Management](reference/apis/js-apis-volumemanager.md) + - Account Management + - [Distributed Account Management](reference/apis/js-apis-distributed-account.md) + - [App Account Management](reference/apis/js-apis-appAccount.md) + - Telephony Service + - [Call](reference/apis/js-apis-call.md) + - [SMS](reference/apis/js-apis-sms.md) + - [SIM Management](reference/apis/js-apis-sim.md) + - [Radio](reference/apis/js-apis-radio.md) + - [observer](reference/apis/js-apis-observer.md) + - [Cellular Data](reference/apis/js-apis-telephony-data.md) + - Network and Connectivity + - [WLAN](reference/apis/js-apis-wifi.md) + - [Bluetooth](reference/apis/js-apis-bluetooth.md) + - [RPC](reference/apis/js-apis-rpc.md) + - Device Management + - [Sensor](reference/apis/js-apis-sensor.md) + - [Vibrator](reference/apis/js-apis-vibrator.md) + - [Brightness](reference/apis/js-apis-brightness.md) + - [Battery Info](reference/apis/js-apis-battery-info.md) + - [Power Management](reference/apis/js-apis-power.md) + - [Thermal Management](reference/apis/js-apis-thermal.md) + - [Running Lock](reference/apis/js-apis-runninglock.md) + - [Device Info](reference/apis/js-apis-device-info.md) + - [systemParameter](reference/apis/js-apis-system-parameter.md) + - [Device Management](reference/apis/js-apis-device-manager.md) + - [Window](reference/apis/js-apis-window.md) + - [Display](reference/apis/js-apis-display.md) + - [Update](reference/apis/js-apis-update.md) + - [USB](reference/apis/js-apis-usb.md) + - [Location](reference/apis/js-apis-geolocation.md) + - Basic Features + - [Application Context](reference/apis/js-apis-basic-features-app-context.md) + - [Console Logs](reference/apis/js-apis-basic-features-logs.md) + - [Page Routing](reference/apis/js-apis-basic-features-routes.md) + - [Pop-up Window](reference/apis/js-apis-basic-features-pop-up.md) + - [Application Configuration](reference/apis/js-apis-basic-features-configuration.md) + - [Timer](reference/apis/js-apis-basic-features-timer.md) + - [Setting the System Time](reference/apis/js-apis-system-time.md) + - [Animation](reference/apis/js-apis-basic-features-animator.md) + - [WebGL](reference/apis/js-apis-webgl.md) + - [WebGL2](reference/apis/js-apis-webgl2.md) + - [Screenshot](reference/apis/js-apis-screenshot.md) + - DFX + - [HiAppEvent](reference/apis/js-apis-hiappevent.md) + - [Performance Tracing](reference/apis/js-apis-hitracemeter.md) + - [Fault Logger](reference/apis/js-apis-faultLogger.md) + - [Distributed Call Chain Tracing](reference/apis/js-apis-hitracechain.md) + - [HiLog](reference/apis/js-apis-hilog.md) + - [HiChecker](reference/apis/js-apis-hichecker.md) + - [HiDebug](reference/apis/js-apis-hidebug.md) + - Language Base Class Library + - [Obtaining Process Information](reference/apis/js-apis-process.md) + - [URL String Parsing](reference/apis/js-apis-url.md) + - [URI String Parsing](reference/apis/js-apis-uri.md) + - [Util](reference/apis/js-apis-util.md) + - [XML Parsing and Generation](reference/apis/js-apis-xml.md) + - [XML-to-JavaScript Conversion](reference/apis/js-apis-convertxml.md) + - [Worker Startup](reference/apis/js-apis-worker.md) + - [Linear Container ArrayList](reference/apis/js-apis-arraylist.md) + - [Linear Container Deque](reference/apis/js-apis-deque.md) + - [Linear Container List](reference/apis/js-apis-list.md) + - [Linear Container LinkedList](reference/apis/js-apis-linkedlist.md) + - [Linear Container Queue](reference/apis/js-apis-queue.md) + - [Linear Container Stack](reference/apis/js-apis-stack.md) + - [Linear Container Vector](reference/apis/js-apis-vector.md) + - [Nonlinear Container HashSet](reference/apis/js-apis-hashset.md) + - [Nonlinear Container HashMap](reference/apis/js-apis-hashmap.md) + - [Nonlinear Container PlainArray](reference/apis/js-apis-plainarray.md) + - [Nonlinear Container TreeMap](reference/apis/js-apis-treemap.md) + - [Nonlinear Container TreeSet](reference/apis/js-apis-treeset.md) + - [Nonlinear Container LightWeightMap](reference/apis/js-apis-lightweightmap.md) + - [Nonlinear Container LightWeightSet](reference/apis/js-apis-lightweightset.md) \ No newline at end of file diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index 29c190d3fc62cba8415a36339d3dcb828f2931d2..410850413bf83f387027b0a706063d1fe54e2ecb 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -23,6 +23,7 @@ - [设备管理](device/Readme-CN.md) - [设备使用信息统计](device-usage-statistics/Readme-CN.md) - [DFX](dfx/Readme-CN.md) + - [国际化](internationalization/Readme-CN.md) - 工具 - [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) - 示例教程 diff --git a/zh-cn/application-dev/ability/Readme-CN.md b/zh-cn/application-dev/ability/Readme-CN.md index 3ec466ad1201d16a2d8addc47f257cc84ef933e3..f3b879e4b906488fff13331e10d006dcd98f0a51 100644 --- a/zh-cn/application-dev/ability/Readme-CN.md +++ b/zh-cn/application-dev/ability/Readme-CN.md @@ -1,24 +1,18 @@ -# Ability框架 - -[Ability框架概述](ability-brief.md) - -### FA模型 - -* [FA模型综述](fa-brief.md) -* [PageAbility开发指导](fa-pageability.md) -* [ServiceAbility开发指导](fa-serviceability.md) -* [DataAbility开发指导](fa-dataability.md) -* [FormAbility开发指导](fa-formability.md) - -### Stage模型 - -* [Stage模型综述](stage-brief.md) -* [Ability开发指导](stage-ability.md) -* [ServiceExtensionAbility开发指导](stage-serviceextension.md) -* [FormExtensionAbility开发指导](stage-formextension.md) -* [应用迁移开发指导](stage-ability-continuation.md) - -### 其他 - -* [WantAgent使用指导](wantagent.md) -* [Ability助手使用指导](ability-assistant-guidelines.md) \ No newline at end of file +# Ability开发 + - [Ability框架概述](ability-brief.md) + - FA模型 + - [FA模型综述](fa-brief.md) + - [PageAbility开发指导](fa-pageability.md) + - [ServiceAbility开发指导](fa-serviceability.md) + - [DataAbility开发指导](fa-dataability.md) + - [FormAbility开发指导](fa-formability.md) + - Stage模型 + - [Stage模型综述](stage-brief.md) + - [Ability开发指导](stage-ability.md) + - [ServiceExtensionAbility开发指导](stage-serviceextension.md) + - [FormExtensionAbility开发指导](stage-formextension.md) + - [应用迁移开发指导](stage-ability-continuation.md) + - [Call调用开发指导](stage-call.md) + - 其他 + - [WantAgent使用指导](wantagent.md) + - [Ability助手使用指导](ability-assistant-guidelines.md) \ No newline at end of file diff --git a/zh-cn/application-dev/ability/fa-pageability.md b/zh-cn/application-dev/ability/fa-pageability.md index 8433c7604ef2fd9250d976c972a0bdaa431c8f2e..be05ac164e0c7d39c4f409b122fe5178f07f1a94 100644 --- a/zh-cn/application-dev/ability/fa-pageability.md +++ b/zh-cn/application-dev/ability/fa-pageability.md @@ -19,9 +19,9 @@ Page模板(以下简称“Page”)是FA唯一支持的模板,用于提供 - **INITIAL**:初始化状态,也表示停止状态,表示当前Ability未运行,Ability被启动后由INITIAL态进入INACTIVE状态。 - - **INACTIVE**:未激活状态,表示当前窗口已显示但是无焦点状态,由于Window暂未支持焦点的概念,当前状态与ACTIVE一致。 + - **INACTIVE**:失去焦点状态,表示当前窗口已显示但是无焦点状态。 - - **ACTIVE**:前台激活状态,表示当前窗口已显示,并获取焦点,Ability在退到后台之前先由ACTIVE状态进入INACTIVE状态。 + - **ACTIVE**:前台激活状态,表示当前窗口已显示,并获取焦点。 - **BACKGROUND**: 后台状态,表示当前Ability退到后台,Ability在被销毁后由BACKGROUND状态进入INITIAL状态,或者重新被激活后由BACKGROUND状态进入ACTIVE状态。 @@ -29,7 +29,56 @@ Page模板(以下简称“Page”)是FA唯一支持的模板,用于提供 ![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) - +PageAbility提供如下生命周期回调,开发者可以在 app.js/app.ets 中重写生相关命周期函数 。 + +* onShow() + + Ability由后台不可见状态切换到前台可见状态调用onShow方法,此时用户在屏幕可以看到该Ability。 + +* onHide() + + Ability由前台切换到后台不可见状态时调用onHide方法,此时用户在屏幕看不到该Ability。 + +* onDestroy() + + 应用退出,销毁Ability对象前调用onDestroy方法,开发者可以在该方法里做一些回收资源、清空缓存等应用退出前的准备工作。 + +* onCreate() + + Ability第一次启动创建Ability时调用onCreate方法,开发者可以在该方法里做一些应用初始化工作。 + +* onInactive() + + Ability失去焦点时调用onInactive方法,Ability在进入后台状态时会先失去焦点,再进入后台。 + +* onActive() + + Ability切换到前台,并且已经获取焦点时调用onActive方法。 + +* 示例 + +```javascript +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, + onShow(){ + console.info('Application onShow') + }, + onHide(){ + console.info('Application onHide') + }, + onInactive(){ + console.info('Application onInactive') + }, + onActive(){ + console.info('Application onActive') + }, +} +``` ## 启动本地PageAbility diff --git a/zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png b/zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png index 269d06b73dde7c952b56cd76f1842a856dde3c01..75c61991a79e17ece3d800f9440f1dfcd9b6804d 100644 Binary files a/zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png and b/zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png differ diff --git a/zh-cn/application-dev/ability/figures/page-ability-lifecycle.png b/zh-cn/application-dev/ability/figures/page-ability-lifecycle.png old mode 100644 new mode 100755 index 30160c8129c6556c2784a3bb893ad4cc67332339..edb49acd0647f3af7355ceda987c5ca812866128 Binary files a/zh-cn/application-dev/ability/figures/page-ability-lifecycle.png and b/zh-cn/application-dev/ability/figures/page-ability-lifecycle.png differ diff --git a/zh-cn/application-dev/ability/figures/stage-call.png b/zh-cn/application-dev/ability/figures/stage-call.png new file mode 100644 index 0000000000000000000000000000000000000000..28f2a0f7ea9d86fc81e0c1a37d556384b14a9bdd Binary files /dev/null and b/zh-cn/application-dev/ability/figures/stage-call.png differ diff --git a/zh-cn/application-dev/ability/stage-ability.md b/zh-cn/application-dev/ability/stage-ability.md index 1d8a3b410bf951a4be2111cb5b3537d9b9e8fe8a..7356a8bad4c9cda79f4d3df2f4333a7b6875ca97 100644 --- a/zh-cn/application-dev/ability/stage-ability.md +++ b/zh-cn/application-dev/ability/stage-ability.md @@ -1 +1,213 @@ -# Ability开发指导 \ No newline at end of file +# Ability开发指导 +## 场景介绍 +Stage模型是基于API version 9的应用开发模型,对此模型的介绍详见[Stage模型综述](stage-brief.md)。基于Stage模型的Ability应用开发,主要涉及如下功能逻辑: +- 创建Page Ability应用,如视频播放、新闻资讯等,需要通过屏幕进行浏览的应用,以及支持人机交互。 +- 获取Ability的配置信息,如ApplicationInfo、AbilityInfo及HapModuleInfo等。 +- 启动/带参数启动/带返回结果启动/带AccountId启动其他Ability。 +- 应用向用户申请授权。 +- 系统环境变化通知给AbilityStage及Ability。 +- 通用组件Call功能,详见[Call调用开发指导](stage-call.md)。 +- 连接ServiceAbility,与ServiceAbility断开连接,详见[ServiceExtensionAbility开发指导](stage-serviceextension.md)。 +- 应用迁移,详见[应用迁移开发指导](stage-ability-continuation.md)。 + +## 接口说明 +AbilityStage功能如下:AbilityStage类,拥有context属性,具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md)。 + +**表1** AbilityStage API接口功能介绍 +|接口名|描述| +|:------|:------| +|void onCreate()|AbilityStage初始化时被调用。| +|string onAcceptWant(want: Want)|启动指定Ability时被调用。| +|void onConfigurationUpdated(config: Configuration)|全局配置发生变更时被调用。| + +Ability功能如下:Ability类,具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-application-ability.md)。 + +**表2** Ability API接口功能介绍 +|接口名|描述| +|:------|:------| +|void onCreate(want: Want, param: AbilityConstant.LaunchParam)|Ability生命周期回调,Ability启动时被调用。| +|void onDestroy()|Ability生命周期回调,Ability销毁时被调用。| +|void onWindowStageCreate(windowStage: window.WindowStage)|Ability生命周期回调,创建window stage时被调用,应用开发者可通过window.WindowStage的接口执行页面加载等操作。| +|void onWindowStageDestroy()|Ability生命周期回调,销毁window stage时被调用。| +|void onForeground()|Ability生命周期回调,Ability切换至前台时被调用。| +|void onBackground()|Ability生命周期回调,Ability切换至后台时被调用。| +|void onNewWant(want: Want)|Ability回调,Ability的启动模式设置为单例时被调用。| +|void onConfigurationUpdated(config: Configuration)|Ability回调,Ability的系统配置更新时被调用。| + +Ability类拥有context属性,context属性为AbilityContext类,AbilityContext类拥有abilityInfo、currentHapModuleInfo等属性,具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-ability-context.md)。 + +**表3** AbilityContext API接口功能介绍 +|接口名|描述| +|:------|:------| +|void startAbility(want: Want, callback: AsyncCallback)|启动Ability。| +|void startAbility(want: Want, options: StartOptions, callback: AsyncCallback)|启动Ability。| +|void startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback)|带AccountId启动Ability。| +|void startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback)|带AccountId启动Ability。| +|void startAbilityForResult(want: Want, callback: AsyncCallback)|带返回结果启动Ability。| +|void startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback)|带返回结果启动Ability。| +|void startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback)|带返回结果及AccountId启动Ability。| +|void startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback)|带返回结果及AccountId启动Ability。| +|void terminateSelf(callback: AsyncCallback)|销毁当前的Page Ability。| +|void terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback)|带返回结果销毁当前的Page Ability。| + +## 开发步骤 +### 创建Page Ability应用 +创建Stage模型的Page Ability应用,需实现AbilityStage接口及Ability生命周期接口,并使用窗口提供的方法设置页面。具体示例代码如下: +1. 导入AbilityStage模块 +``` +import AbilityStage from "@ohos.application.AbilityStage" +``` +2. 实现AbilityStage接口 +```ts +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + } +} +``` +3. 导入Ability模块 +``` +import Ability from '@ohos.application.Ability' +``` +4. 实现Ability生命周期接口 +在`onWindowStageCreate(windowStage)`中通过loadContent接口设置应用要加载的页面,window接口的使用详见[窗口开发指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/windowmanager/window-guidelines.md/)。 +```ts +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("MainAbility onCreate") + } + + onDestroy() { + console.log("MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + console.log("MainAbility onWindowStageCreate") + + windowStage.loadContent("pages/index").then((data) => { + console.log("MainAbility load content succeed with data: " + JSON.stringify(data)) + }).catch((error) => { + console.error("MainAbility load content failed with error: "+ JSON.stringify(error)) + }) + } + + onWindowStageDestroy() { + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + console.log("MainAbility onForeground") + } + + onBackground() { + console.log("MainAbility onBackground") + } +} +``` +### 获取AbilityStage及Ability的配置信息 +AbilityStage类及Ability类均拥有context属性,应用可以通过`this.context`获取Ability实例的上下文,进而获取详细的配置信息。如下示例展示了AbilityStage通过context属性获取包代码路径、hap包名、ability名以及系统语言的方法。具体示例代码如下: +```ts +import AbilityStage from "@ohos.application.AbilityStage" +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + let context = this.context + console.log("MyAbilityStage bundleCodeDir" + context.bundleCodeDir) + + let currentHapModuleInfo = context.currentHapModuleInfo + console.log("MyAbilityStage hap module name" + currentHapModuleInfo.name) + console.log("MyAbilityStage hap module mainAbilityName" + currentHapModuleInfo.mainAbilityName) + + let config = this.context.config + console.log("MyAbilityStage config language" + config.language) + } +} +``` + +如下示例展示了Ability通过context属性获取包代码路径、hap包名、ability名以及系统语言的方法。具体示例代码如下: +```ts +import Ability from '@ohos.application.Ability' +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("MainAbility onCreate") + let context = this.context + console.log("MainAbility bundleCodeDir" + context.bundleCodeDir) + + let abilityInfo = this.context.abilityInfo; + console.log("MainAbility ability bundleName" + abilityInfo.bundleName) + console.log("MainAbility ability name" + abilityInfo.name) + + let config = this.context.config + console.log("MyAbilityStage config language" + config.language) + } +} +``` + +### 启动Ability +应用可以通过`this.context`获取Ability实例的上下文,进而使用AbilityContext中的StartAbility相关接口启动Ability。启动Ability可指定Want、StartOptions、accountId,通过callback形式或promise形式实现。具体示例代码如下: +```ts +let context = this.context +var want = { + "deviceId": "", + "bundleName": "com.example.MyApplication", + "abilityName": "MainAbility" +}; +var options = { + windowMode: 0, + displayId: 2 +}; +context.startAbility(want, options).then((data) => { + console.log("Succeed to start ability with data: " + JSON.stringify(data)) +}).catch((error) => { + console.error("Failed to start ability with error: "+ JSON.stringify(error)) +}) +``` + +### 应用向用户申请授权 +应用需要某些权限如存储、位置信息、访问日历时,需要向用户申请授权。具体示例代码如下: +```ts +let context = this.context +let permissions = ohos.permission.READ_CALENDAR +context.requestPermissionsFromUser(permissions).then((data) => { + console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) +}).catch((error) => { + console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) +}) +``` + +### 系统环境变化通知给AbilityStage及Ability +全局配置,比如系统语言和颜色模式发生变化时,通过onConfigurationUpdated接口通知给AbilityStage和Ability。如下示例展示了AbilityStage的onConfigurationUpdated回调实现,系统语言和颜色模式发生变化时触发该回调。具体示例代码如下: +```ts +import Ability from '@ohos.application.Ability' +import ConfigurationConstant from '@ohos.application.ConfigurationConstant' +export default class MyAbilityStage extends AbilityStage { + onConfigurationUpdated(config) { + console.log("MyAbilityStage onConfigurationUpdated") + console.log("MyAbilityStage config language" + config.language) + console.log("MyAbilityStage config colorMode" + config.colorMode) + } +} +``` + +如下示例展示了Ability的onConfigurationUpdated回调实现,系统语言、颜色模式以及Display相关的参数,比如方向、Density,发生变化时触发该回调。具体示例代码如下: +```ts +import Ability from '@ohos.application.Ability' +import ConfigurationConstant from '@ohos.application.ConfigurationConstant' +export default class MainAbility extends Ability { { + onConfigurationUpdated(config) { + console.log("MainAbility onConfigurationUpdated") + console.log("MainAbility config language" + config.language) + console.log("MainAbility config colorMode" + config.colorMode) + console.log("MainAbility config direction" + config.direction) + console.log("MainAbility config screenDensity" + config.screenDensity) + console.log("MainAbility config displayId" + config.displayId) + } +} +``` + +## 开发实例 +针对Stage模型Ability开发,有以下示例工程可供参考: + +[eTSStageCallAbility]() + +本示例eTSStageCallAbility中,在Application目录的AbilityStage.ts中实现AbilityStage的接口,在MainAbility目录实现Ability的接口并设置"pages/index"中的内容为Ability的界面,在SecondAbility目录实现另一个Ability并设置"pages/second"为Ability的界面。支持MainAbility启动SecondAbility。 \ No newline at end of file diff --git a/zh-cn/application-dev/ability/stage-call.md b/zh-cn/application-dev/ability/stage-call.md new file mode 100644 index 0000000000000000000000000000000000000000..f59db4a98c8a4b65fa31d2a7b991bf766b9e7adc --- /dev/null +++ b/zh-cn/application-dev/ability/stage-call.md @@ -0,0 +1,180 @@ +# Call调用开发指导 +## 场景介绍 +Ability Call调用是Ability能力的扩展,它为Ability提供一种能够被外部调用的能力。使Ability既能被拉起到前台展示UI,也支持Ability在后台被创建并运行。应用开发者可通过Call调用,使用IPC通信实现不同Ability之间的数据共享。Call调用的场景主要包括: +- 创建Callee被调用端。 +- 访问Callee被调用端。 + +本文中的Caller和Callee分别表示调用者和被调用者,Call调用流程示意图如下。 + +![stage-call](figures/stage-call.png) + +## 接口说明 +Caller及Callee功能如下:具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-application-ability.md#caller)。 + +**表1** Call API接口功能介绍 +|接口名|描述| +|:------|:------| +|Promise startAbilityByCall(want: Want)|获取指定通用组件的Caller通信接口,拉起指定通用组件并将其切换到后台。| +|void on(method: string, callback: CaleeCallBack)|Callee.on,通用组件Callee注册method对应的callback方法。| +|void off(method: string)|Callee.off,通用组件Callee去注册method的callback方法。| +|Promise call(method: string, data: rpc.Sequenceable)|Caller.call,向通用组件Callee发送约定序列化数据。| +|Promise callWithResult(method: string, data: rpc.Sequenceable)|Caller.callWithResult,向通用组件Callee发送约定序列化数据, 并将返回的约定序列化数据带回。| +|void release()|Caller.release,释放通用组件的Caller通信接口。| +|void onRelease(callback: OnReleaseCallBack)|Caller.onRelease,注册通用组件通信断开监听通知。| + +## 开发步骤 +### 创建Callee被调用端 +Callee被调用端,需要实现指定方法的数据接收回调函数、数据的序列化及反序列化方法。在需要接收数据期间,通过on接口注册监听,无需接收数据时通过off接口解除监听。 +1. 配置Ability的启动模式 +配置module.json5,将Callee被调用端所在的Ability配置为单实例"singleton"。 + +|Json字段|字段说明| +|:------|:------| +|"launchType"|Ability的启动模式,设置为"singleton"类型 | + +Ability配置标签示例如下: +```json +"abilities":[{ + "name": ".CalleeAbility", + "srcEntrance": "./ets/CalleeAbility/CalleeAbility.ts", + "launchType": "singleton", + "description": "$string:CalleeAbility_desc", + "icon": "$media:icon", + "label": "$string:CalleeAbility_label", + "visible": true +}] +``` +2. 导入Ability模块 +``` +import Ability from '@ohos.application.Ability' +``` +3. 定义约定的序列化数据 +调用端及被调用端发送接收的数据格式需协商一致,如下示例约定数据由number和string组成。具体示例代码如下: +```ts +export class MySequenceable { + num: number = 0 + str: String = "" + + constructor(num, string) { + this.num = num + this.str = string + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num) + messageParcel.writeString(this.str) + return true + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt() + this.str = messageParcel.readString() + return true + } +} +``` +4. 实现Callee.on监听及Callee.off解除监听 +被调用端Callee的监听函数注册时机, 取决于应用开发者。注册监听之前的数据不会被处理,取消监听之后的数据不会被处理。如下示例在Ability的onCreate注册'CalleeSortMethod'监听,在onDestroy取消监听,收到序列化数据后对字符串排序后返回,应用开发者根据实际需要做相应处理。具体示例代码如下: +```ts +let TAG = '[CalleeAbility] ' +let method = 'CalleeSortMethod' + +function CalleeSortFunc(data) { + let receiveData = new MySequenceable(0, '') + data.readSequenceable(receiveData) + console.log(TAG + 'receiveData[' + receiveData.num + ',' + receiveData.str + ']') + return new MySequenceable(receiveData.num + 1, Array.from(receiveData.str).sort().join('')) +} + +export default class CalleeAbility extends Ability { + onCreate(want, launchParam) { + try { + this.callee.on(method, CalleeSortFunc) + } catch (error) { + console.error(TAG + method + 'register failed with error: ' + JSON.stringify(error)) + } + } + + onDestroy() { + try { + this.callee.off(method) + } catch (error) { + console.error(TAG + method + 'unregister failed with error: ' + JSON.stringify(error)) + } + } +} +``` + +### 访问Callee被调用端 +1. 导入Ability模块 +``` +import Ability from '@ohos.application.Ability' +``` +2. 获取Caller通信接口 +Ability的context属性实现了startAbilityByCall方法,用于获取指定通用组件的Caller通信接口。如下示例通过`this.context`获取Ability实例的context属性,使用startAbilityByCall拉起Callee被调用端并获取Caller通信接口,注册Caller的onRelease监听。应用开发者根据实际需要做相应处理。具体示例代码如下: +```ts +let TAG = '[MainAbility] ' +var caller = undefined +let context = this.context + +context.startAbilityByCall({ + bundleName: 'com.samples.CallApplication', + abilityName: 'CalleeAbility' +}).then((data) => { + if (data != null) { + caller = data + console.log(TAG + 'get caller success') + // 注册caller的release监听 + caller.onRelease((msg) => { + console.log(TAG + 'caller onRelease is called ' + msg) + }) + console.log(TAG + 'caller register OnRelease succeed') + } +}).catch((error) => { + console.error(TAG + 'get caller failed with ' + error) +}) +``` +3. 发送约定序列化数据 +向被调用端发送Sequenceable数据有两种方式,一种是不带返回值,一种是获取被调用端返回的数据,method以及序列化数据需要与被调用端协商一致。如下示例调用Call接口,向Calee被调用端发送数据。具体示例代码如下: +```ts +let method = 'CalleeSortMethod' +let msg = new MySequenceable(1, 'call_str') +caller.call(method, msg).then(() => { + console.log(TAG + 'caller call succeed') + }).catch((error) => { + console.error(TAG + 'caller call failed with ' + error) +}) +``` + +如下示例调用CallWithResult接口,向Calee被调用端发送待处理的数据,并将method方法处理完毕的数据赋值给callback。具体示例代码如下: +```ts +let method = 'CalleeSortMethod' +let msg = new MySequenceable(1, sortString) +caller.callWithResult(method, msg) + .then((data) => { + let resultMsg = new MySequenceable(0, '') + data.readSequenceable(resultMsg) + callback(resultMsg.str) + console.log(TAG + 'caller result is [' + resultMsg.num + ',' + resultMsg.str + ']') + }).catch((error) => { + console.error(TAG + 'caller callWithResult failed with ' + error) +}) +``` +4. 释放Caller通信接口 +Caller不再使用后,应用开发者可以通过release接口释放Caller。具体示例代码如下: +```ts +try { + caller.release() + caller = undefined + console.log(TAG + 'caller release succeed') +} catch (error) { + console.error(TAG + 'caller release failed with ' + error) +} +``` + +## 开发实例 +针对Stage模型本地Call功能开发,有以下示例工程可供参考: + +[eTSStageCallAbility]() + +本示例eTSStageCallAbility中,在Application目录的AbilityStage.ts中实现AbilityStage的接口,在MainAbility目录实现Ability的接口并设置"pages/index"为应用的界面,在CaleeAbility目录实现Callee被调用端。MainAbility获取Caller通信接口后,支持用户输入字符串,做序列化处理后传递给CaleeAbility被调用端处理,Calee将字符串排序,返回序列化数据并将排序结果显示在页面上。 \ No newline at end of file diff --git a/zh-cn/application-dev/ability/stage-serviceextension.md b/zh-cn/application-dev/ability/stage-serviceextension.md index 76dcddc720f50f79247a68577e12c74d0ae65b26..84bdde71bba7273bdaf8d29839db209b7ff8ef9c 100644 --- a/zh-cn/application-dev/ability/stage-serviceextension.md +++ b/zh-cn/application-dev/ability/stage-serviceextension.md @@ -1 +1,97 @@ -# ServiceExtensionAbility开发指导 \ No newline at end of file +# ServiceExtensionAbility开发指导 + +## 基本概念 +ExtensionAbility,是Stage模型中新增的扩展组件的基类,一般用于处理无界面的任务,生命周期较简单,没有前后台生命周期。ServiceExtensionAbility是ExtensionAbility的扩展类。 + +开发者可以自定义类继承ServiceExtensionAbility,通过重写基类中相关生命周期方法,来做初始化、连接中、断开连接时相关业务逻辑操作。 +ServiceExtensionAbility中相关生命周期说明如下: + + - onCreate() + + 首次调用startAbility、connectAbility时触发,开发者可以进行初始化操作。 + + - onRequest() + + 每次调用startAbility都会触发,首次调用时startId为1,重复调用startAbility递增。 + + - onConnect() + + 调用connectAbility触发,重复调用不会再次触发,除非调用disconnectAbility解除绑定后再调用;onConnect返回一个进程通信类RemoteObject。 + + - onDisconnect() + + 调用disconnectAbility触发,Extension如果是用connectAbility拉起的,并且已经没有其他应用绑定这个Extension,则会触发onDestroy生命周期销毁组件。 + + - onDestroy() + + 调用停止当前ability接口terminateSelf会触发。 + + +## 约束与限制 + +- ServiceExtensionAbility使用和拉起都必须要有系统权限,鸿蒙系统当前不支持三方应用创建、使用和拉起后台应用功能。 + + +## 启动ServiceExtensionAbility + +1.创建ServiceExtensionAbility + +开发者在创建TS文件中自定义类继承ServiceExtensionAbility,重写基类回调函数,示例如下: + + ```js + import rpc from '@ohos.rpc' + class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des); + } + onRemoteRequest(code, data, reply, option) { + } + } + + class ServiceExt extends ServiceExtensionAbility { + onCreate(want) { + console.log('onCreate, want:' + want.abilityName); + } + onRequest(want, startId) { + console.log('onRequest, want:' + want.abilityName); + } + onConnect(want) { + console.log('onConnect , want:' + want.abilityName); + return new StubTest("test"); + } + onDisconnect(want) { + console.log('onDisconnect, want:' + want.abilityName); + } + onDestroy() { + console.log('onDestroy'); + } + } + ``` + + +2.注册ServiceExtensionAbility + +需要在应用配置文件module.json中进行注册,注册类型type需要设置为service。 + +**config.json配置样例** + +```json +"extensionAbilities":[{ + "name": "ServiceExtAbility", + "icon": "$media:icon", + "description": "service", + "type": "service", + "visible": true, + "srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts" +}] +``` + +## 开发实例 + +针对ServiceExtensionAbility开发,有以下示例工程可供参考: + +- [ServiceExtensionAbility]() + +本示例ServiceExtensionAbility中: + +在ServiceExtensionAbility目录中的ServiceExtAbility.ts文件创建一个ServiceExtensionAbility实例。 diff --git a/zh-cn/application-dev/application-dev-website.md b/zh-cn/application-dev/application-dev-website.md index 5f0e6a172862dedcf5b1dd9bf05edb3188db3d86..207bf47591d88f88ddf0a5f7fe0d3ee0a6f174e2 100644 --- a/zh-cn/application-dev/application-dev-website.md +++ b/zh-cn/application-dev/application-dev-website.md @@ -1,644 +1,643 @@ -# 应用开发 - - [应用开发导读](application-dev-guide.md) -- 了解OpenHarmony - - [了解OpenHarmony开源项目](../OpenHarmony-Overview_zh.md) - - [术语](../device-dev/glossary/glossary.md) - - [版本说明](../release-notes/Readme.md) - - - OpenHarmony 3.x Releases - - - [OpenHarmony v3.1 Beta (2021-12-31)](../release-notes/OpenHarmony-v3.1-beta.md) - - [OpenHarmony v3.0.1 LTS (2022-01-12)](../release-notes/OpenHarmony-v3.0.1-LTS.md) - - [OpenHarmony v3.0 LTS (2021-09-30)](../release-notes/OpenHarmony-v3.0-LTS.md) - - - OpenHarmony 2.x Releases - - - [OpenHarmony v2.2 beta2 (2021-08-04)](../release-notes/OpenHarmony-v2.2-beta2.md) - - [OpenHarmony 2.0 Canary (2021-06-01)](../release-notes/OpenHarmony-2-0-Canary.md) - - - OpenHarmony 1.x Releases - - - [OpenHarmony v1.1.4 LTS (2022-02-11)](../release-notes/OpenHarmony-v1-1-4-LTS.md) - - [OpenHarmony v1.1.3 LTS (2021-09-30)](../release-notes/OpenHarmony-v1-1-3-LTS.md) - - [OpenHarmony v1.1.2 LTS (2021-08-04)](../release-notes/OpenHarmony-v1.1.2-LTS.md) - - [OpenHarmony 1.1.1 LTS (2021-06-22)](../release-notes/OpenHarmony-1-1-1-LTS.md) - - [OpenHarmony 1.1.0 LTS (2021-04-01)](../release-notes/OpenHarmony-1-1-0-LTS.md) - - [OpenHarmony 1.0 (2020-09-10)](../release-notes/OpenHarmony-1-0.md) - 快速开始 - - [应用开发快速入门](quick-start/Readme-CN.md) - - DevEco Studio(OpenHarmony)使用指南 - - [概述](quick-start/deveco-studio-overview.md) - - [版本变更说明](quick-start/deveco-studio-release-notes.md) - - [配置OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) - - 创建OpenHarmony工程 - - [使用工程向导创建新工程](quick-start/use-wizard-to-create-project.md) - - [通过导入Sample方式创建新工程](quick-start/import-sample-to-create-project.md) - - [配置OpenHarmony应用签名信息](quick-start/configuring-openharmony-app-signature.md) - - [安装运行OpenHarmony应用](quick-start/installing-openharmony-app.md) - - 快速入门 - - [前言](start-overview.md) - - [使用eTS语言开发](start-with-ets.md) - - [使用JS语言开发(传统代码方式)](start-with-js.md) - - [使用JS语言开发(低代码方式)](start-with-js-low-code.md) - - [应用开发包结构说明](quick-start/quick-start/package-structure.md) -- 开发 - - [Ability开发](ability/Readme-CN.md) - - [Ability框架概述](ability/ability-brief.md) - - FA模型 - - [FA模型综述](ability/fa-brief.md) - - [PageAbility开发指导](ability/fa-pageability.md) - - [ServiceAbility开发指导](ability/fa-serviceability.md) - - [DataAbility开发指导](ability/fa-dataability.md) - - [FormAbility开发指导](ability/fa-formability.md) - - Stage模型 - - [Stage模型综述](ability/stage-brief.md) - - [Ability开发指导](ability/stage-ability.md) - - [ServiceExtensionAbility开发指导](ability/stage-serviceextension.md) - - [FormExtensionAbility开发指导](ability/stage-formextension.md) - - [应用迁移开发指导](ability/stage-ability-continuation.md) - - 其他 - - [WantAgent使用指导](ability/wantagent.md) - - [Ability助手使用指导](ability/ability-assistant-guidelines.md) - - - [UI开发](ui/Readme-CN.md) - - - [方舟开发框架(ArkUI)概述](ui/arkui-overview.md) - - 基于JS扩展的类Web开发范式 - - [概述](ui/ui-js-overview.md) - - 框架说明 - - [文件组织](ui/js-framework-file.md) - - [js标签配置](ui/js-framework-js-tag.md) - - [app.js](ui/js-framework-js-file.md) - - 语法 - - [HML语法参考](ui/js-framework-syntax-hml.md) - - [CSS语法参考](ui/js-framework-syntax-css.md) - - [JS语法参考](ui/js-framework-syntax-js.md) - - [生命周期](ui/js-framework-lifecycle.md) - - [资源限定与访问](ui/js-framework-resource-restriction.md) - - [多语言支持](ui/js-framework-multiple-languages.md) - - 构建用户界面 - - [组件介绍](ui/ui-js-building-ui-component.md) - - 构建布局 - - [布局说明](ui/ui-js-building-ui-layout-intro.md) - - [添加标题行和文本区域](ui/ui-js-building-ui-layout-text.md) - - [添加图片区域](ui/ui-js-building-ui-layout-image.md) - - [添加留言区域](ui/ui-js-building-ui-layout-comment.md) - - [添加容器](ui/ui-js-building-ui-layout-external-container.md) - - [添加交互](ui/ui-js-building-ui-interactions.md) - - [动画](ui/ui-js-building-ui-animation.md) - - [事件](ui/ui-js-building-ui-event.md) - - [页面路由](ui/ui-js-building-ui-routes.md) - - 常见组件开发指导 - - [Text](ui/ui-js-components-text.md) - - [Input](ui/ui-js-components-input.md) - - [Button](ui/ui-js-components-button.md) - - [List](ui/ui-js-components-list.md) - - [Picker](ui/ui-js-components-picker.md) - - [Dialog](ui/ui-js-components-dialog.md) - - [Form](ui/ui-js-components-form.md) - - [Stepper](ui/ui-js-components-stepper.md) - - [Tabs](ui/ui-js-component-tabs.md) - - [Image](ui/ui-js-components-images.md) - - 动效开发指导 - - CSS动画 - - [属性样式动画](ui/ui-js-animate-attribute-style.md) - - [transform样式动画](ui/ui-js-animate-transform.md) - - [background-position样式动画](ui/ui-js-animate-background-position-style.md) - - JS动画 - - [组件动画](ui/ui-js-animate-component.md) - - 插值器动画 - - [动画动效](ui/ui-js-animate-dynamic-effects.md) - - [动画帧](ui/ui-js-animate-frame.md) - - [自定义组件](ui/ui-js-custom-components.md) - - 基于TS扩展的声明式开发范式 - - [概述](ui/ui-ts-overview.md) - - 框架说明 - - 文件组织 - - [目录结构](ui/ts-framework-directory.md) - - [应用代码文件访问规则](ui/ts-framework-file-access-rules.md) - - [js标签配置](ui/ts-framework-js-tag.md) - - 资源访问 - - [媒体资源类型说明](ui/ts-media-resource-type.md) - - [像素单位](ui/ts-pixel-units.md) - - [类型定义](ui/ts-types.md) - - 声明式语法 - - [描述规范使用说明](ui/ts-syntax-intro.md) - - 通用UI描述规范 - - [基本概念](ui/ts-general-ui-concepts.md) - - 声明式UI描述规范 - - [无构造参数配置](ui/ts-parameterless-configuration.md) - - [必选参数构造配置](ui/ts-configuration-with-mandatory-parameters.md) - - [属性配置](ui/ts-attribution-configuration.md) - - [事件配置](ui/ts-event-configuration.md) - - [子组件配置](ui/ts-child-component-configuration.md) - - 组件化 - - [@Component](ui/ts-component-based-component.md) - - [@Entry](ui/ts-component-based-entry.md) - - [@Preview](ui/ts-component-based-preview.md) - - [@Builder](ui/ts-component-based-builder.md) - - [@Extend](ui/ts-component-based-extend.md) - - [@CustomDialog](ui/ts-component-based-customdialog.md) - - [@Styles](ui/ts-component-based-styles.md) - - UI状态管理 - - [基本概念](ui/ts-ui-state-mgmt-concepts.md) - - 管理组件拥有的状态 - - [@State](ui/ts-component-states-state.md) - - [@Prop](ui/ts-component-states-prop.md) - - [@Link](ui/ts-component-states-link.md) - - 管理应用程序的状态 - - [应用程序的数据存储](ui/ts-application-states-appstorage.md) - - [持久化数据管理](ui/ts-application-states-apis-persistentstorage.md) - - [环境变量](ui/ts-application-states-apis-environment.md) - - 其他类目的状态管理 - - [Observed和ObjectLink数据管理](ui/ts-other-states-observed-objectlink.md) - - [@Consume和@Provide数据管理](ui/ts-other-states-consume-provide.md) - - [@Watch](ui/ts-other-states-watch.md) - - 渲染控制语法 - - [条件渲染](ui/ts-rending-control-syntax-if-else.md) - - [循环渲染](ui/ts-rending-control-syntax-foreach.md) - - [数据懒加载](ui/ts-rending-control-syntax-lazyforeach.md) - - 深入理解组件化 - - [build函数](ui/ts-function-build.md) - - [自定义组件初始化](ui/ts-custom-component-initialization.md) - - [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md) - - [组件创建和重新初始化示例](ui/ts-component-creation-re-initialization.md) - - [语法糖](ui/ts-syntactic-sugar.md) - - 体验声明式UI - - [创建声明式UI工程](ui/ui-ts-creating-project.md) - - [初识Component](ui/ui-ts-components.md) - - [创建简单视图](ui/ui-ts-creating-simple-page.md) - - 页面布局与连接 - - [构建食物数据模型](ui/ui-ts-building-data-model.md) - - [构建食物列表List布局](ui/ui-ts-building-category-list-layout.md) - - [构建食物分类Grid布局](ui/ui-ts-building-category-grid-layout.md) - - [页面跳转与数据传递](ui/ui-ts-page-redirection-data-transmission.md) - - - 基础功能开发 - - [窗口管理](windowmanager/Readme-CN.md) - * 窗口 - * [窗口开发概述](windowmanager/window-overview.md) - * [窗口开发指导](windowmanager/window-guidelines.md) - * 显示设备 - * [屏幕属性开发概述](windowmanager/display-overview.md) - * [屏幕属性开发指导](windowmanager/display-guidelines.md) - * 屏幕截图 - * [屏幕截图开发概述](windowmanager/screenshot-overview.md) - * [屏幕截图开发指导](windowmanager/screenshot-guidelines.md) - - [WebGL](webgl/Readme-CN.md) - - [概述](webgl/webgl-overview.md) - - [WebGL开发指导](webgl/webgl-guidelines.md) - - [媒体](media/Readme-CN.md) - - 音频 - - [音频开发概述](media/audio-overview.md) - - [音频播放开发指导](media/audio-playback.md) - - [音频管理开发指导](media/audio-management.md) - - [音频录制开发指导](media/audio-recorder.md) - - 视频 - - [视频播放开发指导](media/video-playback.md) - - [视频录制开发指导](media/video-recorder.md) - - 图片 - - [图片开发指导](media/image.md) - - [安全](security/Readme-CN.md) - - 用户认证 - - [用户认证开发概述](security/userauth-overview.md) - - [用户认证开发指导](security/userauth-guidelines.md) - - - 密钥管理 - - [HUKS开发概述](security/huks-overview.md) - - [HUKS开发指导](security/huks-guidelines.md) - - - Hap包签名工具 - - [Hap包签名工具开发指导](security/hapsigntool-guidelines.md) - - - 访问控制 - - [访问控制开发概述](security/accesstoken-overview.md) - - [访问控制开发指导](security/accesstoken-guidelines.md) - - [网络与连接](connectivity/Readme-CN.md) - - IPC与RPC通信 - - [IPC与RPC通信概述](connectivity/ipc-rpc-overview.md) - - [IPC与RPC通信开发指导](connectivity/ipc-rpc-development-guideline.md) - - [远端状态订阅开发实例](connectivity/subscribe-remote-state.md) - - [数据管理](database/Readme-CN.md) - - 分布式数据服务 - - [分布式数据服务概述](database/database-mdds-overview.md) - - [分布式数据服务开发指导](database/database-mdds-guidelines.md) - - 关系型数据库 - - [关系型数据库概述](database/database-relational-overview.md) - - [关系型数据库开发指导](database/database-relational-guidelines.md) - - 轻量级数据存储 - - [轻量级数据存储概述](database/database-preference-overview.md) - - [轻量级数据存储开发指导](database/database-preference-guidelines.md) - - 分布式数据对象 - - [分布式数据对象概述](database/database-distributedobject-overview.md) - - [分布式数据对象开发指导](database/database-distributedobject-guidelines.md) - - [后台代理提醒](background-agent-scheduled-reminder/Readme-CN.md) - - [概述](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) - - [开发指导](background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md) - - [后台任务管理](background-task-management/Readme-CN.md) - - 后台任务 - - [后台任务概述](background-task-management/background-task-overview.md) - - [后台任务开发指导](background-task-management/background-task-dev-guide.md) - - [设备管理](device/Readme-CN.md) - - USB服务 - - [USB服务开发概述](device/usb-overview.md) - - [USB服务开发指导](device/usb-guidelines.md) - - 位置 - - [位置开发概述](device/device-location-overview.md) - - [获取设备的位置信息](device/device-location-info.md) - - [(逆)地理编码转化](device/device-location-geocoding.md) - - [设备使用信息统计](device-usage-statistics/Readme-CN.md) - - [设备使用信息统计概述](device-usage-statistics/device-usage-statistics-overview.md) - - [设备使用信息统计开发指导](device-usage-statistics/device-usage-statistics-dev-guide.md) - - [DFX](dfx/Readme-CN.md) - - 应用事件打点 - - [应用事件打点概述](dfx/hiappevent-overview.md) - - [应用事件打点开发指导](dfx/hiappevent-guidelines.md) - - 性能打点跟踪 - - [性能打点跟踪概述](dfx/hitracemeter-overview.md) - - [性能打点跟踪开发指导](dfx/hitracemeter-guidelines.md) - - 分布式跟踪 - - [分布式跟踪概述](dfx/hitracechain-overview.md) - - [分布式跟踪开发指导](dfx/hitracechain-guidelines.md) -- 工具 - - [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) + - 应用开发快速入门 + - DevEco Studio(OpenHarmony)使用指南 - [概述](quick-start/deveco-studio-overview.md) - [版本变更说明](quick-start/deveco-studio-release-notes.md) - [配置OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) - - [创建OpenHarmony工程](quick-start/create-openharmony-project.md) + - 创建OpenHarmony工程 + - [使用工程向导创建新工程](quick-start/use-wizard-to-create-project.md) + - [通过导入Sample方式创建新工程](quick-start/import-sample-to-create-project.md) - [配置OpenHarmony应用签名信息](quick-start/configuring-openharmony-app-signature.md) - [安装运行OpenHarmony应用](quick-start/installing-openharmony-app.md) + - 快速入门 + - [前言](quick-start/start-overview.md) + - [使用eTS语言开发](quick-start/start-with-ets.md) + - [使用JS语言开发(传统代码方式)](quick-start/start-with-js.md) + - [使用JS语言开发(低代码方式)](quick-start/start-with-js-low-code.md) + - [应用开发包结构说明](quick-start/package-structure.md) + - [资源文件的分类](quick-start/basic-resource-file-categories.md) +- 开发 + - [Ability开发](ability/Readme-CN.md) + - [Ability框架概述](ability/ability-brief.md) + - FA模型 + - [FA模型综述](ability/fa-brief.md) + - [PageAbility开发指导](ability/fa-pageability.md) + - [ServiceAbility开发指导](ability/fa-serviceability.md) + - [DataAbility开发指导](ability/fa-dataability.md) + - [FormAbility开发指导](ability/fa-formability.md) + - Stage模型 + - [Stage模型综述](ability/stage-brief.md) + - [Ability开发指导](ability/stage-ability.md) + - [ServiceExtensionAbility开发指导](ability/stage-serviceextension.md) + - [FormExtensionAbility开发指导](ability/stage-formextension.md) + - [应用迁移开发指导](ability/stage-ability-continuation.md) + - 其他 + - [WantAgent使用指导](ability/wantagent.md) + - [Ability助手使用指导](ability/ability-assistant-guidelines.md) + - [UI开发](ui/Readme-CN.md) + - [方舟开发框架(ArkUI)概述](ui/arkui-overview.md) + - 基于JS扩展的类Web开发范式 + - [概述](ui/ui-js-overview.md) + - 框架说明 + - [文件组织](ui/js-framework-file.md) + - [js标签配置](ui/js-framework-js-tag.md) + - [app.js](ui/js-framework-js-file.md) + - 语法 + - [HML语法参考](ui/js-framework-syntax-hml.md) + - [CSS语法参考](ui/js-framework-syntax-css.md) + - [JS语法参考](ui/js-framework-syntax-js.md) + - [生命周期](ui/js-framework-lifecycle.md) + - [资源限定与访问](ui/js-framework-resource-restriction.md) + - [多语言支持](ui/js-framework-multiple-languages.md) + - 构建用户界面 + - [组件介绍](ui/ui-js-building-ui-component.md) + - 构建布局 + - [布局说明](ui/ui-js-building-ui-layout-intro.md) + - [添加标题行和文本区域](ui/ui-js-building-ui-layout-text.md) + - [添加图片区域](ui/ui-js-building-ui-layout-image.md) + - [添加留言区域](ui/ui-js-building-ui-layout-comment.md) + - [添加容器](ui/ui-js-building-ui-layout-external-container.md) + - [添加交互](ui/ui-js-building-ui-interactions.md) + - [动画](ui/ui-js-building-ui-animation.md) + - [事件](ui/ui-js-building-ui-event.md) + - [页面路由](ui/ui-js-building-ui-routes.md) + - 常见组件开发指导 + - 容器组件 + - [List开发指导](ui/ui-js-components-list.md) + - [Dialog开发指导](ui/ui-js-components-dialog.md) + - [Form开发指导](ui/ui-js-components-form.md) + - [Stepper开发指导](ui/ui-js-components-stepper.md) + - [Tabs开发指导](ui/ui-js-component-tabs.md) + - [Swiper开发指导](ui/ui-js-components-swiper.md) + - 基础组件 + - [Text开发指导](ui/ui-js-components-text.md) + - [Input开发指导](ui/ui-js-components-input.md) + - [Button开发指导](ui/ui-js-components-button.md) + - [Picker开发指导](ui/ui-js-components-picker.md) + - [Image开发指导](ui/ui-js-components-images.md) + - [Image-animator开发指导](ui/ui-js-components-image-animator.md) + - [Rating开发指导](ui/ui-js-components-rating.md) + - [Slider开发指导](ui/ui-js-components-slider.md) + - [Chart开发指导](ui/ui-js-components-chart.md) + - [Switch开发指导](ui/ui-js-components-switch.md) + - [Toolbar开发指导](ui/ui-js-components-toolbar.md) + - [Menu开发指导](ui/ui-js-components-menu.md) + - [Marquee开发指导](ui/ui-js-components-marquee.md) + - [Qrcode开发指导](ui/ui-js-components-qrcode.md) + - [Search开发指导](ui/ui-js-components-search.md) + - Canvas开发指导 + - [CanvasRenderingContext2D对象](ui/ui-js-components-canvasrenderingcontext2d.md) + - [Path2D对象](ui/ui-js-components-path2d.md) + - [OffscreenCanvas对象](ui/ui-js-components-offscreencanvas.md) + - [栅格布局](ui/ui-js-components-calendar.md) + - Svg开发指导 + - [基础知识](ui/ui-js-components-svg-overview.md) + - [绘制图形](ui/ui-js-components-svg-graphics.md) + - [绘制路径](ui/ui-js-components-svg-path.md) + - [绘制文本](ui/ui-js-components-svg-text.md) + - 动效开发指导 + - CSS动画 + - [属性样式动画](ui/ui-js-animate-attribute-style.md) + - [transform样式动画](ui/ui-js-animate-transform.md) + - [background-position样式动画](ui/ui-js-animate-background-position-style.md) + - [svg动画](ui/ui-js-animate-svg.md) + - JS动画 + - [组件动画](ui/ui-js-animate-component.md) + - 插值器动画 + - [动画动效](ui/ui-js-animate-dynamic-effects.md) + - [动画帧](ui/ui-js-animate-frame.md) + - [自定义组件](ui/ui-js-custom-components.md) + - 基于TS扩展的声明式开发范式 + - [概述](ui/ui-ts-overview.md) + - 框架说明 + - 文件组织 + - [目录结构](ui/ts-framework-directory.md) + - [应用代码文件访问规则](ui/ts-framework-file-access-rules.md) + - [js标签配置](ui/ts-framework-js-tag.md) + - 资源访问 + - [媒体资源类型说明](ui/ts-media-resource-type.md) + - [像素单位](ui/ts-pixel-units.md) + - [类型定义](ui/ts-types.md) + - 声明式语法 + - [描述规范使用说明](ui/ts-syntax-intro.md) + - 通用UI描述规范 + - [基本概念](ui/ts-general-ui-concepts.md) + - 声明式UI描述规范 + - [无构造参数配置](ui/ts-parameterless-configuration.md) + - [必选参数构造配置](ui/ts-configuration-with-mandatory-parameters.md) + - [属性配置](ui/ts-attribution-configuration.md) + - [事件配置](ui/ts-event-configuration.md) + - [子组件配置](ui/ts-child-component-configuration.md) + - 组件化 + - [@Component](ui/ts-component-based-component.md) + - [@Entry](ui/ts-component-based-entry.md) + - [@Preview](ui/ts-component-based-preview.md) + - [@Builder](ui/ts-component-based-builder.md) + - [@Extend](ui/ts-component-based-extend.md) + - [@CustomDialog](ui/ts-component-based-customdialog.md) + - [@Styles](ui/ts-component-based-styles.md) + - UI状态管理 + - [基本概念](ui/ts-ui-state-mgmt-concepts.md) + - 管理组件拥有的状态 + - [@State](ui/ts-component-states-state.md) + - [@Prop](ui/ts-component-states-prop.md) + - [@Link](ui/ts-component-states-link.md) + - 管理应用程序的状态 + - [应用程序的数据存储](ui/ts-application-states-appstorage.md) + - [持久化数据管理](ui/ts-application-states-apis-persistentstorage.md) + - [环境变量](ui/ts-application-states-apis-environment.md) + - 其他类目的状态管理 + - [Observed和ObjectLink数据管理](ui/ts-other-states-observed-objectlink.md) + - [@Consume和@Provide数据管理](ui/ts-other-states-consume-provide.md) + - [@Watch](ui/ts-other-states-watch.md) + - 渲染控制语法 + - [条件渲染](ui/ts-rending-control-syntax-if-else.md) + - [循环渲染](ui/ts-rending-control-syntax-foreach.md) + - [数据懒加载](ui/ts-rending-control-syntax-lazyforeach.md) + - 深入理解组件化 + - [build函数](ui/ts-function-build.md) + - [自定义组件初始化](ui/ts-custom-component-initialization.md) + - [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md) + - [组件创建和重新初始化示例](ui/ts-component-creation-re-initialization.md) + - [语法糖](ui/ts-syntactic-sugar.md) + - 体验声明式UI + - [创建声明式UI工程](ui/ui-ts-creating-project.md) + - [初识Component](ui/ui-ts-components.md) + - [创建简单视图](ui/ui-ts-creating-simple-page.md) + - 页面布局与连接 + - [构建食物数据模型](ui/ui-ts-building-data-model.md) + - [构建食物列表List布局](ui/ui-ts-building-category-list-layout.md) + - [构建食物分类Grid布局](ui/ui-ts-building-category-grid-layout.md) + - [页面跳转与数据传递](ui/ui-ts-page-redirection-data-transmission.md) + - 基础功能开发 + - 窗口管理 + - 窗口 + - [窗口开发概述](windowmanager/window-overview.md) + - [窗口开发指导](windowmanager/window-guidelines.md) + - 显示设备 + - [屏幕属性开发概述](windowmanager/display-overview.md) + - [屏幕属性开发指导](windowmanager/display-guidelines.md) + - 屏幕截图 + - [屏幕截图开发概述](windowmanager/screenshot-overview.md) + - [屏幕截图开发指导](windowmanager/screenshot-guidelines.md) + - WebGL + - [概述](webgl/webgl-overview.md) + - [WebGL开发指导](webgl/webgl-guidelines.md) + - 媒体 + - 音频 + - [音频开发概述](media/audio-overview.md) + - [音频播放开发指导](media/audio-playback.md) + - [音频录制开发指导](media/audio-recorder.md) + - [音频渲染开发指导](media/audio-renderer.md) + - [音频采集开发指导](media/audio-capturer.md) + - 视频 + - [视频播放开发指导](media/video-playback.md) + - [视频录制开发指导](media/video-recorder.md) + - 图片 + - [图片开发指导](media/image.md) + - 安全 + - 用户认证 + - [用户认证开发概述](security/userauth-overview.md) + - [用户认证开发指导](security/userauth-guidelines.md) + - 密钥管理 + - [HUKS开发概述](security/huks-overview.md) + - [HUKS开发指导](security/huks-guidelines.md) + - Hap包签名工具 + - [Hap包签名工具开发指导](security/hapsigntool-guidelines.md) + - 访问控制 + - [访问控制开发概述](security/accesstoken-overview.md) + - [访问控制开发指导](security/accesstoken-guidelines.md) + - 网络与连接 + - IPC与RPC通信 + - [IPC与RPC通信概述](connectivity/ipc-rpc-overview.md) + - [IPC与RPC通信开发指导](connectivity/ipc-rpc-development-guideline.md) + - [远端状态订阅开发实例](connectivity/subscribe-remote-state.md) + - 数据管理 + - 分布式数据服务 + - [分布式数据服务概述](database/database-mdds-overview.md) + - [分布式数据服务开发指导](database/database-mdds-guidelines.md) + - 关系型数据库 + - [关系型数据库概述](database/database-relational-overview.md) + - [关系型数据库开发指导](database/database-relational-guidelines.md) + - 轻量级数据存储 + - [轻量级数据存储概述](database/database-preference-overview.md) + - [轻量级数据存储开发指导](database/database-preference-guidelines.md) + - 分布式数据对象 + - [分布式数据对象概述](database/database-distributedobject-overview.md) + - [分布式数据对象开发指导](database/database-distributedobject-guidelines.md) + - 后台代理提醒 + - [概述](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) + - [开发指导](background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md) + - 后台任务管理 + - 后台任务 + - [后台任务概述](background-task-management/background-task-overview.md) + - [后台任务开发指导](background-task-management/background-task-dev-guide.md) + - 设备管理 + - USB服务 + - [USB服务开发概述](device/usb-overview.md) + - [USB服务开发指导](device/usb-guidelines.md) + - 位置 + - [位置开发概述](device/device-location-overview.md) + - [获取设备的位置信息](device/device-location-info.md) + - [(逆)地理编码转化](device/device-location-geocoding.md) + - 传感器 + - [传感器开发概述](device/sensor-overview.md) + - [传感器开发指导](device/sensor-guidelines.md) + - 振动 + - [振动开发概述](device/vibrator-guidelines.md) + - [振动开发指导](device/vibrator-guidelines.md) + - 设备使用信息统计 + - [设备使用信息统计概述](device-usage-statistics/device-usage-statistics-overview.md) + - [设备使用信息统计开发指导](device-usage-statistics/device-usage-statistics-dev-guide.md) + - DFX + - 应用事件打点 + - [应用事件打点概述](dfx/hiappevent-overview.md) + - [应用事件打点开发指导](dfx/hiappevent-guidelines.md) + - 性能打点跟踪 + - [性能打点跟踪概述](dfx/hitracemeter-overview.md) + - [性能打点跟踪开发指导](dfx/hitracemeter-guidelines.md) + - 分布式跟踪 + - [分布式跟踪概述](dfx/hitracechain-overview.md) + - [分布式跟踪开发指导](dfx/hitracechain-guidelines.md) + - 国际化 + - [国际化开发概述](internationalization/international-overview.md) + - [Intl开发指导](internationalization/intl-guidelines.md) + - [I18n开发指导](internationalization/i18n-guidelines.md) +- 工具 + - DevEco Studio(OpenHarmony)使用指南 + - [概述](quick-start/deveco-studio-overview.md) + - [版本变更说明](quick-start/deveco-studio-release-notes.md) + - [配置OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) + - [创建OpenHarmony工程](quick-start/create-openharmony-project.md) + - [配置OpenHarmony应用签名信息](quick-start/configuring-openharmony-app-signature.md) + - [安装运行OpenHarmony应用](quick-start/installing-openharmony-app.md) - 示例教程 - - [示例代码](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md) - - - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) + - [示例代码](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md) + - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) - API参考 - - [组件参考(基于JS扩展的类Web开发范式)](reference/arkui-js/Readme-CN.md) - - 组件 - - 通用 - - [通用属性](reference/arkui-js/js-components-common-attributes.md) - - [通用样式](reference/arkui-js/js-components-common-styles.md) - - [通用事件](reference/arkui-js/js-components-common-events.md) - - [通用方法](reference/arkui-js/js-components-common-methods.md) - - [动画样式](reference/arkui-js/js-components-common-animation.md) - - [渐变样式](reference/arkui-js/js-components-common-gradient.md) - - [转场样式](reference/arkui-js/js-components-common-transition.md) - - [媒体查询](reference/arkui-js/js-components-common-mediaquery.md) - - [自定义字体样式](reference/arkui-js/js-components-common-customizing-font.md) - - [原子布局](reference/arkui-js/js-components-common-atomic-layout.md) - - 容器组件 - - [badge](reference/arkui-js/js-components-container-badge.md) - - [dialog](reference/arkui-js/js-components-container-dialog.md) - - [div](reference/arkui-js/js-components-container-div.md) - - [form](reference/arkui-js/js-components-container-form.md) - - [list](reference/arkui-js/js-components-container-list.md) - - [list-item](reference/arkui-js/js-components-container-list-item.md) - - [list-item-group](reference/arkui-js/js-components-container-list-item-group.md) - - [panel](reference/arkui-js/js-components-container-panel.md) - - [popup](reference/arkui-js/js-components-container-popup.md) - - [refresh](reference/arkui-js/js-components-container-refresh.md) - - [stack](reference/arkui-js/js-components-container-stack.md) - - [stepper](reference/arkui-js/js-components-container-stepper.md) - - [stepper-item](reference/arkui-js/js-components-container-stepper-item.md) - - [swiper](reference/arkui-js/js-components-container-swiper.md) - - [tabs](reference/arkui-js/js-components-container-tabs.md) - - [tab-bar](reference/arkui-js/js-components-container-tab-bar.md) - - [tab-content](reference/arkui-js/js-components-container-tab-content.md) - - 基础组件 - - [button](reference/arkui-js/js-components-basic-button.md) - - [chart](reference/arkui-js/js-components-basic-chart.md) - - [divider](reference/arkui-js/js-components-basic-divider.md) - - [image](reference/arkui-js/js-components-basic-image.md) - - [image-animator](reference/arkui-js/js-components-basic-image-animator.md) - - [input](reference/arkui-js/js-components-basic-input.md) - - [label](reference/arkui-js/js-components-basic-label.md) - - [marquee](reference/arkui-js/js-components-basic-marquee.md) - - [menu](reference/arkui-js/js-components-basic-menu.md) - - [option](reference/arkui-js/js-components-basic-option.md) - - [picker](reference/arkui-js/js-components-basic-picker.md) - - [picker-view](reference/arkui-js/js-components-basic-picker-view.md) - - [piece](reference/arkui-js/js-components-basic-piece.md) - - [progress](reference/arkui-js/js-components-basic-progress.md) - - [qrcode](reference/arkui-js/js-components-basic-qrcode.md) - - [rating](reference/arkui-js/js-components-basic-rating.md) - - [richtext](reference/arkui-js/js-components-basic-richtext.md) - - [search](reference/arkui-js/js-components-basic-search.md) - - [select](reference/arkui-js/js-components-basic-select.md) - - [slider](reference/arkui-js/js-components-basic-slider.md) - - [span](reference/arkui-js/js-components-basic-span.md) - - [switch](reference/arkui-js/js-components-basic-switch.md) - - [text](reference/arkui-js/js-components-basic-text.md) - - [textarea](reference/arkui-js/js-components-basic-textarea.md) - - [toolbar](reference/arkui-js/js-components-basic-toolbar.md) - - [toolbar-item](reference/arkui-js/js-components-basic-toolbar-item.md) - - [toggle](reference/arkui-js/js-components-basic-toggle.md) - - [web](reference/arkui-js/js-components-basic-web.md) - - 媒体组件 - - [video](reference/arkui-js/js-components-media-video.md) - - 画布组件 - - [canvas组件](reference/arkui-js/js-components-canvas-canvas.md) - - [CanvasRenderingContext2D对象](reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) - - [Image对象](reference/arkui-js/js-components-canvas-image.md) - - [CanvasGradient对象](reference/arkui-js/js-components-canvas-canvasgradient.md) - - [ImageData对象](reference/arkui-js/js-components-canvas-imagedata.md) - - [Path2D对象](reference/arkui-js/js-components-canvas-path2d.md) - - [ImageBitmap对象](reference/arkui-js/js-components-canvas-imagebitmap.md) - - [OffscreenCanvas对象](reference/arkui-js/js-components-canvas-offscreencanvas.md) - - [OffscreenCanvasRenderingContext2D对象](reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) - - 栅格组件 - - [基本概念](reference/arkui-js/js-components-grid-basic-concepts.md) - - [grid-container](reference/arkui-js/js-components-grid-container.md) - - [grid-row](reference/arkui-js/js-components-grid-row.md) - - [grid-col](reference/arkui-js/js-components-grid-col.md) - - svg组件 - - [通用属性](reference/arkui-js/js-components-svg-common-attributes.md) - - [svg](reference/arkui-js/js-components-svg.md) - - [rect](reference/arkui-js/js-components-svg-rect.md) - - [circle](reference/arkui-js/js-components-svg-circle.md) - - [ellipse](reference/arkui-js/js-components-svg-ellipse.md) - - [path](reference/arkui-js/js-components-svg-path.md) - - [line](reference/arkui-js/js-components-svg-line.md) - - [polyline](reference/arkui-js/js-components-svg-polyline.md) - - [polygon](reference/arkui-js/js-components-svg-polygon.md) - - [text](reference/arkui-js/js-components-svg-text.md) - - [tspan](reference/arkui-js/js-components-svg-tspan.md) - - [textPath](reference/arkui-js/js-components-svg-textpath.md) - - [animate](reference/arkui-js/js-components-svg-animate.md) - - [animateMotion](reference/arkui-js/js-components-svg-animatemotion.md) - - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) - - 自定义组件 - - [基本用法](reference/arkui-js/js-components-custom-basic-usage.md) - - [自定义事件](reference/arkui-js/js-components-custom-events.md) - - [Props](reference/arkui-js/js-components-custom-props.md) - - [事件参数](reference/arkui-js/js-components-custom-event-parameter.md) - - [slot插槽](reference/arkui-js/js-components-custom-slot.md) - - [生命周期定义](reference/arkui-js/js-components-custom-lifecycle.md) - - 附录 - - [类型说明](reference/arkui-js/js-appendix-types.md) - - [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/Readme-CN.md) - - 组件 - - 通用 - - 通用事件 - - [点击事件](reference/arkui-ts/ts-universal-events-click.md) - - [触摸事件](reference/arkui-ts/ts-universal-events-touch.md) - - [挂载卸载事件](reference/arkui-ts/ts-universal-events-show-hide.md) - - [拖拽事件](reference/arkui-ts/ts-universal-events-drag-drop.md) - - [按键事件](reference/arkui-ts/ts-universal-events-key.md) - - [焦点事件](reference/arkui-ts/ts-universal-focus-event.md) - - [鼠标事件](reference/arkui-ts/ts-universal-mouse-key.md) - - [组件区域变化事件](reference/arkui-ts/ts-universal-component-area-change-event.md) - - 通用属性 - - [尺寸设置](reference/arkui-ts/ts-universal-attributes-size.md) - - [位置设置](reference/arkui-ts/ts-universal-attributes-location.md) - - [布局约束](reference/arkui-ts/ts-universal-attributes-layout-constraints.md) - - [Flex布局](reference/arkui-ts/ts-universal-attributes-flex-layout.md) - - [边框设置](reference/arkui-ts/ts-universal-attributes-border.md) - - [背景设置](reference/arkui-ts/ts-universal-attributes-background.md) - - [透明度设置](reference/arkui-ts/ts-universal-attributes-opacity.md) - - [显隐控制](reference/arkui-ts/ts-universal-attributes-visibility.md) - - [禁用控制](reference/arkui-ts/ts-universal-attributes-enable.md) - - [浮层](reference/arkui-ts/ts-universal-attributes-overlay.md) - - [Z序控制](reference/arkui-ts/ts-universal-attributes-z-order.md) - - [图形变换](reference/arkui-ts/ts-universal-attributes-transformation.md) - - [图像效果](reference/arkui-ts/ts-universal-attributes-image-effect.md) - - [形状裁剪](reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) - - [文本样式设置](reference/arkui-ts/ts-universal-attributes-text-style.md) - - [栅格设置](reference/arkui-ts/ts-universal-attributes-grid.md) - - [颜色渐变](reference/arkui-ts/ts-universal-attributes-gradient-color.md) - - [Popup控制](reference/arkui-ts/ts-universal-attributes-popup.md) - - [Menu控制](reference/arkui-ts/ts-universal-attributes-menu.md) - - [点击控制](reference/arkui-ts/ts-universal-attributes-click.md) - - [焦点控制](reference/arkui-ts/ts-universal-attributes-focus.md) - - [悬浮态效果](reference/arkui-ts/ts-universal-attributes-hover-effect.md) - - [组件标识](reference/arkui-ts/ts-universal-attributes-component-id.md) - - [触摸热区设置](reference/arkui-ts/ts-universal-attributes-touch-target.md) - - [多态样式](reference/arkui-ts/ts-universal-attributes-polymorphic-style.md) - - 手势处理 - - [绑定手势方法](reference/arkui-ts/ts-gesture-settings.md) - - 基础手势 - - [TapGesture](reference/arkui-ts/ts-basic-gestures-tapgesture.md) - - [LongPressGesture](reference/arkui-ts/ts-basic-gestures-longpressgesture.md) - - [PanGesture](reference/arkui-ts/ts-basic-gestures-pangesture.md) - - [PinchGesture](reference/arkui-ts/ts-basic-gestures-pinchgesture.md) - - [RotationGesture](reference/arkui-ts/ts-basic-gestures-rotationgesture.md) - - [SwipeGesture](reference/arkui-ts/ts-basic-gestures-swipegesture.md) - - [组合手势](reference/arkui-ts/ts-combined-gestures.md) - - 基础组件 - - [Blank](reference/arkui-ts/ts-basic-components-blank.md) - - [Button](reference/arkui-ts/ts-basic-components-button.md) - - [Checkbox](reference/arkui-ts/ts-basic-components-checkbox.md) - - [CheckboxGroup](reference/arkui-ts/ts-basic-components-checkboxgroup.md) - - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) - - [DatePicker](reference/arkui-ts/ts-basic-components-datepicker.md) - - [Divider](reference/arkui-ts/ts-basic-components-divider.md) - - [Image](reference/arkui-ts/ts-basic-components-image.md) - - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) - - [Progress](reference/arkui-ts/ts-basic-components-progress.md) - - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) - - [Radio](reference/arkui-ts/ts-basic-components-radio.md) - - [Rating](reference/arkui-ts/ts-basic-components-rating.md) - - [Select](reference/arkui-ts/ts-basic-components-select.md) - - [Slider](reference/arkui-ts/ts-basic-components-slider.md) - - [Span](reference/arkui-ts/ts-basic-components-span.md) - - [Text](reference/arkui-ts/ts-basic-components-text.md) - - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) - - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) - - [TextPicker](reference/arkui-ts/ts-basic-components-textpicker.md) - - [TextTimer](reference/arkui-ts/ts-basic-components-texttimer.md) - - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) - - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) - - [Web](reference/arkui-ts/ts-basic-components-web.md) - - 容器组件 - - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) - - [Badge](reference/arkui-ts/ts-container-badge.md) - - [Column](reference/arkui-ts/ts-container-column.md) - - [ColumnSplit](reference/arkui-ts/ts-container-columnsplit.md) - - [Counter](reference/arkui-ts/ts-container-counter.md) - - [Flex](reference/arkui-ts/ts-container-flex.md) - - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) - - [Grid](reference/arkui-ts/ts-container-grid.md) - - [GridItem](reference/arkui-ts/ts-container-griditem.md) - - [List](reference/arkui-ts/ts-container-list.md) - - [ListItem](reference/arkui-ts/ts-container-listitem.md) - - [Navigator](reference/arkui-ts/ts-container-navigator.md) - - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) - - [Panel](reference/arkui-ts/ts-container-panel.md) - - [Row](reference/arkui-ts/ts-container-row.md) - - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - - [Scroll](reference/arkui-ts/ts-container-scroll.md) - - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) - - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - - [Stack](reference/arkui-ts/ts-container-stack.md) - - [Swiper](reference/arkui-ts/ts-container-swiper.md) - - [Tabs](reference/arkui-ts/ts-container-tabs.md) - - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) - - [Refresh](reference/arkui-ts/ts-container-refresh.md) - - 媒体组件 - - [Video](reference/arkui-ts/ts-media-components-video.md) - - 绘制组件 - - [Circle](reference/arkui-ts/ts-drawing-components-circle.md) - - [Ellipse](reference/arkui-ts/ts-drawing-components-ellipse.md) - - [Line](reference/arkui-ts/ts-drawing-components-line.md) - - [Polyline](reference/arkui-ts/ts-drawing-components-polyline.md) - - [Polygon](reference/arkui-ts/ts-drawing-components-polygon.md) - - [Path](reference/arkui-ts/ts-drawing-components-path.md) - - [Rect](reference/arkui-ts/ts-drawing-components-rect.md) - - [Shape](reference/arkui-ts/ts-drawing-components-shape.md) - - 画布组件 - - [Canvas](reference/arkui-ts/ts-components-canvas-canvas.md) - - [CanvasRenderingContext2D对象](reference/arkui-ts/ts-canvasrenderingcontext2d.md) - - [OffscreenCanvasRenderingConxt2D对象](reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md) - - [Lottie](reference/arkui-ts/ts-components-canvas-lottie.md) - - [Path2D对象](reference/arkui-ts/ts-components-canvas-path2d.md) - - [CanvasGradient对象](reference/arkui-ts/ts-components-canvas-canvasgradient.md) - - [ImageBitmap对象](reference/arkui-ts/ts-components-canvas-imagebitmap.md) - - [ImageData对象](reference/arkui-ts/ts-components-canvas-imagedata.md) - - 动画 - - [属性动画](reference/arkui-ts/ts-animatorproperty.md) - - [显式动画](reference/arkui-ts/ts-explicit-animation.md) - - 转场动画 - - [页面间转场](reference/arkui-ts/ts-page-transition-animation.md) - - [组件内转场](reference/arkui-ts/ts-transition-animation-component.md) - - [共享元素转场](reference/arkui-ts/ts-transition-animation-shared-elements.md) - - [路径动画](reference/arkui-ts/ts-motion-path-animation.md) - - [矩阵变换](reference/arkui-ts/ts-matrix-transformation.md) - - [插值计算](reference/arkui-ts/ts-interpolation-calculation.md) - - 全局UI方法 - - [图片缓存](reference/arkui-ts/ts-methods-image-cache.md) - - [媒体查询](reference/arkui-ts/ts-methods-media-query.md) - - 弹窗 - - [警告弹窗](reference/arkui-ts/ts-methods-alert-dialog-box.md) - - [列表选择弹窗](reference/arkui-ts/ts-methods-action-sheet.md) - - [自定义弹窗](reference/arkui-ts/ts-methods-custom-dialog-box.md) - - [日期时间选择弹窗](reference/arkui-ts/ts-methods-datepicker-dialog.md) - - [文本选择弹窗](reference/arkui-ts/ts-methods-textpicker-dialog.md) - - [菜单](reference/arkui-ts/ts-methods-menu.md) - - 附录 - - [文档中涉及到的内置枚举值](reference/arkui-ts/ts-appendix-enums.md) - - [接口参考](reference/apis/Readme-CN.md) - - Ability框架 - - [FeatureAbility模块](reference/apis/js-apis-featureAbility.md) - - [ParticleAbility模块](reference/apis/js-apis-particleAbility.md) - - [DataAbilityHelper模块](reference/apis/js-apis-dataAbilityHelper.md) - - [DataUriUtils模块](reference/apis/js-apis-DataUriUtils.md) - - [Bundle模块](reference/apis/js-apis-Bundle.md) - - [Context模块](reference/apis/js-apis-Context.md) - - 事件与通知 - - [CommonEvent模块](reference/apis/js-apis-commonEvent.md) - - [Notification模块](reference/apis/js-apis-notification.md) - - [后台代理提醒](reference/apis/js-apis-reminderAgent.md) - - 资源管理 - - [资源管理](reference/apis/js-apis-resource-manager.md) - - [国际化-Intl](reference/apis/js-apis-intl.md) - - [国际化-I18n](reference/apis/js-apis-i18n.md) - - 媒体 - - [音频管理](reference/apis/js-apis-audio.md) - - [媒体服务](reference/apis/js-apis-media.md) - - [图片处理](reference/apis/js-apis-image.md) - - [相机管理](reference/apis/js-apis-camera.md) - - 安全 - - [用户认证](reference/apis/js-apis-useriam-userauth.md) - - [访问控制](reference/apis/js-apis-abilityAccessCtrl.md) - - [通用密钥库系统](reference/apis/js-apis-huks.md) - - 数据管理 - - [轻量级存储](reference/apis/js-apis-data-preferences.md) - - [分布式数据管理](reference/apis/js-apis-distributed-data.md) - - [关系型数据库](reference/apis/js-apis-data-rdb.md) - - [结果集](reference/apis/js-apis-data-resultset.md) - - [DataAbility 谓词](reference/apis/js-apis-data-ability.md) - - [设置数据项名称](reference/apis/js-apis-settings.md) - - 文件管理 - - [文件管理](reference/apis/js-apis-fileio.md) - - [Statfs](reference/apis/js-apis-statfs.md) - - [目录环境](reference/apis/js-apis-environment.md) - - [公共文件访问与管理](reference/apis/js-apis-filemanager.md) - - [应用空间统计](reference/apis/js-apis-storage-statistics.md) - - [卷管理](reference/apis/js-apis-volumemanager.md) - - 账号管理 - - [系统帐号管理](reference/apis/js-apis-osAccount.md) - - [分布式帐号管理](reference/apis/js-apis-distributed-account.md) - - [应用帐号管理](reference/apis/js-apis-appAccount.md) - - 电话服务 - - [拨打电话](reference/apis/js-apis-call.md) - - [短信服务](reference/apis/js-apis-sms.md) - - [SIM卡管理](reference/apis/js-apis-sim.md) - - [网络搜索](reference/apis/js-apis-radio.md) - - [observer](reference/apis/js-apis-observer.md) - - [蜂窝数据](reference/apis/js-apis-telephony-data.md) - - 网络管理 - - [网络连接管理](reference/apis/js-apis-net-connection.md) - - [Socket连接](reference/apis/js-apis-socket.md) - - [WebSocket连接](reference/apis/js-apis-webSocket.md) - - [数据请求](reference/apis/js-apis-http.md) - - 通信与连接 - - [WLAN](reference/apis/js-apis-wifi.md) - - [Bluetooth](reference/apis/js-apis-bluetooth.md) - - [RPC通信](reference/apis/js-apis-rpc.md) - - 设备管理 - - [传感器](reference/apis/js-apis-sensor.md) - - [振动](reference/apis/js-apis-vibrator.md) - - [屏幕亮度](reference/apis/js-apis-brightness.md) - - [电量信息](reference/apis/js-apis-battery-info.md) - - [系统电源管理](reference/apis/js-apis-power.md) - - [热管理](reference/apis/js-apis-thermal.md) - - [Runninglock锁](reference/apis/js-apis-runninglock.md) - - [设备信息](reference/apis/js-apis-device-info.md) - - [系统属性](reference/apis/js-apis-system-parameter.md) - - [设备管理](reference/apis/js-apis-device-manager.md) - - [窗口](reference/apis/js-apis-window.md) - - [显示设备属性](reference/apis/js-apis-display.md) - - [升级](reference/apis/js-apis-update.md) - - [USB管理](reference/apis/js-apis-usb.md) - - [位置服务](reference/apis/js-apis-geolocation.md) - - 基本功能 - - [应用上下文](reference/apis/js-apis-basic-features-app-context.md) - - [日志打印](reference/apis/js-apis-basic-features-logs.md) - - [页面路由](reference/apis/js-apis-basic-features-routes.md) - - [弹窗](reference/apis/js-apis-basic-features-pop-up.md) - - [应用配置](reference/apis/js-apis-basic-features-configuration.md) - - [定时器](reference/apis/js-apis-basic-features-timer.md) - - [设置系统时间](reference/apis/js-apis-system-time.md) - - [动画](reference/apis/js-apis-basic-features-animator.md) - - [WebGL](reference/apis/js-apis-webgl.md) - - [WebGL2](reference/apis/js-apis-webgl2.md) - - [屏幕截图](reference/apis/js-apis-screenshot.md) - - [输入法框架](reference/apis/js-apis-inputmethod.md) - - [输入法服务](reference/apis/reference/apis/js-apis-inputmethodengine.md) - - [辅助功能](reference/apis/js-apis-accessibility.md) - - DFX - - [应用打点](reference/apis/js-apis-hiappevent.md) - - [性能打点](reference/apis/js-apis-hitracemeter.md) - - [故障日志获取](reference/apis/js-apis-faultLogger.md) - - [分布式跟踪](reference/apis/js-apis-hitracechain.md) - - [日志打印](reference/apis/js-apis-hilog.md) - - [检测模式](reference/apis/js-apis-hichecker.md) - - [Debug调试](reference/apis/js-apis-hidebug.md) - - 语言基础类库 - - [获取进程相关的信息](reference/apis/js-apis-process.md) - - [URL字符串解析](reference/apis/js-apis-url.md) - - [URI字符串解析](reference/apis/js-apis-uri.md) - - [util工具函数](reference/apis/js-apis-util.md) - - [xml解析与生成](reference/apis/js-apis-xml.md) - - [xml转换JavaScript](reference/apis/js-apis-convertxml.md) - - [启动一个worker](reference/apis/js-apis-worker.md) - - [线性容器ArrayList](reference/apis/js-apis-arraylist.md) - - [线性容器Deque](reference/apis/js-apis-deque.md) - - [线性容器List](reference/apis/js-apis-list.md) - - [线性容器LinkedList](reference/apis/js-apis-linkedlist.md) - - [线性容器Queue](reference/apis/js-apis-queue.md) - - [线性容器Stack](reference/apis/js-apis-stack.md) - - [线性容器Vector](reference/apis/js-apis-vector.md) - - [非线性容器HashSet](reference/apis/js-apis-hashset.md) - - [非线性容器HashMap](reference/apis/js-apis-hashmap.md) - - [非线性容器PlainArray](reference/apis/js-apis-plainarray.md) - - [非线性容器TreeMap](reference/apis/js-apis-treemap.md) - - [非线性容器TreeSet](reference/apis/js-apis-treeset.md) - - [非线性容器LightWeightMap](reference/apis/js-apis-lightweightmap.md) - - [非线性容器LightWeightSet](reference/apis/js-apis-lightweightset.md) - - 定制管理 - - [配置策略](reference/apis/js-apis-config-policy.md) - - [企业设备管理](reference/apis/js-apis-enterprise-device-manager.md) -- 贡献 - - - [参与贡献](../contribute/贡献文档.md) \ No newline at end of file + - 组件参考(基于JS扩展的类Web开发范式) + - 组件 + - 通用 + - [通用属性](reference/arkui-js/js-components-common-attributes.md) + - [通用样式](reference/arkui-js/js-components-common-styles.md) + - [通用事件](reference/arkui-js/js-components-common-events.md) + - [通用方法](reference/arkui-js/js-components-common-methods.md) + - [动画样式](reference/arkui-js/js-components-common-animation.md) + - [渐变样式](reference/arkui-js/js-components-common-gradient.md) + - [转场样式](reference/arkui-js/js-components-common-transition.md) + - [自定义字体样式](reference/arkui-js/js-components-common-customizing-font.md) + - [原子布局](reference/arkui-js/js-components-common-atomic-layout.md) + - 容器组件 + - [badge](reference/arkui-js/js-components-container-badge.md) + - [dialog](reference/arkui-js/js-components-container-dialog.md) + - [div](reference/arkui-js/js-components-container-div.md) + - [form](reference/arkui-js/js-components-container-form.md) + - [list](reference/arkui-js/js-components-container-list.md) + - [list-item](reference/arkui-js/js-components-container-list-item.md) + - [list-item-group](reference/arkui-js/js-components-container-list-item-group.md) + - [panel](reference/arkui-js/js-components-container-panel.md) + - [popup](reference/arkui-js/js-components-container-popup.md) + - [refresh](reference/arkui-js/js-components-container-refresh.md) + - [stack](reference/arkui-js/js-components-container-stack.md) + - [stepper](reference/arkui-js/js-components-container-stepper.md) + - [stepper-item](reference/arkui-js/js-components-container-stepper-item.md) + - [swiper](reference/arkui-js/js-components-container-swiper.md) + - [tabs](reference/arkui-js/js-components-container-tabs.md) + - [tab-bar](reference/arkui-js/js-components-container-tab-bar.md) + - [tab-content](reference/arkui-js/js-components-container-tab-content.md) + - 基础组件 + - [button](reference/arkui-js/js-components-basic-button.md) + - [chart](reference/arkui-js/js-components-basic-chart.md) + - [divider](reference/arkui-js/js-components-basic-divider.md) + - [image](reference/arkui-js/js-components-basic-image.md) + - [image-animator](reference/arkui-js/js-components-basic-image-animator.md) + - [input](reference/arkui-js/js-components-basic-input.md) + - [label](reference/arkui-js/js-components-basic-label.md) + - [marquee](reference/arkui-js/js-components-basic-marquee.md) + - [menu](reference/arkui-js/js-components-basic-menu.md) + - [option](reference/arkui-js/js-components-basic-option.md) + - [picker](reference/arkui-js/js-components-basic-picker.md) + - [picker-view](reference/arkui-js/js-components-basic-picker-view.md) + - [piece](reference/arkui-js/js-components-basic-piece.md) + - [progress](reference/arkui-js/js-components-basic-progress.md) + - [qrcode](reference/arkui-js/js-components-basic-qrcode.md) + - [rating](reference/arkui-js/js-components-basic-rating.md) + - [richtext](reference/arkui-js/js-components-basic-richtext.md) + - [search](reference/arkui-js/js-components-basic-search.md) + - [select](reference/arkui-js/js-components-basic-select.md) + - [slider](reference/arkui-js/js-components-basic-slider.md) + - [span](reference/arkui-js/js-components-basic-span.md) + - [switch](reference/arkui-js/js-components-basic-switch.md) + - [text](reference/arkui-js/js-components-basic-text.md) + - [textarea](reference/arkui-js/js-components-basic-textarea.md) + - [toolbar](reference/arkui-js/js-components-basic-toolbar.md) + - [toolbar-item](reference/arkui-js/js-components-basic-toolbar-item.md) + - [toggle](reference/arkui-js/js-components-basic-toggle.md) + - [web](reference/arkui-js/js-components-basic-web.md) + - 媒体组件 + - [video](reference/arkui-js/js-components-media-video.md) + - 画布组件 + - [canvas组件](reference/arkui-js/js-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) + - [Image对象](reference/arkui-js/js-components-canvas-image.md) + - [CanvasGradient对象](reference/arkui-js/js-components-canvas-canvasgradient.md) + - [ImageData对象](reference/arkui-js/js-components-canvas-imagedata.md) + - [Path2D对象](reference/arkui-js/js-components-canvas-path2d.md) + - [ImageBitmap对象](reference/arkui-js/js-components-canvas-imagebitmap.md) + - [OffscreenCanvas对象](reference/arkui-js/js-components-canvas-offscreencanvas.md) + - [OffscreenCanvasRenderingContext2D对象](reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) + - 栅格组件 + - [基本概念](reference/arkui-js/js-components-grid-basic-concepts.md) + - [grid-container](reference/arkui-js/js-components-grid-container.md) + - [grid-row](reference/arkui-js/js-components-grid-row.md) + - [grid-col](reference/arkui-js/js-components-grid-col.md) + - svg组件 + - [通用属性](reference/arkui-js/js-components-svg-common-attributes.md) + - [svg](reference/arkui-js/js-components-svg.md) + - [rect](reference/arkui-js/js-components-svg-rect.md) + - [circle](reference/arkui-js/js-components-svg-circle.md) + - [ellipse](reference/arkui-js/js-components-svg-ellipse.md) + - [path](reference/arkui-js/js-components-svg-path.md) + - [line](reference/arkui-js/js-components-svg-line.md) + - [polyline](reference/arkui-js/js-components-svg-polyline.md) + - [polygon](reference/arkui-js/js-components-svg-polygon.md) + - [text](reference/arkui-js/js-components-svg-text.md) + - [tspan](reference/arkui-js/js-components-svg-tspan.md) + - [textPath](reference/arkui-js/js-components-svg-textpath.md) + - [animate](reference/arkui-js/js-components-svg-animate.md) + - [animateMotion](reference/arkui-js/js-components-svg-animatemotion.md) + - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) + - 自定义组件 + - [基本用法](reference/arkui-js/js-components-custom-basic-usage.md) + - [自定义事件](reference/arkui-js/js-components-custom-events.md) + - [Props](reference/arkui-js/js-components-custom-props.md) + - [事件参数](reference/arkui-js/js-components-custom-event-parameter.md) + - [slot插槽](reference/arkui-js/js-components-custom-slot.md) + - [生命周期定义](reference/arkui-js/js-components-custom-lifecycle.md) + - 附录 + - [类型说明](reference/arkui-js/js-appendix-types.md) + - 组件参考(基于TS扩展的声明式开发范式) + - 组件 + - 通用 + - 通用事件 + - [点击事件](reference/arkui-ts/ts-universal-events-click.md) + - [触摸事件](reference/arkui-ts/ts-universal-events-touch.md) + - [挂载卸载事件](reference/arkui-ts/ts-universal-events-show-hide.md) + - [拖拽事件](reference/arkui-ts/ts-universal-events-drag-drop.md) + - [按键事件](reference/arkui-ts/ts-universal-events-key.md) + - [焦点事件](reference/arkui-ts/ts-universal-focus-event.md) + - [鼠标事件](reference/arkui-ts/ts-universal-mouse-key.md) + - [组件区域变化事件](reference/arkui-ts/ts-universal-component-area-change-event.md) + - 通用属性 + - [尺寸设置](reference/arkui-ts/ts-universal-attributes-size.md) + - [位置设置](reference/arkui-ts/ts-universal-attributes-location.md) + - [布局约束](reference/arkui-ts/ts-universal-attributes-layout-constraints.md) + - [Flex布局](reference/arkui-ts/ts-universal-attributes-flex-layout.md) + - [边框设置](reference/arkui-ts/ts-universal-attributes-border.md) + - [背景设置](reference/arkui-ts/ts-universal-attributes-background.md) + - [透明度设置](reference/arkui-ts/ts-universal-attributes-opacity.md) + - [显隐控制](reference/arkui-ts/ts-universal-attributes-visibility.md) + - [禁用控制](reference/arkui-ts/ts-universal-attributes-enable.md) + - [浮层](reference/arkui-ts/ts-universal-attributes-overlay.md) + - [Z序控制](reference/arkui-ts/ts-universal-attributes-z-order.md) + - [图形变换](reference/arkui-ts/ts-universal-attributes-transformation.md) + - [图像效果](reference/arkui-ts/ts-universal-attributes-image-effect.md) + - [形状裁剪](reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) + - [文本样式设置](reference/arkui-ts/ts-universal-attributes-text-style.md) + - [栅格设置](reference/arkui-ts/ts-universal-attributes-grid.md) + - [颜色渐变](reference/arkui-ts/ts-universal-attributes-gradient-color.md) + - [Popup控制](reference/arkui-ts/ts-universal-attributes-popup.md) + - [Menu控制](reference/arkui-ts/ts-universal-attributes-menu.md) + - [点击控制](reference/arkui-ts/ts-universal-attributes-click.md) + - [焦点控制](reference/arkui-ts/ts-universal-attributes-focus.md) + - [悬浮态效果](reference/arkui-ts/ts-universal-attributes-hover-effect.md) + - [组件标识](reference/arkui-ts/ts-universal-attributes-component-id.md) + - [触摸热区设置](reference/arkui-ts/ts-universal-attributes-touch-target.md) + - [多态样式](reference/arkui-ts/ts-universal-attributes-polymorphic-style.md) + - 手势处理 + - [绑定手势方法](reference/arkui-ts/ts-gesture-settings.md) + - 基础手势 + - [TapGesture](reference/arkui-ts/ts-basic-gestures-tapgesture.md) + - [LongPressGesture](reference/arkui-ts/ts-basic-gestures-longpressgesture.md) + - [PanGesture](reference/arkui-ts/ts-basic-gestures-pangesture.md) + - [PinchGesture](reference/arkui-ts/ts-basic-gestures-pinchgesture.md) + - [RotationGesture](reference/arkui-ts/ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](reference/arkui-ts/ts-basic-gestures-swipegesture.md) + - [组合手势](reference/arkui-ts/ts-combined-gestures.md) + - 基础组件 + - [Blank](reference/arkui-ts/ts-basic-components-blank.md) + - [Button](reference/arkui-ts/ts-basic-components-button.md) + - [Checkbox](reference/arkui-ts/ts-basic-components-checkbox.md) + - [CheckboxGroup](reference/arkui-ts/ts-basic-components-checkboxgroup.md) + - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) + - [DatePicker](reference/arkui-ts/ts-basic-components-datepicker.md) + - [Divider](reference/arkui-ts/ts-basic-components-divider.md) + - [Image](reference/arkui-ts/ts-basic-components-image.md) + - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) + - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) + - [Progress](reference/arkui-ts/ts-basic-components-progress.md) + - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) + - [Radio](reference/arkui-ts/ts-basic-components-radio.md) + - [Rating](reference/arkui-ts/ts-basic-components-rating.md) + - [Select](reference/arkui-ts/ts-basic-components-select.md) + - [Slider](reference/arkui-ts/ts-basic-components-slider.md) + - [Span](reference/arkui-ts/ts-basic-components-span.md) + - [Text](reference/arkui-ts/ts-basic-components-text.md) + - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) + - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) + - [TextPicker](reference/arkui-ts/ts-basic-components-textpicker.md) + - [TextTimer](reference/arkui-ts/ts-basic-components-texttimer.md) + - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) + - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) + - [Web](reference/arkui-ts/ts-basic-components-web.md) + - 容器组件 + - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) + - [Badge](reference/arkui-ts/ts-container-badge.md) + - [Column](reference/arkui-ts/ts-container-column.md) + - [ColumnSplit](reference/arkui-ts/ts-container-columnsplit.md) + - [Counter](reference/arkui-ts/ts-container-counter.md) + - [Flex](reference/arkui-ts/ts-container-flex.md) + - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) + - [Grid](reference/arkui-ts/ts-container-grid.md) + - [GridItem](reference/arkui-ts/ts-container-griditem.md) + - [List](reference/arkui-ts/ts-container-list.md) + - [ListItem](reference/arkui-ts/ts-container-listitem.md) + - [Navigator](reference/arkui-ts/ts-container-navigator.md) + - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) + - [Panel](reference/arkui-ts/ts-container-panel.md) + - [Row](reference/arkui-ts/ts-container-row.md) + - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) + - [Scroll](reference/arkui-ts/ts-container-scroll.md) + - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) + - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) + - [Stack](reference/arkui-ts/ts-container-stack.md) + - [Swiper](reference/arkui-ts/ts-container-swiper.md) + - [Tabs](reference/arkui-ts/ts-container-tabs.md) + - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) + - [Refresh](reference/arkui-ts/ts-container-refresh.md) + - 媒体组件 + - [Video](reference/arkui-ts/ts-media-components-video.md) + - 绘制组件 + - [Circle](reference/arkui-ts/ts-drawing-components-circle.md) + - [Ellipse](reference/arkui-ts/ts-drawing-components-ellipse.md) + - [Line](reference/arkui-ts/ts-drawing-components-line.md) + - [Polyline](reference/arkui-ts/ts-drawing-components-polyline.md) + - [Polygon](reference/arkui-ts/ts-drawing-components-polygon.md) + - [Path](reference/arkui-ts/ts-drawing-components-path.md) + - [Rect](reference/arkui-ts/ts-drawing-components-rect.md) + - [Shape](reference/arkui-ts/ts-drawing-components-shape.md) + - 画布组件 + - [Canvas](reference/arkui-ts/ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](reference/arkui-ts/ts-canvasrenderingcontext2d.md) + - [OffscreenCanvasRenderingConxt2D对象](reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md) + - [Lottie](reference/arkui-ts/ts-components-canvas-lottie.md) + - [Path2D对象](reference/arkui-ts/ts-components-canvas-path2d.md) + - [CanvasGradient对象](reference/arkui-ts/ts-components-canvas-canvasgradient.md) + - [ImageBitmap对象](reference/arkui-ts/ts-components-canvas-imagebitmap.md) + - [ImageData对象](reference/arkui-ts/ts-components-canvas-imagedata.md) + - 动画 + - [属性动画](reference/arkui-ts/ts-animatorproperty.md) + - [显式动画](reference/arkui-ts/ts-explicit-animation.md) + - 转场动画 + - [页面间转场](reference/arkui-ts/ts-page-transition-animation.md) + - [组件内转场](reference/arkui-ts/ts-transition-animation-component.md) + - [共享元素转场](reference/arkui-ts/ts-transition-animation-shared-elements.md) + - [路径动画](reference/arkui-ts/ts-motion-path-animation.md) + - [矩阵变换](reference/arkui-ts/ts-matrix-transformation.md) + - [插值计算](reference/arkui-ts/ts-interpolation-calculation.md) + - 全局UI方法 + - [图片缓存](reference/arkui-ts/ts-methods-image-cache.md) + - [媒体查询](reference/arkui-ts/ts-methods-media-query.md) + - 弹窗 + - [警告弹窗](reference/arkui-ts/ts-methods-alert-dialog-box.md) + - [列表选择弹窗](reference/arkui-ts/ts-methods-action-sheet.md) + - [自定义弹窗](reference/arkui-ts/ts-methods-custom-dialog-box.md) + - [日期时间选择弹窗](reference/arkui-ts/ts-methods-datepicker-dialog.md) + - [文本选择弹窗](reference/arkui-ts/ts-methods-textpicker-dialog.md) + - [菜单](reference/arkui-ts/ts-methods-menu.md) + - 附录 + - [文档中涉及到的内置枚举值](reference/arkui-ts/ts-appendix-enums.md) + - 接口参考 + - Ability框架 + - [FeatureAbility模块](reference/apis/js-apis-featureAbility.md) + - [ParticleAbility模块](reference/apis/js-apis-particleAbility.md) + - [DataAbilityHelper模块](reference/apis/js-apis-dataAbilityHelper.md) + - [DataUriUtils模块](reference/apis/js-apis-DataUriUtils.md) + - [Bundle模块](reference/apis/js-apis-Bundle.md) + - [Context模块](reference/apis/js-apis-Context.md) + - 事件与通知 + - [CommonEvent模块](reference/apis/js-apis-commonEvent.md) + - [Notification模块](reference/apis/js-apis-notification.md) + - [后台代理提醒](reference/apis/js-apis-reminderAgent.md) + - 资源管理 + - [资源管理](reference/apis/js-apis-resource-manager.md) + - [国际化-Intl](reference/apis/js-apis-intl.md) + - [国际化-I18n](reference/apis/js-apis-i18n.md) + - 媒体 + - [音频管理](reference/apis/js-apis-audio.md) + - [媒体服务](reference/apis/js-apis-media.md) + - [图片处理](reference/apis/js-apis-image.md) + - [相机管理](reference/apis/js-apis-camera.md) + - 安全 + - [用户认证](reference/apis/js-apis-useriam-userauth.md) + - [访问控制](reference/apis/js-apis-abilityAccessCtrl.md) + - [通用密钥库系统](reference/apis/js-apis-huks.md) + - 数据管理 + - [轻量级存储](reference/apis/js-apis-data-preferences.md) + - [分布式数据管理](reference/apis/js-apis-distributed-data.md) + - [关系型数据库](reference/apis/js-apis-data-rdb.md) + - [结果集](reference/apis/js-apis-data-resultset.md) + - [DataAbility 谓词](reference/apis/js-apis-data-ability.md) + - [设置数据项名称](reference/apis/js-apis-settings.md) + - 文件管理 + - [文件管理](reference/apis/js-apis-fileio.md) + - [Statfs](reference/apis/js-apis-statfs.md) + - [目录环境](reference/apis/js-apis-environment.md) + - [公共文件访问与管理](reference/apis/js-apis-filemanager.md) + - [应用空间统计](reference/apis/js-apis-storage-statistics.md) + - [卷管理](reference/apis/js-apis-volumemanager.md) + - 账号管理 + - [系统帐号管理](reference/apis/js-apis-osAccount.md) + - [分布式帐号管理](reference/apis/js-apis-distributed-account.md) + - [应用帐号管理](reference/apis/js-apis-appAccount.md) + - 电话服务 + - [拨打电话](reference/apis/js-apis-call.md) + - [短信服务](reference/apis/js-apis-sms.md) + - [SIM卡管理](reference/apis/js-apis-sim.md) + - [网络搜索](reference/apis/js-apis-radio.md) + - [observer](reference/apis/js-apis-observer.md) + - [蜂窝数据](reference/apis/js-apis-telephony-data.md) + - 网络管理 + - [网络连接管理](reference/apis/js-apis-net-connection.md) + - [Socket连接](reference/apis/js-apis-socket.md) + - [WebSocket连接](reference/apis/js-apis-webSocket.md) + - [数据请求](reference/apis/js-apis-http.md) + - 通信与连接 + - [WLAN](reference/apis/js-apis-wifi.md) + - [Bluetooth](reference/apis/js-apis-bluetooth.md) + - [RPC通信](reference/apis/js-apis-rpc.md) + - 设备管理 + - [传感器](reference/apis/js-apis-sensor.md) + - [振动](reference/apis/js-apis-vibrator.md) + - [屏幕亮度](reference/apis/js-apis-brightness.md) + - [电量信息](reference/apis/js-apis-battery-info.md) + - [系统电源管理](reference/apis/js-apis-power.md) + - [热管理](reference/apis/js-apis-thermal.md) + - [Runninglock锁](reference/apis/js-apis-runninglock.md) + - [设备信息](reference/apis/js-apis-device-info.md) + - [系统属性](reference/apis/js-apis-system-parameter.md) + - [设备管理](reference/apis/js-apis-device-manager.md) + - [窗口](reference/apis/js-apis-window.md) + - [显示设备属性](reference/apis/js-apis-display.md) + - [升级](reference/apis/js-apis-update.md) + - [USB管理](reference/apis/js-apis-usb.md) + - [位置服务](reference/apis/js-apis-geolocation.md) + - 基本功能 + - [应用上下文](reference/apis/js-apis-system-app.md) + - [日志打印](reference/apis/js-apis-basic-features-logs.md) + - [页面路由](reference/apis/js-apis-system-router.md) + - [弹窗](reference/apis/js-apis-system-prompt.md) + - [应用配置](reference/apis/js-apis-system-configuration.md) + - [定时器](reference/apis/js-apis-basic-features-timer.md) + - [设置系统时间](reference/apis/js-apis-system-time.md) + - [动画](reference/apis/js-apis-basic-features-animator.md) + - [WebGL](reference/apis/js-apis-webgl.md) + - [WebGL2](reference/apis/js-apis-webgl2.md) + - [屏幕截图](reference/apis/js-apis-screenshot.md) + - [输入法框架](reference/apis/js-apis-inputmethod.md) + - [输入法服务](reference/apis/js-apis-inputmethodengine.md) + - [辅助功能](reference/apis/js-apis-accessibility.md) + - DFX + - [应用打点](reference/apis/js-apis-hiappevent.md) + - [性能打点](reference/apis/js-apis-hitracemeter.md) + - [故障日志获取](reference/apis/js-apis-faultLogger.md) + - [分布式跟踪](reference/apis/js-apis-hitracechain.md) + - [日志打印](reference/apis/js-apis-hilog.md) + - [检测模式](reference/apis/js-apis-hichecker.md) + - [Debug调试](reference/apis/js-apis-hidebug.md) + - 语言基础类库 + - [获取进程相关的信息](reference/apis/js-apis-process.md) + - [URL字符串解析](reference/apis/js-apis-url.md) + - [URI字符串解析](reference/apis/js-apis-uri.md) + - [util工具函数](reference/apis/js-apis-util.md) + - [xml解析与生成](reference/apis/js-apis-xml.md) + - [xml转换JavaScript](reference/apis/js-apis-convertxml.md) + - [启动一个worker](reference/apis/js-apis-worker.md) + - [线性容器ArrayList](reference/apis/js-apis-arraylist.md) + - [线性容器Deque](reference/apis/js-apis-deque.md) + - [线性容器List](reference/apis/js-apis-list.md) + - [线性容器LinkedList](reference/apis/js-apis-linkedlist.md) + - [线性容器Queue](reference/apis/js-apis-queue.md) + - [线性容器Stack](reference/apis/js-apis-stack.md) + - [线性容器Vector](reference/apis/js-apis-vector.md) + - [非线性容器HashSet](reference/apis/js-apis-hashset.md) + - [非线性容器HashMap](reference/apis/js-apis-hashmap.md) + - [非线性容器PlainArray](reference/apis/js-apis-plainarray.md) + - [非线性容器TreeMap](reference/apis/js-apis-treemap.md) + - [非线性容器TreeSet](reference/apis/js-apis-treeset.md) + - [非线性容器LightWeightMap](reference/apis/js-apis-lightweightmap.md) + - [非线性容器LightWeightSet](reference/apis/js-apis-lightweightset.md) + - 定制管理 + - [配置策略](reference/apis/js-apis-config-policy.md) + - [企业设备管理](reference/apis/js-apis-enterprise-device-manager.md) \ No newline at end of file diff --git a/zh-cn/application-dev/database/database-distributedobject-guidelines.md b/zh-cn/application-dev/database/database-distributedobject-guidelines.md index 5b74de768c4e3c98c941b9a5b4d9079408a9a6b5..60725c7fd01c91aea14f417afff80f66ae6e5439 100644 --- a/zh-cn/application-dev/database/database-distributedobject-guidelines.md +++ b/zh-cn/application-dev/database/database-distributedobject-guidelines.md @@ -15,7 +15,7 @@ **表1** 分布式数据对象实例创建接口 | 包名 | 接口名 | 描述 | | -------- | -------- | -------- | -| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | 创建一个分布式数据对象实例,用于数据操作 | +| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | 创建一个分布式数据对象实例,用于数据操作
- source:设置distributedObject的属性。
- DistributedObject:返回值是创建好的分布式对象。| ### 创建分布式数据对象sessionId @@ -33,7 +33,7 @@ **表3** 分布式数据对象sessionId设置接口 | 类名 | 接口名 | 描述 | | -------- | -------- | -------- | -| DistributedDataObject | setSessionId(sessionId?: string): boolean | 为分布式数据对象设置sessionId | +| DistributedDataObject | setSessionId(sessionId?: string): boolean | 为分布式数据对象设置sessionId
 sessionId:如果指定sessionId,则退出指定分布式组网;如果不指定,则全部退出。| ### 订阅数据变更 @@ -43,7 +43,7 @@ | 类名 | 接口名 | 描述 | | -------- | -------- | -------- | | DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | 订阅数据变更。 | -| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | 注销订阅。 | +| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | 注销订阅。需要删除的变更回调,若不设置则删除该对象所有的变更回调。 | ### 订阅数据对象上下线 @@ -83,12 +83,12 @@ //发起方 var local_object = distributedObject.createDistributedObject({name:"jack", age:18, isVis:true, parent:{mother:"jack mom",father:"jack Dad"},[{mother:"jack mom"}, {father:"jack Dad"}]}; - local_object.setsessionId(sessionId); + local_object.setSessionId(sessionId); - //被发起方 + //被拉起方 var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true, parent:undefined, list:undefined}); - remote_object.setsessionId(sessionId); + remote_object.setSessionId(sessionId); //收到status上线后remote_object同步数据,即name变成jack,age是18 ``` diff --git a/zh-cn/application-dev/database/database-relational-guidelines.md b/zh-cn/application-dev/database/database-relational-guidelines.md index 360dc328abbffe62fd68f4900437d91a83117c95..614e0c20716b42d285cc479d0655271d7af145e7 100644 --- a/zh-cn/application-dev/database/database-relational-guidelines.md +++ b/zh-cn/application-dev/database/database-relational-guidelines.md @@ -133,20 +133,7 @@ | ResultSet | isColumnNull(columnIndex: number): boolean | 检查当前行中指定列的值是否为null。 | | ResultSet | close(): void | 关闭结果集。 | -**数据库更改秘钥** -用户可以对当前数据库进行加密。 - -数据库的加密仅限于初始使用一个数据库时就进行加密,使用过程中进行秘钥的变更,但不支持取消秘钥。 - -数据库初始时为加密库,则一直为加密库;初始时为未加密库,则一直为未加密库。 - -**表8** 数据库更改秘钥 - -| 类名 | 接口名 | 描述 | -| -------- | -------- | -------- | -| RdbStore | changeEncryptKey(newEncryptKey:Uint8Array, callback: AsyncCallback<number>):void; | 数据库更改秘钥接口,通过callback 可以异步处理返回结果。返回结果0成功,非0失败。 | -| RdbStore | changeEncryptKey(newEncryptKey:Uint8Array): Promise<number>; | 数据库更改秘钥接口,通过await 可以同步处理返回结果。返回结果0成功,非0失败。 | **设置分布式列表。** @@ -207,12 +194,12 @@ 示例代码如下: ``` - 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); ``` @@ -236,7 +223,7 @@ 示例代码如下: ``` - let predicates = new dataRdb.RdbPredicates("test"); + let predicates = new data_rdb.RdbPredicates("test"); predicates.equalTo("name", "Tom") let resultSet = await rdbStore.query(predicates) @@ -273,7 +260,7 @@ 示例代码如下: ``` - 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/zh-cn/application-dev/device/Readme-CN.md b/zh-cn/application-dev/device/Readme-CN.md index 78cbf49d8d20258086b4fb2faef038bd3575da89..238af0464cfa601cde081f594f9a70413315dc7b 100644 --- a/zh-cn/application-dev/device/Readme-CN.md +++ b/zh-cn/application-dev/device/Readme-CN.md @@ -7,3 +7,9 @@ - [位置开发概述](device-location-overview.md) - [获取设备的位置信息](device-location-info.md) - [(逆)地理编码转化](device-location-geocoding.md) +- 传感器 + - [传感器开发概述](sensor-overview.md) + - [传感器开发指导](sensor-guidelines.md) +- 振动 + - [振动开发概述](vibrator-guidelines.md) + - [振动开发指导](vibrator-guidelines.md) diff --git a/zh-cn/application-dev/device/vibrator-guidelines.md b/zh-cn/application-dev/device/vibrator-guidelines.md index 60c290835eee87723194f1a7859ca54ccf89208f..26fed2b29f902f1a4ccb2eddbef8df40e7986729 100644 --- a/zh-cn/application-dev/device/vibrator-guidelines.md +++ b/zh-cn/application-dev/device/vibrator-guidelines.md @@ -63,7 +63,7 @@ import vibrator from "@ohos.vibrator" vibrator.vibrate(duration: number).then((error)=>{ if(error){//调用失败,打印error.code和error.message - console.log("Promise return faild.error.code"+error.code+"error.message"+error.message); + console.log("Promise return failed.error.code"+error.code+"error.message"+error.message); }else{//调用成功,设备开始振动 console.log("Promise returned to indicate a successful vibration.") }; @@ -76,7 +76,7 @@ import vibrator from "@ohos.vibrator" vibrator.stop(stopMode: VibratorStopMode).then((error)=>{ if(error){//调用失败,打印error.code和error.message - console.log(“Promise return faild.error.code”+error.code+“error.message”+error.message); + console.log(“Promise return failed.error.code”+error.code+“error.message”+error.message); }else{//调用成功,设备停止振动 Console.log(“Promise returned to indicate successful.”); }; diff --git a/zh-cn/application-dev/dfx/hiappevent-guidelines.md b/zh-cn/application-dev/dfx/hiappevent-guidelines.md index c283e3a95e8fdab47041dc96fd536a3138776df5..77dcf82619f0c200e615c103d91603746bcddd3e 100644 --- a/zh-cn/application-dev/dfx/hiappevent-guidelines.md +++ b/zh-cn/application-dev/dfx/hiappevent-guidelines.md @@ -8,6 +8,8 @@ 应用事件JS打点接口由hiAppEvent模块提供。 +以下仅提供简单的接口介绍,API接口的具体使用说明(参数使用限制、具体取值范围等),请参考[应用事件打点API文档](../reference/apis/js-apis-hiappevent.md)。 + **打点接口功能介绍:** | 接口名 | 返回值 | 描述 | @@ -15,25 +17,6 @@ | write(string eventName, EventType type, object keyValues, AsyncCallback\ callback): void | void | 应用事件异步打点方法,使用callback方式作为异步回调。 | | write(string eventName, EventType type, object keyValues): Promise\ | Promise\ | 应用事件异步打点方法,使用promise方式作为异步回调。 | -- 参数eventName:开发者自定义事件名称。事件名称在48个字符以内,有效的字符是0-9、a-z、下划线,只能以字母开头。 - -- 参数type:事件所属的类型,取值为枚举EventType,具体值如下表。 - - | 类型 | 描述 | - | --------- | -------------- | - | FAULT | 故障类型事件。 | - | STATISTIC | 统计类型事件。 | - | SECURITY | 安全类型事件。 | - | BEHAVIOR | 行为类型事件。 | - -- 参数keyValues:事件参数键值对,如果是变长参数类型,则依次输入事件的参数名与参数值。如果是Json对象类型,则Json对象的key是事件的参数名,value是事件的参数值。 - - 参数名只支持string类型,参数值只支持boolean、number、string、Array(数组参数值为基本类型)。 - - 事件的参数个数必须小于等于32。 - - 参数名在16个字符以内,有效的字符是0-9、a-z、下划线,只能以字母开头,不能以下划线结尾。 - - string类型参数值在8*1024个字符内。 - - Array类型参数值的元素个数必须在100个以内,超出时会进行截断处理。 -- 参数callback:回调函数,可以在回调函数中处理接口返回值。返回值为0表示事件参数校验成功,事件正常异步写入事件文件;大于0表示事件存在异常参数,事件在忽略异常参数后再异步写入事件文件;小于0表示事件校验失败,不执行事件异步打点操作。 - 当采用callback作为异步回调时,可以在callback中进行下一步处理。当采用Promise对象返回时,可以在Promise对象中类似地处理接口返回值。具体结果码说明见[事件校验结果码](hiappevent-overview.md#事件校验结果码)。 **打点配置接口功能介绍:** @@ -42,29 +25,6 @@ | ------------------------------ | ------- | ------------------------------------------------------------ | | configure(ConfigOption config) | boolean | 应用事件打点配置方法,可以对打点功能进行自定义配置。返回true表示配置成功,false表示配置失败。 | -- 参数config:应用事件打点配置项对象。应用打点配置选项ConfigOption如下表。 - - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------- | ---- | ------------------------------------------------------------ | - | disable | boolean | 否 | 应用打点功能开关,例如配置值为true表示关闭打点功能。 | - | maxStorage | string | 否 | 打点落盘文件存放目录的配额大小,默认限额为“10M”,超出限额后会对存放目录进行清理。 | - - -**预定义事件名称常量接口Event:** -| 常量名 | 类型 | 描述 | -| ------------------------- | ------ | ------------------------ | -| USER_LOGIN | string | 用户登录事件名称。 | -| USER_LOGOUT | string | 用户登出事件名称。 | -| DISTRIBUTED_SERVICE_START | string | 分布式服务启动事件名称。 | - - -**预定义参数名称常量接口Param:** -| 常量名 | 类型 | 描述 | -| ------------------------------- | ------ | ------------------ | -| USER_ID | string | 用户自定义ID。 | -| DISTRIBUTED_SERVICE_NAME | string | 分布式服务名称。 | -| DISTRIBUTED_SERVICE_INSTANCE_ID | string | 分布式服务示例ID。 | - ## 开发步骤 在应用启动执行页面加载后,执行一个应用事件打点,用于记录应用的初始页面加载事件。 @@ -112,6 +72,4 @@ } ``` -2. 运行项目,点击应用界面上的运行按钮。 - - +2. 运行项目,点击应用界面上的运行按钮。 \ No newline at end of file diff --git a/zh-cn/application-dev/internationalization/Readme-CN.md b/zh-cn/application-dev/internationalization/Readme-CN.md index 61b9279c0dd6ecaeab5c7b8808397b10e53f96f0..11668f5d993f99ed53d59e4fea5f08cd6ec70664 100644 --- a/zh-cn/application-dev/internationalization/Readme-CN.md +++ b/zh-cn/application-dev/internationalization/Readme-CN.md @@ -1,5 +1,5 @@ # 国际化 -- [国际化开发概述](international-overview.md) -- [Intl开发指导](intl-guidelines.md) -- [I18n开发指导](i18n-guidelines.md) + - [国际化开发概述](international-overview.md) + - [Intl开发指导](intl-guidelines.md) + - [I18n开发指导](i18n-guidelines.md) diff --git a/zh-cn/application-dev/media/image.md b/zh-cn/application-dev/media/image.md index 83aebb768bdcfb2c8a02949b94dcd7e2d6c5ee5f..7ae121dd86608a0d32bafb663f2ec4a08a77edd0 100644 --- a/zh-cn/application-dev/media/image.md +++ b/zh-cn/application-dev/media/image.md @@ -6,7 +6,7 @@ ## 接口说明 -详细API含义请参考[js-apis-image.md](https://gitee.com/openharmony/docs/blob/791904121afc0b9887510a6ec0504a23a71e6a3c/zh-cn/application-dev/reference/apis/js-apis-image.md) +详细API含义请参考[js-apis-image.md](../reference/apis/js-apis-image.md) ## 开发步骤 diff --git a/zh-cn/application-dev/notification/Readme-CN.md b/zh-cn/application-dev/notification/Readme-CN.md index a4ab0856eb27dece8bee613147108fc1e1652144..74aaca325ed0986e709ce51fcd1c4d73afe2edd4 100644 --- a/zh-cn/application-dev/notification/Readme-CN.md +++ b/zh-cn/application-dev/notification/Readme-CN.md @@ -1,6 +1,6 @@ # 公共事件与通知 -[公共事件与通知概述](notification-brief) +[公共事件与通知概述](notification-brief.md) ### 公共事件 diff --git a/zh-cn/application-dev/quick-start/module-structure.md b/zh-cn/application-dev/quick-start/module-structure.md new file mode 100644 index 0000000000000000000000000000000000000000..4aa54d017dcd0329eaa65e88c2de63e5ade5bd8c --- /dev/null +++ b/zh-cn/application-dev/quick-start/module-structure.md @@ -0,0 +1,831 @@ + + +# module.json字段说明 + +在开发FA模型下的应用程序时,需要在config.json文件中对应用的包结构进行申明;同样的,在开发stage模型下的应用程序时,需要在module.json配置文件中对应用的包结构进行声明。 + +## 配置文件内部结构 + +module.json由app和module这两个部分组成,缺一不可。配置文件的内部结构参见表1。 + +表1 配置文件的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | ---------- | +| app | 表示应用的全局配置信息。同一个应用的不同HAP包的app配置必须保持一致。参考[app对象内部结构](#app对象内部结构)。 | 对象 | 否 | +| module | 表示HAP包的配置信息。该标签下的配置只对当前HAP包生效。参考[module对象内部结构](#module对象内部结构)。 | 对象 | 否 | + +module.json示例: + +```json +{ +    "app": { + "bundleName": "com.application.music", +        "vendor": "application", +        "versionCode": 1, +        "versionName": "1.0", +        "minCompatibleVersionCode": 1, +        "apiCompatibleVersion": 7, +        "apiTargetVersion": 8, +        "apiReleaseType": "Release", +        "debug": false, +        "icon" : "$media:app_icon", +        "label": "$string:app_name", +        "description": "$string:description_application", +        "distributedNotificationEnabled": true, +        "entityType": "game", +        "car": { +            "apiCompatibleVersion": 8 +         } +    }, + "module": { + "name": "myHapName", + "type": "entry|feature|har", + "srcEntrance" : "./MyAbilityStage.js", + "description" : "$string:description_application", + "process": "string", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet", + "tv", + "wearable", + "liteWearable", + "ar", + "vr", + "car", + "earphones", + "pc", + "speaker", + "smartVision", + "linkIoT", + "router", + ], + "deliveryWithInstall": true, + "installationFree": false, + "virtualMachine": "ark | default", + "metadata": [ + { + "name": "string", + "value": "string", + "resource": "$profile:config_file1" + }, + { + "name": "string", + "value": "string", + "resource": "$profile:config_file2" + } + ], + "metadata": [ + { + "name": "string", + "value": "string", + "resource": "$profile:config_file1" + }, + { + "name": "string", + "value": "string", + "resource": "$profile:config_file2" + } + ], + "abilities": [ + { + "name": "MainAbility", + "srcEntrance" : "./login/MyMainAbility.ts", + "description": "$string:description_main_ability", + "icon": "$media:icon", + "label": "HiMusic", + "visible": true, + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ], + "uris": [ ] + } + ], + "backgroundModes": [ + "dataTransfer", + "audioPlayback", + "audioRecording", + "location", + "bluetoothInteraction", + "multiDeviceConnection", + "wifiInteraction", + "voip", + "taskKeeping" + ], + } + ], + "abilities": [ + { + "name": "MainAbility", + "srcEntrance" : "./login/MyMainAbility.ts", + "description": "$string:description_main_ability", + "icon": "$media:icon", + "label": "HiMusic", + "visible": true, + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ], + "uris": [ ] + } + ], + "backgroundModes": [ + "dataTransfer", + "audioPlayback", + "audioRecording", + "location", + "bluetoothInteraction", + "multiDeviceConnection", + "wifiInteraction", + "voip", + "taskKeeping" + ], + } + ], + "requestPermissions": [ + { + "name": "ohos.abilitydemo.permission.PROVIDER", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "FormAbility" + ], + "when": "inuse" + } + } + ] + } +} +``` + +### app对象内部结构 + +该标签为整个应用的属性,影响应用中左右hap及组件,不会被hap或组件所替换。该标签的内部结构参见表2。 + +表2 app对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ------------------------------ | ------------------------------------------------------------ | -------- | ------------------------------------------- | +| bundleName | 该标签表示应用的包名,用于标识应用的唯一性。该标签不可缺省。标签的值命名规则:
1)字符串以字母、数字、下划线和符号”.”组成;
2)以字母开头;
3)最小长度7个字节,最大长度127个字节。
推荐采用反域名形式命名(如:com.example.xxx,建议第一级为域名后缀com,第二级为厂商/个人名,第三级为应用名,也可以多级)。
其中,随系统源码编译的应用需命名为”com.ohos.xxx”形式, ohos标识OpenHarmony系统应用。 | 字符串 | 否 | +| debug | 该标签标识应用是否可调试。 | 布尔值 | 该标签可以缺省,缺省为false。 | +| icon | 该标签标识应用的图标,标签值为资源文件的索引。 | 字符串 | 该标签不可缺省。 | +| label | 该标签标识应用的的名称,标签值为资源文件的索引,以支持多语言。 | 字符串 | 该标签不可缺省。 | +| description | 该标签标识App的描述信息,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | +| vendor | 该标签是对应用开发厂商的描述。该标签的值是字符串类型(最大255个字节)。 | 字符串 | 该标签可以缺省,缺省为空。 | +| versionCode | 该标签标识应用的版本号,该标签值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。开发者可以将该值设置为任何正整数,但是必须确保应用的新版本都使用比旧版本更大的值。该标签不可缺省,versionCode 值应小于2的31方。 | 数值 | | +| versionName | 该标签标识版本号的文字描述,用于向用户展示。
该标签仅由数字和点构成,推荐采用“A.B.C.D”四段式的形式。四段式推荐的含义如下所示。
第一段:主版本号/Major,范围0-99,重大修改的版本,如实现新的大功能或重大变化。
第二段:次版本号/Minor,范围0-99,表示实现较突出的特点,如新功能添加和大问题修复。
第三段:特性版本号/Feature,范围0-99,标识规划的新版本特性。
第四段:修订版本号/Patch,范围0-999,表示维护版本,修复bug。 | 字符串 | 该标签不可缺省 | +| minCompatibleVersionCode | 该标签标识应用运行需要的API最小版本。 | 数值 | 该标签可缺省。缺省值等于versionCode标签值。 | +| minAPIVersion | 该标签标识应用运行需要的API目标版本。 | 数值 | 该标签不可缺省。 | +| targetAPIVersion | 该标签标识应用运行需要的API目标版本。 | 整形 | 该标签不可缺省。 | +| apiReleaseType | 该标签标识应用运行需要的API目标版本的类型,采用字符串类型表示。取值为“CanaryN”、“BetaN”或者“Release”,其中,N代表大于零的整数。
Canary:受限发布的版本。
Beta:公开发布的Beta版本。
Release:公开发布的正式版本。 | 字符串 | 该标签可缺省,缺省为“Release”。 | +| distributedNotificationEnabled | 该标签标记该应用是否开启分布式通知。 | 布尔值 | 该标签可缺省,缺省值为true。 | +| entityType | 该标签标记该应用的类别,具体有:游戏类(game),影音类(media)、社交通信类(communication)、新闻类(news)、出行类(travel)、工具类(utility)、购物类(shopping)、教育类(education)、少儿类(kids)、商务类(business)、拍摄类(photography)。 | 字符串 | 该标签可以缺省,缺省为unspecified。 | + +### module对象内部结构 + +hap包的配置信息,该标签下的配置只对当前hap包生效。 + +表3 module对象内部结构 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ------------------- | ------------------------------------------------------------ | ---------- | ------------------------------------- | +| name | 该标签标识当前module的名字,module打包成hap后,表示hap的名称,标签值采用字符串表示(最大长度31个字节),该名称在整个应用要唯一。 | 字符串 | 该标签不可缺省。 | +| type | 该标签表示当前hap的类型。类型有三种,分别是entry、feature和har。 | 字符串 | 该标签不可缺省。 | +| srcEntrance | 该标签表示hap所对应的入口js代码路径,标签值为字符串(最长为127字节)。 | 字符串 | 该标签可缺省。 | +| description | 该标签标识hap包的描述信息,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | +| process | 该标签标识hap的进程名,标签值为字符串类型(最长为31个字节)。如果在hap标签下配置了process,该应用的所有ability都运行在该进程中。 | 字符串 | 可缺省,缺省为hap的名称。 | +| mainElement | 该标签标识hap的入口ability名称或者extension名称。只有配置为mainElement的ability或者extension才允许在服务中心露出。创建OpenHarmony原子化服务时,该标签不可缺省。 | 字符串 | 鸿蒙应用下,该标签可缺省。 | +| deviceTypes | 该标签标识hap可以运行在哪类设备上,标签值采用字符串数组的表示,系统预定义的设备类型见表4。
与syscap不同的是,deviceTypes是以设备类型为粒度,而syscap是以设备能力(例如蓝牙、wifi)为粒度。 | 字符串数组 | 该标签不可缺省,可以为空值。 | +| deliveryWithInstall | 该标签标识当前hap是否在用户主动安装的时候安装,true表示主动安装时安装,false表示主动安装时不安装。 | 布尔值 | 该标签不可缺省。 | +| installationFree | 表示当前HAP是否支持免安装特性。所有Hap包都需要配置不可缺省。
true:表示支持免安装特性,且符合免安装约束。
false:表示不支持免安装特性。

当entry.hap该字段配置为true时,与该entry.hap相关的所有feature.hap该字段也需要配置为ture。
当entry.hap该字段配置为false时,与该entry.hap相关的各feature.hap该字段可按业务需求配置ture或false。 | 布尔值 | 该标签不可缺省。 | +| virtualMachine | 该标签用于标识当前hap运行的目标虚拟机类型,供云端分发使用,如应用市场和分发中心。
该标签值为字符串。如果目标虚拟机类型为方舟虚拟机,则其值为”ark”; 如果目标虚拟机类型不是方舟虚拟机,则其值为”default”。该标签由IDE构建hap的时候自动插入。解包工具解析时,如果hap包没有该标签,设置该标签值为”default”。 | 字符串 | 该标签可缺省,缺省值为“default”。 | +| uiSyntax | syntax定义该JS Component的语法类型。
hml标识该JS Component使用hml/css/js进行开发;
ets标识该JS Component使用ets声明式语法进行开发。 | 字符串 | 该标签可缺省,默认值为hml | +| pages | 该标签是一个profile资源,用于列举JS Component中每个页面信息。pages使用参考pages示例。 | 对象 | 在有ability的场景下,该标签不可缺省。 | +| metadata | 该标签标识Hap的自定义元信息,标签值为数组类型,该标签下的配置只对当前module、或者ability、或者extensionAbility生效。metadata参考[metadata对象内部结构](#metadata对象内部结构)。 | 数组 | 该标签可缺省,缺省值为空。 | +| abilities | 描述元能力的配置信息,标签值为数组类型,该标签下的配置只对当前ability生效。abilities参考[abilities对象内部结构](#abilities对象内部结构)。 | 对象 | 该标签可缺省,缺省值为空。 | +| extensionAbilities | 描述extensionAbilities的配置信息,标签值为数组类型,该标签下的配置只对当前extensionAbility生效。extensionAbilities参考[extensionAbility对象的内部结构说明](#extensionAbility对象的内部结构说明)。 | 对象 | 该标签可缺省,缺省值为空。 | +| requestPermissions | 该标签标识应用运行时需向系统申请的权限集合,标签值为数组类型。requestPermissions参考[requestPermissions对象内部结构](#requestPermissions对象内部结构)。 | 对象 | 该标签可缺省,缺省值为空。 | + +表4 deviceTypes对象的系统预定义设备 + +| 中文 | 英文 | 枚举值 | 设备类型 | +| ------------ | ------------ | ------------ | -------------------------------------------------------- | +| 智能手机 | smartphone | phone | 手机 | +| 平板 | tablet | tablet | 平板,带屏音箱 | +| 智慧屏 | smart TV | tv | | +| 智能手表 | smart watch | wearable | 智能手表,儿童手表,特指资源较丰富的的手表,具备电话功能 | +| 运动手表 | basic watch | liteWearable | 基本功能手表,运动手表 | +| 增强现实 | AR | ar | | +| 虚拟现实 | VR | vr | | +| 车机 | head unit | car | | +| 耳机 | earphones | earphones | | +| 个人计算机 | PC | pc | | +| 音箱 | speaker | speaker | 无屏音箱,有屏音箱,通过硬件profile | +| 智慧视觉设备 | Smart Vision | smartVision | 带摄像头的设备,通过硬件profile分开是否 | +| 联接类模组 | linkiot | linkIoT | Wi-Fi模组,蓝牙模组 | +| 路由器 | router | router | 路由器 | + +deviceTypes示例: + +```json +{ + "module": { + "name": "myHapName", +        "type": "har", + "deviceTypes" : [ + "phone" + ] + } +} +``` + +pages示例: + +```json +{ + "module": { +       "name": "myHapName", +        "type": "har", + "deviceTypes" : [ + "phone" + ], +        "pages": "$profile:pages_config" +    } +} +``` + +pages_config配置文件 + +```json +{ +    "src": [ +        "pages/index/index", +        "pages/second/second", +        "pages/third/third", +        "pages/four/four" +    ] +} +``` + + + +#### metadata对象内部结构 + +描述的module、ability、extensionAbility配置信息,标签值为数组类型,该标签下的配置只对当前module、或者ability、或者extensionAbility生效。 + +表5 metadata对象内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------------- | +| name | 该标签表示数据项的键名称,字符串类型(最大长度255字节)。 | 字符串 | 该标签可缺省,缺省值为空。 | +| value | 该标签表示数据项的值,标签值为字符串(最大长度255字节)。 | 字符串 | 可缺省,缺省为空。 | +| resource | 该标签标识定义用户自定义数据格式,标签值为标识该数据的资源的索引值。 | 字符串 | 可缺省,缺省为空。 | + +metadata示例: + +```json +{  +    "module": { +        "metadata": [ +            { +                "name": "string", +                "value": "string", +                "resource": "$profile:config_file" +            }, +            { +                "name": "string", +                "value": "string", +                "resource": "$profile:config_file" +            } +        ] +    } +} +``` + +#### abilities对象内部结构 + +abilities描述ability的配置信息,标签值为数组类型。 + +表6 abilities对象内部结构说明 + +| 属性 | 含义 | 数据类型 | 是否可缺省 | +| --------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | +| name | 该标签标识当前ability的逻辑名,该名称在整个应用要唯一,标签值采用字符串表示(最大长度127个字节)。 | 字符串 | 该标签不可缺省。 | +| srcEntrance | 该标签表示ability所对应的js代码路径,标签值为字符串(最长为127字节)。。 | 字符串 | 该标签不可缺省。 | +| launchType | 该标签标示ability的启动模式,标签值可选"standard"、“singleton”、‘’‘specified“。该标签缺省为"standard"。standard表示普通多实例,spcified表示该ability内部根据业务自己置顶多实例,singleton表示单实例。 | 字符串 | 可缺省,该标签缺省为"standard" | +| description | 该标签标识ability的描述,标签值是是字符串类型或对描述内容的资源索引,要求采用用资源索引方式,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | +| icon | 该标签标识ability图标,标签值为资源文件的索引。该标签可缺省,缺省值为空。
如果ability被配置为MainElement,该标签必须配置。 | 字符串 | 该标签可缺省,缺省值为空。
如果ability被配置为MainElement,该标签必须配置。 | +| permissions | 该标签标识被其它应用的ability调用时需要申请的权限的集合,字符串数组类型,每个数组元素为一个权限名称,通常采用反向域名方式表示(最大255字节),可以是系统预定义的权限,也可以是该应用自定义的权限。如果是后者,需与defPermissions标签中定义的某个权限的name标签值一致。该标签可缺省,缺省值为空。 | 字符串数组 | 该标签可缺省,缺省值为空。 | +| metadata | 该标签表示ability的元信息。metadata参考[metadata对象内部结构](#metadata对象内部结构)。 | 数组 | 该标签可缺省,缺省值为空。 | +| visible | 该标签标识ability是否可以被其它应用调用,为布尔类型,true表示可以被其它应用调用, false表示不可以被其它应用调用。 | 布尔值 | 该标签可缺省,缺省值为false。 | +| continuable | 该标签标识ability是否可以迁移,为布尔类型,true表示可以被迁移, false表示不可以被迁移。 | 布尔值 | 该标签可缺省,缺省值为false。 | +| skills | 该标签标识ability能够接收的意图的特征集,为数组格式。
配置规则: entry包可以配置多个具有入口能力的skills标签(配置了action.system.home和entity.system.home)的ability,其中第一个配置了skills标签的ability中的label和icon作为鸿蒙服务或应用的label和icon。
鸿蒙服务的Feature包不能配置具有入口能力的skills标签。
鸿蒙应用的Feature包可以配置具有入口能力的skills标签。
skills内部结构参考[skills对象内部结构](#skills对象内部结构)。 | 数组 | 该标签可缺省,缺省值为空。 | +| backgroundModes | 该标签标识ability长时任务集合。指定用于满足特定类型的长时任务。
长时任务类型有如下:
dataTransfer:通过网络/对端设备进行数据下载、备份、分享、传输等业务。
audioPlayback:音频输出业务。
audioRecording:音频输入业务。
location:定位、导航业务。
bluetoothInteraction:蓝牙扫描、连接、传输业务(穿戴)。
multiDeviceConnection:多设备互联业务。
wifiInteraction:Wifi扫描、连接、传输业务(克隆 多屏)。
voip:音视频电话,VOIP业务。
taskKeeping:计算业务。
| 字符串 | 可缺省,缺省为空。 | + +abilities示例 + +```json +{ +    "abilities": [{ +        "name": "MainAbility", +        "srcEntrance": "./ets/login/MyLoginAbility.ts", +        "launchType":"standard" +        "description": "$string:description_main_ability", +        "icon": "$media:icon", +        "label": "Login", +        "permissions": [], +        "metadata": [], +        "visible": true, +        "continuable": true, +        "skills": [{ +            "actions": ["action.system.home"], +            "entities": ["entity.system.home"], +            "uris": [] +        }], +        "backgroundModes": [ +            "dataTransfer", +            "audioPlayback", +            "audioRecording", +            "location", +            "bluetoothInteraction", +            "multiDeviceConnection", +            "wifiInteraction", +            "voip", +            "taskKeeping" +        ], +    }], +} +``` + +#### skills对象内部结构 + +该标签标识ability或者extension能够接收的意图的特征。 + +表7 skills内部结构示例 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | ---------- | -------------------- | +| actions | 该标签标识能够接收的意图的action值的集合,取值通常为系统预定义的action值,也允许自定义。 | 字符串数组 | 可缺省,缺省值为空。 | +| entities | 该标签标识能够接收的Intent的元能力的类别集合,取值通常为系统预定义的类别,也允许自定义。 | 字符串数组 | 可缺省,缺省值为空。 | +| uris | 该标签标识向 want过滤器添加数据规范集合。该规范可以是只有数据类型(mimeType 属性),可以是只有 URI,也可以是既有数据类型又有 URI。uris内部结构参考表8。 | 对象数组 | 可缺省,缺省值为空。 | + +表8 uris对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------- | -------- | -------------------- | +| scheme | 表示uri的scheme值。 | 字符串 | 不可缺省。 | +| host | 表示uri的host值。 | 字符串 | 可缺省,缺省值为空。 | +| port | 表示uri的port值。 | 字符串 | 可缺省,缺省值为空。 | +| path | 表示uri的path值。 | 字符串 | 可缺省,缺省值为空。 | +| type | 表示uri的type值。 | 字符串 | 可缺省,缺省值为空。 | + +skills示例 + +```json +{ +    "abilities": [ +        { +            "skills": [ +                { +                    "actions": [ +                        "action.system.home" +                    ], +                    "entities": [ +                        "entity.system.home" +                    ], +                    "uris": [ +                        { +                            "scheme":"uri2", +                            "host":"host2", +                            "port":"port2", +                            "pathStartWith":"path2", +                            "pathRegex":"/query/.*", +                            "path":"path", +                            "type": "text/*" +                        }, +                    ] +                } +            ], +        } +    ], +    "extensionAbilities": [ +        { +            "skills": [ +                { +                    "actions": [ +                    ], +                    "entities": [ +                    ], +                    "uris": [ +                        { +                            "scheme":"uri2", +                            "host":"host2", +                            "port":"port2", +                            "pathStartWith":"path2", +                            "pathRegex":"/query/.*", +                            "path":"path", +                            "type": "text/*" +                        }, +                    ] +                } +            ], +        } +    ], +} +``` + +#### extensionAbility对象的内部结构说明 + +描述extensionAbility的配置信息,标签值为数组类型,该标签下的配置只对当前extensionAbility生效。 + +表9 extensionAbility对象内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ----------- | ------------------------------------------------------------ | ---------- | ----------------------------- | +| name | 该标签标识当前extensionAbility的逻辑名,标签值采用字符串表示(最大长度127个字节),该名称在整个应用要唯一。 | 字符串 | 该标签不可缺省。 | +| srcEntrance | 该标签表示extensionAbility所对应的js代码路径,标签值为字符串(最长为127字节)。 | 字符串 | 该标签不可缺省。 | +| description | 该标签标识extensionAbility的描述,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | +| icon | 该标签标识extensionAbility图标,标签值为资源文件的索引。如果extensionAbility被配置为MainElement,该标签必须配置。 | 字符串 | 该标签可缺省,缺省值为空。 | +| label | 该标签标识extensionAbility对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。
如果extensionAbility被配置为MainElement,该标签必须配置,且应用内唯一。 | 字符串 | 该标签不可缺省。 | +| type | 该标签标识extensionAbility的类型,取值为form、workScheduler、inputMethod、service、accessibility、dataShare、fileShare、staticSubscriber、wallpaper其中之一。 | 字符串 | 该标签不可缺省。 | +| permissions | 该标签标识被其它应用的ability调用时需要申请的权限的集合,字符串数组类型,每个数组元素为一个权限名称,通常采用反向域名方式表示(最大255字节),可以是系统预定义的权限,也可以是该应用自定义的权限。如果是后者,需与defPermissions标签中定义的某个权限的name标签值一致。 | 字符串数组 | 该标签可缺省,缺省值为空。 | +| uri | 该标签标识ability提供的数据uri,为字符数组类型(最大长度255),用反向域名的格式表示。该标签在type为dataShare类型的extensionAbility时,不可缺省。 | 字符串 | 该标签可缺省,缺省值为空。 | +| skills | 该标签标识ability能够接收的意图的特征集,为数组格式。
配置规则: entry包可以配置多个具有入口能力的skills标签(配置了action.system.home和entity.system.home)的ability,其中第一个配置了skills标签的ability中的label和icon作为鸿蒙服务或应用的label和icon。
鸿蒙服务的Feature包不能配置具有入口能力的skills标签。
鸿蒙应用的Feature包可以配置具有入口能力的skills标签。
skills内部结构参考[skills对象内部结构](#skills对象内部结构)。 | 数组 | 该标签可缺省,缺省值为空。 | +| metadata | 该标签表示extensionAbility的元信息。metadata内部结构参考[metadata对象内部结构](#metadata对象内部结构)。 | 对象 | 该标签可缺省,缺省值为空。 | +| visible | 该标签标识extensionAbility是否可以被其它应用调用,为布尔类型。true表示可以被其它应用调用, false表示不可以被其它应用调用。 | | 该标签可缺省,缺省值为false。 | + +extensionAbility示例: + +```json +{ +    "extensionAbilities": [ +        { +            "name": "FormName", +            "srcEntrance": "./form/MyForm.ts", +            "icon": "$media:icon", +            "label" : "$string:extension_name", +            "description": "$string:form_description", +            "type": "form",  +            "permissions": ["ohos.abilitydemo.permission.PROVIDER"], +            "readPermission": "", +            "writePermission": "", +            "visible": true, +            "uri":"scheme://authority/path/query" +            "skills": [{ +                "actions": [], +                "entities": [], +                "uris": [] +            }], +            "metadata": [ +                { +                    "name": "ohos.extability.form", +                    "resource": "$profile:form_config",  +                } +            ], +        } +    ] +} + +``` + +#### requestPermissions对象内部结构 + +该标签标识应用运行时需向系统申请的权限集合。 + +表10 requestPermissions权限申请字段说明 + +| 属性名称 | 含义 | **类型** | **取值范围** | **默认值** | **规则约束** | +| --------- | ------------------------------------------------------------ | ------------------------------- | ----------------------------------------------------------- | ---------------------- | ------------------------------------------------------------ | +| name | 必须,填写需要使用的权限名称。 | 字符串 | 自定义 | 无 | 未填写时,解析失败。 | +| reason | 可选,当申请的权限为user_grant权限时此字段必填。描述申请权限的原因。 | 字符串 | 显示文字长度不能超过256个字节。 | 空 | user_grant权限必填,否则不允许在应用市场上架。需做多语种适配。 | +| usedScene | 可选,当申请的权限为user_grant权限时此字段必填。描述权限使用的场景和时机。场景类型有:ability、when(调用时机)。可配置多个ability。 | ability:字符串数组when:字符串 | ability:ability的名称when:inuse(使用时)、always(始终) | ability:空when:inuse | user_grant权限必填ability,可选填when。 | + +requestPermissions示例: + +```json +{ +    "usedScene": { +        "abilities": [ +            "AudioAbility", +            "VedioAbility", +        ], +        "when": "inuse" +    } +} +``` + +#### form对象内部结构 + +forms标签表示卡片的配置,form卡片是可以嵌入桌面上并接收定期更新的应用简要视图。在以下场景中可以包含form标签。 + +1. extensions中指定type为form。 + +2. metadata中指定form信息,其中: + name:指定form的名称。使用ohos.extability.form作为form信息的标识。 + resource:指定form信息的资源位置。 + +表11 forms对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ----------------- | ------------------------------------------------------------ | ---------- | ----------------------------- | +| name | 表示卡片的类名。字符串最大长度为127字节。 | 字符串 | 否 | +| description | 表示卡片的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省为空。 | +| src | 该标签标识JS卡片对应的UI代码。建议开发者通过自适应布局显示不同规格卡片,如果不同规格卡片布局相差较大,建议通过不同卡片来区分。 | 字符串 | 可缺省,缺省为空。 | +| window | 该标签标识JS卡片的自适应能力。window结构参考表12。 | 对象 | 可缺省,缺省为空。 | +| isDefault | 表示该卡片是否为默认卡片,每个Ability有且只有一个默认卡片。 true:默认卡片。 false:非默认卡片。 | 布尔值 | 否 | +| colorMode | 表示卡片的主题样式,取值范围如下: auto:自适应。 dark:深色主题。 light:浅色主题。 | 字符串 | 可缺省,缺省值为“auto”。 | +| supportDimensions | 表示卡片支持的外观规格,取值范围: 1 * 2:表示1行2列的二宫格。 2 * 2:表示2行2列的四宫格。 2 * 4:表示2行4列的八宫格。 4 * 4:表示4行4列的十六宫格。 | 字符串数组 | 否 | +| defaultDimension | 表示卡片的默认外观规格,取值必须在该卡片supportDimensions配置的列表中。 | 字符串 | 否 | +| updateDuration | 该标签标识卡片定时刷新的更新频率,单位为30分钟,取值为30的倍数值。卡片的最高频率为每30分钟刷新一次,和定点刷新二选一,二者都配置的情况下,定时优先。 | 数值 | 可缺省,缺省为空。 | +| metadata | 该标签表示卡片的自定义信息。metadata内部结构参考表5。 | 对象 | 可缺省,缺省为空。 | +| formConfigAbility | 该标签标识卡片调整的Ability名称。标签值为字符串类型(最长127字符)。该标签值必须满足下面的格式:
ability://单个ability名字
单个ability名字必须为本应用的ability。 | 字符串 | 可缺省,缺省为空。 | +| formVisibleNotify | 该标签标识卡片是否被允许使用卡片可见性通知。标签值为true或false | 布尔值 | 该标签可缺省,默认值为false。 | + +表12 window内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| --------------- | ------------------------------------------------------------ | -------- | -------------------- | +| designWidth | 指示页面设计的基线宽度,以像素为单位。 元素的大小由实际设备宽度缩放。 这个标签是一个整数。 | 数值 | 可缺省,缺省值为空。 | +| autoDesignWidth | 指定是否自动计算页面设计的基线宽度。 如果设置为true,则designWidth属性无效。基线宽度根据设备宽度和屏幕密度计算。 | 布尔值 | 可缺省,缺省值为空。 | + +form示例: + +在开发视图的resources/base/profile下面定义配置文件form_config.json(文件名称可由开发者定义) + +```json +{ +    "forms": [ +        { +            "name": "Form_Js", +            "description": "$string:form_description", +            "src": "./js/pages/card/index", +            "window": { +                "designWidth": 720, +                "autoDesignWidth": true +            }, +            "colorMode": "auto", +            "formConfigAbility": "ability://xxxxx", +            "formVisibleNotify": false, +            "isDefault": true, +            "updateEnabled": true, +            "scheduledUpdateTime": "10:30", +            "updateDuration": 1, +            "defaultDimension": "2*2", +            "supportDimensions": [ +                "2*2" +            ], +           "metadata": [ +             { +                "name": "string", +                "value": "string", +                "resource": "$profile:config_file" +             } +           ]  +        } +    ] +} +``` + +在module.json的extension组件下面定义metadata信息 + +```json +{ + "extensionAbilities": [ + { + "name": "MyForm", + "type": "form",  + "metadata": [ + { + "name": "ohos.extability.form", + "resource": "$profile:form_config", + } + ], + } + ] +} +``` + +#### shortcuts对象内部结构 + +标识应用的快捷方式信息。标签值为数组,最多可以配置四个快捷方式。其包含四个子标签shortcutId、label、icon、intents。 + +metadata中指定shortcut信息,其中: +1)name:指定shortcuts的名称。使用ohos.ability.shortcut作为shortcuts信息的标识。 +2)resource:指定shortcuts信息的资源位置。 + +表13 shortcuts对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ---------- | ------------------------------------------------------------ | -------- | -------------------------- | +| shortcutId | 表示快捷方式的ID。字符串的最大长度为63字节。 | 字符串 | 否 | +| label | 表示快捷方式的标签信息,即快捷方式对外显示的文字描述信息。取值可以是描述性内容,也可以是标识label的资源索引。字符串最大长度为63字节。 | 字符串 | 可缺省,缺省为空。 | +| icon | 该标签标识shortcut的图标,标签值为资源文件的索引。 | 字符串 | 该标签可缺省,缺省值为空。 | +| wants | 该标签标识快捷方式内定义的目标wants信息集合,每个want可配置两个子标签,bundleName,abilityName。
bundleName:快捷方式目标包名,字符串类型。
abilityName:快捷方式的目标组件名,字符串类型。 | 对象 | 该标签可缺省,缺省为空。 | + +在开发视图的resources/base/profile下面定义配置文件shortcut_config.json(文件名称可由开发者定义)。 + +```json +{ +        "shortcuts": [ +            { +                "shortcutId": "id_test1", +                "label": "$string:shortcut", +                "icon": "$media:aa_icon", +                "wants": [ +                    { +                       "bundleName": "com.ohos.hello" +                       "abilityName": "MainAbility" +                    } +                ] +            } +        ] +} +``` + +在config.json的module下面定义metadata信息,如下: + +```json +{ +    "module": { +        "name": "MyAbilityStage", +        "abilities" : [ +            { +                "name" : "MyAbility", +                "srcEntrance": "./abilities/MyAbility.ts", +                "skills": [{ +                            "actions": ["action.system.home"], +                            "entities": ["entity.system.home"], +                            "uris": [] +                }], +                "metadata": [ +                    { +                        "name": "ohos.ability.shortcut", +                        "resource": "$profile:shortcuts_config",  +                    } +                ], +            } +        ] +    } +} +``` + +#### commonEvents对象内部结构 + +commonEvents标签标识注册静态公共事件信息。标签值为数组。 +metadata中指定commonEvent信息,其中: + +1. name:指定commonEvent的名称。使用ohos.extability.staticSubscriber作为commonEvent信息的标识。 + +2. resource:指定commonEvent信息的资源位置。 + +表14 commonEvents对象内部结构 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ---------- | ------------------------------------------------------------ | ---------- | -------------------------- | +| name | 该标签指明当前静态公共事件对应的ability名,该类需要在ability中标明。 | 字符串 | 该标签不可缺省。 | +| permission | 该标签标识实现该静态公共事件需要申请的权限,以字符串类型表示一个权限名称,通常采用反向域名方式表示(最大255字节)。 | 字符串 | 可缺省,缺省值为空。 | +| types | 该标签配置当前静态公共事件的类别数组,字符串数组类型,每个数组元素为一个类别名称。 | 字符串数组 | 该标签可缺省,缺省值为空。 | +| events | 该标签标识能够接收的意图的event值的集合,取值通常为系统预定义的event值,也允许自定义。 | 字符串数组 | 该标签不可缺省。 | + +在开发视图的resources/base/profile下面定义配置文件common_event_config.json(文件名称可由开发者定义)。 + +```json +{ +    "commonEvents": [ +            { +                "name": "abilityName", +                "permission": "string", +                "types": [ +                    "string", +                    "string" +                ], +                "events": [ +                    "string", +                    "string" +                ] +            } +    ] +} +``` + +在module.json的extension组件下面定义metadata信息,如下: + +```json +"extensionAbilities": [ +    { +        "name": "mySubscriber", +        "srcEntrance": "./extension/my_subscriber.js", +        "type": "staticSubscriber", +        "metadata": [ +            { +                "name": "ohos.extability.staticSubscriber", +                "resource": "$profile:common_event_config",  +            } +        ], +    } +] +``` + +#### distroFilter对象内部结构 + +表示应用的分发规则。 + +该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括API Verion、屏幕形状、屏幕分辨率。在进行分发时,通过deviceType与这三个属性的匹配关系,唯一确定一个用于分发到设备的HAP。 + +表15 distroFilter对象内部结构 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ------------- | ------------------------------------------------------------ | -------- | -------------------------- | +| apiVersion | 表示支持的apiVersion范围。参考表16。 | 对象数组 | 该标签可缺省,缺省值为空。 | +| screenShape | 表示屏幕形状的支持策略。 | 对象数组 | 该标签可缺省,缺省值为空。 | +| screenWindow | 表示应用运行时窗口的分辨率支持策略。该字段仅支持对轻量级智能穿戴设备进行配置。 | 对象数组 | 该标签可缺省,缺省值为空。 | +| screenDensity | 该标签表示屏幕的像素密度(dpi:Dot Per Inch)。该字段可选,如果配置了该字段,取值必须合法。该标签为字符串数组,字符串范围如下。
sdpi:表示小规模的屏幕密度(Small-scale Dots per Inch),适用于dpi取值为(0,120]的设备。
mdpi:表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120,160]的设备。
ldpi:表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160,240]的设备。
xldpi:表示大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240,320]的设备。
xxldpi:表示大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320,480]的设备。
xxxldpi:表示大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480, 640]的设备。 | 对象数组 | 该标签可缺省,缺省值为空。 | +| countryCode | 该标签表示应用需要分发的国家地区码,具体值以ISO-3166-1标准为准。支持多个国家和地区枚举定义。该字段可选,如果配置了该字段,取值必须合法。标签值字符串数组,子串表示所支持的国家或地区,由两个大写字母组成。 | 对象数组 | 该标签可缺省,缺省值为空。 | + +表16 apiVersion对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 支持的取值为API Version存在的整数值,例如4、5、6。场景示例:某应用,针对相同设备型号,同时在网的为使用API 5和API 6开发的两个软件版本,则允许上架2个entry类型的安装包,分别支持到对应设备侧软件版本的分发。 | 数组 | 可缺省,缺省值为空。 | + +表17 screenShape对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 支持的取值为circle(圆形)、rect(矩形)。场景示例:针对智能穿戴设备,可为圆形表盘和矩形表盘分别提供不同的HAP。 | 数组 | 可缺省,缺省值为空。 | + +表18 screenWindow对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 单个字符串的取值格式为:“宽 * 高”,取值为整数像素值,例如“454 * 454”。 | 数组 | 可缺省,缺省值为空。 | + +表19 screenDensity对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 该标签表示屏幕的像素密度(dpi:Dot Per Inch)。 | 数组 | 可缺省,缺省值为空。 | + +表20 countryCode对象的内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | ------------------------------------------------------------ | -------- | -------------------- | +| policy | 表示该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | +| value | 该标签表示应用需要分发的国家地区码。 | 数组 | 可缺省,缺省值为空。 | + +distroFilter示例: + +在开发视图的resources/base/profile下面定义配置文件distroFilter_config.json(文件名称可由开发者定义)。 + +```json +"distroFilter": [ + { + "apiVersion": { + "policy": "include", + "value": [4,5] + }, + "screenShape": { + "policy": "include", + "value": ["circle","rect"] + }, + "screenWindow": { + "policy": "include", + "value": ["454*454","466*466"] + } + } +] +``` + +在module.json的extensionAbilities组件下面定义metadata信息,如下: + +```json +"extensionAbilities": [ +    { +        "name": "mySubscriber", +        "srcEntrance": "./extension/my_subscriber.js", +        "type": "staticSubscriber",  +        "metadata": [ +            { +                "name": "ohos.extability.staticSubscriber", +                "resource": "$profile:distroFilter_config",  +            } +        ], +    } +] + +``` + diff --git a/zh-cn/application-dev/quick-start/package-structure.md b/zh-cn/application-dev/quick-start/package-structure.md index 599bd61b6d33b2da7e112710c570a9278a96be8a..2febf57cd48a520a512d18b11f3b1fe52795f867 100644 --- a/zh-cn/application-dev/quick-start/package-structure.md +++ b/zh-cn/application-dev/quick-start/package-structure.md @@ -351,7 +351,7 @@ metaData示例: | name | 表示Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如“com.example.myapplication.MainAbility”;也可采用“.”开头的类名方式表示,如“.MainAbility”。
Ability的名称,需在一个应用的范围内保证唯一。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。
说明:在使用DevEco Studio新建项目时,默认生成首个Ability的配置,包括生成“MainAbility.java”文件,及“config.json”中“MainAbility”的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127。 | 字符串 | 否 | | description | 表示对Ability的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | | icon | 表示Ability图标资源文件的索引。取值示例:$media:ability_icon。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的icon将同时作为应用的icon。如果存在多个符合条件的Ability,则取位置靠前的Ability的icon作为应用的icon。
说明:应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。 | 字符串 | 可缺省,缺省值为空。 | -| label | 表示Ability对用户显示的名称。取值可以是Ability名称,也可以是对该名称的资源索引,以支持多语言。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。
说明: 应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | +| label | 表示Ability对用户显示的名称。取值可以是Ability名称,也可以是对该名称的资源索引,以支持多语言。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。
说明: 应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。该标签为资源文件中定义的字符串的引用,或以"{}"包括的字符串。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | | uri | 表示Ability的统一资源标识符。该标签最大长度为255。 | 字符串 | 可缺省,对于data类型的Ability不可缺省。 | | launchType | 表示Ability的启动模式,支持“standard”、“singleMission”和“singleton”三种模式:
standard:表示该Ability可以有多实例。
“standard”模式适用于大多数应用场景。
singleMission:表示此Ability在每个任务栈中只能有一个实例。
singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用“singleton”模式。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为“standard”。 | | visible | 表示Ability是否可以被其他应用调用。
true:可以被其他应用调用。
false:不能被其他应用调用。 | 布尔类型 | 可缺省,缺省值为“false”。 | @@ -391,7 +391,7 @@ abilities示例: "name": ".MainAbility", "description": "test main ability", "icon": "$media:ic_launcher", - "label": "example", + "label": "$media:example", "launchType": "standard", "orientation": "unspecified", "permissions": [ @@ -419,7 +419,7 @@ abilities示例: "name": ".PlayService", "description": "example play ability", "icon": "$media:ic_launcher", - "label": "example", + "label": "$media:example", "launchType": "standard", "orientation": "unspecified", "visible": false, diff --git a/zh-cn/application-dev/quick-start/start-overview.md b/zh-cn/application-dev/quick-start/start-overview.md index 5c2117961f0f3f6867af59b62ffef7ccf06516d6..c41800085a4ae9e00999fbc532b9e8769be68f79 100644 --- a/zh-cn/application-dev/quick-start/start-overview.md +++ b/zh-cn/application-dev/quick-start/start-overview.md @@ -24,18 +24,18 @@ OpenHarmony提供了一套UI开发框架,即方舟开发框架(ArkUI框架 | 类Web开发范式 | JS语言 | 数据驱动更新 | 界面较为简单的类小程序应用和卡片 | Web前端开发人员 | | 声明式开发范式 | 扩展的TS语言(eTS) | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 | -对于DevEco Studio V2.2 Beta1及更高版本,在使用JS语言开发时,除传统代码方式外,还支持使用低代码方式。OpenHarmony低代码开发方式,具有丰富的UI界面编辑功能,遵循[JS开发规范](https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-overview-0000001056361791),通过可视化界面开发方式快速构建布局,可有效降低用户的上手成本并提升用户构建UI界面的效率。 +对于DevEco Studio V2.2 Beta1及更高版本,在使用JS语言开发时,除传统代码方式外,还支持使用低代码方式。OpenHarmony低代码开发方式,具有丰富的UI界面编辑功能,遵循[JS开发规范](../reference/apis),通过可视化界面开发方式快速构建布局,可有效降低用户的上手成本并提升用户构建UI界面的效率。 ### Ability -[Ability](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/ability-brief.md)是应用所具备能力的抽象,也是应用程序的重要组成部分。一个应用可以具备多种能力(即可以包含多个Ability)。OpenHarmony支持应用以Ability为单位进行部署。 +[Ability](../ability/ability-brief.md)是应用所具备能力的抽象,也是应用程序的重要组成部分。一个应用可以具备多种能力(即可以包含多个Ability)。OpenHarmony支持应用以Ability为单位进行部署。 Ability可以分为[FA(Feature Ability)](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/glossary/glossary.md#f)和[PA(Particle Ability)](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/glossary/glossary.md#p)两种类型,每种类型为开发者提供了不同的模板,以便实现不同的业务功能。其中,FA支持[Page Ability](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/fa-pageability.md)模板,以提供与用户交互的能力。一个Page Ability可以含有一个或多个页面(即Page),Page Ability与Page的关系如下图所示: ![zh-cn_image_0000001215206886](figures/zh-cn_image_0000001215206886.png) -快速入门提供了一个含有两个页面的Page Ability实例。更多Ability的开发内容及指导,请参见[Ability](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/ability-brief.md)。 +快速入门提供了一个含有两个页面的Page Ability实例。更多Ability的开发内容及指导,请参见[Ability开发](../ability/Readme-CN.md)。 ## 工具准备 diff --git a/zh-cn/application-dev/quick-start/start-with-ets.md b/zh-cn/application-dev/quick-start/start-with-ets.md index 69f3d2ab93d6404a9f6db62f7ffdaa0baebece3d..fd58bc1275cd84fc54b37074cc652f78021efbb6 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets.md +++ b/zh-cn/application-dev/quick-start/start-with-ets.md @@ -21,17 +21,15 @@ ## eTS工程项目文件 - **entry** :OpenHarmony工程模块,编译构建生成一个Hap包。 - - **entry > src > main > ets** :用于存放ets源码。 - - **entry > src >main > ets > MainAbility** :应用/服务的入口。 - - **entry > src >main > ets > MainAbility > pages** :MainAbility包含的页面。 - - **entry > src >main > ets > MainAbility > app.ets** :承载Ability生命周期。 - - **entry > src > main > resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。 - - **entry > src > main >config.json** :模块配置文件。主要包含HAP包的配置信息、应用在具体设备上的配置信息以及应用的全局配置信息。 - - **entry > build-profile.json5** :模块的模块信息 、编译信息配置项,包括 buildOption target配置等。 - - **entry > hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - + - **src > main > ets** :用于存放ets源码。 + - **src > main > ets > MainAbility** :应用/服务的入口。 + - **src > main > ets > MainAbility > pages** :MainAbility包含的页面。 + - **src > main > ets > MainAbility > app.ets** :承载Ability生命周期。 + - **src > main > resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。 + - **src > main >config.json** :模块配置文件。主要包含HAP包的配置信息、应用在具体设备上的配置信息以及应用的全局配置信息。 + - **build-profile.json5** :模块的模块信息 、编译信息配置项,包括 buildOption target配置等。 + - **hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - **build-profile.json5** :应用级配置信息,包括签名、产品配置等。 - - **hvigorfile.js** :应用级编译构建任务脚本。 @@ -149,7 +147,7 @@ 页面间的导航可以通过页面路由router来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。 1. **第一个页面跳转到第二个页面。** - 在第一个页面中,跳转按钮绑定onClick方法,当按钮点击时触发页面路由变化,跳转到第二页。“**index.ets**”文件的示例如下: + 在第一个页面中,跳转按钮绑定onClick方法,点击按钮时跳转到第二页。“**index.ets**”文件的示例如下: ``` @@ -178,7 +176,7 @@ .backgroundColor('#0D9FFB') .width('40%') .height('5%') - // 跳转按钮绑定onClicke方法,点击时触发页面路由变化,跳转到第二页 + // 跳转按钮绑定onClicke方法,点击按钮时跳转到第二页 .onClick(()=>{ router.push({uri:'pages/second'}) }) @@ -191,7 +189,7 @@ ``` 2. **第二个页面返回到第一个页面。** - 在第二个页面中,返回按钮绑定onClick方法,当按钮点击时触发页面路由返回,返回到第一页。“**second.ets**”文件的示例如下: + 在第二个页面中,返回按钮绑定onClick方法,点击按钮时返回到第一页。“**second.ets**”文件的示例如下: ``` @@ -218,7 +216,7 @@ .backgroundColor('#0D9FFB') .width('40%') .height('5%') - // 返回按钮绑定onClicke方法,点击时触发页面返回,返回到第一页 + // 返回按钮绑定onClicke方法,点击按钮时返回到第一页 .onClick(()=>{ router.back() }) @@ -243,3 +241,5 @@ 3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001262206247](figures/zh-cn_image_0000001262206247.png) 按钮运行。效果如下图所示: ![zh-cn_image_0000001217526428](figures/zh-cn_image_0000001217526428.png) + +恭喜您已经使用eTS语言开发完成了第一个OpenHarmony应用,来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 diff --git a/zh-cn/application-dev/quick-start/start-with-js-low-code.md b/zh-cn/application-dev/quick-start/start-with-js-low-code.md index e6b7a0c370d5f312b9f99d8ad910b78988e086ad..686b5da3da2726a5e67ceb62da0415c2ed566366 100644 --- a/zh-cn/application-dev/quick-start/start-with-js-low-code.md +++ b/zh-cn/application-dev/quick-start/start-with-js-low-code.md @@ -7,7 +7,7 @@ > 为确保运行效果,本文以使用**DevEco Studio V3.0.0.900 Beta2**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)获取下载链接。 -OpenHarmony低代码开发方式,具有丰富的UI界面编辑功能,遵循[JS开发规范](https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-overview-0000001056361791),通过可视化界面开发方式快速构建布局,可有效降低用户的上手成本并提升用户构建UI界面的效率。 +OpenHarmony低代码开发方式,具有丰富的UI界面编辑功能,遵循[JS开发规范](../reference/apis/),通过可视化界面开发方式快速构建布局,可有效降低用户的上手成本并提升用户构建UI界面的效率。 使用低代码开发应用或服务有以下两种开发方式: @@ -38,10 +38,11 @@ OpenHarmony低代码开发方式,具有丰富的UI界面编辑功能,遵循[ ![zh-cn_image_0000001216753776](figures/zh-cn_image_0000001216753776.png) -- **pages > index > index.js**:低代码页面的逻辑描述文件,定义了页面里所用到的所有的逻辑关系,比如数据、事件等,详情请参考[JS语法参考](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/js-framework-syntax-js-0000000000611432)。如果创建了多个低代码页面,则pages目录下会生成多个页面文件夹及对应的js文件。 +- **pages > index > index.js**:低代码页面的逻辑描述文件,定义了页面里所用到的所有的逻辑关系,比如数据、事件等,详情请参考[JS语法参考](../ui/js-framework-syntax-js.md)。如果创建了多个低代码页面,则pages目录下会生成多个页面文件夹及对应的js文件。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 使用低代码页面开发时,其关联js文件的同级目录中不能包含hml和css页面,例如上图中的**js > MainAbility > pages > index**目录下不能包含hml与css文件,否则会出现编译报错。 - + - **pages > index > index.visual**:visual文件存储低代码页面的数据模型,双击该文件即可打开低代码页面,进行可视化开发设计。如果创建了多个低代码页面,则pages目录下会生成多个页面文件夹及对应的visual文件。 @@ -102,7 +103,8 @@ OpenHarmony低代码开发方式,具有丰富的UI界面编辑功能,遵循[ 页面间的导航可以通过[页面路由router](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/ui-js-building-ui-routes.md)来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。 1. **第一个页面跳转到第二个页面。** - 在第一个页面中,跳转按钮绑定onclick方法,当按钮点击时触发页面路由变化,跳转到第二页。需同时处理js文件及visual文件。 + 在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。需同时处理js文件及visual文件。 + - “**index.js**”示例如下: ``` @@ -117,12 +119,12 @@ OpenHarmony低代码开发方式,具有丰富的UI界面编辑功能,遵循[ } ``` - - “**index.viusal**”: 打开index.visual,选中画布上的Button组件。点击右侧属性样式栏中的事件图标![zh-cn_image_0000001215388136](figures/zh-cn_image_0000001215388136.png)(Events),鼠标点击Click事件的输入框,选择onclick事件,如下所示: - - ![zh-cn_image_0000001261137889](figures/zh-cn_image_0000001261137889.png) - + - “**index.viusal**”: 打开index.visual,选中画布上的Button组件。点击右侧属性样式栏中的事件图标![zh-cn_image_0000001215388136](figures/zh-cn_image_0000001215388136.png)(Events),鼠标点击Click事件的输入框,选择onclick事件,如下所示: + + ![zh-cn_image_0000001261137889](figures/zh-cn_image_0000001261137889.png) + 2. **第二个页面返回到第一个页面。** - 在第二个页面中,返回按钮绑定onClick方法,当按钮点击时触发页面路由返回,返回到第二页。 + 在第二个页面中,返回按钮绑定onClick方法,点击按钮时返回到第一页。 需同时处理js文件及visual文件。 @@ -155,3 +157,5 @@ OpenHarmony低代码开发方式,具有丰富的UI界面编辑功能,遵循[ 3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001262207811](figures/zh-cn_image_0000001262207811.png)按钮运行效果如下图所示: ![zh-cn_image_0000001262127855](figures/zh-cn_image_0000001262127855.png) + +恭喜您已经使用JS语言开发(低代码方式)完成了第一个OpenHarmony应用,来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 diff --git a/zh-cn/application-dev/quick-start/start-with-js.md b/zh-cn/application-dev/quick-start/start-with-js.md index 816960bbfdeeeb4791d0bb9f5d63a8e0e2a2fab1..779fa7d50be5bb1eeaf3d5de4ef3dea21c4bfe66 100644 --- a/zh-cn/application-dev/quick-start/start-with-js.md +++ b/zh-cn/application-dev/quick-start/start-with-js.md @@ -19,17 +19,16 @@ ## JS工程项目文件 - **entry:** OpenHarmony工程模块,编译构建生成一个Hap包。 - - **entry > src > main > js** :用于存放js源码。 - - **entry > src >main > js > MainAbility** :应用/服务的入口。 - - **entry > src >main > js > MainAbility > pages** :MainAbility包含的页面。 - - **entry > src >main >js > MainAbility > app.js** :承载Ability生命周期。 - - **entry > src > main > resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。 - - **entry > src > main > config.json** :模块配置文件。主要包含HAP包的配置信息、应用在具体设备上的配置信息以及应用的全局配置信息。 - - **entry > build-profile.json5** :模块的模块信息 、编译信息配置项,包括 buildOption target配置等。 - - **entry > hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - + - **src > main > js** :用于存放js源码。 + - **src > main > js > MainAbility** :应用/服务的入口。 + - **src > main > js > MainAbility > i18n** :用于配置不同语言场景资源内容,比如应用文本词条、图片路径资源等。 + - **src > main > js > MainAbility > pages** :MainAbility包含的页面。 + - **src > main > js > MainAbility > app.js** :承载Ability生命周期。 + - **src > main > resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。 + - **src > main > config.json** :模块配置文件。主要包含HAP包的配置信息、应用在具体设备上的配置信息以及应用的全局配置信息。 + - **build-profile.json5** :模块的模块信息 、编译信息配置项,包括 buildOption target配置等。 + - **hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - **build-profile.json5** :应用级配置信息,包括签名、产品配置等。 - - **hvigorfile.js** :应用级编译构建任务脚本。 @@ -157,7 +156,7 @@ 页面间的导航可以通过[页面路由router](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/ui-js-building-ui-routes.md)来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。 1. **第一个页面跳转到第二个页面。** - 在第一个页面中,跳转按钮绑定onClick方法,当按钮点击时触发页面路由变化,跳转到第二页。“**index.js**”示例如下: + 在第一个页面中,跳转按钮绑定onClick方法,点击按钮时跳转到第二页。“**index.js**”示例如下: ``` @@ -173,7 +172,7 @@ ``` 2. **第二个页面返回到第一个页面。** - 在第二个页面中,返回按钮绑定onClick方法,当按钮点击时触发页面路由返回,返回到第二页。“**second.js**”示例如下: + 在第二个页面中,返回按钮绑定onClick方法,点击按钮时返回到第二页。“**second.js**”示例如下: ``` @@ -199,3 +198,5 @@ 3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001217047316](figures/zh-cn_image_0000001217047316.png) 按钮运行。效果如下图所示: ![zh-cn_image_0000001217527892](figures/zh-cn_image_0000001217527892.png) + +恭喜您已经使用JS语言开发(传统代码方式)完成了第一个OpenHarmony应用,来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 5d76cee874ee31f427f240c8a754aa3db34c76d9..33a1ff4e1e4d9fa981302784021ef67592324fa4 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -28,6 +28,7 @@ - [轻量级存储9+](js-apis-data-preferences.md) - [轻量级存储](js-apis-data-storage.md) - [分布式数据管理](js-apis-distributed-data.md) + - [分布式对象](js-apis-data-distributedobject.md) - [关系型数据库](js-apis-data-rdb.md) - [结果集](js-apis-data-resultset.md) - [DataAbility 谓词](js-apis-data-ability.md) @@ -76,12 +77,16 @@ - [升级](js-apis-update.md) - [USB管理](js-apis-usb.md) - [位置服务](js-apis-geolocation.md) + - [输入设备](js-apis-inputdevice.md) + - [组合按键](js-apis-inputconsumer.md) + - [输入监听](js-apis-inputmonitor.md) + - [事件注入](js-apis-inputeventclient.md) - 基本功能 - - [应用上下文](js-apis-basic-features-app-context.md) + - [应用上下文](js-apis-system-app.md) - [日志打印](js-apis-basic-features-logs.md) - - [页面路由](js-apis-basic-features-routes.md) - - [弹窗](js-apis-basic-features-pop-up.md) - - [应用配置](js-apis-basic-features-configuration.md) + - [页面路由](js-apis-system-router.md) + - [弹窗](js-apis-system-prompt.md) + - [应用配置](js-apis-system-configuration.md) - [定时器](js-apis-basic-features-timer.md) - [锁屏管理](js-apis-screen-lock.md) - [设置系统时间](js-apis-system-time.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md index e1333719ff66a34cc1b2c627195fd90e77c62de5..b9ea2509fcd2a61e21e5f9265af965418893fbfa 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -1,5 +1,8 @@ # Bundle模块(JS端SDK接口) +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + ## 导入模块 ``` @@ -567,7 +570,7 @@ bundle.getAbilityInfo(bundleName, abilityName, (err, data) => { }) ``` -## bundle.getAbilityLabel +## bundle.getAbilityLabel8+ getAbilityLabel(bundleName: string, abilityName: string): Promise\ @@ -607,7 +610,7 @@ bundle.getAbilityLabel(bundleName, abilityName) }) ``` -## bundle.getAbilityLabel +## bundle.getAbilityLabel8+ getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\): void @@ -643,7 +646,7 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => { }) ``` -## bundle.isAbilityEnabled +## bundle.isAbilityEnabled8+ isAbilityEnabled(info: AbilityInfo): Promise\ @@ -684,7 +687,7 @@ bundle.isAbilityEnabled(Info) }) ``` -## bundle.isAbilityEnabled +## bundle.isAbilityEnabled8+ isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\): void @@ -721,7 +724,7 @@ bundle.isAbilityEnabled(Info, (err, data) => { }) ``` -## bundle.isApplicationEnabled +## bundle.isApplicationEnabled8+ isApplicationEnabled(bundleName: string): Promise\ @@ -759,7 +762,7 @@ bundle.isApplicationEnabled(bundleName) }) ``` -## bundle.isApplicationEnabled +## bundle.isApplicationEnabled8+ isApplicationEnabled(bundleName: string, callback : AsyncCallback\): void @@ -1071,7 +1074,7 @@ bundle.getLaunchWantForBundle(bundleName, (err, data) => { ``` -## bundle.getNameForUid +## bundle.getNameForUid8+ getNameForUid(uid: number): Promise\ @@ -1104,7 +1107,7 @@ bundle.getNameForUid(uid) }) ``` -## bundle.getNameForUid +## bundle.getNameForUid8+ getNameForUid(uid: number, callback: AsyncCallback\): void; @@ -1135,12 +1138,20 @@ bundle.getNameForUid(uid, (err, data) => { ``` -## bundle.getAbilityIcon +## bundle.getAbilityIcon8+ -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)>; +getAbilityIcon(bundleName: string, abilityName: string): Promise\<[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md)>; 以异步方法通过bundleName和abilityName获取对应Icon的[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md),使用Promise形式返回结果。 +**需要权限:** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -1166,12 +1177,20 @@ bundle.getAbilityIcon(bundleName, abilityName) }) ``` -## bundle.getAbilityIcon +## bundle.getAbilityIcon8+ -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; +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; 以异步方法通过bundleName和abilityName获取对应的[PixelMap](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md),使用callback形式返回结果。 +**需要权限:** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -1195,9 +1214,9 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { ``` -## bundle.queryExtensionAbilityInfosByWant +## bundle.queryExtensionAbilityInfosByWant9+ -function queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId?: number): Promise> +queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId?: number): Promise> 以异步方法根据给定的意图获取ExtensionAbility信息,使用Promise形式返回结果。 @@ -1242,12 +1261,16 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, userId) -## bundle.queryExtensionAbilityInfosByWant +## bundle.queryExtensionAbilityInfosByWant9+ -function queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId: number, callback: AsyncCallback>): void +queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId: number, callback: AsyncCallback>): void 以异步方法根据给定的意图获取ExtensionAbility信息,使用callback形式返回结果。 +**需要权限:** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO + **系统能力:** SystemCapability.BundleManager.BundleFramework @@ -1279,12 +1302,16 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, userId, (err, data }) ``` -## bundle.queryExtensionAbilityInfosByWant +## bundle.queryExtensionAbilityInfosByWant9+ -function queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, callback: AsyncCallback>): void; +queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, callback: AsyncCallback>): void; 以异步方法根据给定的意图获取ExtensionAbility信息,使用callback形式返回结果。 +**需要权限:** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO + **系统能力:** SystemCapability.BundleManager.BundleFramework @@ -1314,7 +1341,6 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { }) ``` - ## ElementName **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework @@ -1327,13 +1353,32 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { | uri | 只读 | string | 否 | 资源标识符。 | | shortName | 只读 | string | 否 | ElementName的简名。 | -## InstallStatus +## InstallErrorCode **系统能力:** SystemCapability.BundleManager.BundleFramework -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ------------- | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| status | 只读 | InstallErrorCode | 是 | 安装结果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 | +| 名称 | 默认值 | 说明 | +| ------ | ------ | ------ | +| 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_INVALID8+ | 0x0D | 恢复预置应用失败 | +| STATUS_ABILITY_NOT_FOUND | 0x40 | Ability未找到 | +| STATUS_BMS_SERVICE_ERROR | 0x41 | BMS服务错误 | +| STATUS_FAILED_NO_SPACE_LEFT8+ | 0x42 | 设备空间不足 | +| STATUS_GRANT_REQUEST_PERMISSIONS_FAILED8+ | 0x43 | 应用授权失败 | +| STATUS_INSTALL_PERMISSION_DENIED8+ | 0x44 | 安装权限拒绝 | +| STATUS_UNINSTALL_PERMISSION_DENIED8+ | 0x45 | 卸载权限拒绝 | ## BundleFlag @@ -1349,12 +1394,12 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { | GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | 获取包括应用的Ability信息 | | GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | 获取包括权限的应用信息 | | GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | 获取包括所需权限的包信息 | -| GET_ABILITY_INFO_WITH_METADATA | 0x00000020 | 获取ability的元数据信息 | -| GET_BUNDLE_WITH_EXTENSION_ABILITY | 0x00000020 | 获取包括Ability信息的扩展包信息 | -| GET_APPLICATION_INFO_WITH_METADATA | 0x00000040 | 获取应用的元数据信息 | -| GET_ABILITY_INFO_SYSTEMAPP_ONLY | 0x00000080 | 获取仅包括系统应用的ability信息 | -| GET_ABILITY_INFO_WITH_DISABLE | 0x00000100 | 获取包括被禁用的ability信息 | -| GET_APPLICATION_INFO_WITH_DISABLE | 0x00000200 | 获取包括被禁用的应用信息 | +| GET_ABILITY_INFO_WITH_METADATA8+ | 0x00000020 | 获取ability的元数据信息 | +| GET_BUNDLE_WITH_EXTENSION_ABILITY9+ | 0x00000020 | 获取包括Ability信息的扩展包信息 | +| GET_APPLICATION_INFO_WITH_METADATA8+ | 0x00000040 | 获取应用的元数据信息 | +| GET_ABILITY_INFO_SYSTEMAPP_ONLY8+ | 0x00000080 | 获取仅包括系统应用的ability信息 | +| GET_ABILITY_INFO_WITH_DISABLE8+ | 0x00000100 | 获取包括被禁用的ability信息 | +| GET_APPLICATION_INFO_WITH_DISABLE8+ | 0x00000200 | 获取包括被禁用的应用信息 | | GET_ALL_APPLICATION_INFO | 0xFFFF0000 | 获取应用所有的信息 | ## BundleOptions @@ -1397,8 +1442,8 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { | isSilentInstallation | string | 是 | 否 | 是否通过静默安装 | | minCompatibleVersionCode | number | 是 | 否 | 分布式场景下的应用包兼容的最低版本 | | entryInstallationFree | boolean | 是 | 否 | Entry是否支持免安装 | -| reqPermissionStates | Array\ | 是 | 否 | 申请权限的授予状态 | -| extensionAbilityInfo | Array\ | 是 | 否 | ability的可扩展信息 | +| reqPermissionStates8+ | Array\ | 是 | 否 | 申请权限的授予状态 | +| extensionAbilityInfo9+ | Array\ | 是 | 否 | ability的可扩展信息 | ## ApplicationInfo @@ -1424,13 +1469,13 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { | moduleInfos | Array\ | 是 | 否 | 应用程序的模块信息 | | entryDir | string | 是 | 否 | 应用程序的文件保存路径 | | customizeData | Map> | 是 | 是 | 应用程序的自定义数据 | -| codePath | string | 是 | 否 | 应用程序的安装目录 | -| metaData | Map> | 是 | 否 | 应用程序的自定义元信息 | -| metaData | Map> | 是 | 否 | 应用程序的元信息 | -| removable | boolean | 是 | 否 | 应用程序是否可以被移除 | -| accessTokenId | number | 是 | 否 | 应用程序的accessTokenId | -| uid | number | 是 | 否 | 应用程序的uid | -| entityType | string | 是 | 否 | 应用程序的实体类型 | +| codePath8+ | string | 是 | 否 | 应用程序的安装目录 | +| metaData8+ | Map> | 是 | 否 | 应用程序的自定义元信息 | +| metaData9+ | Map> | 是 | 否 | 应用程序的元信息 | +| removable8+ | boolean | 是 | 否 | 应用程序是否可以被移除 | +| accessTokenId8+ | number | 是 | 否 | 应用程序的accessTokenId | +| uid8+ | number | 是 | 否 | 应用程序的uid | +| entityType9+ | string | 是 | 否 | 应用程序的实体类型 | ## ModuleInfo @@ -1453,7 +1498,7 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { | ----- | ------ | ---- | ---- | ---------------- | | name | string | 是 | 是 | 自定义元数据名称 | | value | string | 是 | 是 | 自定义元数据值 | -| extra | string | 是 | 是 | 自定义资源 | +| extra8+ | string | 是 | 是 | 自定义资源 | ## HapModuleInfo @@ -1479,9 +1524,9 @@ Hap模块信息 | moduleName | string | 是 | 否 | 模块名 | | mainAbilityName | string | 是 | 否 | 入口Ability名称 | | installationFree | boolean | 是 | 否 | 是否支持免安装 | -| mainElementName | string | 是 | 否 | 入口ability信息 | -| extensionAbilityInfo | Array\ | 是 | 否 | extensionAbility信息 | -| metadata | Array\ | 是 | 否 | Ability的元信息 | +| mainElementName8+ | string | 是 | 否 | 入口ability信息 | +| extensionAbilityInfo9+ | Array\ | 是 | 否 | extensionAbility信息 | +| metadata9+ | Array\ | 是 | 否 | Ability的元信息 | ## ReqPermissionDetail @@ -1540,9 +1585,9 @@ Ability信息 | uri | string | 是 | 否 | 获取Ability的统一资源标识符(URI) | | labelId | number | 是 | 否 | Ability的标签id | | subType | AbilitySubType | 是 | 否 | Ability中枚举使用的模板的子类型 | -| metaData | Array\ | 是 | 否 | ability的自定义信息 | -| metaData | Array\ | 是 | 否 | ability的元信息 | -| enabled | boolean | 是 | 否 | ability是否可用 | +| metaData8+ | Array\ | 是 | 否 | ability的自定义信息 | +| metaData9+ | Array\ | 是 | 否 | ability的元信息 | +| enabled8+ | boolean | 是 | 否 | ability是否可用 | ## AbilityType @@ -1593,7 +1638,7 @@ Ability的子类型 | CA | 1 | Ability子类型是带有 UI 的服务 | -## ExtensionAbilityType +## ExtensionAbilityType9+ ExtensionAbility的类型 @@ -1601,18 +1646,18 @@ ExtensionAbility的类型 | 名称 | 类型 | 说明 | | -------------------- | ---- | ----------------------------- | -| FORM | 0 | ExtensionAbility的类型包括卡片 | -| WORK_SCHEDULER | 1 | ExtensionAbility的类型包括行程安排 | -| INPUT_METHOD | 2 | ExtensionAbility的类型包括输入法 | -| SERVICE | 3 | ExtensionAbility的类型包括服务 | -| ACCESSIBILITY | 4 | ExtensionAbility的类型包括无障碍 | -| DATA_SHARE | 5 | ExtensionAbility的类型包括数据共享 | -| FILE_SHARE | 6 | ExtensionAbility的类型包括文件共享 | -| STATIC_SUBSCRIBER | 7 | ExtensionAbility的类型包括订阅者 | -| WALLPAPER | 8 | ExtensionAbility的类型包括墙纸 | -| UNSPECIFIED | 9 | ExtensionAbility未指定类型 | - -## ExtensionFlag +| FORM9+ | 0 | ExtensionAbility的类型包括卡片 | +| WORK_SCHEDULER9+ | 1 | ExtensionAbility的类型包括行程安排 | +| INPUT_METHOD9+ | 2 | ExtensionAbility的类型包括输入法 | +| SERVICE9+ | 3 | ExtensionAbility的类型包括服务 | +| ACCESSIBILITY9+ | 4 | ExtensionAbility的类型包括无障碍 | +| DATA_SHARE9+ | 5 | ExtensionAbility的类型包括数据共享 | +| FILE_SHARE9+ | 6 | ExtensionAbility的类型包括文件共享 | +| STATIC_SUBSCRIBER9+ | 7 | ExtensionAbility的类型包括订阅者 | +| WALLPAPER9+ | 8 | ExtensionAbility的类型包括墙纸 | +| UNSPECIFIED9+ | 9 | ExtensionAbility未指定类型 | + +## ExtensionFlag9+ 扩展标志 @@ -1620,13 +1665,38 @@ ExtensionAbility的类型 | 名称 | 默认值 | 说明 | | ------ | ------ | ------ | -| GET_EXTENSION_INFO_DEFAULT | 0x00000000 | 获取默认的extensionAbilityInfo | -| GET_EXTENSION_INFO_WITH_PERMISSION | 0x00000002 | 获取携带权限信息的extensionAbilityInfo | -| GET_EXTENSION_INFO_WITH_APPLICATION | 0x00000004 | 获取携带应用信息的extensionAbilityInfo | -| GET_EXTENSION_INFO_WITH_METADATA | 0x00000020 | 获取携带元数据信息的extensionAbilityInfo | +| GET_EXTENSION_INFO_DEFAULT9+ | 0x00000000 | 获取默认的extensionAbilityInfo | +| GET_EXTENSION_INFO_WITH_PERMISSION9+ | 0x00000002 | 获取携带权限信息的extensionAbilityInfo | +| GET_EXTENSION_INFO_WITH_APPLICATION9+ | 0x00000004 | 获取携带应用信息的extensionAbilityInfo | +| GET_EXTENSION_INFO_WITH_METADATA9+ | 0x00000020 | 获取携带元数据信息的extensionAbilityInfo | + + +## ColorMode + +颜色模式 + + **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 说明 | +| ----------- | ---- | ------------------- | +| AUTO_MODE | -1 | 自动模式 | +| DARK_MODE | 0 | 夜间模式 | +| LIGHT_MODE | 1 | 灯光模式 | -## ExtensionAbilityInfo +## GrantStatus + +授予状态 + + **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 说明 | +| ----------- | ---- | ------------------- | +| PERMISSION_DENIED | -1 | 拒绝许可 | +| PERMISSION_GRANTED | 0 | 批准 | + + +## ExtensionAbilityInfo9+ ExtensionAbility信息 @@ -1634,23 +1704,23 @@ ExtensionAbility信息 | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ------ | ------ | ------ | -| bundleName | string | 是 | 否 | 应用包名 | -| moduleName | string | 是 | 否 | ExtensionAbility所属的HAP包的名称 | -| name | string | 是 | 否 | ExtensionAbility名称 | -| labelId | number | 是 | 否 | ExtensionAbility的标签id | -| descriptionId | number | 是 | 否 | ExtensionAbility的描述id | -| iconId | number | 是 | 否 | ExtensionAbility的图标id | -| isVisible | boolean | 是 | 否 | 判断ExtensionAbility是否可以被其他应用调用 | -| extensionAbilityType | bundle.ExtensionAbilityType | 是 | 否 | ExtensionAbility类型 | -| permissions | Array\ | 是 | 否 | 被其他应用ExtensionAbility调用时需要申请的权限集合 | -| applicationInfo | ApplicationInfo | 是 | 否 | 应用程序的配置信息 | -| metaData | Array\ | 是 | 否 | ExtensionAbility的元信息 | -| enabled | boolean | 是 | 否 | ExtensionAbility是否可用 | -| readPermission | string | 是 | 否 | 读取ExtensionAbility数据所需的权限 | -| writePermission | string | 是 | 否 | 向ExtensionAbility写数据所需的权限 | - - -## Metadata +| bundleName9+ | string | 是 | 否 | 应用包名 | +| moduleName9+ | string | 是 | 否 | ExtensionAbility所属的HAP包的名称 | +| name9+ | string | 是 | 否 | ExtensionAbility名称 | +| labelId9+ | number | 是 | 否 | ExtensionAbility的标签id | +| descriptionId9+ | number | 是 | 否 | ExtensionAbility的描述id | +| iconId9+ | number | 是 | 否 | ExtensionAbility的图标id | +| isVisible9+ | boolean | 是 | 否 | 判断ExtensionAbility是否可以被其他应用调用 | +| extensionAbilityType9+ | bundle.ExtensionAbilityType | 是 | 否 | ExtensionAbility类型 | +| permissions9+ | Array\ | 是 | 否 | 被其他应用ExtensionAbility调用时需要申请的权限集合 | +| applicationInfo9+ | ApplicationInfo | 是 | 否 | 应用程序的配置信息 | +| metaData9+ | Array\ | 是 | 否 | ExtensionAbility的元信息 | +| enabled9+ | boolean | 是 | 否 | ExtensionAbility是否可用 | +| readPermission9+ | string | 是 | 否 | 读取ExtensionAbility数据所需的权限 | +| writePermission9+ | string | 是 | 否 | 向ExtensionAbility写数据所需的权限 | + + +## Metadata9+ 元数据信息 @@ -1658,6 +1728,6 @@ ExtensionAbility信息 | 名称 | 类型 | 可读 | 可写 | 说明 | | ----- | ------ | ---- | ---- | ---------------- | -| name | string | 是 | 是 | 元数据名称 | -| value | string | 是 | 是 | 元数据值 | -| resource | string | 是 | 是 | 元数据资源 | \ No newline at end of file +| name9+ | string | 是 | 是 | 元数据名称 | +| value9+ | string | 是 | 是 | 元数据值 | +| resource9+ | string | 是 | 是 | 元数据资源 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-wantConstant.md b/zh-cn/application-dev/reference/apis/js-apis-ability-wantConstant.md new file mode 100644 index 0000000000000000000000000000000000000000..7bda59994ceff639fd483713fd499ed929bf20f9 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-wantConstant.md @@ -0,0 +1,88 @@ +# wantConstant + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + +``` +import wantConstant from '@ohos.ability.wantConstant' +``` + + +## wantConstant.Action + +**系统能力**:SystemCapability.Ability.AbilityBase + +## 权限列表 + +| 系统公共事件宏 | 系统公共事件名称 | 订阅者所需权限 | +| ------------ | ------------------ | ---------------------- | +| ACTION_HOME | ohos.want.action.home | 无 | +| ACTION_DIAL | ohos.want.action.dial | 无 | +| ACTION_SEARCH | ohos.want.action.search | 无 | +| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | 无 | +| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | 无 | +| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | 无 | +| ACTION_SET_ALARM | ohos.want.action.setAlarm | 无 | +| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | 无 | +| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | 无 | +| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | 无 | +| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | 无 | +| ACTION_SEND_SMS | ohos.want.action.sendSms | 无 | +| ACTION_CHOOSE | ohos.want.action.choose | 无 | +| ACTION_IMAGE_CAPTURE8+ | ohos.want.action.imageCapture | 无 | +| ACTION_VIDEO_CAPTUR8+ | ohos.want.action.videoCapture | 无 | +| ACTION_SELECT | ohos.want.action.select | 无 | +| ACTION_SEND_DATA | ohos.want.action.sendData | 无 | +| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | 无 | +| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | 无 | +| ACTION_VIEW_DATA | ohos.want.action.viewData | 无 | +| ACTION_EDIT_DATA | ohos.want.action.editData | 无 | +| INTENT_PARAMS_INTENT | ability.want.params.INTENT | 无 | +| INTENT_PARAMS_TITLE | ability.want.params.TITLE | 无 | +| ACTION_FILE_SELECT7+ | ohos.action.fileSelect | 无 | +| PARAMS_STREAM7+ | ability.params.stream | 无 | +| ACTION_APP_ACCOUNT_OAUTH 8+ | ohos.account.appAccount.action.oauth | 无 | + + +## wantConstant.Entity + +**系统能力**:SystemCapability.Ability.AbilityBase + +## 权限列表 + +| 系统公共事件宏 | 系统公共事件名称 | 订阅者所需权限 | +| ------------ | ------------------ | ---------------------- | +| ENTITY_DEFAULT | entity.system.default | 无 | +| ENTITY_HOME | entity.system.homel | 无 | +| ENTITY_VOICE | ENTITY_VOICE | 无 | +| ENTITY_BROWSABLE | entity.system.browsable | 无 | +| ENTITY_VIDEO | entity.system.video | 无 | +| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | 无 | + + +## flags说明 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase + +| 名称 | 参数 | 描述 | +| ------------------------------------ | ---------- | ------------------------------------------------------------ | +| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | 指示对URI执行读取操作的授权。 | +| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | 指示对URI执行写入操作的授权。 | +| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | 将结果返回给元能力。 | +| FLAG_ABILITY_CONTINUATION | 0x00000008 | 确定是否可以将本地设备上的功能迁移到远程设备。 | +| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | 指定组件是否属于OHOS。 | +| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是否启动某个能力。 | +| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上可能持久化的授权。 | +| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 按照前缀匹配的方式验证URI权限。 | +| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动。 | +| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | 指示无论主机应用程序是否已启动,都将启动使用服务模板的功能。 | +| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示迁移是可拉回的。 | +| FLAG_INSTALL_ON_DEMAND | 0x00000800 | 如果未安装指定的功能,请安装该功能。 | +| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | 如果未安装,使用后台模式安装该功能。 | +| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | 指示清除其他任务的操作。可以为传递给 **[ohos.app.Context](js-apis-ability-context.md)** 中**startAbility**方法的**Want**设置此标志,并且必须与**flag_ABILITY_NEW_MISSION**一起使用。 | +| FLAG_ABILITY_NEW_MISSION | 0x10000000 | 指示在历史任务堆栈上创建任务的操作。 | +| FLAG_ABILITY_MISSION_TOP | 0x20000000 | 指示如果启动能力的现有实例已位于任务堆栈的顶部,则将重用该实例。否则,将创建一个新的能力实例。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index a571496b551cfe0aae82c69336dd92d8afaf9abe..99ad55ca4046d399f0b5b23e6a22f030f12601eb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -11,23 +11,20 @@ import account_appAccount from '@ohos.account.appAccount'; ``` -## 系统能力 - -SystemCapability.Account.AppAccount - - ## account_appAccount.createAppAccountManager -createAppAccountManager(): AppAccountManager; +createAppAccountManager(): AppAccountManager 应用帐号管理:获取应用帐号模块对象。 -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | AppAccountManager | 获取应用帐号模块的实例。 | +**系统能力:** SystemCapability.Account.AppAccount + +**返回值:** +| 类型 | 说明 | +| ----------------- | ------------------------ | +| AppAccountManager | 获取应用帐号模块的实例。 | -- 示例: +**示例:** ``` var appAccountManager = account.createAppAccountManager(); ``` @@ -38,20 +35,20 @@ createAppAccountManager(): AppAccountManager; ### addAccount -addAccount(name: string, callback: AsyncCallback<void>): void; +addAccount(name: string, callback: AsyncCallback<void>): void 将此应用的帐号名添加到帐号管理服务中,使用callback回调异步返回结果。 -需要权限:无。 +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | ------------------------------------------ | - | name | string | 是 | 要添加的应用帐户的名称。 | - | callback | AsyncCallback<void> | 是 | 将此应用的帐号名添加到帐号管理服务的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------------ | +| name | string | 是 | 要添加的应用帐户的名称。 | +| callback | AsyncCallback<void> | 是 | 将此应用的帐号名添加到帐号管理服务的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -62,21 +59,21 @@ addAccount(name: string, callback: AsyncCallback<void>): void; ### addAccount -addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void; +addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void 将此应用程序的帐号名和额外信息添加到帐号管理服务中,使用callback回调异步返回结果。 -需要权限:无。 +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------------- | ---- | ------------------------------------------------------------ | - | name | string | 是 | 要添加的应用帐户的名称。 | - | extraInfo | string | 是 | 要添加的应用帐户的额外信息(例如token等),额外的信息不能是应用帐号的敏感信息。 | - | callback | AsyncCallback<void> | 是 | 将此应用程序的帐号名和额外信息添加到帐号管理服务中的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| name | string | 是 | 要添加的应用帐户的名称。 | +| extraInfo | string | 是 | 要添加的应用帐户的额外信息(例如token等),额外的信息不能是应用帐号的敏感信息。 | +| callback | AsyncCallback<void> | 是 | 将此应用程序的帐号名和额外信息添加到帐号管理服务中的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -89,26 +86,26 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>) ### addAccount -addAccount(name: string, extraInfo?: string): Promise<void>; +addAccount(name: string, extraInfo?: string): Promise<void> 将此应用的帐号名或额外信息添加到帐号管理服务中,使用Promise方式异步返回结果。 -需要权限:无。 +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------ | ---- | ------------------------------------------------------------ | - | name | string | 是 | 要添加的应用帐户的名称。 | - | extraInfo | string | 是 | 要添加的应用帐户的额外信息,额外的信息不能是应用帐号的敏感信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------------------------------------------------------ | +| name | string | 是 | 要添加的应用帐户的名称。 | +| extraInfo | string | 是 | 要添加的应用帐户的额外信息,额外的信息不能是应用帐号的敏感信息。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | ------------- | ---------------------------------- | - | Promise<void> | romise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ------------------- | ---------------------------------- | +| Promise<void> | romise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -121,22 +118,22 @@ addAccount(name: string, extraInfo?: string): Promise<void>; ### 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 根据指定的帐号所有者、鉴权类型和可选项,隐式地添加应用帐号,并使用callback回调异步返回结果。 -需要权限:无。 +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | --- | -------------------------- | - | owner | string | 是 | 要添加的应用帐户的所有者包名。 | - | authType | string | 是 | 要添加的应用帐户的鉴权类型。 | - | options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 | - | callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ------------------------------ | +| owner | string | 是 | 要添加的应用帐户的所有者包名。 | +| authType | string | 是 | 要添加的应用帐户的鉴权类型。 | +| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 | +| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 | -- 示例: +**示例:** ``` import featureAbility from '@ohos.ability.featureAbility'; @@ -162,18 +159,20 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a ### deleteAccount -deleteAccount(name: string, callback: AsyncCallback<void>): void; +deleteAccount(name: string, callback: AsyncCallback<void>): void 从帐号管理服务中删除应用帐号,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | ---------------------------------- | - | name | string | 是 | 要删除的应用帐户的名称。 | - | callback | AsyncCallback<void> | 是 | 帐号管理服务中删除应用帐号的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------------------------- | +| name | string | 是 | 要删除的应用帐户的名称。 | +| callback | AsyncCallback<void> | 是 | 帐号管理服务中删除应用帐号的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -184,23 +183,25 @@ deleteAccount(name: string, callback: AsyncCallback<void>): void; ### deleteAccount -deleteAccount(name: string): Promise<void>; +deleteAccount(name: string): Promise<void> 从帐号管理服务中删除应用帐号,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------------ | - | name | string | 是 | 要删除的应用帐户的名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------ | +| name | string | 是 | 要删除的应用帐户的名称。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -213,19 +214,21 @@ deleteAccount(name: string): Promise<void>; ### disableAppAccess -disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void; +disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void 禁止指定第三方应用帐户的名称访问指定包名称的第三方应用,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------------------- | ---- | ------------------------------------------------------------ | - | name | string | 是 | 要禁用访问的第三方应用帐户的名称。 | - | bundleName | string | 是 | 第三方应用的包名。 | - | callback | AsyncCallback<void> | 是 | 禁止指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------------------------------------------ | +| name | string | 是 | 要禁用访问的第三方应用帐户的名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | +| callback | AsyncCallback<void> | 是 | 禁止指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -236,24 +239,26 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<vo ### disableAppAccess -disableAppAccess(name: string, bundleName: string): Promise<void>; +disableAppAccess(name: string, bundleName: string): Promise<void> 禁止指定第三方应用帐户的名称访问指定包名称的第三方应用,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------ | ---- | ---------------------------------- | - | name | string | 是 | 要禁用访问的第三方应用帐户的名称。 | - | bundleName | string | 是 | 第三方应用的包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ---------------------------------- | +| name | string | 是 | 要禁用访问的第三方应用帐户的名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -266,19 +271,21 @@ disableAppAccess(name: string, bundleName: string): Promise<void>; ### enableAppAccess -enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void; +enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void 允许指定第三方应用帐户的名称访问指定包名称的第三方应用,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------------------- | ---- | ------------------------------------------------------------ | - | name | string | 是 | 应用帐号名称。 | - | bundleName | string | 是 | 第三方应用的包名。 | - | callback | AsyncCallback<void> | 是 | 允许指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------------------------------------------ | +| name | string | 是 | 应用帐号名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | +| callback | AsyncCallback<void> | 是 | 允许指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -289,24 +296,26 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<voi ### enableAppAccess -enableAppAccess(name: string, bundleName: string): Promise<void>; +enableAppAccess(name: string, bundleName: string): Promise<void> 允许指定第三方应用帐户的名称访问指定包名称的第三方应用,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------ | ---- | ------------------ | - | name | string | 是 | 应用帐号名称。 | - | bundleName | string | 是 | 第三方应用的包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------ | +| name | string | 是 | 应用帐号名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { @@ -318,20 +327,22 @@ enableAppAccess(name: string, bundleName: string): Promise<void>; ### checkAppAccountSyncEnable -checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void; +checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void 检查指定应用帐号是否允许应用数据同步,使用callback回调异步返回结果。 -需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | -------------------------------------------- | - | name | string | 是 | 应用帐号名称。 | - | callback | AsyncCallback<boolean> | 是 | 检查指定应用帐号是否允许应用数据同步的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | -------------------------------------------- | +| name | string | 是 | 应用帐号名称。 | +| callback | AsyncCallback<boolean> | 是 | 检查指定应用帐号是否允许应用数据同步的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -343,25 +354,27 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): ### checkAppAccountSyncEnable -checkAppAccountSyncEnable(name: string): Promise<boolean>; +checkAppAccountSyncEnable(name: string): Promise<boolean> 检查指定应用帐号是否允许应用数据同步,使用Promise方式异步返回结果。 -需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 + +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | -------------- | - | name | string | 是 | 应用帐号名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------- | +| name | string | 是 | 应用帐号名称。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :--------------------- | :---------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -374,20 +387,22 @@ checkAppAccountSyncEnable(name: string): Promise<boolean>; ### setAccountCredential -setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void; +setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void 设置此应用程序帐号的凭据,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------------------- | ---- | ---------------------------- | - | name | string | 是 | 应用程序帐户的名称。 | - | credentialType | string | 是 | 要设置的凭据的类型。 | - | credential | string | 是 | 要设置的凭据。 | - | callback | AsyncCallback<void> | 是 | 设置此应用帐号的凭据的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | ---- | ---------------------------- | +| name | string | 是 | 应用程序帐户的名称。 | +| credentialType | string | 是 | 要设置的凭据的类型。 | +| credential | string | 是 | 要设置的凭据。 | +| callback | AsyncCallback<void> | 是 | 设置此应用帐号的凭据的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -398,25 +413,27 @@ setAccountCredential(name: string, credentialType: string, credential: string,ca ### setAccountCredential -setAccountCredential(name: string, credentialType: string, credential: string): Promise<void>; +setAccountCredential(name: string, credentialType: string, credential: string): Promise<void> 设置此应用程序帐号的凭据,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------ | ---- | -------------------- | - | name | string | 是 | 应用帐户的名称。 | - | credentialType | string | 是 | 要设置的凭据的类型。 | - | credential | string | 是 | 要设置的凭据。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | -------------------- | +| name | string | 是 | 应用帐户的名称。 | +| credentialType | string | 是 | 要设置的凭据的类型。 | +| credential | string | 是 | 要设置的凭据。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -429,19 +446,21 @@ setAccountCredential(name: string, credentialType: string, credential: string): ### setAccountExtraInfo -setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void; +setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void 设置此应用程序帐号的额外信息,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------------- | ---- | -------------------------------- | - | name | string | 是 | 应用帐户的名称。 | - | extraInfo | string | 是 | 要设置的额外信息。 | - | callback | AsyncCallback<void> | 是 | 设置此应用帐号的额外信息的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | -------------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| extraInfo | string | 是 | 要设置的额外信息。 | +| callback | AsyncCallback<void> | 是 | 设置此应用帐号的额外信息的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -452,24 +471,26 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback< ### setAccountExtraInfo -setAccountExtraInfo(name: string, extraInfo: string): Promise<void>; +setAccountExtraInfo(name: string, extraInfo: string): Promise<void> 设置此应用程序帐号的额外信息,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------ | ---- | ------------------ | - | name | string | 是 | 应用帐户的名称。 | - | extraInfo | string | 是 | 要设置的额外信息。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------------ | +| name | string | 是 | 应用帐户的名称。 | +| extraInfo | string | 是 | 要设置的额外信息。 | - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -482,21 +503,23 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise<void>; ### setAppAccountSyncEnable -setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void; +setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void 设置指定的应用程序帐号是否允许应用程序数据同步,使用callback回调异步返回结果。 -需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 + +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | -------------------------------------------------- | - | name | string | 是 | 应用帐户的名称。 | - | isEnable | boolean | 是 | 是否允许应用数据同步。 | - | callback | AsyncCallback<void> | 是 | 设置指定的应用帐号是否允许应用程序数据同步的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------------------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| isEnable | boolean | 是 | 是否允许应用数据同步。 | +| callback | AsyncCallback<void> | 是 | 设置指定的应用帐号是否允许应用程序数据同步的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -507,26 +530,28 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback ### setAppAccountSyncEnable -setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>; +setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void> 设置指定的应用程序帐号是否允许应用程序数据同步,使用Promise方式异步返回结果。 -需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------- | ---- | ---------------------- | - | name | string | 是 | 应用帐户的名称。 | - | isEnable | boolean | 是 | 是否允许应用数据同步。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------- | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| isEnable | boolean | 是 | 是否允许应用数据同步。 | - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -539,20 +564,22 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>; ### setAssociatedData -setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void; +setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void 设置与此应用程序帐号关联的数据,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | ---------------------------------- | - | name | string | 是 | 应用帐户的名称。 | - | key | string | 是 | 要设置的数据的键,密钥可以自定义。 | - | value | string | 是 | 要设置的数据的值。 | - | callback | AsyncCallback<void> | 是 | 设置与此应用帐号关联的数据的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| key | string | 是 | 要设置的数据的键,密钥可以自定义。 | +| value | string | 是 | 要设置的数据的值。 | +| callback | AsyncCallback<void> | 是 | 设置与此应用帐号关联的数据的回调。 | -- 示例: +**示例:** ``` app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => { @@ -562,25 +589,27 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb ### setAssociatedData -setAssociatedData(name: string, key: string, value: string): Promise<void>; +setAssociatedData(name: string, key: string, value: string): Promise<void> 设置与此应用程序帐号关联的数据,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ---------------------------------- | - | name | string | 是 | 应用帐户的名称。 | - | key | string | 是 | 要设置的数据的键,密钥可以自定义。 | - | value | string | 是 | 要设置的数据的值。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| key | string | 是 | 要设置的数据的键,密钥可以自定义。 | +| value | string | 是 | 要设置的数据的值。 | - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -593,19 +622,21 @@ setAssociatedData(name: string, key: string, value: string): Promise<void> ### getAccountCredential -getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void; +getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void 获取此应用帐号的凭据,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | --------------------- | ---- | ---------------------------- | - | name | string | 是 | 应用帐号名称。 | - | credentialType | string | 是 | 要获取的凭据的类型。 | - | callback | AsyncCallback<string> | 是 | 获取此应用帐号的凭据的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | --------------------------- | ---- | ---------------------------- | +| name | string | 是 | 应用帐号名称。 | +| credentialType | string | 是 | 要获取的凭据的类型。 | +| callback | AsyncCallback<string> | 是 | 获取此应用帐号的凭据的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -617,24 +648,26 @@ getAccountCredential(name: string, credentialType: string, callback: AsyncCallba ### getAccountCredential -getAccountCredential(name: string, credentialType: string): Promise<string>; +getAccountCredential(name: string, credentialType: string): Promise<string> 获取此应用程序帐号的凭据,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------ | ---- | -------------------- | - | name | string | 是 | 应用帐号名称。 | - | credentialType | string | 是 | 要获取的凭据的类型。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | -------------------- | +| name | string | 是 | 应用帐号名称。 | +| credentialType | string | 是 | 要获取的凭据的类型。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :---------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -647,18 +680,20 @@ getAccountCredential(name: string, credentialType: string): Promise<string> ### getAccountExtraInfo -getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void; +getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void 获取此应用帐号的额外信息,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | -------------------------------- | - | name | string | 是 | 应用帐号名称。 | - | callback | AsyncCallback<string> | 是 | 获取此应用帐号的额外信息的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------------------------- | +| name | string | 是 | 应用帐号名称。 | +| callback | AsyncCallback<string> | 是 | 获取此应用帐号的额外信息的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -670,23 +705,25 @@ getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void; ### getAccountExtraInfo -getAccountExtraInfo(name: string): Promise<string>; +getAccountExtraInfo(name: string): Promise<string> 获取此应用程序帐号的额外信息,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | -------------- | - | name | string | 是 | 应用帐号名称。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------- | +| name | string | 是 | 应用帐号名称。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :---------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -699,19 +736,21 @@ getAccountExtraInfo(name: string): Promise<string>; ### getAssociatedData -getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void; +getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void 获取与此应用程序帐号关联的数据,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ---------------------------------- | - | name | string | 是 | 应用帐号名称。 | - | key | string | 是 | 要获取的数据的key。 | - | callback | AsyncCallback<string> | 是 | 获取与此应用帐号关联的数据的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ---------------------------------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要获取的数据的key。 | +| callback | AsyncCallback<string> | 是 | 获取与此应用帐号关联的数据的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -723,24 +762,26 @@ getAssociatedData(name: string, key: string, callback: AsyncCallback<string&g ### getAssociatedData -getAssociatedData(name: string, key: string): Promise<string>; +getAssociatedData(name: string, key: string): Promise<string> 获取与此应用程序帐号关联的数据,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------- | - | name | string | 是 | 应用帐号名称。 | - | key | string | 是 | 要获取的数据的key。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要获取的数据的key。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :---------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -753,19 +794,21 @@ getAssociatedData(name: string, key: string): Promise<string>; ### getAllAccessibleAccounts -getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void; +getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void 获取全部应用已授权帐号信息。 -需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。 +**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。 + +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------ | ---- | ---------------- | - | callback | AsyncCallback<Array<AppAccountInfo>> | 是 | 应用帐号信息列表 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | ---------------- | +| callback | AsyncCallback<Array<AppAccountInfo>> | 是 | 应用帐号信息列表 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -777,19 +820,21 @@ getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>& ### getAllAccessibleAccounts -getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>; +getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>> 获取全部应用已授权帐号信息。 -需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。 +**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 类型 | 说明 | - | ------------------------------ | ----------------------------------- | - | Promise<Array<AppAccountInfo>> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| ------------------------------------------ | ----------------------------------- | +| Promise<Array<AppAccountInfo>> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -802,20 +847,22 @@ getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>; ### getAllAccounts -getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void; +getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void 获取指定应用全部帐号信息。 -需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。 +**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。 + +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------ | ---- | ---------------- | - | owner | string | 是 | 应用包名称 | - | callback | AsyncCallback<Array<AppAccountInfo>> | 是 | 应用帐号信息列表 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | ---------------- | +| owner | string | 是 | 应用包名称 | +| callback | AsyncCallback<Array<AppAccountInfo>> | 是 | 应用帐号信息列表 | -- 示例: +**示例:** ``` const appAccountManager = account.createAppAccountManager(); @@ -828,25 +875,27 @@ getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo ### getAllAccounts -getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>; +getAllAccounts(owner: string): Promise<Array<AppAccountInfo>> 获取指定应用全部帐号信息。 -需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。 +**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。 + +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ---------- | - | owner | string | 是 | 应用包名称 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------- | +| owner | string | 是 | 应用包名称 | -- 参数: +**参数:** - | 类型 | 说明 | - | ------------------------------ | ----------------------------------- | - | Promise<Array<AppAccountInfo>> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ------------------------------------------ | ----------------------------------- | +| Promise<Array<AppAccountInfo>> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -860,19 +909,21 @@ getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>; ### on('change') -on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void; +on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void 订阅指定帐号所有者的帐户变更事件,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | - | type | 'change' | 是 | 关于帐户更改事件,当帐户所有者更新帐户时,订阅者将收到通知。 | - | owners | Array<string> | 是 | 指示帐户的所有者。 | - | callback | Callback<Array<AppAccountInfo>> | 是 | 订阅指定帐号所有者的帐户变更事件的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | 'change' | 是 | 关于帐户更改事件,当帐户所有者更新帐户时,订阅者将收到通知。 | +| owners | Array<string> | 是 | 指示帐户的所有者。 | +| callback | Callback<Array<AppAccountInfo>> | 是 | 订阅指定帐号所有者的帐户变更事件的回调。 | + +**示例:** ``` const appAccountManager = account.createAppAccountManager(); @@ -889,18 +940,20 @@ on(type: 'change', owners: Array<string>, callback: Callback<Array<A ### off('change') -off(type: 'change', callback?: Callback<void>): void; +off(type: 'change', callback?: Callback>): void 取消订阅帐号事件,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------------------- | ---- | ------------------------ | - | type | 'change' | 是 | 关于帐户更改事件。 | - | callback | Callback<void> | 否 | 取消订阅帐号事件的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------- | ---- | ------------------------ | +| type | 'change' | 是 | 关于帐户更改事件。 | +| callback | Callback> | 否 | 取消订阅帐号事件的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account.createAppAccountManager(); @@ -920,21 +973,23 @@ off(type: 'change', callback?: Callback<void>): void; ### 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 鉴权应用帐户以获取OAuth令牌,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | --------------------------- | - | name | string | 是 | 要鉴权的应用帐户的名称。 | - | owner | string | 是 | 要鉴权的应用帐户的所有者包名。 | - | authType | string | 是 | 鉴权类型。 | - | options | {[key: string]: any} | 是 | 鉴权所需的可选项。 | - | callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ------------------------------ | +| name | string | 是 | 要鉴权的应用帐户的名称。 | +| owner | string | 是 | 要鉴权的应用帐户的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| options | {[key: string]: any} | 是 | 鉴权所需的可选项。 | +| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 | + +**示例:** ``` import featureAbility from '@ohos.ability.featureAbility'; @@ -960,20 +1015,22 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri ### getOAuthToken8+ -getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void; +getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void 获取指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------------- | ---- | -------------------- | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | authType | string | 是 | 鉴权类型。 | - | callback | AsyncCallback<string> | 是 | 查询结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| callback | AsyncCallback<string> | 是 | 查询结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -985,25 +1042,27 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall ### getOAuthToken8+ -getOAuthToken(name: string, owner: string, authType: string): Promise<string>; +getOAuthToken(name: string, owner: string, authType: string): Promise<string> 获取指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | -------------------- | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | authType | string | 是 | 鉴权类型。 | +**参数:** -- 参数: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | - | 类型 | 说明 | - | --------------------- | -------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| --------------------- | ----------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1016,20 +1075,22 @@ getOAuthToken(name: string, owner: string, authType: string): Promise<string& ### setOAuthToken8+ -setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void; +setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void 设置指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------- | ---- | ------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | token | string | 是 | OAuth令牌。 | - | callback | AsyncCallback<void> | 是 | 设置结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------- | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | OAuth令牌。 | +| callback | AsyncCallback<void> | 是 | 设置结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1040,25 +1101,27 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall ### setOAuthToken8+ -setOAuthToken(name: string, authType: string, token: string): Promise<void>; +setOAuthToken(name: string, authType: string, token: string): Promise<void> 设置指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | ------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | token | string | 是 | OAuth令牌。 | +**参数:** -- 参数: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------- | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | OAuth令牌。 | - | 类型 | 说明 | - | ------------------- | -------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| ------------------- | ----------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1071,21 +1134,23 @@ setOAuthToken(name: string, authType: string, token: string): Promise<void> ### 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 删除指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------- | ---- | ------------------ | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | authType | string | 是 | 鉴权类型。 | - | token | string | 是 | 要删除的OAuth令牌。 | - | callback | AsyncCallback<void> | 是 | 删除结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | 要删除的OAuth令牌。 | +| callback | AsyncCallback<void> | 是 | 删除结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1096,26 +1161,28 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c ### deleteOAuthToken8+ -deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>; +deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void> 删除指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | ------------------ | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | authType | string | 是 | 鉴权类型。 | - | token | string | 是 | 要删除的OAuth令牌。 | +**参数:** -- 参数: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | 要删除的OAuth令牌。 | - | 类型 | 说明 | - | ------------------------------ | --------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| ------------------- | ----------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1128,21 +1195,23 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string): ### 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 设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------------------------- | ---- | ------------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | bundleName | string | 是 | 被设置可见性的应用包名。| - | isVisible | boolean | 是 | 是否可见。 | - | callback | AsyncCallback<void> | 是 | 设置结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------ | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 被设置可见性的应用包名。 | +| isVisible | boolean | 是 | 是否可见。 | +| callback | AsyncCallback<void> | 是 | 设置结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1153,26 +1222,28 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi ### setOAuthTokenVisibility8+ -setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>; +setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void> 设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------------------------- | ---- | ------------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | bundleName | string | 是 | 被设置可见性的应用包名。| - | isVisible | boolean | 是 | 是否可见。 | +**参数:** -- 参数: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------- | ---- | ------------------------ | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 被设置可见性的应用包名。 | +| isVisible | boolean | 是 | 是否可见。 | - | 类型 | 说明 | - | ------------------------------ | --------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| ------------------- | ----------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1186,20 +1257,22 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi ### checkOAuthTokenVisibility8+ -checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void; +checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void 检查指定鉴权类型的OAuth令牌对特定应用的可见性,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ---------------------------- | ---- | ---------------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | bundleName | string | 是 | 用于检查可见性的应用包名。 | - | callback | AsyncCallback<boolean> | 是 | 检查结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ---------------------------- | ---- | -------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 用于检查可见性的应用包名。 | +| callback | AsyncCallback<boolean> | 是 | 检查结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1211,25 +1284,27 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca ### checkOAuthTokenVisibility8+ -checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>; +checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean> 检查指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------------------------- | ---- | ---------------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | bundleName | string | 是 | 用于检查可见性的应用包名。 | +**参数:** -- 参数: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | -------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 用于检查可见性的应用包名。 | - | 类型 | 说明 | - | ------------------------------ | ------------------------ | - | Promise<boolean> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| ---------------------- | ----------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1242,19 +1317,21 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P ### getAllOAuthTokens8+ -getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void; +getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void 获取指定应用对调用方全部可见的OAuth令牌,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------------------ | ---- | ------------------- | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | callback | AsyncCallback<Array<OAuthTokenInfo>> | 是 | 查询结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| callback | AsyncCallback<Array<OAuthTokenInfo>> | 是 | 查询结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1266,24 +1343,26 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array& ### getAllOAuthTokens8+ -getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>>; +getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>> 获取指定应用帐户对调用方可见的全部OAuth令牌,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | ------------------- | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | -- 参数: +**参数:** - | 类型 | 说明 | - | ------------------------------ | ----------------------------------- | - | Promise<Array<OAuthTokenInfo>> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ------------------------------------------ | ----------------------------------- | +| Promise<Array<OAuthTokenInfo>> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1296,19 +1375,21 @@ getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenIn ### getOAuthList8+ -getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void; +getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void 获取指定应用帐户和鉴权类型的OAuth令牌的授权列表,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------------------- | ---- | ------------------ | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | callback | AsyncCallback<Array<string>> | 是 | 查询结果的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| callback | AsyncCallback<Array<string>> | 是 | 查询结果的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1320,24 +1401,26 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback<Array< ### getOAuthList8+ -getOAuthList(name: string, authType: string): Promise<Array<string>>; +getOAuthList(name: string, authType: string): Promise<Array<string>> 获取指定应用帐户和鉴权类型的OAuth令牌的授权列表,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | ------------------- | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | -- 参数: +**参数:** - | 类型 | 说明 | - | ------------------------------ | ------------------------------------ | - | Promise<Array<string>> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ---------------------------------- | ----------------------------------- | +| Promise<Array<string>> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1350,18 +1433,20 @@ getOAuthList(name: string, authType: string): Promise<Array<string>> ### getAuthenticatorCallback8+ -getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void; +getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void 获取鉴权会话的认证器回调,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------------------------------------ | ---- | -------------- | - | sessionId | string | 是 | 鉴权会话的标识。 | - | callback | AsyncCallback<AuthenticatorCallback> | 是 | 查询结果的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------------------------ | ---- | ---------------- | +| sessionId | string | 是 | 鉴权会话的标识。 | +| callback | AsyncCallback<AuthenticatorCallback> | 是 | 查询结果的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1383,23 +1468,25 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<Authentic ### getAuthenticatorCallback8+ -getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>; +getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> 获取鉴权会话的认证器回调,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------ | ---- | -------------- | - | sessionId | string | 是 | 鉴权会话的标识。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ---------------- | +| sessionId | string | 是 | 鉴权会话的标识。 | -- 参数: +**参数:** - | 类型 | 说明 | - | ------------------------------------ | -------------------------------- | - | Promise<AuthenticatorCallback> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ------------------------------------ | ----------------------------------- | +| Promise<AuthenticatorCallback> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1421,18 +1508,20 @@ getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> ### getAuthenticatorInfo8+ -getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void; +getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void 获取指定应用帐户的认证器信息,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------------------------------------- | ---- | ------------------- | - | owner | string | 是 | 应用帐户的所有者包名。 | - | callback | AsyncCallback<AuthenticatorInfo> | 是 | 查询结果的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ---------------------- | +| owner | string | 是 | 应用帐户的所有者包名。 | +| callback | AsyncCallback<AuthenticatorInfo> | 是 | 查询结果的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1444,23 +1533,25 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo ### getAuthenticatorInfo8+ -getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>; +getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo> 获取指定应用帐户的认证器信息,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ----- | ------ | ---- | -------------------- | - | owner | string | 是 | 应用帐户的所有者包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| owner | string | 是 | 应用帐户的所有者包名。 | -- 参数: +**参数:** - | 类型 | 说明 | - | ------------------------------ | ----------------------------------- | - | Promise<AuthenticatorInfo> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| -------------------------------- | ----------------------------------- | +| Promise<AuthenticatorInfo> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1475,26 +1566,32 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>; 表示应用帐号信息。 -| 参数名 | 类型 | 必填 | 说明 | -| ----- | ------ | ---- | ---------------- | -| owner | string | 是 | 应用帐户的所有者包名。 | -| name | string | 是 | 应用帐户的名称。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| owner | string | 是 | 应用帐户的所有者包名。 | +| name | string | 是 | 应用帐户的名称。 | ## OAuthTokenInfo8+ 表示OAuth令牌信息。 -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | -------------- | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------- | | authType | string | 是 | 令牌的鉴权类型。 | -| token | string | 是 | 令牌的取值。 | +| token | string | 是 | 令牌的取值。 | ## AuthenticatorInfo8+ 表示OAuth认证器信息。 -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | ------------------ | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | -------------------- | | owner | string | 是 | 认证器的所有者包名。 | | iconId | string | 是 | 认证器的图标标识。 | | labelId | string | 是 | 认证器的标签标识。 | @@ -1503,45 +1600,49 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>; 表示常量的枚举。 -| 名称 | 默认值 | 描述 | -| ----------------------------- | ---------------------- | ----------------------- | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 名称 | 默认值 | 描述 | +| ----------------------------- | ---------------------- | ------------------------- | | ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | 表示操作_隐式添加帐号。 | -| ACTION_AUTHENTICATE | "authenticate" | 表示操作_鉴权。 | +| ACTION_AUTHENTICATE | "authenticate" | 表示操作_鉴权。 | | KEY_NAME | "name" | 表示键名_应用帐户名称。 | | KEY_OWNER | "owner" | 表示键名_应用帐户所有者。 | -| KEY_TOKEN | "token" | 表示键名_令牌。 | -| KEY_ACTION | "action" | 表示键名_操作。 | -| KEY_AUTH_TYPE | "authType" | 表示键名_鉴权类型。 | -| KEY_SESSION_ID | "sessionId" | 表示键名_会话标识。 | -| KEY_CALLER_PID | "callerPid" | 表示键名_调用方PID。 | -| KEY_CALLER_UID | "callerUid" | 表示键名_调用方UID。 | +| KEY_TOKEN | "token" | 表示键名_令牌。 | +| KEY_ACTION | "action" | 表示键名_操作。 | +| KEY_AUTH_TYPE | "authType" | 表示键名_鉴权类型。 | +| KEY_SESSION_ID | "sessionId" | 表示键名_会话标识。 | +| KEY_CALLER_PID | "callerPid" | 表示键名_调用方PID。 | +| KEY_CALLER_UID | "callerUid" | 表示键名_调用方UID。 | | KEY_CALLER_BUNDLE_NAME | "callerBundleName" | 表示键名_调用方包名。 | ## ResultCode8+ 表示返回码的枚举。 -| 名称 | 默认值 | 描述 | -| ----------------------------------- | ----- | ---------------------- | -| SUCCESS | 0 | 表示操作成功。 | -| ERROR_ACCOUNT_NOT_EXIST | 10001 | 表示应用帐户不存在。 | -| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | 表示应用帐户服务异常。 | -| ERROR_INVALID_PASSWORD | 10003 | 表示密码无效。 | -| ERROR_INVALID_REQUEST | 10004 | 表示请求无效。 | -| ERROR_INVALID_RESPONSE | 10005 | 表示响应无效。 | -| ERROR_NETWORK_EXCEPTION | 10006 | 表示网络异常。 | -| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | 表示认证器不存在。 | -| ERROR_OAUTH_CANCELED | 10008 | 表示鉴权取消。 | -| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | 表示开放授权列表过大。 | -| ERROR_OAUTH_SERVICE_BUSY | 10010 | 表示开放授权服务忙碌。 | -| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | 表示开放授权服务异常。 | -| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | 表示鉴权会话不存在。 | -| ERROR_OAUTH_TIMEOUT | 10013 | 表示鉴权超时。 | -| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | 表示开放授权令牌不存在。 | -| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | 表示开放授权令牌过多。 | -| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | 表示不支持的鉴权操作。 | -| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | 表示不支持的鉴权类型。 | -| ERROR_PERMISSION_DENIED | 10018 | 表示权限不足。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 名称 | 默认值 | 描述 | +| ----------------------------------- | ------ | ------------------------ | +| SUCCESS | 0 | 表示操作成功。 | +| ERROR_ACCOUNT_NOT_EXIST | 10001 | 表示应用帐户不存在。 | +| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | 表示应用帐户服务异常。 | +| ERROR_INVALID_PASSWORD | 10003 | 表示密码无效。 | +| ERROR_INVALID_REQUEST | 10004 | 表示请求无效。 | +| ERROR_INVALID_RESPONSE | 10005 | 表示响应无效。 | +| ERROR_NETWORK_EXCEPTION | 10006 | 表示网络异常。 | +| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | 表示认证器不存在。 | +| ERROR_OAUTH_CANCELED | 10008 | 表示鉴权取消。 | +| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | 表示开放授权列表过大。 | +| ERROR_OAUTH_SERVICE_BUSY | 10010 | 表示开放授权服务忙碌。 | +| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | 表示开放授权服务异常。 | +| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | 表示鉴权会话不存在。 | +| ERROR_OAUTH_TIMEOUT | 10013 | 表示鉴权超时。 | +| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | 表示开放授权令牌不存在。 | +| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | 表示开放授权令牌过多。 | +| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | 表示不支持的鉴权操作。 | +| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | 表示不支持的鉴权类型。 | +| ERROR_PERMISSION_DENIED | 10018 | 表示权限不足。 | ## AuthenticatorCallback8+ @@ -1549,17 +1650,19 @@ OAuth认证器回调接口。 ### onResult8+ -onResult: (code: number, result: {[key: string]: any}) => void; +onResult: (code: number, result: {[key: string]: any}) => void 通知鉴权结果。 -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | ------ | -------------------- | ---- | ----------- | - | code | number | 是 | 鉴权结果码。 | - | result | {[key: string]: any} | 是 | 鉴权结果。 | +**系统能力:** SystemCapability.Account.AppAccount -- 示例: +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------------- | ---- | ------------ | +| code | number | 是 | 鉴权结果码。 | +| result | {[key: string]: any} | 是 | 鉴权结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1577,16 +1680,18 @@ onResult: (code: number, result: {[key: string]: any}) => void; ### onRequestRedirected8+ -onRequestRedirected: (request: Want) => void; +onRequestRedirected: (request: Want) => void 通知鉴权请求被跳转。 -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ---- | ---- | ------------------ | - | request | Want | 是 | 用于跳转的请求信息。 | +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---- | ---- | -------------------- | +| request | Want | 是 | 用于跳转的请求信息。 | -- 示例: +**示例:** ``` class MyAuthenticator extends account_appAccount.Authenticator { @@ -1612,34 +1717,38 @@ OAuth认证器基类。 ### 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 根据指定的鉴权类型和可选项,隐式地添加应用帐户,并使用callback回调异步返回结果。 -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | ---------------- | --------------------- | --- | -------------------------- | - | authType | string | 是 | 应用帐户的鉴权类型。 | - | callerBundleName | string | 是 | 鉴权请求方的包名。 | - | options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 | - | callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 | +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | --------------------- | ---- | ------------------------------ | +| authType | string | 是 | 应用帐户的鉴权类型。 | +| callerBundleName | string | 是 | 鉴权请求方的包名。 | +| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 | +| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 | ### 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 对应用帐户进行鉴权,获取OAuth令牌,并使用callback回调异步返回结果。 -- 参数: - | 接口名 | 类型 | 必填 | 说明 | - | ---------------- | --------------------- | ---- | -------------------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 应用帐户的鉴权类型。 | - | callerBundleName | string | 是 | 鉴权请求方的包名。 | - | options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 | - | callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 | +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** +| 接口名 | 类型 | 必填 | 说明 | +| ---------------- | --------------------- | ---- | ------------------------------ | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 应用帐户的鉴权类型。 | +| callerBundleName | string | 是 | 鉴权请求方的包名。 | +| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 | +| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 | -- 示例: +**示例:** ``` class MyAuthenticator extends account_appAccount.Authenticator { @@ -1663,4 +1772,4 @@ authenticate(name: string, authType: string, callerBundleName: string, options: return new MyAuthenticator(); } } - ``` + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md index a42342c7a9155f3874bde46c253f00ab194c3fe3..a97420ecc3e7c326a1e86f6a153d1424b06d1f7e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md @@ -6,7 +6,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 从API Version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 类的数据共享扩展能力。 @@ -21,10 +21,10 @@ import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbili ## 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| context? | ExtensionContext | 是 | 否 | 指示数据共享扩展能力上下文。
**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider | - +| 名称 | 可读 | 可写 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | -------- | -------- | +| context | 是 | 否 | ExtensionContext | 否 | 指示数据共享扩展能力上下文。
**系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider | + ## DataShareExtensionAbility.onCreate @@ -83,7 +83,7 @@ DAHelper.getFileTypes( ## DataShareExtensionAbility.insert -insert?(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\): void +insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\): void 将单个数据记录插入数据库(callback形式)。 @@ -120,7 +120,7 @@ DAHelper.insert( ## DataShareExtensionAbility.update -update?(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void +update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void 更新数据库中的数据记录(callback形式)。 @@ -259,7 +259,7 @@ DAHelper.getType( ## DataShareExtensionAbility.batchInsert -batchInsert?(uri: string, valuesBuckets: Array, callback: AsyncCallback\): void +batchInsert?(uri: string, valueBuckets: Array, callback: AsyncCallback\): void 插入数据库(callback形式)。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md b/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md index bad372255e7d250eb79a1c656cabe8c0aed6a01a..8c715fe253c2f908deaeb0f162e9dae5ab5b22cd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md @@ -6,7 +6,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 从API Version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 StartOptions是系统的基本通信组件。 @@ -21,10 +21,10 @@ import StartOptions from '@ohos.application.StartOptions'; ## 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| windowMode? | number | 是 | 否 | 窗口模式。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore | -| displayId? | number | 是 | 否 | 显示ID。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore | +| 名称 | 可读 | 可写 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | -------- | -------- | +| windowMode | 是 | 否 | number | 否 | 窗口模式。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore | +| displayId | 是 | 否 | number | 否 | 显示ID。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md index 07c67027e18944870e1747015b2bcb31459e986e..9dc5fe3e76e5d60877bc45cb6d0f650c6e6dc931 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md @@ -1,7 +1,7 @@ # Ability > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 从API Version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 Ability模块,提供对Ability生命周期、上下文环境等调用管理。 @@ -363,7 +363,6 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa this.name = name; this.str = str; } - constructor() {} marshalling(messageParcel) { messageParcel.writeInt(this.num); messageParcel.writeString(this.str); @@ -380,7 +379,6 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa var method = 'call_Function'; var caller; export default class MainAbility extends Ability { - onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ bundleName: "com.example.myservice", diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md index c777da815e168dcca898b2a8970bb22be8520212..9f7399e90bec28776e893d9543ea1290f8236c85 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md @@ -1,7 +1,7 @@ # AbilityStage > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 AbilityStage是HAP包的运行时类。在HAP加载的时候,通知开发者,开发者可以在此进行该HAP的初始化(如资源预加载,线程创建等)。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md index f7d0f2fb6c7617c08d6b683d564b6f4d3c34df33..fd5d831722260b0bddc5408d02c408c220a98554 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md @@ -1,7 +1,7 @@ # appManager > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块首批接口从API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 App管理。 @@ -165,4 +165,15 @@ getAppMemorySize(callback: AsyncCallback\): void; console.log('startAbility result success:' + JSON.stringify(data)); }) } - ``` \ No newline at end of file + ``` + +## ProcessRunningInfo + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core + +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| pid8+ | 只读 | number | 否 | 进程ID。 | +| uid8+ | 只读 | number | 否 | 用户ID。 | +| processName8+ | 只读 | string | 否 | 进程的名称。 | +| bundleNames8+ | 只读 | Array\ | 否 | 进程中运行的bundleName数组。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md index 7435c4bd4aad33fb8e261a1a7b3368e94091a011..cacdffa0928cc681600613b68c7a8f0ca71c6bd0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md @@ -264,6 +264,7 @@ arrayList.removeByRange(2, 6); ``` ### replaceAllElements + replaceAllElements(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => T, thisArg?: Object): void @@ -301,6 +302,7 @@ arrayList.replaceAllElements((value, index) => { ``` ### forEach + forEach(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => void, thisArg?: Object): void @@ -335,6 +337,7 @@ arrayList.forEach((value, index) => { ``` ### sort + sort(comparator?: (firstValue: T, secondValue: T) => number): void 对ArrayList中的元素排序。 @@ -366,6 +369,7 @@ arrayList.sort(); ``` ### subArrayList + subArrayList(fromIndex: number, toIndex: number): ArrayList<T> 根据下标截取ArrayList中的一段元素,并返回这一段ArrayList实例,包括起始值但不包括终止值。 @@ -397,6 +401,7 @@ let result3 = arrayList.subArrayList(2, 6); ``` ### clear + clear(): void 清除ArrayList中的所有元素,并把length置为0。 @@ -413,6 +418,7 @@ arrayList.clear(); ``` ### clone + clone(): ArrayList<T> 克隆一个与ArrayList相同的实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 @@ -436,6 +442,7 @@ let result = arrayList.clone(); ``` ### getCapacity + getCapacity(): number 获取当前实例的容量大小。 @@ -458,6 +465,7 @@ let result = arrayList.getCapacity(); ``` ### convertToArray + convertToArray(): Array<T> 把当前ArrayList实例转换成数组,并返回转换后的数组。 @@ -480,6 +488,7 @@ let result = arrayList.convertToArray(); ``` ### isEmpty + isEmpty(): boolean 判断该ArrayList是否为空。 @@ -502,6 +511,7 @@ let result = arrayList.isEmpty(); ``` ### increaseCapacityTo + increaseCapacityTo(newCapacity: number): void 如果传入的新容量大于或等于ArrayList中的元素个数,将容量变更为新容量。 @@ -525,6 +535,7 @@ arrayList.increaseCapacityTo(8); ``` ### trimToCurrentLength + trimToCurrentLength(): void 把容量限制为当前的length大小。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index 7d3d334e0014119a9a6d70d2dba5213236ae3620..4ccdece143e9a6123ec8314398553d2016b8fb48 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -477,7 +477,7 @@ let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); | 名称 | 类型 | 必填 | 说明 | | ------------- | --------------------------- | ---- | ---------------- | -| contentType | [ContentType](#contenttype) | 是 | 媒体类型。 | +| content | [ContentType](#contenttype) | 是 | 媒体类型。 | | usage | [StreamUsage](#streamusage) | 是 | 音频流使用类型。 | | rendererFlags | number | 是 | 音频渲染器标志。 | @@ -580,7 +580,7 @@ let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); | 名称 | 类型 | 必填 | 说明 | | ------------ | --------------------------------------- | ---- | ---------------- | | streamInfo | [AudioStreamInfo](#audiostreaminfo8) | 是 | 表示音频流信息。 | -| rendererInfo | [AudioCapturerInfo](#audiocapturerinfo) | 是 | 表示采集器信息。 | +| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo) | 是 | 表示采集器信息。 | ## AudioCapturerInfo8+ @@ -599,10 +599,11 @@ let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | -| :------------------ | :----- | :------------- | -| SOURCE_TYPE_INVALID | -1 | 无效的音频源。 | -| SOURCE_TYPE_MIC | 0 | Mic音频源。 | +| 名称 | 默认值 | 描述 | +| :------------------------------ | :----- | :----------------------------------------------------------- | +| SOURCE_TYPE_INVALID | -1 | 无效的音频源。 | +| SOURCE_TYPE_MIC | 0 | Mic音频源。 | +| SOURCE_TYPE_VOICE_COMMUNICATION | 7 | 语音通话场景的音频源。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | ## AudioScene8+ @@ -610,12 +611,12 @@ let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Communication -| 名称 | 默认值 | 描述 | -| :------------------------------------------------- | :----- | :------------- | -| AUDIO_SCENE_DEFAULT | 0 | 默认音频场景。 | -| AUDIO_SCENE_RINGING(系统接口,三方应用不支持) | 1 | 响铃模式。 | -| AUDIO_SCENE_PHONE_CALL(系统接口,三方应用不支持) | 2 | 电话模式。 | -| AUDIO_SCENE_VOICE_CHAT | 3 | 语音聊天模式。 | +| 名称 | 默认值 | 描述 | +| :--------------------- | :----- | :-------------------------------------------- | +| AUDIO_SCENE_DEFAULT | 0 | 默认音频场景。 | +| AUDIO_SCENE_RINGING | 1 | 响铃模式。
系统接口,三方应用不支持调用。 | +| AUDIO_SCENE_PHONE_CALL | 2 | 电话模式。
系统接口,三方应用不支持调用。 | +| AUDIO_SCENE_VOICE_CHAT | 3 | 语音聊天模式。 | ## AudioManager @@ -1738,9 +1739,9 @@ setAudioScene\(scene: AudioScene\): Promise 此接口为系统接口,三方应用不支持。 -**系统能力:**: SystemCapability.Multimedia.Audio.Communication +**系统能力:** SystemCapability.Multimedia.Audio.Communication -**Parameters** +**参数:** | 参数名 | 类型 | 必填 | 说明 | | :----- | :----------------------------------- | :--- | :------------- | @@ -1768,7 +1769,7 @@ getAudioScene\(callback: AsyncCallback\): void 获取音频场景模式,使用callback方式返回异步结果。 -**系统能力:**SystemCapability.Multimedia.Audio.Communication +**系统能力:** SystemCapability.Multimedia.Audio.Communication **参数:** @@ -3177,7 +3178,7 @@ on(type: 'stateChange', callback: Callback): void | 参数名 | 类型 | 必填 | 说明 | | :------- | :------------------------- | :--- | :------------------------------------------ | | type | string | 是 | 事件回调类型,支持的事件为:'stateChange'。 | -| callback | [AudioState](#AudioState8) | 是 | 返回监听的状态。 | +| callback | [AudioState](#audiostate8) | 是 | 返回监听的状态。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md index 874602eabbb48cedf1aad3d61a9971f484e6b398..6c5afd5cdc5b6e8417b925659d71a69f546445f8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -129,10 +129,10 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文 | - | bgMode | [BackgroundMode](#BackgroundMode8+) | 是 | 向系统申请的后台模式 | + | context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | + | bgMode | [BackgroundMode](#backgroundmode8) | 是 | 向系统申请的后台模式。| | wantAgent | [WantAgent](js-apis-notification.md#WantAgent接口) | 是 | 通知参数,用于指定长时任务通知点击后跳转的界面。 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果。 | **示例**: ```js @@ -181,9 +181,9 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文 | - | bgMode | [BackgroundMode](#BackgroundMode8+) | 是 | 向系统申请的后台模式 | - | wantAgent | [WantAgent](js-apis-notification.md#WantAgent接口) | 是 | 通知参数,用于指定长时任务通知点击跳转的界面 | + | context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | + | bgMode | [BackgroundMode](#backgroundmode8) | 是 | 向系统申请的后台模式。 | + | wantAgent | [WantAgent](js-apis-notification.md#WantAgent接口) | 是 | 通知参数,用于指定长时任务通知点击跳转的界面。 | **返回值** | 类型 | 说明 | @@ -232,8 +232,8 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果 | + | context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果。 | **示例**: ```js @@ -265,7 +265,7 @@ stopBackgroundRunning(context: Context): Promise<void> **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文 | + | context | [Context](js-apis-Context.md) | 是 | 应用运行的上下文。 | **返回值** | 类型 | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-basic-features-pop-up.md b/zh-cn/application-dev/reference/apis/js-apis-basic-features-pop-up.md deleted file mode 100644 index ead1fbc6eefe3ab15987b788e64baaaaad602184..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-basic-features-pop-up.md +++ /dev/null @@ -1,133 +0,0 @@ -# 弹窗 - - -## 导入模块 - -``` -import prompt from '@system.prompt'; -``` - - -## 权限列表 - -无 - -## prompt.showToast - -showToast(Object): void - -显示文本弹窗。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | message | string | 是 | 显示的文本信息。 | - | duration | number | 否 | 默认值1500ms,建议区间:1500ms-10000ms。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 若小于1500ms则取默认值,最大取值为10000ms。 | - | $[bottom]^{5+}$ | <length> | 否 | 设置弹窗边框距离屏幕底部的位置。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅手机和平板设备支持。 | - -- 示例 - ``` - export default { - showToast() { - prompt.showToast({ - message: 'Message Info', - duration: 2000, - }); - } - } - ``` - - -## prompt.showDialog - -showDialog(): void - -在页面内显示对话框。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | title | string | 否 | 标题文本。 | - | message | string | 否 | 内容文本。 | - | buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 | - | success | Function | 否 | 接口调用成功的回调函数,返回值如success返回值所示。 | - | cancel | Function | 否 | 取消调用此接口的回调函数。 | - | complete | Function | 否 | 弹框退出时的回调函数。 | - - success返回值: - - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | index | number | 选中按钮在buttons数组中的索引。 | - -- 示例 - ``` - export default { - showDialog() { - prompt.showDialog({ - title: 'Title Info', - message: 'Message Info', - buttons: [ - { - text: 'button', - color: '#666666', - }, - ], - success: function(data) { - console.log('dialog success callback,click button : ' + data.index); - }, - cancel: function() { - console.log('dialog cancel callback'); - }, - }); - } - } - ``` - -## prompt.showActionMenu6+ - -showActionMenu(Object): void - -显示操作菜单。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | title | string | 否 | 标题文本。 | - | buttons | Array | 是 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | - | success | (data: TapIndex) => void | 否 | 接口调用成功的回调函数。 | - | cancel | () => void | 否 | 接口调用失败的回调函数。 | - | complete | () => void | 否 | 接口调用结束的回调函数。 | - - **表1** TapIndex - - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | tapIndex | number | 选中按钮在buttons数组中的索引,从0开始。 | - -- 示例 - ``` - export default { - showActionMenu() { - prompt.showActionMenu({ - title: 'Title Info', - buttons: [ - { - text: 'item1', - color: '#666666', - }, - { - text: 'item2', - color: '#000000', - }, - ], - success: function(data) { - console.log('dialog success callback,click button : ' + data.tapIndex); - }, - fail: function(data) { - console.log('dialog fail callback' + data.errMsg); - }, - }); - } - } - ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-basic-features-routes.md b/zh-cn/application-dev/reference/apis/js-apis-basic-features-routes.md deleted file mode 100644 index 42cc91031a704c0d758e01591a272f956ca25024..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-basic-features-routes.md +++ /dev/null @@ -1,291 +0,0 @@ -# 页面路由 - -> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** -> 页面路由需要在页面渲染完成之后才能调用,在onInit和onReady生命周期中页面还处于渲染阶段,禁止调用页面路由方法。 - - -## 导入模块 - -``` -import router from '@system.router'; -``` - -## 权限列表 - -无 - -## router.push - -push(Object): void - -跳转到应用内的指定页面。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | uri | string | 是 | 表示目标页面的uri,可以用以下两种格式:
- 页面绝对路径,由配置文件中pages列表提供,例如:
  - pages/index/index
  - pages/detail/detail
- 特殊值,如果uri的值是"/",则跳转到首页。 | - | params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | - -- 示例 - ``` - // 在当前页面中 - export default { - pushPage() { - router.push({ - uri: 'pages/routerpage2/routerpage2', - params: { - data1: 'message', - data2: { - data3: [123, 456, 789] - }, - }, - }); - } - } - ``` - - ``` - // 在routerpage2页面中 - export default { - data: { - data1: 'default', - data2: { - data3: [1, 2, 3] - } - }, - onInit() { - console.info('showData1:' + this.data1); - console.info('showData3:' + this.data2.data3); - } - } - ``` - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 页面路由栈支持的最大Page数量为32。 - - -## router.replace - -replace(Object): void - -用应用内的某个页面替换当前页面,并销毁被替换的页面。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | uri | string | 是 | 目标页面的uri,可以是以下的两种格式:
- 页面绝对路径,由配置文件中pages列表提供,例如:
  - pages/index/index
  - pages/detail/detail
- 特殊值,如果uri的值是"/",则跳转到首页。 | - | params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | - -- 示例 - ``` - // 在当前页面中 - export default { - replacePage() { - router.replace({ - uri: 'pages/detail/detail', - params: { - data1: 'message', - }, - }); - } - } - ``` - - ``` - // 在detail页面中 - export default { - data: { - data1: 'default' - }, - onInit() { - console.info('showData1:' + this.data1) - } - } - ``` - -## router.back - -back(Object): void - -返回上一页面或指定的页面。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | uri | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。 | - -- 示例 - ``` - // index页面 - export default { - indexPushPage() { - router.push({ - uri: 'pages/detail/detail', - }); - } - } - ``` - - ``` - // detail页面 - export default { - detailPushPage() { - router.push({ - uri: 'pages/mall/mall', - }); - } - } - ``` - - ``` - // mall页面通过back,将返回detail页面 - export default { - mallBackPage() { - router.back(); - } - } - ``` - - ``` - // detail页面通过back,将返回index页面 - export default { - defaultBack() { - router.back(); - } - } - ``` - - ``` - // 通过back,返回到detail页面 - export default { - backToDetail() { - router.back({uri:'pages/detail/detail'}); - } - } - ``` - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 示例中的uri字段是页面路由,由配置文件中的pages列表指定。 - -## router.clear - -clear(): void - -清空页面栈中的所有历史页面,仅保留当前页面作为栈顶页面。 - -- 示例 - ``` - export default { - clearPage() { - router.clear(); - } - } - ``` - -## router.getLength - -getLength(): string - -获取当前在页面栈内的页面数量。 - -- 返回值 - | 类型 | 说明 | - | -------- | -------- | - | string | 页面数量,页面栈支持最大数值是32。 | - -- 示例 - ``` - export default { - getLength() { - var size = router.getLength(); - console.log('pages stack size = ' + size); - } - } - ``` - -## router.getState - -getState(): <RouterState> - -获取当前页面的状态信息。 - -- 返回值 - **表1** RouterState - - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | index | number | 表示当前页面在页面栈中的索引。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 从栈底到栈顶,index从1开始递增。 | - | name | string | 表示当前页面的名称,即对应文件名。 | - | path | string | 表示当前页面的路径。 | - -- 示例 - ``` - export default { - getState() { - var page = router.getState(); - console.log('current index = ' + page.index); - console.log('current name = ' + page.name); - console.log('current path = ' + page.path); - } - } - ``` - -## router.enableAlertBeforeBackPage6+ - -enableAlertBeforeBackPage(Object): void - -开启页面返回询问对话框。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | message | string | 是 | 询问对话框内容。 | - | success | () => void | 否 | 接口调用成功的回调函数。 | - | fail | () => void | 否 | 接口调用失败的回调函数。 | - | complete | () => void | 否 | 接口调用结束的回调函数。 | - -- 示例 - ``` - export default { - enableAlertBeforeBackPage() { - router.enableAlertBeforeBackPage({ - message: 'Message Info', - success: function() { - console.log('success'); - }, - fail: function() { - console.log('fail'); - }, - }); - } - } - ``` - -## router.disableAlertBeforeBackPage6+ - -disableAlertBeforeBackPage(Object): void - -禁用页面返回询问对话框。 - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | success | () => void | 否 | 接口调用成功的回调函数。 | - | fail | () => void | 否 | 接口调用失败的回调函数。 | - | complete | () => void | 否 | 接口调用结束的回调函数。 | - -- 示例 - ``` - export default { - disableAlertBeforeBackPage() { - router.disableAlertBeforeBackPage({ - success: function() { - console.log('success'); - }, - fail: function() { - console.log('fail'); - }, - }); - } - } - ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md index a6e87bf74802a7ed846bad16ab22d0fe2a4f498d..07f05f2c4a91aeeeec49641c44982dfb9c2f18a4 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @@ -607,7 +607,7 @@ bluetooth.off('pinRequired', onReceiveEvent); ## bluetooth.on('bondStateChange')8+ -on(type: "bondStateChange", callback: Callback<BondState>): void +on(type: "bondStateChange", callback: Callback<BondStateParam>): void 订阅蓝牙配对状态改变事件。 @@ -620,7 +620,7 @@ on(type: "bondStateChange", callback: Callback<BondState>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 填写"bondStateChange"字符串,表示蓝牙配对状态改变事件。 | -| callback | Callback<[BondState](#bondstate)> | 是 | 表示回调函数的入参,配对的状态。回调函数由用户创建通过该接口注册。 | +| callback | Callback<[BondStateParam](#bondstate)> | 是 | 表示回调函数的入参,配对的状态。回调函数由用户创建通过该接口注册。 | **返回值:** @@ -638,7 +638,7 @@ bluetooth.on('bondStateChange', onReceiveEvent); ## bluetooth.off('bondStateChange')8+ -off(type: "bondStateChange", callback?: Callback<BondState>): void +off(type: "bondStateChange", callback?: Callback<BondStateParam>): void 取消订阅蓝牙配对状态改变事件。 @@ -651,7 +651,7 @@ off(type: "bondStateChange", callback?: Callback<BondState>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 填写"bondStateChange"字符串,表示蓝牙配对状态改变事件。 | -| callback | Callback<[BondState](#bondstate)> | 否 | 表示取消订阅蓝牙配对状态改变事件上报。不填该参数则取消订阅该type对应的所有回调。 | +| callback | Callback<[BondStateParam](#bondstate)> | 否 | 表示取消订阅蓝牙配对状态改变事件上报。不填该参数则取消订阅该type对应的所有回调。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-camera.md b/zh-cn/application-dev/reference/apis/js-apis-camera.md index 9df4fb1133a6cb211b2450e30a1494984e5e5bed..c5cb2ba389a8e0a4cbf6a5c0b86400387485af7d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-camera.md +++ b/zh-cn/application-dev/reference/apis/js-apis-camera.md @@ -313,7 +313,7 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => { ## Camera -相机实例。 +调用[camera.getCameraManager](#cameragetcameramanager)后,将返回Camera实例,包括相机ID、位置、类型、连接类型等相机相关的元数据。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 @@ -327,19 +327,21 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => { **示例:** ``` -var cameraManager = await camera.getCameraManager(); -var cameras = await cameraManager.getCameras(); -var cameraObj = cameras[0]; -var cameraId = cameraObj.cameraId; -var cameraPosition = cameraObj.cameraPosition; -var cameraType = cameraObj.cameraType; -var cameraId = cameraObj.connectionType; +async function getCameraInfo() { + var cameraManager = await camera.getCameraManager(); + var cameras = await cameraManager.getCameras(); + var cameraObj = cameras[0]; + var cameraId = cameraObj.cameraId; + var cameraPosition = cameraObj.cameraPosition; + var cameraType = cameraObj.cameraType; + var cameraId = cameraObj.connectionType; +} ``` ## CameraStatusInfo -相机状态信息。 +相机管理器回调返回的接口实例,表示相机状态信息。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Camera.Core。 @@ -565,7 +567,7 @@ setFlashMode(flashMode: FlashMode): Promise **示例:** ``` -cameraInput.setFlashMode(flashMode).then() => { +cameraInput.setFlashMode((flashMode).then() => { console.log('Promise returned with the successful execution of setFlashMode.'); }) ``` @@ -613,7 +615,7 @@ getFlashMode(): Promise **示例:** ``` -cameraInput.getFlashMode().then(flashMode) => { +cameraInput.getFlashMode().then((flashMode) => { console.log('Promise returned with current flash mode : ' + flashMode); }) ``` @@ -727,7 +729,7 @@ setFocusMode(afMode: FocusMode): Promise **示例:** ``` -cameraInput.setFocusMode(afMode).then() => { +cameraInput.setFocusMode(afMode).then(() => { console.log('Promise returned with the successful execution of setFocusMode.'); }) ``` @@ -775,7 +777,7 @@ getFocusMode(): Promise **示例:** ``` -cameraInput.getFocusMode().then(afMode) => { +cameraInput.getFocusMode().then((afMode) => { console.log('Promise returned with current focus mode : ' + afMode); }) ``` @@ -797,7 +799,7 @@ getZoomRatioRange\(callback: AsyncCallback\>\): void **示例:** ``` -cameraInput.getZoomRatioRange(err, zoomRatioRange) => { +cameraInput.getZoomRatioRange((err, zoomRatioRange) => { if (err) { console.error('Failed to get the zoom ratio range. ${err.message}'); return; @@ -878,7 +880,7 @@ setZoomRatio(zoomRatio: number): Promise **示例:** ``` -cameraInput.setZoomRatio(zoomRatio).then() => { +cameraInput.setZoomRatio(zoomRatio).then(() => { console.log('Promise returned with the successful execution of setZoomRatio.'); }) ``` @@ -926,7 +928,7 @@ getZoomRatio(): Promise **示例:** ``` -cameraInput.getZoomRatio().then(zoomRatio) => { +cameraInput.getZoomRatio().then((zoomRatio) => { console.log('Promise returned with current zoom ratio : ' + zoomRatio); }) ``` @@ -1004,7 +1006,7 @@ cameraInput.on('focusStateChange', (focusState) => { ### on('error') -on('error', callback: ErrorCallback): void +on(type: 'error', callback: ErrorCallback): void 监听CameraInput的错误事件,通过注册回调函数获取结果。 @@ -1082,7 +1084,7 @@ createCaptureSession\(context: Context, callback: AsyncCallback **示例:** ``` -camera.createCaptureSession(context), (err, captureSession) => { +camera.createCaptureSession((context), (err, captureSession) => { if (err) { console.error('Failed to create the CaptureSession instance. ${err.message}'); return; @@ -1852,7 +1854,7 @@ createPreviewOutput(surfaceId: string, callback: AsyncCallback): **示例:** ``` -camera.createPreviewOutput(surfaceId), (err, previewOutput) => { +camera.createPreviewOutput((surfaceId), (err, previewOutput) => { if (err) { console.error('Failed to create the PreviewOutput instance. ${err.message}'); return; @@ -2029,7 +2031,7 @@ createPhotoOutput(surfaceId: string, callback: AsyncCallback): voi **示例:** ``` -camera.createPhotoOutput(surfaceId), (err, photoOutput) => { +camera.createPhotoOutput((surfaceId), (err, photoOutput) => { if (err) { console.error('Failed to create the PhotoOutput instance. ${err.message}'); return; @@ -2078,6 +2080,8 @@ camera.createPhotoOutput(surfaceId).then((photoOutput) => { | ROTATION_180 | 180 | 图片旋转180度。 | | ROTATION_270 | 270 | 图片旋转270度。 | + + ## QualityLevel 枚举,图片质量。 @@ -2350,7 +2354,7 @@ createVideoOutput(surfaceId: string, callback: AsyncCallback): voi **示例:** ``` -camera.createVideoOutput(surfaceId), (err, videoOutput) => { +camera.createVideoOutput((surfaceId), (err, videoOutput) => { if (err) { console.error('Failed to create the VideoOutput instance. ${err.message}'); return; diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md index 809e2c9f81e162c1616f5d3cc55e9be5a6ec8a23..f59f52a9029a27d23eadc8b05a7d6a4beecf61d0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @@ -468,7 +468,7 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ---------- | -------- | --------------------- | ---- | ------------------------ | | subscriber | 只读 | CommonEventSubscriber | 是 | 表示订阅者对象。 | -| callback | 只读 | AsyncCallback\ | 是 | 表示取消订阅的回调方法。 | +| callback | 只读 | AsyncCallback\ | 否 | 表示取消订阅的回调方法。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEventSubscriber.md b/zh-cn/application-dev/reference/apis/js-apis-commonEventSubscriber.md index 3a551aa5ecbe01b8a00a3897bc559b2fdccbba95..f2e9d685920e39137a7e3bcf3a9bc30b9beca8f0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEventSubscriber.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEventSubscriber.md @@ -25,7 +25,6 @@ getCode(callback: AsyncCallback\): void var subscriber; //创建成功的订阅者对象 //设置有序公共事件的结果数据回调 -getCode() { function getCodeCallback(err, Code) { if (err.code) { console.error("getCode failed " + JSON.stringify(err)); @@ -337,7 +336,7 @@ isOrderedCommonEvent(): Promise\ | 类型 | 说明 | | ----------------- | -------------------------------- | -| Promise\ | 当前公共事件的是否为有序公共事件 | +| Promise\ | 当前公共事件的是否为有序公共事件。 | **示例:** @@ -351,6 +350,66 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => { }); ``` +### isStickyCommonEvent + +isStickyCommonEvent(callback: AsyncCallback\): void + +检查当前公共事件是否为一个粘性事件(callback形式)。 + +返回true代表是粘性公共事件,false代表不是粘性公共事件。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | ----------------------- | ---- | ---------------------------------- | +| callback | AsyncCallback\ | 是 | 当前公共事件的是否为粘性公共事件。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function isStickyCallback(err, isSticky) { + if (err.code) { + console.error("isStickyCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("isSticky " + JSON.stringify(isSticky)); + } +} +subscriber.isStickyCommonEvent(isStickyCallback); +``` + +### isStickyCommonEvent + +isStickyCommonEvent(): Promise\ + +检查当前公共事件是否为一个粘性事件(callback形式)。 + +返回true代表是粘性公共事件,false代表不是粘性公共事件。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**返回值:** + +| 类型 | 说明 | +| ----------------- | -------------------------------- | +| Promise\ | 当前公共事件的是否为粘性公共事件。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +subscriber.isStickyCommonEvent().then((isSticky) => { + console.info("isSticky " + JSON.stringify(isSticky)); +}).catch((err) => { + console.error("isSticky failed " + JSON.stringify(err)); +}); +``` + ### abortCommonEvent abortCommonEvent(callback: AsyncCallback\): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md b/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md index 9af37d0aad2f4f402b2d96616c11620a34411cde..90d4d1451fc7ab04c32a0fa65c183d65a43443f1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md +++ b/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md @@ -22,7 +22,7 @@ import ConfigurationConstant from '@ohos.application.ConfigurationConstant'; **示例:** ``` -ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT。 +ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ``` **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase @@ -41,7 +41,7 @@ ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT。 **示例:** ``` -ConfigurationConstant.Direction.DIRECTION_VERTICAL。 +ConfigurationConstant.Direction.DIRECTION_VERTICAL ``` **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase @@ -60,7 +60,7 @@ ConfigurationConstant.Direction.DIRECTION_VERTICAL。 **示例:** ``` -ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_NOT_SET。 +ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_NOT_SET ``` **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase diff --git a/zh-cn/application-dev/reference/apis/js-apis-contact.md b/zh-cn/application-dev/reference/apis/js-apis-contact.md index 48edd1e36de5a4fec25f03a878538979e85d1321..b38bb1077c0231f30df4ee19415a706e85fd5654 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-contact.md +++ b/zh-cn/application-dev/reference/apis/js-apis-contact.md @@ -461,7 +461,7 @@ queryMyCard(attrs?: ContactAttributes): Promise<Contact> ## contact.selectContact -selectContact(AsyncCallback<Array<Contact>>): void +selectContact(callback: AsyncCallback<Array<Contact>>): void 选择联系人,使用callback方式作为异步方法。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md b/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md index ca56d4628427510f2e023bfac5c8d1b63928d09e..da4dd52df2b344f09cb78c7e1422354b5474d4e0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md @@ -17,16 +17,21 @@ import distributedObject from '@ohos.data.distributedDataObject' createDistributedObject(source: object): DistributedObject -创建一个分布式对象distributedObject,用户可以通过source指定分布式对象中的属性,属性支持基本类型以及复杂类型,返回值是创建好的分布式对象。 +创建一个分布式对象。 **系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | object | source | 是 | 设置distributedObject的属性。 | + | source | object | 是 | 设置distributedObject的属性。 | -- 示例: +**返回值:** + | 类型 | 说明 | + | -------- | -------- | + | [DistributedObject](#distributedobject) | 创建好的分布式对象。 | + +**示例:** ```js import distributedObject from '@ohos.data.distributedDataObject' // 创建对象,对象包含4个属性类型,string,number,boolean和Object @@ -39,16 +44,16 @@ createDistributedObject(source: object): DistributedObject genSessionId(): string -随机创建一个sessionId,返回值是随机创建的sessionId。 +随机创建一个sessionId。 **系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 -- 返回值: +**返回值:** | 类型 | 说明 | | -------- | -------- | | string | 随机创建的sessionId。 | -- 示例: +**示例:** ```js import distributedObject from '@ohos.data.distributedDataObject' var sessionId = distributedObject.genSessionId(); @@ -62,16 +67,21 @@ genSessionId(): string setSessionId(sessionId?: string): boolean -设置同步的sessionId,当可信组网中有多个设备时,多个设备间的对象如果设置为同一个sessionId,就能自动同步。sessionId是指定的sessionId,如果要退出分布式组网,设置为""或不设置均可。结果以boolean形式返回,true标识设置sessionId成功 +设置同步的sessionId,当可信组网中有多个设备时,多个设备间的对象如果设置为同一个sessionId,就能自动同步。 **系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | sessionId | string | 否 | 分布式对象在可信组网中的标识ID。 | + | sessionId | string | 否 | 分布式对象在可信组网中的标识ID。如果要退出分布式组网,设置为""或不设置均可。 | + +**返回值:** + | 类型 | 说明 | + | -------- | -------- | + | boolean | true:标识设置sessionId成功;
false:标识设置sessionId失败。 | -- 示例: +**示例:** ```js import distributedObject from '@ohos.data.distributedDataObject' var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, @@ -87,17 +97,17 @@ setSessionId(sessionId?: string): boolean on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void -监听分布式对象的变更,type需固定为'change',callback是变更时触发的回调,回调参数sessionId标识变更对象的sessionId,fields标识对象变更的属性名 +监听分布式对象的变更。 **系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 事件类型,固定为'change',表示数据变更。 | - | callback | Callback<{ sessionId: string, fields: Array<string> }> | 是 | 变更回调对象实例。 | + | callback | Callback<{ sessionId: string, fields: Array<string> }> | 是 | 变更回调对象实例。
sessionId:标识变更对象的sessionId;
fields:标识对象变更的属性名。 | -- 示例: +**示例:** ```js import distributedObject from '@ohos.data.distributedDataObject' var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, @@ -116,18 +126,18 @@ on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<stri off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void -当不再进行数据变更监听时,使用此接口删除对象的变更监听,type固定为'change',callback为可选参数,若不设置则表示删除该对象所有的变更监听 +当不再进行数据变更监听时,使用此接口删除对象的变更监听。 **系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 事件类型,固定为'change',表示数据变更。 | - | callback | Callback<{ sessionId: string, fields: Array<string> }> | 否 | 需要删除的变更回调,若不设置则删除该对象所有的变更回调。 | + | callback | Callback<{ sessionId: string, fields: Array<string> }> | 否 | 需要删除的变更回调,若不设置则删除该对象所有的变更回调。
sessionId:标识变更对象的sessionId;
fields:标识对象变更的属性名。 | -- 示例: +**示例:** ```js import distributedObject from '@ohos.data.distributedDataObject' var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, @@ -147,17 +157,19 @@ off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<st on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' | 'offline' }>): void -监听分布式对象的上下线,type需固定为'status',callback是分布式对象上下线时触发的回调,回调参数sessionId标识变更对象的sessionId,networkId标识对象设备的networkId,status标识对象为'online'(上线)或'offline'(下线)的状态 +监听分布式对象的上下线。 **系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 事件类型,固定为'status',表示对象上下线。 | - | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | 是 | 监听上下线回调实例。 | + | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | 是 | 监听上下线回调实例。
sessionId:标识变更对象的sessionId;
networkId:标识对象设备的networkId;
status:标识对象为'online'(上线)或'offline'(下线)的状态。 | + + -- 示例: +**示例:** ```js import distributedObject from '@ohos.data.distributedDataObject' var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, @@ -172,18 +184,18 @@ on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, st off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' | 'offline' }>): void -当不再进行对象上下线监听时,使用此接口删除对象的上下线监听,type固定为'status',callback为可选参数,若不设置则表示删除该对象所有的上下线监听 +当不再进行对象上下线监听时,使用此接口删除对象的上下线监听。 **系统能力**:SystemCapability.DistributedDataManager.DataObject.DistributedObject。 -- 参数: +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 事件类型,固定为'status',表示对象上下线。 | - | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | 否 | 需要删除的上下线回调,若不设置则删除该对象所有的上下线回调。 | + | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | 否 | 需要删除的上下线回调,若不设置则删除该对象所有的上下线回调。
sessionId:标识变更对象的sessionId;
deviceId:标识变更对象的deviceId;
status:标识对象为'online'(上线)或'offline'(下线)的状态。 | -- 示例: +**示例:** ```js import distributedObject from '@ohos.data.distributedDataObject' g_object.on("status", function (sessionId, networkId, status) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md index 5fc7302b31b47f2858c45e110147c770b1639dd1..00b162f508af3b8e1cf989a7130ea9474ab0af65 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md @@ -20,27 +20,40 @@ getRdbStore(context?: Context, config: StoreConfig, version: number, callback: A **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | context8+ | Context | 否 | 应用程序或功能的上下文 | - | config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | - | version | number | 是 | 数据库版本。 | - | callback | AsyncCallback<[RdbStore](#rdbstore)> | 是 | 指定callback回调函数。返回一个RdbStore。 | +**参数**: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| context8+ | Context | 否 | 应用程序或功能的上下文 | +| config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | +| version | number | 是 | 数据库版本。 | +| callback | AsyncCallback<[RdbStore](#rdbstore)> | 是 | 指定callback回调函数。返回一个RdbStore。 | -- 示例: - ``` - import Ability from '@ohos.application.Ability' - import data_rdb from '@ohos.data.rdb' - export default class MainAbility extends Ability { - const STORE_CONFIG = { name: "RdbTest.db"} - const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" - data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE) - console.info('create table done.') - }) - } - ``` +**示例**: + +``` +import data_rdb from '@ohos.data.rdb' +const STORE_CONFIG = { name: "RdbTest.db"} +const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" +data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) { + rdbStore.executeSql(SQL_CREATE_TABLE) + console.info('create table done.') +}) +``` + +API9的示例请参考如下代码: + +``` +import Ability from '@ohos.application.Ability' +import data_rdb from '@ohos.data.rdb' +export default class MainAbility extends Ability { + const STORE_CONFIG = { name: "RdbTest.db"} + const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" + data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { + rdbStore.executeSql(SQL_CREATE_TABLE) + console.info('create table done.') + }) +} +``` ## data_rdb.getRdbStore @@ -50,38 +63,60 @@ getRdbStore(context?: Context, config: StoreConfig, version: number): Promise< **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | context8+ | Context | 否 | 应用程序或功能的上下文 | - | config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | - | version | number | 是 | 数据库版本。 | +**参数**: -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<[RdbStore](#rdbstore)> | 指定Promise回调函数。返回一个RdbStore。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| context8+ | Context | 否 | 应用程序或功能的上下文 | +| config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 | +| version | number | 是 | 数据库版本。 | -- 示例: - ``` - import Ability from '@ohos.application.Ability' - import data_rdb from '@ohos.data.rdb' - export default class MainAbility extends Ability { - const STORE_CONFIG = { name: "RdbTest.db" } - const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" - let promisegetRdb = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1); - promisegetRdb.then(async (rdbStore) => { - let promiseExecSql = rdbStore.executeSql(SQL_CREATE_TABLE, null) - promiseExecSql.then(() => { - console.info('executeSql creat done.') - }).catch((err) => { - console.log("executeSql creat err.") - }) - }).catch((err) => { - console.log("getRdbStore err.") - }) - } - ``` +**返回值**: + +| 类型 | 说明 | +| -------- | -------- | +| Promise<[RdbStore](#rdbstore)> | 指定Promise回调函数。返回一个RdbStore。 | + +**示例**: + +``` +import data_rdb from '@ohos.data.rdb' +const STORE_CONFIG = { name: "RdbTest.db" } +const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" +let promisegetRdb = data_rdb.getRdbStore(STORE_CONFIG, 1); +promisegetRdb.then(async (rdbStore) => { + let promiseExecSql = rdbStore.executeSql(SQL_CREATE_TABLE, null) + promiseExecSql.then(() => { + console.info('executeSql creat done.') + }).catch((err) => { + console.log("executeSql creat err.") + }) +}).catch((err) => { + console.log("getRdbStore err.") +}) +``` + +API9的示例请参考如下代码: + +``` +import Ability from '@ohos.application.Ability' +import data_rdb from '@ohos.data.rdb' +export default class MainAbility extends Ability { + const STORE_CONFIG = { name: "RdbTest.db" } + const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" + let promisegetRdb = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1); + promisegetRdb.then(async (rdbStore) => { + let promiseExecSql = rdbStore.executeSql(SQL_CREATE_TABLE, null) + promiseExecSql.then(() => { + console.info('executeSql creat done.') + }).catch((err) => { + console.log("executeSql creat err.") + }) + }).catch((err) => { + console.log("getRdbStore err.") + }) +} +``` ## data_rdb.deleteRdbStore @@ -91,24 +126,33 @@ deleteRdbStore(context?: Context, name: string, callback: AsyncCallback<void& **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | context8+ | Context | 否 | 应用程序或功能的上下文 | | name | string | 是 | 数据库名称。 | | callback | AsyncCallback<void> | 是 | 指定callback回调函数。如果数据库已删除,则为true;否则返回false。 | -- 示例: +**示例**: ``` - import Ability from '@ohos.application.Ability' import data_rdb from '@ohos.data.rdb' - export default class MainAbility extends Ability { - data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { - console.info('delete store done.') - }) - } + data_rdb.deleteRdbStore("RdbTest.db", function (err, rdbStore) { + console.info('delete store done.') + }) ``` +API9的示例请参考如下代码: + +``` +import Ability from '@ohos.application.Ability' +import data_rdb from '@ohos.data.rdb' +export default class MainAbility extends Ability { + data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { + console.info('delete store done.') + }) +} +``` + ## data_rdb.deleteRdbStore deleteRdbStore(context?: Context, name: string): Promise<void> @@ -117,31 +161,43 @@ deleteRdbStore(context?: Context, name: string): Promise<void> **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | context8+ | Context | 否 | 应用程序或功能的上下文 | | name | string | 是 | 数据库名称。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<void> | 指定Promise回调函数。如果数据库已删除,则为true;否则返回false。 | -- 示例: +**示例**: ``` - import Ability from '@ohos.application.Ability' import data_rdb from '@ohos.data.rdb' - export default class MainAbility extends Ability { - let promisedeleteRdb = data_rdb.deleteRdbStore(this.context, "RdbTest.db") - promisedeleteRdb.then(()=>{ - console.info('delete store done.') - }).catch((err) => { - console.log("deleteRdbStore err.") - }) - } + let promisedeleteRdb = data_rdb.deleteRdbStore("RdbTest.db") + promisedeleteRdb.then(()=>{ + console.info('delete store done.') + }).catch((err) => { + console.log("deleteRdbStore err.") + }) ``` +API9的示例请参考如下代码: + +``` +import Ability from '@ohos.application.Ability' +import data_rdb from '@ohos.data.rdb' +export default class MainAbility extends Ability { + let promisedeleteRdb = data_rdb.deleteRdbStore(this.context, "RdbTest.db") + promisedeleteRdb.then(()=>{ + console.info('delete store done.') + }).catch((err) => { + console.log("deleteRdbStore err.") + }) +} +``` + ## RdbPredicates 表示关系型数据库(RDB)的谓词。该类确定RDB中条件表达式的值是true还是false。 @@ -156,12 +212,12 @@ constructor(name: string) **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 数据库表名。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") ``` @@ -175,17 +231,17 @@ inDevices(devices: Array<string>): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | devices | Array<string> | 是 | 指定的组网内的远程设备ID。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicate.inDevices(['12345678abcde']) @@ -200,12 +256,12 @@ inAllDevices(): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.inAllDevices() @@ -220,18 +276,18 @@ equalTo(field: string, value: ValueType): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | [ValueType](#valuetype) | 是 | 指示要与谓词匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "lisi") @@ -247,18 +303,18 @@ notEqualTo(field: string, value: ValueType): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | [ValueType](#valuetype) | 是 | 指示要与谓词匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.notEqualTo("NAME", "lisi") @@ -274,12 +330,12 @@ beginWrap(): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回带有左括号的Rdb谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "lisi") @@ -300,12 +356,12 @@ endWrap(): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回带有右括号的Rdb谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "lisi") @@ -326,12 +382,12 @@ or(): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回带有或条件的Rdb谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Lisa") @@ -349,12 +405,12 @@ and(): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回带有和条件的Rdb谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Lisa") @@ -371,18 +427,18 @@ contains(field: string, value: string): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | string | 是 | 指示要与谓词匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.contains("NAME", "os") @@ -398,18 +454,18 @@ beginsWith(field: string, value: string): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | string | 是 | 指示要与谓词匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.beginsWith("NAME", "os") @@ -425,18 +481,18 @@ endsWith(field: string, value: string): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | string | 是 | 指示要与谓词匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.endsWith("NAME", "se") @@ -452,12 +508,12 @@ isNull(field: string): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | @@ -478,17 +534,17 @@ isNotNull(field: string): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.isNotNull("NAME") @@ -504,18 +560,18 @@ like(field: string, value: string): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | string | 是 | 指示要与谓词匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.like("NAME", "%os%") @@ -531,18 +587,18 @@ glob(field: string, value: string): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | string | 是 | 指示要与谓词匹配的值。
支持通配符,*表示0个、1个或多个数字或字符,?表示1个数字或字符。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.glob("NAME", "?h*g") @@ -558,19 +614,19 @@ between(field: string, low: ValueType, high: ValueType): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | low | [ValueType](#valuetype) | 是 | 指示与谓词匹配的最小值。 | | high | [ValueType](#valuetype) | 是 | 指示要与谓词匹配的最大值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.between("AGE", 10, 50) @@ -586,19 +642,19 @@ notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | low | [ValueType](#valuetype) | 是 | 指示与谓词匹配的最小值。 | | high | [ValueType](#valuetype) | 是 | 指示要与谓词匹配的最大值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.notBetween("AGE", 10, 50) @@ -613,18 +669,18 @@ greaterThan(field: string, value: ValueType): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | [ValueType](#valuetype) | 是 | 指示要与谓词匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.greaterThan("AGE", 18) @@ -640,18 +696,18 @@ lessThan(field: string, value: ValueType): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | [ValueType](#valuetype) | 是 | 指示要与谓词匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.lessThan("AGE", 20) @@ -668,18 +724,18 @@ greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | [ValueType](#valuetype) | 是 | 指示要与谓词匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.greaterThanOrEqualTo("AGE", 18) @@ -696,18 +752,18 @@ lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | [ValueType](#valuetype) | 是 | 指示要与谓词匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.lessThanOrEqualTo("AGE", 20) @@ -724,17 +780,17 @@ orderByAsc(field: string): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.orderByAsc("NAME") @@ -751,17 +807,17 @@ orderByDesc(field: string): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.orderByDesc("AGE") @@ -777,12 +833,12 @@ distinct(): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回可用于过滤重复记录的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").distinct("NAME") @@ -805,17 +861,17 @@ limitAs(value: number): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | value | number | 是 | 最大数据记录数。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回可用于设置最大数据记录数的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").limitAs(3) @@ -831,17 +887,17 @@ offsetAs(rowOffset: number): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | rowOffset | number | 是 | 返回结果的起始位置,取值为正整数。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回具有指定返回结果起始位置的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").offsetAs(3) @@ -857,17 +913,17 @@ groupBy(fields: Array<string>): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | fields | Array<string> | 是 | 指定分组依赖的列名。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回分组查询列的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.groupBy(["AGE", "NAME"]) @@ -882,17 +938,17 @@ indexedBy(indexName: string): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | indexName | string | 是 | 索引列的名称。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回具有指定索引列的RdbPredicates。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.indexedBy("SALARY_INDEX") @@ -908,19 +964,19 @@ in(field: string, value: Array<ValueType>): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | Array<[ValueType](#valuetype)> | 是 | 以ValueType型数组形式指定的要匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.in("AGE", [18, 20]) @@ -936,19 +992,19 @@ notIn(field: string, value: Array<ValueType>): RdbPredicates **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | field | string | 是 | 数据库表中的列名。 | | value | Array<[ValueType](#valuetype)> | 是 | 以ValueType数组形式指定的要匹配的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | [RdbPredicates](#rdbpredicates) | 返回与指定字段匹配的谓词。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.notIn("NAME", ["Lisa", "Rose"]) @@ -968,14 +1024,14 @@ insert(name: string, values: ValuesBucket, callback: AsyncCallback<number> **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 指定的目标表名。 | | values | [ValuesBucket](#valuesbucket) | 是 | 表示要插入到表中的数据行。 | | callback | AsyncCallback<number> | 是 | 指定callback回调函数。如果操作成功,返回行ID;否则返回-1。 | -- 示例: +**示例**: ``` const valueBucket = { "NAME": "Lisa", @@ -997,18 +1053,18 @@ insert(name: string, values: ValuesBucket):Promise<number> **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 指定的目标表名。 | | values | [ValuesBucket](#valuesbucket) | 是 | 表示要插入到表中的数据行。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<number> | 指定Promise回调函数。如果操作成功,返回行ID;否则返回-1。 | -- 示例: +**示例**: ``` const valueBucket = { "NAME": "Lisa", @@ -1033,14 +1089,14 @@ update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallba **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | values | [ValuesBucket](#valuesbucket) | 是 | value指示数据库中要更新的数据行。键值对与数据库表的列名相关联 | | rdbPredicates | [RdbPredicates](#rdbpredicates) | 是 | 表示要插入到表中的数据行。 | | callback | AsyncCallback<number> | 是 | 指定的callback回调方法。返回受影响的行数。 | -- 示例: +**示例**: ``` const valueBucket = { "NAME": "Rose", @@ -1063,18 +1119,18 @@ update(values: ValuesBucket, rdbPredicates: RdbPredicates):Promise<number> **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | values | [ValuesBucket](#valuesbucket) | 是 | value指示数据库中要更新的数据行。键值对与数据库表的列名相关联 | | rdbPredicates | [RdbPredicates](#rdbpredicates) | 是 | 表示要插入到表中的数据行。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<number> | 指定的Promise回调方法。返回受影响的行数。 | -- 示例: +**示例**: ``` const valueBucket = { "NAME": "Rose", @@ -1102,13 +1158,13 @@ delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | rdbPredicates | [RdbPredicates](#rdbpredicates) | 是 | RdbPredicates的实例对象指定的删除条件。 | | callback | AsyncCallback<number> | 是 | 指定callback回调函数。返回受影响的行数。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Lisa") @@ -1126,17 +1182,17 @@ delete(rdbPredicates: RdbPredicates):Promise<number> **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | rdbPredicates | [RdbPredicates](#rdbpredicates) | 是 | RdbPredicates的实例对象指定的删除条件。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<number> | 指定Promise回调函数。返回受影响的行数。 | -- 示例: +**示例**: ``` let predicatesdelete = new data_rdb.RdbPredicates("EMPLOYEE") predicatesdelete.equalTo("NAME", "Lisa") @@ -1157,14 +1213,14 @@ query(rdbPredicates: RdbPredicates, columns: Array<string>, callback: Asyn **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | rdbPredicates | [RdbPredicates](#rdbpredicates) | 是 | 表示rdbPredicates的实例对象指定的查询条件。 | | columns | Array<string> | 是 | 表示要查询的列。如果值为空,则查询应用于所有列。 | | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | 是 | 指定callback回调函数。如果操作成功,则返回ResultSet对象。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose") @@ -1183,18 +1239,18 @@ query(rdbPredicates: RdbPredicates, columns?: Array<string>):Promise<Re **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | rdbPredicates | [RdbPredicates](#rdbpredicates) | 是 | 表示rdbPredicates的实例对象指定的查询条件。 | | columns | Array<string> | 否 | 表示要查询的列。如果值为空,则查询应用于所有列。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<[ResultSet](../apis/js-apis-data-resultset.md)> | 指定Promise回调函数。如果操作成功,则返回ResultSet对象。 | -- 示例: +**示例**: ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose") @@ -1216,14 +1272,14 @@ querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback& **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | sql | string | 是 | 指定要执行的SQL语句。 | | bindArgs | Array<[ValueType](#valuetype)> | 是 | SQL语句中参数的值。 | | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | 是 | 指定callback回调函数。如果操作成功,则返回ResultSet对象。 | -- 示例: +**示例**: ``` rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) { console.log("resultSet column names:" + resultSet.columnNames) @@ -1240,18 +1296,18 @@ querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet> **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | sql | string | 是 | 指定要执行的SQL语句。 | | bindArgs | Array<[ValueType](#valuetype)> | 否 | SQL语句中参数的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<[ResultSet](../apis/js-apis-data-resultset.md)> | 指定Promise回调函数。如果操作成功,则返回ResultSet对象。 | -- 示例: +**示例**: ``` let promisequerySql = rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo']) promisequerySql.then((resultSet) => { @@ -1271,14 +1327,14 @@ executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallbac **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | sql | string | 是 | 指定要执行的SQL语句。 | | bindArgs | Array<[ValueType](#valuetype)> | 是 | SQL语句中参数的值。 | | callback | AsyncCallback<void> | 是 | 指定callback回调函数。 | -- 示例: +**示例**: ``` rdbStore.executeSql("DELETE FROM EMPLOYEE", null, function () { console.info('delete done.') @@ -1294,18 +1350,18 @@ executeSql(sql: string, bindArgs?: Array<ValueType>):Promise<void> **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | sql | string | 是 | 指定要执行的SQL语句。 | | bindArgs | Array<[ValueType](#valuetype)> | 否 | SQL语句中参数的值。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<void> | 指定Promise回调函数。 | -- 示例: +**示例**: ``` let promiseexecuteSql = rdbStore.executeSql("DELETE FROM EMPLOYEE") promiseexecuteSql.then(() => { @@ -1323,7 +1379,7 @@ beginTransaction():void **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 示例: +**示例**: ``` rdbStore.beginTransaction() const valueBucket = { @@ -1347,7 +1403,7 @@ commit():void **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 示例: +**示例**: ``` rdbStore.beginTransaction() const valueBucket = { @@ -1372,7 +1428,7 @@ rollBack():void; **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 示例: +**示例**: ``` try { rdbStore.beginTransaction() @@ -1401,13 +1457,13 @@ setDistributedTables(tables: Array<string>, callback: AsyncCallback<voi **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | tables | Array<string> | 是 | 要设置的分布式列表表名 | | callback | AsyncCallback<void> | 是 | 指定callback回调函数。 | -- 示例: +**示例**: ``` rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { if (err) { @@ -1427,17 +1483,17 @@ setDistributedTables(tables: Array<string>, callback: AsyncCallback<voi **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | tables | Array<string> | 是 | 要设置的分布式列表表名。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<void> | 指定Promise回调函数。 | -- 示例: +**示例**: ``` let promiseset = rdbStore.setDistributedTables(["EMPLOYEE"]) promiseset.then(() => { @@ -1455,14 +1511,14 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | device | string | 是 | 远程设备 。| | table | string | 是 | 本地表名。 | | callback | AsyncCallback<string> | 是 | 指定的callback回调函数。如果操作成功,返回远程设备的分布式表名。 | -- 示例: +**示例**: ``` rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { if (err) { @@ -1482,18 +1538,18 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | device | string | 是 | 远程设备。 | | table | string | 是 | 本地表名。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<string> | 指定Promise回调函数。如果操作成功,返回远程设备的分布式表名。 | -- 示例: +**示例**: ``` let promiseDistr = rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE") promiseDistr.then((tableName) => { @@ -1511,14 +1567,14 @@ sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | mode | SyncMode | 是 | 指同步模式。该值可以是推、拉。 | | predicates | RdbPredicates | 是 | 约束同步数据和设备。 | | callback | AsyncCallback<Array<[string, number]>> | 是 | 指定的callback回调函数,用于向调用者发送同步结果。string:设备ID;number:每个设备同步状态,0表示成功,其他值表示失败。| -- 示例: +**示例**: ``` let predicate = new rdb.RdbPredicates('EMPLOYEE') predicate.inDevices(['12345678abcde']) @@ -1543,18 +1599,18 @@ sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | mode | SyncMode | 是 | 指同步模式。该值可以是推、拉。 | | predicates | RdbPredicates | 是 | 约束同步数据和设备。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<Array<[string, number]>> | 指定Promise回调函数,用于向调用者发送同步结果。string:设备ID;number:每个设备同步状态,0表示成功,其他值表示失败。 | -- 示例: +**示例**: ``` let predicatesync = new rdb.RdbPredicates('EMPLOYEE') predicatesync.inDevices(['12345678abcde']) @@ -1577,13 +1633,13 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | SubscribeType | 是 | 指在{@code SubscribeType}中定义的订阅类型。 | | observer | Callback<Array<string>> | 是 | 指分布式数据库中数据更改事件的观察者。 | -- 示例: +**示例**: ``` function storeObserver(devices) { for (let i = 0; i < devices.length; i++) { @@ -1605,13 +1661,13 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri **系统能力**:SystemCapability.DistributedDataManager.RelationalStore.Core。 -- 参数: +**参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | SubscribeType | 是 | 指在{@code SubscribeType}中定义的订阅类型。 | | observer | Callback<Array<string>> | 是 | 指已注册的数据更改观察者。| -- 示例: +**示例**: ``` function storeObserver(devices) { for (let i = 0; i < devices.length; i++) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md index 04b1695912e16df298266993d9be52bc239bc008..f39822ce4d2108c30849bfe2047780541b293aef 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md @@ -47,10 +47,16 @@ getStorageSync(path: string): Storage import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext() - var path = await context.getFilesDir() - let storage = dataStorage.getStorageSync(path + '/mystore') - storage.putSync('startup', 'auto') - storage.flushSync() + context.getFilesDir((err, path) => { + if (err) { + console.error('getFilesDir failed. err: ' + JSON.stringify(err)); + return; + } + console.info('getFilesDir successful. path:' + JSON.stringify(path)); + let storage = dataStorage.getStorageSync(path + '/mystore') + storage.putSync('startup', 'auto') + storage.flushSync() + }); ``` @@ -74,15 +80,21 @@ getStorage(path: string, callback: AsyncCallback<Storage>): void import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext() - var path = await context.getFilesDir() - dataStorage.getStorage(path + '/mystore', function (err, storage) { + context.getFilesDir((err, path) => { if (err) { - console.info("Get the storage failed, path: " + path + '/mystore') + console.error('getFilesDir failed. err: ' + JSON.stringify(err)); return; } - storage.putSync('startup', 'auto') - storage.flushSync() - }) + console.info('getFilesDir successful. path:' + JSON.stringify(path)); + dataStorage.getStorage(path + '/mystore', function (err, storage) { + if (err) { + console.info("Get the storage failed, path: " + path + '/mystore') + return; + } + storage.putSync('startup', 'auto') + storage.flushSync() + }) + }); ``` @@ -110,14 +122,20 @@ getStorage(path: string): Promise<Storage> import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext() - var path = await context.getFilesDir() - let promisegetSt = dataStorage.getStorage(path + '/mystore') - promisegetSt.then((storage) => { - storage.putSync('startup', 'auto') - storage.flushSync() - }).catch((err) => { - console.info("Get the storage failed, path: " + path + '/mystore') - }) + context.getFilesDir((err, path) => { + if (err) { + console.info("Get the storage failed, path: " + path + '/mystore') + return; + } + console.info('getFilesDir successful. path:' + JSON.stringify(path)); + let promisegetSt = dataStorage.getStorage(path + '/mystore') + promisegetSt.then((storage) => { + storage.putSync('startup', 'auto') + storage.flushSync() + }).catch((err) => { + console.info("Get the storage failed, path: " + path + '/mystore') + }) + }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-deque.md b/zh-cn/application-dev/reference/apis/js-apis-deque.md index 7ad3b930f97b8503ac886f41e4c08cba42b9c759..9d51cccda6d334f75258076f387ace1403cce6f5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-deque.md +++ b/zh-cn/application-dev/reference/apis/js-apis-deque.md @@ -158,6 +158,7 @@ let result = deque.popLast(); ``` ### forEach + forEach(callbackfn: (value: T, index?: number, deque?: Deque<T>) => void, thisArg?: Object): void @@ -193,7 +194,7 @@ deque.forEach((value, index) => { ### getFirst -getFirst(): T; +getFirst(): T 获取Deque实例中的头元素。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md index eaac2ca81999080311d5761cfe12ab3653f21ecf..f63f84c4df44be1f5cba595b76c257f8e66b4156 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md @@ -16,6 +16,9 @@ import deviceManager from '@ohos.distributedHardware.deviceManager'; createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager>): void 创建一个设备管理器实例。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -39,6 +42,8 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager 表示设备状态变化的枚举。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | | ONLINE | 0 | 设备上线。 | @@ -51,6 +56,8 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager 表示设备类型的枚举类。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | | SPEAKER | 0x0A | 智能音箱 | @@ -58,12 +65,16 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager | TABLET | 0x11 | 平板 | | WEARABLE | 0x6D | 智能穿戴 | | TV | 0x9C | 智慧屏 | +| CAR | 0x83 | 车 | +| UNKNOWN_TYPE | 0 | 未知设备 | ## DeviceInfo 设备信息。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.DistributedHardware.DeviceManager + | 名称 | 类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | | deviceId | number | 是 | 设备的唯一标识。 | @@ -82,6 +93,8 @@ release(): void 设备管理实例不再使用后,通过该方法释放DeviceManager实例。 +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + - 示例: ``` dmInstance.release(); @@ -94,6 +107,8 @@ getTrustedDeviceListSync(): Array<DeviceInfo> 同步获取所有可信设备列表。 +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + - 返回值: | 名称 | 说明 | | -------- | -------- | @@ -111,6 +126,8 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange 注册设备状态回调。 +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + - 参数: | 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -132,6 +149,8 @@ off(type: 'deviceStateChange', callback?: Call back<{ action: DeviceStateChan 取消注册设备状态回调。 +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + - 参数: | 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -153,6 +172,8 @@ on(type: 'serviceDie', callback: () => void): void 注册设备管理服务死亡监听。 +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + - 参数: | 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -174,6 +195,8 @@ off(type: 'serviceDie', callback?: () => void): void 取消注册设备管理服务死亡监听。 +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + - 参数: | 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md index 6ec080d5aa6d88a4908b41ca78c679ea81160372..5329495bc7f2ac4857c287b6e9195f5f32b83f60 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @@ -11,8 +11,6 @@ import distributedData from '@ohos.data.distributedData'; ``` - - ## distributedData.createKVManager createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void @@ -21,7 +19,7 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager> **系统能力**:SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | @@ -29,9 +27,8 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager> | callback | AsyncCallback<[KVManager](#kvmanager)> | 是 | KVManager实例创建时调用的回调,返回KVManager对象实例。 | -- 示例: +**示例**: - ``` let kvManager; try { const kvManagerConfig = { @@ -52,7 +49,6 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager> } catch (e) { console.log("An unexpected error occurred. Error:" + e); } - ``` ## distributedData.createKVManager @@ -62,21 +58,20 @@ createKVManager(config: KVManagerConfig): Promise<KVManager> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | | config |[KVManagerConfig](#kvmanager) | 是 | 提供KVManager实例的配置信息,包括调用方的包名和用户信息。 | -- 返回值: +**返回值**: | 类型 | 说明 | | -------- | -------- | | Promise<[KVManager](#kvmanager)> | 指定的Promise回调方法,返回创建的KVManager对象实例。 | -- 示例: +**示例**: - ``` let kvManager; try { const kvManagerConfig = { @@ -95,7 +90,6 @@ createKVManager(config: KVManagerConfig): Promise<KVManager> } catch (e) { console.log("An unexpected error occurred. Error:" + e); } - ``` ## KVManagerConfig @@ -148,7 +142,7 @@ getKVStore<T extends KVStore>(storeId: string, options: Options, callback: **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | @@ -156,7 +150,7 @@ getKVStore<T extends KVStore>(storeId: string, options: Options, callback: | options | [Options](#options) | 是 | 创建KVStore实例的配置信息。 | | callback | AsyncCallback<T>,<T extends KVStore> | 是 | 创建KVStore实例的回调,返回KVStore对象实例。 | -- 示例: +**示例**: ``` let kvStore; @@ -192,7 +186,7 @@ getKVStore<T extends KVStore>(storeId: string, options: Options): Promise& **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ------- | ---------------------- | ---- | -------------------- | @@ -200,14 +194,14 @@ getKVStore<T extends KVStore>(storeId: string, options: Options): Promise& | options | [Options](#options) | 是 | 创建KVStore实例的配置信息。| -- 返回值: +**返回值**: | 类型 | 说明 | | -------------------------------------- | ------------------------ | | Promise<T> <T extends KVStore> | 指定的Promise回调方法,返回创建的KVStore数据库实例。 | -- 示例: +**示例**: ``` let kvStore; @@ -240,7 +234,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | @@ -251,7 +245,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa | callback | AsyncCallback<void> | 是 | 回调函数,如果数据库关闭成功则返回true,否则返回false。 | -- 示例: +**示例**: ``` let kvStore; @@ -286,7 +280,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void& **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------------- | @@ -294,13 +288,13 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void& | storeId | string | 是 | 要关闭的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | | kvStore | [KVStore](#kvstore) | 是 | 要关闭的KvStore数据库。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------------- | -------------- | | Promise | Promise实例,如果数据库关闭成功则返回true,否则返回false。 | -- 示例: +**示例**: ``` let kvManager; @@ -340,7 +334,7 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -349,7 +343,7 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void> | callback | AsyncCallback<void> | 是 | 回调函数,如果成功返回true,否则返回false。 | -- 示例: +**示例**: ``` let kvManager; @@ -384,7 +378,7 @@ deleteKVStore(appId: string, storeId: string): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -392,13 +386,13 @@ deleteKVStore(appId: string, storeId: string): Promise<void> | storeId | string | 是 | 要删除的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------------- | -------------- | | Promise<void> | Promise实例,如果成功返回true,否则返回false。 | -- 示例: +**示例**: ``` let kvManager; @@ -438,14 +432,14 @@ getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | appId | string | 是 | 所调用数据库方的包名。 | | callback | AsyncCallback<void> | 是 |回调函数,返回所有创建的 KvStore 数据库的 storeId。 | -- 示例: +**示例**: ``` let kvManager; @@ -468,20 +462,20 @@ getAllKVStoreId(appId: string): Promise<string[]> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | appId | string | 是 | 所调用数据库方的包名。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------------- | -------------- | | Promise<string[]>| Promise实例,返回所有创建的 KvStore 数据库的 storeId。 | -- 示例: +**示例**: ``` let kvManager; @@ -507,7 +501,7 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): voi **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -516,7 +510,7 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): voi -- 示例 +**示例** ``` let kvManager; @@ -541,7 +535,7 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -549,7 +543,7 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v | deathCallback | Callback<void> | 否 | 回调函数,取消设备状态改变时获取通知。 | -- 示例 +**示例** ``` let kvManager; @@ -668,7 +662,7 @@ constructor(name: string) **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -682,20 +676,20 @@ appendChild(child: FieldNode): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | child | [FieldNode](#FieldNode) | 是 | 要附加的域节点。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------------- | -------------- | | boolean |如果子节点成功添加到这个FieldNode,则返回 true;否则返回 false。 | -- 示例 +**示例** ``` import ddm from '@ohos.data.distributedData'; @@ -733,18 +727,18 @@ getCount(): number **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | number |返回行数。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -767,18 +761,18 @@ getPosition(): number **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | number |返回当前读取位置。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -801,18 +795,18 @@ moveToFirst(): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -835,18 +829,18 @@ moveToLast(): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -869,18 +863,18 @@ moveToNext(): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -903,18 +897,18 @@ moveToPrevious(): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -937,24 +931,24 @@ move(offset: number): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | offset | number | 是 | 表示与当前位置的相对偏移量,负偏移表示向后移动,正偏移表示向前移动。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -977,24 +971,24 @@ moveToPosition(position: number): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | position | number | 是 |表示绝对位置。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | boolean |如果操作成功则返回true,否则返回 false。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -1017,18 +1011,18 @@ isFirst(): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | boolean |如果读取位置是第一行,则返回 true;否则返回 false。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -1051,18 +1045,18 @@ isLast(): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | boolean |如果读取位置是最后一行,则返回 true;否则返回 false。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -1085,18 +1079,18 @@ isBeforeFirst(): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | boolean |如果读取位置在第一行之前,则返回 true;否则返回 false。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -1119,18 +1113,18 @@ isAfterLast(): boolean **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | -------------- | | boolean |如果读取位置在最后一行之后,则返回 true;否则返回 false。 | -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -1153,18 +1147,18 @@ getEntry(): Entry **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | Entry |返回键值对。| -- 示例 +**示例** ``` let kvStore; try { - let resultSet; + let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { console.log('getResultSet success'); resultSet = result; @@ -1204,13 +1198,13 @@ reset(): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回重置的 Query 对象。| -- 示例 +**示例** ``` try { @@ -1234,20 +1228,20 @@ equalTo(field: string, value: number|string|boolean): Query; **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | value | number/string/boolean | 是 | 表示指定的值。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回重置的 Query 对象。| -- 示例 +**示例** ``` try { @@ -1269,20 +1263,20 @@ notEqualTo(field: string, value: number|string|boolean): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | value | number/string/boolean | 是 | 表示指定的值。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回重置的 Query 对象。| -- 示例 +**示例** ``` try { @@ -1304,20 +1298,20 @@ greaterThan(field: string, value: number|string|boolean): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | value | number/string/boolean | 是 | 表示指定的值。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1339,20 +1333,20 @@ lessThan(field: string, value: number|string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | value | number/string/boolean | 是 | 表示指定的值。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1374,20 +1368,20 @@ greaterThanOrEqualTo(field: string, value: number|string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | value | number/string/boolean | 是 | 表示指定的值。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1409,20 +1403,20 @@ lessThanOrEqualTo(field: string, value: number|string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | value | number/string/boolean | 是 | 表示指定的值。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1445,19 +1439,19 @@ isNull(field: string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1480,21 +1474,21 @@ inNumber(field: string, valueList: number[]): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | valueList | number[] | 是 | 表示指定的值列表。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1516,20 +1510,20 @@ inString(field: string, valueList: string[]): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | valueList | string[] | 是 | 表示指定的字符串值列表。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1551,20 +1545,20 @@ notInNumber(field: string, valueList: number[]): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | valueList | number[] | 是 | 表示指定的值列表。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1586,20 +1580,20 @@ notInString(field: string, valueList: string[]): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | valueList | string[] | 是 | 表示指定的字符串值列表。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1621,20 +1615,20 @@ like(field: string, value: string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | valueList | string | 是 | 表示指定的字符串值。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1656,20 +1650,20 @@ unlike(field: string, value: string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | | valueList | string | 是 | 表示指定的字符串值。| -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1691,13 +1685,13 @@ and(): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1721,13 +1715,13 @@ or(): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1751,19 +1745,19 @@ orderByAsc(field: string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1786,20 +1780,20 @@ orderByDesc(field: string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1822,20 +1816,20 @@ limit(total: number, offset: number): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | total | number | 是 |表示指定的结果数。 | | offset | number | 是 |表示起始位置。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1858,19 +1852,19 @@ isNotNull(field: string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1892,13 +1886,13 @@ beginGroup(): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1922,13 +1916,13 @@ endGroup(): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1952,19 +1946,19 @@ prefixKey(prefix: string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | prefix | string | 是 |表示指定的键前缀。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -1987,19 +1981,19 @@ setSuggestIndex(index: string): Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | index | string | 是 |指示要设置的索引。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -2022,20 +2016,20 @@ deviceId(deviceId:string):Query **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId | string | 是 |指示查询的设备 ID。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -2056,13 +2050,13 @@ getSqlLike():string **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | [Query](#query8) |返回查询对象。| -- 示例 +**示例** ``` try { @@ -2089,15 +2083,15 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key | string | 是 |要添加数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | -| value | Uint8Array / string / number / boolean | 是 |要添加数据的value,支持Uint8Array、number 、 string 、boolean,Uint8Array、string 的长度不大于[MAX_VALUE_LENGTH](#constants)。 | - +| value | Uint8Array \| string \| number \| boolean | 是 |要添加数据的value,支持Uint8Array、number 、 string 、boolean,Uint8Array、string 的长度不大于[MAX_VALUE_LENGTH](#constants)。 | +| callback | AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2125,21 +2119,21 @@ put(key: string, value: Uint8Array | string | number | boolean): Promise<void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key | string | 是 |要添加数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | -| value | Uint8Array / string / number / boolean | 是 |要添加数据的value,支持Uint8Array、number 、 string 、boolean,Uint8Array、string 的长度不大于[MAX_VALUE_LENGTH](#constants)。 | +| value | Uint8Array \| string \| number \| boolean | 是 |要添加数据的value,支持Uint8Array、number 、 string 、boolean,Uint8Array、string 的长度不大于[MAX_VALUE_LENGTH](#constants)。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -- 示例 +**示例** ``` let kvStore; @@ -2165,14 +2159,14 @@ delete(key: string, callback: AsyncCallback<void>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key | string | 是 |要删除数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | callback | AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2207,19 +2201,19 @@ delete(key: string): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key | string | 是 |要删除数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -- 示例 +**示例** ``` let kvStore; @@ -2250,7 +2244,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotific **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -2259,7 +2253,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotific | observer |Callback<[ChangeNotification](#changenotification)> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2277,7 +2271,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -2285,7 +2279,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> | syncCallback |Callback<Array<[string, number]>> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2302,14 +2296,14 @@ off(event:'dataChange', observer?: Callback<ChangeNotification>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event |'dataChange' | 是 |回调函数名称。 | | observer |Callback<[ChangeNotification](#changenotification)> |否 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2330,14 +2324,14 @@ putBatch(entries: Entry[], callback: AsyncCallback<void>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | entries |[Entry](#entry)[] | 是 |表示要批量插入的键值对。 | | callback |Asyncallback<void> |是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2378,19 +2372,19 @@ putBatch(entries: Entry[]): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | entries |[Entry](#entry)[] | 是 |表示要批量插入的键值对。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -- 示例 +**示例** ``` let kvStore; @@ -2433,14 +2427,14 @@ deleteBatch(keys: string[], callback: AsyncCallback<void>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keys |string[] | 是 |表示要批量删除的键值对。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2480,19 +2474,19 @@ deleteBatch(keys: string[]): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keys |string[] | 是 |表示要批量删除的键值对。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -- 示例 +**示例** ``` let kvStore; @@ -2536,13 +2530,13 @@ startTransaction(callback: AsyncCallback<void>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2588,13 +2582,13 @@ startTransaction(): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -- 示例 +**示例** ``` let kvStore; @@ -2623,13 +2617,13 @@ commit(callback: AsyncCallback<void>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2655,13 +2649,13 @@ commit(): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -- 示例 +**示例** ``` let kvStore; @@ -2685,13 +2679,13 @@ rollback(callback: AsyncCallback<void>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2717,13 +2711,13 @@ rollback(): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -- 示例 +**示例** ``` let kvStore; @@ -2747,14 +2741,14 @@ enableSync(enabled: boolean, callback: AsyncCallback<void>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | enabled |boolean | 是 |指定是否开启同步,ture表示开启同步,false表示不启用同步。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2780,19 +2774,19 @@ enableSync(enabled: boolean): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | enabled |boolean | 是 |指定是否开启同步,ture表示开启同步,false表示不启用同步。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -- 示例 +**示例** ``` let kvStore; @@ -2816,7 +2810,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: Asy **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -2824,7 +2818,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: Asy | remoteSupportLabels |string[] | 是 |表示要同步数据的设备的同步标签。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -2848,7 +2842,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<v **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -2856,13 +2850,13 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<v | remoteSupportLabels |string[] | 是 |表示要同步数据的设备的同步标签。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | | Promise<void> |Promise实例,用于异步处理。| -- 示例 +**示例** ``` let kvStore; @@ -2959,14 +2953,14 @@ get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | numb **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | callback |AsyncCallback<Uint8Array / string / boolean / number>) | 是 |回调函数,获取查询的值。 | -- 示例 +**示例** ``` let kvStore; @@ -2997,21 +2991,21 @@ get(key: string): Promise<Uint8Array | string | boolean | number> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<Uint8Array / string / boolean / number> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -3041,14 +3035,14 @@ getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keyPrefix |string | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<Entry[]> | 是 |回调函数,获取指定前缀的键值对列表。 | -- 示例 +**示例** ``` let kvStore; @@ -3087,19 +3081,19 @@ getEntries(keyPrefix: string): Promise<Entry[]> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keyPrefix |string | 是 |表示要匹配的键前缀。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[Entry](#entry)[]> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -3145,14 +3139,14 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<Entry[]> | 是 |回调函数,获取指定前缀的键值对列表。 | -- 示例 +**示例** ``` let kvStore; @@ -3196,19 +3190,19 @@ getEntries(query: Query): Promise<Entry[]> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[Entry](#entry)[]> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` try { @@ -3253,14 +3247,14 @@ getResultSet(keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>) **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keyPrefix |string | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |表示要匹配的键前缀。 | -- 示例 +**示例** ``` let kvStore; @@ -3302,19 +3296,19 @@ getResultSet(keyPrefix: string): Promise<KvStoreResultSet> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keyPrefix |string | 是 |表示要匹配的键前缀。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[KvStoreResultSet](#kvstoreresultset8)> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -3362,14 +3356,14 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |Query | 是 |表示查询对象。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数,获取与指定 Query 对象匹配的 KvStoreResultSet 对象。 | -- 示例 +**示例** ``` let kvStore; @@ -3410,19 +3404,19 @@ getResultSet(query: Query): Promise<KvStoreResultSet> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[KvStoreResultSet](#kvstoreresultset8)> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -3466,14 +3460,14 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>) **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#kvstoreresultset8) | 是 |表示要关闭的 KvStoreResultSet 对象。 | | callback |AsyncCallback<void> | 是 |回调函数,获取由 getResultSet 返回的 KvStoreResultSet 对象。 | -- 示例 +**示例** ``` let kvStore; @@ -3500,19 +3494,19 @@ closeResultSet(resultSet: KvStoreResultSet): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#kvstoreresultset8) | 是 |表示要关闭的 KvStoreResultSet 对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<void> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -3537,14 +3531,14 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<number> | 是 |回调函数,获取与指定 Query 对象匹配的结果数。 | -- 示例 +**示例** ``` let kvStore; @@ -3583,19 +3577,19 @@ getResultSize(query: Query): Promise<number> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<number> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -3638,14 +3632,14 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |表示要删除设备的名称。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -3680,19 +3674,19 @@ removeDeviceData(deviceId: string): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |表示要删除设备的名称。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<void> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -3729,14 +3723,14 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event |'syncComplete' | 是 |同步完成时触发的事件名。 | | syncCallback |Callback<Array<[string, number]>> | 是 |用于向调用方发送同步结果的回调。 | -- 示例 +**示例** ``` let kvStore; @@ -3765,7 +3759,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -3773,7 +3767,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& | syncCallback |Callback<Array<[string, number]>> | 否 |用于向调用方发送同步结果的回调。 | -- 示例 +**示例** ``` let kvStore; @@ -3797,7 +3791,7 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -3805,7 +3799,7 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | mode |[SyncMode](#syncmode) | 是 |同步类型。 | | allowedDelayMs |number | 否 |可选参数,允许延时时间,单位:ms(毫秒)。 | -- 示例: +**示例**: ``` let kvStore; @@ -3820,7 +3814,7 @@ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>) **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -3828,7 +3822,7 @@ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>) | callback |AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -3851,20 +3845,20 @@ setSyncParam(defaultAllowedDelayMs: number): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | defaultAllowedDelayMs |number | 是 |表示数据库同步允许的默认延迟,以毫秒为单位。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<void> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -3889,13 +3883,13 @@ getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<[SecurityLevel](#securitylevel)> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -3917,14 +3911,14 @@ getSecurityLevel(): Promise<SecurityLevel> **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[SecurityLevel](#securitylevel)> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -3954,7 +3948,7 @@ get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|num **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -3963,7 +3957,7 @@ get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|num | callback |AsyncCallback<boolean/string/number/Uint8Array> | 是 |回调函数,返回匹配给定条件的字符串值。 | -- 示例 +**示例** ``` let kvStore; @@ -3990,20 +3984,20 @@ get(deviceId: string, key: string): Promise<boolean|string|number|Uint8Array& **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | key |string | 是 |表示要查询 key 值的键。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<boolean/string/number/Uint8Array> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -4034,7 +4028,7 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -4042,7 +4036,7 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry | keyPrefix |string | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回满足给定条件的所有键值对的列表。 | -- 示例 +**示例** ``` let kvStore; @@ -4082,20 +4076,20 @@ getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]> **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | keyPrefix |string | 是 |表示要匹配的键前缀。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[Entry](#entry)[]> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -4141,14 +4135,14 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回与指定 Query 对象匹配的键值对列表。 | -- 示例 +**示例** ``` let kvStore; @@ -4194,19 +4188,19 @@ getEntries(query: Query): Promise<Entry[]> **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[Entry](#entry)[]> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -4252,7 +4246,7 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]> **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -4260,7 +4254,7 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]> | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回与指定 Query 对象匹配的键值对列表。 | -- 示例 +**示例** ``` let kvStore; @@ -4306,20 +4300,20 @@ getEntries(deviceId: string, query: Query): Promise<Entry[]> **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |键值对所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[Entry](#entry)[]> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -4366,7 +4360,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvS **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -4374,7 +4368,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvS | keyPrefix |string | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回 KvStoreResultSet 对象。 | -- 示例 +**示例** ``` let kvStore; @@ -4401,20 +4395,20 @@ getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet&g **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | keyPrefix |string | 是 |表示要匹配的键前缀。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -4445,14 +4439,14 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回与指定 Query 对象匹配的 KvStoreResultSet 对象。 | -- 示例 +**示例** ``` let kvStore; @@ -4497,19 +4491,19 @@ getResultSet(query: Query): Promise<KvStoreResultSet> **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -4561,7 +4555,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreR **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -4569,7 +4563,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreR | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回与指定 Query 对象匹配的 KvStoreResultSet 对象。 | -- 示例 +**示例** ``` let kvStore; @@ -4613,20 +4607,20 @@ getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet> **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |KvStoreResultSet对象所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -4679,14 +4673,14 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>) **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#getresultset8) | 是 |指示要关闭的 KvStoreResultSet 对象。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -4714,19 +4708,19 @@ closeResultSet(resultSet: KvStoreResultSet): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#getresultset8) | 是 |指示要关闭的 KvStoreResultSet 对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<void> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -4752,14 +4746,14 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<number> | 是 |回调函数,返回与指定 Query 对象匹配的结果数。 | -- 示例 +**示例** ``` let kvStore; @@ -4799,19 +4793,19 @@ getResultSize(query: Query): Promise<number> **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<number> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -4855,7 +4849,7 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number& **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -4863,7 +4857,7 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number& | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<number> | 是 |回调函数,返回与指定 Query 对象匹配的结果数。 | -- 示例 +**示例** ``` let kvStore; @@ -4902,20 +4896,20 @@ getResultSize(deviceId: string, query: Query): Promise<number> **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |KvStoreResultSet对象所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<number> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -4958,14 +4952,14 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要删除其数据的设备。 | | callback |AsyncCallback<void> | 是 |回调函数。 | -- 示例 +**示例** ``` let kvStore; @@ -5000,19 +4994,19 @@ removeDeviceData(deviceId: string): Promise<void> **系统能力**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要删除其数据的设备。 | -- 返回值: +**返回值**: | 类型 | 说明 | | ------ | ------- | |Promise<void> |Promise实例,用于获取异步返回结果。| -- 示例 +**示例** ``` let kvStore; @@ -5049,7 +5043,7 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | @@ -5058,7 +5052,7 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | allowedDelayMs |number | 否 |可选参数,允许延时时间,单位:ms(毫秒)。 | -- 示例 +**示例** ``` let kvStore; @@ -5087,14 +5081,14 @@ on(event: 'syncComplete', syncCallback: Callback<Arrary<[string, number]&g **系统能力**: SystemCapability.DistributedDataManager.KVStore.Core。 -- 参数: +**参数**: | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event |'syncComplete' | 是 |同步完成时触发的事件名。 | | syncCallback |Callback { if (error != null) { @@ -86,8 +86,8 @@ let wantTemp = { abilityName: "com.example.myapplication.MainAbility", }; let enterpriseInfo = { - name = "enterprise name", - description = "enterprise description" + name: "enterprise name", + description: "enterprise description" } enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL) .then((result) => { @@ -461,8 +461,8 @@ let wantTemp = { abilityName: "com.example.myapplication.MainAbility", }; let enterpriseInfo = { - name = "enterprise name", - description = "enterprise description" + name: "enterprise name", + description: "enterprise description" } enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) .then((result) => { @@ -503,8 +503,8 @@ let wantTemp = { abilityName: "com.example.myapplication.MainAbility", }; let enterpriseInfo = { - name = "enterprise name", - description = "enterprise description" + name: "enterprise name", + description: "enterprise description" } enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) .then((result) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md index cdce9e3617ce117b221abcd8b86d6bb3564cdc8a..6dc68700bdc40284a457dccaafa5496d1ee1b097 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md +++ b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md @@ -133,7 +133,7 @@ emit(event: string, ...args: Object[]): void; // func1 is called,1,2 this.context.eventHub.emit("123", 1, 2); } - func1(a: string, b: string) { + func1(a, b) { console.log("func1 is called," + a + "," + b); } } diff --git a/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md b/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md index d19c960f4f360bc545c80e5de0f16e6d905a1d45..96dc62be64646f9cd93dd73cc7f9bc0840deb393 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md @@ -694,6 +694,136 @@ GetWindowPromise(){ } ``` +## ConnectOptions.onConnect7+ + +onConnect(elementName: ElementName, remote: rpc.IRemoteObject): void; + +连接成功时的回调函数。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 名称 | 类型 | 必填 | 描述 | +| -------- | ----------------------- | ---- | ------------------------------------------------------------ | +| elementName | ElementName | 是 | 元素名。 | +| remote | rpc.IRemoteObject | 是 | rpc远程对象。 | + +**示例:** + +```javascript +import rpc from '@ohos.rpc' +import featureAbility from '@ohos.ability.featureAbility' +function onConnectCallback(element, remote){ + console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); +} +function onDisconnectCallback(element){ + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) +} +function onFailedCallback(code){ + console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) +} +var connId = featureAbility.connectAbility( + { + deviceId: "", + bundleName: "com.ix.ServiceAbility", + abilityName: "ServiceAbilityA", + }, + { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback, + }, +); +``` + +## ConnectOptions.onDisconnect7+ + +onDisconnect(elementName: ElementName): void; + +连接失败时的回调函数。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 名称 | 类型 | 必填 | 描述 | +| -------- | ----------------------- | ---- | ------------------------------------------------------------ | +| elementName | ElementName | 是 | 元素名。 | + +**示例:** + +```javascript +import rpc from '@ohos.rpc' +import featureAbility from '@ohos.ability.featureAbility' +function onConnectCallback(element, remote){ + console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); +} +function onDisconnectCallback(element){ + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) +} +function onFailedCallback(code){ + console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) +} +var connId = featureAbility.connectAbility( + { + deviceId: "", + bundleName: "com.ix.ServiceAbility", + abilityName: "ServiceAbilityA", + }, + { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback, + }, +); +``` + +## ConnectOptions.onFailed7+ + +onFailed(code: number): void; + +ConnectAbility调用失败时的回调函数。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 名称 | 类型 | 必填 | 描述 | +| -------- | ----------------------- | ---- | ------------------------------------------------------------ | +| code | number | 是 | number类型。 | + +**示例:** + +```javascript +import rpc from '@ohos.rpc' +import featureAbility from '@ohos.ability.featureAbility' +function onConnectCallback(element, remote){ + console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); +} +function onDisconnectCallback(element){ + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) +} +function onFailedCallback(code){ + console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) +} +var connId = featureAbility.connectAbility( + { + deviceId: "", + bundleName: "com.ix.ServiceAbility", + abilityName: "ServiceAbilityA", + }, + { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback, + }, +); +``` + + + + ## AbilityWindowConfiguration @@ -702,7 +832,7 @@ GetWindowPromise(){ **示例:** ``` -featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED。 +featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED ``` | 名称 | 参数 | 描述 | @@ -723,7 +853,7 @@ abilityStartSetting属性是一个定义为[key: string]: any的对象,key对 **示例:** ``` -featureAbility.AbilityStartSetting.BOUNDS_KEY。 +featureAbility.AbilityStartSetting.BOUNDS_KEY ``` | 名称 | 参数 | 描述 | @@ -782,15 +912,17 @@ featureAbility.AbilityStartSetting.BOUNDS_KEY。 | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| deviceId8+ | 只读 | string | 否 | 表示运行指定Ability的设备ID。 | -| bundleName8+ | 只读 | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | -| abilityName8+ | 只读 | string | 否 | 表示待启动的Ability名称。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | -| uri8+ | 只读 | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 | -| type8+ | 只读 | string | 否 | 表示MIME type类型描述,比如:"text/plain" 、 "image/*"等。 | -| flags8+ | 只读 | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](#flags说明)。 | -| action8+ | 只读 | string | 否 | 表示action选项描述。 | -| parameters8+ | 只读 | {[key: string]: any} | 否 | 表示WantParams描述。 | -| entities8+ | 只读 | Array\ | 否 | 表示entities相关描述。 | +| deviceId | 只读 | string | 否 | 表示运行指定Ability的设备ID。 | +| bundleName | 只读 | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | +| abilityName | 只读 | string | 否 | 表示待启动的Ability名称。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | +| uri | 只读 | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 | +| type | 只读 | string | 否 | 表示MIME type类型描述,比如:"text/plain" 、 "image/*"等。 | +| flags | 只读 | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](#flags说明)。 | +| action | 只读 | string | 否 | 表示action选项描述。 | +| parameters | 只读 | {[key: string]: any} | 否 | 表示WantParams描述。 | +| entities | 只读 | Array\ | 否 | 表示entities相关描述。 | +| extensionAbilityName9+ | 只读 | string | 否 | Want中扩展能力名称的描述。 | +| extensionAbilityType9+ | 只读 | number | 否 | 需求中扩展能力类型的描述。 | ## flags说明 @@ -806,12 +938,12 @@ featureAbility.AbilityStartSetting.BOUNDS_KEY。 | FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是否启动某个能力。 | | FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上可能持久化的授权。 | | FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 按照前缀匹配的方式验证URI权限。 | -| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动。< | +| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动。 | | FLAG_START_FOREGROUND_ABILITY | 0x00000200 | 指示无论主机应用程序是否已启动,都将启动使用服务模板的功能。 | | FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示迁移是可拉回的。 | | FLAG_INSTALL_ON_DEMAND | 0x00000800 | 如果未安装指定的功能,请安装该功能。 | | FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | 如果未安装,使用后台模式安装该功能。 | -| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | 指示清除其他任务的操作。可以为传递给**ohos.app.Context#startAbility**的**Want**设置此标志,并且必须与**flag_ABILITY_NEW_MISSION**一起使用。 | +| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | 指示清除其他任务的操作。可以为传递给 **[ohos.app.Context](js-apis-ability-context.md)** 中**startAbility**方法的**Want**设置此标志,并且必须与**flag_ABILITY_NEW_MISSION**一起使用。 | | FLAG_ABILITY_NEW_MISSION | 0x10000000 | 指示在历史任务堆栈上创建任务的操作。 | | FLAG_ABILITY_MISSION_TOP | 0x20000000 | 指示如果启动能力的现有实例已位于任务堆栈的顶部,则将重用该实例。否则,将创建一个新的能力实例。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index df7bf37867a7410a18d2609db8255a90ce2d598e..530ffabede91e7a9b2dc1e89dfc915f04afd2067 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -45,13 +45,13 @@ stat(path: string): Promise<Stat> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待获取文件的绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------- | + | path | string | 是 | 待获取文件的绝对路径。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | 表示文件的具体信息。 | - 示例: @@ -73,10 +73,10 @@ stat(path:string, callback:AsyncCallback<Stat>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待获取文件的绝对路径。 | - | callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取文件的信息之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------- | ---- | --------------- | + | path | string | 是 | 待获取文件的绝对路径。 | + | callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取文件的信息之后的回调。 | - 示例: ```js @@ -95,14 +95,14 @@ statSync(path:string): Stat **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待获取文件的绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------- | + | path | string | 是 | 待获取文件的绝对路径。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------- | ---------- | | [Stat](#stat) | 表示文件的具体信息。 | - 示例: @@ -121,13 +121,13 @@ opendir(path: string): Promise<Dir> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件目录的绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------- | + | path | string | 是 | 待打开文件目录的绝对路径。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------------------------- | -------- | | Promise<[Dir](#dir)> | 返回Dir对象。 | - 示例: @@ -149,10 +149,10 @@ opendir(path: string, callback: AsyncCallback<Dir>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件目录的绝对路径。 | - | callback | AsyncCallback<[Dir](#dir)> | 是 | 异步打开文件目录之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------- | ---- | -------------- | + | path | string | 是 | 待打开文件目录的绝对路径。 | + | callback | AsyncCallback<[Dir](#dir)> | 是 | 异步打开文件目录之后的回调。 | - 示例: ```js @@ -173,13 +173,13 @@ opendirSync(path: string): Dir - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件目录的绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------- | + | path | string | 是 | 待打开文件目录的绝对路径。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ----------- | -------- | | [Dir](#dir) | 返回Dir对象。 | - 示例: @@ -199,14 +199,14 @@ access(path: string, mode?: number): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数:. - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待访问文件的绝对路径。 | - | mode | number | 否 | 访问文件时的选项,可给定如下选项,以按位或的方式使用多个选项,默认给定0。
确认当前进程是否具有对应权限:
- 0:确认文件是否存在。
- 1:确认当前进程是否具有可执行权限。
- 2:确认当前进程是否具有写权限。
- 4:确认当前进程是否具有读权限。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待访问文件的绝对路径。 | + | mode | number | 否 | 访问文件时的选项,可给定如下选项,以按位或的方式使用多个选项,默认给定0。
确认当前进程是否具有对应权限:
- 0:确认文件是否存在。
- 1:确认当前进程是否具有可执行权限。
- 2:确认当前进程是否具有写权限。
- 4:确认当前进程是否具有读权限。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -228,11 +228,11 @@ access(path: string, mode: number, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待访问文件的绝对路径。 | - | mode | number | 否 | 访问文件时的选项,可给定如下选项,以按位或的方式使用多个选项,默认给定0。
确认当前进程是否具有对应权限:
- 0:确认文件是否存在。
- 1:确认当前进程是否具有可执行权限。
- 2:确认当前进程是否具有写权限。
- 4:确认当前进程是否具有读权限。 | - | callback | AsyncCallback<void> | 是 | 异步检查当前进程是否可访问某文件之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------------------------------------- | + | path | string | 是 | 待访问文件的绝对路径。 | + | mode | number | 否 | 访问文件时的选项,可给定如下选项,以按位或的方式使用多个选项,默认给定0。
确认当前进程是否具有对应权限:
- 0:确认文件是否存在。
- 1:确认当前进程是否具有可执行权限。
- 2:确认当前进程是否具有写权限。
- 4:确认当前进程是否具有读权限。 | + | callback | AsyncCallback<void> | 是 | 异步检查当前进程是否可访问某文件之后的回调。 | - 示例: ```js @@ -251,10 +251,10 @@ accessSync(path: string, mode?: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待访问文件的绝对路径。 | - | mode | number | 否 | 访问文件时的选项,可给定如下选项,以按位或的方式使用多个选项,默认给定0。
确认当前进程是否具有对应权限:
- 0:确认文件是否存在。
- 1:确认当前进程是否具有可执行权限。
- 2:确认当前进程是否具有写权限。
- 4:确认当前进程是否具有读权限。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待访问文件的绝对路径。 | + | mode | number | 否 | 访问文件时的选项,可给定如下选项,以按位或的方式使用多个选项,默认给定0。
确认当前进程是否具有对应权限:
- 0:确认文件是否存在。
- 1:确认当前进程是否具有可执行权限。
- 2:确认当前进程是否具有写权限。
- 4:确认当前进程是否具有读权限。 | - 示例: ```js @@ -275,13 +275,13 @@ close(fd: number):Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待关闭文件的文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------ | + | fd | number | 是 | 待关闭文件的文件描述符。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -304,10 +304,10 @@ close(fd: number, callback:AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待关闭文件的文件描述符。 | - | callback | AsyncCallback<void> | 是 | 异步关闭文件之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ------------ | + | fd | number | 是 | 待关闭文件的文件描述符。 | + | callback | AsyncCallback<void> | 是 | 异步关闭文件之后的回调。 | - 示例: ```js @@ -327,9 +327,9 @@ closeSync(fd: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待关闭文件的文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------ | + | fd | number | 是 | 待关闭文件的文件描述符。 | - 示例: ```js @@ -346,8 +346,8 @@ close(): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -369,9 +369,9 @@ close(callback: AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 异步关闭文件流之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ------------- | + | callback | AsyncCallback<void> | 是 | 异步关闭文件流之后的回调。 | - 示例: ```js @@ -390,15 +390,15 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise<voi **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | - | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | - | mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。
0:完全覆盖目标文件,未覆盖部分将被裁切掉。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | -------------------------- | ---- | ---------------------------------------- | + | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | + | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | + | mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。
0:完全覆盖目标文件,未覆盖部分将被裁切掉。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -420,12 +420,12 @@ copyFile(src: string | number, dest: string | number, mode: number, callback: As **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | - | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | - | mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。
0:完全覆盖目标文件,未覆盖部分将被裁切掉。 | - | callback | AsyncCallback<void> | 是 | 异步复制文件之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------- | ---- | ---------------------------------------- | + | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | + | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | + | mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。
0:完全覆盖目标文件,未覆盖部分将被裁切掉。 | + | callback | AsyncCallback<void> | 是 | 异步复制文件之后的回调。 | - 示例: ```js @@ -444,11 +444,11 @@ copyFileSync(src: string | number, dest: string | number, mode?: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | - | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | - | mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。
0:完全覆盖目标文件,未覆盖部分将被裁切掉。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | -------------------------- | ---- | ---------------------------------------- | + | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | + | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | + | mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。
0:完全覆盖目标文件,未覆盖部分将被裁切掉。 | - 示例: ```js @@ -465,14 +465,14 @@ mkdir(path:string, mode?: number): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待创建目录的绝对路径。 | - | mode | number | 否 | 创建目录的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o775。
- 0o775:所有者具有读、写及可执行权限,其余用户具有读及可执行权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待创建目录的绝对路径。 | + | mode | number | 否 | 创建目录的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o775。
- 0o775:所有者具有读、写及可执行权限,其余用户具有读及可执行权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -494,11 +494,11 @@ mkdir(path: string, mode: number, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待创建目录的绝对路径。 | - | mode | number | 否 | 创建目录的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o775。
- 0o775:所有者具有读、写及可执行权限,其余用户具有读及可执行权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - | callback | AsyncCallback<void> | 是 | 异步创建目录操作完成之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------------------------------------- | + | path | string | 是 | 待创建目录的绝对路径。 | + | mode | number | 否 | 创建目录的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o775。
- 0o775:所有者具有读、写及可执行权限,其余用户具有读及可执行权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | callback | AsyncCallback<void> | 是 | 异步创建目录操作完成之后的回调。 | - 示例: ```js @@ -519,10 +519,10 @@ mkdirSync(path: string, mode?: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待创建目录的绝对路径。 | - | mode | number | 否 | 创建目录的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o775。
- 0o775:所有者具有读、写及可执行权限,其余用户具有读及可执行权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待创建目录的绝对路径。 | + | mode | number | 否 | 创建目录的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o775。
- 0o775:所有者具有读、写及可执行权限,其余用户具有读及可执行权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - 示例: ```js @@ -539,15 +539,15 @@ open(path: string, flags?: number, mode?: number): Promise<number> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件的绝对路径。 | - | flags | number | 否 | 打开文件的选项,必须指定如下选项中的一个,默认以只读方式打开:
- 0o0:只读打开。
- 0o1:只写打开。
- 0o2:读写打开。
同时,也可给定如下选项,以按位或的方式追加,默认不给定任何额外选项:
- 0o100:若文件不存在,则创建文件。使用该选项时必须指定第三个参数 mode。
- 0o200:如果追加了0o100选项,且文件已经存在,则出错。
- 0o1000:如果文件存在且以只写或读写的方式打开文件,则将其长度裁剪为零。
- 0o2000:以追加方式打开,后续写将追加到文件末尾。
- 0o4000:如果path指向FIFO、块特殊文件或字符特殊文件,则本次打开及后续 IO 进行非阻塞操作。
- 0o200000:如果path指向目录,则出错。
- 0o400000:如果path指向符号链接,则出错。
- 0o4010000:以同步IO的方式打开文件。 | - | mode | number | 否 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。
- 0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | 参数名 | 类型 | 必填 | 说明 | + | ----- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待打开文件的绝对路径。 | + | flags | number | 否 | 打开文件的选项,必须指定如下选项中的一个,默认以只读方式打开:
- 0o0:只读打开。
- 0o1:只写打开。
- 0o2:读写打开。
同时,也可给定如下选项,以按位或的方式追加,默认不给定任何额外选项:
- 0o100:若文件不存在,则创建文件。使用该选项时必须指定第三个参数 mode。
- 0o200:如果追加了0o100选项,且文件已经存在,则出错。
- 0o1000:如果文件存在且以只写或读写的方式打开文件,则将其长度裁剪为零。
- 0o2000:以追加方式打开,后续写将追加到文件末尾。
- 0o4000:如果path指向FIFO、块特殊文件或字符特殊文件,则本次打开及后续 IO 进行非阻塞操作。
- 0o200000:如果path指向目录,则出错。
- 0o400000:如果path指向符号链接,则出错。
- 0o4010000:以同步IO的方式打开文件。 | + | mode | number | 否 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。
- 0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | --------------------- | ----------- | | Promise<number> | 打开文件的文件描述符。 | - 示例: @@ -569,12 +569,12 @@ open(path: string, flags: number, mode: number, callback: AsyncCallback<numbe **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件的绝对路径。 | - | flags | number | 是 | 打开文件的选项,必须指定如下选项中的一个,默认以只读方式打开:
- 0o0:只读打开。
- 0o1:只写打开。
- 0o2:读写打开。
同时,也可给定如下选项,以按位或的方式追加,默认不给定任何额外选项:
- 0o100:若文件不存在,则创建文件。使用该选项时必须指定第三个参数 mode。
- 0o200:如果追加了0o100选项,且文件已经存在,则出错。
- 0o1000:如果文件存在且以只写或读写的方式打开文件,则将其长度裁剪为零。
- 0o2000:以追加方式打开,后续写将追加到文件末尾。
- 0o4000:如果path指向FIFO、块特殊文件或字符特殊文件,则本次打开及后续 IO 进行非阻塞操作。
- 0o200000:如果path指向目录,则出错。
- 0o400000:如果path指向符号链接,则出错。
- 0o4010000:以同步IO的方式打开文件。 | - | mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。
- 0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - | callback | AsyncCallback <void> | 是 | 异步打开文件之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | path | string | 是 | 待打开文件的绝对路径。 | + | flags | number | 是 | 打开文件的选项,必须指定如下选项中的一个,默认以只读方式打开:
- 0o0:只读打开。
- 0o1:只写打开。
- 0o2:读写打开。
同时,也可给定如下选项,以按位或的方式追加,默认不给定任何额外选项:
- 0o100:若文件不存在,则创建文件。使用该选项时必须指定第三个参数 mode。
- 0o200:如果追加了0o100选项,且文件已经存在,则出错。
- 0o1000:如果文件存在且以只写或读写的方式打开文件,则将其长度裁剪为零。
- 0o2000:以追加方式打开,后续写将追加到文件末尾。
- 0o4000:如果path指向FIFO、块特殊文件或字符特殊文件,则本次打开及后续 IO 进行非阻塞操作。
- 0o200000:如果path指向目录,则出错。
- 0o400000:如果path指向符号链接,则出错。
- 0o4010000:以同步IO的方式打开文件。 | + | mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。
- 0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | callback | AsyncCallback <void> | 是 | 异步打开文件之后的回调。 | - 示例: ```js @@ -593,15 +593,15 @@ openSync(path:string, flags?:number, mode?:number): number **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件的绝对路径。 | - | flags | number | 否 | 打开文件的选项,必须指定如下选项中的一个,默认以只读方式打开:
- 0o0:只读打开。
- 0o1:只写打开。
- 0o2:读写打开。
同时,也可给定如下选项,以按位或的方式追加,默认不给定任何额外选项:
- 0o100:若文件不存在,则创建文件。使用该选项时必须指定第三个参数 mode。
- 0o200:如果追加了0o100选项,且文件已经存在,则出错。
- 0o1000:如果文件存在且以只写或读写的方式打开文件,则将其长度裁剪为零。
- 0o2000:以追加方式打开,后续写将追加到文件末尾。
- 0o4000:如果path指向FIFO、块特殊文件或字符特殊文件,则本次打开及后续 IO 进行非阻塞操作。
- 0o200000:如果path指向目录,则出错。
- 0o400000:如果path指向符号链接,则出错。
- 0o4010000:以同步IO的方式打开文件。 | - | mode | number | 否 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。
- 0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。
创建出的文件权限受umask影响,umask随进程启动确定,其修改当前不开放。 | + | 参数名 | 类型 | 必填 | 说明 | + | ----- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待打开文件的绝对路径。 | + | flags | number | 否 | 打开文件的选项,必须指定如下选项中的一个,默认以只读方式打开:
- 0o0:只读打开。
- 0o1:只写打开。
- 0o2:读写打开。
同时,也可给定如下选项,以按位或的方式追加,默认不给定任何额外选项:
- 0o100:若文件不存在,则创建文件。使用该选项时必须指定第三个参数 mode。
- 0o200:如果追加了0o100选项,且文件已经存在,则出错。
- 0o1000:如果文件存在且以只写或读写的方式打开文件,则将其长度裁剪为零。
- 0o2000:以追加方式打开,后续写将追加到文件末尾。
- 0o4000:如果path指向FIFO、块特殊文件或字符特殊文件,则本次打开及后续 IO 进行非阻塞操作。
- 0o200000:如果path指向目录,则出错。
- 0o400000:如果path指向符号链接,则出错。
- 0o4010000:以同步IO的方式打开文件。 | + | mode | number | 否 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。
- 0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。
创建出的文件权限受umask影响,umask随进程启动确定,其修改当前不开放。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ----------- | | number | 打开文件的文件描述符。 | - 示例: @@ -623,15 +623,15 @@ read(fd: number, buffer: ArrayBuffer, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待读取文件的文件描述符。 | - | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------- | ---- | ---------------------------------------- | + | fd | number | 是 | 待读取文件的文件描述符。 | + | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | 读取的结果。 | - 示例: @@ -659,12 +659,12 @@ read(fd: number, buffer: ArrayBuffer, options: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待读取文件的文件描述符。 | - | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | - | callback | AsyncCallback<[ReadOut](#readout)> | 是 | 异步读取数据之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | fd | number | 是 | 待读取文件的文件描述符。 | + | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | callback | AsyncCallback<[ReadOut](#readout)> | 是 | 异步读取数据之后的回调。 | - 示例: ```js @@ -691,15 +691,15 @@ readSync(fd: number, buffer: ArrayBuffer, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待读取文件的文件描述符。 | - | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------- | ---- | ---------------------------------------- | + | fd | number | 是 | 待读取文件的文件描述符。 | + | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | -------- | | number | 实际读取的长度。 | - 示例: @@ -719,13 +719,13 @@ rmdir(path: string): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待删除目录的绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------- | + | path | string | 是 | 待删除目录的绝对路径。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -747,10 +747,10 @@ rmdir(path: string, callback:AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待删除目录的绝对路径。 | - | callback | AsyncCallback<void> | 是 | 异步删除目录之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ------------ | + | path | string | 是 | 待删除目录的绝对路径。 | + | callback | AsyncCallback<void> | 是 | 异步删除目录之后的回调。 | - 示例: ```js @@ -769,9 +769,9 @@ rmdirSync(path: string): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待删除目录的绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------- | + | path | string | 是 | 待删除目录的绝对路径。 | - 示例: ```js @@ -788,13 +788,13 @@ unlink(path:string): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待删除文件的绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------- | + | path | string | 是 | 待删除文件的绝对路径。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -816,10 +816,10 @@ unlink(path:string, callback:AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待删除文件的绝对路径。 | - | callback | AsyncCallback<void> | 是 | 异步删除文件之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ------------ | + | path | string | 是 | 待删除文件的绝对路径。 | + | callback | AsyncCallback<void> | 是 | 异步删除文件之后的回调。 | - 示例: ```js @@ -840,9 +840,9 @@ unlinkSync(path: string): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待删除文件的绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------- | + | path | string | 是 | 待删除文件的绝对路径。 | - 示例: ```js @@ -864,15 +864,15 @@ write(fd: number, buffer: ArrayBuffer | string, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待写入文件的文件描述符。 | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | 是 | 待写入文件的文件描述符。 | + | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | --------------------- | -------- | | Promise<number> | 实际写入的长度。 | - 示例: @@ -900,12 +900,12 @@ write(fd: number, buffer: ArrayBuffer | string, options: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待写入文件的文件描述符。 | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | - | callback | AsyncCallback<number> | 是 | 异步将数据写入完成后执行的回调函数。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | 是 | 待写入文件的文件描述符。 | + | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | callback | AsyncCallback<number> | 是 | 异步将数据写入完成后执行的回调函数。 | - 示例: ```js @@ -932,15 +932,15 @@ writeSync(fd: number, buffer: ArrayBuffer | string, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待写入文件的文件描述符。 | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | 是 | 待写入文件的文件描述符。 | + | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | -------- | | number | 实际写入的长度。 | - 示例: @@ -959,14 +959,14 @@ hash(path: string, algorithm: string): Promise<string> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待计算哈希值文件的绝对路径。 | - | algorithm | string | 是 | 哈希计算采用的算法。可选 "md5"、"sha1" 或 "sha256"。建议采用安全强度更高的 "sha256"。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待计算哈希值文件的绝对路径。 | + | algorithm | string | 是 | 哈希计算采用的算法。可选 "md5"、"sha1" 或 "sha256"。建议采用安全强度更高的 "sha256"。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | --------------------- | -------------------------- | | Promise<string> | 文件的哈希值。表示为十六进制数字串,所有字母均大写。 | - 示例: @@ -988,11 +988,11 @@ hash(path: string, algorithm: string, callback: AsyncCallback<string>): vo **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待计算哈希值文件的绝对路径。 | - | algorithm | string | 是 | 哈希计算采用的算法。可选 "md5"、"sha1" 或 "sha256"。建议采用安全强度更高的 "sha256"。 | - | callback | AsyncCallback<string> | 是 | 异步计算文件哈希操之后的回调函数(其中给定文件哈希值表示为十六进制数字串,所有字母均大写)。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | --------------------------- | ---- | ---------------------------------------- | + | path | string | 是 | 待计算哈希值文件的绝对路径。 | + | algorithm | string | 是 | 哈希计算采用的算法。可选 "md5"、"sha1" 或 "sha256"。建议采用安全强度更高的 "sha256"。 | + | callback | AsyncCallback<string> | 是 | 异步计算文件哈希操之后的回调函数(其中给定文件哈希值表示为十六进制数字串,所有字母均大写)。 | - 示例: ```js @@ -1013,14 +1013,14 @@ chmod(path: string, mode: number):Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待改变文件权限的绝对路径。 | - | mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待改变文件权限的绝对路径。 | + | mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -1042,11 +1042,11 @@ chmod(path: string, mode: number, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待改变文件权限的绝对路径。 | - | mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - | callback | AsyncCallback<void> | 是 | 异步改变文件权限之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------------------------------------- | + | path | string | 是 | 待改变文件权限的绝对路径。 | + | mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | callback | AsyncCallback<void> | 是 | 异步改变文件权限之后的回调。 | - 示例: ```js @@ -1065,10 +1065,10 @@ chmodSync(path: string, mode: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待改变文件权限的绝对路径。 | - | mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待改变文件权限的绝对路径。 | + | mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - 示例: ```js @@ -1085,13 +1085,13 @@ fstat(fd: number): Promise<Stat> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待获取文件的文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------ | + | fd | number | 是 | 待获取文件的文件描述符。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | 表示文件的具体信息。 | - 示例: @@ -1113,10 +1113,10 @@ fstat(fd: number, callback: AsyncCallback<Stat>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待获取文件的文件描述符。 | - | callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取文件状态信息之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------- | ---- | ---------------- | + | fd | number | 是 | 待获取文件的文件描述符。 | + | callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取文件状态信息之后的回调。 | - 示例: ```js @@ -1136,13 +1136,13 @@ fstatSync(fd: number): Stat **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待获取文件的文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------ | + | fd | number | 是 | 待获取文件的文件描述符。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------- | ---------- | | [Stat](#stat) | 表示文件的具体信息。 | - 示例: @@ -1161,14 +1161,14 @@ ftruncate(fd: number, len?: number): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待截断文件的文件描述符。 | - | len | number | 是 | 文件截断后的长度,以字节为单位。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------- | + | fd | number | 是 | 待截断文件的文件描述符。 | + | len | number | 是 | 文件截断后的长度,以字节为单位。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -1191,11 +1191,11 @@ ftruncate(fd: number, len: number, callback:AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待截断文件的文件描述符。 | - | len | number | 是 | 文件截断后的长度,以字节为单位。 | - | callback | AsyncCallback<void> | 是 | 异步截断文件的信息之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------------- | + | fd | number | 是 | 待截断文件的文件描述符。 | + | len | number | 是 | 文件截断后的长度,以字节为单位。 | + | callback | AsyncCallback<void> | 是 | 异步截断文件的信息之后的回调。 | - 示例: ```js @@ -1214,10 +1214,10 @@ ftruncateSync(fd: number, len?: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待截断文件的文件描述符。 | - | len | number | 否 | 文件截断后的长度,以字节为单位。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------- | + | fd | number | 是 | 待截断文件的文件描述符。 | + | len | number | 否 | 文件截断后的长度,以字节为单位。 | - 示例: ```js @@ -1234,14 +1234,14 @@ truncate(path: string, len?: number): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待截断文件的绝对路径。 | - | len | number | 是 | 文件截断后的长度,以字节为单位。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------- | + | path | string | 是 | 待截断文件的绝对路径。 | + | len | number | 是 | 文件截断后的长度,以字节为单位。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -1263,11 +1263,11 @@ truncate(path: string, len: number, callback:AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待截断文件的绝对路径。 | - | len | number | 是 | 文件截断后的长度,以字节为单位。 | - | callback | AsyncCallback<void> | 是 | 异步截断文件的信息之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------------- | + | path | string | 是 | 待截断文件的绝对路径。 | + | len | number | 是 | 文件截断后的长度,以字节为单位。 | + | callback | AsyncCallback<void> | 是 | 异步截断文件的信息之后的回调。 | - 示例: ```js @@ -1286,10 +1286,10 @@ truncateSync(path: string, len?: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待截断文件的绝对路径。 | - | len | number | 否 | 文件截断后的长度,以字节为单位。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------- | + | path | string | 是 | 待截断文件的绝对路径。 | + | len | number | 否 | 文件截断后的长度,以字节为单位。 | - 示例: ```js @@ -1310,14 +1310,14 @@ readText(filePath: string, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | filePath | string | 是 | 待读取文件的绝对路径。 | - | options | Object | 否 | 支持如下选项:
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- encoding,string类型,当数据是 string 类型时有效,表示数据的编码方式,默认 'utf-8',仅支持 'utf-8'。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | ---------------------------------------- | + | filePath | string | 是 | 待读取文件的绝对路径。 | + | options | Object | 否 | 支持如下选项:
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- encoding,string类型,当数据是 string 类型时有效,表示数据的编码方式,默认 'utf-8',仅支持 'utf-8'。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | --------------------- | ---------- | | Promise<string> | 返回读取文件的内容。 | - 示例: @@ -1343,11 +1343,11 @@ readText(filePath: string, options: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | filePath | string | 是 | 待读取文件的绝对路径。 | - | options | Object | 否 | 支持如下选项:
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- encoding,string类型,当数据是 string 类型时有效,表示数据的编码方式,默认 'utf-8',仅支持 'utf-8'。 | - | callback | AsyncCallback<string> | 是 | 异步通过文本方式读取文件之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------- | ---- | ---------------------------------------- | + | filePath | string | 是 | 待读取文件的绝对路径。 | + | options | Object | 否 | 支持如下选项:
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- encoding,string类型,当数据是 string 类型时有效,表示数据的编码方式,默认 'utf-8',仅支持 'utf-8'。 | + | callback | AsyncCallback<string> | 是 | 异步通过文本方式读取文件之后的回调。 | - 示例: ```js @@ -1370,14 +1370,14 @@ readTextSync(filePath: string, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | filePath | string | 是 | 待读取文件的绝对路径。 | - | options | Object | 否 | 支持如下选项:
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- encoding,string类型,当数据是 string 类型时有效,表示数据的编码方式,默认 'utf-8',仅支持 'utf-8'。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | ---------------------------------------- | + | filePath | string | 是 | 待读取文件的绝对路径。 | + | options | Object | 否 | 支持如下选项:
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- encoding,string类型,当数据是 string 类型时有效,表示数据的编码方式,默认 'utf-8',仅支持 'utf-8'。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | --------------------- | ---------- | | Promise<string> | 返回读取文件的内容。 | - 示例: @@ -1395,13 +1395,13 @@ lstat(path: string): Promise<Stat> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 目标文件的绝对路径,指向链接状态。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------------- | + | path | string | 是 | 目标文件的绝对路径,指向链接状态。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | 表示文件的具体信息。 | - 示例: @@ -1423,10 +1423,10 @@ lstat(path:string, callback:AsyncCallback<Stat>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 目标文件的绝对路径,指向链接状态。 | - | callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取链接状态信息之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------- | ---- | ----------------- | + | path | string | 是 | 目标文件的绝对路径,指向链接状态。 | + | callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取链接状态信息之后的回调。 | - 示例: ```js @@ -1445,13 +1445,13 @@ lstatSync(path:string): Stat **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 目标文件的绝对路径,指向链接状态。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------------- | + | path | string | 是 | 目标文件的绝对路径,指向链接状态。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------- | ---------- | | [Stat](#stat) | 表示文件的具体信息。 | - 示例: @@ -1473,14 +1473,14 @@ read(buffer: ArrayBuffer, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | 读取的结果。 | - 示例: @@ -1506,11 +1506,11 @@ read(buffer: ArrayBuffer, options: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。 | - | callback | AsyncCallback<[ReadOut](#readout)> | 是 | 异步从文件读取数据之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。 | + | callback | AsyncCallback<[ReadOut](#readout)> | 是 | 异步从文件读取数据之后的回调。 | - 示例 ```js @@ -1532,14 +1532,14 @@ rename(oldPath: string, newPath: string): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | oldPath | string | 是 | 目标文件的当前绝对路径。 | - | Newpath | String | 是 | 目标文件的新绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ------------ | + | oldPath | string | 是 | 目标文件的当前绝对路径。 | + | Newpath | String | 是 | 目标文件的新绝对路径。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -1561,11 +1561,11 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): v **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | oldpath | string | 是 | 目标文件的当前绝对路径。 | - | Newpath | String | 是 | 目标文件的新绝对路径。 | - | Callback | AsyncCallback<void> | 是 | 异步重命名文件之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ------------- | + | oldpath | string | 是 | 目标文件的当前绝对路径。 | + | Newpath | String | 是 | 目标文件的新绝对路径。 | + | Callback | AsyncCallback<void> | 是 | 异步重命名文件之后的回调。 | - 示例: ```js @@ -1583,10 +1583,10 @@ renameSync(oldPath: string, newPath: string): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | oldPath | string | 是 | 目标文件的当前绝对路径。 | - | Newpath | String | 是 | 目标文件的新绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ------------ | + | oldPath | string | 是 | 目标文件的当前绝对路径。 | + | Newpath | String | 是 | 目标文件的新绝对路径。 | - 示例: ```js @@ -1603,13 +1603,13 @@ fsync(fd: number): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待同步文件的文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------ | + | fd | number | 是 | 待同步文件的文件描述符。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -1631,10 +1631,10 @@ fsync(fd: number, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待同步文件的文件描述符。 | - | Callback | AsyncCallback<void> | 是 | 异步将文件数据同步之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | --------------- | + | fd | number | 是 | 待同步文件的文件描述符。 | + | Callback | AsyncCallback<void> | 是 | 异步将文件数据同步之后的回调。 | - 示例: ```js @@ -1653,9 +1653,9 @@ fsyncSync(fd: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待同步文件的文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------ | + | fd | number | 是 | 待同步文件的文件描述符。 | - 示例: ```js @@ -1672,13 +1672,13 @@ fdatasync(fd: number): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待同步文件的文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------ | + | fd | number | 是 | 待同步文件的文件描述符。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 | - 示例: @@ -1700,10 +1700,10 @@ fdatasync(fd: number, callback:AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待同步文件的文件描述符。 | - | callback | AsyncCallback <void> | 是 | 异步将文件内容数据同步之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------- | ---- | ----------------- | + | fd | number | 是 | 待同步文件的文件描述符。 | + | callback | AsyncCallback <void> | 是 | 异步将文件内容数据同步之后的回调。 | - 示例: ```js @@ -1722,9 +1722,9 @@ fdatasyncSync(fd: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待同步文件的文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------ | + | fd | number | 是 | 待同步文件的文件描述符。 | - 示例: ```js @@ -1741,14 +1741,14 @@ symlink(target: string, srcPath: string): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | target | string | 是 | 目标文件的绝对路径。 | - | srcPath | string | 是 | 符号链接文件的绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ------------ | + | target | string | 是 | 目标文件的绝对路径。 | + | srcPath | string | 是 | 符号链接文件的绝对路径。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 | - 示例: @@ -1770,11 +1770,11 @@ symlink(target: string, srcPath: string, callback: AsyncCallback<void>): v **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | target | string | 是 | 目标文件的绝对路径。 | - | srcPath | string | 是 | 符号链接文件的绝对路径。 | - | callback | AsyncCallback<void> | 是 | 异步创建符号链接信息之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------------- | + | target | string | 是 | 目标文件的绝对路径。 | + | srcPath | string | 是 | 符号链接文件的绝对路径。 | + | callback | AsyncCallback<void> | 是 | 异步创建符号链接信息之后的回调。 | - 示例: ```js @@ -1793,10 +1793,10 @@ symlinkSync(target: string, srcPath: string): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | target | string | 是 | 目标文件的绝对路径。 | - | srcPath | string | 是 | 符号链接文件的绝对路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ------------ | + | target | string | 是 | 目标文件的绝对路径。 | + | srcPath | string | 是 | 符号链接文件的绝对路径。 | - 示例: ```js @@ -1813,15 +1813,15 @@ chown(path: string, uid: number, gid: number): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待改变文件的绝对路径。 | - | uid | number | 是 | 新的UID(UserID)。 | - | gid | number | 是 | 新的GID(GroupID)。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | --------------- | + | path | string | 是 | 待改变文件的绝对路径。 | + | uid | number | 是 | 新的UID(UserID)。 | + | gid | number | 是 | 新的GID(GroupID)。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 | - 示例: @@ -1844,12 +1844,12 @@ chown(path: string, uid: number, gid: number, callback: AsyncCallback<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待改变文件的绝对路径。 | - | uid | number | 是 | 新的UID。 | - | gid | number | 是 | 新的GID。 | - | callback | AsyncCallback<void> | 是 | 异步改变文件所有者之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | --------------- | + | path | string | 是 | 待改变文件的绝对路径。 | + | uid | number | 是 | 新的UID。 | + | gid | number | 是 | 新的GID。 | + | callback | AsyncCallback<void> | 是 | 异步改变文件所有者之后的回调。 | - 示例: ```js @@ -1869,11 +1869,11 @@ chownSync(path: string, uid: number, gid: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待改变文件的绝对路径。 | - | uid | number | 是 | 新的UID。 | - | gid | number | 是 | 新的GID。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------- | + | path | string | 是 | 待改变文件的绝对路径。 | + | uid | number | 是 | 新的UID。 | + | gid | number | 是 | 新的GID。 | - 示例: ```js @@ -1891,13 +1891,13 @@ mkdtemp(prefix: string): Promise<string> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | --------------------------- | + | prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 | - 返回值: - | 参数名 | 说明 | - | -------- | -------- | + | 参数名 | 说明 | + | --------------------- | ---------- | | Promise<string> | 生成的唯一目录路径。 | - 示例: @@ -1919,10 +1919,10 @@ mkdtemp(prefix: string, callback: AsyncCallback<string>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 | - | callback | AsyncCallback<string> | 是 | 异步创建临时目录之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------- | ---- | --------------------------- | + | prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 | + | callback | AsyncCallback<string> | 是 | 异步创建临时目录之后的回调。 | - 示例: ```js @@ -1941,13 +1941,13 @@ mkdtempSync(prefix: string): string **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | --------------------------- | + | prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 | - 返回值: - | 参数名 | 说明 | - | -------- | -------- | + | 参数名 | 说明 | + | ------ | ---------- | | string | 产生的唯一目录路径。 | - 示例: @@ -1965,14 +1965,14 @@ fchmod(fd: number, mode: number): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待改变文件的文件描述符。 | - | mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | 是 | 待改变文件的文件描述符。 | + | mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - 返回值: - | 参数名 | 说明 | - | -------- | -------- | + | 参数名 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 | - 示例: @@ -1994,11 +1994,11 @@ fchmod(fd: number, mode: number, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待改变文件的文件描述符。 | - | mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - | callback | AsyncCallback <void> | 是 | 异步改变文件权限之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | 是 | 待改变文件的文件描述符。 | + | mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | callback | AsyncCallback <void> | 是 | 异步改变文件权限之后的回调。 | - 示例: ```js @@ -2017,10 +2017,10 @@ fchmodSync(fd: number, mode: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待改变文件的文件描述符。 | - | mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | 是 | 待改变文件的文件描述符。 | + | mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - 示例: ```js @@ -2037,14 +2037,14 @@ createStream(path: string, mode: string): Promise<Stream> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件的绝对路径。 | - | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待打开文件的绝对路径。 | + | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | --------------------------------- | --------- | | Promise<[Stream](#stream7)> | 返回文件流的结果。 | - 示例: @@ -2066,11 +2066,11 @@ createStream(path: string, mode: string, callback: AsyncCallback<Stream>): **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件的绝对路径。 | - | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | - | callback | AsyncCallback<[Stream](#stream7)> | 是 | 异步打开文件流之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------- | ---- | ---------------------------------------- | + | path | string | 是 | 待打开文件的绝对路径。 | + | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | + | callback | AsyncCallback<[Stream](#stream7)> | 是 | 异步打开文件流之后的回调。 | - 示例: ```js @@ -2089,14 +2089,14 @@ createStreamSync(path: string, mode: string): Stream **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件的绝对路径。 | - | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | 是 | 待打开文件的绝对路径。 | + | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | - 返回值: - | 参数名 | 说明 | - | -------- | -------- | + | 参数名 | 说明 | + | ------------------ | --------- | | [Stream](#stream7) | 返回文件流的结果。 | - 示例: @@ -2114,14 +2114,14 @@ fdopenStream(fd: number, mode: string): Promise<Stream> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待打开文件的文件描述符。 | - | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | 是 | 待打开文件的文件描述符。 | + | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | - 返回值: - | 参数名 | 说明 | - | -------- | -------- | + | 参数名 | 说明 | + | --------------------------------- | --------- | | Promise<[Stream](#stream7)> | 返回文件流的结果。 | - 示例: @@ -2143,11 +2143,11 @@ fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): v **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待打开文件的文件描述符。 | - | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | - | callback | AsyncCallback <[Stream](#stream7)> | 是 | 异步打开文件流之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | fd | number | 是 | 待打开文件的文件描述符。 | + | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | + | callback | AsyncCallback <[Stream](#stream7)> | 是 | 异步打开文件流之后的回调。 | - 示例: ```js @@ -2166,14 +2166,14 @@ fdopenStreamSync(fd: number, mode: string): Stream **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待打开文件的文件描述符。 | - | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | 是 | 待打开文件的文件描述符。 | + | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | - 返回值: - | 参数名 | 说明 | - | -------- | -------- | + | 参数名 | 说明 | + | ------------------ | --------- | | [Stream](#stream7) | 返回文件流的结果。 | - 示例: @@ -2191,15 +2191,15 @@ fchown(fd: number, uid: number, gid: number): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待改变文件的文件描述符。 | - | uid | number | 是 | 文件所有者的UID。 | - | gid | number | 是 | 文件所有组的GID。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------ | + | fd | number | 是 | 待改变文件的文件描述符。 | + | uid | number | 是 | 文件所有者的UID。 | + | gid | number | 是 | 文件所有组的GID。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -2222,12 +2222,12 @@ fchown(fd: number, uid: number, gid: number, callback: AsyncCallback<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待改变文件的文件描述符。 | - | uid | number | 是 | 文件所有者的UID。 | - | gid | number | 是 | 文件所有组的GID。 | - | callback | AsyncCallback<void> | 是 | 异步改变文件所有者之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | --------------- | + | fd | number | 是 | 待改变文件的文件描述符。 | + | uid | number | 是 | 文件所有者的UID。 | + | gid | number | 是 | 文件所有组的GID。 | + | callback | AsyncCallback<void> | 是 | 异步改变文件所有者之后的回调。 | - 示例: ```js @@ -2247,11 +2247,11 @@ fchownSync(fd: number, uid: number, gid: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 待改变文件的文件描述符。 | - | uid | number | 是 | 文件所有者的UID。 | - | gid | number | 是 | 文件所有组的GID。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ------------ | + | fd | number | 是 | 待改变文件的文件描述符。 | + | uid | number | 是 | 文件所有者的UID。 | + | gid | number | 是 | 文件所有组的GID。 | - 示例: ```js @@ -2269,15 +2269,15 @@ lchown(path: string, uid: number, gid: number): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件的绝对路径。 | - | uid | number | 是 | 新的UID。 | - | gid | number | 是 | 新的GID。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------- | + | path | string | 是 | 待打开文件的绝对路径。 | + | uid | number | 是 | 新的UID。 | + | gid | number | 是 | 新的GID。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ---------------------------- | | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | - 示例: @@ -2300,12 +2300,12 @@ lchown(path: string, uid: number, gid: number, callback: AsyncCallback<void&g **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件的绝对路径。 | - | uid | number | 是 | 新的UID。 | - | gid | number | 是 | 新的GID。 | - | callback | AsyncCallback<void> | 是 | 异步改变文件所有者之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | --------------- | + | path | string | 是 | 待打开文件的绝对路径。 | + | uid | number | 是 | 新的UID。 | + | gid | number | 是 | 新的GID。 | + | callback | AsyncCallback<void> | 是 | 异步改变文件所有者之后的回调。 | - 示例: ```js @@ -2325,11 +2325,11 @@ lchownSync(path: string, uid: number, gid: number): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 待打开文件的绝对路径。 | - | uid | number | 是 | 新的UID。 | - | gid | number | 是 | 新的GID。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ----------- | + | path | string | 是 | 待打开文件的绝对路径。 | + | uid | number | 是 | 新的UID。 | + | gid | number | 是 | 新的GID。 | - 示例: ```js @@ -2347,15 +2347,15 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | filename | string | 是 | 待监视文件的绝对路径。 | - | events | Number | 是 | - 1: 监听文件或者目录是否发生重命名。
- 2:监听文件或者目录内容的是否修改。
- 3:两者都有。 | - | callback | AsyncCallback<number > | 是 | 每发生变化一次,调用一次此函数。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------- | ---- | ---------------------------------------- | + | filename | string | 是 | 待监视文件的绝对路径。 | + | events | Number | 是 | - 1: 监听文件或者目录是否发生重命名。
- 2:监听文件或者目录内容的是否修改。
- 3:两者都有。 | + | callback | AsyncCallback<number > | 是 | 每发生变化一次,调用一次此函数。 | - 返回值: - | 参数名 | 说明 | - | -------- | -------- | + | 参数名 | 说明 | + | -------------------- | ---------- | | [Watcher](#watcher7) | 文件变化监听的实例。 | - 示例: @@ -2372,11 +2372,11 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe **系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.File.FileIO。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| bytesRead | number | 是 | 是 | 实际读取长度。 | -| offset | number | 是 | 是 | 读取数据相对于缓冲区首地址的偏移。 | -| buffer | ArrayBufer | 是 | 是 | 保存读取数据的缓冲区。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | ---------- | ---- | ---- | ----------------- | +| bytesRead | number | 是 | 是 | 实际读取长度。 | +| offset | number | 是 | 是 | 读取数据相对于缓冲区首地址的偏移。 | +| buffer | ArrayBufer | 是 | 是 | 保存读取数据的缓冲区。 | ## Stat @@ -2387,20 +2387,20 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe ### 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| dev | number | 是 | 否 | 标识包含该文件的主设备号。 | -| ino | number | 是 | 否 | 标识该文件。通常同设备上的不同文件的INO不同。 | -| mode | number | 是 | 否 | 表示文件类型及权限,其首 4 位表示文件类型,后 12 位表示权限。各特征位的含义如下:
- 0o170000:可用于获取文件类型的掩码。
- 0o140000:文件是套接字。
- 0o120000:文件是符号链接。
- 0o100000:文件是一般文件。
- 0o060000:文件属于块设备。
- 0o040000:文件是目录。
- 0o020000:文件是字符设备。
- 0o010000:文件是具名管道,即FIFO。
- 0o0700:可用于获取用户权限的掩码。
- 0o0400:用户读,对于普通文件,所有者可读取文件;对于目录,所有者可读取目录项。
- 0o0200:用户写,对于普通文件,所有者可写入文件;对于目录,所有者可创建/删除目录项。
- 0o0100:用户执行,对于普通文件,所有者可执行文件;对于目录,所有者可在目录中搜索给定路径名。
- 0o0070:可用于获取用户组权限的掩码。
- 0o0040:用户组读,对于普通文件,所有用户组可读取文件;对于目录,所有用户组可读取目录项。
- 0o0020:用户组写,对于普通文件,所有用户组可写入文件;对于目录,所有用户组可创建/删除目录项。
- 0o0010:用户组执行,对于普通文件,所有用户组可执行文件;对于目录,所有用户组是否可在目录中搜索给定路径名。
- 0o0007:可用于获取其他用户权限的掩码。
- 0o0004:其他读,对于普通文件,其余用户可读取文件;对于目录,其他用户组可读取目录项。
- 0o0002:其他写,对于普通文件,其余用户可写入文件;对于目录,其他用户组可创建/删除目录项。
- 0o0001:其他执行,对于普通文件,其余用户可执行文件;对于目录,其他用户组可在目录中搜索给定路径名。 | -| nlink | number | 是 | 否 | 文件的硬链接数。 | -| uid | number | 是 | 否 | 文件所有者的ID。 | -| gid | number | 是 | 否 | 文件所有组的ID。 | -| rdev | number | 是 | 否 | 标识包含该文件的从设备号。 | -| size | number | 是 | 否 | 文件的大小,以字节为单位。仅对普通文件有效。 | -| blocks | number | 是 | 否 | 文件占用的块数,计算时块大小按512B计算。 | -| atime | number | 是 | 否 | 上次访问该文件的时间,表示距1970年1月1日0时0分0秒的秒数。 | -| mtime | number | 是 | 否 | 上次修改该文件的时间,表示距1970年1月1日0时0分0秒的秒数。 | -| ctime | number | 是 | 否 | 最近改变文件状态的时间,表示距1970年1月1日0时0分0秒的秒数。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ---------------------------------------- | +| dev | number | 是 | 否 | 标识包含该文件的主设备号。 | +| ino | number | 是 | 否 | 标识该文件。通常同设备上的不同文件的INO不同。 | +| mode | number | 是 | 否 | 表示文件类型及权限,其首 4 位表示文件类型,后 12 位表示权限。各特征位的含义如下:
- 0o170000:可用于获取文件类型的掩码。
- 0o140000:文件是套接字。
- 0o120000:文件是符号链接。
- 0o100000:文件是一般文件。
- 0o060000:文件属于块设备。
- 0o040000:文件是目录。
- 0o020000:文件是字符设备。
- 0o010000:文件是具名管道,即FIFO。
- 0o0700:可用于获取用户权限的掩码。
- 0o0400:用户读,对于普通文件,所有者可读取文件;对于目录,所有者可读取目录项。
- 0o0200:用户写,对于普通文件,所有者可写入文件;对于目录,所有者可创建/删除目录项。
- 0o0100:用户执行,对于普通文件,所有者可执行文件;对于目录,所有者可在目录中搜索给定路径名。
- 0o0070:可用于获取用户组权限的掩码。
- 0o0040:用户组读,对于普通文件,所有用户组可读取文件;对于目录,所有用户组可读取目录项。
- 0o0020:用户组写,对于普通文件,所有用户组可写入文件;对于目录,所有用户组可创建/删除目录项。
- 0o0010:用户组执行,对于普通文件,所有用户组可执行文件;对于目录,所有用户组是否可在目录中搜索给定路径名。
- 0o0007:可用于获取其他用户权限的掩码。
- 0o0004:其他读,对于普通文件,其余用户可读取文件;对于目录,其他用户组可读取目录项。
- 0o0002:其他写,对于普通文件,其余用户可写入文件;对于目录,其他用户组可创建/删除目录项。
- 0o0001:其他执行,对于普通文件,其余用户可执行文件;对于目录,其他用户组可在目录中搜索给定路径名。 | +| nlink | number | 是 | 否 | 文件的硬链接数。 | +| uid | number | 是 | 否 | 文件所有者的ID。 | +| gid | number | 是 | 否 | 文件所有组的ID。 | +| rdev | number | 是 | 否 | 标识包含该文件的从设备号。 | +| size | number | 是 | 否 | 文件的大小,以字节为单位。仅对普通文件有效。 | +| blocks | number | 是 | 否 | 文件占用的块数,计算时块大小按512B计算。 | +| atime | number | 是 | 否 | 上次访问该文件的时间,表示距1970年1月1日0时0分0秒的秒数。 | +| mtime | number | 是 | 否 | 上次修改该文件的时间,表示距1970年1月1日0时0分0秒的秒数。 | +| ctime | number | 是 | 否 | 最近改变文件状态的时间,表示距1970年1月1日0时0分0秒的秒数。 | ### isBlockDevice @@ -2412,8 +2412,8 @@ isBlockDevice(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ---------------- | | boolean | 表示当前目录项是否是块特殊设备。 | - 示例: @@ -2431,8 +2431,8 @@ isCharacterDevice(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ----------------- | | boolean | 表示当前目录项是否是字符特殊设备。 | - 示例: @@ -2450,8 +2450,8 @@ isDirectory(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ------------- | | boolean | 表示当前目录项是否是目录。 | - 示例: @@ -2469,8 +2469,8 @@ isFIFO(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | --------------------- | | boolean | 表示当前目录项是否是 FIFO。 | - 示例: @@ -2488,8 +2488,8 @@ isFile(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | --------------- | | boolean | 表示当前目录项是否是普通文件。 | - 示例: @@ -2507,8 +2507,8 @@ isSocket(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | -------------- | | boolean | 表示当前目录项是否是套接字。 | - 示例: @@ -2526,8 +2526,8 @@ isSymbolicLink(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | --------------- | | boolean | 表示当前目录项是否是符号链接。 | - 示例: @@ -2564,9 +2564,9 @@ stop(callback: AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 以异步方法关闭watcher监听之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------------------- | + | callback | AsyncCallback<void> | 是 | 以异步方法关闭watcher监听之后的回调。 | - 示例: ```js @@ -2590,8 +2590,8 @@ close(): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ------------- | | Promise<void> | 表示异步关闭文件流的结果。 | - 示例: @@ -2614,9 +2614,9 @@ close(callback: AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 异步关闭文件流之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ------------- | + | callback | AsyncCallback<void> | 是 | 异步关闭文件流之后的回调。 | - 示例: ```js @@ -2651,8 +2651,8 @@ flush(): Promise<void> **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------- | ------------- | | Promise<void> | 表示异步刷新文件流的结果。 | - 示例: @@ -2675,9 +2675,9 @@ flush(callback: AsyncCallback<void>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 异步刷新文件流后的回调函数。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | -------------- | + | callback | AsyncCallback<void> | 是 | 异步刷新文件流后的回调函数。 | - 示例: ```js @@ -2717,14 +2717,14 @@ write(buffer: ArrayBuffer | string, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | --------------------- | -------- | | Promise<number> | 实际写入的长度。 | - 示例: @@ -2752,11 +2752,11 @@ write(buffer: ArrayBuffer | string, options: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | - | callback | AsyncCallback<number> | 是 | 异步写入完成后执行的回调函数。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | callback | AsyncCallback<number> | 是 | 异步写入完成后执行的回调函数。 | - 示例: ```js @@ -2784,14 +2784,14 @@ writeSync(buffer: ArrayBuffer | string, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | -------- | | number | 实际写入的长度。 | - 示例: @@ -2814,14 +2814,14 @@ read(buffer: ArrayBuffer, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | 读取的结果。 | - 示例: @@ -2848,11 +2848,11 @@ read(buffer: ArrayBuffer, options: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | - | callback | AsyncCallback<[ReadOut](#readout)> | 是 | 异步从流文件读取数据之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | callback | AsyncCallback<[ReadOut](#readout)> | 是 | 异步从流文件读取数据之后的回调。 | - 示例: ```js @@ -2878,14 +2878,14 @@ readSync(buffer: ArrayBuffer, options?: { **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 | - | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 | + | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。 | - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | -------- | | number | 实际读取的长度。 | - 示例: @@ -2909,8 +2909,8 @@ read(): Promise<Dirent> **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------------------------------- | ------------- | | Promise<[Dirent](#dirent)> | 表示异步读取目录项的结果。 | - 示例: @@ -2933,9 +2933,9 @@ read(callback: AsyncCallback<Dirent>): void **系统能力**:SystemCapability.FileManagement.File.FileIO - 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[Dirent](#dirent)> | 是 | 异步读取下一个目录项之后的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------------- | ---- | ---------------- | + | callback | AsyncCallback<[Dirent](#dirent)> | 是 | 异步读取下一个目录项之后的回调。 | - 示例: ```js @@ -2958,8 +2958,8 @@ readSync(): Dirent **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ----------------- | -------- | | [Dirent](#dirent) | 表示一个目录项。 | - 示例: @@ -2992,9 +2992,9 @@ closeSync(): void ### 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| name | string | 是 | 否 | 目录项的名称。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ------- | +| name | string | 是 | 否 | 目录项的名称。 | ### isBlockDevice @@ -3006,8 +3006,8 @@ isBlockDevice(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ---------------- | | boolean | 表示当前目录项是否是块特殊设备。 | - 示例: @@ -3026,8 +3026,8 @@ isCharacterDevice(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ----------------- | | boolean | 表示当前目录项是否是字符特殊设备。 | - 示例: @@ -3046,8 +3046,8 @@ isDirectory(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ------------- | | boolean | 表示当前目录项是否是目录。 | - 示例: @@ -3066,8 +3066,8 @@ isFIFO(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | --------------- | | boolean | 表示当前目录项是否是FIFO。 | - 示例: @@ -3086,8 +3086,8 @@ isFile(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | --------------- | | boolean | 表示当前目录项是否是普通文件。 | - 示例: @@ -3106,8 +3106,8 @@ isSocket(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | -------------- | | boolean | 表示当前目录项是否是套接字。 | - 示例: @@ -3126,8 +3126,8 @@ isSymbolicLink(): boolean **系统能力**:SystemCapability.FileManagement.File.FileIO - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | --------------- | | boolean | 表示当前目录项是否是符号链接。 | - 示例: diff --git a/zh-cn/application-dev/reference/apis/js-apis-formInfo.md b/zh-cn/application-dev/reference/apis/js-apis-formInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..76a867a9f4d04baa3a4e32e13b7c7125f4ff2f12 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-formInfo.md @@ -0,0 +1,116 @@ +# FormInfo + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +卡片信息。 + +## 导入模块 + +``` +import formInfo from '@ohos.application.formInfo'; +``` + +## 权限 + +无 + +## FormInfo + +卡片信息 + +**系统能力:** + +SystemCapability.Ability.Form + +| 名称 | 读写属性 | 类型 | 描述 | +| ----------- | -------- | -------------------- | ------------------------------------------------------------ | +| bundleName | 只读 | string | 表示卡片所属包的包名 | +| moduleName | 只读 | string | 表示卡片所属模块的模块名 | +| abilityName | 只读 | string | 表示卡片所属的Ability名称 | +| name | 只读 | string | 表示卡片名称 | +| description | 只读 | string | 表示卡片描述 | +| type | 只读 | [FormType](#enum-formtype) | 表示卡片类型,当前支持JS卡片 | +| jsComponentName | 只读 | string | 表示js卡片的组件名 | +| colorMode | 只读 | [ColorMode](#enum-colormode) | 表示卡片颜色模式 | +| isDefault | 只读 | boolean | 表示是否是默认卡片 | +| updateEnabled | 只读 | boolean | 表示卡片是否使能更新 | +| formVisibleNotify | 只读 | string | 表示卡片是否使能可见通知 | +| relatedBundleName | 只读 | string | 表示卡片所属的相关联包名 | +| scheduledUpdateTime | 只读 | string | 表示卡片更新时间 | +| formConfigAbility | 只读 | string | 表示卡片配置ability | +| updateDuration | 只读 | string | 表示卡片更新周期 | +| defaultDimension | 只读 | number | 表示卡片规格 | +| supportDimensions | 只读 | Array<number> | 表示卡片支持的规格 | +| customizeData | 只读 | {[key: string]: [value: string]} | 表示卡片用户数据 | + +## enum FormType + +支持的卡片类型 + +**系统能力:** + +SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| JS | 1 | 卡片类型为JS | + +## enum ColorMode + +卡片支持的颜色模式 + +**系统能力:** + +SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| MODE_AUTO | -1 | 自动模式 | +| MODE_DARK | 0 | 暗色 | +| MODE_LIGHT | 1 | 亮色 | + +## FormStateInfo + +卡片状态信息 + +**系统能力:** + +SystemCapability.Ability.Form + +| 名称 | 读写属性 | 类型 | 描述 | +| ----------- | -------- | -------------------- | ------------------------------------------------------------ | +| formState | 只读 | [FormState](#enum-formstate) | 表示卡片状态 | +| want | 只读 | Want | Want文本内容 | + +## enum FormState + +卡片状态 + +**系统能力:** + +SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| UNKNOWN | -1 | 未知状态 | +| DEFAULT | 0 | 默认状态 | +| READY | 1 | 就绪状态 | + +## enum FormParam + +卡片参数 + +**系统能力:** + +SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | 卡片标识 | +| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | 卡片规格样式 | +| NAME_KEY | "ohos.extra.param.key.form_name" | 卡片名称 | +| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | 卡片所属模块名称 | +| WIDTH_KEY | "ohos.extra.param.key.form_width" | 卡片宽度 | +| HEIGHT_KEY | "ohos.extra.param.key.form_height" | 卡片高度 | +| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | 临时卡片 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-formerror.md b/zh-cn/application-dev/reference/apis/js-apis-formerror.md new file mode 100644 index 0000000000000000000000000000000000000000..e1f423810f0014a01d5344f0c0c9749b8c8aeedb --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-formerror.md @@ -0,0 +1,50 @@ +# FormError + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +卡片错误码。 + +## 导入模块 + +``` +import formError from '@ohos.application.formError'; +``` + +## 权限 + +无 + +## enum FormError + +支持的卡片类型 + +**系统能力:** + +SystemCapability.Ability.Form + +| 名称 | 值 | 说明 | +| ----------- | ---- | ------------ | +| ERR_COMMON | 1 | 默认错误码 | +| ERR_PERMISSION_DENY | 2 | 没有操作权限 | +| ERR_GET_INFO_FAILED | 4 | 查询卡片信息失败 | +| ERR_GET_BUNDLE_FAILED | 5 | 查询应用信息失败 | +| ERR_GET_LAYOUT_FAILED | 6 | 查询布局信息失败 | +| ERR_ADD_INVALID_PARAM | 7 | 无效参数 | +| ERR_CFG_NOT_MATCH_ID | 8 | 卡片ID不匹配 | +| ERR_NOT_EXIST_ID | 9 | 卡片ID不存在 | +| ERR_BIND_PROVIDER_FAILED | 10 | 绑定卡片提供方失败 | +| ERR_MAX_SYSTEM_FORMS | 11 | 系统卡片实例数量超过限制 | +| ERR_MAX_INSTANCES_PER_FORM | 12 | 每张卡片实例数量超过限制 | +| ERR_OPERATION_FORM_NOT_SELF | 13 | 操作非自己应用申请的卡片 | +| ERR_PROVIDER_DEL_FAIL | 14 | 卡片提供方删除卡片失败 | +| ERR_MAX_FORMS_PER_CLIENT | 15 | 使用方申请卡片实例数超过限制 | +| ERR_MAX_SYSTEM_TEMP_FORMS | 16 | 临时卡片实例数超过限制 | +| ERR_FORM_NO_SUCH_MODULE | 17 | 模块不存在 | +| ERR_FORM_NO_SUCH_ABILITY | 18 | ability组件不存在 | +| ERR_FORM_NO_SUCH_DIMENSION | 19 | 卡片尺寸不存在 | +| ERR_FORM_FA_NOT_INSTALLED | 20 | 卡片所在FA未安装 | +| ERR_SYSTEM_RESPONSES_FAILED | 30 | 系统服务响应失败 | +| ERR_FORM_DUPLICATE_ADDED | 31 | 重复添加卡片 | +| ERR_IN_RECOVERY | 36 | 卡片数据覆盖失败 | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-formhost.md b/zh-cn/application-dev/reference/apis/js-apis-formhost.md new file mode 100644 index 0000000000000000000000000000000000000000..c0444d37c5de6b9cf0ec86de507e28b56d2a92d2 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-formhost.md @@ -0,0 +1,945 @@ +# FormHost + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +卡片使用方相关接口。 + +## 导入模块 + +``` +import formHost from '@ohos.application.formHost'; +``` + +## 权限 + +ohos.permission.REQUIRE_FORM + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +## deleteForm + +deleteForm(formId: string, callback: AsyncCallback<void>): void; + +删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.deleteForm(formId, (error, data) => { + if (error) { + console.log('formHost deleteForm, error:' + error.code); + } + }); + ``` + +## deleteForm + +deleteForm(formId: string): Promise<void>; + +删除指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务不再保留有关该卡片的信息。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + ```js + var formId = "12400633174999288"; + formHost.deleteForm(formId).catch((error) => { + console.log('formProvider deleteForm, error:' + JSON.stringify(error)); + }); + ``` + +## releaseForm + +releaseForm(formId: string, callback: AsyncCallback<void>): void; + +释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,但卡片管理器服务仍然保留有关该卡片的缓存信息和存储信息。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.releaseForm(formId, (error, data) => { + if (error) { + console.log('formHost releaseForm, error:' + error.code); + } + }); + ``` + +## releaseForm + +releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void; + +释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------ | ---- | ----------- | + | formId | string | 是 | 卡片标识 | + | isReleaseCache | boolean | 是 | 是否释放缓存 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.releaseForm(formId, true, (error, data) => { + if (error) { + console.log('formHost releaseForm, error:' + error.code); + } + }); + ``` + +## releaseForm + +releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>; + +释放指定的卡片。调用此方法后,应用程序将无法使用该卡片,卡片管理器服务保留有关该卡片的存储信息,可以选择是否保留缓存信息。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------ | ---- | ----------- | + | formId | string | 是 | 卡片标识 | + | isReleaseCache | boolean | 否 | 是否释放缓存 | + + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.releaseForm(formId, true).catch((error) => { + console.log('formProvider releaseForm, error:' + JSON.stringify(error)); + }); + ``` + +## requestForm + +requestForm(formId: string, callback: AsyncCallback<void>): void; + +请求卡片更新。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.requestForm(formId, (error, data) => { + if (error) { + console.log('formHost requestForm, error:' + error.code); + } + }); + ``` + +## requestForm + +requestForm(formId: string): Promise<void>; + +请求卡片更新。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + +**系统能力:** + +SystemCapability.Ability.Form + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.requestForm(formId).catch((error) => { + console.log('formProvider requestForm, error:' + JSON.stringify(error)); + }); + ``` + +## castTempForm + +castTempForm(formId: string, callback: AsyncCallback<void>): void; + +将指定的临时卡片转换为普通卡片。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.castTempForm(formId, (error, data) => { + if (error) { + console.log('formHost castTempForm, error:' + error.code); + } + }); + ``` + +## castTempForm + +castTempForm(formId: string): Promise<void>; + +将指定的临时卡片转换为普通卡片。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + +**系统能力:** + +SystemCapability.Ability.Form + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.castTempForm(formId).catch((error) => { + console.log('formProvider castTempForm, error:' + JSON.stringify(error)); + }); + ``` + +## notifyVisibleForms + +notifyVisibleForms(formId: string, callback: AsyncCallback<void>): void; + +向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.notifyVisibleForms(formId, (error, data) => { + if (error) { + console.log('formHost notifyVisibleForms, error:' + error.code); + } + }); + ``` + +## notifyVisibleForms + +notifyVisibleForms(formId: string): Promise<void>; + +向卡片框架发送通知以使指定的卡片可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + +**系统能力:** + +SystemCapability.Ability.Form + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.notifyVisibleForms(formId).catch((error) => { + console.log('formProvider notifyVisibleForms, error:' + JSON.stringify(error)); + }); + ``` + +## notifyInvisibleForms + +notifyInvisibleForms(formId: string, callback: AsyncCallback<void>): void; + +向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.notifyInvisibleForms(formId, (error, data) => { + if (error) { + console.log('formHost notifyInvisibleForms, error:' + error.code); + } + }); + ``` + +## notifyInvisibleForms + +notifyInvisibleForms(formId: string): Promise<void>; + +向卡片框架发送通知以使指定的卡片不可见。该方法调用成功后,会调用onVisibilityChange通知卡片提供方。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + +**系统能力:** + +SystemCapability.Ability.Form + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.notifyInvisibleForms(formId).catch((error) => { + console.log('formProvider notifyInvisibleForms, error:' + JSON.stringify(error)); + }); + ``` + +## enableFormsUpdate + +enableFormsUpdate(formId: string, callback: AsyncCallback<void>): void; + +向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.enableFormsUpdate(formId, (error, data) => { + if (error) { + console.log('formHost enableFormsUpdate, error:' + error.code); + } + }); + ``` + +## enableFormsUpdate + +enableFormsUpdate(formId: string): Promise<void>; + +向卡片框架发送通知以使指定的卡片可以更新。该方法调用成功后,卡片刷新状态设置为使能,卡片可以接收来自卡片提供方的更新。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + +**系统能力:** + +SystemCapability.Ability.Form + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.enableFormsUpdate(formId).catch((error) => { + console.log('formProvider enableFormsUpdate, error:' + JSON.stringify(error)); + }); + ``` + +## disableFormsUpdate + +disableFormsUpdate(formId: string, callback: AsyncCallback<void>): void; + +向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.disableFormsUpdate(formId, (error, data) => { + if (error) { + console.log('formHost disableFormsUpdate, error:' + error.code); + } + }); + ``` + +## disableFormsUpdate + +disableFormsUpdate(formId: string): Promise<void>; + +向卡片框架发送通知以使指定的卡片不可以更新。该方法调用成功后,卡片刷新状态设置为去使能,卡片不可以接收来自卡片提供方的更新。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formId | string | 是 | 卡片标识 | + +**系统能力:** + +SystemCapability.Ability.Form + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.disableFormsUpdate(formId).catch((error) => { + console.log('formProvider disableFormsUpdate, error:' + JSON.stringify(error)); + }); + ``` + +## isSystemReady + +isSystemReady(callback: AsyncCallback<void>): void; + +检查系统是否准备好。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.isSystemReady((error, data) => { + if (error) { + console.log('formHost isSystemReady, error:' + error.code); + } + }); + ``` + +## isSystemReady + +isSystemReady(): Promise<void>; + +检查系统是否准备好。 + +**系统能力:** + +SystemCapability.Ability.Form + +**示例:** + + ```js + var formId = "12400633174999288"; + formHost.isSystemReady().catch((error) => { + console.log('formProvider isSystemReady, error:' + JSON.stringify(error)); + }); + ``` + +## getAllFormsInfo + +getAllFormsInfo(callback: AsyncCallback<Array<FormInfo>>): void; + +获取设备上所有应用提供的卡片信息。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息 | + +**示例:** + + ```js + formHost.getAllFormsInfo((error, data) => { + if (error) { + console.log('formHost getAllFormsInfo, error:' + error.code); + } + }); + ``` + +## getAllFormsInfo + +getAllFormsInfo(): Promise<Array<FormInfo>>; + +获取设备上所有应用提供的卡片信息。 + +**系统能力:** + +SystemCapability.Ability.Form + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise实例,用于获取异步返回查询到的卡片信息 | + +**示例:** + + ```js + formHost.getAllFormsInfo().catch((error) => { + console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error)); + }); + ``` + +## getFormsInfo + +getFormsInfo(bundleName: string, callback: AsyncCallback<Array<FormInfo>>): void; + +获取设备上指定应用程序提供的卡片信息。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | bundleName | string | 是 | 要查询的应用程序包名称 | + | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息 | + +**示例:** + + ```js + formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => { + if (error) { + console.log('formHost getFormsInfo, error:' + error.code); + } + }); + ``` + +## getFormsInfo + +getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<FormInfo>>): void; + +获取设备上指定应用程序提供的卡片信息。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | bundleName | string | 是 | 要查询的应用程序包名称 | + | moduleName | string | 是 | 要查询的模块名称 | + | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | 是 | callback形式返回查询到的卡片信息 | + +**示例:** + + ```js + formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => { + if (error) { + console.log('formHost getFormsInfo, error:' + error.code); + } + }); + ``` + +## getFormsInfo + +getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<FormInfo>>; + +获取设备上所有应用提供的卡片信息。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | bundleName | string | 是 | 要查询的应用程序包名称 | + | moduleName | string | 否 | 要查询的模块名称 | + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise实例,用于获取异步返回查询到的卡片信息 | + +**示例:** + + ```js + formHost.getAllFormsInfo().catch((error) => { + console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error)); + }); + ``` + +## deleteInvalidForms + +deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void; + +根据列表删除应用程序的无效卡片。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formIds | Array<string> | 是 | 卡片标识列表 | + | callback | AsyncCallback<number> | 是 | callback形式返回删除的卡片个数 | + +**示例:** + + ```js + var formIds = new Array("12400633174999288", "12400633174999289"); + formHost.deleteInvalidForms(formIds, (error, data) => { + if (error) { + console.log('formHost deleteInvalidForms, error:' + error.code); + } + }); + ``` + +## deleteInvalidForms + +function deleteInvalidForms(formIds: Array<string>): Promise<number>; + +根据列表删除应用程序的无效卡片。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formIds | Array<string> | 是 | 卡片标识列表 | + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回删除的卡片个数 | + +**系统能力:** + +SystemCapability.Ability.Form + +**示例:** + + ```js + var formIds = new Array("12400633174999288", "12400633174999289"); + formHost.deleteInvalidForms(formIds).catch((error) => { + console.log('formProvider deleteInvalidForms, error:' + JSON.stringify(error)); + }); + ``` + +## acquireFormState + +acquireFormState(want: Want, callback: AsyncCallback<FormStateInfo>): void; + +获取卡片状态 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | want | [Want](js-apis-featureAbility.md#want) | 是 | 查询卡片状态时携带的want信息 | + | callback | AsyncCallback<[FormStateInfo](./js-apis-formInfo.md#formstateinfo)> | 是 | callback形式返回卡片状态 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "com.extreme.test.MainAbility" + }; + formHost.acquireFormState(want, (error, data) => { + if (error) { + console.log('formHost acquireFormState, error:' + error.code); + } + }); + ``` + +## acquireFormState + +function acquireFormState(formIds: Array<string>): Promise<formInfo.FormStateInfo>; + +根据列表删除应用程序的无效卡片。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formIds | Array<string> | 是 | 卡片标识列表 | + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<[FormStateInfo](./js-apis-formInfo.md#formstateinfo)> | Promise实例,用于返回卡片状态 | + +**系统能力:** + +SystemCapability.Ability.Form + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "com.extreme.test.MainAbility" + }; + formHost.acquireFormState(want).catch((error) => { + console.log('formProvider acquireFormState, error:' + JSON.stringify(error)); + }); + ``` + +## on("formUninstall") + +on(type: "formUninstall", callback: Callback<string>): void; + +获取卡片状态 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | + | callback | Callback<string> | 是 | 接口本身调用的回调方法 | + +**示例:** + + ```js + formHost.on("formUninstall", (error, data) => { + if (error) { + console.log('formHost on formUninstall, error:' + error.code); + } + }); + ``` + +## off("formUninstall") + +off(type: "formUninstall", callback: Callback<string>): void; + +获取卡片状态 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | type | string | 是 | 填写"formUninstall",表示卡片卸载事件 | + | callback | Callback<string> | 是 | 接口本身调用的回调方法 | + +**示例:** + + ```js + formHost.off("formUninstall", (error, data) => { + if (error) { + console.log('formHost off formUninstall, error:' + error.code); + } + }); + ``` + +## notifyFormsVisible + +notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void; + +通知卡片是否可见。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formIds | Array<string> | 是 | 卡片标识列表 | + | isVisible | boolean | 是 | 是否可见 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formIds = new Array("12400633174999288", "12400633174999289"); + formHost.notifyFormsVisible(formIds, true, (error, data) => { + if (error) { + console.log('formHost notifyFormsVisible, error:' + error.code); + } + }); + ``` + +## notifyFormsVisible + +notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void>; + +通知卡片是否可见。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formIds | Array<string> | 是 | 卡片标识列表 | + | isVisible | boolean | 是 | 是否可见 | + +**示例:** + + ```js + var formIds = new Array("12400633174999288", "12400633174999289"); + formHost.notifyFormsVisible(formIds, true).catch((error) => { + console.log('formProvider notifyFormsVisible, error:' + JSON.stringify(error)); + }); + ``` + +## notifyFormsEnableUpdate + +notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void; + +通知卡片是否启用更新状态。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formIds | Array<string> | 是 | 卡片标识列表 | + | isEnableUpdate | boolean | 是 | 是否使能更新 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | + +**示例:** + + ```js + var formIds = new Array("12400633174999288", "12400633174999289"); + formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => { + if (error) { + console.log('formHost notifyFormsEnableUpdate, error:' + error.code); + } + }); + ``` + +## notifyFormsEnableUpdate + +notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void>; + +通知卡片是否启用更新状态。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------- | + | formIds | Array<string> | 是 | 卡片标识列表 | + | isEnableUpdate | boolean | 是 | 是否使能更新 | + +**示例:** + + ```js + var formIds = new Array("12400633174999288", "12400633174999289"); + formHost.notifyFormsEnableUpdate(formIds, true).catch((error) => { + console.log('formProvider notifyFormsEnableUpdate, error:' + JSON.stringify(error)); + }); + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md index b6f721e33bb056b29d08d0cd45e6d36dd32a4000..166c2c8b79619a8f4ee33b840c5a4be22cf1cb5d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md @@ -17,7 +17,7 @@ import formProvider from '@ohos.application.formProvider'; ## setFormNextRefreshTime -setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback): void; +setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void; 设置指定卡片的下一次更新时间。 @@ -31,6 +31,7 @@ SystemCapability.Ability.Form | ------ | ------ | ---- | ------------------------------------- | | formId | string | 是 | 卡片标识 | | minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | **示例:** @@ -45,7 +46,7 @@ SystemCapability.Ability.Form ## setFormNextRefreshTime -setFormNextRefreshTime(formId: string, minute: number): Promise; +setFormNextRefreshTime(formId: string, minute: number): Promise<void>; 设置指定卡片的下一次更新时间,以promise方式返回。 @@ -71,7 +72,7 @@ SystemCapability.Ability.Form ## updateForm -updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback): void; +updateForm(formId: string, formBindingData: FormBindingData, callback: AsyncCallback<void>): void; 更新指定的卡片。 @@ -85,6 +86,7 @@ SystemCapability.Ability.Form | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | | formId | string | 是 | 请求更新的卡片标识 | | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据 | + | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | **示例:** @@ -101,7 +103,7 @@ SystemCapability.Ability.Form ## updateForm -updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise; +updateForm(formId: string, formBindingData: FormBindingData): Promise<void>; 更新指定的卡片,以promise方式返回。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md index 7e2dfcf0d20fda4ea26e391b28752bf98fe8cc8a..cffd137ac8152bcdad774d7135a2cdb23f22ddc0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md @@ -195,7 +195,7 @@ let result = hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); remove(key: K): V -删除指定key所对应元素。。 +删除指定key所对应元素。 **参数:** @@ -333,8 +333,8 @@ forEach(callbackfn: (value?: V, key?: K, map?: HashMap) => void, thisArg?: callbackfn的参数说明: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | V | 是 | 当前遍历到的元素键值对的值。 | -| key | K | 是 | 当前遍历到的元素键值对的键。 | +| value | V | 否 | 当前遍历到的元素键值对的值。 | +| key | K | 否 | 当前遍历到的元素键值对的键。 | | map | HashMap | 否 | 当前调用forEach方法的实例对象。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashset.md b/zh-cn/application-dev/reference/apis/js-apis-hashset.md index 685929bfc3552b08ab982bd1c120c215f52b6f2b..d8c3bfca464ec2ec59a349adf9492840bc139684 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashset.md @@ -198,7 +198,7 @@ forEach(callbackfn: (value?: T, key?: T, set?: HashSet<T>) => void, thisAr callbackfn的参数说明: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 当前遍历到的元素键值对的值。 | +| value | T | 否 | 当前遍历到的元素键值对的值。 | | key | T | 否 | 当前遍历到的元素键值对的值(和value相同)。 | | set | HashSet<T> | 否 | 当前调用forEach方法的实例对象。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md b/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md index 421c612be614aa96a7833af1a4f84f6a58011f17..4f8afa59d5757c72e2510c811e8847ba83f3a38b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md @@ -21,12 +21,12 @@ write(eventName: string, eventType: EventType, keyValues: object, callback: Asyn **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| eventName | string | 是 | 应用事件名称。 | -| eventType | [EventType](#eventtype) | 是 | 应用事件类型。 | -| keyValues | object | 是 | 应用事件的参数,key类型只能为string,value类型只能为string、number、boolean、Array(数组数据类型只能为string、number、boolean)。 | -| callback | AsyncCallback<void> | 否 | 回调函数,可以在回调函数中处理接口返回值。
- 返回值为0表示事件校验成功,事件正常异步写入事件文件;
- 大于0表示事件校验存在异常参数,在忽略异常参数后将事件异步写入事件文件;
- 小于0表示事件校验失败,不将事件写入事件文件。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| eventName | string | 是 | 应用事件名称。
由开发者自定义。事件名称在48个字符以内,有效的字符是0-9、a-z、下划线,只能以字母开头。 | +| eventType | [EventType](#eventtype) | 是 | 应用事件类型。 | +| keyValues | object | 是 | 事件参数键值对,如果是变长参数类型,则依次输入事件的参数名与参数值。如果是Json对象类型,则Json对象的key是事件的参数名,value是事件的参数值。
- key类型只能为string,value类型只能为string、number、boolean、Array(数组数据类型只能为string、number、boolean)。
- 事件的参数个数必须小于等于32。
- 参数名在16个字符以内,有效的字符是0-9、a-z、下划线,只能以字母开头,不能以下划线结尾。
- string类型参数值在8*1024个字符内。
- Array类型参数值的元素个数必须在100个以内,超出时会进行截断处理。 | +| callback | AsyncCallback<void> | 否 | 回调函数,可以在回调函数中处理接口返回值。
- 返回值为0表示事件校验成功,事件正常异步写入事件文件;
- 大于0表示事件校验存在异常参数,在忽略异常参数后将事件异步写入事件文件;
- 小于0表示事件校验失败,不将事件写入事件文件。 | **示例:** @@ -54,16 +54,16 @@ write(eventName: string, eventType: EventType, keyValues: object): Promise<vo **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| eventName | string | 是 | 应用事件名称。 | -| eventType | [EventType](#eventtype) | 是 | 应用事件类型。 | -| keyValues | object | 是 | 应用事件的参数,key类型只能为string,value类型只能为string、number、boolean、Array(数组数据类型只能为string、number、boolean)。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ----------------------- | ---- | ------------------------------------------------------------ | +| eventName | string | 是 | 应用事件名称。
由开发者自定义。事件名称在48个字符以内,有效的字符是0-9、a-z、下划线,只能以字母开头。 | +| eventType | [EventType](#eventtype) | 是 | 应用事件类型。 | +| keyValues | object | 是 | 事件参数键值对,如果是变长参数类型,则依次输入事件的参数名与参数值。如果是Json对象类型,则Json对象的key是事件的参数名,value是事件的参数值。
- key类型只能为string,value类型只能为string、number、boolean、Array(数组数据类型只能为string、number、boolean)。
- 事件的参数个数必须小于等于32。
- 参数名在16个字符以内,有效的字符是0-9、a-z、下划线,只能以字母开头,不能以下划线结尾。
- string类型参数值在8*1024个字符内。
- Array类型参数值的元素个数必须在100个以内,超出时会进行截断处理。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ------------------------------------------------------------ | | Promise<void> | Promise实例,可以在其then()、catch()方法中分别对事件写入成功、写入异常的情况进行回调处理。 | **示例:** @@ -90,14 +90,14 @@ configure(config: ConfigOption): boolean **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| config | [ConfigOption](#configoption) | 是 | 应用事件打点配置项对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------------------------- | ---- | ------------------------ | +| config | [ConfigOption](#configoption) | 是 | 应用事件打点配置项对象。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------- | ----------------------------------------------------------- | | boolean | 配置结果,true 表示配置成功,false 表示配置失败。 | **示例:** @@ -120,10 +120,10 @@ hiAppEvent.configure({ **系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.HiAppEvent。 -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| disable | boolean | 否 | 应用打点功能开关。配置值为true表示关闭打点功能,false表示不关闭打点功能。 | -| maxStorage | string | 否 | 打点数据本地存储文件所在目录的配额大小,默认限额为“10M”。所在目录大小超出限额后会对目录进行清理操作,会按从旧到新的顺序逐个删除打点数据文件,直到目录大小不超出限额时停止。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------- | ---- | ------------------------------------------------------------ | +| disable | boolean | 否 | 应用打点功能开关。配置值为true表示关闭打点功能,false表示不关闭打点功能。 | +| maxStorage | string | 否 | 打点数据本地存储文件所在目录的配额大小,默认限额为“10M”。所在目录大小超出限额后会对目录进行清理操作,会按从旧到新的顺序逐个删除打点数据文件,直到目录大小不超出限额时停止。 | ## EventType @@ -132,12 +132,12 @@ hiAppEvent.configure({ **系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.HiAppEvent。 -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| FAULT | 1 | 故障类型事件。 | -| STATISTIC | 2 | 统计类型事件。 | -| SECURITY | 3 | 安全类型事件。 | -| BEHAVIOR | 4 | 行为类型事件。 | +| 名称 | 默认值 | 说明 | +| --------- | ------ | -------------- | +| FAULT | 1 | 故障类型事件。 | +| STATISTIC | 2 | 统计类型事件。 | +| SECURITY | 3 | 安全类型事件。 | +| BEHAVIOR | 4 | 行为类型事件。 | ## Event @@ -146,11 +146,11 @@ hiAppEvent.configure({ **系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.HiAppEvent。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| USER_LOGIN | string | 是 | 否 | 用户登录事件。 | -| USER_LOGOUT | string | 是 | 否 | 用户登出事件。 | -| DISTRIBUTED_SERVICE_START | string | 是 | 否 | 分布式服务启动事件。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------------------------- | -------- | ---- | ---- | -------------------- | +| USER_LOGIN | string | 是 | 否 | 用户登录事件。 | +| USER_LOGOUT | string | 是 | 否 | 用户登出事件。 | +| DISTRIBUTED_SERVICE_START | string | 是 | 否 | 分布式服务启动事件。 | ## Param @@ -159,8 +159,8 @@ hiAppEvent.configure({ **系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.HiAppEvent。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| USER_ID | string | 是 | 否 | 用户自定义ID。 | -| DISTRIBUTED_SERVICE_NAME | string | 是 | 否 | 分布式服务名称。 | -| DISTRIBUTED_SERVICE_INSTANCE_ID | string | 是 | 否 | 分布式服务实例ID。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------------------------------- | -------- | ---- | ---- | ------------------ | +| USER_ID | string | 是 | 否 | 用户自定义ID。 | +| DISTRIBUTED_SERVICE_NAME | string | 是 | 否 | 分布式服务名称。 | +| DISTRIBUTED_SERVICE_INSTANCE_ID | string | 是 | 否 | 分布式服务实例ID。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-i18n.md b/zh-cn/application-dev/reference/apis/js-apis-i18n.md index 2ea09cf3a29dd5a30359fc112f19828c3147de24..8eebc8cccb5b0c5432225a68eba07a045405961f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-i18n.md +++ b/zh-cn/application-dev/reference/apis/js-apis-i18n.md @@ -2,7 +2,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> +> > - I18N模块包含国际化能力增强接口(未在ECMA 402中定义)。 @@ -21,19 +21,19 @@ getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): st **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | language | string | 是 | 指定语言。 | - | locale | string | 是 | 显示指定语言的区域ID。 | - | sentenceCase | boolean | 否 | 本地化显示文本是否要首字母大写。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------- | ---- | ---------------- | +| language | string | 是 | 指定语言。 | +| locale | string | 是 | 显示指定语言的区域ID。 | +| sentenceCase | boolean | 否 | 本地化显示文本是否要首字母大写。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 指定语言的本地化显示文本。 | +**返回值:** +| 类型 | 说明 | +| ------ | ------------- | +| string | 指定语言的本地化显示文本。 | -- 示例: +**示例:** ``` i18n.getDisplayLanguage("zh", "en-GB", true); i18n.getDisplayLanguage("zh", "en-GB"); @@ -48,19 +48,19 @@ getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): stri **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | country | string | 是 | 指定国家。 | - | locale | string | 是 | 显示指定国家的区域ID。 | - | sentenceCase | boolean | 否 | 本地化显示文本是否要首字母大写。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------- | ---- | ---------------- | +| country | string | 是 | 指定国家。 | +| locale | string | 是 | 显示指定国家的区域ID。 | +| sentenceCase | boolean | 否 | 本地化显示文本是否要首字母大写。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 指定国家的本地化显示文本。 | +**返回值:** +| 类型 | 说明 | +| ------ | ------------- | +| string | 指定国家的本地化显示文本。 | -- 示例: +**示例:** ``` i18n.getDisplayCountry("zh-CN", "en-GB", true); i18n.getDisplayCountry("zh-CN", "en-GB"); @@ -75,17 +75,17 @@ isRTL(locale: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | locale | string | 指定区域ID。 | +**参数:** +| 参数名 | 类型 | 说明 | +| ------ | ------ | ------- | +| locale | string | 指定区域ID。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | true表示该locale从右至左显示语言;false表示该locale从左至右显示语言。 | +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | true表示该locale从右至左显示语言;false表示该locale从左至右显示语言。 | -- 示例: +**示例:** ``` i18n.isRTL("zh-CN");// 中文不是RTL语言,返回false i18n.isRTL("ar-EG");// 阿语是RTL语言,返回true @@ -100,12 +100,12 @@ getSystemLanguage(): string **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 系统语言ID。 | +**返回值:** +| 类型 | 说明 | +| ------ | ------- | +| string | 系统语言ID。 | -- 示例: +**示例:** ``` i18n.getSystemLanguage(); ``` @@ -119,17 +119,17 @@ setSystemLanguage(language: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | language | string | 语言ID。 | +**参数:** +| 参数名 | 类型 | 说明 | +| -------- | ------ | ----- | +| language | string | 语言ID。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true,表示系统语言设置成功;返回false,表示系统语言设置失败。 | +**返回值:** +| 类型 | 说明 | +| ------- | ------------------------------------- | +| boolean | 返回true,表示系统语言设置成功;返回false,表示系统语言设置失败。 | -- 示例: +**示例:** ``` i18n.setSystemLanguage('zh'); ``` @@ -137,18 +137,18 @@ setSystemLanguage(language: string): boolean ## i18n.getSystemLanguages -getSystemLanguages(): Array +getSystemLanguages(): Array<string> 获取系统支持的语言列表。 **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Array | 系统支持的语言ID列表。 | +**返回值:** +| 类型 | 说明 | +| ------------------- | ------------ | +| Array<string> | 系统支持的语言ID列表。 | -- 示例: +**示例:** ``` i18n.getSystemLanguages(); ``` @@ -156,23 +156,23 @@ getSystemLanguages(): Array ## i18n.getSystemCountries -getSystemCountries(language: string): Array +getSystemCountries(language: string): Array<string> 获取针对输入语言系统支持的区域列表。 **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | language | string | 语言ID。 | +**参数:** +| 参数名 | 类型 | 说明 | +| -------- | ------ | ----- | +| language | string | 语言ID。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Array | 系统支持的区域ID列表。 | +**返回值:** +| 类型 | 说明 | +| ------------------- | ------------ | +| Array<string> | 系统支持的区域ID列表。 | -- 示例: +**示例:** ``` i18n.getSystemCountries('zh'); ``` @@ -186,12 +186,12 @@ getSystemRegion(): string **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 系统地区ID。 | +**返回值:** +| 类型 | 说明 | +| ------ | ------- | +| string | 系统地区ID。 | -- 示例: +**示例:** ``` i18n.getSystemRegion(); ``` @@ -205,17 +205,17 @@ setSystemRegion(region: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | region | string | 地区ID。 | +**参数:** +| 参数名 | 类型 | 说明 | +| ------ | ------ | ----- | +| region | string | 地区ID。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true,表示系统区域设置成功;返回false,表示系统区域设置失败。 | +**返回值:** +| 类型 | 说明 | +| ------- | ------------------------------------- | +| boolean | 返回true,表示系统区域设置成功;返回false,表示系统区域设置失败。 | -- 示例: +**示例:** ``` i18n.setSystemRegion(); ``` @@ -229,12 +229,12 @@ getSystemLocale(): string **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 系统区域ID。 | +**返回值:** +| 类型 | 说明 | +| ------ | ------- | +| string | 系统区域ID。 | -- 示例: +**示例:** ``` i18n.getSystemLocale(); ``` @@ -248,17 +248,17 @@ setSystemLocale(locale: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | locale | string | 指定区域ID,例如zh-CN。 | +**参数:** +| 参数名 | 类型 | 说明 | +| ------ | ------ | --------------- | +| locale | string | 指定区域ID,例如zh-CN。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true,表示系统Locale设置成功;返回false,表示系统Locale设置失败。 | +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true,表示系统Locale设置成功;返回false,表示系统Locale设置失败。 | -- 示例: +**示例:** ``` i18n.setSystemLocale('zh-CN'); ``` @@ -272,18 +272,18 @@ isSuggested(language: string, region?: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | language | string | 是 | 合法的语言ID,例如zh。 | - | region | string | 否 | 合法的地区ID,例如CN | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------- | +| language | string | 是 | 合法的语言ID,例如zh。 | +| region | string | 否 | 合法的地区ID,例如CN | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true,表示当前语言和地区匹配;返回false,表示当前语言和地区不匹配。 | +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true,表示当前语言和地区匹配;返回false,表示当前语言和地区不匹配。 | -- 示例: +**示例:** ``` i18n.isSuggested('zh', 'CN'); ``` @@ -297,18 +297,18 @@ getCalendar(locale: string, type? : string): Calendar **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locale | string | 是 | 合法的locale值,例如zh-Hans-CN。 | - | type | string | 否 | 合法的日历类型,目前合法的类型有buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, japanese, persian。当type没有给出时,采用区域默认的日历类型。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------------- | +| locale | string | 是 | 合法的locale值,例如zh-Hans-CN。 | +| type | string | 否 | 合法的日历类型,目前合法的类型有buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, japanese, persian。当type没有给出时,采用区域默认的日历类型。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | [Calendar](#calendar8) | 日历对象。 | +**返回值:** +| 类型 | 说明 | +| ---------------------- | ----- | +| [Calendar](#calendar8) | 日历对象。 | -- 示例: +**示例:** ``` i18n.getCalendar("zh-Hans", "gregory"); ``` @@ -325,12 +325,12 @@ setTime(date: Date): void **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | date | Date | 是 | 将要设置的日历对象的内部时间日期。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ---- | ---- | ----------------- | +| date | Date | 是 | 将要设置的日历对象的内部时间日期。 | -- 示例: +**示例:** ``` var calendar = I18n.getCalendar("en-US", "gregory"); var date = new Date(2021, 10, 7, 8, 0, 0, 0); @@ -346,12 +346,12 @@ setTime(time: number): void **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | time | number | 是 | time为从1970.1.1 00:00:00 GMT逝去的毫秒数。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ---------------------------------------- | +| time | number | 是 | time为从1970.1.1 00:00:00 GMT逝去的毫秒数。 | -- 示例: +**示例:** ``` var calendar = I18n.getCalendar("en-US", "gregory"); calendar.setTime(10540800000); @@ -366,17 +366,17 @@ set(year: number, month: number, date:number, hour?: number, minute?: number, se **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | year | number | 是 | 设置的年。 | - | month | number | 是 | 设置的月。 | - | date | number | 是 | 设置的日。 | - | hour | number | 否 | 设置的小时。 | - | minute | number | 否 | 设置的分钟。 | - | second | number | 否 | 设置的秒。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------ | +| year | number | 是 | 设置的年。 | +| month | number | 是 | 设置的月。 | +| date | number | 是 | 设置的日。 | +| hour | number | 否 | 设置的小时。 | +| minute | number | 否 | 设置的分钟。 | +| second | number | 否 | 设置的秒。 | -- 示例: +**示例:** ``` var calendar = i18n.getCalendar("zh-Hans"); calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 @@ -391,12 +391,12 @@ setTimeZone(timezone: string): void **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | timezone | string | 是 | 设置的时区id,如“Asia/Shanghai”。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------------------- | +| timezone | string | 是 | 设置的时区id,如“Asia/Shanghai”。 | -- 示例: +**示例:** ``` var calendar = i18n.getCalendar("zh-Hans"); calendar.setTimeZone("Asia/Shanghai"); @@ -411,12 +411,12 @@ getTimeZone(): string **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 日历对象的时区id。 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------- | +| string | 日历对象的时区id。 | -- 示例: +**示例:** ``` var calendar = i18n.getCalendar("zh-Hans"); calendar.setTimeZone("Asia/Shanghai"); @@ -432,12 +432,12 @@ getFirstDayOfWeek(): number **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 获取一周的起始日,1代表周日,7代表周六。 | +**返回值:** +| 类型 | 说明 | +| ------ | --------------------- | +| number | 获取一周的起始日,1代表周日,7代表周六。 | -- 示例: +**示例:** ``` var calendar = I18n.getCalendar("en-US", "gregory"); calendar.getFirstDayOfWeek(); @@ -452,12 +452,12 @@ setFirstDayOfWeek(value: number): void **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | number | 否 | 设置一周的起始日,1代表周日,7代表周六。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | --------------------- | +| value | number | 否 | 设置一周的起始日,1代表周日,7代表周六。 | -- 示例: +**示例:** ``` var calendar = i18n.getCalendar("zh-Hans"); calendar.setFirstDayOfWeek(0); @@ -472,12 +472,12 @@ getMinimalDaysInFirstWeek(): number **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 一年中第一周的最小天数。 | +**返回值:** +| 类型 | 说明 | +| ------ | ------------ | +| number | 一年中第一周的最小天数。 | -- 示例: +**示例:** ``` var calendar = i18n.getCalendar("zh-Hans"); calendar.getMinimalDaysInFirstWeek(); @@ -492,12 +492,12 @@ setMinimalDaysInFirstWeek(value: number): void **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | number | 否 | 一年中第一周的最小天数。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ------------ | +| value | number | 否 | 一年中第一周的最小天数。 | -- 示例: +**示例:** ``` var calendar = i18n.getCalendar("zh-Hans"); calendar.setMinimalDaysInFirstWeek(3); @@ -512,17 +512,17 @@ get(field: string): number **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | field | string | 是 | 通过field来获取日历对象相应的值。目前支持的field值有 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 | 是 | 通过field来获取日历对象相应的值。目前支持的field值有 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。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 与field相关联的值,如当前Calendar对象的内部日期的年份为1990,get("year")返回1990。 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------------------------------------- | +| number | 与field相关联的值,如当前Calendar对象的内部日期的年份为1990,get("year")返回1990。 | -- 示例: +**示例:** ``` var calendar = i18n.getCalendar("zh-Hans"); calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 @@ -538,17 +538,17 @@ getDisplayName(locale: string): string **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locale | string | 是 | locale指定获取哪个区域下该calendar的名字,如buddhist在en-US上显示的名称为“Buddhist Calendar”。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------------- | +| locale | string | 是 | locale指定获取哪个区域下该calendar的名字,如buddhist在en-US上显示的名称为“Buddhist Calendar”。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 日历在locale所指示的区域的名字。 | +**返回值:** +| 类型 | 说明 | +| ------ | ------------------- | +| string | 日历在locale所指示的区域的名字。 | -- 示例: +**示例:** ``` var calendar = i18n.getCalendar("en-US", "buddhist"); calendar.getDisplayName("zh"); // 佛历 @@ -563,17 +563,17 @@ isWeekend(date?: Date): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | date | Date | 否 | 判断日期在日历中是否是周末。如果date没有给出,判断calendar当前日期是否为周末。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ---- | ---- | ---------------------------------------- | +| date | Date | 否 | 判断日期在日历中是否是周末。如果date没有给出,判断calendar当前日期是否为周末。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 当所判断的日期为周末时,返回 true,否则返回false。 | +**返回值:** +| 类型 | 说明 | +| ------- | ----------------------------------- | +| boolean | 当所判断的日期为周末时,返回 true,否则返回false。 | -- 示例: +**示例:** ``` var calendar = i18n.getCalendar("zh-Hans"); calendar.setTime(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00 @@ -595,12 +595,12 @@ constructor(country: string, options?: PhoneNumberFormatOptions) **系统能力**:SystemCapability.Global.I18n 参数: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| country | string | 是 | 表示电话号码所属国家或地区代码。 | -| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | 否 | 电话号码格式化对象的相关选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ---------------- | +| country | string | 是 | 表示电话号码所属国家或地区代码。 | +| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | 否 | 电话号码格式化对象的相关选项。 | -- 示例: +**示例:** ``` var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"}); ``` @@ -614,17 +614,17 @@ isValidNumber(number: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | number | string | 是 | 待判断的电话号码。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | --------- | +| number | string | 是 | 待判断的电话号码。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示电话号码的格式正确,返回false表示电话号码的格式错误。 | +**返回值:** +| 类型 | 说明 | +| ------- | ------------------------------------- | +| boolean | 返回true表示电话号码的格式正确,返回false表示电话号码的格式错误。 | -- 示例: +**示例:** ``` var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); phonenumberfmt.isValidNumber("15812312312"); @@ -639,17 +639,17 @@ format(number: string): string **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | number | string | 是 | 待格式化的电话号码。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------- | +| number | string | 是 | 待格式化的电话号码。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 格式化后的电话号码。 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------- | +| string | 格式化后的电话号码。 | -- 示例: +**示例:** ``` var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); phonenumberfmt.format("15812312312"); @@ -662,9 +662,9 @@ format(number: string): string **系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| type | string | 是 | 是 | 表示对电话号码格式化的类型,取值范围:"E164", "INTERNATIONAL", "NATIONAL", "RFC3966"。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ---------------------------------------- | +| type | string | 是 | 是 | 表示对电话号码格式化的类型,取值范围:"E164", "INTERNATIONAL", "NATIONAL", "RFC3966"。 | ## UnitInfo8+ @@ -673,10 +673,10 @@ format(number: string): string **系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| unit | string | 是 | 是 | 单位的名称,如:"meter", "inch", "cup"等。 | -| measureSystem | string | 是 | 是 | 单位的度量体系,取值包括:"SI", "US", "UK"。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------------- | ------ | ---- | ---- | ---------------------------------------- | +| unit | string | 是 | 是 | 单位的名称,如:"meter", "inch", "cup"等。 | +| measureSystem | string | 是 | 是 | 单位的度量体系,取值包括:"SI", "US", "UK"。 | ## Util8+ @@ -690,21 +690,21 @@ unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fromUnit | [UnitInfo](#unitinfo8) | 是 | 要被转换的单位。 | - | toUnit | [UnitInfo](#unitinfo8) | 是 | 要转换为的单位。 | - | value | number | 是 | 要被转换的单位的数量值。 | - | locale | string | 是 | 格式化时使用的区域参数,如:zh-Hans-CN。 | - | style | string | 否 | 格式化使用的风格,取值包括:"long", "short", "medium"。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ---------------------------------------- | +| fromUnit | [UnitInfo](#unitinfo8) | 是 | 要被转换的单位。 | +| toUnit | [UnitInfo](#unitinfo8) | 是 | 要转换为的单位。 | +| value | number | 是 | 要被转换的单位的数量值。 | +| locale | string | 是 | 格式化时使用的区域参数,如:zh-Hans-CN。 | +| style | string | 否 | 格式化使用的风格,取值包括:"long", "short", "medium"。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 按照toUnit的单位格式化后,得到的字符串。 | +**返回值:** +| 类型 | 说明 | +| ------ | ----------------------- | +| string | 按照toUnit的单位格式化后,得到的字符串。 | -- 示例: +**示例:** ``` I18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long"); ``` @@ -718,17 +718,17 @@ getInstance(locale?:string): IndexUtil **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locale | string | 否 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------- | +| locale | string | 否 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | [IndexUtil](#indexutil8) | locale对应的IndexUtil对象。 | +**返回值:** +| 类型 | 说明 | +| ------------------------ | --------------------- | +| [IndexUtil](#indexutil8) | locale对应的IndexUtil对象。 | -- 示例: +**示例:** ``` var indexUtil= i18n.IndexUtil.getInstance("zh-CN"); ``` @@ -745,12 +745,12 @@ getIndexList(): Array<string> **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Array<string> | 返回当前locale对应的索引列表。 | +**返回值:** +| 类型 | 说明 | +| ------------------- | ------------------ | +| Array<string> | 返回当前locale对应的索引列表。 | -- 示例: +**示例:** ``` var indexUtil = i18n.getInstance("zh-CN"); var indexList = indexUtil.getIndexList(); @@ -765,12 +765,12 @@ addLocale(locale: string): void **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------- | +| locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -- 示例: +**示例:** ``` var indexUtil = i18n.getInstance("zh-CN"); indexUtil.addLocale("en-US"); @@ -785,17 +785,17 @@ getIndex(text: string): string **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | text | string | 是 | 待计算索引值的输入文本。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ------------ | +| text | string | 是 | 待计算索引值的输入文本。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 输入文本对应的索引值。 | +**返回值:** +| 类型 | 说明 | +| ------ | ----------- | +| string | 输入文本对应的索引值。 | -- 示例: +**示例:** ``` var indexUtil= i18n.getInstance("zh-CN"); indexUtil.getIndex("hi"); // 返回h @@ -813,17 +813,17 @@ isDigit(char: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | char | string | 是 | 输入字符。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示输入的字符是数字,返回false表示输入的字符不是数字。 | +**返回值:** +| 类型 | 说明 | +| ------- | ------------------------------------ | +| boolean | 返回true表示输入的字符是数字,返回false表示输入的字符不是数字。 | -- 示例: +**示例:** ``` var isdigit = Character.isDigit("1"); // 返回true ``` @@ -837,17 +837,17 @@ isSpaceChar(char: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | char | string | 是 | 输入字符。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示输入的字符是空格符,返回false表示输入的字符不是空格符。 | +**返回值:** +| 类型 | 说明 | +| ------- | -------------------------------------- | +| boolean | 返回true表示输入的字符是空格符,返回false表示输入的字符不是空格符。 | -- 示例: +**示例:** ``` var isspacechar = Character.isSpaceChar("a"); // 返回false ``` @@ -861,17 +861,17 @@ isWhitespace(char: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | char | string | 是 | 输入字符。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示输入的字符是空白符,返回false表示输入的字符不是空白符。 | +**返回值:** +| 类型 | 说明 | +| ------- | -------------------------------------- | +| boolean | 返回true表示输入的字符是空白符,返回false表示输入的字符不是空白符。 | -- 示例: +**示例:** ``` var iswhitespace = Character.isWhitespace("a"); // 返回false ``` @@ -885,17 +885,17 @@ isRTL(char: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | char | string | 是 | 输入字符。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示输入的字符是从右到左语言的字符,返回false表示输入的字符不是从右到左语言的字符。 | +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true表示输入的字符是从右到左语言的字符,返回false表示输入的字符不是从右到左语言的字符。 | -- 示例: +**示例:** ``` var isrtl = Character.isRTL("a"); // 返回false ``` @@ -909,17 +909,17 @@ isIdeograph(char: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | char | string | 是 | 输入字符。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示输入的字符是表意文字,返回false表示输入的字符不是表意文字。 | +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true表示输入的字符是表意文字,返回false表示输入的字符不是表意文字。 | -- 示例: +**示例:** ``` var isideograph = Character.isIdeograph("a"); // 返回false ``` @@ -933,17 +933,17 @@ isLetter(char: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | char | string | 是 | 输入字符。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示输入的字符是字母,返回false表示输入的字符不是字母。 | +**返回值:** +| 类型 | 说明 | +| ------- | ------------------------------------ | +| boolean | 返回true表示输入的字符是字母,返回false表示输入的字符不是字母。 | -- 示例: +**示例:** ``` var isletter = Character.isLetter("a"); // 返回true ``` @@ -957,17 +957,17 @@ isLowerCase(char: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | char | string | 是 | 输入字符。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示输入的字符是小写字母,返回false表示输入的字符不是小写字母。 | +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true表示输入的字符是小写字母,返回false表示输入的字符不是小写字母。 | -- 示例: +**示例:** ``` var islowercase = Character.isLowerCase("a"); // 返回true ``` @@ -981,17 +981,17 @@ isUpperCase(char: string): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | char | string | 是 | 输入字符。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示输入的字符是大写字母,返回false表示输入的字符不是大写字母。 | +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true表示输入的字符是大写字母,返回false表示输入的字符不是大写字母。 | -- 示例: +**示例:** ``` var isuppercase = Character.isUpperCase("a"); // 返回false ``` @@ -1005,17 +1005,17 @@ getType(char: string): string **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | char | string | 是 | 输入字符。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 输入字符的一般类别值。 | +**返回值:** +| 类型 | 说明 | +| ------ | ----------- | +| string | 输入字符的一般类别值。 | -- 示例: +**示例:** ``` var type = Character.getType("a"); ``` @@ -1029,17 +1029,17 @@ getLineInstance(locale: string): BreakIterator **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locale | string | 是 | 合法的locale值,例如zh-Hans-CN。生成的[BreakIterator](#breakiterator8)将按照locale所指定的区域的规则来进行断句。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------------- | +| locale | string | 是 | 合法的locale值,例如zh-Hans-CN。生成的[BreakIterator](#breakiterator8)将按照locale所指定的区域的规则来进行断句。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | [BreakIterator](#breakiterator8) | 用于进行断句的处理器。 | +**返回值:** +| 类型 | 说明 | +| -------------------------------- | ----------- | +| [BreakIterator](#breakiterator8) | 用于进行断句的处理器。 | -- 示例: +**示例:** ``` i18n.getLineInstance("en"); ``` @@ -1056,12 +1056,12 @@ setLineBreakText(text: string): void **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | text | string | 是 | 指定BreakIterator进行断句的文本。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----------------------- | +| text | string | 是 | 指定BreakIterator进行断句的文本。 | -- 示例: +**示例:** ``` iterator = I18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); @@ -1076,12 +1076,12 @@ getLineBreakText(): string **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | BreakIterator对象正在处理的文本 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------------------- | +| string | BreakIterator对象正在处理的文本 | -- 示例: +**示例:** ``` iterator = I18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); @@ -1097,12 +1097,12 @@ current(): number **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | BreakIterator在当前所处理的文本中的位置。 | +**返回值:** +| 类型 | 说明 | +| ------ | --------------------------- | +| number | BreakIterator在当前所处理的文本中的位置。 | -- 示例: +**示例:** ``` iterator = I18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); @@ -1118,12 +1118,12 @@ first(): number **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 被处理文本的第一个分割点的偏移量。 | +**返回值:** +| 类型 | 说明 | +| ------ | ----------------- | +| number | 被处理文本的第一个分割点的偏移量。 | -- 示例: +**示例:** ``` iterator = I18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); @@ -1139,12 +1139,12 @@ last(): number **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 被处理的文本的最后一个分割点的偏移量 | +**返回值:** +| 类型 | 说明 | +| ------ | ------------------ | +| number | 被处理的文本的最后一个分割点的偏移量 | -- 示例: +**示例:** ``` iterator = I18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); @@ -1160,17 +1160,17 @@ next(index?: number): number **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | index | number | 否 | [BreakIterator](#breakiterator8)将要移动的分割点数,正数代表向后移动,负数代表向前移动。若index没有给出,则按照index=1处理。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ---------------------------------------- | +| index | number | 否 | [BreakIterator](#breakiterator8)将要移动的分割点数,正数代表向后移动,负数代表向前移动。若index没有给出,则按照index=1处理。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 返回移动了index个分割点后,当前[BreakIterator](#breakiterator8)在文本中的位置。若移动index个分割点后超出了所处理的文本的长度范围,返回-1。 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------------------------------------- | +| number | 返回移动了index个分割点后,当前[BreakIterator](#breakiterator8)在文本中的位置。若移动index个分割点后超出了所处理的文本的长度范围,返回-1。 | -- 示例: +**示例:** ``` iterator = I18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); @@ -1188,12 +1188,12 @@ previous(): number **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 返回移动到前一个分割点后,当前[BreakIterator](#breakiterator8)在文本中的位置。若移动index个分割点后超出了所处理的文本的长度范围,返回-1。 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------------------------------------- | +| number | 返回移动到前一个分割点后,当前[BreakIterator](#breakiterator8)在文本中的位置。若移动index个分割点后超出了所处理的文本的长度范围,返回-1。 | -- 示例: +**示例:** ``` iterator = I18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); @@ -1211,17 +1211,17 @@ following(offset: number): number **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | offset | number | 是 | 将[BreakIterator](#breakiterator8)对象的位置设置到由offset所指定的位置的下一个分割点。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------------- | +| offset | number | 是 | 将[BreakIterator](#breakiterator8)对象的位置设置到由offset所指定的位置的下一个分割点。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 返回[BreakIterator](#breakiterator8)移动后的位置,如果由offset所指定的位置的下一个分割点超出了文本的范围则返回-1。 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------------------------------------- | +| number | 返回[BreakIterator](#breakiterator8)移动后的位置,如果由offset所指定的位置的下一个分割点超出了文本的范围则返回-1。 | -- 示例: +**示例:** ``` iterator = I18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); @@ -1239,17 +1239,17 @@ isBoundary(offset: number): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | offset | number | 是 | 指定需要进行判断的位置 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----------- | +| offset | number | 是 | 指定需要进行判断的位置 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果是一个分割点返回true, 否则返回false。 | +**返回值:** +| 类型 | 说明 | +| ------- | ------------------------------- | +| boolean | 如果是一个分割点返回true, 否则返回false。 | -- 示例: +**示例:** ``` iterator = I18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); @@ -1266,12 +1266,12 @@ is24HourClock(): boolean **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true,表示系统24小时开关开启;返回false,表示系统24小时开关关闭。 | +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true,表示系统24小时开关开启;返回false,表示系统24小时开关关闭。 | -- 示例: +**示例:** ``` var is24HourClock = i18n.is24HourClock(); ``` @@ -1285,17 +1285,17 @@ set24HourClock(option: boolean): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | option | boolean | 是 | option为true,表示开启系统24小时制开关;返回false,表示关闭系统24小时开关。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ---------------------------------------- | +| option | boolean | 是 | option为true,表示开启系统24小时制开关;返回false,表示关闭系统24小时开关。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true,表示修改成功;返回false,表示修改失败。 | +**返回值:** +| 类型 | 说明 | +| ------- | ----------------------------- | +| boolean | 返回true,表示修改成功;返回false,表示修改失败。 | -- 示例: +**示例:** ``` // 将系统时间设置为24小时制 var success = I18n.set24HourClock(true); @@ -1310,18 +1310,18 @@ addPreferredLanguage(language: string, index?: number): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | language | string | 是 | 待添加的偏好语言。 | - | index | number | 否 | 偏好语言的添加位置。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------- | +| language | string | 是 | 待添加的偏好语言。 | +| index | number | 否 | 偏好语言的添加位置。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true,表示添加成功;返回false,表示添加失败。 | +**返回值:** +| 类型 | 说明 | +| ------- | ----------------------------- | +| boolean | 返回true,表示添加成功;返回false,表示添加失败。 | -- 示例: +**示例:** ``` // 将语言zh-CN添加到系统偏好语言列表中 var language = 'zh-CN'; @@ -1338,17 +1338,17 @@ removePreferredLanguage(index: number): boolean **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | index | number | 是 | 待删除偏好语言在系统偏好语言列表中的位置。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | --------------------- | +| index | number | 是 | 待删除偏好语言在系统偏好语言列表中的位置。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true,表示删除成功;返回false,表示删除失败。 | +**返回值:** +| 类型 | 说明 | +| ------- | ----------------------------- | +| boolean | 返回true,表示删除成功;返回false,表示删除失败。 | -- 示例: +**示例:** ``` // 删除系统偏好语言列表中的第一个偏好语言 var index = 0; @@ -1358,18 +1358,18 @@ removePreferredLanguage(index: number): boolean ## i18n.getPreferredLanguageList8+ -getPreferredLanguageList(): Array +getPreferredLanguageList(): Array<string> 获取系统偏好语言列表。 **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Array | 系统偏好语言列表。 | +**返回值:** +| 类型 | 说明 | +| ------------------- | --------- | +| Array<string> | 系统偏好语言列表。 | -- 示例: +**示例:** ``` var preferredLanguageList = i18n.getPreferredLanguageList(); ``` @@ -1383,12 +1383,12 @@ getFirstPreferredLanguage(): string **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 偏好语言列表中的第一个语言。 | +**返回值:** +| 类型 | 说明 | +| ------ | -------------- | +| string | 偏好语言列表中的第一个语言。 | -- 示例: +**示例:** ``` var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); ``` @@ -1402,17 +1402,17 @@ getTimeZone(zoneID?: string): TimeZone **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | zondID | string | 否 | 时区ID。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----- | +| zondID | string | 否 | 时区ID。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | TimeZone | 时区ID对应的时区对象。 | +**返回值:** +| 类型 | 说明 | +| -------- | ------------ | +| TimeZone | 时区ID对应的时区对象。 | -- 示例: +**示例:** ``` var timezone = i18n.getTimeZone(); ``` @@ -1429,12 +1429,12 @@ getID(): string **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 时区对象对应的时区ID。 | +**返回值:** +| 类型 | 说明 | +| ------ | ------------ | +| string | 时区对象对应的时区ID。 | -- 示例: +**示例:** ``` var timezone = i18n.getTimeZone(); timezone.getID(); @@ -1449,18 +1449,18 @@ getDisplayName(locale?: string, isDST?: boolean): string **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locale | string | 否 | 区域ID。 | - | isDST | boolean | 否 | 表示获取时区对象的表示时是否考虑夏令时。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | -------------------- | +| locale | string | 否 | 区域ID。 | +| isDST | boolean | 否 | 表示获取时区对象的表示时是否考虑夏令时。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 时区对象在指定区域的表示。 | +**返回值:** +| 类型 | 说明 | +| ------ | ------------- | +| string | 时区对象在指定区域的表示。 | -- 示例: +**示例:** ``` var timezone = i18n.getTimeZone(); timezone.getDisplayName("zh-CN", false); @@ -1475,12 +1475,12 @@ getRawOffset(): number **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 时区对象表示的时区与UTC时区的偏差。 | +**返回值:** +| 类型 | 说明 | +| ------ | ------------------- | +| number | 时区对象表示的时区与UTC时区的偏差。 | -- 示例: +**示例:** ``` var timezone = i18n.getTimeZone(); timezone.getRawOffset(); @@ -1495,12 +1495,12 @@ getOffset(date?: number): number **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 某一时刻时区对象表示的时区与UTC时区的偏差。 | +**返回值:** +| 类型 | 说明 | +| ------ | ----------------------- | +| number | 某一时刻时区对象表示的时区与UTC时区的偏差。 | -- 示例: +**示例:** ``` var timezone = i18n.getTimeZone(); timezone.getOffset(1234567890); diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index cf98e5531350eb8cf320580e507651cae6e09c96..ee5d038c50c7a69093a8c1c4c522d1f0236a9265 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -10,9 +10,9 @@ import image from '@ohos.multimedia.image'; ``` ## image.createPixelMap8+ -createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions): Promise\ +createPixelMap(colors: ArrayBuffer, options: InitializetionOptions): Promise\ -通过属性创建Pixelmap,通过Promise返回结果。 +通过属性创建PixelMap,通过Promise返回结果。 **系统能力:** SystemCapability.Multimedia.Image @@ -21,13 +21,13 @@ createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions): Promise\ | 返回pixelmap。 | +| Promise\<[PixelMap](#pixelmap7)> | 返回Pixelmap。 | **示例:** @@ -43,17 +43,17 @@ image.createPixelMap(Color, opts) createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions) callback: AsyncCallback\): void -通过属性创建Pixelmap,通过回调函数返回结果。 +通过属性创建PixelMap,通过回调函数返回结果。 **系统能力:** SystemCapability.Multimedia.Image **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------ | ---- | -------------------- | -| colors | ArrayBuffer | 是 | 颜色数组。 | -| options | [InitializetionOptions](#InitializationOptions8) | 是 | 属性。 | -| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | 是 | 回调表示成功或失败。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | -------------------------- | +| colors | ArrayBuffer | 是 | 颜色数组。 | +| options | [InitializetionOptions](#initializationoptions8) | 是 | 属性。 | +| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | 是 | 通过回调返回PixelMap对象。 | **示例:** @@ -255,7 +255,7 @@ writePixels(area: PositionArea): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------------------------ | ---- | -------------------- | -| area | [PositionArea](#PositionArea7) | 是 | 区域,根据区域写入。 | +| area | [PositionArea](#positionarea7) | 是 | 区域,根据区域写入。 | **返回值:** @@ -285,7 +285,7 @@ writePixels(area: PositionArea, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------------ | ---- | ------------------------------ | -| area | [PositionArea](#PositionArea7) | 是 | 区域,根据区域写入。 | +| area | [PositionArea](#positionarea7) | 是 | 区域,根据区域写入。 | | callback: | AsyncCallback\ | 是 | 获取回调,失败时返回错误信息。 | **示例:** @@ -335,7 +335,7 @@ pixelMap.writeBufferToPixels(colorBuffer).then(() => { writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\): void -读取缓冲区中的图片数据,结果写入Pixelmap中,使用Promise形式返回。 +读取缓冲区中的图片数据,结果写入Pixelmap中,使用callback形式返回。 **系统能力:** SystemCapability.Multimedia.Image @@ -739,11 +739,11 @@ createPixelMap(index: number, options: DecodingOptions, callback: AsyncCallback\ **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------------- | ------------------------------------- | ---- | -------------------- | -| options | [DecodingOptions](#decodingoptions7) | 是 | 解码参数。 | -| index | number | 是 | 图片索引。 | -| AsyncCallback | AsyncCallback<[PixelMap](#pixelmap7)> | 是 | 回调表示成功或失败。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ------------------------------------- | ---- | -------------------------- | +| options | [DecodingOptions](#decodingoptions7) | 是 | 解码参数。 | +| index | number | 是 | 图片索引。 | +| AsyncCallback | AsyncCallback<[PixelMap](#pixelmap7)> | 是 | 通过回调返回PixelMap对象。 | **示例:** @@ -765,10 +765,10 @@ createPixelMap(options: DecodingOptions, callback: AsyncCallback\): vo **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------- | ---- | -------------------- | -| options | [DecodingOptions](#decodingoptions7) | 是 | 解码参数。 | -| callback | AsyncCallback<[PixelMap](#pixelmap7)> | 是 | 回调表示成功或失败。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | -------------------------- | +| options | [DecodingOptions](#decodingoptions7) | 是 | 解码参数。 | +| callback | AsyncCallback<[PixelMap](#pixelmap7)> | 是 | 通过回调返回PixelMap对象。 | **示例:** @@ -798,10 +798,10 @@ createPixelMap(opts: DecodingOptions, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------- | ---- | -------------------- | -| opts | [DecodingOptions](#decodingoptions7) | 是 | 解码参数。 | -| callback | AsyncCallback<[PixelMap](#pixelmap7)> | 是 | 回调表示成功或失败。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | -------------------------- | +| opts | [DecodingOptions](#decodingoptions7) | 是 | 解码参数。 | +| callback | AsyncCallback<[PixelMap](#pixelmap7)> | 是 | 通过回调返回PixelMap对象。 | **示例:** @@ -881,9 +881,9 @@ createImagePacker(): ImagePacker **返回值:** -| 类型 | 说明 | -| ----------- | ---------------------- | -| ImagePacker | 返回ImagePackers实例。 | +| 类型 | 说明 | +| --------------------------- | --------------------- | +| [ImagePacker](#imagepacker) | 返回ImagePacker实例。 | **示例:** @@ -1020,7 +1020,7 @@ imagePackerApi.release(); | stride | number | 是 | 否 | 像素间距。 | | region | [Region](#region8) | 是 | 否 | 区域,按照区域读写。 | -## **ImageInfo** +## ImageInfo 表示图片信息。 @@ -1098,14 +1098,14 @@ imagePackerApi.release(); | 名称 | 类型 | 可读 | 可写 | 说明 | | ------------------ | ---------------------------------- | ---- | ---- | ---------------- | | sampleSize | number | 是 | 是 | 缩略图采样大小。 | -| rotateDegrees | number | 是 | 是 | 旋转角度。 | +| rotate | number | 是 | 是 | 旋转角度。 | | editable | boolean | 是 | 是 | 是否可编辑。 | | desiredSize | [Size](#size) | 是 | 是 | 期望输出大小。 | -| desiredRegion | [Region](#region8) | 是 | 是 | 解码区域。 | +| desiredRegion | [Region](#region7) | 是 | 是 | 解码区域。 | | desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | 解码的像素格式。 | | index | numer | 是 | 是 | 解码图片序号 | -## Region8+ +## Region7+ 表示区域信息。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md index 8d07bea3498faf2e95abf23fd428b9af7caae921..65c71a03bf58d7f298a1a9d751275be6f10f5609 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -24,11 +24,12 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void **系统能力:** SystemCapability.MultimodalInput.Input.InputDevice -**参数:** +**参数:** -| 参数 | 类型 | 必填 | 说明 | +| 参数 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<Array<number>> | 是 | 回调函数。 | +| callback | AsyncCallback<Array<number>> | 是 | 回调函数。 | + **示例:** @@ -46,6 +47,37 @@ testGetDeviceIds: function () { } ``` +## inputDevice.getDeviceIds + +function getDeviceIds(): Promise> + +获取所有输入设备的id列表,使用Promise方式作为异步方法。 + +**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice + +**返回值:** + +| 参数 | 说明 | +| -------- | -------- | +| Promise> | Promise实例,用于异步获取结果 | + +**示例:** + +``` +testGetDeviceIds: function () { + console.info("InputDeviceJsTest---start---testGetDeviceIds"); + let promise = inputDevice.getDeviceIds(); + promise.then((data)=> { + console.info('GetDeviceIds successed, Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed GetDeviceIds. Cause: ' + JSON.stringify(err)); + }); +} +``` + + + + ## inputDevice.getDevice @@ -57,10 +89,10 @@ getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): voi **参数:** -| 参数 | 类型 | 必填 | 说明 | +| 参数 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| deviceId | number | 是 | 需要获取信息的设备id。 | -| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | 是 | 回调函数,异步返回InputDeviceData对象。 | +| deviceId | number | 是 | 需要获取信息的设备id。 | +| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | 是 | 回调函数,异步返回InputDeviceData对象。 | **示例:** @@ -82,30 +114,84 @@ testGetDevice: function () { } ``` +## inputDevice.getDevice + +function getDevice(deviceId: number): Promise + +获取输入设备的描述信息,使用Promise方式作为异步方法。 + +**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice + +**返回值:** + +| 参数 | 说明 | +| -------- | -------- | +| Promise | Promise实例,用于异步获取结果 | + +**示例:** + +``` +InputDeviceData { + deviceId : 0, + name : "NA", + sources : Array, + axisRanges : Array, +}, +testGetDevice: function () { + // 示例获取设备id为1的设备信息。 + console.info("InputDeviceJsTest---start---testGetDevice"); + let promise = inputDevice.getDevice(1); + promise.then((data)=> { + console.info('GetDeviceId successed, Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed GetDeviceId. Cause: ' + JSON.stringify(err)); + }); +} +``` + + ## InputDeviceData 输入设备的描述信息。 -**系统能力:** 以下各项对应系统能力均为SystemCapability.MultimodalInput.Input.InputDevice +**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice - | 名称 | 参数类型 | 说明 | +| 名称 | 参数类型 | 说明 | | -------- | -------- | -------- | -| id | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | -| name | string | 输入设备的名字。 | +| id | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | +| name | string | 输入设备的名字。 | | sources | Array<[SourceType](#sourcetype)> | 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 | +## AxisType + +轴类型,本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +## AxisRange + +输入设备的轴信息 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice + +| 名称 | 参数类型 | 说明 | +| ------ | ------------------------- | ---------------- | +| source | [SourceType](#sourcetype) | 轴的输入源类型。 | +| axis | [AxisType](axistype) | 轴的类型 | +| max | number | 轴上报的最大值 | +| min | number | 轴上报的最小值 | + + ## SourceType 定义这个轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的源就是鼠标。 -**系统能力:** 以下各项对应系统能力均为SystemCapability.MultimodalInput.Input.InputDevice +**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice - | 名称 | 参数类型 | 说明 | +| 名称 | 参数类型 | 说明 | | -------- | -------- | -------- | | keyboard | string | 表示输入设备是键盘。 | -| touchscreen | string | 表示输入设备是触摸屏。 | +| touchscreen | string | 表示输入设备是触摸屏。 | | mouse | string | 表示输入设备是鼠标。 | | trackball | string | 表示输入设备是轨迹球。 | | touchpad | string | 表示输入设备是触摸板。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md new file mode 100644 index 0000000000000000000000000000000000000000..5a06a6a68c97ac82d65443df0e822607ff7a6796 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @@ -0,0 +1,57 @@ +# 注入按键 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> - 本模块接口均为系统接口,三方应用不支持调用。 + + +## 导入模块 + + +``` +import inputEventClient from '@ohos.multimodalInput.inputEventClient'; +``` + + +## inputEventClient.injectEvent + +injectEvent({KeyEvent: KeyEvent}): void + +注入按键,KeyEvent为注入按键的描述信息。 + +**系统能力:** SystemCapability.MultimodalInput.Input.InputSimulator + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| KeyEvent | [KeyEvent](#keyevent) | 是 | 注入按键的描述信息 | + +**示例:** + +``` +let keyEvent = { + isPressed: true, + keyCode: 2, + keyDownDuration: 0, + isIntercepted: false +} +res = inputEventClient.injectEvent({KeyEvent: keyEvent}); +``` + + +## KeyEvent + +注入按键的描述信息 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator + +| 参数 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| isPressed | boolean | 是 | 按键是否按下 | +| keyCode | Number | 是 | 按键键值 | +| keyDownDuration | boolean | 是 | 按键按下持续时间 | +| isIntercepted | Number | 是 | 按键是否可以被拦截 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index 5be5ae82734b49c43d287f74f092372f0975fd64..bb48bd9a80cdd3f829d3b3e68736edc22dbbb909 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -14,7 +14,7 @@ import inputMethod from '@ohos.inputMethod'; 常量值。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.MiscServices.InputMethodFramework +**系统能力**:以下各项对应的系统能力均为SystemCapability.Miscservices.InputMethodFramework | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -25,7 +25,7 @@ import inputMethod from '@ohos.inputMethod'; 输入法应用属性。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.MiscServices.InputMethodFramework +**系统能力**:以下各项对应的系统能力均为SystemCapability.Miscservices.InputMethodFramework | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -38,7 +38,7 @@ getInputMethodController(): InputMethodController 获取客户端实例[InputMethodController](#InputMethodController)。 -**系统能力**:SystemCapability.MiscServices.InputMethodFramework +**系统能力**:SystemCapability.Miscservices.InputMethodFramework - 返回值 @@ -56,7 +56,7 @@ getInputMethodSetting(): InputMethodSetting 获取客户端设置实例[InputMethodSetting](#InputMethodSetting)。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 返回值 @@ -80,7 +80,7 @@ stopInput(callback: AsyncCallback<boolean>): void 隐藏输入法。 -**系统能力**:SystemCapability.MiscServices.InputMethodFramework +**系统能力**:SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -102,7 +102,7 @@ stopInput(): Promise<boolean> 隐藏输入法。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 返回值 @@ -128,7 +128,7 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>) 查询已安装的输入法列表。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -151,7 +151,7 @@ listInputMethod(): Promise<Array<InputMethodProperty>> 查询已安装的输入法列表。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 返回值 | 类型 | 说明 | @@ -173,7 +173,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void 显示输入法选择对话框。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -194,7 +194,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void 显示输入法选择对话框。 - **系统能力**: SystemCapability.MiscServices.InputMethodFramework + **系统能力**: SystemCapability.Miscservices.InputMethodFramework - 返回值 diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md index afbd6f22ebe353652f01932f81408287d92155c2..f1918f7ba4a8292824d5530977bd4df62b193dc2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -13,7 +13,7 @@ import inputMethodEngine from '@ohos.inputMethodEngine'; 常量值。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.MiscServices.InputMethodFramework +**系统能力**:以下各项对应的系统能力均为SystemCapability.Miscservices.InputMethodFramework | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -50,7 +50,7 @@ getInputMethodEngine(): InputMethodEngine 获取服务端实例。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 返回值 @@ -70,7 +70,7 @@ createKeyboardDelegate(): KeyboardDelegate 获取客户端监听实例。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 返回值 @@ -94,7 +94,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli 订阅输入法绑定成功事件,使用callback回调返回输入法操作相关实例。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -118,7 +118,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC 取消订阅输入法绑定成功事件。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -141,7 +141,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void 订阅输入法事件。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -164,7 +164,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void 取消订阅输入法事件。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -190,7 +190,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void 订阅硬键盘事件,使用callback回调返回按键信息。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -215,7 +215,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void 取消订阅硬键盘事件。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -236,7 +236,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = 订阅光标变化事件,使用callback回调返回光标信息。 - **系统能力**: SystemCapability.MiscServices.InputMethodFramework + **系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -261,7 +261,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) 取消订阅光标变化事件。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -282,7 +282,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi 订阅文本选择变化事件,使用callback回调返回文本选择信息。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -305,7 +305,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe 取消订阅文本选择变化事件。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -327,7 +327,7 @@ on(type: 'textChange', callback: (text: string) => void): void 订阅文本变化事件,使用callback回调返回当前文本内容。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -350,7 +350,7 @@ off(type: 'textChange', callback?: (text: string) => void): void 取消订阅文本变化事件。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -375,7 +375,7 @@ hideKeyboard(callback: AsyncCallback<void>): void 隐藏输入法。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数: @@ -397,7 +397,7 @@ hideKeyboard(): Promise<void> 隐藏输入法。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 返回值 @@ -422,7 +422,7 @@ getForward(length:number, callback: AsyncCallback<string>): void 获取光标前固定长度的文本。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -444,7 +444,7 @@ getForward(length:number): Promise<string> 获取光标前固定长度的文本。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -469,7 +469,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void 获取光标后固定长度的文本。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -491,7 +491,7 @@ getBackward(length:number): Promise<string> 获取光标后固定长度的文本。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -516,7 +516,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void 删除光标前固定长度的文本。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -537,7 +537,7 @@ deleteForward(length:number): Promise<boolean> 删除光标前固定长度的文本。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -562,7 +562,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void 删除光标后固定长度的文本。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -584,7 +584,7 @@ deleteBackward(length:number): Promise<boolean> 删除光标后固定长度的文本。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -608,7 +608,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void 发送功能键。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -630,7 +630,7 @@ sendKeyFunction(action:number): Promise<boolean> 发送功能键。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -655,7 +655,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void 插入文本。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 @@ -677,7 +677,7 @@ insertText(text:string): Promise<boolean> 插入文本。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -702,7 +702,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void 获取编辑框属性值。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -721,7 +721,7 @@ getEditorAttribute(): Promise<EditorAttribute> 获取编辑框属性值。 -**系统能力**: SystemCapability.MiscServices.InputMethodFramework +**系统能力**: SystemCapability.Miscservices.InputMethodFramework - 返回值 | 类型 | 说明 | @@ -737,7 +737,7 @@ getEditorAttribute(): Promise<EditorAttribute> 编辑框属性值。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.MiscServices.InputMethodFramework +**系统能力**:以下各项对应的系统能力均为SystemCapability.Miscservices.InputMethodFramework | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ------------ | -------- | ---- | ---- | ------------------ | @@ -748,7 +748,7 @@ getEditorAttribute(): Promise<EditorAttribute> 按键属性值。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.MiscServices.InputMethodFramework +**系统能力**:以下各项对应的系统能力均为SystemCapability.Miscservices.InputMethodFramework | 名称 | 参数类型 | 可读 | 可写 | 说明 | | --------- | -------- | ---- | ---- | ------------ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md new file mode 100644 index 0000000000000000000000000000000000000000..49b0847e5a4018f324474e65db36a4c375418adf --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @@ -0,0 +1,142 @@ +# 输入监听 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> - 本模块接口均为系统接口,三方应用不支持调用。 + + +## 导入模块 + + +``` +import inputMonitor from '@ohos.multimodalInput.inputMonitor'; +``` + + +## 权限 + +ohos.permission.INPUT_MONITORING + + +## inputMonitor.on + +on(type: "touch", receiver: TouchEventReceiver): void + +开始监听全局输入。 + +**需要权限:**ohos.permission.INPUT_MONITORING + +**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor + + **参数:** + | 参数 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| type | string | 是 | 监听输入事件类型,只支持“touch”。 | +| receiver | [TouchEventReceiver](#toucheventreceiver) | 是 | 触摸输入事件回调函数。 | + + **示例:** + +``` +callback: function (value) { + if (checkEvent(value)) { + //事件满足业务要求,事件被消费 + return true; + } else { + //事件不满足业务要求,事件未被消费 + return false; + } +}, +testOn: function () { + console.info("InputMonitorJsTest---start---testOn"); + inputMonitor.on( + "touch", + this.callback + ); + console.info("InputMonitorJsTest---end---testOn"); +} +``` + + +## inputMonitor.off + +off(type: "touch", receiver: TouchEventReceiver): void + +停止监听全局输入。 + +**需要权限:**ohos.permission.INPUT_MONITORING + +**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor + + **参数:** + | 参数 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| type | string | 是 | 监听输入事件类型,只支持“touch”。 | +| receiver | [TouchEventReceiver](#toucheventreceiver) | 否 | 触摸输入事件回调函数。 | + + **示例:** + +``` +callback: function (value) { + if (checkEvent(value)) { + //事件满足业务要求,事件被消费 + return true; + } else { + //事件不满足业务要求,事件未被消费 + return false; + } +}, +testOff: function () { + console.info("InputMonitorJsTest---start---testOff"); + inputMonitor.off( + "touch", + this.callback + ); + console.info("InputMonitorJsTest---end---testOff"); +} +``` + + +## TouchEventReceiver + +触摸输入事件的回调函数,如果返回true,则触摸输入将被监听器消耗(系统执行关闭动作)。 + + +### (touchEvent: TouchEvent): Boolean + +触摸输入事件的回调函数。函数名由使用者定义,这里是函数调用时必须符合的格式,传入参数必须为TouchEvent类型,返回值为Boolean类型。 + +**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor + + **参数:** +| 参数 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | 是 | 触摸输入事件回调函数,返回true表示输触事件被监听器消费,false表示输触事件未被监听器消费。 | + + **返回值:** + | 类型 | 说明 | +| -------- | -------- | +| Boolean | 返回true表示输触事件被监听器消费,false表示输触事件未被监听器消费。 | + + **示例:** + +``` +callback: function (value) { //此处为(touchEvent:TouchEvent): Boolean 方法的实现 + if (checkEvent(value)) { + //事件满足业务要求,事件被消费 + return true; + } else { + //事件不满足业务要求,事件未被消费 + return false; + } +}, +testOff: function () { + console.info("InputMonitorJsTest---start---testOff"); + inputMonitor.off( + "touch", + this.callback + ); + console.info("InputMonitorJsTest---end---testOff"); +} +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-intl.md b/zh-cn/application-dev/reference/apis/js-apis-intl.md index 9d4ea8f9485858d7c6338f0f222252a416512718..d34826f48d944d1f229bcea211dbdc4a16a2e813 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-intl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-intl.md @@ -2,7 +2,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> +> > - Intl模块包含国际化能力基础接口(在ECMA 402中定义)。 @@ -20,18 +20,18 @@ import Intl from '@ohos.intl'; **系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| language | string | 是 | 否 | 与区域设置关联的语, 如:zh。 | -| script | string | 是 | 否 | 语言的书写方式,如:Hans。 | -| region | string | 是 | 否 | 与区域设置相关的地区,如:CN。 | -| baseName | string | 是 | 否 | Locale的基本核心信息(由语言脚本与地区组成),如:zh-Hans-CN。 | -| caseFirst | string | 是 | 否 | 区域的整理规则是否考虑大小写,取值包括:"upper", "lower", "false"。 | -| calendar | string | 是 | 否 | 区域的日历信息,取值包括:"buddhist", "chinese", "coptic","dangi", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamic-umalqura", "islamic-tbla", "islamic-civil", "islamic-rgsa", "iso8601", "japanese", "persian", "roc", "islamicc"。 | -| collation | string | 是 | 否 | 区域的排序规则,取值包括:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。 | -| hourCycle | string | 是 | 否 | 区域的时制信息,取值包括:"h12", "h23", "h11", "h24"。 | -| numberingSystem | string | 是 | 否 | 区域使用的数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | -| numeric | boolean | 是 | 否 | 是否对数字字符具有特殊的排序规则处理。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------------- | ------- | ---- | ---- | ---------------------------------------- | +| language | string | 是 | 否 | 与区域设置关联的语, 如:zh。 | +| script | string | 是 | 否 | 语言的书写方式,如:Hans。 | +| region | string | 是 | 否 | 与区域设置相关的地区,如:CN。 | +| baseName | string | 是 | 否 | Locale的基本核心信息(由语言脚本与地区组成),如:zh-Hans-CN。 | +| caseFirst | string | 是 | 否 | 区域的整理规则是否考虑大小写,取值包括:"upper", "lower", "false"。 | +| calendar | string | 是 | 否 | 区域的日历信息,取值包括:"buddhist", "chinese", "coptic","dangi", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamic-umalqura", "islamic-tbla", "islamic-civil", "islamic-rgsa", "iso8601", "japanese", "persian", "roc", "islamicc"。 | +| collation | string | 是 | 否 | 区域的排序规则,取值包括:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。 | +| hourCycle | string | 是 | 否 | 区域的时制信息,取值包括:"h12", "h23", "h11", "h24"。 | +| numberingSystem | string | 是 | 否 | 区域使用的数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | +| numeric | boolean | 是 | 否 | 是否对数字字符具有特殊的排序规则处理。 | ### constructor8+ @@ -42,7 +42,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n -- 示例: +**示例:** ``` var locale = new Intl.Locale(); ``` @@ -56,13 +56,13 @@ constructor(locale: string, options?: LocaleOptions) **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | - | options | LocaleOptions | 否 | 用于创建区域对象的选项。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------- | ---- | ---------------------------- | +| locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| options | LocaleOptions | 否 | 用于创建区域对象的选项。 | -- 示例: +**示例:** ``` var locale = new Intl.Locale("zh-CN"); ``` @@ -76,12 +76,12 @@ toString(): string **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 字符串形式的区域信息。 | +**返回值:** +| 类型 | 说明 | +| ------ | ----------- | +| string | 字符串形式的区域信息。 | -- 示例: +**示例:** ``` var locale = new Intl.Locale("zh-CN"); locale.toString(); @@ -96,12 +96,12 @@ maximize(): Locale **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | [Locale](#locale) | 最大化后的区域对象。 | +**返回值:** +| 类型 | 说明 | +| ----------------- | ---------- | +| [Locale](#locale) | 最大化后的区域对象。 | -- 示例: +**示例:** ``` var locale = new Intl.Locale("zh-CN"); locale.maximize(); @@ -116,12 +116,12 @@ minimize(): Locale **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | [Locale](#locale) | 最小化后的区域对象。 | +**返回值:** +| 类型 | 说明 | +| ----------------- | ---------- | +| [Locale](#locale) | 最小化后的区域对象。 | -- 示例: +**示例:** ``` var locale = new Intl.Locale("zh-CN"); locale.minimize(); @@ -134,14 +134,14 @@ minimize(): Locale **系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| calendar | string | 是 | 是 | 日历参数,如:"buddhist", "chinese", "coptic", "dangi", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamic-umalqura", "islamic-tbla", "islamic-civil", "islamic-rgsa", "iso8601", "japanese", "persian", "roc", "islamicc"。 | -| collation | string | 是 | 是 | 排序参数,取值包括:"big5han", "compat", "dict", "direct", "ducet", "emoji", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed ", "search", "searchjl", "standard", "stroke", "trad", "unihan", "zhuyin"。 | -| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11", "h12", "h23", "h24"。 | -| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | -| numeric | boolean | 是 | 是 | 是否使用12小时制。 | -| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper", "lower", "false"。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------------- | ------- | ---- | ---- | ---------------------------------------- | +| calendar | string | 是 | 是 | 日历参数,如:"buddhist", "chinese", "coptic", "dangi", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamic-umalqura", "islamic-tbla", "islamic-civil", "islamic-rgsa", "iso8601", "japanese", "persian", "roc", "islamicc"。 | +| collation | string | 是 | 是 | 排序参数,取值包括:"big5han", "compat", "dict", "direct", "ducet", "emoji", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed ", "search", "searchjl", "standard", "stroke", "trad", "unihan", "zhuyin"。 | +| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11", "h12", "h23", "h24"。 | +| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | +| numeric | boolean | 是 | 是 | 是否使用12小时制。 | +| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper", "lower", "false"。 | ## DateTimeFormat @@ -155,7 +155,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n -- 示例: +**示例:** ``` var datefmt= new Intl.DateTimeFormat(); ``` @@ -163,25 +163,25 @@ constructor() ### constructor -constructor(locale: string | Array, options?: DateTimeOptions) +constructor(locale: string | Array<string>, options?: DateTimeOptions) 创建时间日期格式化对象。 **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locale | string \| Array | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | - | options | [DateTimeOptions](#datetimeoptions) | 否 | 用于创建时间日期格式化的选项。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------------- | ---- | ---------------------------- | +| locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| options | [DateTimeOptions](#datetimeoptions) | 否 | 用于创建时间日期格式化的选项。 | -- 示例: +**示例:** ``` var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' }); ``` -- 示例: +**示例:** ``` var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); ``` @@ -195,17 +195,17 @@ format(date: Date): string **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | date | Date | 是 | 时间日期对象。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ---- | ---- | ------- | +| date | Date | 是 | 时间日期对象。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 格式化后的时间日期字符串 | +**返回值:** +| 类型 | 说明 | +| ------ | ------------ | +| string | 格式化后的时间日期字符串 | -- 示例: +**示例:** ``` var date = new Date(2021, 11, 17, 3, 24, 0); var datefmt = new Intl.DateTimeFormat("en-GB"); @@ -221,18 +221,18 @@ formatRange(startDate: Date, endDate: Date): string **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | startDate | Date | 是 | 起始的时间日期。 | - | endDate | Date | 是 | 结束的时间日期。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ---- | ---- | -------- | +| startDate | Date | 是 | 起始的时间日期。 | +| endDate | Date | 是 | 结束的时间日期。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 格式化后的时间日期段字符串。 | +**返回值:** +| 类型 | 说明 | +| ------ | -------------- | +| string | 格式化后的时间日期段字符串。 | -- 示例: +**示例:** ``` var startDate = new Date(2021, 11, 17, 3, 24, 0); var endDate = new Date(2021, 11, 18, 3, 24, 0); @@ -249,12 +249,12 @@ resolvedOptions(): DateTimeOptions **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | [DateTimeOptions](#datetimeoptions) | DateTimeFormat 对象的格式化选项。 | +**返回值:** +| 类型 | 说明 | +| ----------------------------------- | ----------------------------- | +| [DateTimeOptions](#datetimeoptions) | DateTimeFormat 对象的格式化选项。 | -- 示例: +**示例:** ``` var datefmt = new Intl.DateTimeFormat("en-GB"); datefmt.resolvedOptions(); @@ -267,27 +267,27 @@ resolvedOptions(): DateTimeOptions **系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| locale | string | 是 | 否 | 区域参数, 如:zh-Hans-CN。 | -| dateStyle | string | 是 | 是 | 日期显示格式,取值包括:"long", "short", "medium", "full"。 | -| timeStyle | string | 是 | 是 | 时间显示格式,取值包括:"long", "short", "medium", "full"。 | -| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11", "h12", "h23", "h24"。 | -| timeZone | string | 是 | 是 | 使用的时区(合法的IANA时区ID)。 | -| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | -| hour12 | boolean | 是 | 是 | 是否使用12小时制。 | -| weekday | string | 是 | 是 | 工作日的显示格式,取值包括:"long", "short", "narrow"。 | -| era | string | 是 | 是 | 时代的显示格式,取值包括:"long", "short", "narrow"。 | -| year | string | 是 | 是 | 年份的显示格式,取值包括:"numeric", "2-digit"。 | -| month | string | 是 | 是 | 月份的显示格式,取值包括:"numeric", "2-digit", "long", "short", "narrow"。 | -| day | string | 是 | 是 | 日期的显示格式,取值包括:"numeric", "2-digit"。 | -| hour | string | 是 | 是 | 小时的显示格式,取值包括:"numeric", "2-digit"。 | -| minute | string | 是 | 是 | 分钟的显示格式,取值包括:"numeric", "2-digit"。 | -| second | string | 是 | 是 | 秒钟的显示格式,取值包括:"numeric", "2-digit"。 | -| timeZoneName | string | 是 | 是 | 时区名称的本地化表示。 | -| dayPeriod | string | 是 | 是 | 时段的显示格式,取值包括:"long", "short", "narrow"。 | -| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。 | -| formatMatcher | string | 是 | 是 | 要使用的格式匹配算法,取值包括:"basic", "best fit"。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------------- | ------- | ---- | ---- | ---------------------------------------- | +| locale | string | 是 | 否 | 区域参数, 如:zh-Hans-CN。 | +| dateStyle | string | 是 | 是 | 日期显示格式,取值包括:"long", "short", "medium", "full"。 | +| timeStyle | string | 是 | 是 | 时间显示格式,取值包括:"long", "short", "medium", "full"。 | +| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11", "h12", "h23", "h24"。 | +| timeZone | string | 是 | 是 | 使用的时区(合法的IANA时区ID)。 | +| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | +| hour12 | boolean | 是 | 是 | 是否使用12小时制。 | +| weekday | string | 是 | 是 | 工作日的显示格式,取值包括:"long", "short", "narrow"。 | +| era | string | 是 | 是 | 时代的显示格式,取值包括:"long", "short", "narrow"。 | +| year | string | 是 | 是 | 年份的显示格式,取值包括:"numeric", "2-digit"。 | +| month | string | 是 | 是 | 月份的显示格式,取值包括:"numeric", "2-digit", "long", "short", "narrow"。 | +| day | string | 是 | 是 | 日期的显示格式,取值包括:"numeric", "2-digit"。 | +| hour | string | 是 | 是 | 小时的显示格式,取值包括:"numeric", "2-digit"。 | +| minute | string | 是 | 是 | 分钟的显示格式,取值包括:"numeric", "2-digit"。 | +| second | string | 是 | 是 | 秒钟的显示格式,取值包括:"numeric", "2-digit"。 | +| timeZoneName | string | 是 | 是 | 时区名称的本地化表示。 | +| dayPeriod | string | 是 | 是 | 时段的显示格式,取值包括:"long", "short", "narrow"。 | +| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。 | +| formatMatcher | string | 是 | 是 | 要使用的格式匹配算法,取值包括:"basic", "best fit"。 | ## NumberFormat @@ -301,7 +301,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n -- 示例: +**示例:** ``` var numfmt = new Intl.NumberFormat(); ``` @@ -309,19 +309,19 @@ constructor() ### constructor -constructor(locale: string | Array, options?: NumberOptions) +constructor(locale: string | Array<string>, options?: NumberOptions) 创建数字格式化对象。 **系统能力**:SystemCapability.Global.I18n 参数: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| locale | string \| Array | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -| options | [NumberOptions](#numberoptions) | 否 | 用于创建数字格式化的选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ---------------------------- | +| locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| options | [NumberOptions](#numberoptions) | 否 | 用于创建数字格式化的选项。 | -- 示例: +**示例:** ``` var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"}); ``` @@ -335,18 +335,18 @@ format(number: number): string; **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | number | number | 是 | 数字对象 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---- | +| number | number | 是 | 数字对象 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 格式化后的数字字符串 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------- | +| string | 格式化后的数字字符串 | -- 示例: +**示例:** ``` var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); numfmt.format(1223); @@ -361,13 +361,13 @@ resolvedOptions(): NumberOptions **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | [NumberOptions](#numberoptions) | NumberFormat 对象的格式化选项。 | +**返回值:** +| 类型 | 说明 | +| ------------------------------- | --------------------------- | +| [NumberOptions](#numberoptions) | NumberFormat 对象的格式化选项。 | -- 示例: +**示例:** ``` var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); numfmt.resolvedOptions(); @@ -380,27 +380,27 @@ resolvedOptions(): NumberOptions **系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| locale | string | 是 | 否 | 区域参数, 如:"zh-Hans-CN"。 | -| currency | string | 是 | 是 | 货币单位, 如:"EUR","CNY","USD"等。 | -| currencySign | string | 是 | 是 | 货币单位的符号显示,取值包括: "symbol","narrowSymbol","code","name" 。 | -| currencyDisplay | string | 是 | 是 | 货币的显示方式,取值包括:"symbol", "narrowSymbol", "code", "name"。 | -| unit | string | 是 | 是 | 单位名称,如:"meter","inch",“hectare”等。 | -| unitDisplay | string | 是 | 是 | 单位的显示格式,取值包括:"long", "short", "medium"。 | -| unitUsage | string | 是 | 是 | 单位的使用场景,取值包括:"default", "area-land-agricult", "area-land-commercl", "area-land-residntl", "length-person", "length-person-small", "length-rainfall", "length-road", "length-road-small", "length-snowfall", "length-vehicle", "length-visiblty", "length-visiblty-small", "length-person-informal", "length-person-small-informal", "length-road-informal", "speed-road-travel", "speed-wind", "temperature-person", "temperature-weather", "volume-vehicle-fuel"。 | -| signDisplay | string | 是 | 是 | 数字符号的显示格式,取值包括:"auto", "never", "always", "expectZero"。 | -| compactDisplay | string | 是 | 是 | 紧凑型的显示格式,取值包括:"long", "short"。 | -| notation | string | 是 | 是 | 数字的格式化规格,取值包括:"standard", "scientific", "engineering", "compact"。 | -| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。 | -| style | string | 是 | 是 | 数字的显示格式,取值包括:"decimal", "currency", "percent", "unit"。 | -| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | -| useGrouping | boolean | 是 | 是 | 是否分组显示。 | -| minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。 | -| minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。 | -| maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。 | -| minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。 | -| maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------------------------ | ------- | ---- | ---- | ---------------------------------------- | +| locale | string | 是 | 否 | 区域参数, 如:"zh-Hans-CN"。 | +| currency | string | 是 | 是 | 货币单位, 如:"EUR","CNY","USD"等。 | +| currencySign | string | 是 | 是 | 货币单位的符号显示,取值包括: "symbol","narrowSymbol","code","name" 。 | +| currencyDisplay | string | 是 | 是 | 货币的显示方式,取值包括:"symbol", "narrowSymbol", "code", "name"。 | +| unit | string | 是 | 是 | 单位名称,如:"meter","inch",“hectare”等。 | +| unitDisplay | string | 是 | 是 | 单位的显示格式,取值包括:"long", "short", "medium"。 | +| unitUsage | string | 是 | 是 | 单位的使用场景,取值包括:"default", "area-land-agricult", "area-land-commercl", "area-land-residntl", "length-person", "length-person-small", "length-rainfall", "length-road", "length-road-small", "length-snowfall", "length-vehicle", "length-visiblty", "length-visiblty-small", "length-person-informal", "length-person-small-informal", "length-road-informal", "speed-road-travel", "speed-wind", "temperature-person", "temperature-weather", "volume-vehicle-fuel"。 | +| signDisplay | string | 是 | 是 | 数字符号的显示格式,取值包括:"auto", "never", "always", "expectZero"。 | +| compactDisplay | string | 是 | 是 | 紧凑型的显示格式,取值包括:"long", "short"。 | +| notation | string | 是 | 是 | 数字的格式化规格,取值包括:"standard", "scientific", "engineering", "compact"。 | +| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。 | +| style | string | 是 | 是 | 数字的显示格式,取值包括:"decimal", "currency", "percent", "unit"。 | +| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | +| useGrouping | boolean | 是 | 是 | 是否分组显示。 | +| minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。 | +| minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。 | +| maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。 | +| minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。 | +| maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。 | ## Collator8+ @@ -414,7 +414,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n -- 示例: +**示例:** ``` var collator = new Intl.Collator(); ``` @@ -422,20 +422,20 @@ constructor() ### constructor8+ -constructor(locale: string | Array, options?: CollatorOptions) +constructor(locale: string | Array<string>, options?: CollatorOptions) 创建排序对象。 **系统能力**:SystemCapability.Global.I18n -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locale | string \| Array | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | - | options | [CollatorOptions](#collatoroptions) | 否 | 用于创建排序对象的选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------------- | ---- | ---------------------------- | +| locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| options | [CollatorOptions](#collatoroptions) | 否 | 用于创建排序对象的选项。 | -- 示例: +**示例:** ``` var collator = new Intl.Collator("zh-CN", {localeMatcher: "lookup", usage: "sort"}); ``` @@ -449,18 +449,18 @@ compare(first: string, second: string): number **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | first | string | 是 | 进行比较第一个字符串。 | - | second | string | 是 | 进行比较的第二个字符串。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------ | +| first | string | 是 | 进行比较第一个字符串。 | +| second | string | 是 | 进行比较的第二个字符串。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | number | 比较结果。当number为负数,表示first排序在second之前;当number为0,表示first与second排序相同;当number为正数,表示first排序在second之后。 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------------------------------------- | +| number | 比较结果。当number为负数,表示first排序在second之前;当number为0,表示first与second排序相同;当number为正数,表示first排序在second之后。 | -- 示例: +**示例:** ``` var collator = new Intl.Collator("zh-Hans"); collator.compare("first", "second"); @@ -475,12 +475,12 @@ resolvedOptions(): CollatorOptions **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | [CollatorOptions](#collatoroptions) | 返回的Collator对象的属性。 | +**返回值:** +| 类型 | 说明 | +| ----------------------------------- | ----------------- | +| [CollatorOptions](#collatoroptions) | 返回的Collator对象的属性。 | -- 示例: +**示例:** ``` var collator = new Intl.Collator("zh-Hans"); var options = collator.resolvedOptions(); @@ -493,15 +493,15 @@ resolvedOptions(): CollatorOptions **系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | 是 | 是 | locale匹配算法,取值范围:"best fit", "lookup"。 | -| usage | string | 是 | 是 | 比较的用途,取值范围:"sort", "search"。 | -| sensitivity | string | 是 | 是 | 表示字符串中的哪些差异会导致非零结果值,取值范围:"base", "accent", "case", "variant"。 | -| ignorePunctuation | boolean | 是 | 是 | 表示是否忽略标点符号,取值范围:true, false。 | -| collation | string | 是 | 是 | 排序规则,取值范围:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。 | -| numeric | boolean | 是 | 是 | 是否使用数字排序,取值范围:true, false。 | -| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper", "lower", "false"。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----------------- | ------- | ---- | ---- | ---------------------------------------- | +| localeMatcher | string | 是 | 是 | locale匹配算法,取值范围:"best fit", "lookup"。 | +| usage | string | 是 | 是 | 比较的用途,取值范围:"sort", "search"。 | +| sensitivity | string | 是 | 是 | 表示字符串中的哪些差异会导致非零结果值,取值范围:"base", "accent", "case", "variant"。 | +| ignorePunctuation | boolean | 是 | 是 | 表示是否忽略标点符号,取值范围:true, false。 | +| collation | string | 是 | 是 | 排序规则,取值范围:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。 | +| numeric | boolean | 是 | 是 | 是否使用数字排序,取值范围:true, false。 | +| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper", "lower", "false"。 | ## PluralRules8+ @@ -515,7 +515,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n -- 示例: +**示例:** ``` var pluralRules = new Intl.PluralRules(); ``` @@ -523,19 +523,19 @@ constructor() ### constructor8+ -constructor(locale: string | Array, options?: PluralRulesOptions) +constructor(locale: string | Array<string>, options?: PluralRulesOptions) 创建PluralRules对象。 **系统能力**:SystemCapability.Global.I18n 参数: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| locale | string \| Array | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -| options | [PluralRulesOptions](#pluralrulesoptions) | 否 | 用于创建单复数对象的选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ---------------------------- | +| locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| options | [PluralRulesOptions](#pluralrulesoptions) | 否 | 用于创建单复数对象的选项。 | -- 示例: +**示例:** ``` var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); ``` @@ -549,17 +549,17 @@ select(n: number): string **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | n | number | 是 | 待获取单复数类别的数字。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ------------ | +| n | number | 是 | 待获取单复数类别的数字。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 单复数类别,取值包括:"zero","one","two", "few", "many", "others"。 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------------------------------------- | +| string | 单复数类别,取值包括:"zero","one","two", "few", "many", "others"。 | -- 示例: +**示例:** ``` var pluralRules = new Intl.PluralRules("zh-Hans"); pluralRules.select(1); @@ -572,15 +572,15 @@ select(n: number): string **系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。 | -| type | string | 是 | 是 | 排序的类型,取值包括:"cardinal", "ordinal"。 | -| minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。 | -| minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。 | -| maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。 | -| minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。 | -| maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------------------------ | ------ | ---- | ---- | ---------------------------------------- | +| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。 | +| type | string | 是 | 是 | 排序的类型,取值包括:"cardinal", "ordinal"。 | +| minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。 | +| minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。 | +| maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。 | +| minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。 | +| maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。 | ## RelativeTimeFormat8+ @@ -594,7 +594,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n -- 示例: +**示例:** ``` var relativetimefmt = new Intl.RelativeTimeFormat(); ``` @@ -602,19 +602,19 @@ constructor() ### constructor8+ -constructor(locale: string | Array, options?: RelativeTimeFormatInputOptions) +constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions) 创建相对时间格式化对象。 **系统能力**:SystemCapability.Global.I18n 参数: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| locale | string \| Array | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | 否 | 用于创建相对时间格式化对象的选项。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ---------------------------- | +| locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | 否 | 用于创建相对时间格式化对象的选项。 | -- 示例: +**示例:** ``` var relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {"localeMatcher": "lookup", "numeric": "always", "style": "long"}); ``` @@ -628,18 +628,18 @@ format(value: number, unit: string): string **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | number | 是 | 相对时间格式化的数值。 | - | unit | string | 是 | 相对时间格式化的单位,取值包括:"year", "quarter", "month", "week", "day", "hour", "minute", "second"。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ---------------------------------------- | +| value | number | 是 | 相对时间格式化的数值。 | +| unit | string | 是 | 相对时间格式化的单位,取值包括:"year", "quarter", "month", "week", "day", "hour", "minute", "second"。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | string | 格式化后的相对时间。 | +**返回值:** +| 类型 | 说明 | +| ------ | ---------- | +| string | 格式化后的相对时间。 | -- 示例: +**示例:** ``` var relativetimefmt = new Intl.RelativeTimeFormat("zh-CN"); relativetimefmt.format(3, "quarter") @@ -648,24 +648,24 @@ format(value: number, unit: string): string ### formatToParts8+ -formatToParts(value: number, unit: string): Array +formatToParts(value: number, unit: string): Array<object> 返回一个对象数组,表示可用于自定义区域设置格式的相对时间格式。 **系统能力**:SystemCapability.Global.I18n -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | number | 是 | 相对时间格式化的数值。 | - | unit | string | 是 | 相对时间格式化的单位,取值包括:"year", "quarter", "month", "week", "day", "hour", "minute", "second"。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ---------------------------------------- | +| value | number | 是 | 相对时间格式化的数值。 | +| unit | string | 是 | 相对时间格式化的单位,取值包括:"year", "quarter", "month", "week", "day", "hour", "minute", "second"。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Array | 返回可用于自定义区域设置格式的相对时间格式的对象数组。 | +**返回值:** +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Array<object> | 返回可用于自定义区域设置格式的相对时间格式的对象数组。 | -- 示例: +**示例:** ``` var relativetimefmt = new Intl.RelativeTimeFormat("en", {"numeric": "auto"}); var parts = relativetimefmt.format(10, "seconds"); @@ -680,12 +680,12 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions **系统能力**:SystemCapability.Global.I18n -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions) | RelativeTimeFormat 对象的格式化选项。 | +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | --------------------------------- | +| [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions) | RelativeTimeFormat 对象的格式化选项。 | -- 示例: +**示例:** ``` var relativetimefmt= new Intl.RelativeTimeFormat("en-GB"); relativetimefmt.resolvedOptions(); @@ -698,11 +698,11 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions **系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。 | -| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。 | -| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------------- | ------ | ---- | ---- | ---------------------------------------- | +| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。 | +| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。 | +| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。 | ## RelativeTimeFormatResolvedOptions8+ @@ -711,9 +711,9 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions **系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| locale | string | 是 | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。 | -| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。 | -| numberingSystem | string | 是 | 是 | 使用的数字系统。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------------- | ------ | ---- | ---- | ---------------------------------------- | +| locale | string | 是 | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。 | +| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。 | +| numberingSystem | string | 是 | 是 | 使用的数字系统。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md index b9f1f17231c91aa76c470076941053c1a2e99bd9..6de7c7f1fb9e18894843e4335e8caad80adffa66 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md @@ -524,8 +524,8 @@ forEach(callbackfn: (value?: V, key?: K, map?: LightWeightMap) => void, th callbackfn的参数说明: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | V | 是 | 当前遍历到的元素键值对的值。 | -| key | K | 是 | 当前遍历到的元素键值对的键。 | +| value | V | 否 | 当前遍历到的元素键值对的值。 | +| key | K | 否 | 当前遍历到的元素键值对的键。 | | map | LightWeightMap | 否 | 当前调用forEach方法的实例对象。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md index 7703b787c86d4886a2e88dcef785ad9e34c3e22b..4d2e486b81d24584af9fdb00b4a78feb3f6a4948 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md @@ -160,7 +160,7 @@ has(key: T): boolean let lightWeightSet = new LightWeightSet(); let result = lightWeightSet.has(123); lightWeightSet.add(123); -let result = lightWeightSet.has(123); +result = lightWeightSet.has(123); ``` @@ -188,7 +188,7 @@ equal(obj: Object): boolean let lightWeightSet = new LightWeightSet(); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("sdfs"); -let obj = {"Ahfbrgrbgnutfodgorrogorgrogofdfdf", "sdfs"}; +let obj = ["Ahfbrgrbgnutfodgorrogorgrogofdfdf", "sdfs"]; let result = lightWeightSet.equal(obj); ``` @@ -428,7 +428,7 @@ forEach(callbackfn: (value?: T, key?: T, set?: LightWeightSet<T>) => void, callbackfn的参数说明: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 当前遍历到的元素。 | +| value | T | 否 | 当前遍历到的元素。 | | key | T | 否 | 当前遍历到的元素(和value相同)。 | | set | LightWeightSet<T> | 否 | 当前调用forEach方法的实例对象。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md index a2b99e3f368bbee9dfc6961705e9aedade6ef3f3..768853d1914f671e0915749f1a9e1472186bd6c1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md @@ -176,7 +176,7 @@ let result = linkedList.get(2); ### getLastIndexOf -getLastIndexOf(element: T): number; +getLastIndexOf(element: T): number 返回指定元素最后一次出现时的下标值,查找失败返回-1。 @@ -507,6 +507,7 @@ let result = linkedList.set(2, "b"); ``` ### convertToArray + convertToArray(): Array<T> 把当前LinkedList实例转换成数组,并返回转换后的数组。 @@ -575,7 +576,7 @@ linkedList.getLast(); ### [Symbol.iterator] -[Symbol.iterator]\(): IterableIterator<T>; +[Symbol.iterator]\(): IterableIterator<T> 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-list.md b/zh-cn/application-dev/reference/apis/js-apis-list.md index 31fdd3e13d0dfa95e7cae70b9db8e64b91826728..4caf882c015ee5feb18226bdc5ed4a552a693526 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-list.md +++ b/zh-cn/application-dev/reference/apis/js-apis-list.md @@ -310,6 +310,7 @@ let result = list.remove(2); ``` ### replaceAllElements + replaceAllElements(callbackfn: (value: T, index?: number, list?: List<T>) => T, thisArg?: Object): void @@ -347,6 +348,7 @@ list.replaceAllElements((value, index) => { ``` ### forEach + forEach(callbackfn: (value: T, index?: number, List?: List<T>) => void, thisArg?: Object): void @@ -382,6 +384,7 @@ list.forEach((value, index) => { ``` ### sort + sort(comparator: (firstValue: T, secondValue: T) => number): void 对List中的元素进行一个排序操作。 @@ -412,6 +415,7 @@ list.sort(a, (b => b - a)); ``` ### getSubList + getSubList(fromIndex: number, toIndex: number): List<T> 根据下标截取List中的一段元素,并返回这一段List实例,包括起始值但不包括终止值。 @@ -443,6 +447,7 @@ let result2 = list.subList(2, 6); ``` ### clear + clear(): void 清除List中的所有元素,并把length置为0。 @@ -459,6 +464,7 @@ list.clear(); ``` ### set + set(index: number, element: T): T 将此 List 中指定位置的元素替换为指定元素。 @@ -489,6 +495,7 @@ list.set(2, "b"); ``` ### convertToArray + convertToArray(): Array<T> 把当前List实例转换成数组,并返回转换后的数组。 @@ -511,6 +518,7 @@ let result = list.convertToArray(); ``` ### isEmpty + isEmpty(): boolean 判断该List是否为空。 @@ -547,7 +555,7 @@ getFirst(): T **示例:** ``` -let list = new Vector(); +let list = new List(); list.add(2); list.add(4); list.add(5); @@ -580,7 +588,7 @@ let result = list.getLast(); ### [Symbol.iterator] -[Symbol.iterator]\(): IterableIterator<T>; +[Symbol.iterator]\(): IterableIterator<T> 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index eb19641c2015e90fb225ae49722782940c735d61..fb9cca77a8aab56e9a2cd00aff20d7a33d5369e5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -10,7 +10,7 @@ - 音频播放([AudioPlayer](#audioplayer)) - 视频播放([VideoPlayer](#videoplayer8)) - 音频录制([AudioRecorder](#audiorecorder)) -- 视频录制([VideoRecorder](#videoRecorder8)) +- 视频录制([VideoRecorder](#videoRecorder9)) 后续将提供以下功能:DataSource音视频播放、音视频编解码、容器封装解封装、媒体能力查询等功能。 @@ -125,9 +125,9 @@ createAudioRecorder(): AudioRecorder let audiorecorder = media.createAudioRecorder(); ``` -## media.createVideoRecorder8+ +## media.createVideoRecorder9+ -createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder8)>): void +createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>): void 异步方式创建视频录制实例。通过注册回调函数获取返回值。 @@ -137,7 +137,7 @@ createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder8)>): | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoRecorder](#videorecorder8)> | 是 | 异步创建视频录制实例回调方法。 | +| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | 是 | 异步创建视频录制实例回调方法。 | **示例:** @@ -154,9 +154,9 @@ media.createVideoRecorder((error, video) => { }); ``` -## media.createVideoRecorder8+ +## media.createVideoRecorder9+ -createVideoRecorder(): Promise<[VideoRecorder](#videorecorder8)> +createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)> 异步方式创建视频录制实例。通过Promise获取返回值。 @@ -166,7 +166,7 @@ createVideoRecorder(): Promise<[VideoRecorder](#videorecorder8)> | 类型 | 说明 | | ----------------------------------------- | ----------------------------------- | -| Promise<[VideoRecorder](#videorecorder8)> | 异步创建视频录制实例Promise返回值。 | +| Promise<[VideoRecorder](#videorecorder9)> | 异步创建视频录制实例Promise返回值。 | **示例:** @@ -1802,7 +1802,7 @@ audioRecorder.prepare(); // prepare不设置参数,触发'error' | audioSampleRate | number | 否 | 音频采集采样率,默认值为48000。 | | numberOfChannels | number | 否 | 音频采集声道数,默认值为2。 | | format | [AudioOutputFormat](#audiooutputformat) | 否 | 音量输出封装格式,默认设置为MPEG_4。 | -| location8+ | [Location](#location8) | 否 | 音频采集的地理位置。 | +| location | [Location](#location) | 否 | 音频采集的地理位置。 | | uri | string | 是 | 音频输出URI:fd://xx (fd number)
![zh-cn_image_0000001164217678](figures/zh-cn_image_url.png)
文件需要由调用者创建,并赋予适当的权限。 | | audioEncoderMime | [CodecMimeType](#codecmimetype8) | 否 | 音频编码格式。 | @@ -1836,9 +1836,9 @@ audioRecorder.prepare(); // prepare不设置参数,触发'error' | AMR_WB | 4 | 封装为AMR_WB格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | | AAC_ADTS | 6 | 封装为ADTS(Audio Data Transport Stream)格式,是AAC音频的传输流格式。 | -## VideoRecorder8+ +## VideoRecorder9+ -视频录制管理类,用于录制视频媒体。在调用VideoRecorder的方法前,需要先通过[createVideoRecorder()](#mediacreatevideorecorder8)构建一个[VideoRecorder](#videorecorder8)实例。 +视频录制管理类,用于录制视频媒体。在调用VideoRecorder的方法前,需要先通过[createVideoRecorder()](#mediacreatevideorecorder9)构建一个[VideoRecorder](#videorecorder9)实例。 视频录制demo可参考:[视频录制开发指导](../../media/video-recorder.md) @@ -1848,9 +1848,9 @@ audioRecorder.prepare(); // prepare不设置参数,触发'error' | 名称 | 类型 | 可读 | 可写 | 说明 | | ------------------ | -------------------------------------- | ---- | ---- | ---------------- | -| state8+ | [VideoRecordState](#videorecordstate8) | 是 | 否 | 视频录制的状态。 | +| state8+ | [VideoRecordState](#videorecordstate9) | 是 | 否 | 视频录制的状态。 | -### prepare8+ +### prepare9+ prepare(config: VideoRecorderConfig, callback: AsyncCallback\): void; @@ -1864,7 +1864,7 @@ prepare(config: VideoRecorderConfig, callback: AsyncCallback\): void; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------- | ---- | ----------------------------------- | -| config | [VideoRecorderConfig](#videorecorderconfig8) | 是 | 配置视频录制的相关参数。 | +| config | [VideoRecorderConfig](#videorecorderconfig9) | 是 | 配置视频录制的相关参数。 | | callback | AsyncCallback\ | 是 | 异步视频录制prepare方法的回调方法。 | **示例:** @@ -1918,7 +1918,7 @@ media.createVideoRecorder((err, recorder) => { }); ``` -### prepare8+ +### prepare9+ prepare(config: VideoRecorderConfig): Promise\; @@ -1932,7 +1932,7 @@ prepare(config: VideoRecorderConfig): Promise\; | 参数名 | 类型 | 必填 | 说明 | | ------ | -------------------------------------------- | ---- | ------------------------ | -| config | [VideoRecorderConfig](#videorecorderconfig8) | 是 | 配置视频录制的相关参数。 | +| config | [VideoRecorderConfig](#videorecorderconfig9) | 是 | 配置视频录制的相关参数。 | **返回值:** @@ -1989,7 +1989,7 @@ await videoRecorder.prepare(videoConfig).then(() => { }); ``` -### getInputSurface8+ +### getInputSurface9+ getInputSurface(callback: AsyncCallback\): void; @@ -2022,7 +2022,7 @@ videoRecorder.getInputSurface((err, surfaceId) => { }); ``` -### getInputSurface8+ +### getInputSurface9+ getInputSurface(): Promise\; @@ -2055,7 +2055,7 @@ await videoRecorder.getInputSurface().then((surfaceId) => { }); ``` -### start8+ +### start9+ start(callback: AsyncCallback\): void; @@ -2084,7 +2084,7 @@ videoRecorder.start((err) => { }); ``` -### start8+ +### start9+ start(): Promise\; @@ -2113,7 +2113,7 @@ await videoRecorder.start().then(() => { }); ``` -### pause8+ +### pause9+ pause(callback: AsyncCallback\): void; @@ -2142,7 +2142,7 @@ videoRecorder.pause((err) => { }); ``` -### pause8+ +### pause9+ pause(): Promise\; @@ -2171,7 +2171,7 @@ await videoRecorder.pause().then(() => { }); ``` -### resume8+ +### resume9+ resume(callback: AsyncCallback\): void; @@ -2198,7 +2198,7 @@ videoRecorder.resume((err) => { }); ``` -### resume8+ +### resume9+ resume(): Promise\; @@ -2225,7 +2225,7 @@ await videoRecorder.resume().then(() => { }); ``` -### stop8+ +### stop9+ stop(callback: AsyncCallback\): void; @@ -2254,7 +2254,7 @@ videoRecorder.stop((err) => { }); ``` -### stop8+ +### stop9+ stop(): Promise\; @@ -2283,7 +2283,7 @@ await videoRecorder.stop().then(() => { }); ``` -### release8+ +### release9+ release(callback: AsyncCallback\): void; @@ -2310,7 +2310,7 @@ videoRecorder.release((err) => { }); ``` -### release8+ +### release9+ release(): Promise\; @@ -2337,7 +2337,7 @@ await videoRecorder.release().then(() => { }); ``` -### reset8+ +### reset9+ reset(callback: AsyncCallback\): void; @@ -2366,7 +2366,7 @@ videoRecorder.reset((err) => { }); ``` -### reset8+ +### reset9+ reset(): Promise\; @@ -2395,7 +2395,7 @@ await videoRecorder.reset().then(() => { }); ``` -### on('error')8+ +### on('error')9+ on(type: 'error', callback: ErrorCallback): void @@ -2421,7 +2421,7 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 // 当获取videoRecordState接口出错时通过此订阅事件上报 ``` -## VideoRecordState8+ +## VideoRecordState9+ 视频录制的状态机。可通过state属性获取当前状态。 @@ -2436,7 +2436,7 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 | stopped | string | 视频录制停止。 | | error | string | 错误状态。 | -## VideoRecorderConfig8+ +## VideoRecorderConfig9+ 表示视频录制的参数设置。 @@ -2444,14 +2444,14 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 | 名称 | 参数类型 | 必填 | 说明 | | --------------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | -| audioSourceType | [AudioSourceType](#audiosourcetype8) | 是 | 视频录制的音频源类型。 | -| videoSourceType | [VideoSourceType](#videosourcetype8) | 是 | 视频录制的视频源类型。 | -| profile | [VideoRecorderProfile](#videorecorderprofile8) | 是 | 视频录制的profile。 | +| audioSourceType | [AudioSourceType](#audiosourcetype9) | 是 | 视频录制的音频源类型。 | +| videoSourceType | [VideoSourceType](#videosourcetype9) | 是 | 视频录制的视频源类型。 | +| profile | [VideoRecorderProfile](#videorecorderprofile9) | 是 | 视频录制的profile。 | | rotation | number | 否 | 录制视频的旋转角度。 | -| location | [Location](#location8) | 否 | 录制视频的地理位置。 | +| location | [Location](#location) | 否 | 录制视频的地理位置。 | | url | string | 是 | 视频输出URL:fd://xx (fd number)
![](figures/zh-cn_image_url.png)
文件需要由调用者创建,并赋予适当的权限。 | -## AudioSourceType8+ +## AudioSourceType9+ 表示视频录制中音频源类型的枚举。 @@ -2462,7 +2462,7 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 | AUDIO_SOURCE_TYPE_DEFAULT | 0 | 默认的音频输入源类型。 | | AUDIO_SOURCE_TYPE_MIC | 1 | 表示MIC的音频输入源。 | -## VideoSourceType8+ +## VideoSourceType9+ 表示视频录制中视频源类型的枚举。 @@ -2473,7 +2473,7 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 | VIDEO_SOURCE_TYPE_SURFACE_YUV | 0 | 输入surface中携带的是raw data。 | | VIDEO_SOURCE_TYPE_SURFACE_ES | 1 | 输入surface中携带的是ES data。 | -## VideoRecorderProfile8+ +## VideoRecorderProfile9+ 视频录制的配置文件。 @@ -2486,9 +2486,11 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 | audioCodec | [CodecMimeType](#codecmimetype8) | 是 | 音频编码格式。 | | audioSampleRate | number | 是 | 音频采样率。 | | fileFormat | [ContainerFormatType](#containerformattype8) | 是 | 文件的容器格式。 | -| videoCodec | [CodecMimeType](#codecmimetype8) | 是 | 视频编码格式。 | +| videoBitrate | number | 是 | 视频编码比特率。 | +| videoCodec | [CodecMimeType](#CodecMimeType8) | 是 | 视频编码格式。 | | videoFrameWidth | number | 是 | 录制视频帧的宽。 | | videoFrameHeight | number | 是 | 录制视频帧的高。 | +| videoFrameRate | number | 是 | 录制视频帧率。 | ## ContainerFormatType8+ @@ -2501,7 +2503,7 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 | CFT_MPEG_4 | "mp4" | 视频的容器格式,MP4。 | | CFT_MPEG_4A | "m4a" | 音频的容器格式,M4A。 | -## Location8+ +## Location 视频录制的地理位置。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-missionManager.md b/zh-cn/application-dev/reference/apis/js-apis-missionManager.md index aef0d8659c0a41c8c24de9fc180b629e826acb2b..e3cf1dba13d645fa472c26d20cab7b761c9d445d 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-missionManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-missionManager.md @@ -18,7 +18,7 @@ import missionManager from '@ohos.application.missionManager' ## missionManager.registerMissionListener -function registerMissionListener(listener: MissionListener): number; +registerMissionListener(listener: MissionListener): number; 注册系统任务状态监听。 @@ -53,7 +53,7 @@ function registerMissionListener(listener: MissionListener): number; ## missionManager.unregisterMissionListener -function unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>): void; +unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>): void; 取消任务状态监听。 @@ -86,7 +86,7 @@ function unregisterMissionListener(listenerId: number, callback: AsyncCallback&l ## missionManager.unregisterMissionListener -function unregisterMissionListener(listenerId: number): Promise<void>; +unregisterMissionListener(listenerId: number): Promise<void>; 取消任务状态监听,以promise方式返回执行结果。 @@ -110,7 +110,7 @@ function unregisterMissionListener(listenerId: number): Promise<void>; console.log("registerMissionListener") var listenerid = missionManager.registerMissionListener(listener); - await missionManager.unregisterMissionListener(listenerid).catch(function (err){ + missionManager.unregisterMissionListener(listenerid).catch(function (err){ console.log(err); }); ``` @@ -118,7 +118,7 @@ function unregisterMissionListener(listenerId: number): Promise<void>; ## missionManager.getMissionInfo -function getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<MissionInfo>): void; +getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<MissionInfo>): void; 获取任务信息,以异步回调的方式返回任务信息。 @@ -145,13 +145,13 @@ function getMissionInfo(deviceId: string, missionId: number, callback: AsyncCall console.log("mission.timestamp = " + mission.timestamp); console.log("mission.label = " + mission.label); console.log("mission.iconPath = " + mission.iconPath); - } + }); ``` ## missionManager.getMissionInfo -function getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>; +getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>; 获取任务信息,以promise方式返回任务信息。 @@ -175,7 +175,7 @@ function getMissionInfo(deviceId: string, missionId: number): Promise<Mission ```js import missionManager from '@ohos.application.missionManager' - var mission = await missionManager.getMissionInfo("", id).catch(function (err){ + var mission = missionManager.getMissionInfo("", id).catch(function (err){ console.log(err); }); ``` @@ -183,7 +183,7 @@ function getMissionInfo(deviceId: string, missionId: number): Promise<Mission ## missionManager.getMissionInfos -function getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Array<MissionInfo>>): void; +getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Array<MissionInfo>>): void; 获取所有任务信息,以回调函数的方式返回任务信息数组。 @@ -212,7 +212,7 @@ function getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallba ## missionManager.getMissionInfos -function getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionInfo>>; +getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionInfo>>; 获取所有任务信息,以promise的方式返回任务信息数组。 @@ -236,7 +236,7 @@ function getMissionInfos(deviceId: string, numMax: number): Promise<Array< ```js import missionManager from '@ohos.application.missionManager' - var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ console.log(err); }); ``` @@ -244,7 +244,7 @@ function getMissionInfos(deviceId: string, numMax: number): Promise<Array< ## missionManager.getMissionSnapShot -function getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback<MissionSnapshot>): void; +getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback<MissionSnapshot>): void; 获取任务快照,以回调函数的方式返回快照内容。 @@ -279,7 +279,7 @@ function getMissionSnapShot(deviceId: string, missionId: number, callback: Async ## missionManager.getMissionSnapShot -function getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnapshot>; +getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnapshot>; 获取任务快照,以promise的方式返回快照内容。 @@ -303,13 +303,13 @@ function getMissionSnapShot(deviceId: string, missionId: number): Promise<Mis ```js import missionManager from '@ohos.application.missionManager' - var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ console.log(err); }); console.log("size = " + allMissions.length); console.log("missions = " + JSON.stringify(allMissions)); var id = allMissions[0].missionId; - var snapshot = await missionManager.getMissionSnapShot("", id).catch(function (err){ + var snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){ console.log(err); }); ``` @@ -317,7 +317,7 @@ function getMissionSnapShot(deviceId: string, missionId: number): Promise<Mis ## missionManager.lockMission -function lockMission(missionId: number, callback: AsyncCallback<void>): void; +lockMission(missionId: number, callback: AsyncCallback<void>): void; 锁定指定任务id的任务,以回调函数的方式返回。 @@ -350,7 +350,7 @@ function lockMission(missionId: number, callback: AsyncCallback<void>): vo ## missionManager.lockMission -function lockMission(missionId: number): Promise<void>; +lockMission(missionId: number): Promise<void>; 锁定指定任务id的任务,以promise方式返回。 @@ -367,14 +367,14 @@ function lockMission(missionId: number): Promise<void>; ```js import missionManager from '@ohos.application.missionManager' - var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ console.log(err); }); console.log("size = " + allMissions.length); console.log("missions = " + JSON.stringify(allMissions)); var id = allMissions[0].missionId; - await missionManager.lockMission(id).catch(function (err){ + missionManager.lockMission(id).catch(function (err){ console.log(err); }); ``` @@ -382,7 +382,7 @@ function lockMission(missionId: number): Promise<void>; ## missionManager.unlockMission -function unlockMission(missionId: number, callback: AsyncCallback<void>): void; +unlockMission(missionId: number, callback: AsyncCallback<void>): void; 解锁指定任务id的任务,以回调函数的方式返回。 @@ -414,7 +414,7 @@ function unlockMission(missionId: number, callback: AsyncCallback<void>): ## missionManager.unlockMission -function unlockMission(missionId: number): Promise<void>; +unlockMission(missionId: number): Promise<void>; 解锁指定任务id的任务,以promise的方式返回。 @@ -431,17 +431,17 @@ function unlockMission(missionId: number): Promise<void>; ```js import missionManager from '@ohos.application.missionManager' - var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ console.log(err); }); console.log("size = " + allMissions.length); console.log("missions = " + JSON.stringify(allMissions)); var id = allMissions[0].missionId; - await missionManager.lockMission(id).catch(function (err){ + missionManager.lockMission(id).catch(function (err){ console.log(err); }); - await missionManager.unlockMission(id).catch(function (err){ + missionManager.unlockMission(id).catch(function (err){ console.log(err); }); ``` @@ -449,7 +449,7 @@ function unlockMission(missionId: number): Promise<void>; ## missionManager.clearMission -function clearMission(missionId: number, callback: AsyncCallback<void>): void; +clearMission(missionId: number, callback: AsyncCallback<void>): void; 清理指定任务id的任务,无论该任务是否被锁定,以回调函数的方式返回。 @@ -482,7 +482,7 @@ function clearMission(missionId: number, callback: AsyncCallback<void>): v ## missionManager.clearMission -function clearMission(missionId: number): Promise<void>; +clearMission(missionId: number): Promise<void>; 清理指定任务id的任务,无论该任务是否被锁定,以promise的方式返回。 @@ -499,14 +499,14 @@ function clearMission(missionId: number): Promise<void>; ```js import missionManager from '@ohos.application.missionManager' - var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ console.log(err); }); console.log("size = " + allMissions.length); console.log("missions = " + JSON.stringify(allMissions)); var id = allMissions[0].missionId; - await missionManager.clearMission(id).catch(function (err){ + missionManager.clearMission(id).catch(function (err){ console.log(err); }); ``` @@ -514,7 +514,7 @@ function clearMission(missionId: number): Promise<void>; ## missionManager.clearAllMissions -function clearAllMissions(callback: AsyncCallback<void>): void; +clearAllMissions(callback: AsyncCallback<void>): void; 清理所有未锁定的任务,以回调函数的方式返回。 @@ -533,7 +533,7 @@ function clearAllMissions(callback: AsyncCallback<void>): void; ## missionManager.clearAllMissions -function clearAllMissions(): Promise<void>; +clearAllMissions(): Promise<void>; 清理所有未锁定的任务,以promise的方式返回。 @@ -543,7 +543,7 @@ function clearAllMissions(): Promise<void>; ```js import missionManager from '@ohos.application.missionManager' - await missionManager.clearAllMissions().catch(function (err){ + missionManager.clearAllMissions().catch(function (err){ console.log(err); }); ``` @@ -551,7 +551,7 @@ function clearAllMissions(): Promise<void>; ## missionManager.moveMissionToFront -function moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void; +moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void; 把指定任务id的任务切到前台,以回调函数的方式返回。 @@ -584,7 +584,7 @@ function moveMissionToFront(missionId: number, callback: AsyncCallback<void&g ## missionManager.moveMissionToFront -function moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback<void>): void; +moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback<void>): void; 把指定任务id的任务切到前台,同时指定任务切换到前台时的启动参数,例如窗口模式、设备ID等,以回调函数的方式返回。 @@ -618,7 +618,7 @@ function moveMissionToFront(missionId: number, options: StartOptions, callback: ## missionManager.moveMissionToFront -function moveMissionToFront(missionId: number, options?: StartOptions): Promise<void>; +moveMissionToFront(missionId: number, options?: StartOptions): Promise<void>; 把指定任务id的任务切到前台,以promise的方式返回。 @@ -636,14 +636,14 @@ function moveMissionToFront(missionId: number, options?: StartOptions): Promise& ```js import missionManager from '@ohos.application.missionManager' - var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){ + var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ console.log(err); }); console.log("size = " + allMissions.length); console.log("missions = " + JSON.stringify(allMissions)); var id = allMissions[0].missionId; - await missionManager.moveMissionToFront(id).catch(function (err){ + missionManager.moveMissionToFront(id).catch(function (err){ console.log(err); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md index a47a4fb0647d085027f123eb3d6e6551aa3f439f..12cc9d84d9602eb68ac52aa30fb52445518f9edc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -10,33 +10,35 @@ import account_osAccount from '@ohos.account.osAccount'; ``` -## 系统能力 - -SystemCapability.Account.OsAccount - ## account_osAccount.getAccountManager getAccountManager(): AccountManager 获取系统帐号能力的实例。 -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例: +**返回值:** +| 类型 | 说明 | +| --------------------------------- | ------------------------ | +| [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); ``` ## OsAccountType + 枚举,系统帐号类型。 - | 参数 | 默认值 | 说明 | - | -------- | -------- | -------- | - | ADMIN | 0 | 管理员帐号。| - | NORMAL | 1 | 普通帐号。| - | GUEST | 2 | 访客帐号。| + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。 + +| 参数 | 默认值 | 说明 | +| ------ | ------ | ------------ | +| ADMIN | 0 | 管理员帐号。 | +| NORMAL | 1 | 普通帐号。 | +| GUEST | 2 | 访客帐号。 | ## AccountManager @@ -48,14 +50,18 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void 激活指定系统帐号,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | -------------------- | - | localId | number | 是 | 要激活的系统帐号ID。 | - | callback | AsyncCallback<void> | 是 | 回调结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------- | +| localId | number | 是 | 要激活的系统帐号ID。 | +| callback | AsyncCallback<void> | 是 | 回调结果。 | -- 示例:激活ID为100的系统帐号 +**示例:**激活ID为100的系统帐号 ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -70,19 +76,23 @@ activateOsAccount(localId: number): Promise<void> 激活指定系统帐号,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 要激活的系统帐号ID。 | +**系统能力:** SystemCapability.Account.OsAccount -- 返回值: +**参数:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | -------------------- | +| localId | number | 是 | 要激活的系统帐号ID。 | -- 示例:激活ID为100的系统帐号 +**返回值:** + +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:**激活ID为100的系统帐号 ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -99,13 +109,15 @@ isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void 判断是否支持多系统帐号,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | ------------------------------ | - | callback | AsyncCallback<boolean> | 是 | 回调结果,支持多系统帐号则返回true,否则返回false。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | --------------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调结果,支持多系统帐号则返回true,否则返回false。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -121,13 +133,15 @@ isMultiOsAccountEnable(): Promise<boolean> 判断是否支持多系统帐号,使用Promise方式异步返回结果。 -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果,支持多系统帐号则返回true,否则返回false。 | +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,支持多系统帐号则返回true,否则返回false。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -144,14 +158,18 @@ isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): voi 判断指定系统帐号是否处于激活状态,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | ------------------------------ | - | localId | number | 是 | 系统帐号ID。 | - | callback | AsyncCallback<boolean> | 是 | 回调结果,处于激活状态则返回true,否则返回false。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例:判断ID为100的系统帐号是否处于激活状态 +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<boolean> | 是 | 回调结果,处于激活状态则返回true,否则返回false。 | + +**示例:**判断ID为100的系统帐号是否处于激活状态 ``` const accountManager = account_osAccount.getAccountManager(); @@ -168,19 +186,23 @@ isOsAccountActived(localId: number): Promise<boolean> 判断指定系统帐号是否处于激活状态,使用Promise方式异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 系统帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果,处于激活状态则返回true,否则返回false。 | +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,处于激活状态则返回true,否则返回false。 | -- 示例:判断ID为100的系统帐号是否处于激活状态 +**示例:**判断ID为100的系统帐号是否处于激活状态 ``` const accountManager = account_osAccount.getAccountManager(); @@ -196,17 +218,21 @@ isOsAccountActived(localId: number): Promise<boolean> isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback<boolean>): void -判断指定系统帐号是否具有指定[约束](#系统帐号约束列表),使用callback回调异步返回结果。 +判断指定系统帐号是否具有指定约束,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ---------------------- | ---- | ------------------------------ | - | localId | number | 是 | 指定的系统帐号ID。 | - | constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 | - | callback | AsyncCallback<boolean> | 是 | 回调结果,具有指定约束则返回true,否则返回false。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例:判断ID为100的系统帐号是否有禁止使用wifi的[约束](#系统帐号约束列表) +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ---------------------------- | ---- | ------------------------------------------------- | +| localId | number | 是 | 指定的系统帐号ID。 | +| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 | +| callback | AsyncCallback<boolean> | 是 | 回调结果,具有指定约束则返回true,否则返回false。 | + +**示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -221,22 +247,26 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boolean> -判断指定系统帐号是否具有指定[约束](#系统帐号约束列表),使用Promise方式异步返回结果。 +判断指定系统帐号是否具有指定约束,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------ | ---- | ---------------- | - | localId | number | 是 | 指定的系统帐号ID。 | - | constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------------------------- | +| localId | number | 是 | 指定的系统帐号ID。 | +| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果,具有指定[约束](#系统帐号约束列表)则返回true,否则返回false。 | +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,具有指定约束则返回true,否则返回false。 | -- 示例:判断ID为100的系统帐号是否有禁止使用wifi的[约束](#系统帐号约束列表) +**示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -254,13 +284,15 @@ isTestOsAccount(callback: AsyncCallback<boolean>): void 检查当前系统帐号是否为测试帐号,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | ------------------------------------------ | - | callback | AsyncCallback<boolean> | 是 | 回调结果,是测试帐号则返回true,否则返回false。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ----------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调结果,是测试帐号则返回true,否则返回false。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -276,13 +308,15 @@ isTestOsAccount(): Promise<boolean> 检查当前系统帐号是否为测试帐号,使用Promise方式异步返回结果。 -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果,是测试帐号则返回true,否则返回false。 | +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,是测试帐号则返回true,否则返回false。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -299,13 +333,15 @@ isOsAccountVerified(callback: AsyncCallback<boolean>): void 检查当前系统帐号是否已验证,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | ---------------------------------- | - | callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -321,14 +357,16 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo 检查指定系统帐号是否已验证,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | ---------------------------------- | - | localId | number | 否 | 指定的系统帐号ID。 | - | callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------- | +| localId | number | 否 | 指定的系统帐号ID。 | +| callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -340,23 +378,25 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo ### isOsAccountVerified -isOsAccountVerified(localId: number?): Promise<boolean> +isOsAccountVerified(localId?: number): Promise<boolean> 检查指定系统帐号是否已验证,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 否 | 指定的系统帐号ID。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------ | +| localId | number | 否 | 指定的系统帐号ID。 | - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果,已验证则返回true,否则返回false。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,已验证则返回true,否则返回false。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -373,14 +413,20 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void 删除指定系统帐号,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | ------------------------ | - | localId | number | 是 | 要删除的系统帐号ID。 | - | callback | AsyncCallback<void> | 是 | 回调结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------- | +| localId | number | 是 | 要删除的系统帐号ID。 | +| callback | AsyncCallback<void> | 是 | 回调结果。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -399,19 +445,25 @@ removeOsAccount(localId: number): Promise<void> 删除指定系统帐号,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 要删除的系统帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | -------------------- | +| localId | number | 是 | 要删除的系统帐号ID。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -431,18 +483,24 @@ removeOsAccount(localId: number): Promise<void> setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean,callback: AsyncCallback<void>): void -为指定系统帐号设置/删除[约束](#系统帐号约束列表),使用callback回调异步返回结果。 +为指定系统帐号设置/删除约束返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | ----------- | ------------------- | ---- | ------------------------------- | - | localId | number | 是 | 系统帐号ID。 | - | constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 | - | enable | boolean | 是 | 设置(true)/删除(false) | - | callback | AsyncCallback<void> | 是 | 回调结果。 | +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS -- 示例:给ID为100的系统帐号设置禁止使用wifi的[约束](#系统帐号约束列表) +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 | +| enable | boolean | 是 | 设置(true)/删除(false) | +| callback | AsyncCallback<void> | 是 | 回调结果。 | + +**示例:**给ID为100的系统帐号设置禁止使用wifi的约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -456,23 +514,29 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean): Promise<void> -为指定系统帐号设置/删除[约束](#系统帐号约束列表),使用Promise方式异步返回结果。 +为指定系统帐号设置/删除约束回结果。 + +此接口为系统接口,三方应用不支持调用。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS - | 参数名 | 类型 | 必填 | 说明 | - | ----------- | ------------- | ---- | ----------------------- | - | localId | number | 是 | 系统帐号ID。 | - | constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 | - | enable | boolean | 是 | 设置(true)/删除(false)。 | +**系统能力:** SystemCapability.Account.OsAccount -- 返回值: +**参数:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------- | ---- | -------------------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 | +| enable | boolean | 是 | 设置(true)/删除(false)。 | -- 示例:删除ID为100的系统帐号的禁止使用wifi的[约束](#系统帐号约束列表) +**返回值:** + +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:**删除ID为100的系统帐号的禁止使用wifi的约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -490,15 +554,19 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback< 设置指定系统帐号的帐号名,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | :-------- | ------------------- | ---- | ------------------------ | - | localId | number | 是 | 系统帐号ID。 | - | localName | string | 是 | 帐号名。 | - | callback | AsyncCallback<void> | 是 | 回调结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| :-------- | ------------------------- | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | +| localName | string | 是 | 帐号名。 | +| callback | AsyncCallback<void> | 是 | 回调结果。 | -- 示例:将ID为100的系统帐号的帐号名设置成demoName +**示例:**将ID为100的系统帐号的帐号名设置成demoName ``` const accountManager = account_osAccount.getAccountManager(); @@ -515,20 +583,24 @@ setOsAccountName(localId: number, localName: string): Promise<void> 设置指定系统帐号的帐号名,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------ | ---- | ----------------------- | - | localId | number | 是 | 系统帐号ID。 | - | localName | string | 是 | 帐号名。 | +**系统能力:** SystemCapability.Account.OsAccount -- 返回值: +**参数:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | +| localName | string | 是 | 帐号名。 | -- 示例:将ID为100的系统帐号的帐号名设置成demoName +**返回值:** + +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:**将ID为100的系统帐号的帐号名设置成demoName ``` const accountManager = account_osAccount.getAccountManager(); @@ -547,13 +619,17 @@ getCreatedOsAccountsCount(callback: AsyncCallback<number>): void 获取已创建的系统帐号数量,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ------------------------------ | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是已创建的系统帐号的数量。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------ | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是已创建的系统帐号的数量。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -569,13 +645,17 @@ getCreatedOsAccountsCount(): Promise<number> 获取已创建的系统帐号数量,使用Promise方式异步返回结果。 -- 返回值: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是已创建的系统帐号的数量。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例: +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是已创建的系统帐号的数量。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -592,13 +672,15 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void 获取当前进程所属的系统帐号的帐号ID,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ----------------------------------------- | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------------------------------------------- | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号ID。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -614,13 +696,15 @@ getOsAccountLocalIdFromProcess(): Promise<number> 获取当前进程所属的系统帐号的帐号ID,使用Promise方式异步返回结果。 -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号ID。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号ID。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -637,14 +721,16 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): 从进程uid中获取该uid所属的系统帐号的帐号ID,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | --------------------------------------- | - | uid | number | 是 | 进程uid。 | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是uid所属的系统帐号的帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------------------------------------- | +| uid | number | 是 | 进程uid。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是uid所属的系统帐号的帐号ID。 | -- 示例:查询值为12345678的uid所属的系统帐号的帐号ID +**示例:**查询值为12345678的uid所属的系统帐号的帐号ID ``` const accountManager = account_osAccount.getAccountManager(); @@ -661,19 +747,21 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number> 从进程uid中获取该uid所属的系统帐号的帐号ID,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------- | - | uid | number | 是 | 进程uid。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | --------- | +| uid | number | 是 | 进程uid。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是uid所属的系统帐号的帐号ID。 | +**返回值:** -- 示例:查询值为12345678的uid所属的系统帐号的帐号ID +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是uid所属的系统帐号的帐号ID。 | + +**示例:**查询值为12345678的uid所属的系统帐号的帐号ID ``` const accountManager = account_osAccount.getAccountManager(); @@ -685,20 +773,24 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number> }); ``` -### getOsAccountLocalIdFromDomain +### getOsAccountLocalIdFromDomain8+ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void 根据域帐号信息,获取与其关联的系统帐号的帐号ID。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | --------------------------------------- | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是和域帐号关联的系统帐号ID。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | -------------------------------------------- | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是和域帐号关联的系统帐号ID。 | + +**示例:** ``` var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; @@ -709,25 +801,29 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall }); ``` -### getOsAccountLocalIdFromDomain +### getOsAccountLocalIdFromDomain8+ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number> 根据域帐号信息,获取与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------- | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | ------------ | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是和域帐号关联的系统帐号ID。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是和域帐号关联的系统帐号ID。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -745,13 +841,17 @@ queryMaxOsAccountNumber(callback: AsyncCallback<number>): void 查询允许创建的系统帐号的最大数量,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ---------------------------------- | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是允许创建的系统帐号的最大数量。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------------ | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是允许创建的系统帐号的最大数量。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -767,13 +867,17 @@ queryMaxOsAccountNumber(): Promise<number> 查询允许创建的系统帐号的最大数量,使用Promise方式异步返回结果。 -- 返回值: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是允许创建的系统帐号的最大数量。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是允许创建的系统帐号的最大数量。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -788,16 +892,20 @@ queryMaxOsAccountNumber(): Promise<number> getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<string>>): void -获取指定系统帐号的全部[约束](#系统帐号约束列表),使用callback回调异步返回结果。 +获取指定系统帐号的全部约束,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------- | ---- | ---------------------------------- | - | localId | number | 是 | 系统帐号ID。 | - | callback | AsyncCallback<Array<string>> | 是 | 回调结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 | +**参数:** -- 示例:获取ID为100的系统帐号的全部[约束](#系统帐号约束列表) +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<Array<string>> | 是 | 回调结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 | + +**示例:**获取ID为100的系统帐号的全部约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -812,21 +920,25 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array< getOsAccountAllConstraints(localId: number): Promise<Array<string>> -获取指定系统帐号的全部[约束](#系统帐号约束列表),使用Promise方式异步返回结果。 +获取指定系统帐号的全部约束,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 系统帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<Array<string>> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 | +| 类型 | 说明 | +| :--------------------------------- | :----------------------------------------------------------- | +| Promise<Array<string>> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 | -- 示例:获取ID为100的系统帐号的全部[约束](#系统帐号约束列表) +**示例:**获取ID为100的系统帐号的全部约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -844,13 +956,17 @@ queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>& 查询已创建的所有系统帐号的信息列表,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ----------------------------------- | ---- | -------------------------------- | - | callback | AsyncCallback<Array<[OsAccountInfo](#osaccountinfo)>> | 是 | 回调结果,返回的是已创建的所有系统帐号的信息列表。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例: +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| callback | AsyncCallback<Array<[OsAccountInfo](#osaccountinfo)>> | 是 | 回调结果,返回的是已创建的所有系统帐号的信息列表。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -866,13 +982,17 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>> 查询已创建的所有系统帐号的信息列表,使用Promise方式异步返回结果。 -- 返回值: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** - | 类型 | 说明 | - | :---------------------------- | :---------------------------------- | - | Promise<Array<[OsAccountInfo](#osaccountinfo)>> | Promise实例,用于获取异步返回结果,返回的是已创建的所有系统帐号的信息列表。 | +| 类型 | 说明 | +| :---------------------------------------------------------- | :----------------------------------------------------------- | +| Promise<Array<[OsAccountInfo](#osaccountinfo)>> | Promise实例,用于获取异步返回结果,返回的是已创建的所有系统帐号的信息列表。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -883,19 +1003,21 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>> }); ``` -### queryActivatedOsAccountIds +### queryActivatedOsAccountIds8+ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void 查询当前处于激活状态的系统帐号的ID列表,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ----------------------------------- | ---- | -------------------------------- | - | callback | AsyncCallback<Array<number>> | 是 | 回调结果,返回的是当前处于激活状态的系统帐号的ID列表。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ | +| callback | AsyncCallback<Array<number>> | 是 | 回调结果,返回的是当前处于激活状态的系统帐号的ID列表。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -908,19 +1030,21 @@ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): }); ``` -### queryActivatedOsAccountIds +### queryActivatedOsAccountIds8+ queryActivatedOsAccountIds(): Promise<Array<number>> 查询当前处于激活状态的系统帐号的ID列表,使用Promise方式异步返回结果。 -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** - | 类型 | 说明 | - | :---------------------------- | :---------------------------------- | - | Promise<Array<number>> | Promise实例,用于获取异步返回结果,返回的是当前处于激活状态的系统帐号的ID列表。 | +| 类型 | 说明 | +| :--------------------------------- | :----------------------------------------------------------- | +| Promise<Array<number>> | Promise实例,用于获取异步返回结果,返回的是当前处于激活状态的系统帐号的ID列表。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -937,15 +1061,21 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback& 创建一个系统帐号,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | :-------- | ---------------------------- | ---- | -------------------- | - | localName | string | 是 | 创建的系统帐号的名称。 | - | type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| :-------- | ---------------------------------------------------- | ---- | ------------------------------------------ | +| localName | string | 是 | 创建的系统帐号的名称。 | +| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -961,20 +1091,26 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf 创建一个系统帐号,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------- | ---- | ---------------- | - | localName | string | 是 | 创建的系统帐号的名称。 | - | type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------------- | ---- | ---------------------- | +| localName | string | 是 | 创建的系统帐号的名称。 | +| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 | +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -985,21 +1121,27 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf }); ``` -### createOsAccountForDomain +### createOsAccountForDomain8+ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>): void 根据域帐号信息,创建一个系统帐号并将其与域帐号关联,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | :-------- | ---------------------------- | ---- | -------------------- | - | type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| :--------- | ---------------------------------------------------- | ---- | ------------------------------------------ | +| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1010,26 +1152,32 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal }); ``` -### createOsAccountForDomain +### createOsAccountForDomain8+ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise<OsAccountInfo> 根据传入的域帐号信息,创建与其关联的系统帐号,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------- | ---- | ---------------- | - | type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | ---------------------- | +| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | + +**返回值:** + +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1047,13 +1195,17 @@ queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void 查询当前进程所属的系统帐号的信息,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------- | ---- | -------------------------- | - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是当前进程所属的系统帐号信息。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是当前进程所属的系统帐号信息。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1069,13 +1221,17 @@ queryCurrentOsAccount(): Promise<OsAccountInfo> 查询当前进程所属的系统帐号的信息,使用Promise方式异步返回结果。 -- 返回值: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号信息。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号信息。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1092,14 +1248,20 @@ queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo> 查询指定系统帐号的信息,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------- | ---- | -------------------------- | - | localId | number | 是 | 要查询的系统帐号的ID | - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是查到的系统帐号的信息。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例:查询ID为100的系统帐号信息 +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------- | +| localId | number | 是 | 要查询的系统帐号的ID | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是查到的系统帐号的信息。 | + +**示例:**查询ID为100的系统帐号信息 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1116,19 +1278,25 @@ queryOsAccountById(localId: number): Promise<OsAccountInfo> 查询指定系统帐号的信息,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------- | ---- | -------------------------- | - | localId | number | 是 | 要查询的系统帐号的ID | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | -------------------- | +| localId | number | 是 | 要查询的系统帐号的ID | - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是查到的系统帐号的信息。 | +**返回值:** -- 示例:查询ID为100的系统帐号信息 +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是查到的系统帐号的信息。 | + +**示例:**查询ID为100的系统帐号信息 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1146,13 +1314,15 @@ getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void 查询当前进程所属的系统帐号的帐号类型,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------- | ---- | ---------------------------------------- | - | callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- | +| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1168,13 +1338,15 @@ getOsAccountTypeFromProcess(): Promise<OsAccountType> 查询当前进程所属的系统帐号的帐号类型,使用Promise方式异步返回结果。 -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountType](#osaccounttype)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 | +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountType](#osaccounttype)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1191,13 +1363,17 @@ getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void 获取分布式虚拟设备ID,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ---------------------------- | - | callback | AsyncCallback<string> | 是 | 回调结果,返回的是分布式虚拟设备ID。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例: +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------ | +| callback | AsyncCallback<string> | 是 | 回调结果,返回的是分布式虚拟设备ID。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1213,13 +1389,17 @@ getDistributedVirtualDeviceId(): Promise<string> 获取分布式虚拟设备ID,使用Promise方式异步返回结果。 -- 返回值: +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果,返回的是分布式虚拟设备ID。 | +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果,返回的是分布式虚拟设备ID。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1236,14 +1416,20 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>) 获取指定系统帐号的头像信息,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ------------------------ | - | localId | number | 是 | 系统帐号ID。 | - | callback | AsyncCallback<string> | 是 | 回调结果,返回的是该系统帐号的头像信息。 | +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS -- 示例:获取ID为100的系统帐号的头像 +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ---------------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<string> | 是 | 回调结果,返回的是该系统帐号的头像信息。 | + +**示例:**获取ID为100的系统帐号的头像 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1260,19 +1446,25 @@ getOsAccountProfilePhoto(localId: number): Promise<string> 获取指定系统帐号的头像信息,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 系统帐号ID。 | +**系统能力:** SystemCapability.Account.OsAccount -- 返回值: +**参数:** - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的头像信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | -- 示例:获取ID为100的系统帐号的头像 +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的头像信息。 | + +**示例:**获取ID为100的系统帐号的头像 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1290,15 +1482,21 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback 为指定系统帐号设置头像信息,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | ------------------------ | - | localId | number | 是 | 系统帐号ID。 | - | photo | string | 是 | 头像信息。 | - | callback | AsyncCallback<void> | 是 | 回调结果。 | +**参数:** -- 示例:给ID为100的系统帐号设置头像 +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | +| photo | string | 是 | 头像信息。 | +| callback | AsyncCallback<void> | 是 | 回调结果。 | + +**示例:**给ID为100的系统帐号设置头像 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1318,20 +1516,26 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void> 为指定系统帐号设置头像信息,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 系统帐号ID。 | - | photo | string | 是 | 头像信息。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | +| photo | string | 是 | 头像信息。 | - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例:给ID为100的系统帐号设置头像 +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:**给ID为100的系统帐号设置头像 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1347,20 +1551,22 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void> }); ``` -### getOsAccountLocalIdBySerialNumber +### getOsAccountLocalIdBySerialNumber8+ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void 通过SN码查询与其关联的系统帐号的帐号ID,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------------ | --------------------- | ---- | ------------------------------ | - | serialNumber | number | 是 | 帐号SN码。 | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是与SN码关联的系统帐号的帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | --------------------------- | ---- | ------------------------------------------------ | +| serialNumber | number | 是 | 帐号SN码。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与SN码关联的系统帐号的帐号ID。 | -- 示例:查询与SN码12345关联的系统帐号的ID +**示例:**查询与SN码12345关联的系统帐号的ID ``` const accountManager = account_osAccount.getAccountManager(); @@ -1371,25 +1577,27 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback& }); ``` -### getOsAccountLocalIdBySerialNumber +### getOsAccountLocalIdBySerialNumber8+ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> 通过SN码查询与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------------ | ------ | ---- | ---------- | - | serialNumber | number | 是 | 帐号SN码。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------ | ---- | ---------- | +| serialNumber | number | 是 | 帐号SN码。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是与SN码关联的系统帐号的帐号ID。 | +**返回值:** -- 示例:查询与SN码12345关联的系统帐号的ID +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与SN码关联的系统帐号的帐号ID。 | + +**示例:**查询与SN码12345关联的系统帐号的ID ``` const accountManager = account_osAccount.getAccountManager(); @@ -1401,20 +1609,22 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> }); ``` -### getSerialNumberByOsAccountLocalId +### getSerialNumberByOsAccountLocalId8+ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void 通过系统帐号ID获取与该系统帐号关联的SN码,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ------------------------------ | - | localId | number | 是 | 系统帐号ID。 | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是与该系统帐号关联的SN码。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------ | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与该系统帐号关联的SN码。 | -- 示例:获取ID为100的系统帐号关联的SN码 +**示例:**获取ID为100的系统帐号关联的SN码 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1425,25 +1635,27 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<nu }); ``` -### getSerialNumberByOsAccountLocalId +### getSerialNumberByOsAccountLocalId8+ getSerialNumberByOsAccountLocalId(localId: number): Promise<number> 通过系统帐号ID获取与该系统帐号关联的SN码,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 系统帐号ID。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是与该系统帐号关联的SN码。 | +**返回值:** -- 示例:获取ID为100的系统帐号关联的SN码 +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与该系统帐号关联的SN码。 | + +**示例:**获取ID为100的系统帐号关联的SN码 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1461,15 +1673,21 @@ on(type: 'activate' | 'activating', name: string, callback: Callback<number&g 订阅系统帐号的变动信息,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------------------------- | ---- | ------------------------ | - | type | 'activate' \| 'activating' | 是 | 订阅类型,activate表示订阅的是帐号已激活完成的事件,activating表示订阅的是帐号正在激活的事件。 | - | name | string | 是 | 订阅名称,可自定义,要求非空且长度不超过1024字节。| - | callback | Callback<number> | 是 | 订阅系统帐号变动信息的回调,表示当前事件对应的系统帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------------------------------------------------ | +| type | 'activate' \| 'activating' | 是 | 订阅类型,activate表示订阅的是帐号已激活完成的事件,activating表示订阅的是帐号正在激活的事件。 | +| name | string | 是 | 订阅名称,可自定义,要求非空且长度不超过1024字节。 | +| callback | Callback<number> | 是 | 订阅系统帐号变动信息的回调,表示当前事件对应的系统帐号ID。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1485,15 +1703,21 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number 取消订阅系统帐号的变动信息,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------------------------- | ---- | ---------------------------- | - | type | 'activate' \| 'activating' | 是 | 取消订阅类型,activate表示取消订阅帐号已激活完成的事件,activating取消订阅帐号正在激活的事件。 | - | name | string | 是 | 订阅名称,可自定义,,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 | - | callback | Callback<number> | 否 | 取消订阅系统帐号变化的回调,默认返回0。 | +**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION -- 示例: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------------------------------------------------ | +| type | 'activate' \| 'activating' | 是 | 取消订阅类型,activate表示取消订阅帐号已激活完成的事件,activating取消订阅帐号正在激活的事件。 | +| name | string | 是 | 订阅名称,可自定义,,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 | +| callback | Callback<number> | 否 | 取消订阅系统帐号变化的回调,默认返回0。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1504,45 +1728,53 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number ``` ## OsAccountInfo -系统帐号信息 -| 参数名 | 类型 | 必填 | 说明 | -| ----------------- | ---------------------------------- | ---- | ------------------------ | -| localId | number | 是 | 系统帐号ID。 | -| localName | string | 是 | 系统帐号名称。 | -| type | [OsAccountType](#osaccounttype) | 是 | 系统帐号类型 | -| constraints | Array<string> | 否 | 系统帐号[约束](#系统帐号约束列表) | -| isVerified | boolean | 是 | 帐号是否锁屏 | -| photo | string | 否 | 系统帐号头像 | -| createTime | number | 是 | 系统帐号创建时间 | -| lastLoginTime | number | 否 | 系统帐号最后一次登录时间 | -| serialNumber | number | 是 | 系统帐号SN码 | -| isActived | boolean | 是 | 系统帐号激活状态 | -| isCreateCompleted | boolean | 是 | 系统帐号创建是否完整 | -| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | 否 | 分布式帐号信息 | -| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 否 | 域帐号信息 | + +系统帐号信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | ------------------------------------------------------------ | ---- | --------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| localName | string | 是 | 系统帐号名称。 | +| type | [OsAccountType](#osaccounttype) | 是 | 系统帐号类型 | +| constraints | Array<string> | 否 | 系统帐号[约束](#系统帐号约束列表) | +| isVerified | boolean | 是 | 帐号是否锁屏 | +| photo | string | 否 | 系统帐号头像 | +| createTime | number | 是 | 系统帐号创建时间 | +| lastLoginTime | number | 否 | 系统帐号最后一次登录时间 | +| serialNumber | number | 是 | 系统帐号SN码 | +| isActived | boolean | 是 | 系统帐号激活状态 | +| isCreateCompleted | boolean | 是 | 系统帐号创建是否完整 | +| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | 否 | 分布式帐号信息 | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 否 | 域帐号信息 | ## DomainAccountInfo -域帐号信息 -| 参数名 | 类型 | 必填 | 说明 | -| ----------------- | ---------------------------------- | ---- | ------------------------ | -| domain | string | 是 | 域名。 | -| accountName | string | 是 | 域帐号名。 | + +域帐号信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------ | ---- | ---------- | +| domain | string | 是 | 域名。 | +| accountName | string | 是 | 域帐号名。 | ## 系统帐号约束列表 -| 约束 | 说明 | -| ----------------- | ------------------- | -| constraint.wifi | 禁止使用wifi | -| constraint.wifi.set | 禁止配置wifi | -| constraint.locale.set | 禁止配置设备语言 | -| constraint.app.accounts | 禁止添加和删除应用帐号 | -| constraint.apps.install | 禁止安装应用 | -| constraint.apps.uninstall | 禁止卸载应用 | -| constraint.location.shared | 禁止打开位置共享 | -| constraint.unknown.sources.install | 禁止安装未知来源的应用 | +| 约束 | 说明 | +| ------------------------------------- | ------------------------------ | +| constraint.wifi | 禁止使用wifi | +| constraint.wifi.set | 禁止配置wifi | +| constraint.locale.set | 禁止配置设备语言 | +| constraint.app.accounts | 禁止添加和删除应用帐号 | +| constraint.apps.install | 禁止安装应用 | +| constraint.apps.uninstall | 禁止卸载应用 | +| constraint.location.shared | 禁止打开位置共享 | +| constraint.unknown.sources.install | 禁止安装未知来源的应用 | | constraint.global.unknown.app.install | 禁止所有用户安装未知来源的应用 | -| constraint.bluetooth.set | 禁止配置蓝牙 | -| constraint.bluetooth | 禁止使用蓝牙 +| constraint.bluetooth.set | 禁止配置蓝牙 | +| constraint.bluetooth | 禁止使用蓝牙 | | constraint.bluetooth.share | 禁止共享使用蓝牙 | | constraint.usb.file.transfer | 禁止通过USB传输文件 | | constraint.credentials.set | 禁止配置用户凭据 | @@ -1594,4 +1826,4 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number | constraint.ambient.display | 禁止显示环境 | | constraint.screen.timeout.set | 禁止配置屏幕关闭的超时 | | constraint.print | 禁止打印 | -| constraint.private.dns.set | 禁止配置专用DNS | +| constraint.private.dns.set | 禁止配置专用DNS | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md index 3051642b6fbf9e4ab0340a439f3f28c7c95511a3..c2b55af5584868611ed11bbd3bfc1d525c39f713 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @@ -417,7 +417,7 @@ connectAbility(request: Want, options:ConnectOptions): number ## particleAbility.disconnectAbility -disconnectAbility(connection: number, callback:AsyncCallback): void; +disconnectAbility(connection: number, callback:AsyncCallback\): void; 将功能与服务功能断开连接。 @@ -463,7 +463,7 @@ disconnectAbility(connection: number, callback:AsyncCallback): void; ## particleAbility.disconnectAbility -disconnectAbility(connection: number): Promise; +disconnectAbility(connection: number): Promise\; 将功能与服务功能断开连接。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md index 8b706d69a8d9cfac50036e6bc71fc6a0951c2e04..be8fbccd2715f4acdd8d7febbd4f1479f95dbe48 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md +++ b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md @@ -115,7 +115,7 @@ let result = plainArray.get(1); ### getIndexOfKey -getIndexOfKey(key: number): number; +getIndexOfKey(key: number): number 查找指定key第一次出现的下标值,如果没有找到该key返回-1。 @@ -143,7 +143,7 @@ let result = plainArray.getIndexOfKey("sdfs"); ### getIndexOfValue -getIndexOfValue(value: T): number; +getIndexOfValue(value: T): number 查找指定value元素第一次出现的下标值,如果没有找到该value元素返回-1。 @@ -171,7 +171,7 @@ let result = plainArray.getIndexOfValue("sddfhf"); ### getKeyAt -getKeyAt(index: number): number; +getKeyAt(index: number): number 查找指定下标的元素键值对中key值。 @@ -238,7 +238,7 @@ clone(): PlainArray<T> **示例:** ``` -let plainArray = new ArrayList(); +let plainArray = new PlainArray(); plainArray.add(1, "sddfhf"); plainArray.add(2, "sffdfhf"); let newPlainArray = plainArray.clone(); @@ -416,7 +416,7 @@ plainArray.clear(); ### forEach -forEach(callbackfn: (value?: T, index?: number, PlainArray?: PlainArray) => void, thisArg?: Object): void +forEach(callbackfn: (value: T, index?: number, PlainArray?: PlainArray) => void, thisArg?: Object): void 通过回调函数来遍历实例对象上的元素以及元素对应的下标。 @@ -431,7 +431,7 @@ callbackfn的参数说明: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | value | T | 是 | 当前遍历到的元素键值对的值。 | -| index | number | 是 | 当前遍历到的元素键值对的键。 | +| index | number | 否 | 当前遍历到的元素键值对的键。 | | plainArray | PlainArray | 否 | 当前调用forEach方法的实例对象。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-process.md b/zh-cn/application-dev/reference/apis/js-apis-process.md index 5b5cd956dc51bf6e9a313008a8349b16d728fc5f..8cf388df7ac0a971829eb6d4a29e395c1883af3b 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-process.md +++ b/zh-cn/application-dev/reference/apis/js-apis-process.md @@ -379,7 +379,7 @@ var pres = process.getEnvironmentVar("PATH") ## process.runCmd -runCmd(command: string, options?: { timeout : number, killSignal : number | string, maxBuffer : number }) : ChildProcess +runCmd(command: string, options?: { timeout : number, killSignal : number | string, maxBuffer : number }): ChildProcess 通过runcmd可以fork一个新的进程来运行一段shell,并返回ChildProcess对象。 @@ -574,7 +574,7 @@ var time = process.uptime(); ## process.kill -kill(pid: number, signal: number ): boolean +kill(signal: number, pid: number): boolean 发送signal到指定的进程,结束指定进程。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-queue.md b/zh-cn/application-dev/reference/apis/js-apis-queue.md index bfabc48531a3d8e81e1f1cf22eef4715150bd25d..79dbbb889a13d2a6c92778d9855acc26d53bf58c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-queue.md +++ b/zh-cn/application-dev/reference/apis/js-apis-queue.md @@ -117,6 +117,7 @@ let result = queue.getFirst(); ``` ### forEach + forEach(callbackfn: (value: T, index?: number, Queue?: Queue<T>) => void, thisArg?: Object): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index 4117d7a6437f022e726ee052d404f999dcbeb942..a38f68e711389b81dc314c0c6977dbbb528d518a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -126,7 +126,7 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void ### on('progress') -on(type: 'progress', callback:AsyncCallback <uploadedSize: number, totalSize: number> => void): void +on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => void): void 开启上传任务监听,异步方法,使用callback形式返回结果。 @@ -142,10 +142,10 @@ on(type: 'progress', callback:AsyncCallback <uploadedSize: number, totalSize: 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 | - | totalSize | number | 是 | 上传文件的总大小,单位为KB。 | + | uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 | + | totalSize | number | 是 | 上传文件的总大小,单位为KB。 | - 示例: @@ -159,7 +159,7 @@ on(type: 'progress', callback:AsyncCallback <uploadedSize: number, totalSize: ### on('headerReceive')7+ -on(type: 'headerReceive', callback: AsyncCallback<object> => void): void +on(type: 'headerReceive', callback: (header: object) => void): void 开启上传任务监听,异步方法,使用callback形式返回结果。 @@ -171,13 +171,13 @@ on(type: 'headerReceive', callback: AsyncCallback<object> => void): voi | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 订阅的事件类型,取值为'headerReceive'(接收响应头)。 | - | callback | AsyncCallback<object> | 是 | HTTP Response Header事件的回调函数。 | + | callback | header: object | 是 | HTTP Response Header事件的回调函数。 | 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | headers | object | 是 | HTTP Response Header。 | + | header | object | 是 | HTTP Response Header。 | - 示例: @@ -191,7 +191,7 @@ on(type: 'headerReceive', callback: AsyncCallback<object> => void): voi ### off('progress') -off(type: 'progress', callback:AsyncCallback<uploadedSize: number, totalSize: number>=> void): void +off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) => void): void 关闭上传任务监听,异步方法,使用callback形式返回结果。 @@ -207,10 +207,10 @@ off(type: 'progress', callback:AsyncCallback<uploadedSize: number, totalSize: 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 | - | totalSize | number | 是 | 上传文件的总大小,单位为KB。 | + | uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 | + | totalSize | number | 是 | 上传文件的总大小,单位为KB。 | - 示例: @@ -224,7 +224,7 @@ off(type: 'progress', callback:AsyncCallback<uploadedSize: number, totalSize: ### off('headerReceive')7+ -off(type: 'headerReceive', callback:AsyncCallback<object> => void): void +off(type: 'headerReceive', callback?: (header: object) => void): void 关闭上传任务监听,异步方法,使用callback形式返回结果。 @@ -236,13 +236,13 @@ off(type: 'headerReceive', callback:AsyncCallback<object> => void): voi | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取消订阅的事件类型,取值为'headerReceive'(接收响应头)。 | - | callback | AsyncCallback<object> | 否 | HTTP Response Header事件的回调函数。 | + | callback | header: object | 否 | HTTP Response Header事件的回调函数。 | 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | headers | object | 是 | HTTP Response Header。 | + | header | object | 是 | HTTP Response Header。 | - 示例: @@ -337,7 +337,7 @@ remove(callback: AsyncCallback<boolean>): void | -------- | -------- | -------- | -------- | | filename | string | 否 | multipart提交时,请求头中的文件名。 | | name | string | 否 | multipart提交时,表单项目的名称,缺省为file。 | -| url | string | 是 | 文件的本地存储路径。
支持“dataability”和“internal”两种协议类型,但“internal”仅支持临时目录,示例:
dataability:///com.domainname.dataability.persondata/person/10/file.txt
internal://cache/path/to/file.txt | +| uri | string | 是 | 文件的本地存储路径。
支持“dataability”和“internal”两种协议类型,但“internal”仅支持临时目录,示例:
dataability:///com.domainname.dataability.persondata/person/10/file.txt
internal://cache/path/to/file.txt | | type | string | 否 | 文件的内容类型,默认根据文件名或路径的后缀获取。 | @@ -419,7 +419,7 @@ download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): v ### on('progress') -on(type: 'progress', callback:AsyncCallback<receivedSize: number, totalSize: number> => void): void +on(type: 'progress', callback:(receivedSize: number, totalSize: number) => void): void 开启下载任务监听,异步方法,使用callback形式返回结果。 @@ -435,10 +435,10 @@ on(type: 'progress', callback:AsyncCallback<receivedSize: number, totalSize: 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | receivedSize | number | 是 | 当前下载的进度,单位为KB。 | - | totalSize | number | 是 | 下载文件的总大小,单位为KB。 | + | receivedSize | number | 是 | 当前下载的进度,单位为KB。 | + | totalSize | number | 是 | 下载文件的总大小,单位为KB。 | - 示例: @@ -459,7 +459,7 @@ on(type: 'progress', callback:AsyncCallback<receivedSize: number, totalSize: ### off('progress') -off(type: 'progress', callback: AsyncCallback<receivedSize: number, totalSize: number> => void): void +off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => void): void 关闭下载任务监听,异步方法,使用callback形式返回结果。 @@ -475,10 +475,10 @@ off(type: 'progress', callback: AsyncCallback<receivedSize: number, totalSize 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | receivedSize | number | 是 | 当前下载的进度。 | - | totalSize | number | 是 | 下载文件的总大小。 | + | receivedSize | number | 是 | 当前下载的进度。 | + | totalSize | number | 是 | 下载文件的总大小。 | - 示例: @@ -499,7 +499,7 @@ off(type: 'progress', callback: AsyncCallback<receivedSize: number, totalSize ### on('complete')7+ -on(type: 'complete', callback:AsyncCallback<> => void): void +on(type: 'complete', callback:() => void): void 开启下载任务完成监听,异步方法,使用callback形式返回。 @@ -532,7 +532,7 @@ on(type: 'complete', callback:AsyncCallback<> => void): void ### off('complete')7+ -off(type: 'complete', callback:AsyncCallback<> => void): void +off(type: 'complete', callback?:() => void): void 取消下载任务完成监听,异步方法,使用callback形式返回。 @@ -565,7 +565,7 @@ off(type: 'complete', callback:AsyncCallback<> => void): void ### on('fail')7+ -on(type: 'fail', callback:AsyncCallback<err: number> => void): void +on(type: 'fail', callback: (err: number) => void): void 开启下载任务失败监听,异步方法,使用callback形式返回结果。 @@ -581,9 +581,9 @@ on(type: 'fail', callback:AsyncCallback<err: number> => void): void 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | err | number | 是 | 下载失败的错误码,错误原因见[ERROR.*](#常量)。 | + | err | number | 是 | 下载失败的错误码,错误原因见[ERROR.*](#常量)。 | - 示例 @@ -604,7 +604,7 @@ on(type: 'fail', callback:AsyncCallback<err: number> => void): void ### off('fail')7+ -off(type: 'fail', callback:AsyncCallback<err: number> => void): void +off(type: 'fail', callback?: (err: number) => void): void 取消下载任务失败监听,异步方法,使用callback形式返回结果。 @@ -620,9 +620,9 @@ off(type: 'fail', callback:AsyncCallback<err: number> => void): void 回调函数的参数 - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | err | number | 是 | 下载失败的错误码。错误原因见[ERROR_*](#常量)。 | + | err | number | 是 | 下载失败的错误码。错误原因见[ERROR_*](#常量)。 | - 示例 @@ -643,7 +643,7 @@ off(type: 'fail', callback:AsyncCallback<err: number> => void): void ### on('pause')7+ -on(type: 'pause', callback:AsyncCallback<> => void): void +on(type: 'pause', callback:() => void): void 开启下载任务暂停监听,异步方法,使用callback形式返回结果。 @@ -676,7 +676,7 @@ on(type: 'pause', callback:AsyncCallback<> => void): void ### off('pause')7+ -off(type: 'pause', callback:AsyncCallback<> => void): void +off(type: 'pause', callback?:() => void): void 取消下载任务暂停监听,异步方法,使用callback形式返回结果。 @@ -709,7 +709,7 @@ off(type: 'pause', callback:AsyncCallback<> => void): void ### on('remove')7+ -on(type: 'remove', callback:AsyncCallback<> => void): void +on(type: 'remove', callback:() => void): void 开启下载任务移除监听,异步方法,使用callback形式返回结果。 @@ -742,7 +742,7 @@ on(type: 'remove', callback:AsyncCallback<> => void): void ### off('remove')7+ -off(type: 'remove', callback:AsyncCallback<> => void): void +off(type: 'remove', callback?:() => void): void 取消下载任务移除监听,异步方法,使用callback形式返回结果。 @@ -847,7 +847,7 @@ query(): Promise<DownloadInfo> - 参数: | 类型 | 说明 | | -------- | -------- | - | Promise<[DownloadInfo](#downloadinfo)> | 查询下载任务信息。 | + | Promise<[DownloadInfo](#downloadinfo7)> | 查询下载任务信息。 | - 示例 @@ -873,7 +873,7 @@ query(callback: AsyncCallback<DownloadInfo>): void - 参数: | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[DownloadInfo](#downloadinfo)> | 是 | 查询下载任务的回调函数。 | + | callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | 是 | 查询下载任务的回调函数。 | - 示例: @@ -944,7 +944,7 @@ queryMimeType(callback: AsyncCallback<string>): void; ### pause7+ -pause(): Promise<boolean> +pause(): Promise<void> 暂停下载任务,异步方法,使用promise形式返回结果。 @@ -955,7 +955,7 @@ pause(): Promise<boolean> - 返回值: | 类型 | 说明 | | -------- | -------- | - | Promise<boolean> | 暂停下载任务是否成功。 | + | Promise<void> | 暂停下载任务是否成功。 | - 示例 @@ -974,7 +974,7 @@ pause(): Promise<boolean> ### pause7+ -pause(callback: AsyncCallback<boolean>): void +pause(callback: AsyncCallback<void>): void 暂停下载任务,异步方法,使用callback形式返回结果。 @@ -985,7 +985,7 @@ pause(callback: AsyncCallback<boolean>): void - 参数 | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | 暂停下载任务的回调函数。 | + | callback | AsyncCallback<void> | 是 | 暂停下载任务的回调函数。 | - 示例 @@ -1006,7 +1006,7 @@ pause(callback: AsyncCallback<boolean>): void ### resume7+ -resume(): Promise<boolean> +resume(): Promise<void> 重新启动暂停的下载任务,异步方法,使用promise形式返回结果。 @@ -1017,7 +1017,7 @@ resume(): Promise<boolean> - 参数: | 类型 | 说明 | | -------- | -------- | - | Promise<boolean> | 重新启动暂停的下载任务是否成功。 | + | Promise<void> | 重新启动暂停的下载任务是否成功。 | - 示例 @@ -1037,7 +1037,7 @@ resume(): Promise<boolean> ### resume7+ -resume(callback: AsyncCallback<boolean>): void +resume(callback: AsyncCallback<void>): void 重新启动暂停的下载任务,异步方法,使用callback形式返回结果。 @@ -1048,7 +1048,7 @@ resume(callback: AsyncCallback<boolean>): void - 参数 | 参数名 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | 重新启动暂停的下载任务的回调函数。 | + | callback | AsyncCallback<void> | 是 | 重新启动暂停的下载任务的回调函数。 | - 示例 @@ -1083,7 +1083,7 @@ resume(callback: AsyncCallback<boolean>): void | title | string | 否 | 设置下载会话标题。 | -## DownloadInfo +## DownloadInfo7+ **系统能力**: SystemCapability.MiscServices.Download diff --git a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md index ac3cf96b369ecc02ae6ebc10cf9687f37a6de8ad..ca7621d5b38f7eb930986be83dc25032bcb6d84d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @@ -1,4 +1,4 @@ -# 资源管理 +资源管理 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -18,12 +18,12 @@ getResourceManager(callback: AsyncCallback<ResourceManager>): void **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[ResourceManager](#resourcemanager)> | 是 | callback方式返回ResourceManager对象 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------------------- | +| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | 是 | callback方式返回ResourceManager对象 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { if (error != null) { @@ -49,13 +49,13 @@ getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManage **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | bundleName | string | 是 | 指定应用的Bundle名称 | - | callback | AsyncCallback<[ResourceManager](#resourcemanager)> | 是 | callback方式返回ResourceManager对象 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ---------------------------------------- | ---- | ----------------------------- | +| bundleName | string | 是 | 指定应用的Bundle名称 | +| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | 是 | callback方式返回ResourceManager对象 | -- 示例: +**示例:** ``` resourceManager.getResourceManager("com.example.myapplication", (error, mgr) => { }); @@ -70,12 +70,12 @@ getResourceManager(): Promise<ResourceManager> **系统能力**:SystemCapability.Global.ResourceManager -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<[ResourceManager](#resourcemanager)> | Promise方式返回资源管理对象 | +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | ----------------- | +| Promise<[ResourceManager](#resourcemanager)> | Promise方式返回资源管理对象 | -- 示例: +**示例:** ``` resourceManager.getResourceManager().then(mgr => { mgr.getString(0x1000000, (error, value) => { @@ -99,22 +99,22 @@ getResourceManager(bundleName: string): Promise<ResourceManager> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | bundleName | string | 是 | 指定应用的Bundle名称 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------- | +| bundleName | string | 是 | 指定应用的Bundle名称 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<[ResourceManager](#resourcemanager)> | Promise方式返回的资源管理对象 | +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | ------------------ | +| Promise<[ResourceManager](#resourcemanager)> | Promise方式返回的资源管理对象 | -- 示例: +**示例:** ``` resourceManager.getResourceManager("com.example.myapplication").then(mgr => { - + }).catch(error => { - + }); ``` @@ -123,72 +123,82 @@ getResourceManager(bundleName: string): Promise<ResourceManager> 用于表示设备屏幕方向。 -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| DIRECTION_VERTICAL | 0 | 竖屏
**系统能力**:SystemCapability.Global.ResourceManager | -| DIRECTION_HORIZONTAL | 1 | 横屏
**系统能力**:SystemCapability.Global.ResourceManager | +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.ResourceManager + +| 名称 | 默认值 | 说明 | +| -------------------- | ---- | ---- | +| DIRECTION_VERTICAL | 0 | 竖屏 | +| DIRECTION_HORIZONTAL | 1 | 横屏 | ## DeviceType 用于表示当前设备类型。 -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| DEVICE_TYPE_PHONE | 0x00 | 手机
**系统能力**:SystemCapability.Global.ResourceManager | -| DEVICE_TYPE_TABLET | 0x01 | 平板
**系统能力**:SystemCapability.Global.ResourceManager | -| DEVICE_TYPE_CAR | 0x02 | 汽车
**系统能力**:SystemCapability.Global.ResourceManager | -| DEVICE_TYPE_PC | 0x03 | 电脑
**系统能力**:SystemCapability.Global.ResourceManager | -| DEVICE_TYPE_TV | 0x04 | 电视
**系统能力**:SystemCapability.Global.ResourceManager | -| DEVICE_TYPE_WEARABLE | 0x06 | 穿戴
**系统能力**:SystemCapability.Global.ResourceManager | +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.ResourceManager + +| 名称 | 默认值 | 说明 | +| -------------------- | ---- | ---- | +| DEVICE_TYPE_PHONE | 0x00 | 手机 | +| DEVICE_TYPE_TABLET | 0x01 | 平板 | +| DEVICE_TYPE_CAR | 0x02 | 汽车 | +| DEVICE_TYPE_PC | 0x03 | 电脑 | +| DEVICE_TYPE_TV | 0x04 | 电视 | +| DEVICE_TYPE_WEARABLE | 0x06 | 穿戴 | ## ScreenDensity 用于表示当前设备屏幕密度。 -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| SCREEN_SDPI | 120 | 小规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | -| SCREEN_MDPI | 160 | 中规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | -| SCREEN_LDPI | 240 | 大规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | -| SCREEN_XLDPI | 320 | 特大规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | -| SCREEN_XXLDPI | 480 | 超大规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | -| SCREEN_XXXLDPI | 640 | 超特大规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.ResourceManager + +| 名称 | 默认值 | 说明 | +| -------------- | ---- | ---------- | +| SCREEN_SDPI | 120 | 小规模的屏幕密度 | +| SCREEN_MDPI | 160 | 中规模的屏幕密度 | +| SCREEN_LDPI | 240 | 大规模的屏幕密度 | +| SCREEN_XLDPI | 320 | 特大规模的屏幕密度 | +| SCREEN_XXLDPI | 480 | 超大规模的屏幕密度 | +| SCREEN_XXXLDPI | 640 | 超特大规模的屏幕密度 | ## Configuration 表示当前设备的状态。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.ResourceManager + -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| direction | [Direction](#direction) | 是 | 否 | 当前设备屏幕方向
**系统能力**:SystemCapability.Global.ResourceManager | -| locale | string | 是 | 否 | 当前系统语言
**系统能力**:SystemCapability.Global.ResourceManager | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | ----------------------- | ---- | ---- | -------- | +| direction | [Direction](#direction) | 是 | 否 | 当前设备屏幕方向 | +| locale | string | 是 | 否 | 当前系统语言 | ## DeviceCapability 表示设备支持的能力。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.ResourceManager + -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| screenDensity | [ScreenDensity](#screendensity) | 是 | 否 | 当前设备屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | -| deviceType | [DeviceType](#devicetype) | 是 | 否 | 当前设备类型
**系统能力**:SystemCapability.Global.ResourceManager | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------------- | ------------------------------- | ---- | ---- | -------- | +| screenDensity | [ScreenDensity](#screendensity) | 是 | 否 | 当前设备屏幕密度 | +| deviceType | [DeviceType](#devicetype) | 是 | 否 | 当前设备类型 | ## RawFileDescriptor8+ -表示rawfile的descriptor信息。 -
系统能力: 以下各项对应的系统能力均为SystemCapability.Global.ResourceManager +表示rawfile的descriptor信息。
+**系统能力:** 以下各项对应的系统能力均为SystemCapability.Global.ResourceManager -| 名称 | 类型 | 说明 | -| -------- | -------- | -------- | -| fd | number | rawfile的descriptor | -| offset | number | rawfile的起始偏移量 | -| length | number | rawfile的文件长度 | +| 名称 | 类型 | 说明 | +| ------ | ------ | ------------------ | +| fd | number | rawfile的descriptor | +| offset | number | rawfile的起始偏移量 | +| length | number | rawfile的文件长度 | ## ResourceManager @@ -197,7 +207,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - ResourceManager涉及到的方法,仅限基于TS扩展的声明式开发范式使用。 -> +> > - 资源文件在工程的resources目录中定义,id可通过$r(资源地址).id的方式获取,例如$r('app.string.test').id。 @@ -209,13 +219,13 @@ getString(resId: number, callback: AsyncCallback<string>): void **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | resId | number | 是 | 资源ID值 | - | callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的字符串 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------- | +| resId | number | 是 | 资源ID值 | +| callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的字符串 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getString($r('app.string.test').id, (error, value) => { @@ -237,17 +247,17 @@ getString(resId: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | resId | number | 是 | 资源ID值 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----- | +| resId | number | 是 | 资源ID值 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<string> | 资源ID值对应的字符串 | +**返回值:** +| 类型 | 说明 | +| --------------------- | ----------- | +| Promise<string> | 资源ID值对应的字符串 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getString($r('app.string.test').id).then(value => { @@ -267,13 +277,13 @@ getStringArray(resId: number, callback: AsyncCallback<Array<string>> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | resId | number | 是 | 资源ID值 | - | callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回获取的字符串数组 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------- | +| resId | number | 是 | 资源ID值 | +| callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回获取的字符串数组 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getStringArray($r('app.strarray.test').id, (error, value) => { @@ -295,17 +305,17 @@ getStringArray(resId: number): Promise<Array<string>> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | resId | number | 是 | 资源ID值 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----- | +| resId | number | 是 | 资源ID值 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<Array<string>> | 资源ID值对应的字符串数组 | +**返回值:** +| 类型 | 说明 | +| ---------------------------------- | ------------- | +| Promise<Array<string>> | 资源ID值对应的字符串数组 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getStringArray($r('app.strarray.test').id).then(value => { @@ -325,13 +335,13 @@ getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | resId | number | 是 | 资源ID值 | - | callback | AsyncCallback<Uint8Array> | 是 | 异步回调,用于返回获取的媒体文件内容 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------- | ---- | ------------------ | +| resId | number | 是 | 资源ID值 | +| callback | AsyncCallback<Uint8Array> | 是 | 异步回调,用于返回获取的媒体文件内容 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getMedia($r('app.media.test').id, (error, value) => { @@ -353,17 +363,17 @@ getMedia(resId: number): Promise<Uint8Array> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | resId | number | 是 | 资源ID值 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----- | +| resId | number | 是 | 资源ID值 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<Uint8Array> | 资源ID值对应的媒体文件内容 | +**返回值:** +| 类型 | 说明 | +| ------------------------- | -------------- | +| Promise<Uint8Array> | 资源ID值对应的媒体文件内容 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getMedia($r('app.media.test').id).then(value => { @@ -383,13 +393,13 @@ getMediaBase64(resId: number, callback: AsyncCallback<string>): void **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | resId | number | 是 | 资源ID值 | - | callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的图片资源Base64编码 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------ | +| resId | number | 是 | 资源ID值 | +| callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的图片资源Base64编码 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getMediaBase64($r('app.media.test').id, (error, value) => { @@ -411,17 +421,17 @@ getMediaBase64(resId: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | resId | number | 是 | 资源ID值 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----- | +| resId | number | 是 | 资源ID值 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<string> | 资源ID值对应的图片资源Base64编码 | +**返回值:** +| 类型 | 说明 | +| --------------------- | -------------------- | +| Promise<string> | 资源ID值对应的图片资源Base64编码 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getMediaBase64($r('app.media.test').id).then(value => { @@ -441,12 +451,12 @@ getConfiguration(callback: AsyncCallback<Configuration>): void **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[Configuration](#configuration)> | 是 | 异步回调,用于返回设备的Configuration | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------- | +| callback | AsyncCallback<[Configuration](#configuration)> | 是 | 异步回调,用于返回设备的Configuration | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getConfiguration((error, value) => { @@ -468,12 +478,12 @@ getConfiguration(): Promise<Configuration> **系统能力**:SystemCapability.Global.ResourceManager -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<[Configuration](#configuration)> | 设备的Configuration | +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | ---------------- | +| Promise<[Configuration](#configuration)> | 设备的Configuration | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getConfiguration().then(value => { @@ -493,12 +503,12 @@ getDeviceCapability(callback: AsyncCallback<DeviceCapability>): void **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[DeviceCapability](#devicecapability)> | 是 | 异步回调,用于返回设备的DeviceCapability | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------- | +| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | 是 | 异步回调,用于返回设备的DeviceCapability | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getDeviceCapability((error, value) => { @@ -520,12 +530,12 @@ getDeviceCapability(): Promise<DeviceCapability> **系统能力**:SystemCapability.Global.ResourceManager -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<[DeviceCapability](#devicecapability)> | 设备的DeviceCapability | +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | ------------------- | +| Promise<[DeviceCapability](#devicecapability)> | 设备的DeviceCapability | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getDeviceCapability().then(value => { @@ -545,14 +555,14 @@ getPluralString(resId: number, num: number, callback: AsyncCallback<string> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | resId | number | 是 | 资源ID值 | - | num | number | 是 | 数量值 | - | callback | AsyncCallback<string> | 是 | 异步回调,返回根据指定数量获取指定ID字符串表示的单复数字符串 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------- | +| resId | number | 是 | 资源ID值 | +| num | number | 是 | 数量值 | +| callback | AsyncCallback<string> | 是 | 异步回调,返回根据指定数量获取指定ID字符串表示的单复数字符串 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getPluralString($r("app.plural.test").id, 1, (error, value) => { @@ -574,18 +584,18 @@ getPluralString(resId: number, num: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | resId | number | 是 | 资源ID值 | - | num | number | 是 | 数量值 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----- | +| resId | number | 是 | 资源ID值 | +| num | number | 是 | 数量值 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<string> | 根据提供的数量获取对应ID字符串表示的单复数字符串 | +**返回值:** +| 类型 | 说明 | +| --------------------- | ------------------------- | +| Promise<string> | 根据提供的数量获取对应ID字符串表示的单复数字符串 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getPluralString($r("app.plural.test").id, 1).then(value => { @@ -604,13 +614,13 @@ getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | rawfile文件路径 | - | callback | AsyncCallback<Uint8Array> | 是 | 异步回调,用于返回获取的rawfile文件内容 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------- | ---- | ----------------------- | +| path | string | 是 | rawfile文件路径 | +| callback | AsyncCallback<Uint8Array> | 是 | 异步回调,用于返回获取的rawfile文件内容 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getRawFile("test.xml", (error, value) => { @@ -631,17 +641,17 @@ getRawFile(path: string): Promise<Uint8Array> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | rawfile文件路径 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----------- | +| path | string | 是 | rawfile文件路径 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<Uint8Array> | rawfile文件内容 | +**返回值:** +| 类型 | 说明 | +| ------------------------- | ----------- | +| Promise<Uint8Array> | rawfile文件内容 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getRawFile("test.xml").then(value => { @@ -660,13 +670,13 @@ getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor& **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | rawfile文件路径 | - | callback | AsyncCallback<[RawFileDescriptor](#RawFileDescriptor8+)> | 是 | 异步回调,用于返回获取的rawfile文件的descriptor | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | -------------------------------- | +| path | string | 是 | rawfile文件路径 | +| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8+ { mgr.getRawFileDescriptor("test.xml", (error, value) => { @@ -689,17 +699,17 @@ getRawFileDescriptor(path: string): Promise<RawFileDescriptor> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | rawfile文件路径 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----------- | +| path | string | 是 | rawfile文件路径 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<[RawFileDescriptor](#RawFileDescriptor8+)> | rawfile文件descriptor | +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | ------------------- | +| Promise<[RawFileDescriptor](#rawfiledescriptor8)> | rawfile文件descriptor | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.getRawFileDescriptor("test.xml").then(value => { @@ -720,13 +730,13 @@ closeRawFileDescriptor(path: string, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | rawfile文件路径 | - | callback | AsyncCallback<void> | 是 | 异步回调 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ----------- | +| path | string | 是 | rawfile文件路径 | +| callback | AsyncCallback<void> | 是 | 异步回调 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.closeRawFileDescriptor("test.xml", (error, value) => { @@ -745,17 +755,17 @@ closeRawFileDescriptor(path: string): Promise<void> **系统能力**:SystemCapability.Global.ResourceManager -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | rawfile文件路径 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----------- | +| path | string | 是 | rawfile文件路径 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 无返回值 | +**返回值:** +| 类型 | 说明 | +| ------------------- | ---- | +| Promise<void> | 无返回值 | -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.closeRawFileDescriptor("test.xml").then(value => { @@ -768,13 +778,13 @@ closeRawFileDescriptor(path: string): Promise<void> ### release7+ -release(); +release() 用户释放创建的resourceManager。 **系统能力**:SystemCapability.Global.ResourceManager -- 示例: +**示例:** ``` resourceManager.getResourceManager((error, mgr) => { mgr.release((error, value) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-rpc.md b/zh-cn/application-dev/reference/apis/js-apis-rpc.md index 90214b82d0c1287b2fd11bcc0a090d87fd53af73..adf7571c213934eed481225f12ce14fa78237e98 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-rpc.md +++ b/zh-cn/application-dev/reference/apis/js-apis-rpc.md @@ -1708,8 +1708,8 @@ readException(): void } }; let want = { - "bundleName": "com.huawei.server", - "abilityName": "com.huawei.server.MainAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); let option = new rpc.MessageOption(); @@ -2563,8 +2563,8 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options } }; let want = { - "bundleName": "com.huawei.server", - "abilityName": "com.huawei.server.MainAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); let option = new rpc.MessageOption(); @@ -2608,8 +2608,8 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options } }; let want = { - "bundleName": "com.huawei.server", - "abilityName": "com.huawei.server.MainAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); let option = new rpc.MessageOption(); @@ -2672,8 +2672,8 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me } }; let want = { - "bundleName": "com.huawei.server", - "abilityName": "com.huawei.server.MainAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", }; function sendRequestCallback(result) { if (result.errCode === 0) { @@ -2734,8 +2734,8 @@ queryLocalInterface(interface: string): IRemoteBroker } }; let want = { - "bundleName":"com.huawei.server", - "abilityName":"com.huawei.server.MainAbility", + "bundleName":"com.ohos.server", + "abilityName":"com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); let broker = proxy.queryLocalInterface("testObject"); @@ -2780,8 +2780,8 @@ addDeathRecipient(recipient : DeathRecipient, flags : number): boolean } }; let want = { - "bundleName": "com.huawei.server", - "abilityName": "com.huawei.server.MainAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); class MyDeathRecipient { @@ -2831,8 +2831,8 @@ removeDeathRecipient(recipient : DeathRecipient, flags : number): boolean } }; let want = { - "bundleName": "com.huawei.server", - "abilityName": "com.huawei.server.MainAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); class MyDeathRecipient { @@ -2877,8 +2877,8 @@ getInterfaceDescriptor(): string } }; let want = { - "bundleName": "com.huawei.server", - "abilityName": "com.huawei.server.MainAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); let descriptor = proxy.getInterfaceDescriptor(); @@ -2917,8 +2917,8 @@ isObjectDead(): boolean } }; let want = { - "bundleName": "com.huawei.server", - "abilityName": "com.huawei.server.MainAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); let isDead = proxy.isObjectDead(); diff --git a/zh-cn/application-dev/reference/apis/js-apis-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-sensor.md index cd3d770578e9f0711824e323b0e8c5053b3dc61a..3b46689c13854ce9737ed144048ac16b363fec36 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md @@ -22,14 +22,14 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<Acceler **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | - | callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ console.info('X-coordinate component: ' + data.x); @@ -51,14 +51,14 @@ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<Line **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | - | callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){ console.info('X-coordinate component: ' + data.x); @@ -80,14 +80,14 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | - | callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){ console.info('X-coordinate component: ' + data.x); @@ -110,14 +110,14 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityRespons **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | - | callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){ console.info('X-coordinate component: ' + data.x); @@ -139,14 +139,14 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeRes **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | - | callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){ console.info('X-coordinate component: ' + data.x); @@ -168,14 +168,14 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback<G **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | - | callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){ console.info('X-coordinate component: ' + data.x); @@ -198,14 +198,14 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback<Sig **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | - | callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){ console.info('Scalar data: ' + data.scalar); @@ -225,14 +225,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback<Pe **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | - | callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){ console.info('Scalar data: ' + data.scalar); @@ -252,14 +252,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerRes **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | - | callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){ console.info('Steps: ' + data.steps); @@ -277,14 +277,14 @@ on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback<Ambie **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | - | callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){ console.info('Temperature: ' + data.temperature); @@ -302,14 +302,14 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<Magneti **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | - | callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | +| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){ console.info('X-coordinate component: ' + data.x); @@ -323,20 +323,20 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<Magneti ## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED) -on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback<MagneticFieldUncalibratedResponse>, options: Options): void +on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback<MagneticFieldUncalibratedResponse>, options?: Options): void 监听未校准磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | - | callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){ console.info('X-coordinate component: ' + data.x); @@ -359,14 +359,14 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityRes **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | - | callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){ console.info('Distance: ' + data.distance); @@ -384,14 +384,14 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityRespo **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | - | callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | -------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){ console.info('Humidity: ' + data.humidity); @@ -409,14 +409,14 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerRes **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | - | callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){ console.info('Atmospheric pressure: ' + data.pressure); @@ -434,14 +434,14 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse>, **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | - | callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){ console.info('Status: ' + data.status); @@ -459,14 +459,14 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightRes **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | - | callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){ console.info(' Illumination: ' + data.intensity); @@ -484,14 +484,14 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<Orientatio **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | - | callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){ console.info('The device rotates at an angle around the X axis: ' + data.beta); @@ -512,14 +512,14 @@ on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateRe **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){ @@ -537,14 +537,14 @@ on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback<Rotatio **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | - | callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){ console.info('X-coordinate component: ' + data.x); @@ -565,14 +565,14 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDet **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 要订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | - | callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | - | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -- 示例: +**示例:** ``` sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){ console.info('Wear status: ' + data.value); @@ -592,13 +592,13 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<Accele **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | - | callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ console.info('X-coordinate component: ' + data.x); @@ -619,13 +619,13 @@ once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<Li **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | - | callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) { console.info('X-coordinate component: ' + data.x); @@ -646,13 +646,13 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callba **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 未校准加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | - | callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 未校准加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) { console.info('X-coordinate component: ' + data.x); @@ -674,13 +674,13 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityRespo **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | - | callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) { console.info('X-coordinate component: ' + data.x); @@ -701,13 +701,13 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeR **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | - | callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) { console.info('X-coordinate component: ' + data.x); @@ -728,13 +728,13 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | - | callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) { console.info('X-coordinate component: ' + data.x); @@ -756,13 +756,13 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback<Si **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 有效运动传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | - | callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 有效运动传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) { console.info('Scalar data: ' + data.scalar); @@ -781,13 +781,13 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback<P **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | - | callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) { console.info('Scalar data: ' + data.scalar); @@ -806,13 +806,13 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerR **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | - | callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) { console.info('Steps: ' + data.steps); @@ -829,13 +829,13 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback<A **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | - | callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) { console.info('Temperature: ' + data.temperature); @@ -852,13 +852,13 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<Magne **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | - | callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | +| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) { console.info('X-coordinate component: ' + data.x); @@ -877,13 +877,13 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callb **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | - | callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) { console.info('X-coordinate component: ' + data.x); @@ -905,13 +905,13 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityR **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | - | callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) { if (error) { @@ -932,13 +932,13 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityRes **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | - | callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) { console.info('Humidity: ' + data.humidity); @@ -955,13 +955,13 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerR **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | - | callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) { console.info('Atmospheric pressure: ' + data.pressure); @@ -978,13 +978,13 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse> **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | - | callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) { console.info('Status: ' + data.status); @@ -1001,13 +1001,13 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightR **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | - | callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | -------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) { console.info(' Illumination: ' + data.intensity); @@ -1024,13 +1024,13 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<Orientat **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 方向传感器类型为SENSOR_TYPE_ID_ORIENTATION。 | - | callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 方向传感器类型为SENSOR_TYPE_ID_ORIENTATION。 | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) { console.info('The device rotates at an angle around the X axis: ' + data.beta); @@ -1049,13 +1049,13 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback<Rota **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | - | callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) { console.info('X-coordinate component: ' + data.x); @@ -1077,13 +1077,13 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRate **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | - | callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) { console.info("Heart rate: " + data.heartRate); @@ -1100,13 +1100,13 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearD **系统能力**:SystemCapability.Sensors.Sensor -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [SensorType](#sensortype) | 是 | 佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | - | callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | -- 示例: +**示例:** ``` sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) { console.info("Wear status: "+ data.value); @@ -1124,14 +1124,14 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback<Accele **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | -| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 取消注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 取消注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1152,14 +1152,14 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | -| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 取消注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 取消注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1181,14 +1181,14 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback<LightR **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | -| callback | Callback<[LightResponse](#lightresponse)> | 是 | 取消注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 取消注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1205,14 +1205,14 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback< **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | -| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 取消注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 取消注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1229,14 +1229,14 @@ off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback<BarometerR **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | -| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 取消注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 取消注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1253,14 +1253,14 @@ off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback<GravityRespo **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | -| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 取消注册注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 取消注册注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1281,14 +1281,14 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback<GyroscopeR **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | -| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 取消注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 取消注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1309,14 +1309,14 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback& **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | -| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 取消注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 取消注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1335,14 +1335,14 @@ off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback<HallResponse> **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | -| callback | Callback<[HallResponse](#hallresponse)> | 是 | 取消注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 取消注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1361,14 +1361,14 @@ off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback<HeartRate **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype)[SensorType](#sensortype) | 是 | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype)[SensorType](#sensortype) | 是 | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1387,14 +1387,14 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback<HumidityRes **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | -| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 取消注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 取消注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1413,14 +1413,14 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback< **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1441,14 +1441,14 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback); **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | -| callbackcallback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 取消注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | +| callbackcallback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 取消注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1467,14 +1467,14 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | -| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 取消注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 取消注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1496,14 +1496,14 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callbac **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | -| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 取消注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 取消注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1522,14 +1522,14 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback<PedometerR **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | -| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 取消注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 取消注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | -- 示例; +**返回值:** ; ``` function callback(data) { @@ -1548,14 +1548,14 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback< **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | -| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 取消注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 取消注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1572,14 +1572,14 @@ off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback<ProximityR **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | -| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 取消注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 取消注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1596,14 +1596,14 @@ off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback<Rota **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | -| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 取消注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 取消注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1623,14 +1623,14 @@ off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback<S **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | -| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 取消注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 取消注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | -- 示例: +**示例:** ``` function callback(data) { @@ -1647,14 +1647,14 @@ off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback<WearD **系统能力**:SystemCapability.Sensors.Sensor -- 参数: +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | -| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 取消注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 取消注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | -- 示例: +**示例:** ``` function accCallback(data) { @@ -1671,29 +1671,28 @@ transformCoordinateSystem(inRotationVector: Array<number>, coordinates: Co **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------------- | ----------------------------------------- | ---- | ---------------------- | - | inRotationVector | Array<number> | 是 | 表示旋转矩阵。 | - | coordinates | [CoordinatesOptions](#coordinatesoptions) | 是 | 表示坐标系方向。 | - | callback | AsyncCallback<Array<number>> | 是 | 返回转换后的旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ---------------------------------------- | ---- | ----------- | +| inRotationVector | Array<number> | 是 | 表示旋转矩阵。 | +| coordinates | [CoordinatesOptions](#coordinatesoptions) | 是 | 表示坐标系方向。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回转换后的旋转矩阵。 | -- 示例 - - ``` - sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) { - if (err) { - console.error("Operation failed. Error code: " + err.code + ", message: " + err.message); - return; - } - console.info("Operation successed. Data obtained: " + data.x); - for (var i=0; i < data.length; i++) { - console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); - } - }) - ``` +**示例:** +``` +sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) { + if (err) { + console.error("Operation failed. Error code: " + err.code + ", message: " + err.message); + return; + } + console.info("Operation successed. Data obtained: " + data.x); + for (var i=0; i < data.length; i++) { + console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); + } + }) +``` ## sensor.transformCoordinateSystem transformCoordinateSystem(inRotationVector: Array<number>, coordinates: CoordinatesOptions): Promise<Array<number>> @@ -1702,35 +1701,32 @@ transformCoordinateSystem(inRotationVector: Array<number>, coordinates: Co **系统能力**:SystemCapability.Sensors.Sensor -- 参数 - - | 参数名 | 类型 | 必填 | 说明 | - | ---------------- | ----------------------------------------- | ---- | ---------------- | - | inRotationVector | Array<number> | 是 | 表示旋转矩阵。 | - | coordinates | [CoordinatesOptions](#coordinatesoptions) | 是 | 表示坐标系方向。 | - -- 返回值 +**参数:** - | 类型 | 说明 | - | ---------------------------------- | ---------------------- | - | Promise<Array<number>> | 返回转换后的旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ---------------------------------------- | ---- | -------- | +| inRotationVector | Array<number> | 是 | 表示旋转矩阵。 | +| coordinates | [CoordinatesOptions](#coordinatesoptions) | 是 | 表示坐标系方向。 | -- 示例 +**返回值:** - ``` - const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}); - promise.then((data) => { - console.info("Operation successed."); - for (var i=0; i < data.length; i++) { - console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); - } - }).catch((err) => { - console.info("Operation failed"); - }) - ``` +| 类型 | 说明 | +| ---------------------------------- | ----------- | +| Promise<Array<number>> | 返回转换后的旋转矩阵。 | - +**示例:** +``` +const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}); + promise.then((data) => { + console.info("Operation successed."); + for (var i=0; i < data.length; i++) { + console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); + } + }).catch((err) => { + console.info("Operation failed"); +}) +``` ## sensor.getGeomagneticField @@ -1740,27 +1736,25 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callba **系统能力**:SystemCapability.Sensors.Sensor -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locationOptions | [LocationOptions](#locationoptions) | 是 | 地理位置。 | - | timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | - | callback | AsyncCallback<[GeomagneticResponse](#geomagneticresponse)> | 是 | 返回磁场信息。 | - -- 示例 - ``` - sensor.getGeomagneticField([80, 0, 0], {'timeMillis':1580486400000}, function(err, data) { - if (err) { - console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message); - return; - } - console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + - data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + - ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); - }); - ``` - +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ---------------------------------------- | ---- | ----------------- | +| locationOptions | [LocationOptions](#locationoptions) | 是 | 地理位置。 | +| timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | +| callback | AsyncCallback<[GeomagneticResponse](#geomagneticresponse)> | 是 | 返回磁场信息。 | +**示例:** +``` +sensor.getGeomagneticField([80, 0, 0], {'timeMillis':1580486400000}, function(err, data) { + if (err) { + console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message); + return; + } + console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); +}); +``` ## sensor.getGeomagneticField getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise<GeomagneticResponse> @@ -1769,18 +1763,18 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promi **系统能力**:SystemCapability.Sensors.Sensor -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locationOptions | [LocationOptions](#locationoptions) | 是 | 地理位置。 | - | timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ----------------------------------- | ---- | ----------------- | +| locationOptions | [LocationOptions](#locationoptions) | 是 | 地理位置。 | +| timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | -- 返回值 - | 类型 | 说明 | - | -------- | -------- | - | Promise<[GeomagneticResponse](#geomagneticresponse)> | 返回磁场信息。 | +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | ------- | +| Promise<[GeomagneticResponse](#geomagneticresponse)> | 返回磁场信息。 | -- 示例 +**返回值:** ``` const promise = sensor.getGeomagneticField([80, 0, 0], {'timeMillis':1580486400000}); promise.then((data) => { @@ -1800,15 +1794,15 @@ getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallbac **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------------- | --------------------------- | ---- | ------------------------------------- | - | seaPressure | number | 是 | 表示海平面气压值,单位为hPa。 | - | currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | - | callback | AsyncCallback<number> | 是 | 返回设备所在的海拔高度,单位为米。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | --------------------------- | ---- | -------------------- | +| seaPressure | number | 是 | 表示海平面气压值,单位为hPa。 | +| currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | +| callback | AsyncCallback<number> | 是 | 返回设备所在的海拔高度,单位为米。 | -- 示例 +**返回值:** ``` sensor.getAltitude(0, 200, function(err, data) { @@ -1829,20 +1823,20 @@ getAltitude(seaPressure: number, currentPressure: number): Promise<number> **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------------- | ------ | ---- | ------------------------------------- | - | seaPressure | number | 是 | 表示海平面气压值,单位为hPa。 | - | currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ------ | ---- | -------------------- | +| seaPressure | number | 是 | 表示海平面气压值,单位为hPa。 | +| currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | -- 返回值 +**返回值:** - | 类型 | 说明 | - | --------------------- | ------------------------------------ | - | Promise<number> | 返回设备所在的海拔高度(单位:米)。 | +| 类型 | 说明 | +| --------------------- | ------------------ | +| Promise<number> | 返回设备所在的海拔高度(单位:米)。 | -- 示例 +**返回值:** ``` const promise = sensor.getAltitude(0, 200); @@ -1862,14 +1856,14 @@ getGeomagneticDip(inclinationMatrix: Array<number>, callback: AsyncCallbac **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ----------------- | --------------------------- | ---- | ---------------------------- | - | inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | - | callback | AsyncCallback<number> | 是 | 返回地磁倾斜角,单位为弧度。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | --------------------------- | ---- | -------------- | +| inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | +| callback | AsyncCallback<number> | 是 | 返回地磁倾斜角,单位为弧度。 | -- 示例 +**返回值:** ``` sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { @@ -1878,7 +1872,7 @@ getGeomagneticDip(inclinationMatrix: Array<number>, callback: AsyncCallbac err.message); return; } - console.info(Successed to get getGeomagneticDip interface get data: " + data); + console.info("Successed to get getGeomagneticDip interface get data: " + data); }) ``` @@ -1890,19 +1884,19 @@ getGeomagneticDip(inclinationMatrix: Array<number>): Promise<number> **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ----------------- | ------------------- | ---- | -------------- | - | inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | ------------------- | ---- | ------- | +| inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | -- 返回值 +**返回值:** - | 类型 | 说明 | - | --------------------- | ---------------------------- | - | Promise<number> | 返回地磁倾斜角,单位为弧度。 | +| 类型 | 说明 | +| --------------------- | -------------- | +| Promise<number> | 返回地磁倾斜角,单位为弧度。 | -- 示例 +**返回值:** ``` const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]); @@ -1921,15 +1915,15 @@ getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Ar **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------------------- | ---------------------------------------- | ---- | --------------------------------- | - | currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | - | preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | - | callback | AsyncCallback<Array<number>> | 是 | 返回z、x、y轴方向的旋转角度变化。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------------------- | ---------------------------------------- | ---- | ------------------ | +| currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | +| preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回z、x、y轴方向的旋转角度变化。 | -- 示例 +**返回值:** ``` sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) { @@ -1954,20 +1948,20 @@ getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Ar **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------------------- | ------------------- | ---- | ------------------ | - | currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | - | preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------------------- | ------------------- | ---- | --------- | +| currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | +| preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | -- 返回值 +**返回值:** - | 类型 | 说明 | - | ---------------------------------- | --------------------------------- | - | Promise<Array<number>> | 返回z、x、y轴方向的旋转角度变化。 | +| 类型 | 说明 | +| ---------------------------------- | ------------------ | +| Promise<Array<number>> | 返回z、x、y轴方向的旋转角度变化。 | -- 示例 +**返回值:** ``` const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]); @@ -1990,14 +1984,14 @@ createRotationMatrix(rotationVector: Array<number>, callback: AsyncCallbac **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ---------------------------------------- | ---- | -------------- | - | rotationVector | Array<number> | 是 | 表示旋转矢量。 | - | callback | AsyncCallback<Array<number>> | 是 | 返回旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------------- | ---- | ------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回旋转矩阵。 | -- 示例 +**返回值:** ``` sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { @@ -2022,19 +2016,19 @@ createRotationMatrix(rotationVector: Array<number>): Promise<Array<n **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------------------- | ---- | -------------- | - | rotationVector | Array<number> | 是 | 表示旋转矢量。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------- | ---- | ------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | -- 返回值 +**返回值:** - | 类型 | 说明 | - | ---------------------------------- | -------------- | - | Promise<Array<number>> | 返回旋转矩阵。 | +| 类型 | 说明 | +| ---------------------------------- | ------- | +| Promise<Array<number>> | 返回旋转矩阵。 | -- 示例 +**返回值:** ``` const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); @@ -2057,14 +2051,14 @@ createQuaternion(rotationVector: Array<number>, callback: AsyncCallback< **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ---------------------------------------- | ---- | -------------- | - | rotationVector | Array<number> | 是 | 表示旋转矢量。 | - | callback | AsyncCallback<Array<number>> | 是 | 返回四元数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------------- | ---- | ------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回四元数。 | -- 示例 +**返回值:** ``` sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { @@ -2089,19 +2083,19 @@ createQuaternion(rotationVector: Array<number>): Promise<Array<numbe **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------------------- | ---- | -------------- | - | rotationVector | Array<number> | 是 | 表示旋转矢量。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------- | ---- | ------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | -- 返回值 +**返回值:** - | 类型 | 说明 | - | ---------------------------------- | ------------ | - | Promise<Array<number>> | 返回四元数。 | +| 类型 | 说明 | +| ---------------------------------- | ------ | +| Promise<Array<number>> | 返回四元数。 | -- 示例 +**返回值:** ``` const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]); @@ -2124,14 +2118,14 @@ getDirection(rotationMatrix: Array<number>, callback: AsyncCallback<Arr **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ---------------------------------------- | ---- | --------------------------------- | - | rotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | - | callback | AsyncCallback<Array<number>> | 是 | 返回围绕z、x、y轴方向的旋转角度。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------------- | ---- | ------------------ | +| rotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回围绕z、x、y轴方向的旋转角度。 | -- 示例 +**返回值:** ``` sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { @@ -2156,19 +2150,19 @@ getDirection(rotationMatrix: Array<number>): Promise<Array<number> **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------------------- | ---- | -------------- | - | rotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------- | ---- | ------- | +| rotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | -- 返回值 +**返回值:** - | 类型 | 说明 | - | ---------------------------------- | --------------------------------- | - | Promise<Array<number>> | 返回围绕z、x、y轴方向的旋转角度。 | +| 类型 | 说明 | +| ---------------------------------- | ------------------ | +| Promise<Array<number>> | 返回围绕z、x、y轴方向的旋转角度。 | -- 示例 +**返回值:** ``` const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]); @@ -2191,15 +2185,15 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ----------- | ------------------------------------------------------------ | ---- | -------------- | - | gravity | Array<number> | 是 | 表示重力向量。 | - | geomagnetic | Array<number> | 是 | 表示地磁矢量。 | - | callback | AsyncCallback<[RotationMatrixResponse](#rotationmatrixresponse)> | 是 | 返回旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ---------------------------------------- | ---- | ------- | +| gravity | Array<number> | 是 | 表示重力向量。 | +| geomagnetic | Array<number> | 是 | 表示地磁矢量。 | +| callback | AsyncCallback<[RotationMatrixResponse](#rotationmatrixresponse)> | 是 | 返回旋转矩阵。 | -- 示例 +**返回值:** ``` sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) { @@ -2224,20 +2218,20 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:SystemCapability.Sensors.Sensor -- 参数 +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ----------- | ------------------- | ---- | -------------- | - | gravity | Array<number> | 是 | 表示重力向量。 | - | geomagnetic | Array<number> | 是 | 表示地磁矢量。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------- | ---- | ------- | +| gravity | Array<number> | 是 | 表示重力向量。 | +| geomagnetic | Array<number> | 是 | 表示地磁矢量。 | -- 返回值 +**返回值:** - | 类型 | 说明 | - | ------------------------------------------------------------ | -------------- | - | Promise<[RotationMatrixResponse](#rotationmatrixresponse)> | 返回旋转矩阵。 | +| 类型 | 说明 | +| ---------------------------------------- | ------- | +| Promise<[RotationMatrixResponse](#rotationmatrixresponse)> | 返回旋转矩阵。 | -- 示例 +**返回值:** ``` const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); @@ -2259,29 +2253,29 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| SENSOR_TYPE_ID_ACCELEROMETER | 1 | 加速度传感器。 | -| SENSOR_TYPE_ID_GYROSCOPE | 2 | 陀螺仪传感器。 | -| SENSOR_TYPE_ID_AMBIENT_LIGHT | 5 | 环境光传感器。 | -| SENSOR_TYPE_ID_MAGNETIC_FIELD | 6 | 磁场传感器。 | -| SENSOR_TYPE_ID_BAROMETER | 8 | 气压计传感器。 | -| SENSOR_TYPE_ID_HALL | 10 | 霍尔传感器。 | -| SENSOR_TYPE_ID_PROXIMITY | 12 | 接近光传感器。 | -| SENSOR_TYPE_ID_HUMIDITY | 13 | 湿度传感器。 | -| SENSOR_TYPE_ID_ORIENTATION | 256 | 方向传感器。 | -| SENSOR_TYPE_ID_GRAVITY | 257 | 重力传感器。 | -| SENSOR_TYPE_ID_LINEAR_ACCELERATION | 258 | 线性加速度传感器。 | -| SENSOR_TYPE_ID_ROTATION_VECTOR | 259 | 旋转矢量传感器。 | -| SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 260 | 环境温度传感器。 | -| SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 261 | 未校准磁场传感器。 | -| SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 263 | 未校准陀螺仪传感器。 | -| SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 264 | 有效运动传感器。 | -| SENSOR_TYPE_ID_PEDOMETER_DETECTION | 265 | 计步检测传感器。 | -| SENSOR_TYPE_ID_PEDOMETER | 266 | 计步传感器。 | -| SENSOR_TYPE_ID_HEART_RATE | 278 | 心率传感器。 | -| SENSOR_TYPE_ID_WEAR_DETECTION | 280 | 佩戴检测传感器。 | -| SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 281 | 未校准加速度计传感器。 | +| 名称 | 默认值 | 说明 | +| ---------------------------------------- | ---- | ----------- | +| SENSOR_TYPE_ID_ACCELEROMETER | 1 | 加速度传感器。 | +| SENSOR_TYPE_ID_GYROSCOPE | 2 | 陀螺仪传感器。 | +| SENSOR_TYPE_ID_AMBIENT_LIGHT | 5 | 环境光传感器。 | +| SENSOR_TYPE_ID_MAGNETIC_FIELD | 6 | 磁场传感器。 | +| SENSOR_TYPE_ID_BAROMETER | 8 | 气压计传感器。 | +| SENSOR_TYPE_ID_HALL | 10 | 霍尔传感器。 | +| SENSOR_TYPE_ID_PROXIMITY | 12 | 接近光传感器。 | +| SENSOR_TYPE_ID_HUMIDITY | 13 | 湿度传感器。 | +| SENSOR_TYPE_ID_ORIENTATION | 256 | 方向传感器。 | +| SENSOR_TYPE_ID_GRAVITY | 257 | 重力传感器。 | +| SENSOR_TYPE_ID_LINEAR_ACCELERATION | 258 | 线性加速度传感器。 | +| SENSOR_TYPE_ID_ROTATION_VECTOR | 259 | 旋转矢量传感器。 | +| SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 260 | 环境温度传感器。 | +| SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 261 | 未校准磁场传感器。 | +| SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 263 | 未校准陀螺仪传感器。 | +| SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 264 | 有效运动传感器。 | +| SENSOR_TYPE_ID_PEDOMETER_DETECTION | 265 | 计步检测传感器。 | +| SENSOR_TYPE_ID_PEDOMETER | 266 | 计步传感器。 | +| SENSOR_TYPE_ID_HEART_RATE | 278 | 心率传感器。 | +| SENSOR_TYPE_ID_WEAR_DETECTION | 280 | 佩戴检测传感器。 | +| SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 281 | 未校准加速度计传感器。 | ## Response @@ -2290,9 +2284,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| timestamp | number | 是 | 是 | 传感器数据上报的时间戳。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ------------ | +| timestamp | number | 是 | 是 | 传感器数据上报的时间戳。 | ## AccelerometerResponse @@ -2302,11 +2296,11 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| x | number | 是 | 是 | 施加在设备x轴的加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴的加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴的加速度,单位 : m/s2。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ---------------------- | +| x | number | 是 | 是 | 施加在设备x轴的加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴的加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴的加速度,单位 : m/s2。 | ## LinearAccelerometerResponse @@ -2316,11 +2310,11 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| x | number | 是 | 是 | 施加在设备x轴的线性加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴的线性加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴的线性加速度,单位 : m/s2。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ------------------------ | +| x | number | 是 | 是 | 施加在设备x轴的线性加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴的线性加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴的线性加速度,单位 : m/s2。 | ## AccelerometerUncalibratedResponse @@ -2330,14 +2324,14 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| x | number | 是 | 是 | 施加在设备x轴未校准的加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴未校准的加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴未校准的加速度,单位 : m/s2。 | -| biasX | number | 是 | 是 | 施加在设备x轴未校准的加速度偏量,单位 : m/s2。 | -| biasY | number | 是 | 是 | 施加在设备上y轴未校准的加速度偏量,单位 : m/s2。 | -| biasZ | number | 是 | 是 | 施加在设备z轴未校准的加速度偏量,单位 : m/s2。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | ---------------------------- | +| x | number | 是 | 是 | 施加在设备x轴未校准的加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴未校准的加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴未校准的加速度,单位 : m/s2。 | +| biasX | number | 是 | 是 | 施加在设备x轴未校准的加速度偏量,单位 : m/s2。 | +| biasY | number | 是 | 是 | 施加在设备上y轴未校准的加速度偏量,单位 : m/s2。 | +| biasZ | number | 是 | 是 | 施加在设备z轴未校准的加速度偏量,单位 : m/s2。 | ## GravityResponse @@ -2347,11 +2341,11 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| x | number | 是 | 是 | 施加在设备x轴的重力加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴的重力加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴的重力加速度,单位 : m/s2。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ------------------------ | +| x | number | 是 | 是 | 施加在设备x轴的重力加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴的重力加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴的重力加速度,单位 : m/s2。 | ## OrientationResponse @@ -2361,11 +2355,11 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| alpha | number | 是 | 是 | 设备围绕 Z 轴旋转一定角度,单位 : rad。 | -| beta | number | 是 | 是 | 设备围绕 X轴旋转一定角度,单位 : rad。 | -| gamma | number | 是 | 是 | 设备围绕 Y轴旋转一定角度,单位 : rad。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | ------------------------ | +| alpha | number | 是 | 是 | 设备围绕 Z 轴旋转一定角度,单位 : rad。 | +| beta | number | 是 | 是 | 设备围绕 X轴旋转一定角度,单位 : rad。 | +| gamma | number | 是 | 是 | 设备围绕 Y轴旋转一定角度,单位 : rad。 | ## RotationVectorResponse @@ -2375,12 +2369,12 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| x | number | 是 | 是 | 旋转矢量x轴分量。 | -| y | number | 是 | 是 | 旋转矢量y轴分量。 | -| z | number | 是 | 是 | 旋转矢量z轴分量。 | -| w | number | 是 | 是 | 标量。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | --------- | +| x | number | 是 | 是 | 旋转矢量x轴分量。 | +| y | number | 是 | 是 | 旋转矢量y轴分量。 | +| z | number | 是 | 是 | 旋转矢量z轴分量。 | +| w | number | 是 | 是 | 标量。 | ## GyroscopeResponse @@ -2390,11 +2384,11 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| x | number | 是 | 是 | 设备x轴的旋转角速度,单位rad/s。 | -| y | number | 是 | 是 | 设备y轴的旋转角速度,单位rad/s。 | -| z | number | 是 | 是 | 设备z轴的旋转角速度,单位rad/s。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ------------------- | +| x | number | 是 | 是 | 设备x轴的旋转角速度,单位rad/s。 | +| y | number | 是 | 是 | 设备y轴的旋转角速度,单位rad/s。 | +| z | number | 是 | 是 | 设备z轴的旋转角速度,单位rad/s。 | ## GyroscopeUncalibratedResponse @@ -2404,14 +2398,14 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| x | number | 是 | 是 | 设备x轴未校准的旋转角速度,单位rad/s。 | -| y | number | 是 | 是 | 设备y轴未校准的旋转角速度,单位rad/s。 | -| z | number | 是 | 是 | 设备z轴未校准的旋转角速度,单位rad/s。 | -| biasX | number | 是 | 是 | 设备x轴未校准的旋转角速度偏量,单位rad/s。 | -| biasY | number | 是 | 是 | 设备y轴未校准的旋转角速度偏量,单位rad/s。 | -| biasZ | number | 是 | 是 | 设备z轴未校准的旋转角速度偏量,单位rad/s。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | ------------------------ | +| x | number | 是 | 是 | 设备x轴未校准的旋转角速度,单位rad/s。 | +| y | number | 是 | 是 | 设备y轴未校准的旋转角速度,单位rad/s。 | +| z | number | 是 | 是 | 设备z轴未校准的旋转角速度,单位rad/s。 | +| biasX | number | 是 | 是 | 设备x轴未校准的旋转角速度偏量,单位rad/s。 | +| biasY | number | 是 | 是 | 设备y轴未校准的旋转角速度偏量,单位rad/s。 | +| biasZ | number | 是 | 是 | 设备z轴未校准的旋转角速度偏量,单位rad/s。 | ## SignificantMotionResponse @@ -2421,9 +2415,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| scalar | number | 是 | 是 | 表示剧烈运动程度。测量三个物理轴(x、y 和 z)上,设备是否存在大幅度运动;如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ---------------------------------------- | +| scalar | number | 是 | 是 | 表示剧烈运动程度。测量三个物理轴(x、y 和 z)上,设备是否存在大幅度运动;如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动。 | ## ProximityResponse @@ -2433,9 +2427,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| distance | number | 是 | 是 | 可见物体与设备显示器的接近程度。0表示接近,1表示远离。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | ------ | ---- | ---- | ---------------------------- | +| distance | number | 是 | 是 | 可见物体与设备显示器的接近程度。0表示接近,1表示远离。 | ## LightResponse @@ -2445,9 +2439,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| intensity | number | 是 | 是 | 光强(单位:勒克斯)。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ----------- | +| intensity | number | 是 | 是 | 光强(单位:勒克斯)。 | ## HallResponse @@ -2457,9 +2451,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| status | number | 是 | 是 | 显示霍尔状态。测量设备周围是否存在磁力吸引,0表示有,1表示没有。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | --------------------------------- | +| status | number | 是 | 是 | 显示霍尔状态。测量设备周围是否存在磁力吸引,0表示有,1表示没有。 | ## MagneticFieldResponse @@ -2469,11 +2463,11 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| x | number | 是 | 是 | x轴环境磁场强度,单位 : μT。 | -| y | number | 是 | 是 | y轴环境磁场强度,单位 : μT。 | -| z | number | 是 | 是 | z轴环境磁场强度,单位 : μT。。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ------------------ | +| x | number | 是 | 是 | x轴环境磁场强度,单位 : μT。 | +| y | number | 是 | 是 | y轴环境磁场强度,单位 : μT。 | +| z | number | 是 | 是 | z轴环境磁场强度,单位 : μT。。 | ## MagneticFieldUncalibratedResponse @@ -2483,14 +2477,14 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| x | number | 是 | 是 | x轴未校准环境磁场强度,单位 : μT。 | -| y | number | 是 | 是 | y轴未校准环境磁场强度,单位 : μT。 | -| z | number | 是 | 是 | z轴未校准环境磁场强度,单位 : μT。 | -| biasX | number | 是 | 是 | x轴未校准环境磁场强度偏量,单位 : μT。 | -| biasY | number | 是 | 是 | y轴未校准环境磁场强度偏量,单位 : μT。 | -| biasZ | number | 是 | 是 | z轴未校准环境磁场强度偏量,单位 : μT。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | ---------------------- | +| x | number | 是 | 是 | x轴未校准环境磁场强度,单位 : μT。 | +| y | number | 是 | 是 | y轴未校准环境磁场强度,单位 : μT。 | +| z | number | 是 | 是 | z轴未校准环境磁场强度,单位 : μT。 | +| biasX | number | 是 | 是 | x轴未校准环境磁场强度偏量,单位 : μT。 | +| biasY | number | 是 | 是 | y轴未校准环境磁场强度偏量,单位 : μT。 | +| biasZ | number | 是 | 是 | z轴未校准环境磁场强度偏量,单位 : μT。 | ## PedometerResponse @@ -2500,9 +2494,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| steps | number | 是 | 是 | 用户的行走步数。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | -------- | +| steps | number | 是 | 是 | 用户的行走步数。 | ## HumidityResponse @@ -2512,9 +2506,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| humidity | number | 是 | 是 | 湿度值。测量环境的相对湿度,以百分比 (%) 表示。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | ------ | ---- | ---- | ------------------------------------ | +| humidity | number | 是 | 是 | 湿度值。测量环境的相对湿度,以百分比 (%) 表示。 | ## PedometerDetectionResponse @@ -2524,9 +2518,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| scalar | number | 是 | 是 | 计步器检测。检测用户的计步动作,如果取值为1则代表用户产生了计步行走的动作,取值为0则代表用户没有发生运动。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ---------------------------------------- | +| scalar | number | 是 | 是 | 计步器检测。检测用户的计步动作,如果取值为1则代表用户产生了计步行走的动作,取值为0则代表用户没有发生运动。 | ## AmbientTemperatureResponse @@ -2536,9 +2530,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| temperature | number | 是 | 是 | 环境温度(单位:摄氏度)。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----------- | ------ | ---- | ---- | ------------- | +| temperature | number | 是 | 是 | 环境温度(单位:摄氏度)。 | ## BarometerResponse @@ -2548,9 +2542,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| pressure | number | 是 | 是 | 压力值(单位:帕斯卡)。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | ------ | ---- | ---- | ------------ | +| pressure | number | 是 | 是 | 压力值(单位:帕斯卡)。 | ## HeartRateResponse @@ -2560,9 +2554,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| heartRate | number | 是 | 是 | 心率值。测量用户的心率数值,单位:bpm。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | --------------------- | +| heartRate | number | 是 | 是 | 心率值。测量用户的心率数值,单位:bpm。 | ## WearDetectionResponse @@ -2572,9 +2566,9 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| value | number | 是 | 是 | 表示设备是否被穿戴(1表示已穿戴,0表示未穿戴)。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | ------------------------- | +| value | number | 是 | 是 | 表示设备是否被穿戴(1表示已穿戴,0表示未穿戴)。 | ## Options @@ -2583,8 +2577,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 说明 | -| -------- | -------- | -------- | +| 名称 | 参数类型 | 说明 | +| -------- | ------ | --------------------------- | | interval | number | 表示传感器的上报频率,默认值为200000000ns。 | ## RotationMatrixResponse @@ -2593,10 +2587,10 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----------- | ------------------- | ---- | ---- | ---------- | -| rotation | Array<number> | 是 | 是 | 旋转矩阵。 | -| inclination | Array<number> | 是 | 是 | 倾斜矩阵。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----------- | ------------------- | ---- | ---- | ----- | +| rotation | Array<number> | 是 | 是 | 旋转矩阵。 | +| inclination | Array<number> | 是 | 是 | 倾斜矩阵。 | ## CoordinatesOptions @@ -2605,10 +2599,10 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | -------- | ---- | ---- | ----------- | -| x | number | 是 | 是 | x坐标方向。 | -| y | number | 是 | 是 | y坐标方向。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ------ | +| x | number | 是 | 是 | x坐标方向。 | +| y | number | 是 | 是 | y坐标方向。 | ## GeomagneticResponse @@ -2617,15 +2611,15 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| x | number | 是 | 是 | 地磁场的北分量。 | -| y | number | 是 | 是 | 地磁场的东分量。 | -| z | number | 是 | 是 | 地磁场的垂直分量。 | -| geomagneticDip | number | 是 | 是 | 地磁倾角,即地球磁场线与水平面的夹角。 | -| deflectionAngle | number | 是 | 是 | 地磁偏角,即地磁北方向与正北方向在水平面上的角度。 | -| levelIntensity | number | 是 | 是 | 地磁场的水平强度。 | -| totalIntensity | number | 是 | 是 | 地磁场的总强度。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------------- | ------ | ---- | ---- | ------------------------- | +| x | number | 是 | 是 | 地磁场的北分量。 | +| y | number | 是 | 是 | 地磁场的东分量。 | +| z | number | 是 | 是 | 地磁场的垂直分量。 | +| geomagneticDip | number | 是 | 是 | 地磁倾角,即地球磁场线与水平面的夹角。 | +| deflectionAngle | number | 是 | 是 | 地磁偏角,即地磁北方向与正北方向在水平面上的角度。 | +| levelIntensity | number | 是 | 是 | 地磁场的水平强度。 | +| totalIntensity | number | 是 | 是 | 地磁场的总强度。 | ## LocationOptions @@ -2633,8 +2627,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| latitude | number | 是 | 是 | 纬度。 | -| longitude | number | 是 | 是 | 经度。 | -| altitude | number | 是 | 是 | 海拔高度。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ----- | +| latitude | number | 是 | 是 | 纬度。 | +| longitude | number | 是 | 是 | 经度。 | +| altitude | number | 是 | 是 | 海拔高度。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-stack.md b/zh-cn/application-dev/reference/apis/js-apis-stack.md index 0341c7ca8367410a6d451c128b8d4b0f730ced63..88f73c51614991f79c031f88534f0bf122fd7813 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-stack.md +++ b/zh-cn/application-dev/reference/apis/js-apis-stack.md @@ -145,6 +145,7 @@ let result = stack.locate(2); ``` ### forEach + forEach(callbackfn: (value: T, index?: number, stack?: Stack<T>) => void, thisArg?: Object): void @@ -179,6 +180,7 @@ stack.forEach((value, index) => { ``` ### isEmpty + isEmpty(): boolean 判断该栈是否为空。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md b/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md index be6c4bf4cba3de8f1a0ce1b9b87a20fd601d0f42..4b98776f3ebaf2951d6fe8381707eb451e883735 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md @@ -13,7 +13,7 @@ import prompt from '@system.prompt'; ## prompt.showToast -showToast(Object): void +showToast(options: ShowToastOptions): void 显示文本弹窗。 @@ -23,9 +23,7 @@ showToast(Object): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| message | string | 是 | 显示的文本信息。 | -| duration | number | 否 | 默认值1500ms,建议区间:1500ms-10000ms。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 若小于1500ms则取默认值,最大取值为10000ms。 | -| [bottom]5+ | <length> | 否 | 设置弹窗边框距离屏幕底部的位置。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅手机和平板设备支持。 | +| options | [ShowToastOptions](#showtoastoptions) | 是 | 定义ShowToast的选项。 | **示例:** @@ -43,9 +41,9 @@ export default { ## prompt.showDialog -showDialog(): void +showDialog(options: ShowDialogOptions): void -在页面内显示对话框。 +显示对话框。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full @@ -53,18 +51,8 @@ showDialog(): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| title | string | 否 | 标题文本。 | -| message | string | 否 | 内容文本。 | -| buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 | -| success | Function | 否 | 接口调用成功的回调函数,返回值如success返回值所示。 | -| cancel | Function | 否 | 取消调用此接口的回调函数。 | -| complete | Function | 否 | 弹框退出时的回调函数。 | - -success返回值: +| options | [ShowDialogOptions](#showdialogoptions) | 是 | 定义显示对话框的选项。| -| 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| index | number | 选中按钮在buttons数组中的索引。 | **示例:** @@ -93,7 +81,7 @@ export default { ## prompt.showActionMenu6+ -showActionMenu(Object): void +showActionMenu(options: ShowActionMenuOptions): void 显示操作菜单。 @@ -103,17 +91,8 @@ showActionMenu(Object): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| title | string | 否 | 标题文本。 | -| buttons | Array | 是 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | -| success | (data: TapIndex) => void | 否 | 接口调用成功的回调函数。 | -| cancel | () => void | 否 | 接口调用失败的回调函数。 | -| complete | () => void | 否 | 接口调用结束的回调函数。 | - - **表1** TapIndex +| options | [ShowActionMenuOptions](#showactionmenuoptions) | 是 | 定义ShowActionMenu的选项。 | -| 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| tapIndex | number | 选中按钮在buttons数组中的索引,从0开始。 | **示例:** @@ -141,4 +120,65 @@ export default { }); } } -``` \ No newline at end of file +``` +## ShowToastOptions + +定义ShowToast的选项。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| message | string | 是 | 显示的文本信息。 | +| duration | number | 否 | 默认值1500ms,建议区间:1500ms-10000ms。若小于1500ms则取默认值,最大取值为10000ms。 | +| bottom5+ | string\|number| 否 | 设置弹窗边框距离屏幕底部的位置,仅手机和平板设备支持。 | + +## Button + +定义按钮的提示信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| text | string | 是 | 定义按钮信息。 | +| color | string | 是 | 定义按钮颜色。 | + +## ShowDialogSuccessResponse + +定义ShowDialog的响应。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| index | number | 是 | 定义数据的索引信息。 | + +## ShowDialogOptions + +定义显示对话框的选项。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| title | string | 否 | 标题文本。 | +| message | string | 否 | 文本内容。 | +| buttons | [[Button](#button), [Button](#button)?, [Button](#button)?] | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | +| success | (data: [ShowDialogSuccessResponse](#showdialogsuccessresponse)) => void | 否 | 接口调用成功的回调函数。 | +| cancel | (data: string, code: string) => void | 否 | 接口调用失败的回调函数。 | +| complete | (data: string) => void | 否 | 接口调用结束的回调函数。 | + +## ShowActionMenuOptions6+ + +定义ShowActionMenu的选项。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 参数类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| title | string | 否 | 标题文本。 | +| buttons | [[Button](#button), [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?] | 是 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。| +| success | (tapIndex: number, errMsg: string) => void | 否 | 弹出对话框时调用。 | +| fail | (errMsg: string) => void | 否 | 接口调用失败的回调函数。 | +| complete | (data: string) => void | 否 | 关闭对话框时调用。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-treemap.md b/zh-cn/application-dev/reference/apis/js-apis-treemap.md index 796112066e342dd7fe36577480a0481f3962d2b1..d49b3e210e250dac04158bf37f36622d79885db5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treemap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treemap.md @@ -45,7 +45,7 @@ let treeMap = new TreeMap(); ### isEmpty -isEmpty(): boolean; +isEmpty(): boolean 判断该容器是否为空。 @@ -65,7 +65,7 @@ let result = treeMap.isEmpty(); ### hasKey -hasKey(key: K): boolean; +hasKey(key: K): boolean 判断此容器中是否含有该指定key。 @@ -149,7 +149,7 @@ let result = treeMap.get("sdfs"); ### getFirstKey -getFirstKey(): K; +getFirstKey(): K 获取容器中排序第一的key。 @@ -171,7 +171,7 @@ let result = treeMap.getFirstKey(); ### getLastKey -getLastKey(): K; +getLastKey(): K 获取容器中排序最后的key。 @@ -215,6 +215,7 @@ treeMap.setAll(map); ### set + set(key: K, value: V): Object 向treemap中添加一组数据。 @@ -242,7 +243,7 @@ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); ### remove -remove(key: K): V; +remove(key: K): V 删除指定key对应的元素。 @@ -326,6 +327,7 @@ let result = treeMap.getHigherKey("sdfs"); ``` ### replace + replace(key: K, newValue: V): boolean 对TreeMap中一组数据进行更新(替换)。 @@ -424,7 +426,7 @@ while(temp != undefined) { ### forEach -forEach(callbackfn: (value: V, key?: K, map?: TreeMap) => void, thisArg?: Object): void +forEach(callbackfn: (value?: V, key?: K, map?: TreeMap) => void, thisArg?: Object): void 通过回调函数来遍历实例对象上的元素以及元素对应的下标。 @@ -438,8 +440,8 @@ forEach(callbackfn: (value: V, key?: K, map?: TreeMap) => void, thisArg?: callbackfn的参数说明: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | V | 是 | 当前遍历到的元素键值对的值。 | -| key | K | 是 | 当前遍历到的元素键值对的键。 | +| value | V | 否 | 当前遍历到的元素键值对的值。 | +| key | K | 否 | 当前遍历到的元素键值对的键。 | | map | TreeMap | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -484,7 +486,7 @@ while(temp != undefined) { ### [Symbol.iterator] -[Symbol.iterator]\(): IterableIterator<[K, V]>; +[Symbol.iterator]\(): IterableIterator<[K, V]> 返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-treeset.md b/zh-cn/application-dev/reference/apis/js-apis-treeset.md index 48c65fea23227ff1113273dc6aff3f772ab2ab99..473db461ba74cc8b961402595ee66d9abea2c3d7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treeset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treeset.md @@ -136,6 +136,7 @@ let result = treeSet.getLastValue(); ### add + add(value: T): boolean 向TreeSet中添加一组数据。 @@ -162,7 +163,7 @@ let result = treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); ### remove -remove(value: T): boolean; +remove(value: T): boolean 删除指定的元素。 @@ -335,7 +336,7 @@ while(temp != undefined) { ### forEach -forEach(callbackfn: (value: T, key?: T, set?: TreeSet<T>) => void, thisArg?: Object): void +forEach(callbackfn: (value?: T, key?: T, set?: TreeSet<T>) => void, thisArg?: Object): void 通过回调函数来遍历实例对象上的元素以及元素对应的下标。 @@ -349,7 +350,7 @@ forEach(callbackfn: (value: T, key?: T, set?: TreeSet<T>) => void, thisArg callbackfn的参数说明: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 当前遍历到的元素。 | +| value | T | 否 | 当前遍历到的元素。 | | key | T | 否 | 当前遍历到的元素(和value相同)。 | | set | TreeSet<T> | 否 | 当前调用forEach方法的实例对象。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-update.md b/zh-cn/application-dev/reference/apis/js-apis-update.md index ea84b0d18e42292353a90ff55f8c9f70b6fcec1b..d5cb631df90fda9bfd7300f7460fa8441ecf0e73 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-update.md +++ b/zh-cn/application-dev/reference/apis/js-apis-update.md @@ -30,15 +30,15 @@ getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | -------- | -| upgradeFile | string | 是 | 升级文件 | -| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ---- | +| upgradeFile | string | 是 | 升级文件 | +| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | **返回值:** -| 类型 | 说明 | -| ------------------- | -------- | +| 类型 | 说明 | +| ------------------- | ---- | | [Updater](#updater) | 升级对象 | **示例:** @@ -61,16 +61,16 @@ getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | ---------- | -| upgradeFile | string | 是 | 升级文件 | -| device | string | 是 | 待升级设备 | -| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ----- | +| upgradeFile | string | 是 | 升级文件 | +| device | string | 是 | 待升级设备 | +| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | **返回值:** -| 类型 | 说明 | -| ------------------- | -------- | +| 类型 | 说明 | +| ------------------- | ---- | | [Updater](#updater) | 升级对象 | **示例:** @@ -93,16 +93,16 @@ getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateType **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | ---------- | -| upgradeFile | string | 是 | 升级文件 | -| device | string | 是 | 待升级设备 | -| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ----- | +| upgradeFile | string | 是 | 升级文件 | +| device | string | 是 | 待升级设备 | +| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | **返回值:** -| 类型 | 说明 | -| ------------------- | -------- | +| 类型 | 说明 | +| ------------------- | ---- | | [Updater](#updater) | 升级对象 | **示例:** @@ -127,9 +127,9 @@ getNewVersionInfo(callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------ | ---- | ------------------ | -| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | 否 | 回调返回新版本信息 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | 否 | 回调返回新版本信息 | **示例:** @@ -152,8 +152,8 @@ getNewVersionInfo(): Promise\ **返回值:** -| 类型 | 说明 | -| ------------------------------------------- | ------------------------- | +| 类型 | 说明 | +| ---------------------------------------- | ---------------- | | Promise\<[NewVersionInfo](#newversioninfo)> | Promise,用于异步获取结果 | **示例:** @@ -178,9 +178,9 @@ checkNewVersion(callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------- | ---- | ------------------ | -| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | 否 | 回调返回新版本信息 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | 否 | 回调返回新版本信息 | **示例:** @@ -203,8 +203,8 @@ checkNewVersion(): Promise\ **返回值:** -| 类型 | 说明 | -| ------------------------------------------- | ------------------------- | +| 类型 | 说明 | +| ---------------------------------------- | ---------------- | | Promise\<[NewVersionInfo](#newversioninfo)> | Promise函数返回新版本信息 | **示例:** @@ -229,10 +229,10 @@ verifyUpdatePackage(upgradeFile: string, certsFile: string): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------ | ---- | ------------------ | -| upgradeFile | string | 是 | 待校验的升级包路径 | -| certsFile | string | 是 | 证书路径 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------ | ---- | --------- | +| upgradeFile | string | 是 | 待校验的升级包路径 | +| certsFile | string | 是 | 证书路径 | **示例:** @@ -253,8 +253,8 @@ rebootAndCleanUserData(): Promise\ **返回值:** -| 类型 | 说明 | -| ---------------- | ------------------------------- | +| 类型 | 说明 | +| ---------------- | ------------------- | | Promise\ | Promise示例,用于异步获取结果。 | **示例:** @@ -277,9 +277,9 @@ rebootAndCleanUserData(callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | ---------------------- | -| callback | Function | 是 | AsyncCallback\ | +| callback | Function | 是 | AsyncCallback\ | **示例:** @@ -299,8 +299,8 @@ applyNewVersion(): Promise\ **返回值:** -| 类型 | 说明 | -| ---------------- | ------------------------------- | +| 类型 | 说明 | +| ---------------- | ------------------- | | Promise\ | Promise示例,用于异步获取结果。 | **示例:** @@ -323,9 +323,9 @@ applyNewVersion(callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | ---------------------- | -| callback | Function | 是 | AsyncCallback\ | +| callback | Function | 是 | AsyncCallback\ | **示例:** @@ -356,7 +356,7 @@ updater.download(); ### upgrade -updater.upgrade():void +upgrade():void 启动升级。 @@ -383,10 +383,10 @@ setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------- | ---- | ------------ | -| policy | [UpdatePolicy](#updatepolicy) | 是 | 设置升级策略 | -| callback | AsyncCallback\ | 是 | 回调返回结果 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------- | ---- | ------ | +| policy | [UpdatePolicy](#updatepolicy) | 是 | 设置升级策略 | +| callback | AsyncCallback\ | 是 | 回调返回结果 | **示例:** @@ -414,14 +414,14 @@ setUpdatePolicy(policy: UpdatePolicy): Promise\ **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------------------------- | ---- | ------------ | -| policy | [UpdatePolicy](#updatepolicy) | 是 | 设置升级策略 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------------------------- | ---- | ------ | +| policy | [UpdatePolicy](#updatepolicy) | 是 | 设置升级策略 | **返回值:** -| 类型 | 说明 | -| ---------------- | ----------------------- | +| 类型 | 说明 | +| ---------------- | --------------- | | Promise\ | Promise函数返回设置结果 | **示例:** @@ -451,9 +451,9 @@ getUpdatePolicy(callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------- | ---- | -------------------- | -| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | 否 | 回调返回升级策略信息 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | 否 | 回调返回升级策略信息 | **示例:** @@ -476,8 +476,8 @@ getUpdatePolicy(): Promise\ **返回值:** -| 类型 | 说明 | -| --------------------------------------- | --------------------------- | +| 类型 | 说明 | +| --------------------------------------- | ----------------- | | Promise\<[UpdatePolicy](#updatepolicy)> | Promise函数返回升级策略信息 | **示例:** @@ -498,10 +498,10 @@ update.getUpdatePolicy().then(value => { **系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService -| 参数名 | 说明 | -| ------ | -------- | -| OTA | OTA升级 | -| patch | 补丁升级 | +| 参数名 | 说明 | +| ----- | ----- | +| OTA | OTA升级 | +| patch | 补丁升级 | ## PackageTypes @@ -509,15 +509,15 @@ update.getUpdatePolicy().then(value => { **系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService -| 参数名 | 默认值 | 说明 | -| -------------------- | ------ | -------------- | -| PACKAGE_TYPE_NORMAL | 1 | 通用升级包 | -| PACKAGE_TYPE_BASE | 2 | 基础升级包 | -| PACKAGE_TYPE_CUST | 3 | 定制升级包 | -| PACKAGE_TYPE_PRELOAD | 4 | 预装升级包 | -| PACKAGE_TYPE_COTA | 5 | 参数配置升级包 | -| PACKAGE_TYPE_VERSION | 6 | 版本升级包 | -| PACKAGE_TYPE_PATCH | 7 | 补丁包 | +| 参数名 | 默认值 | 说明 | +| -------------------- | ---- | ------- | +| PACKAGE_TYPE_NORMAL | 1 | 通用升级包 | +| PACKAGE_TYPE_BASE | 2 | 基础升级包 | +| PACKAGE_TYPE_CUST | 3 | 定制升级包 | +| PACKAGE_TYPE_PRELOAD | 4 | 预装升级包 | +| PACKAGE_TYPE_COTA | 5 | 参数配置升级包 | +| PACKAGE_TYPE_VERSION | 6 | 版本升级包 | +| PACKAGE_TYPE_PATCH | 7 | 补丁包 | ## InstallMode @@ -525,11 +525,11 @@ update.getUpdatePolicy().then(value => { **系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService -| 参数名 | 默认值 | 说明 | -| ------------------- | ------ | -------- | -| INSTALL_MODE_NORMAL | 0 | 正常升级 | -| INSTALL_MODE_NIGHT | 1 | 夜间升级 | -| INSTALL_MODE_AUTO | 2 | 自动升级 | +| 参数名 | 默认值 | 说明 | +| ------------------- | ---- | ---- | +| INSTALL_MODE_NORMAL | 0 | 正常升级 | +| INSTALL_MODE_NIGHT | 1 | 夜间升级 | +| INSTALL_MODE_AUTO | 2 | 自动升级 | ## NewVersionStatus @@ -537,12 +537,12 @@ update.getUpdatePolicy().then(value => { **系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService -| 参数名 | 默认值 | 说明 | -| ------------------- | ------ | ---------------- | -| VERSION_STATUS_ERR | -1 | 检测版本时出错 | -| VERSION_STATUS_NEW | 0 | 检测到新版本 | -| VERSION_STATUS_NONE | 1 | 没有检测到新版本 | -| VERSION_STATUS_BUSY | 2 | 检测版本时忙 | +| 参数名 | 默认值 | 说明 | +| ------------------- | ---- | -------- | +| VERSION_STATUS_ERR | -1 | 检测版本时出错 | +| VERSION_STATUS_NEW | 0 | 检测到新版本 | +| VERSION_STATUS_NONE | 1 | 没有检测到新版本 | +| VERSION_STATUS_BUSY | 2 | 检测版本时忙 | ## UpdatePolicy @@ -550,11 +550,11 @@ update.getUpdatePolicy().then(value => { **系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService -| 名称 | 参数类型 | 必填 | 说明 | -| ------------------- | --------------------------- | ---- | -------------- | -| autoDownload | bool | 是 | 自动升级开关 | -| installMode | [InstallMode](#installmode) | 是 | 安装模式 | -| autoUpgradeInterval | Array\ | 是 | 自动升级时间段 | +| 名称 | 参数类型 | 必填 | 说明 | +| ------------------- | --------------------------- | ---- | ------- | +| autoDownload | bool | 是 | 自动升级开关 | +| installMode | [InstallMode](#installmode) | 是 | 安装模式 | +| autoUpgradeInterval | Array\ | 是 | 自动升级时间段 | ## NewVersionInfo @@ -562,12 +562,12 @@ update.getUpdatePolicy().then(value => { **系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService -| 名称 | 参数类型 | 必填 | 说明 | -| --------------- | ------------------------------------------- | ---- | -------- | -| status | [NewVersionStatus](#newversionstatus) | 是 | 升级状态 | -| errMsg | string | 是 | 错误信息 | -| checkResults | Array<[CheckResult](#checkresult)> | 是 | 检测结果 | -| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | 是 | 描述信息 | +| 名称 | 参数类型 | 必填 | 说明 | +| --------------- | ---------------------------------------- | ---- | ---- | +| status | [NewVersionStatus](#newversionstatus) | 是 | 升级状态 | +| errMsg | string | 是 | 错误信息 | +| checkResults | Array<[CheckResult](#checkresult)> | 是 | 检测结果 | +| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | 是 | 描述信息 | ## CheckResult @@ -575,14 +575,14 @@ update.getUpdatePolicy().then(value => { **系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService -| 名称 | 参数类型 | 必填 | 说明 | -| ------------- | ----------------------------- | ---- | ------------ | -| versionName | string | 是 | 版本名称 | -| versionCode | number | 是 | 版本编码 | -| size | number | 是 | 版本大小 | -| verifyInfo | string | 是 | 版本校验信息 | -| packageType | [PackageTypes](#packagetypes) | 是 | 版本类型 | -| descriptionId | string | 是 | 版本描述信息 | +| 名称 | 参数类型 | 必填 | 说明 | +| ------------- | ----------------------------- | ---- | ------ | +| versionName | string | 是 | 版本名称 | +| versionCode | number | 是 | 版本编码 | +| size | number | 是 | 版本大小 | +| verifyInfo | string | 是 | 版本校验信息 | +| packageType | [PackageTypes](#packagetypes) | 是 | 版本类型 | +| descriptionId | string | 是 | 版本描述信息 | ## DescriptionInfo @@ -590,7 +590,7 @@ update.getUpdatePolicy().then(value => { **系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService -| 名称 | 参数类型 | 必填 | 说明 | -| ------------- | -------- | ---- | ----------------- | -| descriptionId | string | 是 | 版本versionId信息 | -| content | string | 是 | 版本changelog信息 | \ No newline at end of file +| 名称 | 参数类型 | 必填 | 说明 | +| ------------- | ------ | ---- | ------------- | +| descriptionId | string | 是 | 版本versionId信息 | +| content | string | 是 | 版本changelog信息 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-url.md b/zh-cn/application-dev/reference/apis/js-apis-url.md old mode 100644 new mode 100755 index 2208093cd8c569b43645479e6840acf41e5f4ef4..1c2c93f6e64079d70e4716be6286dcd70f25f22c --- a/zh-cn/application-dev/reference/apis/js-apis-url.md +++ b/zh-cn/application-dev/reference/apis/js-apis-url.md @@ -113,7 +113,7 @@ console.log(params.getAll('fod')) // Output ["1","3"]. ### entries -entries(): IterableIterator<[string, string]> +entries(): IterableIterator<[string, string]> 返回一个ES6的迭代器,迭代器的每一项都是一个 JavaScript Array。Array的第一项是name,Array的第二项是value。 @@ -135,7 +135,7 @@ for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pair ### forEach -forEach(callbackfn: (value: string, key: string, searchParams: Object) => void, thisArg?: Object): void +forEach(callbackfn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void 通过回调函数来遍历URLSearchParams实例对象上的键值对。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md index 0fee12263476c476addc5eb0734ea48a7ad712cc..feecb98ea5cfefa7c76ed6b25ebcdcabba8560f1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -34,24 +34,23 @@ export default { ```js // API version 8 import userIAM_userAuth from '@ohos.userIAM.userAuth'; +let auth = new userIAM_userAuth.UserAuth(); export default { - let auth = new userIAM_userAuth.UserAuth(); - getVersion() { console.info("start get version"); - let version = auth.getVersion(); + let version = this.auth.getVersion(); console.info("auth version = " + version); }, startAuth() { console.info("start auth"); - auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { + this.auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { onResult: (result, extraInfo) => { try { console.info("auth onResult result = " + result); console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo)); - if (result == SUCCESS) { + if (result == 'SUCCESS') { // 此处添加认证成功逻辑 } else { // 此处添加认证失败逻辑 @@ -75,7 +74,7 @@ export default { checkAuthSupport() { console.info("start check auth support"); - let checkCode = auth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1); + let checkCode = this.auth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1); if (checkCode == userIAM_userAuth.ResultCode.SUCCESS) { console.info("check auth support success"); // 此处添加支持指定类型认证的逻辑 @@ -91,13 +90,13 @@ export default { let contextId = auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { onResult: (result, extraInfo) => { console.info("auth onResult result = " + result); - } + }, onAcquireInfo: (module, acquire, extraInfo) => { console.info("auth onAcquireInfo module = " + module); } }); - let cancelCode = auth.cancel(contextId); + let cancelCode = this.auth.cancel(contextId); if (cancelCode == userIAM_userAuth.Result.SUCCESS) { console.info("cancel auth success"); } else { @@ -118,7 +117,7 @@ getAuthenticator(): Authenticator **需要权限**:ohos.permission.ACCESS_BIOMETRIC -**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth +**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core **返回值:** | 类型 | 说明 | @@ -149,7 +148,7 @@ execute(type: string, level: string, callback: AsyncCallback<number>): voi **需要权限**:ohos.permission.ACCESS_BIOMETRIC -**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth +**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core **参数:** @@ -188,7 +187,7 @@ execute(type:string, level:string): Promise<number> **需要权限**:ohos.permission.ACCESS_BIOMETRIC -**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth +**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -219,7 +218,7 @@ authenticator.execute("FACE_ONLY", "S2").then((code)=>{ 表示认证结果的枚举。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth +**系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core | 名称 | 默认值 | 描述 | | ------------------ | ------ | -------------------------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-util.md b/zh-cn/application-dev/reference/apis/js-apis-util.md index 3b675034884feadb4cbe11bf7c3b4db6ead2d499..4f160237ffa92af7655936bba888696dbc78778a 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-util.md +++ b/zh-cn/application-dev/reference/apis/js-apis-util.md @@ -147,7 +147,7 @@ promiseWrapper(original: (err: Object, value: Object) => void): Object ### constructor -constructor(encoding?: string, options?: { fatal?: boolean;ignoreBOM?: boolean }) +constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean },) TextDecoder的构造函数。 @@ -174,7 +174,7 @@ TextDecoder的构造函数。 ### decode -decode(input: Unit8Array, options?: {stream?: false}): string +decode(input: Uint8Array, options?: { stream?: false }): string 通过输入参数解码后输出对应文本。 @@ -1108,7 +1108,7 @@ class Temperature{ ### constructor8+ -constructor(lowerObj: ScopeType,upperObje: ScopeType) +constructor(lowerObj: ScopeType, upperObj: ScopeType) 用于创建指定下限和上限的作用域实例的构造函数,返回一个Scope对象。 @@ -2321,7 +2321,7 @@ isStringObject(value: Object): boolean ### isSymbolObjec8+ -isSymbolObjec(value: Object): boolean +isSymbolObject(value: Object): boolean 检查输入的value是否是Symbol对象类型。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-vector.md b/zh-cn/application-dev/reference/apis/js-apis-vector.md index 23351ac3b6c21bd45cb5b5b90acc826791ae9635..e6ddff2aec31f60981b997b5ac4633376b169c8a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vector.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vector.md @@ -241,7 +241,8 @@ let result = vector.remove(2); ``` ### removeByRange -removeByRange(fromIndex: number, toIndex: number): void; + +removeByRange(fromIndex: number, toIndex: number): void 从一段范围内删除元素,包括起始值但不包括终止值。 @@ -266,6 +267,7 @@ vector.removeByRange(2,6); ``` ### replaceAllElements + replaceAllElements(callbackfn: (value: T, index?: number, vector?: Vector<T>) => T, thisArg?: Object): void @@ -303,8 +305,9 @@ vector.replaceAllElements((value, index) => { ``` ### forEach + forEach(callbackfn: (value: T, index?: number, vector?: Vector<T>) => void, -thisArg?: Object): void; +thisArg?: Object): void 通过回调函数来遍历Vector实例对象上的元素以及元素对应的下标。 @@ -338,6 +341,7 @@ vector.forEach((value, index) => { ``` ### sort + sort(comparator?: (firstValue: T, secondValue: T) => number): void 对Vector中的元素进行一个排序操作。 @@ -369,6 +373,7 @@ vector.sort(); ``` ### subVector + subVector(fromIndex: number, toIndex: number): Vector<T> 根据下标截取Vector中的一段元素,并返回这一段vector实例,包括起始值但不包括终止值。 @@ -401,6 +406,7 @@ let result2 = vector.subVector(2,6); ``` ### clear + clear(): void 清除Vector中的所有元素,并把length置为0。 @@ -417,6 +423,7 @@ vector.clear(); ``` ### clone + clone(): Vector<T> 克隆一个与Vector相同的实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 @@ -439,6 +446,7 @@ let result = vector.clone(); ``` ### getCapacity + getCapacity(): number 获取当前实例的容量大小。 @@ -461,6 +469,7 @@ let result = vector.getCapacity(); ``` ### convertToArray + convertToArray(): Array<T> 把当前Vector实例转换成数组,并返回转换后的数组。 @@ -483,6 +492,7 @@ let result = vector.convertToArray(); ``` ### isEmpty + isEmpty(): boolean 判断该Vector是否为空。 @@ -505,6 +515,7 @@ let result = vector.isEmpty(); ``` ### increaseCapacityTo + increaseCapacityTo(newCapacity: number): void 如果传入的新容量大于或等于Vector中的元素个数,将容量变更为新容量。 @@ -699,6 +710,7 @@ let result = vector.getIndexFrom(4, 3); ``` ### setLength + setLength(newSize: number): void 设置Vector实例的元素个数。 @@ -722,6 +734,7 @@ vector.setLength(2); ``` ### get + get(index: number): T 根据下标值获取Vector实例中的元素。 @@ -749,6 +762,7 @@ get(index: number): T let result = vector.get(2); ``` ### set + set(index: number, element: T): T 将此Vector中指定位置的元素替换为指定元素。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md index f0880ee46acee9980596247992a75f4b37cc739c..64e9e9c484c067719de81281ec2d481cf246ce5c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md @@ -22,18 +22,18 @@ vibrate(duration: number): Promise<void> **系统能力**:SystemCapability.Sensors.MiscDevice -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | duration | number | 是 | 指示马达振动的持续时间。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------ | +| duration | number | 是 | 指示马达振动的持续时间。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 指示触发振动是否成功。 | +**返回值:** +| 类型 | 说明 | +| ------------------- | ----------- | +| Promise<void> | 指示触发振动是否成功。 | -- 示例: +**示例:** ``` vibrator.vibrate(1000).then(()=>{ console.log("Promise returned to indicate a successful vibration."); @@ -53,13 +53,13 @@ vibrate(duration: number, callback?: AsyncCallback<void>): void **系统能力**:SystemCapability.Sensors.MiscDevice -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | duration | number | 是 | 指示马达振动的持续时间。 | - | callback | AsyncCallback<void> | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ----------------------- | +| duration | number | 是 | 指示马达振动的持续时间。 | +| callback | AsyncCallback<void> | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 | -- 示例: +**示例:** ``` vibrator.vibrate(1000,function(error){ if(error){ @@ -81,17 +81,17 @@ vibrate(effectId: EffectId): Promise<void> **系统能力**:SystemCapability.Sensors.MiscDevice -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | effectId | [EffectId](#effectid) | 是 | 指示马达振动效果的字符串。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ------------- | +| effectId | [EffectId](#effectid) | 是 | 指示马达振动效果的字符串。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 指示触发振动是否成功。 | +**返回值:** +| 类型 | 说明 | +| ------------------- | ----------- | +| Promise<void> | 指示触发振动是否成功。 | -- 示例: +**示例:** ``` vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{ console.log("Promise returned to indicate a successful vibration."); @@ -111,13 +111,13 @@ vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void **系统能力**:SystemCapability.Sensors.MiscDevice -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | effectId | [EffectId](#effectid) | 是 | 指示马达振动效果的字符串。 | - | callback | AsyncCallback<void> | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ----------------------- | +| effectId | [EffectId](#effectid) | 是 | 指示马达振动效果的字符串。 | +| callback | AsyncCallback<void> | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 | -- 示例: +**示例:** ``` vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){ if(error){ @@ -139,17 +139,17 @@ stop(stopMode: VibratorStopMode): Promise<void> **系统能力**:SystemCapability.Sensors.MiscDevice -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 指示马达要停止指定的振动模式。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | --------------- | +| stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 指示马达要停止指定的振动模式。 | -- 返回值: - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 指示停止振动是否成功。 | +**返回值:** +| 类型 | 说明 | +| ------------------- | ----------- | +| Promise<void> | 指示停止振动是否成功。 | -- 示例: +**示例:** ``` vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ console.log("Promise returned to indicate a successful vibration."); @@ -169,13 +169,13 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void; **系统能力**:SystemCapability.Sensors.MiscDevice -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 指示马达要停止指定的振动模式。 | - | callback | AsyncCallback<void> | 否 | 马达停止振动的回调函数,指示停止振动是否成功。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | ----------------------- | +| stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 指示马达要停止指定的振动模式。 | +| callback | AsyncCallback<void> | 否 | 马达停止振动的回调函数,指示停止振动是否成功。 | -- 示例: +**示例:** ``` vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ if(error){ @@ -193,8 +193,8 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void; **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | +| 名称 | 默认值 | 说明 | +| ------------------ | -------------------- | --------------- | | EFFECT_CLOCK_TIMER | "haptic.clock.timer" | 调整定时器时振动器的振动效果。 | @@ -204,7 +204,7 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void; **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| VIBRATOR_STOP_MODE_TIME | "time" | 停止模式为duration模式的振动。即触发振动时参数类型为number,参数本身为指示振动持续时间的触发方式。 | +| 名称 | 默认值 | 说明 | +| ------------------------- | -------- | ---------------------------------------- | +| VIBRATOR_STOP_MODE_TIME | "time" | 停止模式为duration模式的振动。即触发振动时参数类型为number,参数本身为指示振动持续时间的触发方式。 | | VIBRATOR_STOP_MODE_PRESET | "preset" | 停止模式为预置EffectId的振动。即触发振动时参数类型为EffectId,参数本身为指示马达振动效果的字符串的触发方式。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md index 212f15f2fe30dbd7c7c6ef209606bf7ec6d2dc0e..3b9e5d5930249145945dac5a661747ee8abce050 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @@ -358,7 +358,7 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void - 示例: ``` - wallpaper.reset((error, data) => { + wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to reset because: ` + JSON.stringify(error)); return; @@ -391,7 +391,7 @@ reset(wallpaperType: WallpaperType): Promise<void> - 示例: ``` - wallpaper.reset(wallpaper.WALLPAPER_SYSTEM).then((data) => { + wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to reset.`); }).catch((error) => { console.error(`failed to reset because: ` + JSON.stringify(error)); @@ -401,7 +401,7 @@ reset(wallpaperType: WallpaperType): Promise<void> ## wallpaper.setWallpaper -setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void +setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void 将指定资源设置为指定类型的壁纸。 @@ -412,16 +412,16 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | uriOrPixelMap | string \|[PixelMap](js-apis-image.md#pixelmap7) | | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | + | source | string \|[PixelMap](js-apis-image.md#pixelmap7) | | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是返回设置的结果,调用失败则返回error信息。 | - 示例: ``` - // uriOrPixelMap类型为string + // source类型为string let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; - wallpaper.setWallpaper(wallpaperPath, wallpaper.WALLPAPER_SYSTEM, (error, data) => { + wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); return; @@ -429,7 +429,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp console.log(`success to setWallpaper.`); }); - // uriOrPixelMap类型为image.PixelMap + // source类型为image.PixelMap import image from '@ohos.multimedia.image'; let imageSource = image.createImageSource("file://" + wallpaperPath); let opts = { @@ -439,7 +439,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp } }; imageSource.createPixelMap(opts).then((pixelMap) => { - wallpaper.setWallpaper(pixelMap, wallpaper.WALLPAPER_SYSTEM, (error, data) => { + wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); return; @@ -454,7 +454,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp ## wallpaper.setWallpaper -setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void> +setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void> 将指定资源设置为指定类型的壁纸。 @@ -465,7 +465,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | uriOrPixelMap | string \|[PixelMap](js-apis-image.md#pixelmap7) | 是 | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | + | source | string \|[PixelMap](js-apis-image.md#pixelmap7) | 是 | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: @@ -476,15 +476,15 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp - 示例: ``` - // uriOrPixelMap类型为string + // source类型为string let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; - wallpaper.setWallpaper(wallpaperPath, wallpaper.WALLPAPER_SYSTEM).then((data) => { + wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to setWallpaper.`); }).catch((error) => { console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); }); - // uriOrPixelMap类型为image.PixelMap + // source类型为image.PixelMap import image from '@ohos.multimedia.image'; let imageSource = image.createImageSource("file://" + wallpaperPath); let opts = { @@ -494,7 +494,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp } }; imageSource.createPixelMap(opts).then((pixelMap) => { - wallpaper.setWallpaper(pixelMap, wallpaper.WALLPAPER_SYSTEM).then((data) => { + wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to setWallpaper.`); }).catch((error) => { console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); @@ -503,6 +503,62 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); }); ``` +## wallpaper.getFile8+ + +getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void + +获取指定类型的壁纸文件。 + +**需要权限**:ohos.permission.SET_WALLPAPER、ohos.permission.READ_USER_STORAGE + +**系统能力**: SystemCapability.Miscservices.Wallpaper + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<number> | 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | + +- 示例: + + ``` + wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { + if (error) { + console.error(`failed to getFile because: ` + JSON.stringify(error)); + return; + } + console.log(`success to getFile: ` + JSON.stringify(data)); + }); + ``` +## wallpaper.getFile8+ + +getFile(wallpaperType: WallpaperType): Promise<number> + +获取指定类型的壁纸文件。 + +**需要权限:** ohos.permission.SET_WALLPAPER、ohos.permission.READ_USER_STORAGE + +**系统能力**: SystemCapability.Miscservices.Wallpaper + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<number> | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | + +- 示例: + + ``` + wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { + console.log(`success to getFile: ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to getFile because: ` + JSON.stringify(error)); + }); + ``` ## wallpaper.on('colorChange') diff --git a/zh-cn/application-dev/reference/apis/js-apis-webgl.md b/zh-cn/application-dev/reference/apis/js-apis-webgl.md index 99783f9e0ba2806654e404dcadd600844dab3e0c..289a71c99f853061b42acf97cbe5412bdbb28703 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webgl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webgl.md @@ -7,13 +7,6 @@ WebGL标准图形API,对应OpenGL ES 2.0特性集。更多信息请参考[WebGL™标准](https://www.khronos.org/registry/webgl/specs/latest/1.0/)。 -## 导入模块 - -``` -import webgl from '@ohos.webglnapi' -``` - - ## 调用方式 hml内创建canvas,示例如下: diff --git a/zh-cn/application-dev/reference/apis/js-apis-webgl2.md b/zh-cn/application-dev/reference/apis/js-apis-webgl2.md index dbeff187353b5899c2ac7e63275cbc27f796b259..1365302250ee39c56de5d8db811a5e67257ba2f7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webgl2.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webgl2.md @@ -7,13 +7,6 @@ WebGL标准图形API,对应OpenGL ES 3.0特性集。更多信息请参考[WebGL™标准](https://www.khronos.org/registry/webgl/specs/latest/2.0/)。 -## 导入模块 - -``` -import webgl from '@ohos.webglnapi' -``` - - ## 调用方式 hml内创建canvas,示例如下: @@ -33,7 +26,7 @@ js内获取canvas实例,示例如下: // 获取canvas组件实例 const el = this.$refs.canvas1; // 从canvas组件实例获取WebGL上下文 -const gl = el.getContext('webgl'); +const gl = el.getContext('webgl2'); // 调用WebGL API gl.clearColor(0.0, 0.0, 0.0, 1.0); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-wifi.md b/zh-cn/application-dev/reference/apis/js-apis-wifi.md index 71fb6b77d80138291df2619d0309c569dc3e4579..34b8c0304bfa1eff29ff477aa55ae24af2d267a9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wifi.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wifi.md @@ -154,7 +154,7 @@ WLAN热点信息。 | WIFI_SEC_TYPE_SAE | 4 | Simultaneous Authentication of Equals (SAE)加密类型。 | -## wifi.addUntrustedConfig +## wifi.addUntrustedConfig7+ addUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> @@ -189,7 +189,7 @@ WLAN配置信息。 | securityType | [WifiSecurityType](#WifiSecurityType) | 只读 | 加密类型。 | -## wifi.addUntrustedConfig +## wifi.addUntrustedConfig7+ addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean>): void @@ -208,7 +208,7 @@ addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean& | callback | AsyncCallback<boolean> | 是 | 操作结果,ture: 成功, false: 失败。 | -## wifi.removeUntrustedConfig +## wifi.removeUntrustedConfig7+ removeUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> @@ -231,7 +231,7 @@ removeUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> | Promise<boolean> | 操作结果,ture: 成功, false: 失败。 | -## wifi.removeUntrustedConfig +## wifi.removeUntrustedConfig7+ removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean>): void @@ -274,7 +274,7 @@ getSignalLevel(rssi: number, band: number): number | number | 信号强度,取值范围为[0, 4]。 | -## wifi.getLinkedInfo7+ +## wifi.getLinkedInfo getLinkedInfo(): Promise<WifiLinkedInfo> @@ -292,7 +292,7 @@ getLinkedInfo(): Promise<WifiLinkedInfo> | Promise<[WifiLinkedInfo](#WifiLinkedInfo)> | WLAN连接的相关信息。 | -## wifi.getLinkedInfo7+ +## wifi.getLinkedInfo getLinkedInfo(callback: AsyncCallback<WifiLinkedInfo>): void @@ -437,7 +437,7 @@ getIpInfo(): IpInfo | [IpInfo](#IpInfo) | IP信息。 | -## IpInfo +## IpInfo7+ IP信息。 @@ -506,7 +506,7 @@ getP2pLinkedInfo(callback: AsyncCallback<WifiP2pLinkedInfo>): void | callback | AsyncCallback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | 是 | P2P连接信息结果回调函数。 | -## WifiP2pLinkedInfo +## WifiP2pLinkedInfo8+ 提供WLAN连接的相关信息。 @@ -517,7 +517,7 @@ getP2pLinkedInfo(callback: AsyncCallback<WifiP2pLinkedInfo>): void | groupOwnerAddr | string | 只读 | 群组MAC地址。 | -## P2pConnectState +## P2pConnectState8+ 表示P2P连接状态的枚举。 @@ -563,7 +563,7 @@ getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void | callback | AsyncCallback<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> | 是 | 当前组信息的回调函数。 | -## WifiP2pGroupInfo +## WifiP2pGroupInfo8+ 表示P2P群组相关信息。 @@ -579,7 +579,7 @@ getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void | clientDevices | [WifiP2pDevice[]](#WifiP2pDevice) | 只读 | 接入的设备列表信息。 | | goIpAddress | string | 只读 | 群组IP地址。 | -## WifiP2pDevice +## WifiP2pDevice8+ 表示P2P设备信息。 @@ -591,7 +591,7 @@ getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void | deviceStatus | [P2pDeviceStatus](#P2pDeviceStatus) | 只读 | 设备状态。 | | groupCapabilitys | number | 只读 | 群组能力。 | -## P2pDeviceStatus +## P2pDeviceStatus8+ 表示设备状态的枚举。 @@ -662,7 +662,7 @@ createGroup(config: WifiP2PConfig): boolean; | -------- | -------- | | boolean | true:创建群组操作执行成功, false:创建群组操作执行失败。 | -## WifiP2PConfig +## WifiP2PConfig8+ 表示P2P配置信息。 @@ -675,7 +675,7 @@ createGroup(config: WifiP2PConfig): boolean; | goBand | [GroupOwnerBand](#GroupOwnerBand) | 只读 | 群组带宽。 | -## GroupOwnerBand +## GroupOwnerBand8+ 表示群组带宽的枚举。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md index b2b623dc6f9c8018aeabb4528af605b5fb96730c..626bd01dff25af4e8739a87fc57ac90ba32d07bc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md +++ b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @@ -19,14 +19,14 @@ startWork(work: WorkInfo): boolean **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| work | [WorkInfo](#workinfo) | 是 | 指示要添加到执行队列的工作。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---- | --------------------- | ---- | -------------- | +| work | [WorkInfo](#workinfo) | 是 | 指示要添加到执行队列的工作。 | **返回值**: -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------- | -------------------------------- | | boolean | 如果工作成功添加到执行队列,则返回true,否则返回false。 | **示例**: @@ -54,15 +54,15 @@ stopWork(work: WorkInfo, needCancel?: boolean): boolean **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| work | [WorkInfo](#workinfo) | 是 | 指示要停止的工作。 | -|needCancel|boolean| 是| 是否需要取消的工作。| +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------- | ---- | ---------- | +| work | [WorkInfo](#workinfo) | 是 | 指示要停止的工作。 | +| needCancel | boolean | 是 | 是否需要取消的工作。 | **返回值**: -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------- | ----------------------- | | boolean | 如果成功,则返回true,否则返回false。 | **示例**: @@ -90,10 +90,10 @@ getWorkStatus(workId: number, callback : AsyncCallback\): void **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| workId | number | 是 | work的id。 | -|callback|AsyncCallback\<[WorkInfo](#workinfo)>| 是| 指定的callback回调方法。如果指定的工作Id有效,则返回从WorkSchedulerService获取的有效工作状态;否则返回null。| +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | ---------------------------------------- | +| workId | number | 是 | work的id。 | +| callback | AsyncCallback\<[WorkInfo](#workinfo)> | 是 | 指定的callback回调方法。如果指定的工作Id有效,则返回从WorkSchedulerService获取的有效工作状态;否则返回null。 | **示例**: @@ -110,7 +110,7 @@ getWorkStatus(workId: number, callback : AsyncCallback\): void ``` ## workScheduler.getWorkStatus -getWorkStatus(workID: number): Promise\ +getWorkStatus(workId: number): Promise\ 获取工作的最新状态,使用Promise形式返回。 @@ -118,14 +118,14 @@ getWorkStatus(workID: number): Promise\ **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| workId | number | 是 | work的id。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| workId | number | 是 | work的id。 | **返回值**: -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------------------- | ---------------------------------------- | | Promise\<[WorkInfo](#workinfo)> | 指定的Promise回调方法。如果指定的工作ID有效,则返回从WorkSchedulerService获取的有效工作状态;否则返回null。 | **示例**: @@ -149,14 +149,14 @@ obtainAllWorks(callback : AsyncCallback\): Array\ **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -|callback|AsyncCallback\| 是| 指定的callback回调方法。返回与应用程序关联的所有工作。| +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------------------- | +| callback | AsyncCallback\ | 是 | 指定的callback回调方法。返回与应用程序关联的所有工作。 | **返回值**: -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ----------------------------- | --------------- | | Array\<[WorkInfo](#workinfo)> | 返回与应用程序关联的所有工作。 | **示例**: @@ -180,9 +180,9 @@ obtainAllWorks(): Promise> **返回值**: -| 类型 | 说明 | -| -------- | -------- | -| Promise> | 指定的Promise回调方法。返回与应用程序关联的所有工作。| +| 类型 | 说明 | +| -------------------------------------- | ------------------------------ | +| Promise> | 指定的Promise回调方法。返回与应用程序关联的所有工作。 | **示例**: @@ -217,15 +217,15 @@ isLastWorkTimeOut(workId: number, callback : AsyncCallback\): boolean **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| workId | number | 是 | work的id。 | -|callback|AsyncCallback\| 是| 指定的callback回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。| +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------------------------------- | +| workId | number | 是 | work的id。 | +| callback | AsyncCallback\ | 是 | 指定的callback回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | **返回值**: -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------- | ---------------------------------------- | | boolean | 指定的callback回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | **示例**: @@ -249,15 +249,15 @@ isLastWorkTimeOut(workId: number): Promise\ **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| workId | number | 是 | work的id。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| workId | number | 是 | work的id。 | **返回值**: -| 类型 | 说明 | -| -------- | -------- | -| Promise\ | 指定的Promise回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。| +| 类型 | 说明 | +| ----------------- | ---------------------------------------- | +| Promise\ | 指定的Promise回调方法。如果指定工作的最后一次执行是超时操作,则返回true;否则返回false。 | **示例**: @@ -276,57 +276,57 @@ isLastWorkTimeOut(workId: number): Promise\ **系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -|workId |number |是 |当前工作的ID。| -|bundleName |string |是| 延迟任务包名。| -|abilityName | string| 是| 延迟任务回调通知的组件名(必填)| -|networkType | [NetworkType](#networktype) | 否| 网络条件 | -|isCharging | bool| 否|是否充电 | -|chargerType | [ChargingType](#chargingtype) | 否|充电类型 | -|batteryLevel | number| 否|电量| -|batteryStatus| [BatteryStatus](#batterystatus) | 否|电池状态| -|storageRequest|[StorageRequest](#storagerequest)| 否|存储状态| -|isRepeat|boolean|否|是否循环任务| -|repeatCycleTime |number|否|循环间隔| -|repeatCount |number|否|循环次数| +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | --------------------------------- | ---- | ---------------- | +| workId | number | 是 | 当前工作的ID | +| bundleName | string | 是 | 延迟任务包名 | +| abilityName | string | 是 | 延迟任务回调通知的组件名(必填) | +| networkType | [NetworkType](#networktype) | 否 | 网络类型 | +| isCharging | boolean | 否 | 是否充电 | +| chargerType | [ChargingType](#chargingtype) | 否 | 充电类型 | +| batteryLevel | number | 否 | 电量 | +| batteryStatus | [BatteryStatus](#batterystatus) | 否 | 电池状态 | +| storageRequest | [StorageRequest](#storagerequest) | 否 | 存储状态 | +| isRepeat | boolean | 否 | 是否循环任务 | +| repeatCycleTime | number | 否 | 循环间隔 | +| repeatCount | number | 否 | 循环次数 | ## NetworkType 触发工作的网络类型。 **系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler - |名称 |默认值 |说明| - | -------- | -------- | -------- | - |NETWORK_TYPE_ANY |0 |表示这个触发条件是任何类型的网络连接。| - |NETWORK_TYPE_MOBILE |1| 表示这个触发条件是Mobile网络连接。| - |NETWORK_TYPE_WIFI |2 |表示这个触发条件是Wifi类型的网络连接。| - |NETWORK_TYPE_BLUETOOTH |3 |表示这个触发条件是Bluetooth网络连接。| - |NETWORK_TYPE_WIFI_P2P |4 |表示这个触发条件是Wifi P2P网络连接。| - |NETWORK_TYPE_ETHERNET |5 |表示这个触发条件是有线网络连接。| +| 名称 | 默认值 | 说明 | +| ---------------------- | ---- | ----------------------- | +| NETWORK_TYPE_ANY | 0 | 表示这个触发条件是任何类型的网络连接。 | +| NETWORK_TYPE_MOBILE | 1 | 表示这个触发条件是Mobile网络连接。 | +| NETWORK_TYPE_WIFI | 2 | 表示这个触发条件是Wifi类型的网络连接。 | +| NETWORK_TYPE_BLUETOOTH | 3 | 表示这个触发条件是Bluetooth网络连接。 | +| NETWORK_TYPE_WIFI_P2P | 4 | 表示这个触发条件是Wifi P2P网络连接。 | +| NETWORK_TYPE_ETHERNET | 5 | 表示这个触发条件是有线网络连接。 | ## ChargingType 触发工作的充电类型。 **系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler - |名称 |默认值 |说明| - | -------- | -------- | -------- | - |CHARGING_PLUGGED_ANY |0| 表示这个触发条件是任何类型的充电器连接。| - |CHARGING_PLUGGED_AC |1 |表示这个触发条件是直流充电器连接。| - |CHARGING_PLUGGED_USB |2 |表示这个触发条件是USB充连接。| - |CHARGING_PLUGGED_WIRELESS |3| 表示这个触发条件是无线充电器连接。| +| 名称 | 默认值 | 说明 | +| ------------------------- | ---- | -------------------- | +| CHARGING_PLUGGED_ANY | 0 | 表示这个触发条件是任何类型的充电器连接。 | +| CHARGING_PLUGGED_AC | 1 | 表示这个触发条件是直流充电器连接。 | +| CHARGING_PLUGGED_USB | 2 | 表示这个触发条件是USB充连接。 | +| CHARGING_PLUGGED_WIRELESS | 3 | 表示这个触发条件是无线充电器连接。 | ## BatteryStatus 触发工作的电池状态。 **系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.WorkScheduler - |名称 |默认值 |说明| - | -------- | -------- | -------- | - |BATTERY_STATUS_LOW |0 |表示这个触发条件是低电告警。| - |BATTERY_STATUS_OKAY |1| 表示这个触发条件是从低电恢复到正常电量。| - |BATTERY_STATUS_LOW_OR_OKAY |2 |表示这个触发条件是从低电恢复到正常电量或者低电告警。| +| 名称 | 默认值 | 说明 | +| -------------------------- | ---- | -------------------------- | +| BATTERY_STATUS_LOW | 0 | 表示这个触发条件是低电告警。 | +| BATTERY_STATUS_OKAY | 1 | 表示这个触发条件是从低电恢复到正常电量。 | +| BATTERY_STATUS_LOW_OR_OKAY | 2 | 表示这个触发条件是从低电恢复到正常电量或者低电告警。 | ## StorageRequest 触发工作的存储状态。 diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index 0165dc8046718a4a63f1b9d20c75f0f5cef89151..ac9ec7248172d57d474d1476e9f636abad9b1a90 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -64,6 +64,7 @@ - [QRCode](ts-basic-components-qrcode.md) - [Radio](ts-basic-components-radio.md) - [Rating](ts-basic-components-rating.md) + - [Search](ts-basic-components-search.md) - [Select](ts-basic-components-select.md) - [Slider](ts-basic-components-slider.md) - [Span](ts-basic-components-span.md) @@ -76,6 +77,7 @@ - [Toggle](ts-basic-components-toggle.md) - [TextClock](ts-basic-components-textclock.md) - [Web](ts-basic-components-web.md) + - [RichText](ts-basic-components-richtext.md) - [Xcomponent](ts-basic-components-xcomponent.md) - [PluginComponent](ts-basic-components-plugincomponent.md) - 容器组件 diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/sidebarcontainer.png b/zh-cn/application-dev/reference/arkui-ts/figures/sidebarcontainer.png new file mode 100644 index 0000000000000000000000000000000000000000..1cbb01859041e2028d76b49db655148cf4eb3062 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/sidebarcontainer.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md new file mode 100644 index 0000000000000000000000000000000000000000..826d85d4747535195472b3a81321a3bbe7bd547a --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md @@ -0,0 +1,101 @@ +# Search + +> ![](public_sys-resources/icon-note.gif) **说明:** 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +提供搜索框组件,用于提供用户搜索内容的输入区域。 + +## 权限列表 + +无 + +## 子组件 + +无 + +## 接口 + +Search(options?: { value?: string; placeholder?: string; icon?: string; controller?: SearchController }) + +- 参数 + + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | -------- | -------- | -------- | -------- | -------- | + | value | string | 否 | - | 搜索文本值。 | + | placeholder | string | 否 | - | 无输入时的提示文本。| + | icon | string | 否 | - | 搜索图标路径,默认使用系统搜索图标,支持的图标格式: svg, jpg和png。 | + | controller | SearchController | 否 | - | 控制器。| + + +## 属性 + +| 名称 | 参数类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| searchButton | string | 无 | 搜索框末尾搜索按钮文本值,默认无搜索按钮。| +| placeholderColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | 设置placeholder颜色。| +| placeholderFont | [Font](../../ui/ts-types.md#Font) | - | 设置placeholder文本样式。| +| textFont | [Font](../../ui/ts-types.md#Font) | - | 设置搜索框内文本样式。| + +## 事件 + +| 名称 | 功能描述 | +| -------- | -------- | +| onSubmit(callback: (value: string) => void) | 点击搜索图标、搜索按钮或者按下软键盘搜索按钮时触发。
-value: 当前输入文本框的内容。| +| onChange(callback: (value: string) => void) | 输入内容发生变化时,触发回调。
-value: 当前输入文本框的内容。| +| onCopy(callback: (value: string) => void) | 组件触发系统剪切板复制操作。
-value: 复制的文本内容。| +| onCut(callback: (value: string) => void) | 组件触发系统剪切板剪切操作。
-value: 剪切的文本内容。| +| onPaste(callback: (value: string) => void) | 组件触发系统剪切板粘贴操作。
-value: 粘贴的文本内容。| + +## SearchController + +Search组件的控制器,通过它操作Search组件。 + +#### 导入对象 +``` +controller: SearchController = new SearchController() +``` +#### caretPosition + +creatPosition(value: number): viod + +设置输入光标的位置。 + +- 参数 + + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | ---- | ------ | ---- | ---- | --------------------- | + | value | number | 是 | - | 从字符串开始到光标所在位置的长度。 | + + + +## 示例 + +``` +@Entry +@Component +struct SearchExample { + @State changevalue: string = '' + @State submitvalue: string = '' + controller: SearchController = new SearchController() + + build() { + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text(this.submitvalue) + Text(this.changevalue) + Search({value: '', placeholder: 'Type to search', controller: this.controller}) + .searchButton('Search') + .width(400) + .height(35) + .backgroundColor(Color.White) + .placeholderColor(Color.Grey) + .placeholderFont({ size: 50, weight: 10, family: 'serif', style: FontStyle.Normal }) + .onSubmit((value: string) => { + this.submitvalue = value + }) + .onChange((value: string) => { + this.changevalue = value + }) + .margin({ top: 30 }) + } + } +} +``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index d3f5d40f7d5787bb830f89ee4a82d57e67ff2072..b9c0fbfb166fab6f2c22f60630af11cda0a18a40 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -4,7 +4,7 @@ > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -侧边栏容器,分为侧边栏和内容区两部分,可单独添加子组件。 +提供侧边栏可以显示和隐藏的侧边栏容器,通过子组件定义侧边栏和内容区,第一个子组件表示侧边栏,第二个子组件表示内容区。 ## 权限列表 @@ -14,10 +14,7 @@ ## 子组件 -可以包含两个子组件。 -> ![](../../public_sys-resources/icon-note.gif) **说明:** -> 第一个子组件的类型必须为[Column](ts-container-column.md),表示侧边栏,第二个子组件的类型必须为[RowSplit](ts-container-rowsplit.md),表示内容区。 - +可以包含子组件。 ## 接口 @@ -42,18 +39,18 @@ SideBarContainer( type?: SideBarContainerType ) | showSideBar | boolean | true | 设置是否显示侧边栏。 | | controlButton | ButtonStyle | - | 设置侧边栏控制按钮的属性。 | | showControlButton | boolean | true | 设置是否显示控制按钮。 | -| sidebarWidth | number | 200vp | 设置侧边栏的宽度。 | -| minSideBarWidth | number | 200vp | 设置侧边栏最小宽度。 | -| maxSideBarWidth | number | 280vp | 设置侧边栏最大宽度。 | +| sideBarWidth | number | 200 | 设置侧边栏的宽度。 | +| minSideBarWidth | number | 200 | 设置侧边栏最小宽度。 | +| maxSideBarWidth | number | 280 | 设置侧边栏最大宽度。 | - ButtonStyle对象说明 | 名称 | 参数类型 | 必填 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -------- | - | left | number | 否 | 16vp | 设置侧边栏控制按钮距离容器左界限的间距。 | - | top | number | 否 | 48vp | 设置侧边栏控制按钮距离容器上界限的间距。 | - | width | number | 否 | 32vp | 设置侧边栏控制按钮的宽度。 | - | height | number | 否 | 32vp | 设置侧边栏控制按钮的高度。 | - | icons | {
shown: string \| PixelMap \| [Resource](../../ui/ts-types.md#resource类型) ,
hidden: string \| PixelMap \| [Resource](../../ui/ts-types.md#resource类型) ,
switching?: string \| PixelMap \| [Resource](../../ui/ts-types.md#resource类型)
} | 否 | - | 设置侧边栏控制按钮的图标:

- shown: 设置侧边栏显示时控制按钮的图标。
- hidden: 设置侧边栏隐藏时控制按钮的图标。
- switching:设置侧边栏显示和隐藏状态切换时控制按钮的图标。 | + | left | number | 否 | 16 | 设置侧边栏控制按钮距离容器左界限的间距。 | + | top | number | 否 | 48 | 设置侧边栏控制按钮距离容器上界限的间距。 | + | width | number | 否 | 32 | 设置侧边栏控制按钮的宽度。 | + | height | number | 否 | 32 | 设置侧边栏控制按钮的高度。 | + | icons | {
shown: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,
hidden: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,
switching?: string \| PixelMap \| [Resource](../../ui/ts-types.md)
} | 否 | - | 设置侧边栏控制按钮的图标:

- shown: 设置侧边栏显示时控制按钮的图标。
- hidden: 设置侧边栏隐藏时控制按钮的图标。
- switching:设置侧边栏显示和隐藏状态切换时控制按钮的图标。 | @@ -113,4 +110,5 @@ struct SideBarContainerExample { } } ``` - + +![](figures/sidebarcontainer.png) diff --git a/zh-cn/application-dev/ui/Readme-CN.md b/zh-cn/application-dev/ui/Readme-CN.md index 7b70cf8f8248b4ef6ae19cb09d11c4c3e569869a..db0a9882d7e26f3bdd28ee9ff980983bdaff7ef3 100755 --- a/zh-cn/application-dev/ui/Readme-CN.md +++ b/zh-cn/application-dev/ui/Readme-CN.md @@ -27,21 +27,45 @@ - [事件](ui-js-building-ui-event.md) - [页面路由](ui-js-building-ui-routes.md) - 常见组件开发指导 - - [Text](ui-js-components-text.md) - - [Input](ui-js-components-input.md) - - [Button](ui-js-components-button.md) - - [List](ui-js-components-list.md) - - [Picker](ui-js-components-picker.md) - - [Dialog](ui-js-components-dialog.md) - - [Form](ui-js-components-form.md) - - [Stepper](ui-js-components-stepper.md) - - [Tabs](ui-js-component-tabs.md) - - [Image](ui-js-components-images.md) + - 容器组件 + - [List开发指导](ui-js-components-list.md) + - [Dialog开发指导](ui-js-components-dialog.md) + - [Form开发指导](ui-js-components-form.md) + - [Stepper开发指导](ui-js-components-stepper.md) + - [Tabs开发指导](ui-js-component-tabs.md) + - [Swiper开发指导](ui-js-components-swiper.md) + - 基础组件 + - [Text开发指导](ui-js-components-text.md) + - [Input开发指导](ui-js-components-input.md) + - [Button开发指导](ui-js-components-button.md) + - [Picker开发指导](ui-js-components-picker.md) + - [Image开发指导](ui-js-components-images.md) + - [Image-animator开发指导](ui-js-components-image-animator.md) + - [Rating开发指导](ui-js-components-rating.md) + - [Slider开发指导](ui-js-components-slider.md) + - [Chart开发指导](ui-js-components-chart.md) + - [Switch开发指导](ui-js-components-switch.md) + - [Toolbar开发指导](ui-js-components-toolbar.md) + - [Menu开发指导](ui-js-components-menu.md) + - [Marquee开发指导](ui-js-components-marquee.md) + - [Qrcode开发指导](ui-js-components-qrcode.md) + - [Search开发指导](ui-js-components-search.md) + - Canvas开发指导 + - [CanvasRenderingContext2D对象](ui-js-components-canvasrenderingcontext2d.md) + - [Path2D对象](ui-js-components-path2d.md) + - [OffscreenCanvas对象](ui-js-components-offscreencanvas.md) + - [栅格布局](ui-js-components-calendar.md) + - Svg开发指导 + - [基础知识](ui-js-components-svg-overview.md) + - [绘制图形](ui-js-components-svg-graphics.md) + - [绘制路径](ui-js-components-svg-path.md) + - [绘制文本](ui-js-components-svg-text.md) - 动效开发指导 - CSS动画 - [属性样式动画](ui-js-animate-attribute-style.md) - [transform样式动画](ui-js-animate-transform.md) - [background-position样式动画](ui-js-animate-background-position-style.md) + - [svg动画](ui-js-animate-svg.md) - JS动画 - [组件动画](ui-js-animate-component.md) - 插值器动画 diff --git a/zh-cn/application-dev/webgl/webgl-guidelines.md b/zh-cn/application-dev/webgl/webgl-guidelines.md index 6495b6aeb122781b25d4fdeb25e41327399c43bd..48e4c98715f74acb9729f37f7cadbefe94182b5d 100644 --- a/zh-cn/application-dev/webgl/webgl-guidelines.md +++ b/zh-cn/application-dev/webgl/webgl-guidelines.md @@ -7,12 +7,6 @@ WebGL主要帮助开发者在前端开发中完成图形图像的相关处理, ## 接口说明 -使用WebGL开放能力需导入模块: - -``` -import webgl from "@ohos.webglnapi"; -``` - **表1** WebGL主要接口列表 | 接口名 | 描述 | @@ -142,7 +136,6 @@ import webgl from "@ohos.webglnapi"; 3. 编辑JavaScript代码文件,增加彩色三角形绘制逻辑代码。index.js示例如下: ``` //index.js - import webgl from "@ohos.webglnapi";//导入WebGL模块 //WebGL相关预定义 var gl = { diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md new file mode 100644 index 0000000000000000000000000000000000000000..207bf47591d88f88ddf0a5f7fe0d3ee0a6f174e2 --- /dev/null +++ b/zh-cn/application-dev/website.md @@ -0,0 +1,643 @@ +- [应用开发导读](application-dev-guide.md) +- 快速开始 + - 应用开发快速入门 + - DevEco Studio(OpenHarmony)使用指南 + - [概述](quick-start/deveco-studio-overview.md) + - [版本变更说明](quick-start/deveco-studio-release-notes.md) + - [配置OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) + - 创建OpenHarmony工程 + - [使用工程向导创建新工程](quick-start/use-wizard-to-create-project.md) + - [通过导入Sample方式创建新工程](quick-start/import-sample-to-create-project.md) + - [配置OpenHarmony应用签名信息](quick-start/configuring-openharmony-app-signature.md) + - [安装运行OpenHarmony应用](quick-start/installing-openharmony-app.md) + - 快速入门 + - [前言](quick-start/start-overview.md) + - [使用eTS语言开发](quick-start/start-with-ets.md) + - [使用JS语言开发(传统代码方式)](quick-start/start-with-js.md) + - [使用JS语言开发(低代码方式)](quick-start/start-with-js-low-code.md) + - [应用开发包结构说明](quick-start/package-structure.md) + - [资源文件的分类](quick-start/basic-resource-file-categories.md) +- 开发 + - [Ability开发](ability/Readme-CN.md) + - [Ability框架概述](ability/ability-brief.md) + - FA模型 + - [FA模型综述](ability/fa-brief.md) + - [PageAbility开发指导](ability/fa-pageability.md) + - [ServiceAbility开发指导](ability/fa-serviceability.md) + - [DataAbility开发指导](ability/fa-dataability.md) + - [FormAbility开发指导](ability/fa-formability.md) + - Stage模型 + - [Stage模型综述](ability/stage-brief.md) + - [Ability开发指导](ability/stage-ability.md) + - [ServiceExtensionAbility开发指导](ability/stage-serviceextension.md) + - [FormExtensionAbility开发指导](ability/stage-formextension.md) + - [应用迁移开发指导](ability/stage-ability-continuation.md) + - 其他 + - [WantAgent使用指导](ability/wantagent.md) + - [Ability助手使用指导](ability/ability-assistant-guidelines.md) + - [UI开发](ui/Readme-CN.md) + - [方舟开发框架(ArkUI)概述](ui/arkui-overview.md) + - 基于JS扩展的类Web开发范式 + - [概述](ui/ui-js-overview.md) + - 框架说明 + - [文件组织](ui/js-framework-file.md) + - [js标签配置](ui/js-framework-js-tag.md) + - [app.js](ui/js-framework-js-file.md) + - 语法 + - [HML语法参考](ui/js-framework-syntax-hml.md) + - [CSS语法参考](ui/js-framework-syntax-css.md) + - [JS语法参考](ui/js-framework-syntax-js.md) + - [生命周期](ui/js-framework-lifecycle.md) + - [资源限定与访问](ui/js-framework-resource-restriction.md) + - [多语言支持](ui/js-framework-multiple-languages.md) + - 构建用户界面 + - [组件介绍](ui/ui-js-building-ui-component.md) + - 构建布局 + - [布局说明](ui/ui-js-building-ui-layout-intro.md) + - [添加标题行和文本区域](ui/ui-js-building-ui-layout-text.md) + - [添加图片区域](ui/ui-js-building-ui-layout-image.md) + - [添加留言区域](ui/ui-js-building-ui-layout-comment.md) + - [添加容器](ui/ui-js-building-ui-layout-external-container.md) + - [添加交互](ui/ui-js-building-ui-interactions.md) + - [动画](ui/ui-js-building-ui-animation.md) + - [事件](ui/ui-js-building-ui-event.md) + - [页面路由](ui/ui-js-building-ui-routes.md) + - 常见组件开发指导 + - 容器组件 + - [List开发指导](ui/ui-js-components-list.md) + - [Dialog开发指导](ui/ui-js-components-dialog.md) + - [Form开发指导](ui/ui-js-components-form.md) + - [Stepper开发指导](ui/ui-js-components-stepper.md) + - [Tabs开发指导](ui/ui-js-component-tabs.md) + - [Swiper开发指导](ui/ui-js-components-swiper.md) + - 基础组件 + - [Text开发指导](ui/ui-js-components-text.md) + - [Input开发指导](ui/ui-js-components-input.md) + - [Button开发指导](ui/ui-js-components-button.md) + - [Picker开发指导](ui/ui-js-components-picker.md) + - [Image开发指导](ui/ui-js-components-images.md) + - [Image-animator开发指导](ui/ui-js-components-image-animator.md) + - [Rating开发指导](ui/ui-js-components-rating.md) + - [Slider开发指导](ui/ui-js-components-slider.md) + - [Chart开发指导](ui/ui-js-components-chart.md) + - [Switch开发指导](ui/ui-js-components-switch.md) + - [Toolbar开发指导](ui/ui-js-components-toolbar.md) + - [Menu开发指导](ui/ui-js-components-menu.md) + - [Marquee开发指导](ui/ui-js-components-marquee.md) + - [Qrcode开发指导](ui/ui-js-components-qrcode.md) + - [Search开发指导](ui/ui-js-components-search.md) + - Canvas开发指导 + - [CanvasRenderingContext2D对象](ui/ui-js-components-canvasrenderingcontext2d.md) + - [Path2D对象](ui/ui-js-components-path2d.md) + - [OffscreenCanvas对象](ui/ui-js-components-offscreencanvas.md) + - [栅格布局](ui/ui-js-components-calendar.md) + - Svg开发指导 + - [基础知识](ui/ui-js-components-svg-overview.md) + - [绘制图形](ui/ui-js-components-svg-graphics.md) + - [绘制路径](ui/ui-js-components-svg-path.md) + - [绘制文本](ui/ui-js-components-svg-text.md) + - 动效开发指导 + - CSS动画 + - [属性样式动画](ui/ui-js-animate-attribute-style.md) + - [transform样式动画](ui/ui-js-animate-transform.md) + - [background-position样式动画](ui/ui-js-animate-background-position-style.md) + - [svg动画](ui/ui-js-animate-svg.md) + - JS动画 + - [组件动画](ui/ui-js-animate-component.md) + - 插值器动画 + - [动画动效](ui/ui-js-animate-dynamic-effects.md) + - [动画帧](ui/ui-js-animate-frame.md) + - [自定义组件](ui/ui-js-custom-components.md) + - 基于TS扩展的声明式开发范式 + - [概述](ui/ui-ts-overview.md) + - 框架说明 + - 文件组织 + - [目录结构](ui/ts-framework-directory.md) + - [应用代码文件访问规则](ui/ts-framework-file-access-rules.md) + - [js标签配置](ui/ts-framework-js-tag.md) + - 资源访问 + - [媒体资源类型说明](ui/ts-media-resource-type.md) + - [像素单位](ui/ts-pixel-units.md) + - [类型定义](ui/ts-types.md) + - 声明式语法 + - [描述规范使用说明](ui/ts-syntax-intro.md) + - 通用UI描述规范 + - [基本概念](ui/ts-general-ui-concepts.md) + - 声明式UI描述规范 + - [无构造参数配置](ui/ts-parameterless-configuration.md) + - [必选参数构造配置](ui/ts-configuration-with-mandatory-parameters.md) + - [属性配置](ui/ts-attribution-configuration.md) + - [事件配置](ui/ts-event-configuration.md) + - [子组件配置](ui/ts-child-component-configuration.md) + - 组件化 + - [@Component](ui/ts-component-based-component.md) + - [@Entry](ui/ts-component-based-entry.md) + - [@Preview](ui/ts-component-based-preview.md) + - [@Builder](ui/ts-component-based-builder.md) + - [@Extend](ui/ts-component-based-extend.md) + - [@CustomDialog](ui/ts-component-based-customdialog.md) + - [@Styles](ui/ts-component-based-styles.md) + - UI状态管理 + - [基本概念](ui/ts-ui-state-mgmt-concepts.md) + - 管理组件拥有的状态 + - [@State](ui/ts-component-states-state.md) + - [@Prop](ui/ts-component-states-prop.md) + - [@Link](ui/ts-component-states-link.md) + - 管理应用程序的状态 + - [应用程序的数据存储](ui/ts-application-states-appstorage.md) + - [持久化数据管理](ui/ts-application-states-apis-persistentstorage.md) + - [环境变量](ui/ts-application-states-apis-environment.md) + - 其他类目的状态管理 + - [Observed和ObjectLink数据管理](ui/ts-other-states-observed-objectlink.md) + - [@Consume和@Provide数据管理](ui/ts-other-states-consume-provide.md) + - [@Watch](ui/ts-other-states-watch.md) + - 渲染控制语法 + - [条件渲染](ui/ts-rending-control-syntax-if-else.md) + - [循环渲染](ui/ts-rending-control-syntax-foreach.md) + - [数据懒加载](ui/ts-rending-control-syntax-lazyforeach.md) + - 深入理解组件化 + - [build函数](ui/ts-function-build.md) + - [自定义组件初始化](ui/ts-custom-component-initialization.md) + - [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md) + - [组件创建和重新初始化示例](ui/ts-component-creation-re-initialization.md) + - [语法糖](ui/ts-syntactic-sugar.md) + - 体验声明式UI + - [创建声明式UI工程](ui/ui-ts-creating-project.md) + - [初识Component](ui/ui-ts-components.md) + - [创建简单视图](ui/ui-ts-creating-simple-page.md) + - 页面布局与连接 + - [构建食物数据模型](ui/ui-ts-building-data-model.md) + - [构建食物列表List布局](ui/ui-ts-building-category-list-layout.md) + - [构建食物分类Grid布局](ui/ui-ts-building-category-grid-layout.md) + - [页面跳转与数据传递](ui/ui-ts-page-redirection-data-transmission.md) + - 基础功能开发 + - 窗口管理 + - 窗口 + - [窗口开发概述](windowmanager/window-overview.md) + - [窗口开发指导](windowmanager/window-guidelines.md) + - 显示设备 + - [屏幕属性开发概述](windowmanager/display-overview.md) + - [屏幕属性开发指导](windowmanager/display-guidelines.md) + - 屏幕截图 + - [屏幕截图开发概述](windowmanager/screenshot-overview.md) + - [屏幕截图开发指导](windowmanager/screenshot-guidelines.md) + - WebGL + - [概述](webgl/webgl-overview.md) + - [WebGL开发指导](webgl/webgl-guidelines.md) + - 媒体 + - 音频 + - [音频开发概述](media/audio-overview.md) + - [音频播放开发指导](media/audio-playback.md) + - [音频录制开发指导](media/audio-recorder.md) + - [音频渲染开发指导](media/audio-renderer.md) + - [音频采集开发指导](media/audio-capturer.md) + - 视频 + - [视频播放开发指导](media/video-playback.md) + - [视频录制开发指导](media/video-recorder.md) + - 图片 + - [图片开发指导](media/image.md) + - 安全 + - 用户认证 + - [用户认证开发概述](security/userauth-overview.md) + - [用户认证开发指导](security/userauth-guidelines.md) + - 密钥管理 + - [HUKS开发概述](security/huks-overview.md) + - [HUKS开发指导](security/huks-guidelines.md) + - Hap包签名工具 + - [Hap包签名工具开发指导](security/hapsigntool-guidelines.md) + - 访问控制 + - [访问控制开发概述](security/accesstoken-overview.md) + - [访问控制开发指导](security/accesstoken-guidelines.md) + - 网络与连接 + - IPC与RPC通信 + - [IPC与RPC通信概述](connectivity/ipc-rpc-overview.md) + - [IPC与RPC通信开发指导](connectivity/ipc-rpc-development-guideline.md) + - [远端状态订阅开发实例](connectivity/subscribe-remote-state.md) + - 数据管理 + - 分布式数据服务 + - [分布式数据服务概述](database/database-mdds-overview.md) + - [分布式数据服务开发指导](database/database-mdds-guidelines.md) + - 关系型数据库 + - [关系型数据库概述](database/database-relational-overview.md) + - [关系型数据库开发指导](database/database-relational-guidelines.md) + - 轻量级数据存储 + - [轻量级数据存储概述](database/database-preference-overview.md) + - [轻量级数据存储开发指导](database/database-preference-guidelines.md) + - 分布式数据对象 + - [分布式数据对象概述](database/database-distributedobject-overview.md) + - [分布式数据对象开发指导](database/database-distributedobject-guidelines.md) + - 后台代理提醒 + - [概述](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) + - [开发指导](background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md) + - 后台任务管理 + - 后台任务 + - [后台任务概述](background-task-management/background-task-overview.md) + - [后台任务开发指导](background-task-management/background-task-dev-guide.md) + - 设备管理 + - USB服务 + - [USB服务开发概述](device/usb-overview.md) + - [USB服务开发指导](device/usb-guidelines.md) + - 位置 + - [位置开发概述](device/device-location-overview.md) + - [获取设备的位置信息](device/device-location-info.md) + - [(逆)地理编码转化](device/device-location-geocoding.md) + - 传感器 + - [传感器开发概述](device/sensor-overview.md) + - [传感器开发指导](device/sensor-guidelines.md) + - 振动 + - [振动开发概述](device/vibrator-guidelines.md) + - [振动开发指导](device/vibrator-guidelines.md) + - 设备使用信息统计 + - [设备使用信息统计概述](device-usage-statistics/device-usage-statistics-overview.md) + - [设备使用信息统计开发指导](device-usage-statistics/device-usage-statistics-dev-guide.md) + - DFX + - 应用事件打点 + - [应用事件打点概述](dfx/hiappevent-overview.md) + - [应用事件打点开发指导](dfx/hiappevent-guidelines.md) + - 性能打点跟踪 + - [性能打点跟踪概述](dfx/hitracemeter-overview.md) + - [性能打点跟踪开发指导](dfx/hitracemeter-guidelines.md) + - 分布式跟踪 + - [分布式跟踪概述](dfx/hitracechain-overview.md) + - [分布式跟踪开发指导](dfx/hitracechain-guidelines.md) + - 国际化 + - [国际化开发概述](internationalization/international-overview.md) + - [Intl开发指导](internationalization/intl-guidelines.md) + - [I18n开发指导](internationalization/i18n-guidelines.md) +- 工具 + - DevEco Studio(OpenHarmony)使用指南 + - [概述](quick-start/deveco-studio-overview.md) + - [版本变更说明](quick-start/deveco-studio-release-notes.md) + - [配置OpenHarmony SDK](quick-start/configuring-openharmony-sdk.md) + - [创建OpenHarmony工程](quick-start/create-openharmony-project.md) + - [配置OpenHarmony应用签名信息](quick-start/configuring-openharmony-app-signature.md) + - [安装运行OpenHarmony应用](quick-start/installing-openharmony-app.md) +- 示例教程 + - [示例代码](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md) + - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) +- API参考 + - 组件参考(基于JS扩展的类Web开发范式) + - 组件 + - 通用 + - [通用属性](reference/arkui-js/js-components-common-attributes.md) + - [通用样式](reference/arkui-js/js-components-common-styles.md) + - [通用事件](reference/arkui-js/js-components-common-events.md) + - [通用方法](reference/arkui-js/js-components-common-methods.md) + - [动画样式](reference/arkui-js/js-components-common-animation.md) + - [渐变样式](reference/arkui-js/js-components-common-gradient.md) + - [转场样式](reference/arkui-js/js-components-common-transition.md) + - [自定义字体样式](reference/arkui-js/js-components-common-customizing-font.md) + - [原子布局](reference/arkui-js/js-components-common-atomic-layout.md) + - 容器组件 + - [badge](reference/arkui-js/js-components-container-badge.md) + - [dialog](reference/arkui-js/js-components-container-dialog.md) + - [div](reference/arkui-js/js-components-container-div.md) + - [form](reference/arkui-js/js-components-container-form.md) + - [list](reference/arkui-js/js-components-container-list.md) + - [list-item](reference/arkui-js/js-components-container-list-item.md) + - [list-item-group](reference/arkui-js/js-components-container-list-item-group.md) + - [panel](reference/arkui-js/js-components-container-panel.md) + - [popup](reference/arkui-js/js-components-container-popup.md) + - [refresh](reference/arkui-js/js-components-container-refresh.md) + - [stack](reference/arkui-js/js-components-container-stack.md) + - [stepper](reference/arkui-js/js-components-container-stepper.md) + - [stepper-item](reference/arkui-js/js-components-container-stepper-item.md) + - [swiper](reference/arkui-js/js-components-container-swiper.md) + - [tabs](reference/arkui-js/js-components-container-tabs.md) + - [tab-bar](reference/arkui-js/js-components-container-tab-bar.md) + - [tab-content](reference/arkui-js/js-components-container-tab-content.md) + - 基础组件 + - [button](reference/arkui-js/js-components-basic-button.md) + - [chart](reference/arkui-js/js-components-basic-chart.md) + - [divider](reference/arkui-js/js-components-basic-divider.md) + - [image](reference/arkui-js/js-components-basic-image.md) + - [image-animator](reference/arkui-js/js-components-basic-image-animator.md) + - [input](reference/arkui-js/js-components-basic-input.md) + - [label](reference/arkui-js/js-components-basic-label.md) + - [marquee](reference/arkui-js/js-components-basic-marquee.md) + - [menu](reference/arkui-js/js-components-basic-menu.md) + - [option](reference/arkui-js/js-components-basic-option.md) + - [picker](reference/arkui-js/js-components-basic-picker.md) + - [picker-view](reference/arkui-js/js-components-basic-picker-view.md) + - [piece](reference/arkui-js/js-components-basic-piece.md) + - [progress](reference/arkui-js/js-components-basic-progress.md) + - [qrcode](reference/arkui-js/js-components-basic-qrcode.md) + - [rating](reference/arkui-js/js-components-basic-rating.md) + - [richtext](reference/arkui-js/js-components-basic-richtext.md) + - [search](reference/arkui-js/js-components-basic-search.md) + - [select](reference/arkui-js/js-components-basic-select.md) + - [slider](reference/arkui-js/js-components-basic-slider.md) + - [span](reference/arkui-js/js-components-basic-span.md) + - [switch](reference/arkui-js/js-components-basic-switch.md) + - [text](reference/arkui-js/js-components-basic-text.md) + - [textarea](reference/arkui-js/js-components-basic-textarea.md) + - [toolbar](reference/arkui-js/js-components-basic-toolbar.md) + - [toolbar-item](reference/arkui-js/js-components-basic-toolbar-item.md) + - [toggle](reference/arkui-js/js-components-basic-toggle.md) + - [web](reference/arkui-js/js-components-basic-web.md) + - 媒体组件 + - [video](reference/arkui-js/js-components-media-video.md) + - 画布组件 + - [canvas组件](reference/arkui-js/js-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) + - [Image对象](reference/arkui-js/js-components-canvas-image.md) + - [CanvasGradient对象](reference/arkui-js/js-components-canvas-canvasgradient.md) + - [ImageData对象](reference/arkui-js/js-components-canvas-imagedata.md) + - [Path2D对象](reference/arkui-js/js-components-canvas-path2d.md) + - [ImageBitmap对象](reference/arkui-js/js-components-canvas-imagebitmap.md) + - [OffscreenCanvas对象](reference/arkui-js/js-components-canvas-offscreencanvas.md) + - [OffscreenCanvasRenderingContext2D对象](reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) + - 栅格组件 + - [基本概念](reference/arkui-js/js-components-grid-basic-concepts.md) + - [grid-container](reference/arkui-js/js-components-grid-container.md) + - [grid-row](reference/arkui-js/js-components-grid-row.md) + - [grid-col](reference/arkui-js/js-components-grid-col.md) + - svg组件 + - [通用属性](reference/arkui-js/js-components-svg-common-attributes.md) + - [svg](reference/arkui-js/js-components-svg.md) + - [rect](reference/arkui-js/js-components-svg-rect.md) + - [circle](reference/arkui-js/js-components-svg-circle.md) + - [ellipse](reference/arkui-js/js-components-svg-ellipse.md) + - [path](reference/arkui-js/js-components-svg-path.md) + - [line](reference/arkui-js/js-components-svg-line.md) + - [polyline](reference/arkui-js/js-components-svg-polyline.md) + - [polygon](reference/arkui-js/js-components-svg-polygon.md) + - [text](reference/arkui-js/js-components-svg-text.md) + - [tspan](reference/arkui-js/js-components-svg-tspan.md) + - [textPath](reference/arkui-js/js-components-svg-textpath.md) + - [animate](reference/arkui-js/js-components-svg-animate.md) + - [animateMotion](reference/arkui-js/js-components-svg-animatemotion.md) + - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) + - 自定义组件 + - [基本用法](reference/arkui-js/js-components-custom-basic-usage.md) + - [自定义事件](reference/arkui-js/js-components-custom-events.md) + - [Props](reference/arkui-js/js-components-custom-props.md) + - [事件参数](reference/arkui-js/js-components-custom-event-parameter.md) + - [slot插槽](reference/arkui-js/js-components-custom-slot.md) + - [生命周期定义](reference/arkui-js/js-components-custom-lifecycle.md) + - 附录 + - [类型说明](reference/arkui-js/js-appendix-types.md) + - 组件参考(基于TS扩展的声明式开发范式) + - 组件 + - 通用 + - 通用事件 + - [点击事件](reference/arkui-ts/ts-universal-events-click.md) + - [触摸事件](reference/arkui-ts/ts-universal-events-touch.md) + - [挂载卸载事件](reference/arkui-ts/ts-universal-events-show-hide.md) + - [拖拽事件](reference/arkui-ts/ts-universal-events-drag-drop.md) + - [按键事件](reference/arkui-ts/ts-universal-events-key.md) + - [焦点事件](reference/arkui-ts/ts-universal-focus-event.md) + - [鼠标事件](reference/arkui-ts/ts-universal-mouse-key.md) + - [组件区域变化事件](reference/arkui-ts/ts-universal-component-area-change-event.md) + - 通用属性 + - [尺寸设置](reference/arkui-ts/ts-universal-attributes-size.md) + - [位置设置](reference/arkui-ts/ts-universal-attributes-location.md) + - [布局约束](reference/arkui-ts/ts-universal-attributes-layout-constraints.md) + - [Flex布局](reference/arkui-ts/ts-universal-attributes-flex-layout.md) + - [边框设置](reference/arkui-ts/ts-universal-attributes-border.md) + - [背景设置](reference/arkui-ts/ts-universal-attributes-background.md) + - [透明度设置](reference/arkui-ts/ts-universal-attributes-opacity.md) + - [显隐控制](reference/arkui-ts/ts-universal-attributes-visibility.md) + - [禁用控制](reference/arkui-ts/ts-universal-attributes-enable.md) + - [浮层](reference/arkui-ts/ts-universal-attributes-overlay.md) + - [Z序控制](reference/arkui-ts/ts-universal-attributes-z-order.md) + - [图形变换](reference/arkui-ts/ts-universal-attributes-transformation.md) + - [图像效果](reference/arkui-ts/ts-universal-attributes-image-effect.md) + - [形状裁剪](reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) + - [文本样式设置](reference/arkui-ts/ts-universal-attributes-text-style.md) + - [栅格设置](reference/arkui-ts/ts-universal-attributes-grid.md) + - [颜色渐变](reference/arkui-ts/ts-universal-attributes-gradient-color.md) + - [Popup控制](reference/arkui-ts/ts-universal-attributes-popup.md) + - [Menu控制](reference/arkui-ts/ts-universal-attributes-menu.md) + - [点击控制](reference/arkui-ts/ts-universal-attributes-click.md) + - [焦点控制](reference/arkui-ts/ts-universal-attributes-focus.md) + - [悬浮态效果](reference/arkui-ts/ts-universal-attributes-hover-effect.md) + - [组件标识](reference/arkui-ts/ts-universal-attributes-component-id.md) + - [触摸热区设置](reference/arkui-ts/ts-universal-attributes-touch-target.md) + - [多态样式](reference/arkui-ts/ts-universal-attributes-polymorphic-style.md) + - 手势处理 + - [绑定手势方法](reference/arkui-ts/ts-gesture-settings.md) + - 基础手势 + - [TapGesture](reference/arkui-ts/ts-basic-gestures-tapgesture.md) + - [LongPressGesture](reference/arkui-ts/ts-basic-gestures-longpressgesture.md) + - [PanGesture](reference/arkui-ts/ts-basic-gestures-pangesture.md) + - [PinchGesture](reference/arkui-ts/ts-basic-gestures-pinchgesture.md) + - [RotationGesture](reference/arkui-ts/ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](reference/arkui-ts/ts-basic-gestures-swipegesture.md) + - [组合手势](reference/arkui-ts/ts-combined-gestures.md) + - 基础组件 + - [Blank](reference/arkui-ts/ts-basic-components-blank.md) + - [Button](reference/arkui-ts/ts-basic-components-button.md) + - [Checkbox](reference/arkui-ts/ts-basic-components-checkbox.md) + - [CheckboxGroup](reference/arkui-ts/ts-basic-components-checkboxgroup.md) + - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) + - [DatePicker](reference/arkui-ts/ts-basic-components-datepicker.md) + - [Divider](reference/arkui-ts/ts-basic-components-divider.md) + - [Image](reference/arkui-ts/ts-basic-components-image.md) + - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) + - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) + - [Progress](reference/arkui-ts/ts-basic-components-progress.md) + - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) + - [Radio](reference/arkui-ts/ts-basic-components-radio.md) + - [Rating](reference/arkui-ts/ts-basic-components-rating.md) + - [Select](reference/arkui-ts/ts-basic-components-select.md) + - [Slider](reference/arkui-ts/ts-basic-components-slider.md) + - [Span](reference/arkui-ts/ts-basic-components-span.md) + - [Text](reference/arkui-ts/ts-basic-components-text.md) + - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) + - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) + - [TextPicker](reference/arkui-ts/ts-basic-components-textpicker.md) + - [TextTimer](reference/arkui-ts/ts-basic-components-texttimer.md) + - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) + - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) + - [Web](reference/arkui-ts/ts-basic-components-web.md) + - 容器组件 + - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) + - [Badge](reference/arkui-ts/ts-container-badge.md) + - [Column](reference/arkui-ts/ts-container-column.md) + - [ColumnSplit](reference/arkui-ts/ts-container-columnsplit.md) + - [Counter](reference/arkui-ts/ts-container-counter.md) + - [Flex](reference/arkui-ts/ts-container-flex.md) + - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) + - [Grid](reference/arkui-ts/ts-container-grid.md) + - [GridItem](reference/arkui-ts/ts-container-griditem.md) + - [List](reference/arkui-ts/ts-container-list.md) + - [ListItem](reference/arkui-ts/ts-container-listitem.md) + - [Navigator](reference/arkui-ts/ts-container-navigator.md) + - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) + - [Panel](reference/arkui-ts/ts-container-panel.md) + - [Row](reference/arkui-ts/ts-container-row.md) + - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) + - [Scroll](reference/arkui-ts/ts-container-scroll.md) + - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) + - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) + - [Stack](reference/arkui-ts/ts-container-stack.md) + - [Swiper](reference/arkui-ts/ts-container-swiper.md) + - [Tabs](reference/arkui-ts/ts-container-tabs.md) + - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) + - [Refresh](reference/arkui-ts/ts-container-refresh.md) + - 媒体组件 + - [Video](reference/arkui-ts/ts-media-components-video.md) + - 绘制组件 + - [Circle](reference/arkui-ts/ts-drawing-components-circle.md) + - [Ellipse](reference/arkui-ts/ts-drawing-components-ellipse.md) + - [Line](reference/arkui-ts/ts-drawing-components-line.md) + - [Polyline](reference/arkui-ts/ts-drawing-components-polyline.md) + - [Polygon](reference/arkui-ts/ts-drawing-components-polygon.md) + - [Path](reference/arkui-ts/ts-drawing-components-path.md) + - [Rect](reference/arkui-ts/ts-drawing-components-rect.md) + - [Shape](reference/arkui-ts/ts-drawing-components-shape.md) + - 画布组件 + - [Canvas](reference/arkui-ts/ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](reference/arkui-ts/ts-canvasrenderingcontext2d.md) + - [OffscreenCanvasRenderingConxt2D对象](reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md) + - [Lottie](reference/arkui-ts/ts-components-canvas-lottie.md) + - [Path2D对象](reference/arkui-ts/ts-components-canvas-path2d.md) + - [CanvasGradient对象](reference/arkui-ts/ts-components-canvas-canvasgradient.md) + - [ImageBitmap对象](reference/arkui-ts/ts-components-canvas-imagebitmap.md) + - [ImageData对象](reference/arkui-ts/ts-components-canvas-imagedata.md) + - 动画 + - [属性动画](reference/arkui-ts/ts-animatorproperty.md) + - [显式动画](reference/arkui-ts/ts-explicit-animation.md) + - 转场动画 + - [页面间转场](reference/arkui-ts/ts-page-transition-animation.md) + - [组件内转场](reference/arkui-ts/ts-transition-animation-component.md) + - [共享元素转场](reference/arkui-ts/ts-transition-animation-shared-elements.md) + - [路径动画](reference/arkui-ts/ts-motion-path-animation.md) + - [矩阵变换](reference/arkui-ts/ts-matrix-transformation.md) + - [插值计算](reference/arkui-ts/ts-interpolation-calculation.md) + - 全局UI方法 + - [图片缓存](reference/arkui-ts/ts-methods-image-cache.md) + - [媒体查询](reference/arkui-ts/ts-methods-media-query.md) + - 弹窗 + - [警告弹窗](reference/arkui-ts/ts-methods-alert-dialog-box.md) + - [列表选择弹窗](reference/arkui-ts/ts-methods-action-sheet.md) + - [自定义弹窗](reference/arkui-ts/ts-methods-custom-dialog-box.md) + - [日期时间选择弹窗](reference/arkui-ts/ts-methods-datepicker-dialog.md) + - [文本选择弹窗](reference/arkui-ts/ts-methods-textpicker-dialog.md) + - [菜单](reference/arkui-ts/ts-methods-menu.md) + - 附录 + - [文档中涉及到的内置枚举值](reference/arkui-ts/ts-appendix-enums.md) + - 接口参考 + - Ability框架 + - [FeatureAbility模块](reference/apis/js-apis-featureAbility.md) + - [ParticleAbility模块](reference/apis/js-apis-particleAbility.md) + - [DataAbilityHelper模块](reference/apis/js-apis-dataAbilityHelper.md) + - [DataUriUtils模块](reference/apis/js-apis-DataUriUtils.md) + - [Bundle模块](reference/apis/js-apis-Bundle.md) + - [Context模块](reference/apis/js-apis-Context.md) + - 事件与通知 + - [CommonEvent模块](reference/apis/js-apis-commonEvent.md) + - [Notification模块](reference/apis/js-apis-notification.md) + - [后台代理提醒](reference/apis/js-apis-reminderAgent.md) + - 资源管理 + - [资源管理](reference/apis/js-apis-resource-manager.md) + - [国际化-Intl](reference/apis/js-apis-intl.md) + - [国际化-I18n](reference/apis/js-apis-i18n.md) + - 媒体 + - [音频管理](reference/apis/js-apis-audio.md) + - [媒体服务](reference/apis/js-apis-media.md) + - [图片处理](reference/apis/js-apis-image.md) + - [相机管理](reference/apis/js-apis-camera.md) + - 安全 + - [用户认证](reference/apis/js-apis-useriam-userauth.md) + - [访问控制](reference/apis/js-apis-abilityAccessCtrl.md) + - [通用密钥库系统](reference/apis/js-apis-huks.md) + - 数据管理 + - [轻量级存储](reference/apis/js-apis-data-preferences.md) + - [分布式数据管理](reference/apis/js-apis-distributed-data.md) + - [关系型数据库](reference/apis/js-apis-data-rdb.md) + - [结果集](reference/apis/js-apis-data-resultset.md) + - [DataAbility 谓词](reference/apis/js-apis-data-ability.md) + - [设置数据项名称](reference/apis/js-apis-settings.md) + - 文件管理 + - [文件管理](reference/apis/js-apis-fileio.md) + - [Statfs](reference/apis/js-apis-statfs.md) + - [目录环境](reference/apis/js-apis-environment.md) + - [公共文件访问与管理](reference/apis/js-apis-filemanager.md) + - [应用空间统计](reference/apis/js-apis-storage-statistics.md) + - [卷管理](reference/apis/js-apis-volumemanager.md) + - 账号管理 + - [系统帐号管理](reference/apis/js-apis-osAccount.md) + - [分布式帐号管理](reference/apis/js-apis-distributed-account.md) + - [应用帐号管理](reference/apis/js-apis-appAccount.md) + - 电话服务 + - [拨打电话](reference/apis/js-apis-call.md) + - [短信服务](reference/apis/js-apis-sms.md) + - [SIM卡管理](reference/apis/js-apis-sim.md) + - [网络搜索](reference/apis/js-apis-radio.md) + - [observer](reference/apis/js-apis-observer.md) + - [蜂窝数据](reference/apis/js-apis-telephony-data.md) + - 网络管理 + - [网络连接管理](reference/apis/js-apis-net-connection.md) + - [Socket连接](reference/apis/js-apis-socket.md) + - [WebSocket连接](reference/apis/js-apis-webSocket.md) + - [数据请求](reference/apis/js-apis-http.md) + - 通信与连接 + - [WLAN](reference/apis/js-apis-wifi.md) + - [Bluetooth](reference/apis/js-apis-bluetooth.md) + - [RPC通信](reference/apis/js-apis-rpc.md) + - 设备管理 + - [传感器](reference/apis/js-apis-sensor.md) + - [振动](reference/apis/js-apis-vibrator.md) + - [屏幕亮度](reference/apis/js-apis-brightness.md) + - [电量信息](reference/apis/js-apis-battery-info.md) + - [系统电源管理](reference/apis/js-apis-power.md) + - [热管理](reference/apis/js-apis-thermal.md) + - [Runninglock锁](reference/apis/js-apis-runninglock.md) + - [设备信息](reference/apis/js-apis-device-info.md) + - [系统属性](reference/apis/js-apis-system-parameter.md) + - [设备管理](reference/apis/js-apis-device-manager.md) + - [窗口](reference/apis/js-apis-window.md) + - [显示设备属性](reference/apis/js-apis-display.md) + - [升级](reference/apis/js-apis-update.md) + - [USB管理](reference/apis/js-apis-usb.md) + - [位置服务](reference/apis/js-apis-geolocation.md) + - 基本功能 + - [应用上下文](reference/apis/js-apis-system-app.md) + - [日志打印](reference/apis/js-apis-basic-features-logs.md) + - [页面路由](reference/apis/js-apis-system-router.md) + - [弹窗](reference/apis/js-apis-system-prompt.md) + - [应用配置](reference/apis/js-apis-system-configuration.md) + - [定时器](reference/apis/js-apis-basic-features-timer.md) + - [设置系统时间](reference/apis/js-apis-system-time.md) + - [动画](reference/apis/js-apis-basic-features-animator.md) + - [WebGL](reference/apis/js-apis-webgl.md) + - [WebGL2](reference/apis/js-apis-webgl2.md) + - [屏幕截图](reference/apis/js-apis-screenshot.md) + - [输入法框架](reference/apis/js-apis-inputmethod.md) + - [输入法服务](reference/apis/js-apis-inputmethodengine.md) + - [辅助功能](reference/apis/js-apis-accessibility.md) + - DFX + - [应用打点](reference/apis/js-apis-hiappevent.md) + - [性能打点](reference/apis/js-apis-hitracemeter.md) + - [故障日志获取](reference/apis/js-apis-faultLogger.md) + - [分布式跟踪](reference/apis/js-apis-hitracechain.md) + - [日志打印](reference/apis/js-apis-hilog.md) + - [检测模式](reference/apis/js-apis-hichecker.md) + - [Debug调试](reference/apis/js-apis-hidebug.md) + - 语言基础类库 + - [获取进程相关的信息](reference/apis/js-apis-process.md) + - [URL字符串解析](reference/apis/js-apis-url.md) + - [URI字符串解析](reference/apis/js-apis-uri.md) + - [util工具函数](reference/apis/js-apis-util.md) + - [xml解析与生成](reference/apis/js-apis-xml.md) + - [xml转换JavaScript](reference/apis/js-apis-convertxml.md) + - [启动一个worker](reference/apis/js-apis-worker.md) + - [线性容器ArrayList](reference/apis/js-apis-arraylist.md) + - [线性容器Deque](reference/apis/js-apis-deque.md) + - [线性容器List](reference/apis/js-apis-list.md) + - [线性容器LinkedList](reference/apis/js-apis-linkedlist.md) + - [线性容器Queue](reference/apis/js-apis-queue.md) + - [线性容器Stack](reference/apis/js-apis-stack.md) + - [线性容器Vector](reference/apis/js-apis-vector.md) + - [非线性容器HashSet](reference/apis/js-apis-hashset.md) + - [非线性容器HashMap](reference/apis/js-apis-hashmap.md) + - [非线性容器PlainArray](reference/apis/js-apis-plainarray.md) + - [非线性容器TreeMap](reference/apis/js-apis-treemap.md) + - [非线性容器TreeSet](reference/apis/js-apis-treeset.md) + - [非线性容器LightWeightMap](reference/apis/js-apis-lightweightmap.md) + - [非线性容器LightWeightSet](reference/apis/js-apis-lightweightset.md) + - 定制管理 + - [配置策略](reference/apis/js-apis-config-policy.md) + - [企业设备管理](reference/apis/js-apis-enterprise-device-manager.md) \ No newline at end of file diff --git a/zh-cn/application-dev/windowmanager/window-guidelines.md b/zh-cn/application-dev/windowmanager/window-guidelines.md index 0c4e6e252f43a041cb7d2ced3df7607064121657..fa53347833b063a3bef04ab5e1337447aa0073da 100644 --- a/zh-cn/application-dev/windowmanager/window-guidelines.md +++ b/zh-cn/application-dev/windowmanager/window-guidelines.md @@ -1,6 +1,6 @@ # 窗口开发指导 -# 场景介绍 +## 场景介绍 窗口的接口层在应用进程运行,负责对页面布局的加载,和提供应用程序接口。 通过调用窗口接口可以实现窗口创建与销毁,窗口的位置、大小布局,以及进入沉浸式等。 @@ -12,7 +12,7 @@ | 接口名 | 描述 | | :----------------------------------------------------------- | :--------------------------------------------- | | create(id: string, type: WindowType, callback: AsyncCallback\): void | 创建子窗口。 | -| moveTo(x: number, y: number): Promise\ | 移动窗口位置,x值为正表示右移,y为正表示右移。 | +| moveTo(x: number, y: number): Promise\ | 移动窗口位置,x值为正表示右移,y为正表示下移。 | | resetSize(width: number, height: number): Promise\ | 改变当前窗口大小。 | | hide(): Promise\ | 隐藏当前窗口。 | | destroy(): Promise\ | 销毁当前窗口。 | @@ -22,7 +22,7 @@ ### 创建主窗口 在当前模型下,应用启动时会自动创建主窗口,由应用管理窗口的声明周期,隐藏及销毁由应用管理。 -###创建子窗口 +### 创建子窗口 当前可以通过`create`接口创建子窗口。具体示例代码如下: ``` diff --git a/zh-cn/application-dev/windowmanager/window-overview.md b/zh-cn/application-dev/windowmanager/window-overview.md index 5fc7811424d937bf3e9a27c42cfc42923be50424..9e2e82208ed5a1a3985b93b3316d55d037e8c646 100644 --- a/zh-cn/application-dev/windowmanager/window-overview.md +++ b/zh-cn/application-dev/windowmanager/window-overview.md @@ -1,18 +1,13 @@ # 窗口开发概述 **窗口子系统**提供窗口管理和Display管理的基础能力,是系统图形界面显示所需的基础子系统。 -窗口系统的作用,是提供一种机制,让多个应用界面复用同一块物理屏幕进行显示和交互。每个应用程序中,著需要实现被分配部分的显示区域内的交互界面,窗口作用应用界面的显示容器,而窗口系统负责将这些交互界面组织成最终用户见到的形态。 +窗口系统的作用,是提供一种机制,让多个应用界面复用同一块物理屏幕进行显示和交互。每个应用程序中,需要实现固定窗口区域内的交互界面设计,窗口作用应用界面的显示容器,而窗口系统负责将这些交互界面组织成最终用户见到的形态。 ## 基本概念 -**沉浸式** -应用窗口跟状态栏与导航栏颜色一致,视觉上融合。 +**沉浸式**:应用窗口跟状态栏与导航栏颜色一致,视觉上融合。 ## 运作机制 -为了将图形界面显示在屏幕上,应用和系统需要向窗口系统申请窗口对象,这通常代表了屏幕上一块矩形区域,具有位置、宽高、和叠加层次等属性。同时,窗口对象也负责加载界面中UI框架的根节点,应用程序的UI界面就通过这个根节点在窗口中加载显示。 - -## 约束与限制 - -window API提供的相关接口除回调注册`on`,注销`off`为同步接口外,其余全部为异步接口。 \ No newline at end of file +为了将图形界面显示在屏幕上,应用和系统需要向窗口系统申请窗口对象,这通常代表了屏幕上一块矩形区域,具有位置、宽高、和叠加层次等属性。同时,窗口对象也负责加载界面中UI框架的根节点,应用程序的UI界面就通过这个根节点在窗口中加载显示。 \ No newline at end of file diff --git a/zh-cn/design/OpenHarmony-API-governance.md b/zh-cn/design/OpenHarmony-API-governance.md index b16a693ce1f6037d11f00bae97e971734da9f115..843823a4c53363b6fbfeddefe99e58c3c431e78f 100755 --- a/zh-cn/design/OpenHarmony-API-governance.md +++ b/zh-cn/design/OpenHarmony-API-governance.md @@ -4,7 +4,7 @@ 为了引导OpenHarmony生态健康、有序发展和演进,本章程对OpenHarmony API的新增、变更、废弃、删除等生命周期与治理流程进行约束,同时定义了基本的API设计要求。 -本章程由[API SIG](https://www.openharmony.cn/SIG/api/)制定,经[PMC](https://www.openharmony.cn/community/pmc/)批准发布;本对章程的修订必须经由API SIG评审后,由PMC批准发布。 +本章程由[API SIG](https://www.openharmony.cn/SIG/api/)制定,经[PMC](https://www.openharmony.cn/community/pmc/)批准发布;对本章程的修订必须经由API SIG评审后,由PMC批准发布。 ## 概述 diff --git a/zh-cn/device-dev/Readme-CN.md b/zh-cn/device-dev/Readme-CN.md index c673c5fb5c02dbe61f71c2e97ae8b03033bff179..a88be1fdf243dcf537469ad3dee0cb1b79925449 100644 --- a/zh-cn/device-dev/Readme-CN.md +++ b/zh-cn/device-dev/Readme-CN.md @@ -1,8 +1,8 @@ # 设备开发 +- [设备开发导读](device-dev-guide.md) - 了解OpenHarmony - [了解OpenHarmony开源项目](../OpenHarmony-Overview_zh.md) - - [了解OpenHarmony系统](../readme.md) - [术语](glossary/glossary.md) - [版本说明](../release-notes/Readme.md) - 快速开始 @@ -14,7 +14,8 @@ - [轻量和小型系统三方库移植指导](porting/porting-thirdparty.md) - [轻量系统芯片移植指导](porting/porting-minichip.md) - [轻量系统芯片移植案例](porting/porting-minichip-cases.md) - - [小型系统芯片移植指导](porting/porting-smallchip.md) + - [小型系统芯片移植指导](porting/porting-smallchip.md) + - [标准系统芯片移植指导](porting/standard-system-porting-guide.md) - 子系统开发 - 内核 - [轻量系统内核](kernel/kernel-mini.md) @@ -37,7 +38,7 @@ - [启动恢复](subsystems/subsys-boot.md) - [DFX](subsystems/subsys-dfx.md) - 专题开发 - - [HPM Bundle](bundles/Readme-CN.md) + - [HPM Part](hpm-part/Readme-CN.md) - 设备开发示例 - [轻量和小型系统设备开发示例](guide/device-lite.md) - [标准系统设备开发示例](guide/device-lite.md) diff --git a/zh-cn/device-dev/device-dev-guide.md b/zh-cn/device-dev/device-dev-guide.md index 978bdbf97ff456359c349659ae4a8567ab6e73d7..7f0119b6f5afc6ebbbc0e9cfef88b07bce2884ac 100644 --- a/zh-cn/device-dev/device-dev-guide.md +++ b/zh-cn/device-dev/device-dev-guide.md @@ -90,7 +90,7 @@ OpenHarmony也提供了一系列可选的系统组件,方便设备开发者按

OpenHarmony贡献功能组件

- +

参考

@@ -160,7 +160,7 @@ OpenHarmony也提供了一系列可选的系统组件,方便设备开发者按

OpenHarmony贡献功能组件

- +

参考

diff --git a/zh-cn/device-dev/driver/driver-peripherals-audio-des.md b/zh-cn/device-dev/driver/driver-peripherals-audio-des.md index 27232b2a39a4af299398f66ee19f95ebf2a90a2d..4e12a54f06ecab87d2a83cc3435aa60e770fa685 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-audio-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-audio-des.md @@ -69,8 +69,8 @@ Audio驱动框架基于[HDF驱动框架](https://device.harmonyos.com/cn/docs/do - Audio Control Dispatch : 接收lib层的控制指令并将控制指令分发到驱动层。 - Audio Stream Dispatch : 接收lib层的数据并将数据分发到驱动层。 -- Card Manager : 多声卡管理模块。每个声卡含有Dai、Platform、Codec、Accessory、Dsp、Sapm模块。 -- Platform Driver : 驱动适配层。 +- Card Manager : 多声卡管理模块。每个声卡含有Dai、Platform、Codec、Accessory、Dsp、SAPM模块。 +- Platform Drivers : 驱动适配层。 - SAPM(Smart Audio Power Manager) : 电源管理模块,对整个ADM电源进行功耗策略优化。 # Audio驱动开发 diff --git a/zh-cn/device-dev/driver/driver-peripherals-light-des.md b/zh-cn/device-dev/driver/driver-peripherals-light-des.md index 2e0ba1e5c9cdbf36e5eb07d1e83e241d463aed35..eea5df18f69350273e96ed602b35ce8e764d4d24 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-light-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-light-des.md @@ -1,17 +1,5 @@ # LIGHT -- [概述](##概述) - - [功能简介](###功能简介) - - [运作机制](###运作机制) - -- [开发指导](##开发指导) - - - [场景介绍](###场景介绍) - - - [接口说明](###接口说明) - - [开发步骤](###开发步骤) - - [调测验证](###调测验证) - ## 概述 @@ -21,7 +9,7 @@ **图 1** Light驱动模型图 -![Light驱动模型图](figures/Light%E9%A9%B1%E5%8A%A8%E6%A8%A1%E5%9E%8B%E5%9B%BE.png) +![Light驱动模型图](figures/Light驱动模型图.png) ### 运作机制 @@ -29,7 +17,7 @@ **图 2** Light驱动运行图 -![Light驱动运行图](figures/Light%E9%A9%B1%E5%8A%A8%E8%BF%90%E8%A1%8C%E5%9B%BE.png) +![Light驱动运行图](figures/Light驱动运行图.png) Light驱动模型以标准系统Hi3516DV300为例,介绍整个驱动加载及运行流程: diff --git a/zh-cn/device-dev/driver/driver-peripherals-vibrator-des.md b/zh-cn/device-dev/driver/driver-peripherals-vibrator-des.md index 50aab04131508567f003a8da6eb490f13d3ac200..dba78a0b7170b1b1cfd8484fa20440de2ae0a59c 100755 --- a/zh-cn/device-dev/driver/driver-peripherals-vibrator-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-vibrator-des.md @@ -1,7 +1,3 @@ ---- - ---- - # Vibrator - [概述](##概述) - [功能简介](###功能简介) @@ -63,7 +59,7 @@ ### 接口说明 -马达驱动模型支持静态HCS配置和动态参数两种振动效果配置能力。马达硬件服务调用StartOnce接口动态配置持续振动;调用Start接口启动静态配置的振动效果。马达驱动模型对HDI开放的API接口能力,参考[表1](马达驱动模型对外API接口能力介绍)。 +马达驱动模型支持静态HCS配置和动态参数两种振动效果配置能力。马达硬件服务调用StartOnce接口动态配置持续振动;调用Start接口启动静态配置的振动效果。马达驱动模型对HDI开放的API接口能力,参考[表1](#马达驱动模型对外API接口能力介绍)。 **表 1** 马达驱动模型对外API接口能力介绍 diff --git a/zh-cn/device-dev/driver/driver-platform-mipicsi-des.md b/zh-cn/device-dev/driver/driver-platform-mipicsi-des.md index 2a910dbf2d6f73a2da6fa251b2fa89f423b37ec3..9b5e164be92a075f1b500f92e7075deeabcfe1d7 100755 --- a/zh-cn/device-dev/driver/driver-platform-mipicsi-des.md +++ b/zh-cn/device-dev/driver/driver-platform-mipicsi-des.md @@ -1,4 +1,4 @@ -# MIPI CSI +# MIPI-CSI - [概述](#section1_MIPI_CSIDes) - [ComboDevAttr结构体](#section1.1_MIPI_CSIDes) diff --git a/zh-cn/device-dev/driver/driver-platform-pin-develop.md b/zh-cn/device-dev/driver/driver-platform-pin-develop.md index 3e098c1fd43fb59d5a347958817e681e76ede03b..890e385759a8fc987a2ec306b07f8375ecf373c5 100755 --- a/zh-cn/device-dev/driver/driver-platform-pin-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-pin-develop.md @@ -1,21 +1,12 @@ -# PIN +# PIN -- [概述](#section1_PinDevelop) - - [功能简介](#section2_PinDevelop) - - [基本概念](#section3_PinDevelop) - - [运作机制](#section4_PinDevelop) - - [约束与限制](#section5_PinDevelop) -- [使用指导](#section6_PinDevelop) - - [场景介绍](#section7_PinDevelop) - - [接口说明](#section8_PinDevelop) - - [开发步骤](#section9_PinDevelop) -## 概述 +## 概述 -### 功能简介 +### 功能简介 PIN即管脚控制器,用于统一管理各SoC厂商管脚资源,对外提供管脚复用功能。 -### 基本概念 +### 基本概念 PIN是一个软件层面的概念,目的是为了统一各SoC厂商PIN管脚管理,对外提供管脚复用功能,配置PIN管脚的电气特性。 @@ -27,26 +18,26 @@ PIN是一个软件层面的概念,目的是为了统一各SoC厂商PIN管脚 由于芯片自身的引脚数量有限,无法满足日益增多的外接需求。此时可以通过软件层面的寄存器设置,让引脚工作在不同的状态,从而实现相同引脚完成不同功能的目的。 -### 运作机制 +### 运作机制 -在HDF框架中,PIN模块暂不支持用户态,所以不需要发布服务,接口适配模式采用无服务模式(如图1所示),用于不需要在用户态提供API的设备类型,或者没有用户态和内核区分的OS系统,其关联方式是DevHandle直接指向设备对象内核态地址(DevHandle是一个void类型指针)。 +在HDF框架中,PIN模块暂不支持用户态,所以不需要发布服务,接口适配模式采用无服务模式(如[图1](#无服务模式结构图)所示),用于不需要在用户态提供API的设备类型,或者没有用户态和内核区分的OS系统,其关联方式是DevHandle直接指向设备对象内核态地址(DevHandle是一个void类型指针)。 PIN模块各分层作用:接口层提供获取PIN管脚、设置PIN管脚推拉方式、获取PIN管脚推拉方式、设置PIN管脚推拉强度、获取PIN管脚推拉强度、设置PIN管脚功能、获取PIN管脚功能、释放PIN管脚的接口。核心层主要提供PIN管脚资源匹配,PIN管脚控制器的添加、移除以及管理的能力,通过钩子函数与适配层交互。适配层主要是将钩子函数的功能实例化,实现具体的功能。 **图 1** 无服务模式结构图 -![image1](figures/无服务模式结构图.png) +![无服务模式结构图](figures/无服务模式结构图.png) -### 约束与限制 +### 约束与限制 - PIN模块目前仅支持轻量和小型系统内核(LiteOS)。 +PIN模块目前仅支持轻量和小型系统内核(LiteOS)。 -## 开发指导 +## 开发指导 -### 场景介绍 +### 场景介绍 PIN模块主要用于管脚资源管理。在各SoC厂商对接HDF框架时,需要来适配PIN驱动。 -### 接口说明 +### 接口说明 通过以下PinCntlrMethod中的函数调用PIN驱动对应的函数。 PinCntlrMethod定义: @@ -73,7 +64,7 @@ struct PinCntlrMethod { | SetPinFunc | **cntlr**:结构体指针,核心层Pin控制器;
**index**:uint32_t变量,管脚索引号;
**funcName**:char指针常量,传入Pin管脚功能; | 无 | HDF_STATUS相关状态 | PIN设置管脚功能 | | GetPinFunc | **cntlr**:结构体指针,核心层Pin控制器;
**index**:uint32_t变量,管脚索引号; | **funcName**:char双重指针常量,传出Pin管脚功能; | HDF_STATUS相关状态 | PIN获取管脚功能 | -### 开发步骤 +### 开发步骤 PIN模块适配包含以下四个步骤: @@ -85,7 +76,7 @@ PIN模块适配包含以下四个步骤: 1. **实例化驱动入口:** - 实例化HdfDriverEntry结构体成员。 - 驱动开发首先需要实例化驱动入口,驱动入口必须为HdfDriverEntry(在 hdf_device_desc.h 中定义)类型的全局变量,且moduleName要和device_info.hcs中保持一致。 + 驱动开发首先需要实例化驱动入口,驱动入口必须为HdfDriverEntry(在 hdf_device_desc.h 中定义)类型的全局变量,且moduleName要和device_info.hcs中保持一致。 - 调用HDF_INIT将HdfDriverEntry实例化对象注册到HDF框架中。 一般在加载驱动时HDF会先调用Init函数加载该驱动。当Init调用异常时,HDF框架会调用Release释放驱动资源并退出。 @@ -292,7 +283,7 @@ PIN模块适配包含以下四个步骤: HdfDeviceObject这个是整个驱动对外暴露的接口参数,具备HCS配置文件的信息。 返回值: - HDF\_STATUS相关状态 (下表为部分展示,如需使用其他状态,可见/drivers/framework/include/utils/hdf\_base.h中HDF\_STATUS 定义)。 + HDF\_STATUS相关状态(下表为部分展示,如需使用其他状态,可见/drivers/framework/include/utils/hdf\_base.h中HDF\_STATUS 定义)。 | **状态(值)** | **问题描述** | | ---------------------- | -------------- | diff --git a/zh-cn/device-dev/driver/driver-platform-regulator-des.md b/zh-cn/device-dev/driver/driver-platform-regulator-des.md index 11af14de0e2daca02878b0d4b201d0dc8ddb2d4f..ef724cf08dca036fbbb8b980b09853da162e07db 100755 --- a/zh-cn/device-dev/driver/driver-platform-regulator-des.md +++ b/zh-cn/device-dev/driver/driver-platform-regulator-des.md @@ -1,107 +1,91 @@ -# REGULATOR - -- [概述](#section1_REGULATOR_des) -- [接口说明](#section2_REGULATOR_des) -- [使用指导](#section3_REGULATOR_des) - - [使用流程](#section3.1_REGULATOR_des) - - [获取REGULATOR设备句柄](#section3.2_REGULATOR_des) - - [销毁REGULATOR设备句柄](#section3.3_REGULATOR_des) - - [使能](#section3.4_REGULATOR_des) - - [禁用](#section3.5_REGULATOR_des) - - [强制禁用](#section3.6_REGULATOR_des) - - [设置REGULATOR电压输出电压范围](#section3.7_REGULATOR_des) - - [获取REGULATOR设备电压](#section3.8_REGULATOR_des) - - [设置REGULATOR设备输出电流范围](#section3.9_REGULATOR_des) - - [获取REGULATOR设备电流](#section3.10_REGULATOR_des) - - [获取REGULATOR设备状态](#section3.11_REGULATOR_des) -- [使用实例](#section4_REGULATOR_des) - -## 概述 - -- REGULATOR模块用于控制系统中某些设备的电压/电流供应。在嵌入式系统(尤其是手机)中,控制耗电量很重要,直接影响到电池的续航时间。所以,如果系统中某一个模块暂时不需要使用,就可以通过regulator关闭其电源供应;或者降低提供给该模块的电压、电流大小。 - -- REGULATOR接口定义了操作REGULATOR设备的通用方法集合,包括: - - REGULATOR设备句柄获取和销毁。 - - REGULATOR设备电压、电流的设置。 - - REGULATOR设备使能和关闭。 - - REGULATOR设备电压、电流和状态的获取 - -## 接口说明 +# REGULATOR + +- [概述](#section1) + - [功能简介](#section2) + - [基本概念](#section3) + - [运作机制](#section4) + - [约束与限制](#section5) +- [使用指导](#section6) + - [场景介绍](#section7) + - [接口说明](#section8) + - [开发步骤](#section9) + - [使用实例](#section10) + +## 概述 + +### 功能简介 + +- REGULATOR模块用于控制系统中某些设备的电压/电流供应。在嵌入式系统(尤其是手机)中,控制耗电量很重要,直接影响到电池的续航时间。所以,如果系统中某一个模块暂时不需要使用,就可以通过REGULATOR关闭其电源供应;或者降低提供给该模块的电压、电流大小。 +- REGULATOR接口定义了操作REGULATOR设备的通用方法集合,包括: + - REGULATOR设备句柄获取和销毁。 + - REGULATOR设备电压、电流的设置。 + - REGULATOR设备使能和关闭。 + - REGULATOR设备电压、电流和状态的获取。 + + +### 基本概念 + +- 校准器 + + 当输入电压和输出负载发生变化时可以通过软件调整,使其能够提供稳定的输出电压。 + +- Consumer + + 由REGULATOR供电的设备统称为Consumer, 其可分为静态和动态两类: + + * 静态:不需要改变电压电流,只需要开关电源,通常在bootloader、firmware、kernel board阶段被设置。 + * 动态:根据操作需求改变电压电流。 + +- Power Management Ic + + 电源管理芯片,内含多个电源甚至其他子系统。 + + +### 运作机制 + +在HDF框架中,REGULATOR模块接口适配模式采用统一服务模式,这需要一个设备服务来作为REGULATOR模块的管理器,统一处理外部访问,这会在配置文件中有所体现。统一服务模式适合于同类型设备对象较多的情况,如REGULATOR可能同时具备十几个控制器,采用独立服务模式需要配置更多的设备节点,且服务会占据内存资源。 + +REGULATOR模块各分层的作用为:接口层提供打开设备,写入数据,关闭设备接口的能力。核心层主要提供绑定设备、初始化设备以及释放设备的能力。适配层实现其他具体的功能。 + +![](../public_sys-resources/icon-note.gif) 说明:核心层可以调用接口层的函数,也可以通过钩子函数调用适配层函数,从而使得适配层间接的可以调用接口层函数,但是不可逆转接口层调用适配层函数。 + +图 1 统一服务模式结构图 + +![image1](figures/统一服务模式结构图.png) + +### 约束与限制 + + REGULATOR模块当前仅支持轻量和小型系统内核(LiteOS) 。 + +## 使用指导 + +### 场景介绍 + + REGULATOR主要用于: + +1. 用于控制系统中某些设备的电压/电流供应。 +2. 用于稳压电源的管理 。 + +### 接口说明 **表1** REGULATOR设备API功能介绍 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
功能分类接口名描述
REGULATOR句柄操作RegulatorOpen获取REGULATOR设备驱动句柄
RegulatorClose销毁REGULATOR设备驱动句柄
使能/禁用REGULATORRegulatorEnable使能REGULATOR
RegulatorDisable禁用REGULATOR
RegulatorForceDisable强制禁用REGULATOR
设置/获取REGULATOR输出电压RegulatorSetVoltage设置REGULATOR输出电压
RegulatorGetVoltage获取REGULATOR输出电压
设置/获取REGULATOR输出电流RegulatorSetCurrent设置REGULATOR输出电流
RegulatorGetCurrent获取REGULATOR输出电流
获取REGULATOR状态RegulatorGetStatus获取REGULATOR状态
- ->![](../public_sys-resources/icon-note.gif) **说明:** ->REGULATOR当前仅限内核态使用,不支持在用户态使用。 - -## 使用指导 - -### 使用流程 +| 接口名 | 描述 | +| --------------------- | ------------------------- | +| RegulatorOpen | 获取REGULATOR设备驱动句柄 | +| RegulatorClose | 销毁REGULATOR设备驱动句柄 | +| RegulatorEnable | 使能REGULATOR | +| RegulatorDisable | 禁用REGULATOR | +| RegulatorForceDisable | 强制禁用REGULATOR | +| RegulatorSetVoltage | 设置REGULATOR输出电压 | +| RegulatorGetVoltage | 获取REGULATOR输出电压 | +| RegulatorSetCurrent | 设置REGULATOR输出电流 | +| RegulatorGetCurrent | 获取REGULATOR输出电流 | +| RegulatorGetStatus | 获取REGULATOR状态 | + + + +### 开发步骤 在操作系统启动过程中,驱动管理模块根据配置文件加载REGULATOR驱动,REGULATOR驱动会检测REGULATOR器件并初始化驱动。 @@ -109,20 +93,19 @@ **图 1** REGULATOR设备使用流程图 - ![](figures/REGULATOR设备使用流程图.png) -### 获取REGULATOR设备句柄 +#### 获取REGULATOR设备句柄 在操作REGULATOR设备时,首先要调用RegulatorOpen获取REGULATOR设备句柄,该函数会返回指定设备名称的REGULATOR设备句柄。 -```c +``` DevHandle RegulatorOpen(const char *name); ``` **表2** RegulatorOpen参数和返回值描述 - + | 参数 | 参数描述 | | ---------- | ----------------------------- | @@ -132,7 +115,8 @@ DevHandle RegulatorOpen(const char *name); | NULL | 获取失败 | -```c + +``` /* REGULATOR设备名称 */ const char *name = "regulator_virtual_1"; DevHandle handle = NULL; @@ -144,39 +128,37 @@ if (handle == NULL) { } ``` -### 销毁REGULATOR设备句柄 +#### 销毁REGULATOR设备句柄 关闭REGULATOR设备,系统释放对应的资源。 -```c +``` void RegulatorClose(DevHandle handle); ``` **表3** RegulatorClose参数描述 - + | 参数 | 参数描述 | | ------ | ----------------- | | handle | REGULATOR设备句柄 | - -```c +``` /* 销毁REGULATOR设备句柄 */ RegulatorClose(handle); ``` -### 使能 +#### 使能 启用REGULATOR设备。 -```c +``` int32_t RegulatorEnable(DevHandle handle); ``` - **表4** RegulatorEnable参数描述 - + | 参数 | 参数描述 | | ---------- | ----------------- | @@ -185,7 +167,9 @@ int32_t RegulatorEnable(DevHandle handle); | 0 | 使能成功 | | 负数 | 使能失败 | -```c + + +``` int32_t ret; /*启用REGULATOR设备*/ @@ -195,18 +179,16 @@ if (ret != 0) { } ``` -### 禁用 +#### 禁用 禁用REGULATOR设备。 -```c +``` int32_t RegulatorDisable(DevHandle handle); ``` **表5** RegulatorDisable参数描述 - - | 参数 | 参数描述 | | ---------- | ----------------- | | handle | REGULATOR设备句柄 | @@ -214,7 +196,7 @@ int32_t RegulatorDisable(DevHandle handle); | 0 | 禁用成功 | | 负数 | 禁用失败 | -```c +``` int32_t ret; /*禁用REGULATOR设备,如果REGULATOR设备状态为常开,或存在REGULATOR设备子节点未禁用,则禁用失败*/ @@ -224,26 +206,26 @@ if (ret != 0) { } ``` -### 强制禁用 +#### 强制禁用 强制禁用REGULATOR设备。 -```c +``` int32_t RegulatorForceDisable(DevHandle handle); ``` -**表6** RegulatorForceDisable参数描述 +**表5** RegulatorDisable参数描述 - + | 参数 | 参数描述 | | ---------- | ----------------- | | handle | REGULATOR设备句柄 | | **返回值** | **返回值描述** | -| 0 | 强制禁用成功 | -| 负数 | 强制禁用失败 | +| 0 | 禁用成功 | +| 负数 | 禁用失败 | -```c +``` int32_t ret; /*强制禁用REGULATOR设备,无论REGULATOR设备的状态是常开还是子节点已使能,REGULATOR设备都会被禁用*/ @@ -252,11 +234,12 @@ if (ret != 0) { /*错误处理*/ } ``` -### 设置REGULATOR输出电压范围 + +#### 设置REGULATOR输出电压范围 设置REGULATOR电压输出电压范围。 -```c +``` int32_t RegulatorSetVoltage(DevHandle handle, uint32_t minUv, uint32_t maxUv); ``` @@ -273,7 +256,7 @@ int32_t RegulatorSetVoltage(DevHandle handle, uint32_t minUv, uint32_t maxUv); | 0 | 设置成功 | | 负数 | 设置失败 | -```c +``` int32_t ret; int32_t minUv = 0; //最小电压为0Uv int32_t maxUv = 20000; //最大电压为20000Uv @@ -284,11 +267,12 @@ if (ret != 0) { /*错误处理*/ } ``` -### 获取REGULATOR电压 + +#### 获取REGULATOR电压 获取REGULATOR电压。 -```c +``` int32_t RegulatorGetVoltage(DevHandle handle, uint32_t *voltage); ``` @@ -304,7 +288,7 @@ int32_t RegulatorGetVoltage(DevHandle handle, uint32_t *voltage); | 0 | 获取成功 | | 负数 | 获取失败 | -```c +``` int32_t ret; uint32_t voltage; @@ -315,12 +299,11 @@ if (ret != 0) { } ``` - -### 设置REGULATOR输出电流范围 +#### 设置REGULATOR输出电流范围 设置REGULATOR输出电流范围。 -```c +``` int32_t RegulatorSetCurrent(DevHandle handle, uint32_t minUa, uint32_t maxUa); ``` @@ -337,10 +320,10 @@ int32_t RegulatorSetCurrent(DevHandle handle, uint32_t minUa, uint32_t maxUa); | 0 | 设置成功 | | 负数 | 设置失败 | -```c +``` int32_t ret; int32_t minUa = 0; //最小电流为0Ua -int32_t maxUa = 200; //最大电流为200Ua +int32_t maxUa = 200; //最大电流为200Ua /*设置REGULATOR输出电流范围*/ ret = RegulatorSetCurrent(handle, minUa, maxUa); @@ -349,11 +332,11 @@ if (ret != 0) { } ``` -### 获取REGULATOR电流 +#### 获取REGULATOR电流 获取REGULATOR电流。 -```c +``` int32_t RegulatorGetCurrent(DevHandle handle, uint32_t *regCurrent); ``` @@ -369,7 +352,7 @@ int32_t RegulatorGetCurrent(DevHandle handle, uint32_t *regCurrent); | 0 | 获取成功 | | 负数 | 获取失败 | -```c +``` int32_t ret; uint32_t regCurrent; @@ -379,17 +362,18 @@ if (ret != 0) { /*错误处理*/ } ``` -### 获取REGULATOR状态 + +#### 获取REGULATOR状态 获取REGULATOR状态。 -```c +``` int32_t RegulatorGetStatus(DevHandle handle, uint32_t *status); ``` -**表11** RegulatorGetStatus参数描述 +**表10** RegulatorGetCurrent参数描述 - + | 参数 | 参数描述 | | ---------- | ----------------- | @@ -399,7 +383,7 @@ int32_t RegulatorGetStatus(DevHandle handle, uint32_t *status); | 0 | 获取成功 | | 负数 | 获取失败 | -```c +``` int32_t ret; uint32_t status; @@ -410,11 +394,13 @@ if (ret != 0) { } ``` -## 使用实例 + + +## 使用实例 REGULATOR设备完整的使用示例如下所示,首先获取REGULATOR设备句柄,然后使能,设置电压,获取电压、状态,禁用,最后销毁REGULATOR设备句柄。 -```c +``` void RegulatorTestSample(void) { int32_t ret; @@ -476,4 +462,4 @@ _ERR: /* 销毁REGULATOR设备句柄 */ RegulatorClose(handle); } -``` \ No newline at end of file +``` diff --git a/zh-cn/device-dev/driver/driver-platform-regulator-develop.md b/zh-cn/device-dev/driver/driver-platform-regulator-develop.md index 69b06d2b86712cb2c62df5075642d8bd6680c5be..d7a501f4bdabd3fadd57bc6f46303017896617d3 100755 --- a/zh-cn/device-dev/driver/driver-platform-regulator-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-regulator-develop.md @@ -1,22 +1,58 @@ -# REGULATOR +# REGULATOR -- [概述](#section1_REGULATORDevelop) -- [接口说明](#section2_REGULATORDevelop) -- [开发步骤](#section3_REGULATORDevelop) -- [开发实例](#section4_REGULATORDevelop) +- [概述](#1) + - [功能简介](#2) + - [基本概念](#3) + - [运作机制](#4) + - [约束与限制](#5) +- [开发指导](#6) + - [场景介绍](#7) + - [接口说明](#8) + - [开发步骤](#9) -## 概述 +## 概述 -REGULATOR模块用于控制系统中某些设备的电压/电流供应。在HDF框架中,REGULATOR模块接口适配模式采用统一服务模式,这需要一个设备服务来作为REGULATOR模块的管理器,统一处理外部访问,这会在配置文件中有所体现。统一服务模式适合于同类型设备对象较多的情况,如REGULATOR可能同时具备十几个控制器,采用独立服务模式需要配置更多的设备节点,且服务会占据内存资源。 +### 功能简介 + +REGULATOR模块用于控制系统中某些设备的电压/电流供应。 + +### 基本概念 + +REGULATOR模块用于控制系统中某些设备的电压/电流供应。在嵌入式系统(尤其是手机)中,控制耗电量很重要,直接影响到电池的续航时间。所以,如果系统中某一个模块暂时不需要使用,就可以通过REGULATOR关闭其电源供应;或者降低提供给该模块的电压、电流大小。 + +### 运作机制 + +在HDF框架中,REGULATOR模块接口适配模式采用统一服务模式,这需要一个设备服务来作为REGULATOR模块的管理器,统一处理外部访问,这会在配置文件中有所体现。统一服务模式适合于同类型设备对象较多的情况,如REGULATOR可能同时具备十几个控制器,采用独立服务模式需要配置更多的设备节点,且服务会占据内存资源。 + +REGULATOR模块各分层的作用为:接口层提供打开设备,写入数据,关闭设备接口的能力。核心层主要提供绑定设备、初始化设备以及释放设备的能力。适配层实现其他具体的功能。 + +![](../public_sys-resources/icon-note.gif) 说明:核心层可以调用接口层的函数,也可以通过钩子函数调用适配层函数,从而使得适配层间接的可以调用接口层函数,但是不可逆转接口层调用适配层函数。 图 1 统一服务模式结构图 + ![image1](figures/统一服务模式结构图.png) -## 接口说明 -RegulatorMethod 定义: -```c + + +### 约束与限制 + + REGULATOR模块当前仅支持轻量和小型系统内核(LiteOS) 。 + +## 开发指导 + +### 场景介绍 + +REGULATOR模块用于控制系统中某些设备的电压/电流供应。 + +### 接口说明 + +通过以下RegulatorMethod中的函数调用REGULATOR驱动对应的函数。 + +RegulatorMethod定义: + +``` struct RegulatorMethod { int32_t (*open)(struct RegulatorNode *node); int32_t (*close)(struct RegulatorNode *node); @@ -32,78 +68,73 @@ struct RegulatorMethod { }; ``` -**表 1** RegulatorMethod 成员的回调函数功能说明 +**表 1** RegulatorMethod 结构体成员的回调函数功能说明 -| 成员函数 | 入参 | 返回值 | 功能 | -| ------------ | ------------------------------------------- | ------ | ---- | -| open | **node**:结构体指针,核心层regulator节点; |HDF_STATUS相关状态|打开设备| -| close | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 关闭设备 | -| release | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 释放设备句柄 | -| enable | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 使能 | -| disable | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 禁用 | -| forceDisable | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 强制禁用 | -| setVoltage | **node**:结构体指针,核心层regulator节点;
**minUv**:uint32_t变量,最小电压;
**maxUv**:uint32_t变量,最大电压; | HDF_STATUS相关状态 | 设置输出电压范围 | -| getVoltage | **node**:结构体指针,核心层regulator节点;
**voltage**:uint32_t指针,传出电压值; | HDF_STATUS相关状态 | 获取电压 | -| setCurrent | **node**:结构体指针,核心层regulator节点;
**minUa**:uint32_t变量,最小电流;
**maxUa**:uint32_t变量,最大电流; | HDF_STATUS相关状态 | 设置输出电流范围 | -| getCurrent | **node**:结构体指针,核心层regulator节点;
**regCurrent**:uint32_t指针,传出电流值; | HDF_STATUS相关状态 | 获取电流 | -| getStatus | **node**:结构体指针,核心层regulator节点;
**status**:uint32_t指针,传出状态值; | HDF_STATUS相关状态 | 获取设备状态 | + -## 开发步骤 - -REGULATOR模块适配的三个环节是实例化驱动入口、配置属性文件、以及实例化核心层接口函数。 - -1. **实例化驱动入口:** - - - 实例化HdfDriverEntry结构体成员。 - - 调用HDF_INIT将HdfDriverEntry实例化对象注册到HDF框架中。 - -2. **配置属性文件:** +| 成员函数 | 入参 | 返回值 | 功能 | +| ------------ | ------------------------------------------------------------ | ------------------ | ---------------- | +| open | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 打开设备 | +| close | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 关闭设备 | +| release | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 释放设备句柄 | +| enable | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 使能 | +| disable | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 禁用 | +| forceDisable | **node**:结构体指针,核心层regulator节点; | HDF_STATUS相关状态 | 强制禁用 | +| setVoltage | **node**:结构体指针,核心层regulator节点; **minUv**:uint32_t变量,最小电压; **maxUv**:uint32_t变量,最大电压; | HDF_STATUS相关状态 | 设置输出电压范围 | +| getVoltage | **node**:结构体指针,核心层regulator节点; **voltage**:uint32_t指针,传出电压值; | HDF_STATUS相关状态 | 获取电压 | +| setCurrent | **node**:结构体指针,核心层regulator节点; **minUa**:uint32_t变量,最小电流; **maxUa**:uint32_t变量,最大电流; | HDF_STATUS相关状态 | 设置输出电流范围 | +| getCurrent | **node**:结构体指针,核心层regulator节点; **regCurrent**:uint32_t指针,传出电流值; | HDF_STATUS相关状态 | 获取电流 | +| getStatus | **node**:结构体指针,核心层regulator节点; **status**:uint32_t指针,传出状态值; | HDF_STATUS相关状态 | 获取设备状态 | - - 在device_info.hcs文件中添加deviceNode描述。 - - 【可选】添加regulator_config.hcs器件属性文件。 +### 开发步骤 -3. **实例化REGULATOR控制器对象:** - - - 初始化RegulatorNode成员。 - - - 实例化RegulatorNode成员RegulatorMethod。 - - >![](../public_sys-resources/icon-note.gif) **说明:** - >实例化RegulatorNode成员RegulatorMethod,其定义和成员说明见[接口说明](#section2_REGULATORDevelop)。 - -4. **驱动调试:** - - 【可选】针对新增驱动程序,建议验证驱动基本功能,例如挂载后的信息反馈,数据传输的成功与否等。 +REGULATOR模块适配包含以下四个步骤: -## 开发实例 +- 实例化驱动入口。 +- 配置属性文件。 +- 实例化核心层接口函数。 +- 驱动调试。 -下方将以regulator_virtual.c为示例,展示需要厂商提供哪些内容来完整实现设备功能。 +1. **实例化驱动入口:** -1. 驱动开发首先需要实例化驱动入口,驱动入口必须为HdfDriverEntry(在 hdf\_device\_desc.h 中定义)类型的全局变量,且moduleName要和device\_info.hcs中保持一致。HDF框架会将所有加载的驱动的HdfDriverEntry对象首地址汇总,形成一个类似数组的段地址空间,方便上层调用。 + 驱动开发首先需要实例化驱动入口,驱动入口必须为HdfDriverEntry(在 hdf_device_desc.h 中定义)类型的全局变量,且moduleName要和device_info.hcs中保持一致。 HDF框架会汇总所有加载的驱动的HdfDriverEntry对象入口 ,形成一个类似数组的段地址空间,方便上层调用。 + + 一般在加载驱动时HDF会先调用Init函数加载该驱动。当Init调用异常时,HDF框架会调用Release释放驱动资源并退出。 + + ``` + struct HdfDriverEntry g_regulatorDriverEntry = { + .moduleVersion = 1, + .moduleName = "virtual_regulator_driver",//【必要且与HCS文件中里面的moduleName匹配】 + .Init = VirtualRegulatorInit, + .Release = VirtualRegulatorRelease, + }; + //调用HDF_INIT将驱动入口注册到HDF框架中 + HDF_INIT(g_regulatorDriverEntry); + ``` + +2. **配置属性文件:** - 一般在加载驱动时HDF会先调用Bind函数,再调用Init函数加载该驱动。当Init调用异常时,HDF框架会调用Release释放驱动资源并退出。 + - 在vendor/hisilicon/hispark_taurus/hdf_config/device_info/device_info.hcs文件中添加deviceNode描述。 - REGULATOR驱动入口参考 + deviceNode信息与驱动入口注册相关,器件属性值与核心层RegulatorNode成员的默认值或限制范围有密切关系。 - ```c - struct HdfDriverEntry g_regulatorDriverEntry = { - .moduleVersion = 1, - .moduleName = "virtual_regulator_driver",//【必要且与HCS文件中里面的moduleName匹配】 - .Init = VirtualRegulatorInit, - .Release = VirtualRegulatorRelease, - }; - //调用HDF_INIT将驱动入口注册到HDF框架中 - HDF_INIT(g_regulatorDriverEntry); - ``` + 由于采用了统一服务模式,device_info.hcs文件中第一个设备节点必须为REGULATOR管理器,其各项参数必须如下设置: -2. 完成驱动入口注册之后,下一步请在device\_info.hcs文件中添加deviceNode信息,并在regulator\_config.hcs中配置器件属性。deviceNode信息与驱动入口注册相关,器件属性值与核心层RegulatorNode成员的默认值或限制范围有密切关系。 + | 成员名 | 值 | + | --------------- | ------------------------------------------------------------ | + | policy | 具体配置为0,不发布服务 | + | priority | 驱动启动优先级(0-200),值越大优先级越低,,优先级相同则不保证device的加载顺序。 | + | permission | 驱动权限 | + | moduleName | 固定为 HDF_PLATFORM_REGULATOR_MANAGER | + | serviceName | 固定为HDF_PLATFORM_REGULATOR_MANAGER | + | deviceMatchAttr | 没有使用,可忽略 | - >![](W:\docs\zh-cn\device-dev\public_sys-resources\icon-note.gif) **说明:** - >如有更多个器件信息,则需要在device\_info文件增加deviceNode信息,以及在regulator\_config文件中增加对应的器件属性。 + 从第二个节点开始配置具体REGULATOR控制器信息,此节点并不表示某一路REGULATOR控制器,而是代表一个资源性质设备,用于描述一类REGULATOR控制器的信息。本例只有一个REGULATOR设备,如有多个设备,则需要在device_info文件增加deviceNode信息,以及在regulator\_config文件中增加对应的器件属性。 - - device\_info.hcs 配置参考。 + - device_info.hcs 配置参考。 - ```c - root { + ``` + root { device_info { platform :: host { hostName = "platform_host"; @@ -129,211 +160,196 @@ REGULATOR模块适配的三个环节是实例化驱动入口、配置属性文 } } } - } - ``` - - - regulator\_config.hcs 配置参考。 - - ```c - root { - platform { - regulator_config { - match_attr = "linux_regulator_adapter"; - template regulator_controller { //【必要】模板配置,继承该模板的节点如果使用模板中的默认值,则节点字段可以缺省 - device_num = 1; - name = ""; - devName = "regulator_adapter_consumer01"; - supplyName = ""; - mode = 1; - minUv = 0; - maxUv = 20000; - minUa = 0; - maxUa = 0; - } - controller_0x130d0000 :: regulator_controller { - device_num = 1; - name = "regulator_adapter_1"; - devName = "regulator_adapter_consumer01"; - supplyName = "virtual-regulator-hdf-adapter"; - mode = 1; - minUv = 1000; - maxUv = 50000; - minUa = 0; - maxUa = 0; - } - /*每个Regulator控制器对应一个controller节点,如存在多个Regulator控制器,请依次添加对应的controller节点。*/ - controller_0x130d0001 :: regulator_controller { - device_num = 1; - name = "regulator_adapter_2"; - devName = "regulator_adapter_consumer01"; - supplyName = "virtual2-regulator-hdf-adapter"; - mode = 2; - minUv = 0; - maxUv = 0; - minUa = 1000; - maxUa = 50000; - } - } - } - } - ``` - -3. 完成驱动入口注册之后,最后一步就是对核心层RegulatorNode对象的初始化,包括厂商自定义结构体(传递参数和数据),实例化RegulatorNode成员RegulatorMethod(让用户可以通过接口来调用驱动底层函数),实现HdfDriverEntry成员函数(Bind,Init,Release)。 - - - 自定义结构体参考。 - - 从驱动的角度看,RegulatorNode结构体是参数和数据的载体,HDF框架通过DeviceResourceIface将regulator\_config.hcs文件中的数值读入其中。 - - ```c - // RegulatorNode是核心层控制器结构体,其中的成员在Init函数中会被赋值 - struct RegulatorNode { - struct RegulatorDesc regulatorInfo; - struct DListHead node; - struct RegulatorMethod *ops; - void *priv; - struct OsalMutex lock; - }; - - struct RegulatorDesc { - const char *name; /* regulator 名称 */ - const char *parentName; /* regulator 父节点名称 */ - struct RegulatorConstraints constraints; /* regulator 约束信息 */ - uint32_t minUv; /* 最小输出电压值 */ - uint32_t maxUv; /* 最大输出电压值 */ - uint32_t minUa; /* 最小输出电流值 */ - uint32_t maxUa; /* 最大输出电流值 */ - uint32_t status; /* regulator的状态,开或关 */ - int useCount; - int consumerRegNums; /* regulator用户数量 */ - RegulatorStatusChangecb cb; /* 当regulator状态改变时,可通过此变量通知 */ - }; - - struct RegulatorConstraints { - uint8_t alwaysOn; /* regulator是否常开 */ - uint8_t mode; /* 模式:电压或者电流 */ - uint32_t minUv; /* 最小可设置输出电压 */ - uint32_t maxUv; /* 最大可设置输出电压 */ - uint32_t minUa; /* 最小可设置输出电流 */ - uint32_t maxUa; /* 最大可设置输出电流 */ - }; - ``` - - - 实例化RegulatorNode成员RegulatorMethod,其他成员在Init函数中初始化。 - - ```c - // regulator_virtual.c 中的示例:钩子函数的填充 - static struct RegulatorMethod g_method = { - .enable = VirtualRegulatorEnable, - .disable = VirtualRegulatorDisable, - .setVoltage = VirtualRegulatorSetVoltage, - .getVoltage = VirtualRegulatorGetVoltage, - .setCurrent = VirtualRegulatorSetCurrent, - .getCurrent = VirtualRegulatorGetCurrent, - .getStatus = VirtualRegulatorGetStatus, - }; - ``` - - - Init函数参考 - - 入参: - - HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 - - 返回值: - - HDF\_STATUS相关状态 (下表为部分展示,如需使用其他状态,可见//drivers/framework/include/utils/hdf\_base.h中HDF\_STATUS 定义)。 - - **表 2** HDF\_STATUS相关状态 - - - - - - - - - - - - - - - - - - - - - - - - -

状态(值)

-

问题描述

-

HDF_ERR_INVALID_OBJECT

-

控制器对象非法

-

HDF_ERR_MALLOC_FAIL

-

内存分配失败

-

HDF_ERR_INVALID_PARAM

-

参数非法

-

HDF_ERR_IO

-

I/O 错误

-

HDF_SUCCESS

-

初始化成功

-

HDF_FAILURE

-

初始化失败

-
- 函数说明: - 初始化自定义结构体和RegulatorNode成员,并通过调用核心层RegulatorNodeAdd函数挂载Regulator控制器。 - - ```c - static int32_t VirtualRegulatorInit(struct HdfDeviceObject *device) - { - int32_t ret; - const struct DeviceResourceNode *childNode = NULL; - ... - DEV_RES_NODE_FOR_EACH_CHILD_NODE(device->property, childNode) { - ret = VirtualRegulatorParseAndInit(device, childNode);//【必要】实现见下 - ... - } - ... - } - - static int32_t VirtualRegulatorParseAndInit(struct HdfDeviceObject *device, const struct DeviceResourceNode *node) - { - int32_t ret; - struct RegulatorNode *regNode = NULL; - (void)device; - - regNode = (struct RegulatorNode *)OsalMemCalloc(sizeof(*regNode));//加载HCS文件 - ... - ret = VirtualRegulatorReadHcs(regNode, node);//读取HCS文件信息 - ... - regNode->priv = (void *)node; //实例化节点 - regNode->ops = &g_method; //实例化ops - - ret = RegulatorNodeAdd(regNode); //挂载节点 - ... - } - - - - Release 函数参考 - + } + ``` + + - regulator\_config.hcs 配置参考。 + + ``` + root { + platform { + regulator_config { + match_attr = "linux_regulator_adapter"; + template regulator_controller { //【必要】模板配置,继承该模板的节点如果使用模板中的默认值,则节点字段可以缺省 + device_num = 1; + name = ""; + devName = "regulator_adapter_consumer01"; + supplyName = ""; + mode = 1; + minUv = 0; + maxUv = 20000; + minUa = 0; + maxUa = 0; + } + controller_0x130d0000 :: regulator_controller { + device_num = 1; + name = "regulator_adapter_1"; + devName = "regulator_adapter_consumer01"; + supplyName = "virtual-regulator-hdf-adapter"; + mode = 1; + minUv = 1000; + maxUv = 50000; + minUa = 0; + maxUa = 0; + } + /*每个Regulator控制器对应一个controller节点,如存在多个Regulator控制器,请依次添加对应的controller节点。*/ + controller_0x130d0001 :: regulator_controller { + device_num = 1; + name = "regulator_adapter_2"; + devName = "regulator_adapter_consumer01"; + supplyName = "virtual2-regulator-hdf-adapter"; + mode = 2; + minUv = 0; + maxUv = 0; + minUa = 1000; + maxUa = 50000; + } + } + } + } + ``` + +3. **实例化核心层接口函数:** + + - 完成驱动入口注册之后,最后一步就是对核心层RegulatorNode对象的初始化,包括厂商自定义结构体(传递参数和数据),实例化RegulatorNode成员RegulatorMethod(让用户可以通过接口来调用驱动底层函数),实现HdfDriverEntry成员函数(Bind,Init,Release)。 + + - 自定义结构体参考。 + + 从驱动的角度看,RegulatorNode结构体是参数和数据的载体,HDF框架通过DeviceResourceIface将regulator\_config.hcs文件中的数值读入其中。 + + ``` + // RegulatorNode是核心层控制器结构体,其中的成员在Init函数中会被赋值 + struct RegulatorNode { + struct RegulatorDesc regulatorInfo; + struct DListHead node; + struct RegulatorMethod *ops; + void *priv; + struct OsalMutex lock; + }; + + struct RegulatorDesc { + const char *name; /* regulator 名称 */ + const char *parentName; /* regulator 父节点名称 */ + struct RegulatorConstraints constraints; /* regulator 约束信息 */ + uint32_t minUv; /* 最小输出电压值 */ + uint32_t maxUv; /* 最大输出电压值 */ + uint32_t minUa; /* 最小输出电流值 */ + uint32_t maxUa; /* 最大输出电流值 */ + uint32_t status; /* regulator的状态,开或关 */ + int useCount; + int consumerRegNums; /* regulator用户数量 */ + RegulatorStatusChangecb cb; /* 当regulator状态改变时,可通过此变量通知 */ + }; + + struct RegulatorConstraints { + uint8_t alwaysOn; /* regulator是否常开 */ + uint8_t mode; /* 模式:电压或者电流 */ + uint32_t minUv; /* 最小可设置输出电压 */ + uint32_t maxUv; /* 最大可设置输出电压 */ + uint32_t minUa; /* 最小可设置输出电流 */ + uint32_t maxUa; /* 最大可设置输出电流 */ + }; + ``` + + + + - 实例化RegulatorNode成员RegulatorMethod,其他成员在Init函数中初始化。 + + ```c + // regulator_virtual.c 中的示例:钩子函数的填充 + static struct RegulatorMethod g_method = { + .enable = VirtualRegulatorEnable, + .disable = VirtualRegulatorDisable, + .setVoltage = VirtualRegulatorSetVoltage, + .getVoltage = VirtualRegulatorGetVoltage, + .setCurrent = VirtualRegulatorSetCurrent, + .getCurrent = VirtualRegulatorGetCurrent, + .getStatus = VirtualRegulatorGetStatus, + }; + ``` + + + + - Init函数参考 + 入参: - - HdfDeviceObject是整个驱动对外暴露的接口参数,其包含了HCS配置文件中的相关配置信息。 - + + HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 + 返回值: - - 无。 - - 函数说明: - - 释放内存和删除控制器,该函数需要在驱动入口结构体中赋值给Release接口,当HDF框架调用Init函数初始化驱动失败时,可以调用Release释放驱动资源。 - + + HDF\_STATUS相关状态 (下表为部分展示,如需使用其他状态,可见//drivers/framework/include/utils/hdf\_base.h中HDF\_STATUS 定义)。 + + **表 2** HDF\_STATUS相关状态 + + | 状态(值) | 问题描述 | + | ---------------------- | -------------- | + | HDF_ERR_INVALID_OBJECT | 控制器对象非法 | + | HDF_ERR_MALLOC_FAIL | 内存分配失败 | + | HDF_ERR_INVALID_PARAM | 参数非法 | + | HDF_ERR_IO | I/O 错误 | + | HDF_SUCCESS | 初始化成功 | + | HDF_FAILURE | 初始化失败 | + + 函数说明: + + 初始化自定义结构体和RegulatorNode成员,并通过调用核心层RegulatorNodeAdd函数挂载Regulator控制器。 + + ```c + static int32_t VirtualRegulatorInit(struct HdfDeviceObject *device) + { + int32_t ret; + const struct DeviceResourceNode *childNode = NULL; + ... + DEV_RES_NODE_FOR_EACH_CHILD_NODE(device->property, childNode) { + ret = VirtualRegulatorParseAndInit(device, childNode);//【必要】实现见下 + ... + } + ... + } + + static int32_t VirtualRegulatorParseAndInit(struct HdfDeviceObject *device, const struct DeviceResourceNode *node) + { + int32_t ret; + struct RegulatorNode *regNode = NULL; + (void)device; + + regNode = (struct RegulatorNode *)OsalMemCalloc(sizeof(*regNode));//加载HCS文件 + ... + ret = VirtualRegulatorReadHcs(regNode, node);//读取HCS文件信息 + ... + regNode->priv = (void *)node; //实例化节点 + regNode->ops = &g_method; //实例化ops + + ret = RegulatorNodeAdd(regNode); //挂载节点 + ... + } + ``` + + - Release 函数参考 + + 入参: + + HdfDeviceObject是整个驱动对外暴露的接口参数,其包含了HCS配置文件中的相关配置信息。 + + 返回值: + + 无。 + + 函数说明: + + 释放内存和删除控制器,该函数需要在驱动入口结构体中赋值给Release接口,当HDF框架调用Init函数 初始化驱动失败时,可以调用Release释放驱动资源。 + ```c static void VirtualRegulatorRelease(struct HdfDeviceObject *device) { ... RegulatorNodeRemoveAll();//【必要】调用核心层函数,释放RegulatorNode的设备和服务 } + ``` + +4. **驱动调试:** + + 【可选】针对新增驱动程序,建议验证驱动基本功能,例如挂载后的测试用例是否成功等。 + + diff --git "a/zh-cn/device-dev/driver/figures/ADM\345\220\257\345\212\250\346\265\201\347\250\213\345\233\276.png" "b/zh-cn/device-dev/driver/figures/ADM\345\220\257\345\212\250\346\265\201\347\250\213\345\233\276.png" index aa9044c2e0d345da6f52ac4209d8dba8bf357f79..1f84fdc77743b6b6861176db1ecf4affc8203661 100644 Binary files "a/zh-cn/device-dev/driver/figures/ADM\345\220\257\345\212\250\346\265\201\347\250\213\345\233\276.png" and "b/zh-cn/device-dev/driver/figures/ADM\345\220\257\345\212\250\346\265\201\347\250\213\345\233\276.png" differ diff --git "a/zh-cn/device-dev/driver/figures/ADM\346\216\247\345\210\266\346\265\201\347\250\213\345\233\276.png" "b/zh-cn/device-dev/driver/figures/ADM\346\216\247\345\210\266\346\265\201\347\250\213\345\233\276.png" index 9f43c4f6510359d84d11c056ec7b0bcde705cf3c..160f4869578f452e790bcf9fe0605257adc6b556 100644 Binary files "a/zh-cn/device-dev/driver/figures/ADM\346\216\247\345\210\266\346\265\201\347\250\213\345\233\276.png" and "b/zh-cn/device-dev/driver/figures/ADM\346\216\247\345\210\266\346\265\201\347\250\213\345\233\276.png" differ diff --git "a/zh-cn/device-dev/driver/figures/ADM\346\222\255\346\224\276\346\265\201\347\250\213\345\233\276.png" "b/zh-cn/device-dev/driver/figures/ADM\346\222\255\346\224\276\346\265\201\347\250\213\345\233\276.png" index 66891974d7202a641a268b611066b1ee988fe162..e3d3b1f9e1038dd77a7fd03841a0f7e75ead6710 100644 Binary files "a/zh-cn/device-dev/driver/figures/ADM\346\222\255\346\224\276\346\265\201\347\250\213\345\233\276.png" and "b/zh-cn/device-dev/driver/figures/ADM\346\222\255\346\224\276\346\265\201\347\250\213\345\233\276.png" differ diff --git "a/zh-cn/device-dev/driver/figures/Audio\346\241\206\346\236\266\345\233\276.png" "b/zh-cn/device-dev/driver/figures/Audio\346\241\206\346\236\266\345\233\276.png" index 07b4c54a4100620f2d469922c6979ba03acea654..248ea1854492ca3d2c02fb5a1be1fd5d4ef408a8 100644 Binary files "a/zh-cn/device-dev/driver/figures/Audio\346\241\206\346\236\266\345\233\276.png" and "b/zh-cn/device-dev/driver/figures/Audio\346\241\206\346\236\266\345\233\276.png" differ diff --git "a/zh-cn/device-dev/driver/figures/HAL\346\265\201\347\250\213\345\233\276.png" "b/zh-cn/device-dev/driver/figures/HAL\346\265\201\347\250\213\345\233\276.png" index eb3cc69a0d77910e74f38403cfd0ec3b1e727994..2982822ddb3a2d223bd083d506722d2a1befdcfa 100644 Binary files "a/zh-cn/device-dev/driver/figures/HAL\346\265\201\347\250\213\345\233\276.png" and "b/zh-cn/device-dev/driver/figures/HAL\346\265\201\347\250\213\345\233\276.png" differ diff --git "a/zh-cn/device-dev/driver/figures/\345\274\200\345\217\221\346\265\201\347\250\213\345\233\2761.png" "b/zh-cn/device-dev/driver/figures/\345\274\200\345\217\221\346\265\201\347\250\213\345\233\2761.png" index 37afe238749f8f77174cb84951f14f4862a3b49e..86ecc439e05220d80fd97013f20b7e9fe6f5e5b1 100644 Binary files "a/zh-cn/device-dev/driver/figures/\345\274\200\345\217\221\346\265\201\347\250\213\345\233\2761.png" and "b/zh-cn/device-dev/driver/figures/\345\274\200\345\217\221\346\265\201\347\250\213\345\233\2761.png" differ diff --git "a/zh-cn/device-dev/driver/figures/\345\274\200\345\217\221\346\265\201\347\250\213\345\233\2762.png" "b/zh-cn/device-dev/driver/figures/\345\274\200\345\217\221\346\265\201\347\250\213\345\233\2762.png" index 713903a37d72853cb7b487772ff71454df9abe5d..69cea74987a148b02fa708de7a9aed16c2d364ed 100644 Binary files "a/zh-cn/device-dev/driver/figures/\345\274\200\345\217\221\346\265\201\347\250\213\345\233\2762.png" and "b/zh-cn/device-dev/driver/figures/\345\274\200\345\217\221\346\265\201\347\250\213\345\233\2762.png" differ diff --git a/zh-cn/device-dev/faqs/faqs-kernel.md b/zh-cn/device-dev/faqs/faqs-kernel.md index 28c3fe078d00ef632a8d5463f793eb6907f73a92..54a99ff1aed4103c770e98c5295a8e4ca5c08f61 100644 --- a/zh-cn/device-dev/faqs/faqs-kernel.md +++ b/zh-cn/device-dev/faqs/faqs-kernel.md @@ -1,27 +1,5 @@ # 内核常见问题 -- [基础内核](#section263912372168) - - [LiteOS-A和LiteOS-M内核对外API的差异](#section447571122918) - - [如何分析线程栈溢出](#section8623141711293) - -- [文件系统](#section098519592162) - - [Hi3516开源板以写的模式打开同一个文件失败(LiteOS-A)](#section517972255311) - - [LiteOS内核已支持哪些硬件平台](#section868413518533) - - [LiteOS内核已支持哪几款芯片架构](#section1131661465417) - -- [三方组件](#section971818231178) - - [OpenHarmony已支持哪些三方组件](#section74138185411) - - [在OpenHarmony上使用OpenSSL,出现秘钥长度校验不正确](#section10564614135516) - - [setsockopt是否支持SO\_RCVBUF和SO\_SNDBUF选项](#section2093373215556) - -- [编译链接](#section10955302179) - - [Arm Linux开发的应用程序,OpenHarmony如何在LiteOS-A上运行](#section1164175713557) - - [OpenHarmony在什么系统下编译,使用什么编译器](#section132287223567) - - [LiteOS-M上使用单独编译成静态库的三方组件,出现三方组件中的全局变量值不正确,或调用三方组件的函数后系统卡死](#section15189154225619) - - [LiteOS-A生成目标可执行文件时,提示 use VFP register arguments,xxx.o does not](#section193571012578) - - [clock\_gettime接口获取的时间打印不对](#section8973152015717) - - ## 基础内核 ### LiteOS-A和LiteOS-M内核对外API的差异 @@ -48,7 +26,7 @@ Hi3516开源板使用FAT文件系统,不允许该操作。 ### LiteOS内核已支持哪些硬件平台 -开源版本LiteOS-A已支持Hi3516/Hi3518开发板;LiteOS-M已支持Hi3861开发板、STM32F103、野火挑战者STM32F429IGTb、Nucleo\_f767zi等,详细查看kernel/liteos\_m目录下的README\_zh.md文件。 +开源版本LiteOS-A已支持Hi3516/Hi3518开发板;LiteOS-M已支持Hi3861开发板、Nucleo\_f767zi等,详细查看kernel/liteos\_m目录下的README\_zh.md文件。 ### LiteOS内核已支持哪几款芯片架构 diff --git a/zh-cn/device-dev/get-code/gettools-acquire.md b/zh-cn/device-dev/get-code/gettools-acquire.md index 7471a02fe2edd29f78b398dc982e68e6c9e7e54d..ded916b192889b065e7b4d4c0870408a06a76c3c 100644 --- a/zh-cn/device-dev/get-code/gettools-acquire.md +++ b/zh-cn/device-dev/get-code/gettools-acquire.md @@ -165,7 +165,7 @@ hb set ## 基于HPM的Docker环境 -docker\_dist是一个[HPM](https://hpm.harmonyos.com/)系统中的模板组件,能够帮助用户快速初始化HPM工程,利用docker镜像来快速编译OpenHarmony发行版,在很大程度上简化了编译前的环境配置。开发者在配置好Ubuntu和[hpm-cli](../bundles/hpm-part-development.md)开发环境后,可以通过以下步骤来使用我们提供的Docker环境。 +docker\_dist是一个[HPM](https://hpm.harmonyos.com/)系统中的模板组件,能够帮助用户快速初始化HPM工程,利用docker镜像来快速编译OpenHarmony发行版,在很大程度上简化了编译前的环境配置。开发者在配置好Ubuntu和[hpm-cli](../hpm-part/hpm-part-development.md)开发环境后,可以通过以下步骤来使用我们提供的Docker环境。 ### 搭建Docker环境 diff --git a/zh-cn/device-dev/bundles/Readme-CN.md b/zh-cn/device-dev/hpm-part/Readme-CN.md old mode 100755 new mode 100644 similarity index 91% rename from zh-cn/device-dev/bundles/Readme-CN.md rename to zh-cn/device-dev/hpm-part/Readme-CN.md index 4a7a1144571eb01cd817465f366e8d4b6cca5f40..0b199f9e743850fdebe2ee6747bda9ea7abaa51e --- a/zh-cn/device-dev/bundles/Readme-CN.md +++ b/zh-cn/device-dev/hpm-part/Readme-CN.md @@ -1,5 +1,6 @@ -# bundles +# HPM Part - [HPM Part介绍](hpm-part-about.md) - [HPM Part开发指导](hpm-part-development.md) - [HPM Part参考](hpm-part-reference.md) + diff --git a/zh-cn/device-dev/hpm-part/figures/zh-cn_image_0000001195369804.png b/zh-cn/device-dev/hpm-part/figures/zh-cn_image_0000001195369804.png new file mode 100644 index 0000000000000000000000000000000000000000..74709a0e975b0c339179bbab1df1fc83127af515 Binary files /dev/null and b/zh-cn/device-dev/hpm-part/figures/zh-cn_image_0000001195369804.png differ diff --git a/zh-cn/device-dev/bundles/figures/zh-cn_image_0000001217486680.png b/zh-cn/device-dev/hpm-part/figures/zh-cn_image_0000001217486680.png similarity index 100% rename from zh-cn/device-dev/bundles/figures/zh-cn_image_0000001217486680.png rename to zh-cn/device-dev/hpm-part/figures/zh-cn_image_0000001217486680.png diff --git a/zh-cn/device-dev/bundles/figures/zh-cn_image_0000001240409717.png b/zh-cn/device-dev/hpm-part/figures/zh-cn_image_0000001240409717.png similarity index 100% rename from zh-cn/device-dev/bundles/figures/zh-cn_image_0000001240409717.png rename to zh-cn/device-dev/hpm-part/figures/zh-cn_image_0000001240409717.png diff --git a/zh-cn/device-dev/bundles/figures/zh-cn_image_0000001262166533.png b/zh-cn/device-dev/hpm-part/figures/zh-cn_image_0000001262166533.png similarity index 100% rename from zh-cn/device-dev/bundles/figures/zh-cn_image_0000001262166533.png rename to zh-cn/device-dev/hpm-part/figures/zh-cn_image_0000001262166533.png diff --git a/zh-cn/device-dev/bundles/hpm-part-about.md b/zh-cn/device-dev/hpm-part/hpm-part-about.md similarity index 100% rename from zh-cn/device-dev/bundles/hpm-part-about.md rename to zh-cn/device-dev/hpm-part/hpm-part-about.md diff --git a/zh-cn/device-dev/bundles/hpm-part-development.md b/zh-cn/device-dev/hpm-part/hpm-part-development.md similarity index 100% rename from zh-cn/device-dev/bundles/hpm-part-development.md rename to zh-cn/device-dev/hpm-part/hpm-part-development.md diff --git a/zh-cn/device-dev/bundles/hpm-part-reference.md b/zh-cn/device-dev/hpm-part/hpm-part-reference.md similarity index 99% rename from zh-cn/device-dev/bundles/hpm-part-reference.md rename to zh-cn/device-dev/hpm-part/hpm-part-reference.md index 17b0f2cc443fe6bcd381c0e837a71a5c8b400d13..68ba5bae2ca3bdb83015e71261e729b80767523c 100644 --- a/zh-cn/device-dev/bundles/hpm-part-reference.md +++ b/zh-cn/device-dev/hpm-part/hpm-part-reference.md @@ -242,7 +242,7 @@ Part的依赖关系(包括间接依赖)可以通过hpm list命令显示( ``` $ hpm list +--demo@1.0.0 -| +--@huawei/media@1.0.2 +| +--@example/media@1.0.2 | +--@demo/sport_hi3518ev300_liteos_a@1.0.0 | | +--@demo/app@4.0.1 | | | +--@demo/build@4.0.1 diff --git a/zh-cn/device-dev/hpm-part/public_sys-resources/icon-caution.gif b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-caution.gif differ diff --git a/zh-cn/device-dev/hpm-part/public_sys-resources/icon-danger.gif b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-danger.gif differ diff --git a/zh-cn/device-dev/hpm-part/public_sys-resources/icon-note.gif b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-note.gif differ diff --git a/zh-cn/device-dev/hpm-part/public_sys-resources/icon-notice.gif b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-notice.gif differ diff --git a/zh-cn/device-dev/hpm-part/public_sys-resources/icon-tip.gif b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-tip.gif differ diff --git a/zh-cn/device-dev/hpm-part/public_sys-resources/icon-warning.gif b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/device-dev/hpm-part/public_sys-resources/icon-warning.gif differ diff --git a/zh-cn/device-dev/kernel/kernel-standard-mm-eswap.md b/zh-cn/device-dev/kernel/kernel-standard-mm-eswap.md index 1550ae7e4e3c35b6745845d3c56262f55554e3fd..ee4710c4969d18c16fff260c82e6de6d17d9527d 100644 --- a/zh-cn/device-dev/kernel/kernel-standard-mm-eswap.md +++ b/zh-cn/device-dev/kernel/kernel-standard-mm-eswap.md @@ -89,7 +89,7 @@ ESwap(Enhanced Swap)提供了自定义新增存储分区作为内存交换分区 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > /sys/block/zram0/group可接受参数及作用为: > - > - none:表示disable; + > - disable:表示disable; > - readonly:表示只记录数据的cgroup信息,并不换出; > - readwrite:表示打开ZRAM到eswap的换入换出功能。 @@ -120,6 +120,8 @@ ESwap(Enhanced Swap)提供了自定义新增存储分区作为内存交换分区 2. 关闭ZRAM及ZRAM group ```Bash + // 若已经执行过swapon,则需先执行swapoff + swapoff /dev/block/zram0 echo 1 > /sys/block/zram0/reset ``` diff --git a/zh-cn/device-dev/porting/Readme-CN.md b/zh-cn/device-dev/porting/Readme-CN.md index 8154f0b712fd9c0823295e897d14b69a796d61e0..014cfa66bcf060783e552542de6a7f9f859dee8b 100755 --- a/zh-cn/device-dev/porting/Readme-CN.md +++ b/zh-cn/device-dev/porting/Readme-CN.md @@ -52,7 +52,7 @@ repo init -u https://gitee.com/openharmony-sig/manifest.git -b master -m devboar - [标准系统芯片移植指导](standard-system-porting-guide.md) - [标准系统移植指南](standard-system-porting-guide.md) - [一种快速移植OpenHarmony Linux内核的方法](porting-linux-kernel.md) -- [轻量和小型系统三方库移植指导]( porting-thirdparty.md) +- [轻量和小型系统三方库移植指导](porting-thirdparty.md) - [概述](porting-thirdparty-overview.md) - [CMake方式组织编译的库移植](porting-thirdparty-cmake.md) - [Makefile方式组织编译的库移植](porting-thirdparty-makefile.md) diff --git a/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md b/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md index b65533df179d3078518e6d089a5f662f5e93c75a..795d9534a38a108150185689518a2263db889e1f 100644 --- a/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md +++ b/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md @@ -294,7 +294,15 @@ if (ohos_kernel_type == "liteos_m") { --- 由于多内核设 ### 内核启动适配 -内核启动适配的文件路径在 `//device/soc/bestechnic/bes2600/liteos_m/sdk/bsp/rtos/liteos/liteos_m/board.c` +系统启动流程分为三个阶段: + +| 阶段名称 | 分区规划 | 描述 | +| --------- | ------------------------ | ----------------------------- | +| BOOT1 | [0, 0x10000] | 第一阶段启动,进行固件启动 | +| BOOT2 | [0x2C010000, 0x2C020000] | 第二阶段启动,进行OTA升级启动 | +| RTOS_MAIN | [0x2C080000, 0x2C860000] | 第三阶段启动,进行内核启动 | + +在第三阶段内核启动中,需要适配的文件路径在 `//device/soc/bestechnic/bes2600/liteos_m/sdk/bsp/rtos/liteos/liteos_m/board.c` 内核启动适配总体思路如下: @@ -332,7 +340,7 @@ int OhosSystemAdapterHooks(void) ### littlefs文件系统移植 -文件系统使用的是`littlefs`,适配过程中,需要在指定路径下放置文件系统预置文件,根据配置可自动生成文件系统镜像,可以实现自动化生成和打包到烧录包中。 + `V200Z-R`开发板开发板采用最大`32MB`的支持`XIP`的`Nor Flash`,文件系统可以使用`example`,适配过程中,需要在指定路径下放置文件系统预置文件,根据配置可自动生成文件系统镜像,可以实现自动化生成和打包到烧录包中。 1. 配置指定目录放置打包文件系统`config.json`,通过`flash_partition_dir`指定目录: @@ -359,7 +367,7 @@ int OhosSystemAdapterHooks(void) ``` misc { fs_config { - littlefs_config { + example_config { match_attr = "littlefs_config"; mount_points = ["/data"]; partitions = [10]; @@ -613,7 +621,7 @@ static int32_t PanelDriverInit(struct HdfDeviceObject *object) - 在`config.json`中增加对应子系统和部件,这样编译系统会将该部件纳入编译目标中。 - 针对该部件的`HAL`层接口进行硬件适配,或者可选的软件功能适配。 -#### communication子系统适配 +#### 分布式软总线子系统适配 ##### wifi_lite部件适配 @@ -787,13 +795,126 @@ ethernetif_init(struct netif *netif) } ``` -#### 系统基本能力适配 +##### dsoftbus部件适配 + +在`config.json`中增加`dsoftbus`部件配置如下: + +``` +{ + "component": "dsoftbus", + "features": [ + "softbus_adapter_config = \"//vendor/bestechnic/mini_distributed_music_player/dsoftbus_lite_config\"" + ] +}, +``` + +`dsoftbus`部件在`//foundation/communication/dsoftbus/dsoftbus.gni`文件中提供了`softbus_adapter_config`配置选项可供移植过程进行配置,该配置设定了软总线移植适配的路径。 + +在本案例中,`softbus_adapter_config`配置为`//vendor/bestechnic/mini_distributed_music_player/dsoftbus_lite_config`路径,该路径下的内容为: + +``` +. +├── feature_config --- 软总线功能特性配置,例如是否开启自发现功能等 +│   └── mini +│   └── config.gni +└── spec_config --- 软总线规格特性配置,例如设置软总线日志级别设置 + ├── softbus_config_adapter.c + ├── softbus_config_adapter.h + └── softbus_config_type.h +``` + +在`config.gni`文件中规定了以下配置项: + +| 配置项 | 描述 | +| ------------------------------------------ | ------------------------ | +| dsoftbus_standard_feature_disc_ble | 是否开启BLE发现功能 | +| dsoftbus_standard_feature_disc_coap | 是否开启COAP发现功能 | +| dsoftbus_standard_feature_conn_tcp | 是否开启TCP连接功能 | +| dsoftbus_standard_feature_conn_br | 是否开启BR连接功能 | +| dsoftbus_standard_feature_conn_ble | 是否开启BLE连接功能 | +| dsoftbus_standard_feature_conn_p2p | 是否开启P2P连接功能 | +| dsoftbus_standard_feature_trans_udp | 是否开启UDP传输功能 | +| dsoftbus_standard_feature_trans_udp_stream | 是否开启UDP传输流功能 | +| dsoftbus_standard_feature_trans_udp_file | 是否开启UDP传输文件功能 | +| dsoftbus_standard_feature_ip_auth | 是否开启认证传输通道功能 | +| dsoftbus_standard_feature_auth_account | 是否开启基于账号认证功能 | +| dsoftbus_standard_feature_qos | 是否开启QoS功能 | + +在`softbus_config_adapter.c`文件中规定了以下配置项: + +| 配置项 | 描述 | +| ------------------------------------ | ----------------------------- | +| SOFTBUS_INT_MAX_BYTES_LENGTH | SendBytes发送最大Bytes长度 | +| SOFTBUS_INT_MAX_MESSAGE_LENGTH | SendMessage发送最大消息的长度 | +| SOFTBUS_INT_CONN_BR_MAX_DATA_LENGTH | 蓝牙最大接收数据量 | +| SOFTBUS_INT_CONN_RFCOM_SEND_MAX_LEN | 蓝牙最大接收数据量 | +| SOFTBUS_INT_ADAPTER_LOG_LEVEL | 日志级别设置 | +| SOFTBUS_STR_STORAGE_DIRECTORY | 存储目录设置 | + +因为软总线配置了后,不会默认启动,所以需要在通过启动框架调用`InitSoftBusServer`函数,如下: + +``` +static void DSoftBus(void) +{ + osThreadAttr_t attr; + attr.name = "dsoftbus task"; + attr.attr_bits = 0U; + attr.cb_mem = NULL; + attr.cb_size = 0U; + attr.stack_mem = NULL; + attr.stack_size = 65536; + attr.priority = 24; + + extern void InitSoftBusServer(void); + if (osThreadNew((osThreadFunc_t) InitSoftBusServer, NULL, &attr) == NULL) { + printf("Falied to create WifiSTATask!\n"); + } +} + +APP_FEATURE_INIT(DSoftBus); +``` + +##### RPC部件适配 -本小节主要从移植的角度出发,分析适配过程中,需要操作或者注意的事项。 +在`config.json`中增加`rpc`部件配置如下: -##### startup子系统适配 +``` +{ + "component": "rpc" +}, +``` -``startup`子系统适配`bootstrap_lite`/`syspara_lite`两个部件。请在`vendor/bestechnic_bak/display_demo/config.json`中新增对应的配置选项。 +同样地,`rpc`部件需要通过启动框架调用`StartDBinderService`函数,由于该函数正常运行依赖主机已经获取`IP`地址,因此在`LWIP`协议栈注册`IP`地址变化事件的回调函数中调用该函数,如下: + +``` +static void RpcServerWifiDHCPSucCB(struct netif *netif, netif_nsc_reason_t reason, + const netif_ext_callback_args_t *args) +{ + (void) args; + if (netif == NULL) { + printf("%s %d, error: input netif is NULL!\n", __FUNCTION__, __LINE__); + return; + } + if (reason == LWIP_NSC_IPSTATUS_CHANGE) { + if (netif_is_up(netif) && !ip_addr_isany(&netif->ip_addr)) { + printf("%s %d, start rpc server!\n", __FUNCTION__, __LINE__); + StartDBinderService(); + } + } +} + +static void WifiDHCPRpcServerCB(void) +{ + NETIF_DECLARE_EXT_CALLBACK(WifiReadyRpcServerCallback); + netif_add_ext_callback(&WifiReadyRpcServerCallback, RpcServerWifiDHCPSucCB); +} + +APP_FEATURE_INIT(WifiDHCPRpcServerCB); +``` + +#### 启动恢复子系统适配 + +启动恢复子系统适配`bootstrap_lite`/`syspara_lite`两个部件。请在`vendor/bestechnic_bak/display_demo/config.json`中新增对应的配置选项。 ``` { @@ -1014,11 +1135,9 @@ const char* HalGetSerial(void) } ``` +#### DFX子系统适配 - -##### hiviewdfx子系统适配 - -进行`hiviewdfx`子系统适配需要添加`hilog_lite`部件,直接在`config.json`文件配置即可。 +进行`DFX`子系统适配需要添加`hilog_lite`部件,直接在`config.json`文件配置即可。 ``` { @@ -1047,9 +1166,9 @@ boolean HilogProc_Impl(const HiLogContent *hilogContent, uint32 len) HiviewRegisterHilogProc(HilogProc_Impl); ``` -##### distributedschedule子系统适配 +#### 系统服务管理子系统适配 -进行`distributedschedule`子系统适配需要添加`samgr_lite`部件,直接在`config.json`配置即可。 +进行系统服务管理子系统适配需要添加`samgr_lite`部件,直接在`config.json`配置即可。 ``` { @@ -1067,9 +1186,72 @@ HiviewRegisterHilogProc(HilogProc_Impl); 在轻量系统中,`samgr_lite`配置的共享任务栈大小默认为`0x800`。当函数调用栈较大时,会出现栈溢出的问题。在本次适配过程中,将其调整为`0x1000`。 -##### utils子系统适配 +#### 安全子系统适配 -进行`utils`子系统适配需要添加`kv_store`/`js_builtin`/`timer_task`/`kal_timer`部件,直接在`config.json`配置即可。 +进行安全子系统适配需要添加`huks/deviceauth_lite`部件,直接在`config.json`配置即可。 + +``` + { + "subsystem": "security", + "components": [ + { + "component": "huks", + "features": [ + "huks_use_lite_storage = true", + "huks_use_hardware_root_key = true", + "huks_config_file = \"hks_config_lite.h\"", + "huks_key_store_path = \"/data/\"", + "ohos_security_huks_mbedtls_porting_path = \"//device/soc/bestechnic/hals/mbedtls\"" + ] + }, + { + "component": "deviceauth_lite", + "features": [ + "deviceauth_storage_path = \"/data/\"", + "deviceauth_hichain_thread_stack_size = 9472" + ] + } + ] + } +``` + +`huks`部件适配时,`huks_key_store_path`配置选项用于指定存放秘钥路径,`ohos_security_huks_mbedtls_porting_path`配置选项用于指定进行`mbedtls`适配的目录,用于芯片对`mbedtls`进行硬件随机数等适配。 + +`deviceauth_lite`部件适配时,`deviceauth_storage_path`配置选项用于指定存放设备认证信息的路径,`deviceauth_hichain_thread_stack_size`用于指定线程栈大小。 + +#### 媒体子系统适配 + +进行媒体子系统适配需要添加`histreamer`部件,直接在`config.json`配置即可。 + +``` +{ + "subsystem": "multimedia", + "components": [ + { + "component": "histreamer", + "features": [ + "multimedia_histreamer_enable_plugin_hdi_adapter = true", + "multimedia_histreamer_enable_plugin_minimp3_adapter = true", + "multimedia_histreamer_enable_plugin_ffmpeg_adapter = false", + "config_ohos_multimedia_histreamer_stack_size = 65536" + ] + } + ] +}, +``` + +`histreamer`部件配置项说明如下: + +| 配置项 | 说明 | +| --------------------------------------------------- | ------------------------------- | +| multimedia_histreamer_enable_plugin_hdi_adapter | 是否使能histreamer对接到hdi接口 | +| multimedia_histreamer_enable_plugin_minimp3_adapter | 是否使能插件适配minimp3 | +| multimedia_histreamer_enable_plugin_ffmpeg_adapter | 是否使能插件适配FFmpeg | +| config_ohos_multimedia_histreamer_stack_size | histreamer栈大小设置 | + +#### 公共基础库子系统适配 + +进行公共基础库子系统适配需要添加`kv_store`/`js_builtin`/`timer_task`/`kal_timer`部件,直接在`config.json`配置即可。 ``` { @@ -1096,11 +1278,9 @@ HiviewRegisterHilogProc(HilogProc_Impl); 与适配`syspara_lite`部件类似,适配`kv_store`部件时,键值对会写到文件中。在轻量系统中,文件操作相关接口有`POSIX`接口与`HalFiles`接口这两套实现。因为对接内核的文件系统,采用`POSIX`相关的接口,所以`features`需要增加`enable_ohos_utils_native_lite_kv_store_use_posix_kv_api = true`。如果对接`HalFiles`相关的接口实现的,则无须修改。 -#### 图形显示子系统适配 - -##### graphic子系统适配 +#### 图形子系统适配 -进行`graphic`子系统适配需要添加`graphic_utils`部件,直接在`config.json`配置即可。 +进行图形子系统适配需要添加`graphic_utils`部件,直接在`config.json`配置即可。 ``` "components": [ @@ -1125,10 +1305,10 @@ HiviewRegisterHilogProc(HilogProc_Impl); - `touch_input`:实例化`PointerInputDevice`。 - `UiMainTask`:初始化字体引擎,执行渲染任务等。 -`graphic`子系统层次: +图形子系统层次: ``` -aafwk_lite + appexecfwk_lite (AMS + BMS) +aafwk_lite + appexecfwk_lite (AAFWK + APPEXECFWK) | ace_engine_lite + jerryscript + i18n_lite + resmgr_lite + utils/native/lite/... (ACE,JS引擎及其依赖) | @@ -1158,9 +1338,9 @@ void AppEntry(void) APP_FEATURE_INIT(AppEntry); ``` -##### ace子系统适配 +#### ACE开发框架子系统适配 -进行`ace`子系统适配需要添加`ace_engine_lite`部件,直接在`config.json`配置即可。 +进行`ACE`开发框架子系统适配需要添加`ace_engine_lite`部件,直接在`config.json`配置即可。 { "subsystem": "ace", @@ -1192,9 +1372,9 @@ APP_FEATURE_INIT(AppEntry); 4. 最终编译生成系统镜像,烧录到单板后,系统会从`app.js`加载启动`ace`的应用。 -##### aafwk子系统适配 +#### 元能力子系统适配 -进行`aafwk`子系统适配需要添加`aafwk_lite`部件,直接在`config.json`配置即可。 +进行元能力子系统适配需要添加`aafwk_lite`部件,直接在`config.json`配置即可。 ``` { @@ -1204,7 +1384,7 @@ APP_FEATURE_INIT(AppEntry); "component": "aafwk_lite", "features": [ "enable_ohos_appexecfwk_feature_ability = true", --- 支持FA特性,即包含图形能力 - "config_ohos_aafwk_ams_task_size = 4096" --- 配置ams栈的大小 + "config_ohos_aafwk_ams_task_size = 4096" --- 配置aafwk栈的大小 ] } ] @@ -1213,14 +1393,14 @@ APP_FEATURE_INIT(AppEntry); `aafwk_lite`相关的应用样例见`vendor/bestechnic/display_demo/tests/ability`目录,包含`launcher`和`js app`这两类应用,应用的函数调用流程描述如下: -1. `launcher`应用,通过`InstallLauncher`安装`BundleName`为 `"com.huawei.launcher"`的`native ui`应用,在`AbilityMgrSliteFeature`启动后会调用`AbilityMgrHandler::StartLauncher()`启动`launcher`应用。 +1. `launcher`应用,通过`InstallLauncher`安装`BundleName`为 `"com.example.launcher"`的`native ui`应用,在`AbilityMgrSliteFeature`启动后会调用`AbilityMgrHandler::StartLauncher()`启动`launcher`应用。 2. `StartJSApp`应用,通过`StartAbility`启动任意`Want`,通过将`want data`传递`JS_APP_PATH`, `SetWantData(&want, JS_APP_PATH, strlen(JS_APP_PATH) + 1)`。 -##### appexecfwk子系统适配 +#### 包管理子系统适配 -进行`appexecfwk`子系统适配需要添加`appexecfwk_lite`部件,直接在`config.json`配置即可。 +进行包管理子系统适配需要添加`appexecfwk_lite`部件,直接在`config.json`配置即可。 ``` { @@ -1293,8 +1473,7 @@ APP_FEATURE_INIT(AppEntry); - 蓝牙 - `bms`包安装 -- 音频播放 - 验证运行`JS`的`bytecode` -- 分布式能力:`dsoftbus`、`dms`、`dm` +- 分布式能力:`dms`、`dm` - 分布式音乐播放器样例 diff --git a/zh-cn/device-dev/porting/porting-linux-kernel.md b/zh-cn/device-dev/porting/porting-linux-kernel.md index 1139514ab02e862a9d5e2a59ff9bcecab4c640c1..f54b3a7b8d3ebb42b858459d7783f44e0423f85b 100644 --- a/zh-cn/device-dev/porting/porting-linux-kernel.md +++ b/zh-cn/device-dev/porting/porting-linux-kernel.md @@ -1,16 +1,5 @@ # 一种快速移植OpenHarmony Linux内核的方法 -- [移植概述](#移植概述) -- [移植到三方芯片平台的整体思路](#移植到三方芯片平台的整体思路) - - [内核态层和用户态层](#内核态层和用户态层) - - [获得内核态层的两种方法](#获得内核态层的两种方法) - - [借助已有Linux内核来移植OpenHarmony的流程](#section1233187263176) -- [移植到三方芯片平台的步骤](#移植到三方芯片平台的步骤) - - [整体构建环境的准备](#整体构建环境的准备) - - [内核态基础代码的移植](#内核态基础代码的移植) - - [内核态必选特性HDF的移植](#内核态必选特性hdf的移植) - - [编译Image](#编译image) - - [编译和运行HDF测试用例(可选)](#编译和运行hdf测试用例-可选-) ## 移植概述 diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md b/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md index afd8bf414e2434f55a029860e2679a92ec4d2564..42c4c162fb6fd745b154dff2ac71c98e27f04eb5 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md @@ -1,8 +1,5 @@ # 使用安装包方式搭建编译环境 -- [安装必要的库和工具](#section108201740181219) -- [安装hb](#section15794154618411) -- [安装LLVM\(仅OpenHarmony\_v1.x分支/标签需要\)](#section711117144296) 使用安装包方式搭建Ubuntu编译环境步骤如下: @@ -46,7 +43,7 @@ sudo apt-get install build-essential gcc g++ make libffi-dev e2fsprogs pkg-confi source ~/.bashrc ``` -3. 执行"hb -h",界面打印以下信息即表示安装成功: +3. 在源码目录执行"hb -h",界面打印以下信息即表示安装成功: ``` usage: hb diff --git a/zh-cn/device-dev/subsystems/Readme-CN.md b/zh-cn/device-dev/subsystems/Readme-CN.md index 2b2082482827996a282ca733eadaccebc5605fbb..43b2be4edbde545d91c43a93b8040eb49ff5546b 100755 --- a/zh-cn/device-dev/subsystems/Readme-CN.md +++ b/zh-cn/device-dev/subsystems/Readme-CN.md @@ -71,6 +71,7 @@ - [应用权限管理开发指导](subsys-security-rightmanagement.md) - [IPC通信鉴权开发指导](subsys-security-communicationverify.md) - [设备安全等级管理开发指导](subsys-security-devicesecuritylevel.md) + - [密钥管理开发指导](subsys-security-huks.md) - [启动恢复](subsys-boot.md) - [启动恢复子系统概述](subsys-boot-overview.md) - [init启动引导组件](subsys-boot-init.md) diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide.md b/zh-cn/device-dev/subsystems/subsys-aiframework-devguide.md index 5de9fe721cbe94bd784c2b09bd70f3258a6af68e..2b749285030c67c8b2528b4ca0496841d7b645b8 100644 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide.md +++ b/zh-cn/device-dev/subsystems/subsys-aiframework-devguide.md @@ -1,6 +1,6 @@ # 开发指导 -为实现AI 引擎框架的接入,开发者需开发上述[图1](subsys-aiframework-guide.md#fig143186187187)中的SDK模块和Plugin模块,通过调用sdk提供的接口,基于AI引擎框架实现调用plugin中算法的能力,从而实现AI能力的生命周期管理和按需部署功能。 +为实现AI 引擎框架的接入,开发者需开发《AI引擎框架开发指南》[图1](subsys-aiframework-guide.md#fig143186187187)中的SDK模块和Plugin模块,通过调用sdk提供的接口,基于AI引擎框架实现调用plugin中算法的能力,从而实现AI能力的生命周期管理和按需部署功能。 - **[SDK开发过程](subsys-aiframework-devguide-sdk.md)** diff --git a/zh-cn/device-dev/subsystems/subsys-application-framework-envbuild.md b/zh-cn/device-dev/subsystems/subsys-application-framework-envbuild.md index e84d391fdfdcee5fe1c030720dcf6396ef88eb02..0d015bf975615463a85b066fc82815a84f0f95bd 100644 --- a/zh-cn/device-dev/subsystems/subsys-application-framework-envbuild.md +++ b/zh-cn/device-dev/subsystems/subsys-application-framework-envbuild.md @@ -3,5 +3,5 @@ - 开发板:Hi3516DV300 - [下载源码](../get-code/sourcecode-acquire.md) -- [编译用户程序框架](../../readme/用户程序框架子系统.md) +- [编译用户程序框架](../../readme/包管理子系统.md) diff --git a/zh-cn/device-dev/subsystems/subsys-boot-faqs.md b/zh-cn/device-dev/subsystems/subsys-boot-faqs.md index 49e36b3f762940e507236c9220c84caf6fc52d47..aa99975af2e18e7609139850230ade8b8ef894cc 100644 --- a/zh-cn/device-dev/subsystems/subsys-boot-faqs.md +++ b/zh-cn/device-dev/subsystems/subsys-boot-faqs.md @@ -29,7 +29,7 @@ **可能原因** -被init启动的服务都有一个叫做“importance”的属性(详见[第2章表3](subsys-boot-init.md#table14737791471)描述)。 +被init启动的服务都有一个叫做“importance”的属性(详见[init启动引导组件表3](subsys-boot-init.md#table14737791471)描述)。 - 当该属性为0时,表示若当前服务进程退出,init不需要重启单板。 - 当该属性为1时,表示若当前服务进程退出,init需要重启单板。 diff --git a/zh-cn/device-dev/subsystems/subsys-boot-overview.md b/zh-cn/device-dev/subsystems/subsys-boot-overview.md index 6e3379866f55012abe89428ae8ce74b6c1d1b68a..d1602e8d6ab69ec3de160e5eaba0b6e2bf202b50 100644 --- a/zh-cn/device-dev/subsystems/subsys-boot-overview.md +++ b/zh-cn/device-dev/subsystems/subsys-boot-overview.md @@ -23,7 +23,7 @@ - init启动引导组件 - init启动引导组件对应的进程为init进程,是内核完成初始化后启动的第一个用户态进程。init进程启动之后,读取init.cfg配置文件,根据解析结果,执行相应命令(见[第2章表2](subsys-boot-init.md#table122681439144112)描述)并依次启动各关键系统服务进程,在启动系统服务进程的同时设置其对应权限。 + init启动引导组件对应的进程为init进程,是内核完成初始化后启动的第一个用户态进程。init进程启动之后,读取init.cfg配置文件,根据解析结果,执行相应命令(见[init启动引导组件表2](subsys-boot-init.md#table122681439144112)描述)并依次启动各关键系统服务进程,在启动系统服务进程的同时设置其对应权限。 - ueventd启动引导组件 diff --git a/zh-cn/device-dev/subsystems/subsys-data-storage-guide.md b/zh-cn/device-dev/subsystems/subsys-data-storage-guide.md index 8d3f4e2725e8986d33f9e0c2b7a74748d47b24db..95e273f55e4d046db071815cd94629fff667cd4e 100755 --- a/zh-cn/device-dev/subsystems/subsys-data-storage-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-data-storage-guide.md @@ -165,7 +165,7 @@ 订阅数据变化,并触发执行回调方法: ``` C++ std::shared_ptr counter = - std::shared_ptr(new PreferencesObserverCounter()); + std::make_shared(); pref->RegisterObserver(counter); // 注册数据变化的回调。 pref->PutString(PreferencesTest::KEY_TEST_STRING_ELEMENT, "test"); diff --git a/zh-cn/device-dev/subsystems/subsys-testguide-test.md b/zh-cn/device-dev/subsystems/subsys-testguide-test.md index 3788200ef39dc7fac2e1b141fa81ffeb1496ecd3..83f4e683332845d5e48906ac2a14557de15bae0b 100644 --- a/zh-cn/device-dev/subsystems/subsys-testguide-test.md +++ b/zh-cn/device-dev/subsystems/subsys-testguide-test.md @@ -76,7 +76,7 @@ subsystem # 子系统 - 用例示例 ``` /* - * Copyright (c) 2021 XXXX Device Co., Ltd. + * Copyright (c) 2022 XXXX Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -142,7 +142,7 @@ subsystem # 子系统 1. 添加测试用例文件头注释信息 ``` /* - * Copyright (c) 2021 XXXX Device Co., Ltd. + * Copyright (c) 2022 XXXX Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -256,7 +256,7 @@ subsystem # 子系统 - 用例示例 ``` /* - * Copyright (C) 2021 XXXX Device Co., Ltd. + * Copyright (C) 2022 XXXX Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -313,7 +313,7 @@ subsystem # 子系统 1. 添加测试用例文件头注释信息 ``` /* - * Copyright (C) 2021 XXXX Device Co., Ltd. + * Copyright (C) 2022 XXXX Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -381,7 +381,7 @@ subsystem # 子系统 - **C++用例编译配置示例** ``` - # Copyright (c) 2021 XXXX Device Co., Ltd. + # Copyright (c) 2022 XXXX Device Co., Ltd. import("//build/test.gni") @@ -417,7 +417,7 @@ subsystem # 子系统 1. 添加文件头注释信息 ``` - # Copyright (c) 2021 XXXX Device Co., Ltd. + # Copyright (c) 2022 XXXX Device Co., Ltd. ``` 2. 导入编译模板文件 ``` @@ -483,7 +483,7 @@ subsystem # 子系统 - **JavaScript用例编译配置示例** ``` - # Copyright (C) 2021 XXXX Device Co., Ltd. + # Copyright (C) 2022 XXXX Device Co., Ltd. import("//build/test.gni") @@ -507,7 +507,7 @@ subsystem # 子系统 1. 添加文件头注释信息 ``` - # Copyright (C) 2021 XXXX Device Co., Ltd. + # Copyright (C) 2022 XXXX Device Co., Ltd. ``` 2. 导入编译模板文件 diff --git a/zh-cn/device-dev/subsystems/subsys-toolchain-hiperf.md b/zh-cn/device-dev/subsystems/subsys-toolchain-hiperf.md index f90216596234bac89303afbc7053b4b5b6988544..8a5476185d5eed517aeff04f49d4efc3e4f3f710 100644 --- a/zh-cn/device-dev/subsystems/subsys-toolchain-hiperf.md +++ b/zh-cn/device-dev/subsystems/subsys-toolchain-hiperf.md @@ -1,17 +1,6 @@ # hiperf 使用指南 -- [list 命令](#list-命令) - - [参数说明](#参数说明) - - [使用示例](#使用示例) -- [stat 命令](#stat-命令) - - [参数说明](#参数说明) - - [使用示例](#使用示例) - - [字段说明](#字段说明) -- [record 命令](#record-命令) - - [参数说明](#参数说明) - - [使用示例](#使用示例) -- [report 命令](#report-命令) -- [使用示例](#使用示例) + hiperf是为开发人员提供性能采样分析的工具,基于内核perf机制进行的用户态能力的扩展,可以对指定的程序或者整个系统进行性能采样。 diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md new file mode 100644 index 0000000000000000000000000000000000000000..586eb494bbed246fdd0feb2e51bc1bfd313e0e66 --- /dev/null +++ b/zh-cn/device-dev/website.md @@ -0,0 +1,399 @@ +- [设备开发导读](device-dev-guide.md) + +- 快速开始 + + - 轻量和小型系统入门 + - [轻量与小型系统入门概述](quick-start/quickstart-lite-overview.md) + - 搭建轻量与小型系统环境 + - [搭建系统环境概述](quick-start/quickstart-lite-env-setup-overview.md) + - [开发环境准备](quick-start/quickstart-lite-env-prepare.md) + - [获取源码](quick-start/quickstart-lite-sourcecode-acquire.md) + - [使用安装包方式搭建编译环境](quick-start/quickstart-lite-package-environment.md) + - [使用Docker方式搭建编译环境](quick-start/quickstart-lite-docker-environment.md) + - [常见问题](quick-start/quickstart-lite-env-setup-faqs.md) + - 运行“Hello World” + - Hi3861开发板 + - [安装开发板环境](quick-start/quickstart-lite-steps-hi3861-setting.md) + - [新建应用程序](quick-start/quickstart-lite-steps-hi3861-application-framework.md) + - [编译](quick-start/quickstart-lite-steps-hi3861-building.md) + - [烧录](quick-start/quickstart-lite-steps-hi3861-burn.md) + - [调试验证](quick-start/quickstart-lite-steps-hi3861-debug.md) + - [运行](quick-start/quickstart-lite-steps-hi3861-running.md) + - [常见问题](quick-start/quickstart-lite-steps-hi3861-faqs.md) + - Hi3516开发板 + - [安装开发板环境](quick-start/quickstart-lite-steps-hi3516-setting.md) + - [新建应用程序](quick-start/quickstart-lite-steps-hi3516-application-framework.md) + - [编译](quick-start/quickstart-lite-steps-hi3516-building.md) + - [烧录](quick-start/quickstart-lite-steps-hi3516-burn.md) + - [运行](quick-start/quickstart-lite-steps-hi3516-running.md) + - [常见问题](quick-start/quickstart-lite-steps-hi3516-faqs.md) + - Hi3518开发板 + - [安装开发板环境](quick-start/quickstart-lite-steps-hi3518-setting.md) + - [新建应用程序](quick-start/quickstart-lite-steps-hi3518-application-framework.md) + - [编译](quick-start/quickstart-lite-steps-hi3518-building.md) + - [烧录](quick-start/quickstart-lite-steps-hi3518-burn.md) + - [运行](quick-start/quickstart-lite-steps-hi3518-running.md) + - [常见问题](quick-start/quickstart-lite-steps-hi3518-faqs.md) + - 附录 + - [Hi3861开发板介绍](quick-start/quickstart-lite-introduction-hi3861.md) + - [Hi3516开发板介绍](quick-start/quickstart-lite-introduction-hi3516.md) + - [Hi3518开发板介绍](quick-start/quickstart-lite-introduction-hi3518.md) + - 标准系统入门 + - [标准系统入门简介](quick-start/quickstart-standard-overview.md) + - [标准系统开发环境准备(仅Hi3516需要)](quick-start/quickstart-standard-env-setup.md) + - [获取源码](quick-start/quickstart-standard-sourcecode-acquire.md) + - 运行“Hello World” + - Hi3516开发板 + - [创建应用程序](quick-start/quickstart-standard-running-hi3516-create.md) + - [编译](quick-start/quickstart-standard-running-hi3516-build.md) + - [烧录](quick-start/quickstart-standard-running-hi3516-burn.md) + - [运行](quick-start/quickstart-standard-running-hi3516-run.md) + - RK3568开发板 + - [创建应用程序](quick-start/quickstart-standard-running-rk3568-create.md) + - [编译](quick-start/quickstart-standard-running-rk3568-build.md) + - [烧录](quick-start/quickstart-standard-running-rk3568-burn.md) + - [运行](quick-start/quickstart-standard-running-rk3568-run.md) + - [常见问题](quick-start/quickstart-standard-faqs.md) + - 附录 + - [Hi3516开发板介绍](quick-start/quickstart-standard-appendix-hi3516.md) + - [RK3568开发板介绍](quick-start/quickstart-standard-appendix-rk3568.md) + +- 兼容性与安全 + + - [隐私保护](security/security-privacy-protection.md) + - [安全指南](security/security-guidelines-overall.md) + +- 移植 + + - 轻量系统芯片移植指导 + + - 移植准备 + - [移植须知](porting/oem_transplant_chip_prepare_knows.md) + - [编译构建适配流程](porting/porting-chip-prepare-process.md) + - 内核移植 + - [移植概述](porting/porting-chip-kernel-overview.md) + - [内核基础适配](porting/porting-chip-kernel-adjustment.md) + - [内核移植验证](porting/porting-chip-kernel-verify.md) + - 板级系统移植 + - [移植概述](porting/porting-chip-board-overview.md) + - [板级驱动适配](porting/porting-chip-board-driver.md) + - [HAL层实现](porting/porting-chip-board-hal.md) + - [系统组件调用](porting/porting-chip-board-component.md) + - [lwIP组件适配](porting/porting-chip-board-lwip.md) + - [三方组件适配](porting/porting-chip-board-bundle.md) + - [XTS认证](porting/porting-chip-board-xts.md) + - [常见问题](porting/porting-chip-faqs.md) + + - 小型系统芯片移植指导 + + - 移植准备 + - [移植须知](porting/porting-smallchip-prepare-needs.md) + - [编译构建](porting/porting-smallchip-prepare-building.md) + - 移植内核 + - [LiteOS-A内核](porting/porting-smallchip-kernel-a.md) + - [Linux内核](porting/porting-smallchip-kernel-linux.md) + - 驱动移植 + - [移植概述](porting/porting-smallchip-driver-overview.md) + - [平台驱动移植](porting/porting-smallchip-driver-plat.md) + - [器件驱动移植](porting/porting-smallchip-driver-oom.md) + + - 标准系统芯片移植指导 + + - [标准系统移植指南](porting/standard-system-porting-guide.md) + - [一种快速移植OpenHarmony Linux内核的方法](porting/porting-linux-kernel.md) + + - [轻量和小型系统三方库移植指导](porting/porting-thirdparty.md) + - [概述](porting/porting-thirdparty-overview.md) + - [CMake方式组织编译的库移植](porting/porting-thirdparty-cmake.md) + - [Makefile方式组织编译的库移植](porting/porting-thirdparty-makefile.md) + + - 轻量系统芯片移植案例 + + - [带屏解决方案之恒玄芯片移植案例](porting/porting-bes2600w-on-minisystem-display-demo.md) + +- 子系统开发 + + - 内核 + - 轻量系统内核 + - [内核概述](kernel/kernel-mini-overview.md) + - 基础内核 + - [中断管理](kernel/kernel-mini-basic-interrupt.md) + - [任务管理](kernel/kernel-mini-basic-task.md) + - 内存管理 + - [基本概念](kernel/kernel-mini-basic-memory-basic.md) + - [静态内存](kernel/kernel-mini-basic-memory-static.md) + - [动态内存](kernel/kernel-mini-basic-memory-dynamic.md) + - 内核通信机制 + - [事件](kernel/kernel-mini-basic-ipc-event.md) + - [互斥锁](kernel/kernel-mini-basic-ipc-mutex.md) + - [消息队列](kernel/kernel-mini-basic-ipc-queue.md) + - [信号量](kernel/kernel-mini-basic-ipc-sem.md) + - [时间管理](kernel/kernel-basic-mini-time.md) + - [软件定时器](kernel/kernel-mini-basic-soft.md) + - 扩展组件 + - [C++支持](kernel/kernel-mini-extend-support.md) + - [CPU占用率](kernel/kernel-mini-extend-cpup.md) + - [动态加载](kernel/kernel-mini-extend-dynamic-loading.md) + - 文件系统 + - [FAT](kernel/kernel-mini-extend-file-fat.md) + - [LittleFS](kernel/kernel-mini-extend-file-lit.md) + - 内核调测 + - 内存调测 + - [内存信息统计](kernel/kernel-mini-memory-debug-mes.md) + - [内存泄漏检测](kernel/kernel-mini-imemory-debug-det.md) + - [踩内存检测](kernel/kernel-mini-memory-debug-cet.md) + - [异常调测](kernel/kernel-mini-memory-exception.md) + - [Trace调测](kernel/kernel-mini-memory-trace.md) + - [LMS调测](kernel/kernel-mini-memory-lms.md) + - 附录 + - [内核编码规范](kernel/kernel-mini-appx-code.md) + - 基本数据结构 + - [双向链表](kernel/kernel-mini-appx-data-list.md) + - 标准库支持 + - [CMSIS支持](kernel/kernel-mini-appx-lib-cmsis.md) + - [POSIX支持](kernel/kernel-mini-appx-lib-posix.md) + - 小型系统内核 + - [内核概述](kernel/kernel-small-overview.md) + - 内核启动 + - [内核态启动](kernel/kernel-small-start-kernel.md) + - [用户态启动](kernel/kernel-small-start-user.md) + - 基础内核 + - [中断及异常处理](kernel/kernel-small-basic-interrupt.md) + - 进程管理 + - [进程](kernel/kernel-small-basic-process-process.md) + - [任务](kernel/kernel-small-basic-process-thread.md) + - [调度器](kernel/kernel-small-basic-process-scheduler.md) + - 内存管理 + - [堆内存管理](kernel/kernel-small-basic-memory-heap.md) + - [物理内存管理](kernel/kernel-small-basic-memory-physical.md) + - [虚拟内存管理](kernel/kernel-small-basic-memory-virtual.md) + - [虚实映射](kernel/kernel-small-basic-inner-reflect.md) + - 内核通信机制 + - [事件](kernel/kernel-small-basic-trans-event.md) + - [信号量](kernel/kernel-small-basic-trans-semaphore.md) + - [互斥锁](kernel/kernel-small-basic-trans-mutex.md) + - [消息队列](kernel/kernel-small-basic-trans-queue.md) + - [读写锁](kernel/kernel-small-basic-trans-rwlock.md) + - [用户态快速互斥锁](kernel/kernel-small-basic-trans-user-mutex.md) + - [信号](kernel/kernel-small-basic-trans-user-signal.md) + - [时间管理](kernel/kernel-small-basic-time.md) + - [软件定时器](kernel/kernel-small-basic-softtimer.md) + - [原子操作](kernel/kernel-small-basic-atomic.md) + - 扩展组件 + - [系统调用](kernel/kernel-small-bundles-system.md) + - [动态加载与链接](kernel/kernel-small-bundles-linking.md) + - [虚拟动态共享库](kernel/kernel-small-bundles-share.md) + - [轻量级进程间通信](kernel/kernel-small-bundles-ipc.md) + - 文件系统 + - [虚拟文件系统](kernel/kernel-small-bundles-fs-virtual.md) + - 支持的文件系统 + - [FAT](kernel/kernel-small-bundles-fs-support-fat.md) + - [JFFS2](kernel/kernel-small-bundles-fs-support-jffs2.md) + - [NFS](kernel/kernel-small-bundles-fs-support-nfs.md) + - [Ramfs](kernel/kernel-small-bundles-fs-support-ramfs.md) + - [Procfs](kernel/kernel-small-bundles-fs-support-procfs.md) + - [适配新的文件系统](kernel/kernel-small-bundles-fs-new.md) + - 调测与工具 + - Shell + - [Shell介绍](kernel/kernel-small-debug-shell-overview.md) + - [Shell命令开发指导](kernel/kernel-small-debug-shell-guide.md) + - [Shell命令编程实例](kernel/kernel-small-debug-shell-build.md) + - Shell命令使用详解 + - 系统命令 + - [cpup](kernel/kernel-small-debug-shell-cmd-cpup.md) + - [date](kernel/kernel-small-debug-shell-cmd-date.md) + - [dmesg](kernel/kernel-small-debug-shell-cmd-dmesg.md) + - [exec](kernel/kernel-small-debug-shell-cmd-exec.md) + - [free](kernel/kernel-small-debug-shell-cmd-free.md) + - [help](kernel/kernel-small-debug-shell-cmd-help.md) + - [hwi](kernel/kernel-small-debug-shell-cmd-hwi.md) + - [kill](kernel/kernel-small-debug-shell-cmd-kill.md) + - [log](kernel/kernel-small-debug-shell-cmd-log.md) + - [memcheck](kernel/kernel-small-debug-shell-cmd-memcheck.md) + - [oom](kernel/kernel-small-debug-shell-cmd-oom.md) + - [pmm](kernel/kernel-small-debug-shell-cmd-pmm.md) + - [reset](kernel/kernel-small-debug-shell-cmd-reset.md) + - [sem](kernel/kernel-small-debug-shell-cmd-sem.md) + - [stack](kernel/kernel-small-debug-shell-cmd-stack.md) + - [su](kernel/kernel-small-debug-shell-cmd-su.md) + - [swtmr](kernel/kernel-small-debug-shell-cmd-swtmr.md) + - [systeminfo](kernel/kernel-small-debug-shell-cmd-sysinfo.md) + - [task](kernel/kernel-small-debug-shell-cmd-task.md) + - [uname](kernel/kernel-small-debug-shell-cmd-uname.md) + - [vmm](kernel/kernel-small-debug-shell-cmd-vmm.md) + - [watch](kernel/kernel-small-debug-shell-cmd-watch.md) + - [reboot](kernel/kernel-small-debug-shell-cmd-reboot.md) + - [top](kernel/kernel-small-debug-shell-cmd-top.md) + - 文件命令 + - [cat](kernel/kernel-small-debug-shell-file-cat.md) + - [cd](kernel/kernel-small-debug-shell-file-cd.md) + - [chgrp](kernel/kernel-small-debug-shell-file-chgrp.md) + - [chmod](kernel/kernel-small-debug-shell-file-chmod.md) + - [chown](kernel/kernel-small-debug-shell-file-chown.md) + - [cp](kernel/kernel-small-debug-shell-file-cp.md) + - [format](kernel/kernel-small-debug-shell-file-format.md) + - [ls](kernel/kernel-small-debug-shell-file-ls.md) + - [lsfd](kernel/kernel-small-debug-shell-file-lsfd.md) + - [mkdir](kernel/kernel-small-debug-shell-file-mkdir.md) + - [mount](kernel/kernel-small-debug-shell-file-mount.md) + - [partinfo](kernel/kernel-small-debug-shell-file-partinfo.md) + - [partition](kernel/kernel-small-debug-shell-file-partition.md) + - [pwd](kernel/kernel-small-debug-shell-file-pwd.md) + - [rm](kernel/kernel-small-debug-shell-file-rm.md) + - [rmdir](kernel/kernel-small-debug-shell-file-rmdir.md) + - [statfs](kernel/kernel-small-debug-shell-file-statfs.md) + - [sync](kernel/kernel-small-debug-shell-file-sync.md) + - [touch](kernel/kernel-small-debug-shell-file-touch.md) + - [writeproc](kernel/kernel-small-debug-shell-file-write.md) + - [umount](kernel/kernel-small-debug-shell-file-umount.md) + - [du](kernel/kernel-small-debug-shell-file-du.md) + - [mv](kernel/kernel-small-debug-shell-file-mv.md) + - 网络命令 + - [arp](kernel/kernel-small-debug-shell-net-arp.md) + - [dhclient](kernel/kernel-small-debug-shell-net-dhclient.md) + - [ifconfig](kernel/kernel-small-debug-shell-net-ifconfig.md) + - [ipdebug](kernel/kernel-small-debug-shell-net-ipdebug.md) + - [netstat](kernel/kernel-small-debug-shell-net-netstat.md) + - [ntpdate](kernel/kernel-small-debug-shell-net-ntpdate.md) + - [ping](kernel/kernel-small-debug-shell-net-ping.md) + - [ping6](kernel/kernel-small-debug-shell-net-ping6.md) + - [telnet](kernel/kernel-small-debug-shell-net-telnet.md) + - [tftp](kernel/kernel-small-debug-shell-net-tftp.md) + - [魔法键使用方法](kernel/kernel-small-debug-shell-magickey.md) + - [用户态异常信息说明](kernel/kernel-small-debug-shell-error.md) + - [Trace](kernel/kernel-small-debug-trace.md) + - [Perf调测](kernel/kernel-mini-memory-perf.md) + - [LMS调测](kernel/kernel-small-memory-lms.md) + - 进程调测 + - [CPU占用率](kernel/kernel-small-debug-process-cpu.md) + - 内核态内存调测 + - [内存信息统计](kernel/kernel-small-debug-memory-info.md) + - [内存泄漏检测](kernel/kernel-small-debug-memory-leak.md) + - [踩内存检测](kernel/kernel-small-debug-memory-corrupt.md) + - 用户态内存调测 + - [基本概念](kernel/kernel-small-debug-user-concept.md) + - [运行机制](kernel/kernel-small-debug-user-function.md) + - 使用指导 + - [接口说明](kernel/kernel-small-debug-user-guide-api.md) + - 使用说明 + - [接口调用方式](kernel/kernel-small-debug-user-guide-use-api.md) + - [命令行参数方式](kernel/kernel-small-debug-user-guide-use-cli.md) + - [常见问题场景](kernel/kernel-small-debug-user-faqs.md) + - 其他内核调测手段 + - [临终遗言](kernel/kernel-small-debug-trace-other-lastwords.md) + - [常见问题定位方法](kernel/kernel-small-debug-trace-other-faqs.md) + - 附录 + - 基本数据结构 + - [双向链表](kernel/kernel-small-apx-dll.md) + - [位操作](kernel/kernel-small-apx-bitwise.md) + - [标准库](kernel/kernel-small-apx-library.md) + - 标准系统内核 + - [Linux内核概述](kernel/kernel-standard-overview.md) + - [开发板Patch使用指导](kernel/kernel-standard-patch.md) + - [Linux内核编译与构建指导](kernel/kernel-standard-build.md) + - 内核增强特性 + - 内存管理 + - [Enhanced SWAP特性介绍](kernel/kernel-standard-mm-eswap.md) + - 任务调度 + - [关联线程组调度](kernel/kernel-standard-sched-rtg.md) + - [CPU轻量级隔离](kernel/kernel-standard-sched-cpuisolation.md) + - 驱动 + - HDF驱动框架 + - [HDF开发概述](driver/driver-hdf-overview.md) + - [驱动开发](driver/driver-hdf-development.md) + - [驱动服务管理](driver/driver-hdf-servicemanage.md) + - [驱动消息机制管理](driver/driver-hdf-message-management.md) + - [配置管理](driver/driver-hdf-manage.md) + - [HDF开发实例](driver/driver-hdf-sample.md) + - 平台驱动开发 + - [ADC](driver/driver-platform-adc-develop.md) + - [GPIO](driver/driver-platform-gpio-develop.md) + - [HDMI](driver/driver-platform-hdmi-develop.md) + - [I2C](driver/driver-platform-i2c-develop.md) + - [I3C](driver/driver-platform-i3c-develop.md) + - [MIPI-CSI](driver/driver-platform-mipicsi-develop.md) + - [MIPI-DSI](driver/driver-platform-mipidsi-develop.md) + - [MMC](driver/driver-platform-mmc-develop.md) + - [PIN](driver/driver-platform-pin-develop.md) + - [PWM](driver/driver-platform-pwm-develop.md) + - [REGULATOR](driver/driver-platform-regulator-develop.md) + - [RTC](driver/driver-platform-rtc-develop.md) + - [SDIO](driver/driver-platform-sdio-develop.md) + - [SPI](driver/driver-platform-spi-develop.md) + - [UART](driver/driver-platform-uart-develop.md) + - [WatchDog](driver/driver-platform-watchdog-develop.md) + - 平台驱动使用 + - [ADC](driver/driver-platform-adc-des.md) + - [GPIO](driver/driver-platform-gpio-des.md) + - [HDMI](driver/driver-platform-hdmi-des.md) + - [I2C](driver/driver-platform-i2c-des.md) + - [I3C](driver/driver-platform-i3c-des.md) + - [MIPI-CSI](driver/driver-platform-mipicsi-des.md) + - [MIPI-DSI](driver/driver-platform-mipidsi-des.md) + - [PWM](driver/driver-platform-pwm-des.md) + - [REGULATOR](driver/driver-platform-regulator-des.md) + - [RTC](driver/driver-platform-rtc-des.md) + - [SDIO](driver/driver-platform-sdio-des.md) + - [SPI](driver/driver-platform-spi-des.md) + - [UART](driver/driver-platform-uart-des.md) + - [WATCHDOG](driver/driver-platform-watchdog-des.md) + - 外设驱动使用 + - [LCD](driver/driver-peripherals-lcd-des.md) + - [TOUCHSCREEN](driver/driver-peripherals-touch-des.md) + - [SENSOR](driver/driver-peripherals-sensor-des.md) + - [WLAN](driver/driver-peripherals-external-des.md) + - [AUDIO](driver/driver-peripherals-audio-des.md) + - [USB](driver/driver-peripherals-usb-des.md) + - [CAMERA](driver/driver-peripherals-camera-des.md) + - [编译构建](subsystems/subsys-build.md) + - [分布式远程启动](subsystems/subsys-remote-start.md) + - [图形图像](subsystems/subsys-graphics.md) + - [媒体](subsystems/subsys-multimedia.md) + - [公共基础](subsystems/subsys-utils.md) + - [AI框架](subsystems/subsys-aiframework.md) + - [数据管理](subsystems/subsys-data.md) + - [Sensor服务](subsystems/subsys-sensor.md) + - [USB服务](subsystems/subsys-usbservice.md) + - [用户程序框架](subsystems/subsys-application-framework.md) + - [OTA升级](subsystems/subsys-ota-guide.md) + - [电话服务](subsystems/subsys-tel.md) + - [安全](subsystems/subsys-security.md) + - [启动恢复](subsystems/subsys-boot.md) + - [DFX](subsystems/subsys-dfx.md) + +- 专题 + - [HPM Part](hpm-part/Readme-CN.md) + - [HPM Part介绍](hpm-part/hpm-part-about.md) + - [HPM Part开发指导](hpm-part/hpm-part-development.md) + - [HPM Part参考](hpm-part/hpm-part-reference.md) + +- 设备开发示例 + + - [轻量和小型系统设备开发示例](guide/device-lite.md) + - [标准系统设备开发示例](guide/device-lite.md) + +- 调测 + + - [测试用例开发](subsystems/subsys-testguide-test.md) + - [调测工具](subsystems/subsys-toolchain.md) + +- XTS认证 + + - [XTS认证](subsystems/subsys-xts-guide.md) + +- 工具 + + - [Docker编译环境](get-code/gettools-acquire.md) + - [IDE集成开发环境](get-code/gettools-ide.md) + +- 参考 + + - [常见问题-设备开发](faqs/Readme-CN.md) + - [常见问题概述](faqs/faqs-overview.md) + - [环境搭建常见问题](faqs/faqs-environment-setup.md) + - [编译构建子系统常见问题](faqs/faqs-building.md) + - [烧录常见问题](faqs/faqs-burning.md) + - [内核常见问题](faqs/faqs-kernel.md) + - [移植常见问题](faqs/faqs-porting.md) + - [启动恢复常见问题](faqs/faqs-startup.md) + - [系统应用常见问题](faqs/faqs-system-applications.md) \ No newline at end of file diff --git a/zh-cn/release-notes/OpenHarmony-v3.1-beta.md b/zh-cn/release-notes/OpenHarmony-v3.1-beta.md index 2d276a6eb35e85a147f1ce1250fed9bc6aa98435..1ee4b871a79220f4a72605409bb3846bb242636f 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.1-beta.md +++ b/zh-cn/release-notes/OpenHarmony-v3.1-beta.md @@ -45,6 +45,26 @@ ## 源码获取 +### 前提条件 + +1. 注册码云gitee账号。 +2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 +3. 安装[git客户端](https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git)和[git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)并配置用户信息。 + + ``` + git config --global user.name "yourname" + git config --global user.email "your-email-address" + git config --global credential.helper store + ``` + +4. 安装码云repo工具,可以执行如下命令。 + + ``` + curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中 + chmod a+x /usr/local/bin/repo + pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests + ``` + ### 通过repo获取 diff --git a/zh-cn/website-directory.md b/zh-cn/website-directory.md deleted file mode 100644 index 97b716421778d8708ab316c1696984dd4476394d..0000000000000000000000000000000000000000 --- a/zh-cn/website-directory.md +++ /dev/null @@ -1,1971 +0,0 @@ -# OpenHarmony - -——>——> 了解OpenHarmony - -——>——>——> [了解OpenHarmony开源项目](OpenHarmony-Overview_zh.md) - -——>——>——> 了解OpenHarmony系统 - -——>——>——>——>[内核子系统](readme/内核子系统.md) - -——>——>——>——>[驱动子系统](readme/驱动子系统.md) - -——>——>——>——>[方舟运行时子系统](readme/ARK-Runtime-Subsystem-zh.md) - -——>——>——>——>[DFX子系统](readme/DFX子系统.md) - -——>——>——>——>[JS-UI框架子系统](readme/JS-UI框架子系统.md) - -——>——>——>——>[Misc软件服务子系统](readme/Misc软件服务子系统.md) - -——>——>——>——>[XTS子系统](readme/XTS子系统.md) - -——>——>——>——>[事件通知子系统](readme/事件通知子系统.md) - -——>——>——>——>[元能力子系统](readme/元能力子系统.md) - -——>——>——>——>[全球化子系统](readme/全球化子系统.md) - -——>——>——>——>[公共基础库](readme/公共基础库.md) - -——>——>——>——>[分布式任务调度子系统](readme/分布式任务调度子系统.md) - -——>——>——>——>[分布式数据管理子系统](readme/分布式数据管理子系统.md) - -——>——>——>——>[分布式文件子系统](readme/分布式文件子系统.md) - -——>——>——>——>[分布式软总线子系统](readme/分布式软总线子系统.md) - -——>——>——>——>[升级子系统](readme/升级子系统.md) - -——>——>——>——>[启动恢复子系统](readme/启动恢复子系统.md) - -——>——>——>——>[图形子系统](readme/图形子系统.md) - -——>——>——>——>[多模输入子系统](readme/多模输入子系统.md) - -——>——>——>——>[媒体子系统](readme/媒体子系统.md) - -——>——>——>——>[安全子系统](readme/安全子系统.md) - -——>——>——>——>[帐号子系统](readme/帐号子系统.md) - -——>——>——>——>[泛Sensor子系统](readme/泛Sensor子系统.md) - -——>——>——>——>[测试子系统](readme/测试子系统.md) - -——>——>——>——>[用户程序框架子系统](readme/用户程序框架子系统.md) - -——>——>——>——>[电源管理子系统](readme/电源管理子系统.md) - -——>——>——>——>[电话服务子系统](readme/电话服务子系统.md) - -——>——>——>——>[研发工具链子系统](readme/研发工具链子系统.md) - -——>——>——>——>[系统应用](readme/系统应用.md) - -——>——>——>——>[编译构建子系统](readme/编译构建子系统.md) - -——>——>——>——>[语言运行时子系统](readme/语言运行时子系统.md) - -——>——>——>——>[AI业务子系统](readme/AI业务子系统.md) - -——>——>——> [术语](device-dev/glossary/glossary.md) - -——>——>——> [版本说明](release-notes/Readme.md) - -——>——> 快速开始 - -——>——>——>[轻量和小型系统入门](device-dev/quick-start/quickstart-lite.md) - -——>——>——>——>[轻量与小型系统入门概述](device-dev/quick-start/quickstart-lite-overview.md) - -——>——>——>——>[搭建轻量与小型系统环境](device-dev/quick-start/quickstart-lite-env-setup.md) - -——>——>——>——>——>[搭建系统环境概述](device-dev/quick-start/quickstart-lite-env-setup-overview.md) - -——>——>——>——>——>[开发环境准备](device-dev/quick-start/quickstart-lite-env-prepare.md) - -——>——>——>——>——>[获取源码](device-dev/quick-start/quickstart-lite-sourcecode-acquire.md) - -——>——>——>——>——>[使用安装包方式搭建编译环境](device-dev/quick-start/quickstart-lite-package-environment.md) - -——>——>——>——>——>[使用Docker方式搭建编译环境](device-dev/quick-start/quickstart-lite-docker-environment.md) - -——>——>——>——>——>[常见问题](device-dev/quick-start/quickstart-lite-env-setup-faqs.md) - -——>——>——>——>[运行“Hello World”](device-dev/quick-start/quickstart-lite-steps.md) - -——>——>——>——>——>[Hi3861开发板](device-dev/quick-start/quickstart-lite-steps-hi3861.md) - -——>——>——>——>——>——>[安装开发板环境](device-dev/quick-start/quickstart-lite-steps-hi3861-setting.md) - -——>——>——>——>——>——>[新建应用程序](device-dev/quick-start/quickstart-lite-steps-hi3861-application-framework.md) - -——>——>——>——>——>——>[编译](device-dev/quick-start/quickstart-lite-steps-hi3861-building.md) - -——>——>——>——>——>——>[烧录](device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md) - -——>——>——>——>——>——>[调试验证](device-dev/quick-start/quickstart-lite-steps-hi3861-debug.md) - -——>——>——>——>——>——>[运行](device-dev/quick-start/quickstart-lite-steps-hi3816-running.md) - -——>——>——>——>——>——>[常见问题](device-dev/quick-start/quickstart-lite-steps-hi3861-faqs.md) - -——>——>——>——>——>[Hi3516开发板](device-dev/quick-start/quickstart-lite-steps-hi3516.md) - -——>——>——>——>——>——>[安装开发板环境](device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md) - -——>——>——>——>——>——>[新建应用程序](device-dev/quick-start/quickstart-lite-steps-hi3516-application-framework.md) - -——>——>——>——>——>——>[编译](device-dev/quick-start/quickstart-lite-steps-hi3516-building.md) - -——>——>——>——>——>——>[烧录](device-dev/quick-start/quickstart-lite-steps-hi3516-burn.md) - -——>——>——>——>——>——>[运行](device-dev/quick-start/quickstart-lite-steps-hi3516-running.md) - -——>——>——>——>——>——>[常见问题](device-dev/quick-start/quickstart-lite-steps-hi3516-faqs.md) - -——>——>——>——>——>[Hi3518开发板](device-dev/quick-start/quickstart-lite-steps-hi3518.md) - -——>——>——>——>——>——>[安装开发板环境](device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md) - -——>——>——>——>——>——>[新建应用程序](device-dev/quick-start/quickstart-lite-steps-hi3518-application-framework.md) - -——>——>——>——>——>——>[编译](device-dev/quick-start/quickstart-lite-steps-hi3518-building.md) - -——>——>——>——>——>——>[烧录](device-dev/quick-start/quickstart-lite-steps-hi3518-burn.md) - -——>——>——>——>——>——>[运行](device-dev/quick-start/quickstart-lite-steps-hi3518-running.md) - -——>——>——>——>——>——>[常见问题](device-dev/quick-start/quickstart-lite-steps-hi3518-faqs.md) - -——>——>——>——>[附录](device-dev/quick-start/quickstart-lite-introduction.md) - -——>——>——>——>——>[Hi3861开发板介绍](device-dev/quick-start/quickstart-lite-introduction-hi3861.md) - -——>——>——>——>——>[Hi3516开发板介绍](device-dev/quick-start/quickstart-lite-introduction-hi3516.md) - -——>——>——>——>——>[Hi3518开发板介绍](device-dev/quick-start/quickstart-lite-introduction-hi3518.md) - -——>——>——>[标准系统入门](device-dev/quick-start/quickstart-standard.md) - -——>——>——>——>[标准系统入门简介](device-dev/quick-start/quickstart-standard-overview.md) - -——>——>——>——>[标准系统开发环境准备(仅Hi3516需要)](device-dev/quick-start/quickstart-standard-env-setup.md) - -——>——>——>——>[获取源码](device-dev/quick-start/quickstart-standard-sourcecode-acquire.md) - -——>——>——>——>[运行“Hello World”](device-dev/quick-start/quickstart-standard-running.md) - -——>——>——>——>——>[Hi3516开发板](device-dev/quick-start/quickstart-standard-running-hi3516.md) - -——>——>——>——>——>——>[创建应用程序](device-dev/quick-start/quickstart-standard-running-hi3516-create.md) - -——>——>——>——>——>——>[编译](device-dev/quick-start/quickstart-standard-running-hi3516-build.md) - -——>——>——>——>——>——>[烧录](device-dev/quick-start/quickstart-standard-running-hi3516-burn.md) - -——>——>——>——>——>——>[运行](device-dev/quick-start/quickstart-standard-running-hi3516-run.md) - -——>——>——>——>——>[RK3568开发板](device-dev/quick-start/quickstart-standard-running-rk3568.md) - -——>——>——>——>——>——>[创建应用程序](device-dev/quick-start/quickstart-standard-running-rk3568-create.md) - -——>——>——>——>——>——>[编译](device-dev/quick-start/quickstart-standard-running-rk3568-build.md) - -——>——>——>——>——>——>[烧录](device-dev/quick-start/quickstart-standard-running-rk3568-burn.md) - -——>——>——>——>——>——>[运行](device-dev/quick-start/quickstart-standard-running-rk3568-run.md) - -——>——>——>——>[常见问题](device-dev/quick-start/quickstart-standard-faqs.md) - -——>——>——>——>[附录](device-dev/quick-start/quickstart-standard-appendix.md) - -——>——>——>——>——>[Hi3516开发板介绍](device-dev/quick-start/quickstart-standard-appendix-hi3516.md) - -——>——>——>——>——>[RK3568开发板介绍](device-dev/quick-start/quickstart-standard-appendix-rk3568.md) - -——>——> 兼容性与安全 - -——>——>——> [隐私与安全规范](device-dev/security/security.md) - -——>——>——>——> [隐私保护](device-dev/security/security-privacy-protection.md) - -——>——>——>——> [安全指南](device-dev/security/security-guidelines-overall.md) - -——>——> 移植 - -——>——>——>[轻量系统芯片移植指导](device-dev/porting/porting-minichip.md) - -——>——>——>——>[移植准备](device-dev/porting/porting-chip-prepare.md) - -——>——>——>——>——>[移植须知](device-dev/porting/oem_transplant_chip_prepare_knows.md) - -——>——>——>——>——>[编译构建适配流程](device-dev/porting/porting-chip-prepare-process.md) - -——>——>——>——>[内核移植](device-dev/porting/porting-chip-kernel.md) - -——>——>——>——>——>[移植概述](device-dev/porting/porting-chip-kernel-overview.md) - -——>——>——>——>——>[内核基础适配](device-dev/porting/porting-chip-kernel-adjustment.md) - -——>——>——>——>——>[内核移植验证](device-dev/porting/porting-chip-kernel-verify.md) - -——>——>——>——>[板级系统移植](device-dev/porting/porting-chip-board.md) - -——>——>——>——>——>[移植概述](device-dev/porting/porting-chip-board-overview.md) - -——>——>——>——>——>[板级驱动适配](device-dev/porting/porting-chip-board-driver.md) - -——>——>——>——>——>[HAL层实现](device-dev/porting/porting-chip-board-hal.md) - -——>——>——>——>——>[系统组件调用](device-dev/porting/porting-chip-board-component.md) - -——>——>——>——>——>[lwIP组件适配](device-dev/porting/porting-chip-board-lwip.md) - -——>——>——>——>——>[三方组件适配](device-dev/porting/porting-chip-board-bundle.md) - -——>——>——>——>——>[XTS认证](device-dev/porting/porting-chip-board-xts.md) - -——>——>——>——>[常见问题](device-dev/porting/porting-chip-faqs.md) - -——>——>——>[小型系统芯片移植指导](device-dev/porting/porting-smallchip.md) - -——>——>——>——>[移植准备](device-dev/porting/porting-smallchip-prepare.md) - -——>——>——>——>——>[移植须知](device-dev/porting/porting-smallchip-prepare-needs.md) - -——>——>——>——>——>[编译构建](device-dev/porting/porting-smallchip-prepare-building.md) - -——>——>——>——>[移植内核](device-dev/porting/porting-smallchip-kernel.md) - -——>——>——>——>——>[LiteOS-A内核](device-dev/porting/porting-smallchip-kernel-a.md) - -——>——>——>——>——>[Linux内核](device-dev/porting/porting-smallchip-kernel-linux.md) - -——>——>——>——>[驱动移植](device-dev/porting/porting-smallchip-driver.md) - -——>——>——>——>——>[移植概述](device-dev/porting/porting-smallchip-driver-overview.md) - -——>——>——>——>——>[平台驱动移植](device-dev/porting/porting-smallchip-driver-plat.md) - -——>——>——>——>——>[器件驱动移植](device-dev/porting/porting-smallchip-driver-oom.md) - -——>——>——>[标准系统芯片移植指导](device-dev/porting/standard-system-porting-guide.md) - -——>——>——>——>[标准系统移植指南](device-dev/porting/standard-system-porting-guide.md) - -——>——>——>——>[一种快速移植OpenHarmony Linux内核的方法](device-dev/porting/porting-linux-kernel.md) - -——>——>——>[轻量和小型系统三方库移植指导](device-dev/porting/porting-thirdparty.md) - -——>——>——>——>[概述](device-dev/porting/porting-thirdparty-overview.md) - -——>——>——>——>[CMake方式组织编译的库移植](device-dev/porting/porting-thirdparty-cmake.md) - -——>——>——>——>[Makefile方式组织编译的库移植](device-dev/porting/porting-thirdparty-makefile.md) - -——>——>——>[轻量系统芯片移植案例](device-dev/porting/porting-minichip-cases.md) - -——>——>——>——>[带屏解决方案之恒玄芯片移植案例](device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md) - -——>——> 子系统开发 - -——>——>——> [内核](device-dev/kernel/kernel.md) - -——>——>——>——> [轻量系统内核](device-dev/kernel/kernel-mini.md) - -——>——>——>——>——> [内核概述](device-dev/kernel/kernel-mini-overview.md) - -——>——>——>——>——> [基础内核](device-dev/kernel/kernel-mini-basic.md) - -——>——>——>——>——>——> [中断管理](device-dev/kernel/kernel-mini-basic-interrupt.md) - -——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-basic-interrupt-concept.md) - -——>——>——>——>——>——>——> [开发指导](device-dev/kernel/kernel-mini-basic-interrupt-guide.md) - -——>——>——>——>——>——> [任务管理](device-dev/kernel/kernel-mini-basic-task.md) - -——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-basic-task-basic.md) - -——>——>——>——>——>——>——> [开发指导](device-dev/kernel/kernel-mini-basic-task-guide.md) - -——>——>——>——>——>——> [内存管理](device-dev/kernel/kernel-mini-basic-memory.md) - -——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-basic-memory-basic.md) - -——>——>——>——>——>——>——> [静态内存](device-dev/kernel/kernel-mini-basic-memory-static.md) - -——>——>——>——>——>——>——> [动态内存](device-dev/kernel/kernel-mini-basic-memory-dynamic.md) - -——>——>——>——>——>——> [内核通信机制](device-dev/kernel/kernel-mini-basic-ipc.md) - -——>——>——>——>——>——>——> [事件](device-dev/kernel/kernel-mini-basic-ipc-event.md) - -——>——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-basic-ipc-event-basic.md) - -——>——>——>——>——>——>——>——> [开发指导](device-dev/kernel/kernel-mini-basic-ipc-event-guide.md) - -——>——>——>——>——>——>——> [互斥锁](device-dev/kernel/kernel-mini-basic-ipc-mutex.md) - -——>——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-basic-ipc-mutex-basic.md) - -——>——>——>——>——>——>——>——> [开发指导](device-dev/kernel/kernel-mini-basic-ipc-mutex-guide.md) - -——>——>——>——>——>——>——> [消息队列](device-dev/kernel/kernel-mini-basic-ipc-queue.md) - -——>——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-basic-ipc-queue-basic.md) - -——>——>——>——>——>——>——>——> [开发指导](device-dev/kernel/kernel-mini-basic-ipc-queue-guide.md) - -——>——>——>——>——>——>——> [信号量](device-dev/kernel/kernel-mini-basic-ipc-sem.md) - -——>——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-basic-ipc-sem-basic.md) - -——>——>——>——>——>——>——>——> [开发指导](device-dev/kernel/kernel-mini-basic-ipc-sem-guide.md) - -——>——>——>——>——>——> [时间管理](device-dev/kernel/kernel-basic-mini-time.md) - -——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-basic-time-basic.md) - -——>——>——>——>——>——>——> [开发指导](device-dev/kernel/kernel-mini-basic-time-guide.md) - -——>——>——>——>——>——> [软件定时器](device-dev/kernel/kernel-mini-basic-soft.md) - -——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-basic-soft-basic.md) - -——>——>——>——>——>——>——> [开发指导](device-dev/kernel/kernel-mini-basic-soft-guide.md) - -——>——>——>——>——> [扩展组件](device-dev/kernel/kernel-mini-extend.md) - -——>——>——>——>——>——> [C++支持](device-dev/kernel/kernel-mini-extend-support.md) - -——>——>——>——>——>——> [CPU占用率](device-dev/kernel/kernel-mini-extend-cpup.md) - -——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-extend-cpup-basic.md) - -——>——>——>——>——>——>——> [开发指导](device-dev/kernel/kernel-mini-extend-cpup-guide.md) - -——>——>——>——>——>——> [文件系统](device-dev/kernel/kernel-mini-extend-file.md) - -——>——>——>——>——>——>——> [FAT](device-dev/kernel/kernel-mini-extend-file-fat.md) - -——>——>——>——>——>——>——> [LittleFS](device-dev/kernel/kernel-mini-extend-file-lit.md) - -——>——>——>——>——>——>——>——> [基本概念](device-dev/kernel/kernel-mini-extend-file-littlefs-basic.md) - -——>——>——>——>——>——>——>——> [开发指导](device-dev/kernel/kernel-mini-extend-file-littlefs-guide.md) - -——>——>——>——>——> [内核调测](device-dev/kernel/kernel-memory-inner.md) - -——>——>——>——>——>——> [内存调测](device-dev/kernel/kernel-mini-memory-debug.md) - -——>——>——>——>——>——>——> [内存信息统计](device-dev/kernel/kernel-mini-memory-debug-mes.md) - -——>——>——>——>——>——>——> [内存泄漏检测](device-dev/kernel/kernel-mini-imemory-debug-det.md) - -——>——>——>——>——>——>——> [踩内存检测](device-dev/kernel/kernel-mini-memory-debug-cet.md) - -——>——>——>——>——>——> [异常调测](device-dev/kernel/kernel-mini-memory-exception.md) - -——>——>——>——>——>——> [Trace调测](device-dev/kernel/kernel-mini-memory-trace.md) - -——>——>——>——>——>——> [LMS调测](device-dev/kernel/kernel-mini-debug-lms.md) - -——>——>——>——>——> [附录](device-dev/kernel/kernel-mini-app.md) - -——>——>——>——>——>——> [内核编码规范](device-dev/kernel/kernel-mini-appx-code.md) - -——>——>——>——>——>——> [基本数据结构](device-dev/kernel/kernel-mini-appx-data.md) - -——>——>——>——>——>——>——> [双向链表](device-dev/kernel/kernel-mini-appx-data-list.md) - -——>——>——>——>——>——> [标准库支持](device-dev/kernel/kernel-mini-appx-lib.md) - -——>——>——>——>——>——>——> [CMSIS支持](device-dev/kernel/kernel-mini-appx-lib-cmsis.md) - -——>——>——>——>——>——>——> [POSIX支持](device-dev/kernel/kernel-mini-appx-lib-posix.md) - -——>——>——>——> [小型系统内核](device-dev/kernel/kernel-small.md) - -——>——>——>——>——> [内核概述](device-dev/kernel/kernel-small-overview.md) - -——>——>——>——>——> [内核启动](device-dev/kernel/kernel-small-start.md) - -——>——>——>——>——>——> [内核态启动](device-dev/kernel/kernel-small-start-kernel.md) - -——>——>——>——>——>——> [用户态启动](device-dev/kernel/kernel-small-start-user.md) - -——>——>——>——>——> [基础内核](device-dev/kernel/kernel-small-basics.md) - -——>——>——>——>——>——> [中断及异常处理](device-dev/kernel/kernel-small-basic-interrupt.md) - -——>——>——>——>——>——> [进程管理](device-dev/kernel/kernel-small-basic-process.md) - -——>——>——>——>——>——>——> [进程](device-dev/kernel/kernel-small-basic-process-process.md) - -——>——>——>——>——>——>——> [任务](device-dev/kernel/kernel-small-basic-process-thread.md) - -——>——>——>——>——>——>——> [调度器](device-dev/kernel/kernel-small-basic-process-scheduler.md) - -——>——>——>——>——>——> [内存管理](device-dev/kernel/kernel-small-basic-memory.md) - -——>——>——>——>——>——>——> [堆内存管理](device-dev/kernel/kernel-small-basic-memory-heap.md) - -——>——>——>——>——>——>——> [物理内存管理](device-dev/kernel/kernel-small-basic-memory-physical.md) - -——>——>——>——>——>——>——> [虚拟内存管理](device-dev/kernel/kernel-small-basic-memory-virtual.md) - -——>——>——>——>——>——>——> [虚实映射](device-dev/kernel/kernel-small-basic-inner-reflect.md) - -——>——>——>——>——>——> [内核通信机制](device-dev/kernel/kernel-small-basic-trans.md) - -——>——>——>——>——>——>——> [事件](device-dev/kernel/kernel-small-basic-trans-event.md) - -——>——>——>——>——>——>——> [信号量](device-dev/kernel/kernel-small-basic-trans-semaphore.md) - -——>——>——>——>——>——>——> [互斥锁](device-dev/kernel/kernel-small-basic-trans-mutex.md) - -——>——>——>——>——>——>——> [消息队列](device-dev/kernel/kernel-small-basic-trans-queue.md) - -——>——>——>——>——>——>——> [读写锁](device-dev/kernel/kernel-small-basic-trans-rwlock.md) - -——>——>——>——>——>——>——> [用户态快速互斥锁](device-dev/kernel/kernel-small-basic-trans-user-mutex.md) - -——>——>——>——>——>——>——> [信号](device-dev/kernel/kernel-small-basic-trans-user-signal.md) - -——>——>——>——>——>——> [时间管理](device-dev/kernel/kernel-small-basic-time.md) - -——>——>——>——>——>——> [软件定时器](device-dev/kernel/kernel-small-basic-softtimer.md) - -——>——>——>——>——>——> [原子操作](device-dev/kernel/kernel-small-basic-atomic.md) - -——>——>——>——>——> [扩展组件](device-dev/kernel/kernel-small-bundles.md) - -——>——>——>——>——>——> [系统调用](device-dev/kernel/kernel-small-bundles-system.md) - -——>——>——>——>——>——> [动态加载与链接](device-dev/kernel/kernel-small-bundles-linking.md) - -——>——>——>——>——>——> [虚拟动态共享库](device-dev/kernel/kernel-small-bundles-share.md) - -——>——>——>——>——>——> [轻量级进程间通信](device-dev/kernel/kernel-small-bundles-ipc.md) - -——>——>——>——>——>——> [文件系统](device-dev/kernel/kernel-small-bundles-fs.md) - -——>——>——>——>——>——>——> [虚拟文件系统](device-dev/kernel/kernel-small-bundles-fs-virtual.md) - -——>——>——>——>——>——>——> [支持的文件系统](device-dev/kernel/kernel-small-bundles-fs-support.md) - -——>——>——>——>——>——>——>——> [FAT](device-dev/kernel/kernel-small-bundles-fs-support-fat.md) - -——>——>——>——>——>——>——>——> [JFFS2](device-dev/kernel/kernel-small-bundles-fs-support-jffs2.md) - -——>——>——>——>——>——>——>——> [NFS](device-dev/kernel/kernel-small-bundles-fs-support-nfs.md) - -——>——>——>——>——>——>——>——> [Ramfs](device-dev/kernel/kernel-small-bundles-fs-support-ramfs.md) - -——>——>——>——>——>——>——>——> [Procfs](device-dev/kernel/kernel-small-bundles-fs-support-procfs.md) - -——>——>——>——>——>——>——> [适配新的文件系统](device-dev/kernel/kernel-small-bundles-fs-new.md) - -——>——>——>——>——> [调测与工具](device-dev/kernel/kernel-small-debug.md) - -——>——>——>——>——>——> [Shell](device-dev/kernel/kernel-small-debug-shell.md) - -——>——>——>——>——>——>——> [Shell介绍](device-dev/kernel/kernel-small-debug-shell-overview.md) - -——>——>——>——>——>——>——> [Shell命令开发指导](device-dev/kernel/kernel-small-debug-shell-guide.md) - -——>——>——>——>——>——>——> [Shell命令编程实例](device-dev/kernel/kernel-small-debug-shell-build.md) - -——>——>——>——>——>——>——> [Shell命令使用详解](device-dev/kernel/kernel-small-debug-shell-details.md) - -——>——>——>——>——>——>——>——> [系统命令](device-dev/kernel/kernel-small-debug-shell-cmd.md) - -——>——>——>——>——>——>——>——>——> [cpup](device-dev/kernel/kernel-small-debug-shell-cmd-cpup.md) - -——>——>——>——>——>——>——>——>——> [date](device-dev/kernel/kernel-small-debug-shell-cmd-date.md) - -——>——>——>——>——>——>——>——>——> [dmesg](device-dev/kernel/kernel-small-debug-shell-cmd-dmesg.md) - -——>——>——>——>——>——>——>——>——> [exec](device-dev/kernel/kernel-small-debug-shell-cmd-exec.md) - -——>——>——>——>——>——>——>——>——> [free](device-dev/kernel/kernel-small-debug-shell-cmd-free.md) - -——>——>——>——>——>——>——>——>——> [help](device-dev/kernel/kernel-small-debug-shell-cmd-help.md) - -——>——>——>——>——>——>——>——>——> [hwi](device-dev/kernel/kernel-small-debug-shell-cmd-hwi.md) - -——>——>——>——>——>——>——>——>——> [kill](device-dev/kernel/kernel-small-debug-shell-cmd-kill.md) - -——>——>——>——>——>——>——>——>——> [log](device-dev/kernel/kernel-small-debug-shell-cmd-log.md) - -——>——>——>——>——>——>——>——>——> [memcheck](device-dev/kernel/kernel-small-debug-shell-cmd-memcheck.md) - -——>——>——>——>——>——>——>——>——> [oom](device-dev/kernel/kernel-small-debug-shell-cmd-oom.md) - -——>——>——>——>——>——>——>——>——> [pmm](device-dev/kernel/kernel-small-debug-shell-cmd-pmm.md) - -——>——>——>——>——>——>——>——>——> [reset](device-dev/kernel/kernel-small-debug-shell-cmd-reset.md) - -——>——>——>——>——>——>——>——>——> [sem](device-dev/kernel/kernel-small-debug-shell-cmd-sem.md) - -——>——>——>——>——>——>——>——>——> [stack](device-dev/kernel/kernel-small-debug-shell-cmd-stack.md) - -——>——>——>——>——>——>——>——>——> [su](device-dev/kernel/kernel-small-debug-shell-cmd-su.md) - -——>——>——>——>——>——>——>——>——> [swtmr](device-dev/kernel/kernel-small-debug-shell-cmd-swtmr.md) - -——>——>——>——>——>——>——>——>——> [systeminfo](device-dev/kernel/kernel-small-debug-shell-cmd-sysinfo.md) - -——>——>——>——>——>——>——>——>——> [task](device-dev/kernel/kernel-small-debug-shell-cmd-task.md) - -——>——>——>——>——>——>——>——>——> [uname](device-dev/kernel/kernel-small-debug-shell-cmd-uname.md) - -——>——>——>——>——>——>——>——>——> [vmm](device-dev/kernel/kernel-small-debug-shell-cmd-vmm.md) - -——>——>——>——>——>——>——>——>——> [watch](device-dev/kernel/kernel-small-debug-shell-cmd-watch.md) - -——>——>——>——>——>——>——>——>——>[reboot](device-dev/kernel/kernel-small-debug-shell-cmd-reboot.md) - -——>——>——>——>——>——>——>——>——>[top](device-dev/kernel/kernel-small-debug-shell-cmd-top.md) - -——>——>——>——>——>——>——>——> [文件命令](device-dev/kernel/kernel-small-debug-shell-file.md) - -——>——>——>——>——>——>——>——>——> [cat](device-dev/kernel/kernel-small-debug-shell-file-cat.md) - -——>——>——>——>——>——>——>——>——> [cd](device-dev/kernel/kernel-small-debug-shell-file-cd.md) - -——>——>——>——>——>——>——>——>——> [chgrp](device-dev/kernel/kernel-small-debug-shell-file-chgrp.md) - -——>——>——>——>——>——>——>——>——> [chmod](device-dev/kernel/kernel-small-debug-shell-file-chmod.md) - -——>——>——>——>——>——>——>——>——> [chown](device-dev/kernel/kernel-small-debug-shell-file-chown.md) - -——>——>——>——>——>——>——>——>——> [cp](device-dev/kernel/kernel-small-debug-shell-file-cp.md) - -——>——>——>——>——>——>——>——>——> [format](device-dev/kernel/kernel-small-debug-shell-file-format.md) - -——>——>——>——>——>——>——>——>——> [ls](device-dev/kernel/kernel-small-debug-shell-file-ls.md) - -——>——>——>——>——>——>——>——>——> [lsfd](device-dev/kernel/kernel-small-debug-shell-file-lsfd.md) - -——>——>——>——>——>——>——>——>——> [mkdir](device-dev/kernel/kernel-small-debug-shell-file-mkdir.md) - -——>——>——>——>——>——>——>——>——> [mount](device-dev/kernel/kernel-small-debug-shell-file-mount.md) - -——>——>——>——>——>——>——>——>——> [partinfo](device-dev/kernel/kernel-small-debug-shell-file-partinfo.md) - -——>——>——>——>——>——>——>——>——> [partition](device-dev/kernel/kernel-small-debug-shell-file-partition.md) - -——>——>——>——>——>——>——>——>——> [pwd](device-dev/kernel/kernel-small-debug-shell-file-pwd.md) - -——>——>——>——>——>——>——>——>——> [rm](device-dev/kernel/kernel-small-debug-shell-file-rm.md) - -——>——>——>——>——>——>——>——>——> [rmdir](device-dev/kernel/kernel-small-debug-shell-file-rmdir.md) - -——>——>——>——>——>——>——>——>——> [statfs](device-dev/kernel/kernel-small-debug-shell-file-statfs.md) - -——>——>——>——>——>——>——>——>——> [sync](device-dev/kernel/kernel-small-debug-shell-file-sync.md) - -——>——>——>——>——>——>——>——>——> [touch](device-dev/kernel/kernel-small-debug-shell-file-touch.md) - -——>——>——>——>——>——>——>——>——> [writeproc](device-dev/kernel/kernel-small-debug-shell-file-write.md) - -——>——>——>——>——>——>——>——>——> [umount](device-dev/kernel/kernel-small-debug-shell-file-umount.md) - -——>——>——>——>——>——>——>——>——>[du](device-dev/kernel/kernel-small-debug-shell-file-du.md) - -——>——>——>——>——>——>——>——>——>[mv](device-dev/kernel/kernel-small-debug-shell-file-mv.md) - -——>——>——>——>——>——>——>——> [网络命令](device-dev/kernel/kernel-small-debug-shell-net.md) - -——>——>——>——>——>——>——>——>——> [arp](device-dev/kernel/kernel-small-debug-shell-net-arp.md) - -——>——>——>——>——>——>——>——>——> [dhclient](device-dev/kernel/kernel-small-debug-shell-net-dhclient.md) - -——>——>——>——>——>——>——>——>——> [ifconfig](device-dev/kernel/kernel-small-debug-shell-net-ifconfig.md) - -——>——>——>——>——>——>——>——>——> [ipdebug](device-dev/kernel/kernel-small-debug-shell-net-ipdebug.md) - -——>——>——>——>——>——>——>——>——> [netstat](device-dev/kernel/kernel-small-debug-shell-net-netstat.md) - -——>——>——>——>——>——>——>——>——> [ntpdate](device-dev/kernel/kernel-small-debug-shell-net-ntpdate.md) - -——>——>——>——>——>——>——>——>——> [ping](device-dev/kernel/kernel-small-debug-shell-net-ping.md) - -——>——>——>——>——>——>——>——>——> [ping6](device-dev/kernel/kernel-small-debug-shell-net-ping6.md) - -——>——>——>——>——>——>——>——>——> [telnet](device-dev/kernel/kernel-small-debug-shell-net-telnet.md) - -——>——>——>——>——>——>——>——>——> [tftp](device-dev/kernel/kernel-small-debug-shell-net-tftp.md) - -——>——>——>——>——>——>——> [魔法键使用方法](device-dev/kernel/kernel-small-debug-shell-magickey.md) - -——>——>——>——>——>——>——> [用户态异常信息说明](device-dev/kernel/kernel-small-debug-shell-error.md) - -——>——>——>——>——>——> [Trace](device-dev/kernel/kernel-small-debug-trace.md) - -——>——>——>——>——>——>[Perf调测](device-dev/kernel/kernel-small-debug-perf.md) - -——>——>——>——>——>——>[LMS调测](device-dev/kernel/kernel-small-debug-lms.md) - -——>——>——>——>——>——> [进程调测](device-dev/kernel/kernel-small-debug-process.md) - -——>——>——>——>——>——>——> [CPU占用率](device-dev/kernel/kernel-small-debug-process-cpu.md) - -——>——>——>——>——>——> [内存调测](device-dev/kernel/kernel-small-debug-memory.md) - -——>——>——>——>——>——>——> [内存信息统计](device-dev/kernel/kernel-small-debug-memory-info.md) - -——>——>——>——>——>——>——> [内存泄漏检测](device-dev/kernel/kernel-small-debug-memory-leak.md) - -——>——>——>——>——>——>——> [踩内存检测](device-dev/kernel/kernel-small-debug-memory-corrupt.md) - -——>——>——>——>——>——>[用户态内存调测](device-dev/kernel/kernel-small-debug-user.md) - -——>——>——>——>——>——>——>[基本概念](device-dev/kernel/kernel-small-debug-user-concept.md) - -——>——>——>——>——>——>——>[运行机制](device-dev/kernel/kernel-small-debug-user-function.md) - -——>——>——>——>——>——>——>[使用指导](device-dev/kernel/kernel-small-debug-user-guide.md) - -——>——>——>——>——>——>——>——>[接口说明](device-dev/kernel/kernel-small-debug-user-guide-api.md) - -——>——>——>——>——>——>——>——>[使用说明](device-dev/kernel/kernel-small-debug-user-guide-use.md) - -——>——>——>——>——>——>——>——>——>[接口调用方式](device-dev/kernel/kernel-small-debug-user-guide-use-api.md) - -——>——>——>——>——>——>——>——>——>[命令行参数方式](device-dev/kernel/kernel-small-debug-user-guide-use-cli.md) - -——>——>——>——>——>——>——>[常见问题场景](device-dev/kernel/kernel-small-debug-user-faqs.md) - -——>——>——>——>——>——> [其他内核调测手段](device-dev/kernel/kernel-small-debug-other.md) - -——>——>——>——>——>——>——> [临终遗言](device-dev/kernel/kernel-small-debug-trace-other-lastwords.md) - -——>——>——>——>——>——>——> [常见问题定位方法](device-dev/kernel/kernel-small-debug-trace-other-faqs.md) - -——>——>——>——>——> [附录](device-dev/kernel/kernel-small-apx.md) - -——>——>——>——>——>——> [基本数据结构](device-dev/kernel/kernel-small-apx-structure.md) - -——>——>——>——>——>——>——> [双向链表](device-dev/kernel/kernel-small-apx-dll.md) - -——>——>——>——>——>——>——> [位操作](device-dev/kernel/kernel-small-apx-bitwise.md) - -——>——>——>——>——>——> [标准库](device-dev/kernel/kernel-small-apx-library.md) - -——>——>——>——> [标准系统内核](device-dev/kernel/kernel-standard.md) - -——>——>——>——>——> [Linux内核概述](device-dev/kernel/kernel-standard-overview.md) - -——>——>——>——>——> [OpenHarmony开发板Patch使用指导](device-dev/kernel/kernel-standard-patch.md) - -——>——>——>——>——> [Linux内核编译与构建指导](device-dev/kernel/kernel-standard-build.md) - -——>——>——> [驱动](device-dev/driver/driver.md) - -——>——>——>——>[HDF驱动框架](device-dev/driver/driver-hdf.md) - -——>——>——>——>——>[HDF开发概述](device-dev/driver/driver-hdf-overview.md) - -——>——>——>——>——>[驱动开发](device-dev/driver/driver-hdf-development.md) - -——>——>——>——>——>[驱动服务管理](device-dev/driver/driver-hdf-servicemanage.md) - -——>——>——>——>——>[驱动消息机制管理](device-dev/driver/driver-hdf-message-management.md) - -——>——>——>——>——>[配置管理](device-dev/driver/driver-hdf-manage.md) - -——>——>——>——>——>[HDF开发实例](device-dev/driver/driver-hdf-sample.md) - -——>——>——>——>[平台驱动开发](device-dev/driver/driver-develop.md) - -——>——>——>——>——>[ADC](device-dev/driver/driver-platform-adc-develop.md) - -——>——>——>——>——>[GPIO](device-dev/driver/driver-platform-gpio-develop.md) - -——>——>——>——>——>[HDMI](device-dev/driver/driver-platform-hdmi-develop.md) - -——>——>——>——>——>[I2C](device-dev/driver/driver-platform-i2c-develop.md) - -——>——>——>——>——>[I3C](device-dev/driver/driver-platform-i3c-develop.md) - -——>——>——>——>——>[MIPI-CSI](device-dev/driver/driver-platform-mipicsi-develop.md) - -——>——>——>——>——>[MIPI-DSI](device-dev/driver/driver-platform-mipidsi-develop.md) - -——>——>——>——>——>[MMC](device-dev/driver/driver-platform-mmc-develop.md) - -——>——>——>——>——>[PWM](device-dev/driver/driver-platform-pwm-develop.md) - -——>——>——>——>——>[RTC](device-dev/driver/driver-platform-rtc-develop.md) - -——>——>——>——>——>[SDIO](device-dev/driver/driver-platform-sdio-develop.md) - -——>——>——>——>——>[SPI](device-dev/driver/driver-platform-spi-develop.md) - -——>——>——>——>——>[UART](device-dev/driver/driver-platform-uart-develop.md) - -——>——>——>——>——>[WatchDog](device-dev/driver/driver-platform-watchdog-develop.md) - -——>——>——>——>[平台驱动使用](device-dev/driver/driver-platform.md) - -——>——>——>——>——>[ADC](device-dev/driver/driver-platform-adc-des.md) - -——>——>——>——>——>[GPIO](device-dev/driver/driver-platform-gpio-des.md) - -——>——>——>——>——>[HDMI](device-dev/driver/driver-platform-hdmi-des.md) - -——>——>——>——>——>[I2C](device-dev/driver/driver-platform-i2c-des.md) - -——>——>——>——>——>[I3C](device-dev/driver/driver-platform-i3c-des.md) - -——>——>——>——>——>[MIPI-CSI](device-dev/driver/driver-platform-mipicsi-des.md) - -——>——>——>——>——>[MIPI-DSI](device-dev/driver/driver-platform-mipidsi-des.md) - -——>——>——>——>——>[PWM](device-dev/driver/driver-platform-pwm-des.md) - -——>——>——>——>——>[RTC](device-dev/driver/driver-platform-rtc-des.md) - -——>——>——>——>——>[SDIO](device-dev/driver/driver-platform-sdio-des.md) - -——>——>——>——>——>[SPI](device-dev/driver/driver-platform-spi-des.md) - -——>——>——>——>——>[UART](device-dev/driver/driver-platform-uart-des.md) - -——>——>——>——>——>[WATCHDOG](device-dev/driver/driver-platform-watchdog-des.md) - -——>——>——>——>[外设驱动使用](device-dev/driver/driver-peripherals.md) - -——>——>——>——>——>[LCD](device-dev/driver/driver-peripherals-lcd-des.md) - -——>——>——>——>——>[TOUCHSCREEN](device-dev/driver/driver-peripherals-touch-des.md) - -——>——>——>——>——>[SENSOR](device-dev/driver/driver-peripherals-sensor-des.md) - -——>——>——>——>——>[WLAN](device-dev/driver/driver-peripherals-external-des.md) - -——>——>——>——>——>[AUDIO](device-dev/driver/driver-peripherals-audio-des.md) - -——>——>——>——>——>[USB](device-dev/driver/driver-peripherals-usb-des.md) - -——>——>——>——>——>[CAMERA](device-dev/driver/driver-peripherals-camera-des.md) - -——>——>——> [编译构建](device-dev/subsystems/subsys-build.md) - -——>——>——>——> [轻量和小型系统编译构建指导](device-dev/subsystems/subsys-build-mini-lite.md) - -——>——>——>——> [标准系统编译构建指导](device-dev/subsystems/subsys-build-standard-large.md) - -——>——>——>——>[构建系统编码规范和最佳实践指导](device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md) - -——>——>——> [分布式远程启动](device-dev/subsystems/subsys-remote-start.md) - -——>——>——> [图形图像](device-dev/subsystems/subsys-graphics.md) - -——>——>——>——> [图形图像概述](device-dev/subsystems/subsys-graphics-overview.md) - -——>——>——>——> [容器类组件开发指导](device-dev/subsystems/subsys-graphics-container-guide.md) - -——>——>——>——> [布局容器类组件开发指导](device-dev/subsystems/subsys-graphics-layout-guide.md) - -——>——>——>——> [普通组件开发指导](device-dev/subsystems/subsys-graphics-common-guide.md) - -——>——>——>——> [动画开发指导](device-dev/subsystems/subsys-graphics-animation-guide.md) - -——>——>——> [媒体](device-dev/subsystems/subsys-multimedia.md) - -——>——>——>——> [相机](device-dev/subsystems/subsys-multimedia-camera.md) - -——>——>——>——>——> [相机开发概述](device-dev/subsystems/subsys-multimedia-camera-overview.md) - -——>——>——>——>——> [拍照开发指导](device-dev/subsystems/subsys-multimedia-camera-photo-guide.md) - -——>——>——>——>——> [录像开发指导](device-dev/subsystems/subsys-multimedia-camera-record-guide.md) - -——>——>——>——>——> [预览开发指导](device-dev/subsystems/subsys-multimedia-camera-preview-guide.md) - -——>——>——>——> [音视频](device-dev/subsystems/subsys-multimedia-video.md) - -——>——>——>——>——> [音视频开发概述](device-dev/subsystems/subsys-multimedia-video-overview.md) - -——>——>——>——>——> [音视频播放开发指导](device-dev/subsystems/subsys-multimedia-video-play-guide.md) - -——>——>——>——>——> [音视频录制开发指导](device-dev/subsystems/subsys-multimedia-video-record-guide.md) - -——>——>——> [公共基础](device-dev/subsystems/subsys-utils.md) - -——>——>——>——> [公共基础库概述](device-dev/subsystems/subsys-utils-overview.md) - -——>——>——>——> [公共基础库开发指导](device-dev/subsystems/subsys-utils-guide.md) - -——>——>——>——> [公共基础库常见问题](device-dev/subsystems/subsys-utils-faqs.md) - -——>——>——> [AI框架](device-dev/subsystems/subsys-aiframework.md) - -——>——>——>——> [概述](device-dev/subsystems/subsys-aiframework-guide.md) - -——>——>——>——> [搭建环境](device-dev/subsystems/subsys-aiframework-envbuild.md) - -——>——>——>——> [技术规范](device-dev/subsystems/subsys-aiframework-tech.md) - -——>——>——>——>——> [代码管理规范](device-dev/subsystems/subsys-aiframework-tech-codemanage.md) - -——>——>——>——>——> [命名规范](device-dev/subsystems/subsys-aiframework-tech-name.md) - -——>——>——>——>——> [接口开发规范](device-dev/subsystems/subsys-aiframework-tech-interface.md) - -——>——>——>——> [开发指导](device-dev/subsystems/subsys-aiframework-devguide.md) - -——>——>——>——>——> [SDK开发过程](device-dev/subsystems/subsys-aiframework-devguide-sdk.md) - -——>——>——>——>——> [插件的开发过程](device-dev/subsystems/subsys-aiframework-devguide-plugin.md) - -——>——>——>——>——> [配置文件的开发过程](device-dev/subsystems/subsys-aiframework-devguide-conf.md) - -——>——>——>——> [开发示例](device-dev/subsystems/subsys-aiframework-demo.md) - -——>——>——>——>——> [唤醒词识别SDK的开发示例](device-dev/subsystems/subsys-aiframework-demo-sdk.md) - -——>——>——>——>——> [唤醒词识别插件的开发示例](device-dev/subsystems/subsys-aiframework-demo-plugin.md) - -——>——>——>——>——> [唤醒词识别配置文件的开发示例](device-dev/subsystems/subsys-aiframework-demo-conf.md) - -——>——>——> [Sensor服务](device-dev/subsystems/subsys-sensor.md) - -——>——>——>——> [Sensor服务子系概述](device-dev/subsystems/subsys-sensor-overview.md) - -——>——>——>——> [Sensor服务子系使用指导](device-dev/subsystems/subsys-sensor-guide.md) - -——>——>——>——> [Sensor服务子系使用实例](device-dev/subsystems/subsys-sensor-demo.md) - -——>——>——> [用户程序框架](device-dev/subsystems/subsys-application-framework.md) - -——>——>——>——> [概述](device-dev/subsystems/subsys-application-framework-overview.md) - -——>——>——>——> [搭建环境](device-dev/subsystems/subsys-application-framework-envbuild.md) - -——>——>——>——> [开发指导](device-dev/subsystems/subsys-application-framework-guide.md) - -——>——>——>——> [开发实例](device-dev/subsystems/subsys-application-framework-demo.md) - -——>——>——> [OTA升级](device-dev/subsystems/subsys-ota-guide.md) - -——>——>——>[电话服务](device-dev/subsystems/subsys-tel.md) - -——>——>——>——>[电话服务概述](device-dev/subsystems/subsys-tel-overview.md) - -——>——>——>——>[电话服务开发指导](device-dev/subsystems/subsys-tel-guide.md) - -——>——>——> [安全](device-dev/subsystems/subsys-security.md) - -——>——>——>——> [概述](device-dev/subsystems/subsys-security-overview.md) - -——>——>——>——> [应用验签开发指导](device-dev/subsystems/subsys-security-sigverify.md) - -——>——>——>——> [应用权限管理开发指导](device-dev/subsystems/subsys-security-rightmanagement.md) - -——>——>——>——> [IPC通信鉴权开发指导](device-dev/subsystems/subsys-security-communicationverify.md) - -——>——>——> [启动恢复](device-dev/subsystems/subsys-boot.md) - -——>——>——>——> [启动恢复子系统概述](device-dev/subsystems/subsys-boot-overview.md) - -——>——>——>——> [init启动引导组件](device-dev/subsystems/subsys-boot-init.md) - -——>——>——>——> [appspawn应用孵化组件](device-dev/subsystems/subsys-boot-appspawn.md) - -——>——>——>——> [bootstrap服务启动组件](device-dev/subsystems/subsys-boot-bootstrap.md) - -——>——>——>——> [syspara系统属性组件](device-dev/subsystems/subsys-boot-syspara.md) - -——>——>——>——> [常见问题](device-dev/subsystems/subsys-boot-faqs.md) - -——>——>——>——> [参考](device-dev/subsystems/subsys-boot-ref.md) - -——>——>——> [DFX](device-dev/subsystems/subsys-dfx.md) - -——>——>——>——> [DFX概述](device-dev/subsystems/subsys-dfx-overview.md) - -——>——>——>——> [HiLog开发指导](device-dev/subsystems/subsys-dfx-hilog-rich.md) - -——>——>——>——> [HiLog\_Lite开发指导](device-dev/subsystems/subsys-dfx-hilog-lite.md) - -——>——>——>——> [HiSysEvent开发指导](device-dev/subsystems/subsys-dfx-hisysevent.md) - -——>——>——> [DFX](device-dev/subsystems/subsys-dfx.md) - -——>——>——>——>[DFX概述](device-dev/subsystems/subsys-dfx-overview.md) - -——>——>——>——>[HiLog开发指导](device-dev/subsystems/subsys-dfx-hilog-rich.md) - -——>——>——>——>[HiLog\_Lite开发指导](device-dev/subsystems/subsys-dfx-hilog-lite.md) - -——>——>——>——>[HiTrace开发指导](device-dev/subsystems/subsys-dfx-hitrace.md) - -——>——>——>——>[HiCollie开发指导](device-dev/subsystems/subsys-dfx-hicollie.md) - -——>——>——>——>[HiSysEvent开发指导](device-dev/subsystems/subsys-dfx-hisysevent.md) - -——>——>——>——>——>[HiSysEvent打点配置指导](device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md) - -——>——>——>——>——>[HiSysEvent打点指导](device-dev/subsystems/subsys-dfx-hisysevent-logging.md) - -——>——>——>——>——>[HiSysEvent订阅指导](device-dev/subsystems/subsys-dfx-hisysevent-listening.md) - -——>——>——>——>——>[HiSysEvent查询指导](device-dev/subsystems/subsys-dfx-hisysevent-querying.md) - -——>——>——>——>——>[HiSysEvent工具使用指导](device-dev/subsystems/subsys-dfx-hisysevent-tool.md) - -——>——> 专题 - -——>——>——> [HPM bundle](device-dev/bundles/bundles.md) - -——>——>——>——> [HPM Bundle开发规范](device-dev/bundles/oem_bundle_standard_des.md) - -——>——>——>——> [开发指南](device-dev/bundles/bundles-guide.md) - -——>——>——>——>——> [HPM Bundle概述](device-dev/bundles/bundles-guide-overview.md) - -——>——>——>——>——> [安装hpm命令行工具](device-dev/bundles/bundles-guide-prepare.md) - -——>——>——>——>——> [开发Bundle](device-dev/bundles/bundles-guide-develop.md) - -——>——>——>——> [开发示例](device-dev/bundles/bundles-demo.md) - -——>——>——>——>——> [HPM介绍](device-dev/bundles/bundles-demo-hpmdescription.md) - -——>——>——>——>——> [编译环境准备](device-dev/bundles/bundles-demo-environment.md) - -——>——>——>——>——> [操作实例](device-dev/bundles/bundles-demo-devsample.md) - -——>——> 设备开发示例 - -——>——>——> [轻量和小型系统设备](device-dev/guide/device-lite.md) - -——>——>——>——> [WLAN连接类产品](device-dev/guide/device-wlan.md) - -——>——>——>——>——> [LED外设控制](device-dev/guide/device-wlan-led-control.md) - -——>——>——>——>——> [集成三方SDK](device-dev/guide/device-wlan-sdk.md) - -——>——>——>——> [无屏摄像头类产品](device-dev/guide/device-iotcamera.md) - -——>——>——>——>——> [摄像头控制](device-dev/guide/device-iotcamera-control.md) - -——>——>——>——>——>——> [概述](device-dev/guide/device-iotcamera-control-overview.md) - -——>——>——>——>——>——> [示例开发](device-dev/guide/device-iotcamera-control-demo.md) - -——>——>——>——>——>——>——> [拍照开发指导](device-dev/guide/device-iotcamera-control-demo-photodevguide.md) - -——>——>——>——>——>——>——> [录像开发指导](device-dev/guide/device-iotcamera-control-demo-videodevguide.md) - -——>——>——>——>——>——> [应用实例](device-dev/guide/device-iotcamera-control-example.md) - -——>——>——>——> [带屏摄像头类产品](device-dev/guide/device-camera.md) - -——>——>——>——>——> [屏幕和摄像头控制](device-dev/guide/device-camera-control.md) - -——>——>——>——>——>——> [概述](device-dev/guide/device-camera-control-overview.md) - -——>——>——>——>——>——> [示例开发](device-dev/guide/device-camera-control-demo.md) - -——>——>——>——>——>——>——> [拍照开发指导](device-dev/guide/device-camera-control-demo-photoguide.md) - -——>——>——>——>——>——>——> [录像开发指导](device-dev/guide/device-camera-control-demo-videoguide.md) - -——>——>——>——>——>——>——> [预览开发指导](device-dev/guide/device-camera-control-demo-previewguide.md) - -——>——>——>——>——>——> [应用实例](device-dev/guide/device-camera-control-example.md) - -——>——>——>——>——> [视觉应用开发](device-dev/guide/device-camera-visual.md) - -——>——>——>——>——>——> [概述](device-dev/guide/device-camera-visual-overview.md) - -——>——>——>——>——>——> [开发准备](device-dev/guide/device-camera-visual-prepare.md) - -——>——>——>——>——>——> [添加页面](device-dev/guide/device-camera-visual-addpage.md) - -——>——>——>——>——>——> [开发首页](device-dev/guide/device-camera-visual-firstpage.md) - -——>——>——>——>——>——> [开发详情页](device-dev/guide/device-camera-visual-details.md) - -——>——>——>——>——>——> [调试打包](device-dev/guide/device-camera-visual-debug.md) - -——>——>——>——>——>——> [真机运行](device-dev/guide/device-camera-visual-run.md) - -——>——>——>——>——>——> [常见问题](device-dev/guide/device-camera-visual-faqs.md) - -——>——>——> [标准系统设备](device-dev/guide/device-standard.md) - -——>——>——>——> [时钟应用开发指导](device-dev/guide/device-clock-guide.md) - -——>——>——>——> [平台驱动开发示例](device-dev/guide/device-driver-demo.md) - -——>——>——>——> [外设驱动开发示例](device-dev/guide/device-outerdriver-demo.md) - -——>——> 应用开发 - -——>——>——> [应用开发快速入门](application-dev/quick-start) - -——>——>——>——> [开发准备](application-dev/quick-start/start-overview.md) - -——>——>——>——> [使用JS语言开发](application-dev/quick-start/start-with-js.md) - -——>——>——>——> [使用eTS语言开发](application-dev/quick-start/start-with-ets.md) - -——>——>——> 方舟开发框架(ArkUI) - -——>——>——>——> [方舟开发框架概述](application-dev/ui/arkui-overview.md) - -——>——>——>——> 基于JS扩展的类Web开发范式 - -——>——>——>——>——> [概述](application-dev/ui/ui-js-overview.md) - -——>——>——>——>——> 框架说明 - -——>——>——>——>——>——> [文件组织](application-dev/ui/js-framework-file.md) - -——>——>——>——>——>——> [js标签配置](application-dev/ui/js-framework-js-tag.md) - -——>——>——>——>——>——> [app.js](application-dev/ui/js-framework-js-file.md) - -——>——>——>——>——>——> 语法 - -——>——>——>——>——>——>——> [HML语法参考](application-dev/ui/js-framework-syntax-hml.md) - -——>——>——>——>——>——>——> [CSS语法参考](application-dev/ui/js-framework-syntax-css.md) - -——>——>——>——>——>——>——> [JS语法参考](application-dev/ui/js-framework-syntax-js.md) - -——>——>——>——>——>——> [生命周期](application-dev/ui/js-framework-lifecycle.md) - -——>——>——>——>——>——> [资源限定与访问](application-dev/ui/js-framework-resource-restriction.md) - -——>——>——>——>——>——> [多语言支持](application-dev/ui/js-framework-multiple-languages.md) - -——>——>——>——>——> 构建用户界面 - -——>——>——>——>——>——> [组件介绍](application-dev/ui/ui-js-building-ui-component.md) - -——>——>——>——>——>——> 构建布局 - -——>——>——>——>——>——>——> [布局说明](application-dev/ui/ui-js-building-ui-layout-intro.md) - -——>——>——>——>——>——>——> [添加标题行和文本区域](application-dev/ui/ui-js-building-ui-layout-text.md) - -——>——>——>——>——>——>——> [添加图片区域](application-dev/ui/ui-js-building-ui-layout-image.md) - -——>——>——>——>——>——>——> [添加留言区域](application-dev/ui/ui-js-building-ui-layout-comment.md) - -——>——>——>——>——>——>——> [添加容器](application-dev/ui/ui-js-building-ui-layout-external-container.md) - -——>——>——>——>——>——> [添加交互](application-dev/ui/ui-js-building-ui-interactions.md) - -——>——>——>——>——>——> [动画](application-dev/ui/ui-js-building-ui-animation.md) - -——>——>——>——>——>——> [事件](application-dev/ui/ui-js-building-ui-event.md) - -——>——>——>——>——>——> [页面路由](application-dev/ui/ui-js-building-ui-routes.md) - -——>——>——>——>——> 常见组件开发指导 - -——>——>——>——>——>——> [Text](application-dev/ui/ui-js-components-text.md) - -——>——>——>——>——>——> [Input](application-dev/ui/ui-js-components-input.md) - -——>——>——>——>——>——> [Button](application-dev/ui/ui-js-components-button.md) - -——>——>——>——>——>——> [List](application-dev/ui/ui-js-components-list.md) - -——>——>——>——>——>——> [Picker](application-dev/ui/ui-js-components-picker.md) - -——>——>——>——>——>——> [Dialog](application-dev/ui/ui-js-components-dialog.md) - -——>——>——>——>——>——> [Form](application-dev/ui/ui-js-components-form.md) - -——>——>——>——>——>——> [Stepper](application-dev/ui/ui-js-components-stepper.md) - -——>——>——>——>——>——> [Tabs](application-dev/ui/ui-js-component-tabs.md) - -——>——>——>——>——>——> [Image](application-dev/ui/ui-js-components-images.md) - -——>——>——>——>——> 动效开发指导 - -——>——>——>——>——>——> CSS动画 - -——>——>——>——>——>——>——> [属性样式动画](application-dev/ui/ui-js-animate-attribute-style.md) - -——>——>——>——>——>——>——> [transform样式动画](application-dev/ui/ui-js-animate-transform.md) - -——>——>——>——>——>——>——> [background-position样式动画](application-dev/ui/ui-js-animate-background-position-style.md) - -——>——>——>——>——>——> JS动画 - -——>——>——>——>——>——>——> [组件动画](application-dev/ui/ui-js-animate-component.md) - -——>——>——>——>——>——>——> 插值器动画 - -——>——>——>——>——>——>——>——> [动画动效](application-dev/ui/ui-js-animate-dynamic-effects.md) - -——>——>——>——>——>——>——>——> [动画帧](application-dev/ui/ui-js-animate-frame.md) - -——>——>——>——>——> [自定义组件](application-dev/ui/ui-js-custom-components.md) - -——>——>——>——> 基于TS扩展的声明式开发范式 - -——>——>——>——>——> [概述](application-dev/ui/ui-ts-overview.md) - -——>——>——>——>——> 框架说明 - -——>——>——>——>——>——> 文件组织 - -——>——>——>——>——>——>——> [目录结构](application-dev/ui/ts-framework-directory.md) - -——>——>——>——>——>——>——> [应用代码文件访问规则](application-dev/ui/ts-framework-file-access-rules.md) - -——>——>——>——>——>——> [js标签配置](application-dev/ui/ts-framework-js-tag.md) - -——>——>——>——>——>——> 资源访问 - -——>——>——>——>——>——>——> [媒体资源类型说明](application-dev/ui/ts-media-resource-type.md) - -——>——>——>——>——>——> [像素单位](application-dev/ui/ts-pixel-units.md) - -——>——>——>——>——>——> [类型定义](application-dev/ui/ts-types.md) - -——>——>——>——>——> 声明式语法 - -——>——>——>——>——>——> [描述规范使用说明](application-dev/ui/ts-syntax-intro.md) - -——>——>——>——>——>——> 通用UI描述规范 - -——>——>——>——>——>——>——> [基本概念](application-dev/ui/ts-general-ui-concepts.md) - -——>——>——>——>——>——>——> 声明式UI描述规范 - -——>——>——>——>——>——>——>——> [无构造参数配置](application-dev/ui/ts-parameterless-configuration.md) - -——>——>——>——>——>——>——>——> [必选参数构造配置](application-dev/ui/ts-configuration-with-mandatory-parameters.md) - -——>——>——>——>——>——>——>——> [属性配置](application-dev/ui/ts-attribution-configuration.md) - -——>——>——>——>——>——>——>——> [事件配置](application-dev/ui/ts-event-configuration.md) - -——>——>——>——>——>——>——>——> [子组件配置](application-dev/ui/ts-child-component-configuration.md) - -——>——>——>——>——>——>——> 组件化 - -——>——>——>——>——>——>——>——> [@Component](application-dev/ui/ts-component-based-component.md) - -——>——>——>——>——>——>——>——> [@Entry](application-dev/ui/ts-component-based-entry.md) - -——>——>——>——>——>——>——>——> [@Preview](application-dev/ui/ts-component-based-preview.md) - -——>——>——>——>——>——>——>——> [@Builder](application-dev/ui/ts-component-based-builder.md) - -——>——>——>——>——>——>——>——> [@Extend](application-dev/ui/ts-component-based-extend.md) - -——>——>——>——>——>——>——>——> [@CustomDialog](application-dev/ui/ts-component-based-customdialog.md) - -——>——>——>——>——>——> UI状态管理 - -——>——>——>——>——>——>——> [基本概念](application-dev/ui/ts-ui-state-mgmt-concepts.md) - -——>——>——>——>——>——>——> 管理组件拥有的状态 - -——>——>——>——>——>——>——>——> [@State](application-dev/ui/ts-component-states-state.md) - -——>——>——>——>——>——>——>——> [@Prop](application-dev/ui/ts-component-states-prop.md) - -——>——>——>——>——>——>——>——> [@Link](application-dev/ui/ts-component-states-link.md) - -——>——>——>——>——>——>——> 管理应用程序的状态 - -——>——>——>——>——>——>——>——> 接口 - -——>——>——>——>——>——>——>——>——> [应用程序的数据存储](application-dev/ui/ts-application-states-appstorage.md) - -——>——>——>——>——>——>——>——>——> [持久化数据管理](application-dev/ui/ts-application-states-apis-persistentstorage.md) - -——>——>——>——>——>——>——>——>——> [环境变量](application-dev/ui/ts-application-states-apis-environment.md) - -——>——>——>——>——>——>——>——> [AppStorage与组件同步](application-dev/ui/ts-application-states-storagelink-storageprop.md) - -——>——>——>——>——>——>——> 其他类目的状态管理 - -——>——>——>——>——>——>——>——> [Observed和ObjectLink数据管理](application-dev/ui/ts-other-states-observed-objectlink.md) - -——>——>——>——>——>——>——>——> [@Consume和@Provide数据管理](application-dev/ui/ts-other-states-consume-provide.md) - -——>——>——>——>——>——>——>——> [@Watch](application-dev/ui/ts-other-states-watch.md) - -——>——>——>——>——>——> 渲染控制语法 - -——>——>——>——>——>——>——> [条件渲染](application-dev/ui/ts-rending-control-syntax-if-else.md) - -——>——>——>——>——>——>——> [循环渲染](application-dev/ui/ts-rending-control-syntax-foreach.md) - -——>——>——>——>——>——>——> [数据懒加载](application-dev/ui/ts-rending-control-syntax-lazyforeach.md) - -——>——>——>——>——>——> 深入理解组件化 - -——>——>——>——>——>——>——> [build函数](application-dev/ui/ts-function-build.md) - -——>——>——>——>——>——>——> [自定义组件初始化](application-dev/ui/ts-custom-component-initialization.md) - -——>——>——>——>——>——>——> [自定义组件生命周期回调函数](application-dev/ui/ts-custom-component-lifecycle-callbacks.md) - -——>——>——>——>——>——>——> [组件创建和重新初始化示例](application-dev/ui/ts-component-creation-re-initialization.md) - -——>——>——>——>——>——> 语法糖 - -——>——>——>——>——>——>——> [装饰器](application-dev/ui/ts-syntactic-sugar-decorator.md) - -——>——>——>——>——>——>——> [链式调用](application-dev/ui/ts-syntactic-sugar-chaining.md) - -——>——>——>——>——>——>——> [struct对象](application-dev/ui/ts-syntactic-sugar-struct.md) - -——>——>——>——>——>——>——> [在实例化过程中省略"new"](application-dev/ui/ts-instantiating-a-struct-without-new-keyword.md) - -——>——>——>——>——>——>——> [组件创建使用独立一行](application-dev/ui/ts-using-a-separate-line-for-new-component.md) - -——>——>——>——>——>——>——> [生成器函数内使用TS语言的限制](application-dev/ui/ts-restrictions-for-generators.md) - -——>——>——>——>——> 体验声明式UI - -——>——>——>——>——>——> [创建声明式UI工程](application-dev/ui/ui-ts-creating-project.md) - -——>——>——>——>——>——> [初识Component](application-dev/ui/ui-ts-components.md) - -——>——>——>——>——>——> [创建简单视图](application-dev/ui/ui-ts-creating-simple-page.md) - -——>——>——>——>——> 页面布局与连接 - -——>——>——>——>——>——> [构建食物数据模型](application-dev/ui/ui-ts-building-data-model.md) - -——>——>——>——>——>——> [构建食物列表List布局](application-dev/ui/ui-ts-building-category-list-layout.md) - -——>——>——>——>——>——> [构建食物分类Grid布局](application-dev/ui/ui-ts-building-category-grid-layout.md) - -——>——>——>——>——>——> [页面跳转与数据传递](application-dev/ui/ui-ts-page-redirection-data-transmission.md) - -——>——>——> 媒体 - -——>——>——>——> 音频 - -——>——>——>——>——> [音频开发概述](application-dev/media/audio-overview.md) - -——>——>——>——>——> [音频播放开发指导](application-dev/media/audio-playback.md) - -——>——>——>——>——> [音频管理开发指导](application-dev/media/audio-management.md) - -——>——>——>——>——> [音频录制开发指导](application-dev/media/audio-recorder.md) - -——>——>——> 用户认证 - -——>——>——>——> [用户认证开发概述](application-dev/security/userauth-overview.md) - -——>——>——>——> [用户认证开发指导](application-dev/security/userauth-guidelines.md) - -——>——>——> IPC与RPC通信 - -——>——>——>——> [IPC与RPC通信概述](application-dev/connectivity/ipc-rpc-overview.md) - -——>——>——>——> [IPC与RPC通信开发指导](application-dev/connectivity/ipc-rpc-development-guideline.md) - -——>——>——>——> [远端状态订阅开发实例](application-dev/connectivity/subscribe-remote-state.md) - -——>——>——> 分布式数据服务 - -——>——>——>——> [分布式数据服务概述](application-dev/database/database-mdds-overview.md) - -——>——>——>——> [分布式数据服务开发指导](application-dev/database/database-mdds-guidelines.md) - -——>——>——> USB服务 - -——>——>——>——> [USB服务开发概述](application-dev/usb/usb-overview.md) - -——>——>——>——> [USB服务开发指导](application-dev/usb/usb-guidelines.md) - -——>——>——> DFX - -——>——>——>——> [应用事件打点概述](application-dev/dfx/hiappevent-overview.md) - -——>——>——>——> [应用事件开发指导](application-dev/dfx/hiappevent-guidelines.md) - -——>——>——> [DevEco Studio(OpenHarmony)使用指南](application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md) - -——>——>——>——> [概述](application-dev/quick-start/deveco-studio-overview.md) - -——>——>——>——> [版本变更说明](application-dev/quick-start/deveco-studio-release-notes.md) - -——>——>——>——> [配置OpenHarmony SDK](application-dev/quick-start/configuring-openharmony-sdk.md) - -——>——>——>——> [创建OpenHarmony工程](application-dev/quick-start/create-openharmony-project.md) - -——>——>——>——>——> [使用工程向导创建新工程](application-dev/quick-start/use-wizard-to-create-project.md) - -——>——>——>——>——> [通过导入Sample方式创建新工程](application-dev/quick-start/import-sample-to-create-project.md) - -——>——>——>——> [配置OpenHarmony应用签名信息](application-dev/quick-start/configuring-openharmony-app-signature.md) - -——>——>——>——> [安装运行OpenHarmony应用](application-dev/quick-start/installing-openharmony-app.md) - -——>——> 调测 - -——>——>——> [测试用例开发](device-dev/subsystems/subsys-testguide-test.md) - -——>——>——> [调测工具](device-dev/subsystems/subsys-toolchain.md) - -——>——>——>——> [bytrace使用指导](device-dev/subsystems/subsys-toolchain-bytrace-guide.md) - -——>——>——>——> [hdc\_std 使用指导](device-dev/subsystems/subsys-toolchain-hdc-guide.md) - -——>——> XTS认证 - -——>——>——> [XTS认证用例开发指导](device-dev/subsystems/subsys-xts-guide.md) - -——>——> 工具 - -——>——>——> [Docker编译环境](device-dev/get-code/gettools-acquire.md) - -——>——>——> [IDE集成开发环境](device-dev/get-code/gettools-ide.md) - -——>——> 参考 - -——>——>——> [JS API参考](application-dev/reference/apis/Readme-CN.md) - -——>——>——>——> Ability框架 - -——>——>——>——>——> [FeatureAbility模块](application-dev/reference/apis/js-apis-featureAbility.md) - -——>——>——>——>——> [ParticleAbility模块](application-dev/reference/apis/js-apis-particleAbility.md) - -——>——>——>——>——> [DataAbilityHelper模块](application-dev/reference/apis/js-apis-dataAbilityHelper.md) - -——>——>——>——>——> [DataUriUtils模块](application-dev/reference/apis/js-apis-DataUriUtils.md) - -——>——>——>——>——> [Bundle模块](application-dev/reference/apis/js-apis-Bundle.md) - -——>——>——>——>——> [CommonEvent模块](application-dev/reference/apis/js-apis-commonEvent.md) - -——>——>——>——>——> [Notification模块](application-dev/reference/apis/js-apis-notification.md) - -——>——>——>——>——> [Context模块](application-dev/reference/apis/js-apis-Context.md) - -——>——>——>——> 资源管理 - -——>——>——>——>——> [资源管理](application-dev/reference/apis/js-apis-resource-manager.md) - -——>——>——>——>——> [国际化(I18n)](application-dev/reference/apis/js-apis-i18n.md) - -——>——>——>——>——> [国际化(Intl)](application-dev/reference/apis/js-apis-intl.md) - -——>——>——>——> 媒体 - -——>——>——>——>——> [音频管理](application-dev/reference/apis/js-apis-audio.md) - -——>——>——>——>——> [媒体服务](application-dev/reference/apis/js-apis-media.md) - -——>——>——>——> 安全 - -——>——>——>——>——> [用户认证](application-dev/reference/apis/js-apis-useriam-userauth.md) - -——>——>——>——> 数据管理 - -——>——>——>——>——> [轻量级存储](application-dev/reference/apis/js-apis-data-preferences.md) - -——>——>——>——>——> [轻量级存储(废弃 since 8)](application-dev/reference/apis/js-apis-data-storage.md) - -——>——>——>——>——> [分布式数据管理](application-dev/reference/apis/js-apis-distributed-data.md) - -——>——>——>——>——> [关系型数据库](application-dev/reference/apis/js-apis-data-rdb.md) - -——>——>——>——>——> [结果集](application-dev/reference/apis/js-apis-data-resultset.md) - -——>——>——>——>——> [DataAbility 谓词](application-dev/reference/apis/js-apis-data-ability.md) - -——>——>——>——>——> [设置数据项名称](application-dev/reference/apis/js-apis-settings.md) - -——>——>——>——> 文件管理 - -——>——>——>——>——> [文件管理](application-dev/reference/apis/js-apis-fileio.md) - -——>——>——>——>——> [Statfs管理](application-dev/reference/apis/js-apis-statfs.md) - -——>——>——>——>——> [目录环境](application-dev/reference/apis/js-apis-environment.md) - -——>——>——>——> 账号管理 - -——>——>——>——>——> [分布式帐号管理](application-dev/reference/apis/js-apis-distributed-account.md) - -——>——>——>——>——>[应用帐号管理](application-dev/reference/apis/js-apis-appAccount.md) - -——>——>——>——> 电话服务 - -——>——>——>——>——> [拨打电话](application-dev/reference/apis/js-apis-call.md) - -——>——>——>——>——> [短信服务](application-dev/reference/apis/js-apis-sms.md) - -——>——>——>——>——> [SIM卡管理](application-dev/reference/apis/js-apis-sim.md) - -——>——>——>——>——> [网络搜索](application-dev/reference/apis/js-apis-radio.md) - -——>——>——>——> 网络与连接 - -——>——>——>——>——> [WLAN](application-dev/reference/apis/js-apis-wifi.md) - -——>——>——>——> 设备管理 - -——>——>——>——>——> [传感器](application-dev/reference/apis/js-apis-sensor.md) - -——>——>——>——>——> [振动](application-dev/reference/apis/js-apis-vibrator.md) - -——>——>——>——>——> [屏幕亮度](application-dev/reference/apis/js-apis-brightness.md) - -——>——>——>——>——> [电量信息](application-dev/reference/apis/js-apis-battery-info.md) - -——>——>——>——>——> [系统电源管理](application-dev/reference/apis/js-apis-power.md) - -——>——>——>——>——> [Runninglock锁](application-dev/reference/apis/js-apis-runninglock.md) - -——>——>——>——>——> [设备信息](application-dev/reference/apis/js-apis-device-info.md) - -——>——>——>——>——> [系统属性](application-dev/reference/apis/js-apis-system-parameter.md) - -——>——>——>——>——> [设备管理](application-dev/reference/apis/js-apis-device-manager.md) - -——>——>——>——>——> [窗口](application-dev/reference/apis/js-apis-window.md) - -——>——>——>——>——> [显示设备属性](application-dev/reference/apis/js-apis-display.md) - -——>——>——>——>——> [升级](application-dev/reference/apis/js-apis-update.md) - -——>——>——>——>——> [USB管理](application-dev/reference/apis/js-apis-usb.md) - -——>——>——>——> 基本功能 - -——>——>——>——>——> [应用上下文](application-dev/reference/apis/js-apis-basic-features-app-context.md) - -——>——>——>——>——> [日志打印](application-dev/reference/apis/js-apis-basic-features-logs.md) - -——>——>——>——>——> [页面路由](application-dev/reference/apis/js-apis-basic-features-routes.md) - -——>——>——>——>——> [弹窗](application-dev/reference/apis/js-apis-basic-features-pop-up.md) - -——>——>——>——>——> [应用配置](application-dev/reference/apis/js-apis-basic-features-configuration.md) - -——>——>——>——>——> [定时器](application-dev/reference/apis/js-apis-basic-features-timer.md) - -——>——>——>——>——> [设置系统时间](application-dev/reference/apis/js-apis-system-time.md) - -——>——>——>——>——> [动画](application-dev/reference/apis/js-apis-basic-features-animator.md) - -——>——>——>——>——> [应用打点](application-dev/reference/apis/js-apis-hiappevent.md) - -——>——>——>——>——> [性能打点](application-dev/reference/apis/js-apis-bytrace.md) - -——>——>——>——>——> [故障日志获取](application-dev/reference/apis/js-apis-faultLogger.md) - -——>——>——>——> 语言基础类库 - -——>——>——>——>——> [获取进程相关的信息](application-dev/reference/apis/js-apis-process.md) - -——>——>——>——>——> [URL字符串解析](application-dev/reference/apis/js-apis-url.md) - -——>——>——>——>——> [URI字符串解析](application-dev/reference/apis/js-apis-uri.md) - -——>——>——>——>——> [util工具函数](application-dev/reference/apis/js-apis-util.md) - -——>——>——>——>——> [xml解析与生成](application-dev/reference/apis/js-apis-xml.md) - -——>——>——>——>——> [xml转换JavaScript](application-dev/reference/apis/js-apis-convertxml.md) - -——>——>——>——>——> [启动一个worker](application-dev/reference/apis/js-apis-worker.md) - -——>——>——> ArkUI组件参考 - -——>——>——>——> [基于JS扩展的类Web开发范式](application-dev/reference/arkui-js/Readme-CN.md) - -——>——>——>——>——> 组件 - -——>——>——>——>——>——> 通用 - -——>——>——>——>——>——>——> [通用属性](application-dev/reference/arkui-js/js-components-common-attributes.md) - -——>——>——>——>——>——>——> [通用样式](application-dev/reference/arkui-js/js-components-common-styles.md) - -——>——>——>——>——>——>——> [通用事件](application-dev/reference/arkui-js/js-components-common-events.md) - -——>——>——>——>——>——>——> [通用方法](application-dev/reference/arkui-js/js-components-common-methods.md) - -——>——>——>——>——>——>——> [动画样式](application-dev/reference/arkui-js/js-components-common-animation.md) - -——>——>——>——>——>——>——> [渐变样式](application-dev/reference/arkui-js/js-components-common-gradient.md) - -——>——>——>——>——>——>——> [转场样式](application-dev/reference/arkui-js/js-components-common-transition.md) - -——>——>——>——>——>——>——> [媒体查询](application-dev/reference/arkui-js/js-components-common-mediaquery.md) - -——>——>——>——>——>——>——> [自定义字体样式](application-dev/reference/arkui-js/js-components-common-customizing-font.md) - -——>——>——>——>——>——>——> [原子布局](application-dev/reference/arkui-js/js-components-common-atomic-layout.md) - -——>——>——>——>——>——> 容器组件 - -——>——>——>——>——>——>——> [badge](application-dev/reference/arkui-js/js-components-container-badge.md) - -——>——>——>——>——>——>——> [dialog](application-dev/reference/arkui-js/js-components-container-dialog.md) - -——>——>——>——>——>——>——> [div](application-dev/reference/arkui-js/js-components-container-div.md) - -——>——>——>——>——>——>——> [form](application-dev/reference/arkui-js/js-components-container-form.md) - -——>——>——>——>——>——>——> [list](application-dev/reference/arkui-js/js-components-container-list.md) - -——>——>——>——>——>——>——> [list-item](application-dev/reference/arkui-js/js-components-container-list-item.md) - -——>——>——>——>——>——>——> [list-item-group](application-dev/reference/arkui-js/js-components-container-list-item-group.md) - -——>——>——>——>——>——>——> [panel](application-dev/reference/arkui-js/js-components-container-panel.md) - -——>——>——>——>——>——>——> [popup](application-dev/reference/arkui-js/js-components-container-popup.md) - -——>——>——>——>——>——>——> [refresh](application-dev/reference/arkui-js/js-components-container-refresh.md) - -——>——>——>——>——>——>——> [stack](application-dev/reference/arkui-js/js-components-container-stack.md) - -——>——>——>——>——>——>——> [stepper](application-dev/reference/arkui-js/js-components-container-stepper.md) - -——>——>——>——>——>——>——> [stepper-item](application-dev/reference/arkui-js/js-components-container-stepper-item.md) - -——>——>——>——>——>——>——> [swiper](application-dev/reference/arkui-js/js-components-container-swiper.md) - -——>——>——>——>——>——>——> [tabs](application-dev/reference/arkui-js/js-components-container-tabs.md) - -——>——>——>——>——>——>——> [tab-bar](application-dev/reference/arkui-js/js-components-container-tab-bar.md) - -——>——>——>——>——>——>——> [tab-content](application-dev/reference/arkui-js/js-components-container-tab-content.md) - -——>——>——>——>——>——> 基础组件 - -——>——>——>——>——>——>——> [button](application-dev/reference/arkui-js/js-components-basic-button.md) - -——>——>——>——>——>——>——> [chart](application-dev/reference/arkui-js/js-components-basic-chart.md) - -——>——>——>——>——>——>——> [divider](application-dev/reference/arkui-js/js-components-basic-divider.md) - -——>——>——>——>——>——>——> [image](application-dev/reference/arkui-js/js-components-basic-image.md) - -——>——>——>——>——>——>——> [image-animator](application-dev/reference/arkui-js/js-components-basic-image-animator.md) - -——>——>——>——>——>——>——> [input](application-dev/reference/arkui-js/js-components-basic-input.md) - -——>——>——>——>——>——>——> [label](application-dev/reference/arkui-js/js-components-basic-label.md) - -——>——>——>——>——>——>——> [marquee](application-dev/reference/arkui-js/js-components-basic-marquee.md) - -——>——>——>——>——>——>——> [menu](application-dev/reference/arkui-js/js-components-basic-menu.md) - -——>——>——>——>——>——>——> [option](application-dev/reference/arkui-js/js-components-basic-option.md) - -——>——>——>——>——>——>——> [picker](application-dev/reference/arkui-js/js-components-basic-picker.md) - -——>——>——>——>——>——>——> [picker-view](application-dev/reference/arkui-js/js-components-basic-picker-view.md) - -——>——>——>——>——>——>——> [piece](application-dev/reference/arkui-js/js-components-basic-piece.md) - -——>——>——>——>——>——>——> [progress](application-dev/reference/arkui-js/js-components-basic-progress.md) - -——>——>——>——>——>——>——> [qrcode](application-dev/reference/arkui-js/js-components-basic-qrcode.md) - -——>——>——>——>——>——>——> [rating](application-dev/reference/arkui-js/js-components-basic-rating.md) - -——>——>——>——>——>——>——> [richtext](application-dev/reference/arkui-js/js-components-basic-richtext.md) - -——>——>——>——>——>——>——> [search](application-dev/reference/arkui-js/js-components-basic-search.md) - -——>——>——>——>——>——>——> [select](application-dev/reference/arkui-js/js-components-basic-select.md) - -——>——>——>——>——>——>——> [slider](application-dev/reference/arkui-js/js-components-basic-slider.md) - -——>——>——>——>——>——>——> [span](application-dev/reference/arkui-js/js-components-basic-span.md) - -——>——>——>——>——>——>——> [switch](application-dev/reference/arkui-js/js-components-basic-switch.md) - -——>——>——>——>——>——>——> [text](application-dev/reference/arkui-js/js-components-basic-text.md) - -——>——>——>——>——>——>——> [textarea](application-dev/reference/arkui-js/js-components-basic-textarea.md) - -——>——>——>——>——>——>——> [toolbar](application-dev/reference/arkui-js/js-components-basic-toolbar.md) - -——>——>——>——>——>——>——> [toolbar-item](application-dev/reference/arkui-js/js-components-basic-toolbar-item.md) - -——>——>——>——>——>——>——> [toggle](application-dev/reference/arkui-js/js-components-basic-toggle.md) - -——>——>——>——>——>——> 媒体组件 - -——>——>——>——>——>——>——> [video](application-dev/reference/arkui-js/js-components-media-video.md) - -——>——>——>——>——>——> 画布组件 - -——>——>——>——>——>——>——> [canvas组件](application-dev/reference/arkui-js/js-components-canvas-canvas.md) - -——>——>——>——>——>——>——> [CanvasRenderingContext2D对象](application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) - -——>——>——>——>——>——>——> [Image对象](application-dev/reference/arkui-js/js-components-canvas-image.md) - -——>——>——>——>——>——>——> [CanvasGradient对象](application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md) - -——>——>——>——>——>——>——> [ImageData对象](application-dev/reference/arkui-js/js-components-canvas-imagedata.md) - -——>——>——>——>——>——>——> [Path2D对象](application-dev/reference/arkui-js/js-components-canvas-path2d.md) - -——>——>——>——>——>——>——> [ImageBitmap对象](application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md) - -——>——>——>——>——>——>——> [OffscreenCanvas对象](application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md) - -——>——>——>——>——>——>——> [OffscreenCanvasRenderingContext2D对象](application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) - -——>——>——>——>——>——> 栅格组件 - -——>——>——>——>——>——>——> [基本概念](application-dev/reference/arkui-js/js-components-grid-basic-concepts.md) - -——>——>——>——>——>——>——> [grid-container](application-dev/reference/arkui-js/js-components-grid-container.md) - -——>——>——>——>——>——>——> [grid-row](application-dev/reference/arkui-js/js-components-grid-row.md) - -——>——>——>——>——>——>——> [grid-col](application-dev/reference/arkui-js/js-components-grid-col.md) - -——>——>——>——>——>——> svg组件 - -——>——>——>——>——>——>——> [通用属性](application-dev/reference/arkui-js/js-components-svg-common-attributes.md) - -——>——>——>——>——>——>——> [svg](application-dev/reference/arkui-js/js-components-svg.md) - -——>——>——>——>——>——>——> [rect](application-dev/reference/arkui-js/js-components-svg-rect.md) - -——>——>——>——>——>——>——> [circle](application-dev/reference/arkui-js/js-components-svg-circle.md) - -——>——>——>——>——>——>——> [ellipse](application-dev/reference/arkui-js/js-components-svg-ellipse.md) - -——>——>——>——>——>——>——> [path](application-dev/reference/arkui-js/js-components-svg-path.md) - -——>——>——>——>——>——>——> [line](application-dev/reference/arkui-js/js-components-svg-line.md) - -——>——>——>——>——>——>——> [polyline](application-dev/reference/arkui-js/js-components-svg-polyline.md) - -——>——>——>——>——>——>——> [polygon](application-dev/reference/arkui-js/js-components-svg-polygon.md) - -——>——>——>——>——>——>——> [text](application-dev/reference/arkui-js/js-components-svg-text.md) - -——>——>——>——>——>——>——> [tspan](application-dev/reference/arkui-js/js-components-svg-tspan.md) - -——>——>——>——>——>——>——> [textPath](application-dev/reference/arkui-js/js-components-svg-textpath.md) - -——>——>——>——>——>——>——> [animate](application-dev/reference/arkui-js/js-components-svg-animate.md) - -——>——>——>——>——>——>——> [animateMotion](application-dev/reference/arkui-js/js-components-svg-animatemotion.md) - -——>——>——>——>——>——>——> [animateTransform](application-dev/reference/arkui-js/js-components-svg-animatetransform.md) - -——>——>——>——>——> 自定义组件 - -——>——>——>——>——>——> [基本用法](application-dev/reference/arkui-js/js-components-custom-basic-usage.md) - -——>——>——>——>——>——> [自定义事件](application-dev/reference/arkui-js/js-components-custom-events.md) - -——>——>——>——>——>——> [Props](application-dev/reference/arkui-js/js-components-custom-props.md) - -——>——>——>——>——>——> [事件参数](application-dev/reference/arkui-js/js-components-custom-event-parameter.md) - -——>——>——>——>——>——> [slot插槽](application-dev/reference/arkui-js/js-components-custom-slot.md) - -——>——>——>——>——>——> [生命周期定义](application-dev/reference/arkui-js/js-components-custom-lifecycle.md) - -——>——>——>——>——> [附录](application-dev/reference/arkui-js/js-appendix.md) - -——>——>——>——>——>——> [类型说明](application-dev/reference/arkui-js/js-appendix-types.md) - -——>——>——>——> [基于TS扩展的声明式开发范式](application-dev/reference/arkui-ts/Readme-CN.md) - -——>——>——>——>——> 组件 - -——>——>——>——>——>——> 通用 - -——>——>——>——>——>——>——> [通用事件](application-dev/reference/arkui-ts/ts-universal-events.md) - -——>——>——>——>——>——>——>——> [点击事件](application-dev/reference/arkui-ts/ts-universal-events-click.md) - -——>——>——>——>——>——>——>——> [触摸事件](application-dev/reference/arkui-ts/ts-universal-events-touch.md) - -——>——>——>——>——>——>——>——> [挂载卸载事件](application-dev/reference/arkui-ts/ts-universal-events-show-hide.md) - -——>——>——>——>——>——>——>——> [按键事件](application-dev/reference/arkui-ts/ts-universal-events-key.md) - -——>——>——>——>——>——>——>——>[组件区域变化事件](application-dev/reference/arkui-ts/ts-universal-events-component-area-change.md) - -——>——>——>——>——>——>——> 通用属性 - -——>——>——>——>——>——>——>——> [尺寸设置](application-dev/reference/arkui-ts/ts-universal-attributes-size.md) - -——>——>——>——>——>——>——>——> [位置设置](application-dev/reference/arkui-ts/ts-universal-attributes-location.md) - -——>——>——>——>——>——>——>——> [布局约束](application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md) - -——>——>——>——>——>——>——>——> [Flex布局](application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md) - -——>——>——>——>——>——>——>——> [边框设置](application-dev/reference/arkui-ts/ts-universal-attributes-border.md) - -——>——>——>——>——>——>——>——> [背景设置](application-dev/reference/arkui-ts/ts-universal-attributes-background.md) - -——>——>——>——>——>——>——>——> [透明度设置](application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md) - -——>——>——>——>——>——>——>——> [显隐控制](application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md) - -——>——>——>——>——>——>——>——> [禁用控制](application-dev/reference/arkui-ts/ts-universal-attributes-enable.md) - -——>——>——>——>——>——>——>——> [浮层](application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md) - -——>——>——>——>——>——>——>——> [Z序控制](application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md) - -——>——>——>——>——>——>——>——> [图形变换](application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md) - -——>——>——>——>——>——>——>——> [图像效果](application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md) - -——>——>——>——>——>——>——>——> [形状裁剪](application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) - -——>——>——>——>——>——>——>——> [文本样式设置](application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md) - -——>——>——>——>——>——>——>——> [栅格设置](application-dev/reference/arkui-ts/ts-universal-attributes-grid.md) - -——>——>——>——>——>——>——>——> [颜色渐变](application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md) - -——>——>——>——>——>——>——>——> [Popup控制](application-dev/reference/arkui-ts/ts-universal-attributes-popup.md) - -——>——>——>——>——>——>——>——> [Menu控制](application-dev/reference/arkui-ts/ts-universal-attributes-menu.md) - -——>——>——>——>——>——>——>——>[点击控制](application-dev/reference/arkui-ts/ts-universal-attributes-touchable.md) - -——>——>——>——>——>——>——>——>[触摸热区设置](application-dev/reference/arkui-ts/ts-universal-attributes-response-region.md) - -——>——>——>——>——>——>——> 手势处理 - -——>——>——>——>——>——>——>——> [绑定手势方法](application-dev/reference/arkui-ts/ts-gesture-settings.md) - -——>——>——>——>——>——>——>——> 基础手势 - -——>——>——>——>——>——>——>——>——> [TapGesture](application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md) - -——>——>——>——>——>——>——>——>——> [LongPressGesture](application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md) - -——>——>——>——>——>——>——>——>——> [PanGesture](application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md) - -——>——>——>——>——>——>——>——>——> [PinchGesture](application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md) - -——>——>——>——>——>——>——>——>——> [RotationGesture](application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md) - -——>——>——>——>——>——>——>——>——> [SwipeGesture](application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md) - -——>——>——>——>——>——>——>——> [组合手势](application-dev/reference/arkui-ts/ts-combined-gestures.md) - -——>——>——>——>——>——> 基础组件 - -——>——>——>——>——>——>——> [Blank](application-dev/reference/arkui-ts/ts-basic-components-blank.md) - -——>——>——>——>——>——>——> [Button](application-dev/reference/arkui-ts/ts-basic-components-button.md) - -——>——>——>——>——>——>——> [DataPanel](application-dev/reference/arkui-ts/ts-basic-components-datapanel.md) - -——>——>——>——>——>——>——> [Divider](application-dev/reference/arkui-ts/ts-basic-components-divider.md) - -——>——>——>——>——>——>——>[Gauge](application-dev/reference/arkui-ts/ts-basic-components-gauge.md) - -——>——>——>——>——>——>——> [Image](application-dev/reference/arkui-ts/ts-basic-components-image.md) - -——>——>——>——>——>——>——> [ImageAnimator](application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md) - -——>——>——>——>——>——>——> [Progress](application-dev/reference/arkui-ts/ts-basic-components-progress.md) - -——>——>——>——>——>——>——> [QRCode](application-dev/reference/arkui-ts/ts-basic-components-qrcode.md) - -——>——>——>——>——>——>——> [Rating](application-dev/reference/arkui-ts/ts-basic-components-rating.md) - -——>——>——>——>——>——>——> [Span](application-dev/reference/arkui-ts/ts-basic-components-span.md) - -——>——>——>——>——>——>——> [Slider](application-dev/reference/arkui-ts/ts-basic-components-slider.md) - -——>——>——>——>——>——>——> [Text](application-dev/reference/arkui-ts/ts-basic-components-text.md) - -——>——>——>——>——>——>——> [TextArea](application-dev/reference/arkui-ts/ts-basic-components-textarea.md) - -——>——>——>——>——>——>——> [TextInput](application-dev/reference/arkui-ts/ts-basic-components-textinput.md) - -——>——>——>——>——>——>——> [Toggle](application-dev/reference/arkui-ts/ts-basic-components-toggle.md) - -——>——>——>——>——>——> 容器组件 - -——>——>——>——>——>——>——> [AlphabetIndexer](application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md) - -——>——>——>——>——>——>——> [Badge](application-dev/reference/arkui-ts/ts-container-badge.md) - -——>——>——>——>——>——>——> [Column](application-dev/reference/arkui-ts/ts-container-column.md) - -——>——>——>——>——>——>——> [ColumnSplit](application-dev/reference/arkui-ts/ts-container-columnsplit.md) - -——>——>——>——>——>——>——> [Counter](application-dev/reference/arkui-ts/ts-container-counter.md) - -——>——>——>——>——>——>——> [Flex](application-dev/reference/arkui-ts/ts-container-flex.md) - -——>——>——>——>——>——>——> [GridContainer](application-dev/reference/arkui-ts/ts-container-gridcontainer.md) - -——>——>——>——>——>——>——> [Grid](application-dev/reference/arkui-ts/ts-container-grid.md) - -——>——>——>——>——>——>——> [GridItem](application-dev/reference/arkui-ts/ts-container-griditem.md) - -——>——>——>——>——>——>——> [List](application-dev/reference/arkui-ts/ts-container-list.md) - -——>——>——>——>——>——>——> [ListItem](application-dev/reference/arkui-ts/ts-container-listitem.md) - -——>——>——>——>——>——>——> [Navigator](application-dev/reference/arkui-ts/ts-container-navigator.md) - -——>——>——>——>——>——>——> [Navigation](application-dev/reference/arkui-ts/ts-container-navigation.md) - -——>——>——>——>——>——>——> [Panel](application-dev/reference/arkui-ts/ts-container-panel.md) - -——>——>——>——>——>——>——> [Row](application-dev/reference/arkui-ts/ts-container-row.md) - -——>——>——>——>——>——>——> [RowSplit](application-dev/reference/arkui-ts/ts-container-rowsplit.md) - -——>——>——>——>——>——>——> [Scroll](application-dev/reference/arkui-ts/ts-container-scroll.md) - -——>——>——>——>——>——>——> [ScrollBar](application-dev/reference/arkui-ts/ts-container-scrollbar.md) - -——>——>——>——>——>——>——> [Stack](application-dev/reference/arkui-ts/ts-container-stack.md) - -——>——>——>——>——>——>——> [Swiper](application-dev/reference/arkui-ts/ts-container-swiper.md) - -——>——>——>——>——>——>——> [Tabs](application-dev/reference/arkui-ts/ts-container-tabs.md) - -——>——>——>——>——>——>——> [TabContent](application-dev/reference/arkui-ts/ts-container-tabcontent.md) - -——>——>——>——>——>——>——> [Stepper](application-dev/reference/arkui-ts/ts-container-stepper.md) - -——>——>——>——>——>——>——> [StepperItem](application-dev/reference/arkui-ts/ts-container-stepperitem.md) - -——>——>——>——>——>——> 绘制组件 - -——>——>——>——>——>——>——> [Circle](application-dev/reference/arkui-ts/ts-drawing-components-circle.md) - -——>——>——>——>——>——>——> [Ellipse](application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md) - -——>——>——>——>——>——>——> [Line](application-dev/reference/arkui-ts/ts-drawing-components-line.md) - -——>——>——>——>——>——>——> [Polyline](application-dev/reference/arkui-ts/ts-drawing-components-polyline.md) - -——>——>——>——>——>——>——> [Polygon](application-dev/reference/arkui-ts/ts-drawing-components-polygon.md) - -——>——>——>——>——>——>——> [Path](application-dev/reference/arkui-ts/ts-drawing-components-path.md) - -——>——>——>——>——>——>——> [Rect](application-dev/reference/arkui-ts/ts-drawing-components-rect.md) - -——>——>——>——>——>——>——> [Shape](application-dev/reference/arkui-ts/ts-drawing-components-shape.md)‘ - -——>——>——>——>——>——>画布组件 - -——>——>——>——>——>——>——>[Canvas](application-dev/reference/arkui-ts/ts-components-canvas-canvas.md) - -——>——>——>——>——>——>——>[CanvasRenderingContext2D对象](application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md) - -——>——>——>——>——>——>——>[OffscreenCanvasRenderingConxt2D对象](application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md) - -——>——>——>——>——>——>——>[Lottie](application-dev/reference/arkui-ts/ts-components-canvas-lottie.md) - -——>——>——>——>——>——>——>[Path2D对象](application-dev/reference/arkui-ts/ts-components-canvas-path2d.md) - -——>——>——>——>——>——>——>[CanvasGradient对象](application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md) - -——>——>——>——>——>——>——>[ImageBitmap对象](application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md) - -——>——>——>——>——>——>——>[ImageData对象](application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md) - -——>——>——>——>——> 动画 - -——>——>——>——>——>——> [属性动画](application-dev/reference/arkui-ts/ts-animatorproperty.md) - -——>——>——>——>——>——> [显式动画](application-dev/reference/arkui-ts/ts-explicit-animation.md) - -——>——>——>——>——>——> 转场动画 - -——>——>——>——>——>——>——> [页面间转场](application-dev/reference/arkui-ts/ts-page-transition-animation.md) - -——>——>——>——>——>——>——> [组件内转场](application-dev/reference/arkui-ts/ts-transition-animation-component.md) - -——>——>——>——>——>——>——> [共享元素转场](application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md) - -——>——>——>——>——>——> [路径动画](application-dev/reference/arkui-ts/ts-motion-path-animation.md) - -——>——>——>——>——>——> [矩阵变换](application-dev/reference/arkui-ts/ts-matrix-transformation.md) - -——>——>——>——>——>——> [插值计算](application-dev/reference/arkui-ts/ts-interpolation-calculation.md) - -——>——>——>——>——> 全局UI方法 - -——>——>——>——>——>——> [警告弹窗](application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md) - -——>——>——>——>——>——> [自定义弹窗](application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md) - -——>——>——>——>——>——> [图片缓存](application-dev/reference/arkui-ts/ts-methods-image-cache.md) - -——>——>——>——>——>——> [媒体查询](application-dev/reference/arkui-ts/ts-methods-media-query.md) - -——>——>——>——>——> 附录 - -——>——>——>——>——>——> [文档中涉及到的内置枚举值](application-dev/reference/arkui-ts/ts-appendix-enums.md) - -——>——>——>[应用开发包结构说明](application-dev/quick-start/package-structure.md) - -——>——>——> 常见问题-设备开发 - -——>——>——>——>[常见问题概述](device-dev/faqs/faqs-overview.md) - -——>——>——>——>[环境搭建常见问题](device-dev/faqs/faqs-environment-building.md) - -——>——>——>——>[编译构建子系统常见问题](device-dev/faqs/faqs-building.md) - -——>——>——>——>[烧录常见问题](device-dev/faqs/faqs-burning.md) - -——>——>——>——>[内核常见问题](device-dev/faqs/faqs-kernel.md) - -——>——>——>——>[移植常见问题](device-dev/faqs/faqs-transplant.md) - -——>——>——>——>[启动恢复常见问题](device-dev/faqs/faqs-init.md) - -——>——>——>——>[系统应用常见问题](device-dev/faqs/faqs-system-using.md) - -——>——> 贡献 - -——>——>——>[参与贡献](contribute/参与贡献.md) - -——>——>——> [行为准则](contribute/行为准则.md) - -——>——>——>[贡献代码](contribute/贡献代码.md) - -——>——>——>[贡献流程](contribute/贡献流程.md) - -——>——>——> [贡献文档](contribute/贡献文档.md) - -——>——>——>——>[写作规范](contribute/写作规范.md) - -——>——>——>——>[为发行版本撰写配套文档](contribute/docs-release-process.md) - -——>——>——>[社区沟通与交流](contribute/社区沟通与交流.md) - -——>——>——>[FAQ](contribute/FAQ.md) diff --git a/zh-cn/website.md b/zh-cn/website.md new file mode 100644 index 0000000000000000000000000000000000000000..385f5d06bd2d926acedc14a3c3838a982f3c8506 --- /dev/null +++ b/zh-cn/website.md @@ -0,0 +1,36 @@ +# 了解OpenHarmony + +- [了解OpenHarmony开源项目](OpenHarmony-Overview_zh.md) +- [术语](device-dev/glossary/glossary.md) +- 版本说明 + - OpenHarmony 3.x Releases + + - [OpenHarmony v3.1 Beta (2021-12-31)](release-notes/OpenHarmony-v3.1-beta.md) + - [OpenHarmony v3.0.1 LTS (2022-01-12)](release-notes/OpenHarmony-v3.0.1-LTS.md) + - [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md) + + - OpenHarmony 2.x Releases + + - [OpenHarmony v2.2 beta2 (2021-08-04)](release-notes/OpenHarmony-v2.2-beta2.md) + - [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md) + + - OpenHarmony 1.x Releases + + - [OpenHarmony v1.1.4 LTS (2022-02-11)](release-notes/OpenHarmony-v1-1-4-LTS.md) + - [OpenHarmony v1.1.3 LTS (2021-09-30)](release-notes/OpenHarmony-v1-1-3-LTS.md) + - [OpenHarmony v1.1.2 LTS (2021-08-04)](release-notes/OpenHarmony-v1.1.2-LTS.md) + - [OpenHarmony 1.1.1 LTS (2021-06-22)](release-notes/OpenHarmony-1-1-1-LTS.md) + - [OpenHarmony 1.1.0 LTS (2021-04-01)](release-notes/OpenHarmony-1-1-0-LTS.md) + - [OpenHarmony 1.0 (2020-09-10)](release-notes/OpenHarmony-1-0.md) + +- 贡献 + - [参与贡献](contribute/参与贡献.md) + - [行为准则](contribute/行为准则.md) + - [贡献代码](contribute/贡献代码.md) + - [贡献流程](contribute/贡献流程.md) + - [自测试验证](readme/测试子系统.md) + - [贡献文档](contribute/贡献文档.md) + - [写作规范](contribute/写作规范.md) + - [社区沟通与交流](contribute/社区沟通与交流.md) + - [FAQ](contribute/FAQ.md) + \ No newline at end of file