diff --git a/CODEOWNERS b/CODEOWNERS index 9ffdaf23ba7351b7dd5e18b54559e424f4a2b80a..7c6530eb16de9051510d7344025cf8b61c566c78 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -231,7 +231,7 @@ zh-cn/application-dev/reference/apis/js-apis-audio.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-camera.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-image.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-media.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-i18n.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-intl.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @HelloCrease @@ -365,4 +365,7 @@ zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen zh-cn/application-dev/reference/js-service-widget-ui @HelloCrease zh-cn/application-dev/website.md @zengyawen zh-cn/application-dev/faqs/ @zengyawen -zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @zengyawen \ No newline at end of file +zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-userfilemanager.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md @zengyawen +zh-cn/application-dev/reference/apis/Readme-CN.md @zengyawen \ No newline at end of file diff --git a/OAT.xml b/OAT.xml index 8cc884632d4a963fa921c5905cfbf96e7e22edb7..4edf72f5a3b3e03801bdab83dad547cd7c0c18ef 100644 --- a/OAT.xml +++ b/OAT.xml @@ -66,7 +66,7 @@ - + diff --git a/en/application-dev/ability/stage-call.md b/en/application-dev/ability/stage-call.md index cad2aeddec2ae0782776009d4a8a9b092bace023..390e1b6c3ce5393956d0a7801f362ab7f49578a4 100644 --- a/en/application-dev/ability/stage-call.md +++ b/en/application-dev/ability/stage-call.md @@ -81,7 +81,7 @@ import Ability from '@ohos.application.Ability' ```ts export default class MySequenceable { num: number = 0 - str: String = "" + str: string = "" constructor(num, string) { this.num = num diff --git a/en/application-dev/database/database-mdds-overview.md b/en/application-dev/database/database-mdds-overview.md index 26efa7491805e871017db3593f5fa50d947717f5..cfe264a4f7eb06cd51cb834bc3e38ee27e649a14 100644 --- a/en/application-dev/database/database-mdds-overview.md +++ b/en/application-dev/database/database-mdds-overview.md @@ -1,105 +1,103 @@ # Distributed Data Service Overview -The distributed data service (DDS) implements distributed database collaboration across devices for applications. +The distributed data service (DDS) implements distributed database collaboration across devices for applications. Applications save data to distributed databases by calling the DDS APIs. The DDS isolates data of different applications based on a triplet of account, application, and database to ensure secure data access. The DDS synchronizes application data between trusted devices to provide users with consistent data access experience on different devices. You do not need to care about the implementation of the database locking mechanism. + ## Basic Concepts -- **KV data model** +### KV Data Model - The key-value \(KV\) data model allows data to be organized, indexed, and stored in key-value pairs. +The key-value (KV) data model allows data to be organized, indexed, and stored in KV pairs. - The KV data model is suitable for storing service data that is not related. It provides better read and write performance than the SQL database. The KV data model is widely used in distributed scenarios because it handles database version compatibility issues and data synchronization conflicts easily. The distributed database is based on the KV data model and provides KV-based access interfaces. +The KV data model is suitable for storing service data that is not related. It provides better read and write performance than the SQL database. The KV data model is widely used in distributed scenarios because it handles database version compatibility issues and data synchronization conflicts easily. The distributed database is based on the KV data model and provides KV-based access interfaces. -- **Distributed database transactions** +### Distributed Database Transaction - Distributed database transactions include local transactions \(same as the transactions of traditional databases\) and synchronization transactions. Synchronization transactions allow data to be synchronized between devices by local transaction. Synchronization of a local transaction modification either succeeds or fails on all the devices. +Distributed database transactions include local transactions (same as the transactions of traditional databases) and synchronization transactions. Synchronization transactions allow data to be synchronized between devices by local transaction. Synchronization of a local transaction modification either succeeds or fails on all the devices. -- **Distributed database consistency** +### Distributed Database Consistency - In a distributed scenario, cross-device collaboration demands consistent data between the devices in the same network. The data consistency can be classified into the following types: +In a distributed scenario, cross-device collaboration demands consistent data between the devices in the same network. The data consistency can be classified into the following types: - - **Strong consistency**: When data is inserted, deleted, or modified on a device, other devices in the same network will obtain the latest data immediately. - - **Weak consistency**: When data is added, deleted, or modified on a device, other devices in the same network may or may not obtain the latest data. The data on these devices may be inconsistent after a certain period of time. - - **Eventual consistency**: When data is added, deleted, or modified on a device, other devices in the same network may not obtain the latest data immediately. However, data on these devices will become consistent after a certain period of time. +- **Strong consistency**: When data is inserted, deleted, or modified on a device, other devices in the same network will obtain the latest data immediately. +- **Weak consistency**: When data is added, deleted, or modified on a device, other devices in the same network may or may not obtain the latest data. The data on these devices may be inconsistent after a certain period of time. +- **Eventual consistency**: When data is added, deleted, or modified on a device, other devices in the same network may not obtain the latest data immediately. However, data on these devices will become consistent after a certain period of time. - Strong consistency has high requirements on distributed data management and may be used in distributed server deployment. The DDS supports only the eventual consistency because mobile devices are not always online and the network has no center. +Strong consistency has high requirements on distributed data management and may be used in distributed server deployment. The DDS supports only the eventual consistency because mobile devices are not always online and the network has no center. -- **Distributed database synchronization** +### Distributed Database Synchronization - After discovering and authenticating a device, the underlying communication component notifies the upper-layer application \(including the DDS\) that the device goes online. The DDS then establishes an encrypted transmission channel to synchronize data between the two devices. +After discovering and authenticating a device, the underlying communication component notifies the upper-layer application (including the DDS) that the device goes online. The DDS then establishes an encrypted transmission channel to synchronize data between the two devices. - The DDS provides the following synchronization modes: +The DDS provides the following synchronization modes: - - **Manual synchronization**: Applications call **sync** to trigger a synchronization. The list of devices to be synchronized and the synchronization mode must be specified. The synchronization mode can be **PULL\_ONLY** \(pulling remote data to the local end\), **PUSH\_ONLY** \(pushing local data to the remote end\), or **PUSH\_PULL** \(pushing local data to the remote end and pulling remote data to the local end\). The internal interface supports condition-based synchronization. The data that meets the conditions can be synchronized to the remote end. - - **Automatic synchronization**: includes full synchronization and condition-based subscription synchronization. In full synchronization, the distributed database automatically pushes local data to the remote end and pulls remote data to the local end when a device goes online or application data is updated. Applications do not need to call **sync**. The internal interface supports condition-based subscription synchronization. The data that meets the subscription conditions on the remote end is automatically synchronized to the local end. +- **Manual synchronization**: Applications call **sync()** to trigger a synchronization. The list of devices to be synchronized and the synchronization mode must be specified. The synchronization mode can be **PULL_ONLY** (pulling remote data to the local end), **PUSH_ONLY** (pushing local data to the remote end), or **PUSH_PULL** (pushing local data to the remote end and pulling remote data to the local end). The internal interface supports condition-based synchronization. The data that meets the conditions can be synchronized to the remote end. +- **Automatic synchronization**: includes full synchronization and condition-based subscription synchronization. In full synchronization, the distributed database automatically pushes local data to the remote end and pulls remote data to the local end when a device goes online or application data is updated. Applications do not need to call **sync()**. The internal interface supports condition-based subscription synchronization. The data that meets the subscription conditions on the remote end is automatically synchronized to the local end. -- **Single KV store** +### Single KV Store - Data is saved locally in the unit of a single KV entry. Only one entry is saved for each key. Data can be modified only locally and synchronized to remote devices in sequence based on the update time. +Data is saved locally in the unit of a single KV entry. Only one entry is saved for each key. Data can be modified only locally and synchronized to remote devices in sequence based on the update time. -- **Device KV store** +### Device KV Store - The device KV store is based on the single KV store. The local device ID is added to the key when KV data is stored in the device KV store. Data can be isolated, managed, and queried by device. However, the data synchronized from remote devices cannot be modified locally. +The device KV store is based on the single KV store. The local device ID is added to the key when KV data is stored in the device KV store. Data can be isolated, managed, and queried by device. However, the data synchronized from remote devices cannot be modified locally. -- **Conflict resolution** +### Conflict Resolution - A data conflict occurs when multiple devices modify the same data and commit the modification to the database. The last write wins \(LWW\) is the default conflict resolution policy used for data conflicts. Based on the commit timestamps, the data with a later timestamp is used. Currently, customized conflict resolution policies are not supported. +A data conflict occurs when multiple devices modify the same data and commit the modification to the database. The last write wins (LWW) is the default conflict resolution policy used for data conflicts. Based on the commit timestamps, the data with a later timestamp is used. Currently, customized conflict resolution policies are not supported. -- **Schema-based database management and data query based on predicates** +### Schema-based Database Management and Predicate-based Data Query - A schema is specified when you create or open a single KV store. Based on the schema, the database detects the value format of key-value pairs and checks the value structure. Based on the fields in the values, the database implements index creation and predicate-based query. +A schema is specified when you create or open a single KV store. Based on the schema, the database detects the value format of KV pairs and checks the value structure. Based on the fields in the values, the database implements index creation and predicate-based query. -- **Distributed database backup** +### Distributed Database Backup - The DDS provides the database backup capability. You can set **backup** to **true** to enable daily backup. If a distributed database is damaged, the DDS deletes the database and restores the most recent data from the backup database. If no backup database is available, the DDS creates one. The DDS can also back up encrypted databases. +The DDS provides the database backup capability. You can set **backup** to **true** to enable daily backup. If a distributed database is damaged, the DDS deletes the database and restores the most recent data from the backup database. If no backup database is available, the DDS creates one. The DDS can also back up encrypted databases. ## Working Principles -The DDS supports distributed management of application database data in the OpenHarmony system. Data can be synchronized between multiple devices with the same account, delivering a consistent user experience across devices. The DDS consists of the following: +The DDS supports distributed management of application database data in the OpenHarmony system. Data can be synchronized between multiple devices with the same account, delivering a consistent user experience across devices. -- **APIs** +The DDS consists of the following: - The DDS provides APIs to create databases, access data, and subscribe to data. The APIs support the KV data model and common data types. They are highly compatible and easy to use, and can be released. +- **APIs**
The DDS provides APIs to create databases, access data, and subscribe to data. The APIs support the KV data model and common data types. They are highly compatible and easy to use, and can be released. -- **Service component** +- **Service component**
The service component implements management of metadata, permissions, encryption, backup and restore, and multiple users, and completes initialization of the storage component, synchronization component, and communication adaptation layer of the distributed database. - The service component implements management of metadata, permissions, encryption, backup and restore, and multiple users, and completes initialization of the storage component, synchronization component, and communication adaptation layer of the distributed database. +- **Storage component**
The storage component implements data access, data reduction, transactions, snapshots, database encryption, data combination, and conflict resolution. -- **Storage component** +- **Synchronization component**
The synchronization component interacts with the storage component and the communication adaptation layer to maintain data consistency between online devices. It synchronizes data generated on the local device to other devices and merges data from other devices into the local device. - The storage component implements data access, data reduction, transactions, snapshots, database encryption, data combination, and conflict resolution. +- **Communication adaptation layer**
The communication adaptation layer calls APIs of the underlying public communication layer to create and connect to communication channels, receive device online and offline messages, update metadata of the connected and disconnected devices, send device online and offline messages to the synchronization component. The synchronization component updates the list of connected devices, and calls the APIs of the communication adaption layer to encapsulate data and send the data to the connected devices. -- **Synchronization component** +Applications call the DDS APIs to create, access, and subscribe to distributed databases. The APIs store data to the storage component based on the capabilities provided by the service component. The storage component interacts with the synchronization component to synchronize data. The synchronization component uses the communication adaptation layer to synchronize data to remote devices, which update the data in the storage component and provide the data for applications through service APIs. - The synchronization component interacts with the storage component and the communication adaptation layer to maintain data consistency between online devices. It synchronizes data generated on the local device to other devices and merges data from other devices into the local device. -- **Communication adaptation layer** +**Figure 1** How DDS works - The communication adaptation layer calls APIs of the underlying public communication layer to create and connect to communication channels, receive device online and offline messages, update metadata of the connected and disconnected devices, send device online and offline messages to the synchronization component. The synchronization component updates the list of connected devices, and calls the APIs of the communication adaption layer to encapsulate data and send the data to the connected devices. +![](figures/en-us_image_0000001183386164.png) -Applications call the DDS APIs to create, access, and subscribe to distributed databases. The APIs store data to the storage component based on the capabilities provided by the service component. The storage component interacts with the synchronization component to synchronize data. The synchronization component uses the communication adaptation layer to synchronize data to remote devices, which update the data in the storage component and provide the data for applications through service APIs. -**Figure 1** How DDS works +## Constraints +- The DDS supports the KV data model only. It does not support foreign keys or triggers of the relational database. -![](figures/en-us_image_0000001183386164.png) +- The KV data model specifications supported by the DDS are as follows: -## Constraints + - For each record in a device KV store, the key must be less than or equal to 896 bytes and the value be less than 4 MB. + - For each record in a single KV store, the key must be less than or equal to 1 KB and the value be less than 4 MB. + - An application can open a maximum of 16 KV stores simultaneously. + +- The data that needs to be synchronized between devices should be stored in distributed databases rather than local databases. -- The DDS supports the KV data model only. It does not support foreign keys or triggers of the relational database. -- The KV data model specifications supported by the DDS are as follows: - - For each record in a device KV store, the key must be less than or equal to 896 bytes and the value be less than 4 MB. - - For each record in a single KV store, the key must be less than or equal to 1 KB and the value be less than 4 MB. - - An application can open a maximum of 16 KV stores simultaneously. +- The DDS does not support customized conflict resolution policies. -- The data that needs to be synchronized between devices should be stored in distributed databases rather than local databases. -- The DDS does not support customized conflict resolution policies. -- The maximum number of access requests to the KvStore API is 1000 per second and 10000 per minute. The maximum number of access requests to the KvManager API is 50 per second and 500 per minute. -- Blocking operations, such as modifying UI components, are not allowed in the distributed database event callback. +- The maximum number of access requests to the KvStore API is 1000 per second and 10000 per minute. The maximum number of access requests to the KvManager API is 50 per second and 500 per minute. +- Blocking operations, such as modifying UI components, are not allowed in the distributed database event callback. diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index a4acbd9a7b47dca4332c7f6a881939b1928abd78..bd38925cbe8a17e5cb6319ffc9729ef263945e9c 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -196,17 +196,41 @@ Table 15 Transaction APIs (3) Create an RDB store. - The sample code is as follows: + FA model: ```js - import data_rdb from '@ohos.data.rdb' + import data_rdb from '@ohos.data.rdb' + // Obtain the context. + import featureAbility from '@ohos.ability.featureAbility' + let context = featureAbility.getContext() + + 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 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" } - data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { + const STORE_CONFIG = { name: "RdbTest.db" } + data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) { rdbStore.executeSql(CREATE_TABLE_TEST) console.info('create table done.') - }) + }) + ``` + Stage model: + ```ts + import data_rdb from '@ohos.data.rdb' + // Obtain the context. + import Ability from '@ohos.application.Ability' + let context = null + class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + context = this.context + } + } + + 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" } + data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) { + rdbStore.executeSql(CREATE_TABLE_TEST) + console.info('create table done.') + }) ``` 2. Insert data. diff --git a/en/application-dev/device/sensor-guidelines.md b/en/application-dev/device/sensor-guidelines.md index 99c6cc6c045a6f7d9a813372af163ab1eaa2efe1..50ebd3428f89eba4f968dd98e5fe2edee91bee34 100644 --- a/en/application-dev/device/sensor-guidelines.md +++ b/en/application-dev/device/sensor-guidelines.md @@ -26,70 +26,30 @@ | -------- | -------- | -------- | | 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.| +| 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 requested 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" - } - } - ] - ``` +1. Before obtaining data from a type of sensor, check whether the required permission has been configured.
+ The system provides the following sensor-related permissions: + - ohos.permission.ACCELEROMETER + + - ohos.permission.GYROSCOPE + + - ohos.permission.ACTIVITY_MOTION + + - ohos.permission.READ_HEALTH_DATA + + For details about how to configure a permission, see [Declaring Permissions](../security/accesstoken-guidelines.md). 2. Subscribe to data changes of a type of sensor. ``` - import sensor from "@ohos.sensor" - sensor.on(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data){ - console.info("Subscription succeeded. data = " + data); // The call is successful, and the obtained sensor data is printed. - } - ); + import sensor from "@ohos.sensor"; + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(data){ + console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // Data is obtained. + }); ``` The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**. @@ -99,11 +59,8 @@ 3. Unsubscribe from sensor data changes. ``` - import sensor from "@ohos.sensor" - sensor.off(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function() { - console.info("Succeeded in unsubscribing from acceleration sensor data."); // The unsubscription is successful, and the result is printed. - } - ); + import sensor from "@ohos.sensor"; + sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER); ``` The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**. @@ -113,11 +70,10 @@ 4. Subscribe to only one data change of a type of sensor. ``` - import sensor from "@ohos.sensor" - sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) { - console.info("Data obtained successfully. data=" + data); // The call is successful, and the obtained sensor data is printed. - } - ); + import sensor from "@ohos.sensor"; + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(data) { + console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // Data is obtained. + }); ``` The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**. @@ -127,11 +83,12 @@ If the API fails to be called, you are advised to use the **try/catch** statement to capture error information that may occur in the code. Example: ``` + import sensor from "@ohos.sensor"; try { - sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) { - console.info("Data obtained successfully. data=" + data); // The call is successful, and the obtained sensor data is printed. + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(data) { + console.info("Data obtained successfully. x: " + data.x + "y: " + data.y + "z: " + data.z); // Data is obtained. }); } catch (error) { - console.error(error); + console.error("Failed to get sensor data"); } - ``` + ``` \ No newline at end of file diff --git a/en/application-dev/device/sensor-overview.md b/en/application-dev/device/sensor-overview.md index ec2374fbdf0fe63d1e10cbf26beff696c899025b..cb6129928d3796779075bcfc28da7f606bd130d9 100644 --- a/en/application-dev/device/sensor-overview.md +++ b/en/application-dev/device/sensor-overview.md @@ -52,15 +52,12 @@ The following modules work cooperatively to implement OpenHarmony sensors: Senso 1. To obtain data of the following sensors, you must claim the required permissions. - Table 7 Sensor data permissions - -| Sensor | Permission | Sensitivity | Permission Description | -| ------------------------- | -------------------------------- | ------------ | ----------------------- | -| Acceleration sensor, uncalibrated acceleration sensor, and linear acceleration sensor| ohos.permission.ACCELEROMETER | system_grant | Allows an 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 an application to subscribe to data of the gyroscope-related sensors in the motion category.| -| Pedometer sensor | ohos.permission.ACTIVITY_MOTION | user_grant | Allows an application to subscribe to the motion status. | -| Heart rate sensor | ohos.permission.READ_HEALTH_DATA | user_grant | Allows an application to read health data. | - - - + | Sensor | Permission | Sensitivity | Permission Description | + | ------------------------- | -------------------------------- | ------------ | ----------------------- | + | Acceleration sensor, uncalibrated acceleration sensor, and linear acceleration sensor| ohos.permission.ACCELEROMETER | system_grant | Allows an 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 an application to subscribe to data of the gyroscope-related sensors in the motion category.| + | Pedometer sensor | ohos.permission.ACTIVITY_MOTION | user_grant | Allows an application to subscribe to the motion status. | + | Heart rate sensor | ohos.permission.READ_HEALTH_DATA | user_grant | Allows an application to read health data. | + 2. 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/device/vibrator-guidelines.md b/en/application-dev/device/vibrator-guidelines.md index 97f9f5933b55c9a1b57b5555db5812b6576a262a..0dfc8344e5bb27a7ab6b6cd11943595c9f7855a6 100644 --- a/en/application-dev/device/vibrator-guidelines.md +++ b/en/application-dev/device/vibrator-guidelines.md @@ -22,42 +22,7 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md ## How to Develop -1. Declare the permissions required for controlling vibrators on the hardware device in the `config.json` file. - - ``` - "reqPermissions": [ - { - "name": "ohos.permission.ACCELEROMETER", - "reason": "", - "usedScene": { - "ability": [ - ".MainAbility" - ], - "when": "inuse" - } - }, - { - "name": "ohos.permission.VIBRATE", - "reason": "", - "usedScene": { - "ability": [ - ".MainAbility" - ], - "when": "inuse" - } - }, - { - "name": "ohos.permission.ACTIVITY_MOTION", - "reason": "", - "usedScene": { - "ability": [ - ".MainAbility" - ], - "when": "inuse" - } - } - ] - ``` +1. Before using the vibrator on a device, you must declare the **ohos.permission.VIBRATE** permission. For details about how to configure a permission, see [Declaring Permissions](../security/accesstoken-guidelines.md). 2. Trigger the device to vibrate. diff --git a/en/application-dev/device/vibrator-overview.md b/en/application-dev/device/vibrator-overview.md index 62e0d0d7b99e8bc4eaf5c38b4fc3006a19264df2..aea46d62cab1225c26e138decde615924593bcb6 100644 --- a/en/application-dev/device/vibrator-overview.md +++ b/en/application-dev/device/vibrator-overview.md @@ -23,4 +23,4 @@ The vibrator is a Misc device that consists of four modules: Vibrator API, Vibra ## Constraints -When using a vibrator, you must declare the **ohos.permission.VIBRATE** permission before you can control the vibration effect. The authorization mode of this permission is **system_grant**. +When using a vibrator, you must declare the **ohos.permission.VIBRATE** permission before you can control the vibration effect. diff --git a/en/application-dev/quick-start/package-structure.md b/en/application-dev/quick-start/package-structure.md index cae1337dea083ff731be54f0536fa33f6fd64812..076bc9474ba724746938c1a4da837a3679c73d5a 100644 --- a/en/application-dev/quick-start/package-structure.md +++ b/en/application-dev/quick-start/package-structure.md @@ -232,7 +232,6 @@ Table 11 Internal structure of the module tag | distroFilter | Application distribution rules.
AppGallery uses these rules to distribute HAP files to the matching devices. Distribution rules cover three factors: API version, screen shape, and screen resolution. AppGallery distributes a HAP file to the device whose on the mapping between **deviceType** and these three factors. For details, see Table 29. | Object | Yes (initial value: left empty)
Set this attribute when an application has multiple entry modules. | | reqCapabilities | Device capabilities required for running the application. | String array| Yes (initial value: left empty) | | commonEvents | Static broadcast. For details, see Table 35. | Object array | Yes (initial value: left empty) | -| allowClassMap | Metadata of the HAP file. The value can be **true** or **false**. If the value is **true**, the HAP file uses the Java object proxy mechanism provided by the OpenHarmony framework. | Boolean | No (initial value: **false**) | | entryTheme | Keyword of an OpenHarmony internal theme. Set it to the resource index of the name.| String | Yes (initial value: left empty) | Example of the **module** tag structure: @@ -348,7 +347,7 @@ Table 17 Internal structure of the abilities attribute | Attribute | Description | Data Type | Initial Value Allowed | | ---------------- | ------------------------------------------------------------ | ---------- | -------------------------------------------------------- | | process | Name of the process running the application or ability. If the **process** attribute is configured in the **deviceConfig** tag, all abilities of the application run in this process. You can set the **process** attribute for a specific ability in the **abilities** attribute, so that the ability can run in the particular process. If this attribute is set to the name of the process running other applications, all these applications can run in the same process, provided they have the same unified user ID and the same signature. Devices running OpenHarmony do not support this attribute.| String | Yes (initial value: left empty) | -| name | Name of the ability. The value is a reverse domain name, in the format of "*Bundle name*.*Class name*", for example, **"com.example.myapplication.MainAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".MainAbility"**.
The ability name must be unique in an application. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.
Note: When you use DevEco Studio to create a project, the configuration of the first ability is generated by default, including the **MainAbility.java** file and the class name **MainAbility** defaulted in the **name** string for the **abilities** attribute in **config.json**. The value of this attribute can be customized if you use other IDE tools. The value can contain a maximum of 127 characters.| String | No | +| name | Name of the ability. The value is a reverse domain name, in the format of "*Bundle name*.*Class name*", for example, **"com.example.myapplication.MainAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".MainAbility"**.
The ability name must be unique in an application. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.
Note: If you use DevEco Studio to create the project, an ability named **MainAbility** will be created together with the default configuration in the **config.json** file. The value of this attribute can be customized if you use other IDE tools. The value can contain a maximum of 127 characters.| String | No | | description | Description of the ability. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 characters.| String | Yes (initial value: left empty) | | icon | Index to the ability icon file. Example value: **$media:ability_icon**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the icon of the ability is also used as the icon of the application. If multiple abilities address this condition, the icon of the first candidate ability is used as the application icon.
Note: The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels.| String | Yes (initial value: left empty) | | label | Ability name visible to users. The value can be a name string or a resource index to names in multiple languages. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the label of the ability is also used as the label of the application. If multiple abilities address this condition, the label of the first candidate ability is used as the application label.
Note: The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels. The value can be a reference to a string defined in a resource file or a string enclosed in brackets ({}). The value can contain a maximum of 255 characters.| String | Yes (initial value: left empty) | @@ -372,7 +371,7 @@ Table 17 Internal structure of the abilities attribute | supportPipMode | Whether the ability allows the user to enter the Picture in Picture (PiP) mode. The PiP mode enables the user to watch a video in a small window that hovers on top of a full screen window (main window). This attribute applies only to the ability using the Page template. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| Boolean | Yes (initial value: **false**) | | formsEnabled | Whether the ability can provide forms. This attribute applies only to the ability using the Page template.
**true**: This ability can provide forms.
**false**: This ability cannot provide forms.| Boolean | Yes (initial value: **false**) | | forms | Details about the forms used by the ability. This attribute is valid only when **formsEnabled** is set to **true**. For details, see Table 27.| Object array | Yes (initial value: left empty) | -| srcLanguage | Programming language used to develop the ability. | String | The value can be **java**, **js**, or **ets**. | +| srcLanguage | Programming language used to develop the ability. | String | The value can be **js**, or **ets**. | | srcPath | Path of the JS code and components corresponding to the ability. | String | Yes (initial value: left empty) | | uriPermission | Application data that the ability can access. This attribute consists of the **mode** and **path** sub-attributes. This attribute is valid only for the capability of the type provider. Devices running OpenHarmony do not support this attribute. For details, see Table 18.| Object | Yes (initial value: left empty) | | startWindowIcon | Index to the icon file of the ability startup page. Example value: **$media:icon**. | String | Yes (initial value: left empty) | @@ -587,12 +586,10 @@ Table 27 Internal structure of the forms attribute | name | Class name of the widget. The value is a string with a maximum of 127 bytes. | String | No | | description | Description of the widget. The value can be a string or a resource index to descriptions in multiple languages. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) | | isDefault | Whether the widget is a default one. Each ability has only one default widget.
**true**: The widget is the default one.
**false**: The widget is not the default one.| Boolean | No | -| type | Type of the widget. Available values are as follows:
**Java**: indicates a Java-programmed widget.
**JS**: indicates a JavaScript-programmed widget.| String | No | +| type | Type of the widget. Available values are as follows:
**JS**: indicates a JavaScript-programmed widget.| String | No | | colorMode | Color mode of the widget. Available values are as follows:
**auto**: The widget adopts the auto-adaptive color mode.
**dark**: The widget adopts the dark color mode.
**light**: The widget adopts the light color mode.| String | Yes (initial value: **auto**)| | supportDimensions | Grid styles supported by the widget. Available values are as follows:
1 * 2: indicates a grid with one row and two columns.
2 * 2: indicates a grid with two rows and two columns.
2 * 4: indicates a grid with two rows and four columns.
4 * 4: indicates a grid with four rows and four columns.| String array| No | | defaultDimension | Default grid style of the widget. The value must be available in the **supportDimensions** array of the widget.| String | No | -| landscapeLayouts | Landscape layouts for the grid styles. Values in this array must correspond to the values in the **supportDimensions** array. This field is required only by Java-programmed widgets.| String array| No | -| portraitLayouts | Portrait layouts for the grid styles. Values in this array must correspond to the values in the **supportDimensions** array. This field is required only by Java-programmed widgets.| String array| No | | updateEnabled | Whether the widget can be updated periodically. Available values are as follows:
**true**: The widget can be updated periodically, depending on the update way you select, either at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** is preferentially recommended.
**false**: The widget cannot be updated periodically.| Boolean | No | | scheduledUpdateTime | Scheduled time to update the widget. The value is in 24-hour format and accurate to minute. | String | Yes (initial value: **0:0**) | | updateDuration | Interval to update the widget. The value is a natural number, in the unit of 30 minutes.
If the value is **0**, this field does not take effect.
If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.| Number | Yes (initial value: **0**) | @@ -632,9 +629,9 @@ Example of the **forms** attribute structure: ] }, { - "name": "Form_Java", - "description": "It's Java Form", - "type": "Java", + "name": "Form_JS", + "description": "It's JS Form", + "type": "JS", "colorMode": "auto", "isDefault": false, "updateEnabled": true, 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 9aab0179f06478fef211871d29e90daa33cf5609..9d33d34e9e0275c538e1cf2913af5fc0fdc656bc 100644 --- a/en/application-dev/reference/apis/js-apis-ability-context.md +++ b/en/application-dev/reference/apis/js-apis-ability-context.md @@ -6,8 +6,8 @@ This module provides APIs for accessing ability-specific resources. You can use > **NOTE** > -> 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. -> The APIs of this module can be used only in the stage model. +> - 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. +> - The APIs of this module can be used only in the stage model. ## Usage diff --git a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md index 619ed387b6338fa06a064b3848a3491ee7ea08c9..4b1a66f071f464d6662d8429606c48aa025e8ef6 100644 --- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md +++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md @@ -4,12 +4,12 @@ The **wantConstant** module provides the actions, entities, and flags used in ** > **NOTE** > -> The initial APIs of this module are supported since API 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import -``` -import wantConstant from '@ohos.ability.wantConstant' +```js +import wantConstant from '@ohos.ability.wantConstant'; ``` ## wantConstant.Action @@ -46,8 +46,13 @@ Enumerates the action constants of the **Want** object. | ACTION_FILE_SELECT7+ | ohos.action.fileSelect | Action of selecting a file. | | PARAMS_STREAM7+ | ability.params.stream | URI of the data stream associated with the target when the data is sent. | | ACTION_APP_ACCOUNT_OAUTH 8+ | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. | -| ACTION_MARKER_DOWNLOAD 9+ | ohos.want.action.marketDownload | Action of downloading an application from the application market.
**System API**: This is a system API and cannot be called by third-party applications. | - +| ACTION_MARKET_DOWNLOAD 9+ | ohos.want.action.marketDownload | Action of downloading an application from the application market.
**System API**: This is a system API and cannot be called by third-party applications. | +| ACTION_MARKET_CROWDTEST 9+ | ohos.want.action.marketCrowdTest | Action of crowdtesting an application from the application market.
**System API**: This is a system API and cannot be called by third-party applications. | +| DLP_PARAMS_SANDBOX9+ |ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.
**System API**: This is a system API and cannot be called by third-party applications. | +| DLP_PARAMS_BUNDLE_NAME9+ |ohos.dlp.params.bundleName |Action of obtaining the DLP bundle name.
**System API**: This is a system API and cannot be called by third-party applications. | +| DLP_PARAMS_MODULE_NAME9+ |ohos.dlp.params.moduleName |Action of obtaining the DLP module name.
**System API**: This is a system API and cannot be called by third-party applications. | +| DLP_PARAMS_ABILITY_NAME9+ |ohos.dlp.params.abilityName |Action of obtaining the DLP ability name.
**System API**: This is a system API and cannot be called by third-party applications. | +| DLP_PARAMS_INDEX9+ |ohos.dlp.params.index |Action of obtaining the DLP index.
**System API**: This is a system API and cannot be called by third-party applications. | ## wantConstant.Entity diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md index 44f96b01b333ed9ad5e1258b0173734c0c7869d7..c98d603c0092e8f2fd9e1f9a2ce0d33ecd9cc1a7 100644 --- a/en/application-dev/reference/apis/js-apis-appAccount.md +++ b/en/application-dev/reference/apis/js-apis-appAccount.md @@ -2104,6 +2104,7 @@ Called to return the result of an authentication request. **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ------ | -------------------- | ---- | ------ | | code | number | Yes | Authentication result code.| @@ -2134,6 +2135,7 @@ Called to redirect a request. **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ------- | ---- | ---- | ---------- | | request | Want | Yes | Request to be redirected.| @@ -2191,6 +2193,7 @@ Implicitly adds an app account based on the specified authentication type and op **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | authType | string | Yes | Authentication type. | @@ -2207,6 +2210,7 @@ Authenticates an app account to obtain the OAuth token. This API uses an asynchr **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | name | string | Yes | Name of the target app account. | @@ -2224,6 +2228,7 @@ Verifies the credential of an app account. This API uses an asynchronous callbac **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | name | string | Yes | Name of the target app account. | @@ -2239,6 +2244,7 @@ Sets authenticator properties. This API uses an asynchronous callback to return **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | options | [SetPropertiesOptions](#setpropertiesoptions9) | Yes | Authenticator properties to set. | @@ -2253,6 +2259,7 @@ Checks the account labels. This API uses an asynchronous callback to return the **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | name | string | Yes | Name of the target app account. | @@ -2268,6 +2275,7 @@ Checks whether an app account can be deleted. This API uses an asynchronous call **System capability**: SystemCapability.Account.AppAccount **Parameters** + | Name | Type | Mandatory | Description | | ---------------- | --------------------- | ---- | --------------- | | name | string | Yes | Name of the target app account. | diff --git a/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md index c48d33d59a701fb998f82316d5c70a0d86fc5ea1..1fa16906d34877c7e7dce4638b472b0c539b8921 100644 --- a/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @@ -78,7 +78,7 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility { ## WindowExtensionAbility.onWindowReady -onWindowReady(window: Window): void +onWindowReady(window: window.Window): void Called when a window is ready. @@ -88,7 +88,7 @@ Called when a window is ready. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| window | [Window](js-apis-window.md) | Yes| Current **Window** instance.| +| window | [window.Window](js-apis-window.md#window) | Yes| Current **Window** instance.| **Example** @@ -99,7 +99,7 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility { onWindowReady(window) { window.loadContent('WindowExtAbility/pages/index1').then(() => { window.getProperties().then((pro) => { - console.log("WindowExtension " + JSON.stringify(pro)); + console.log('WindowExtension ' + JSON.stringify(pro)); }) window.show(); }) 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 565210637c6e83f83ec734c0905e11596baaf0db..87a9809bb9b49db443ec6f7d1617a2228dacaf88 100644 --- a/en/application-dev/reference/apis/js-apis-application-ability.md +++ b/en/application-dev/reference/apis/js-apis-application-ability.md @@ -4,7 +4,7 @@ The **Ability** module manages the ability lifecycle and context, such as creati This module provides the following common ability-related functions: -- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller) invokes the target ability (callee). +- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability). - [Callee](#callee): implements callbacks for registration and deregistration of caller notifications. > **NOTE** @@ -22,12 +22,12 @@ import Ability from '@ohos.application.Ability'; **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -| 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-application-Want.md) | Yes| No| Parameters for starting the ability.| -| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.| -| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.| +| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.| +| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.| +| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.| +| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.| ## Ability.onCreate @@ -39,13 +39,13 @@ Called to initialize the service logic when an ability is created. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.| -| param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.| - -**Example** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.| + | param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.| +**Example** + ```js class myAbility extends Ability { onCreate(want, param) { @@ -65,12 +65,12 @@ Called when a **WindowStage** is created for this ability. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| windowStage | window.WindowStage | Yes| **WindowStage** information.| - -**Example** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | windowStage | window.WindowStage | Yes| **WindowStage** information.| +**Example** + ```js class myAbility extends Ability { onWindowStageCreate(windowStage) { @@ -88,8 +88,8 @@ Called when the **WindowStage** is destroyed for this ability. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -**Example** - +**Example** + ```js class myAbility extends Ability { onWindowStageDestroy() { @@ -109,12 +109,12 @@ Called when the **WindowStage** is restored during the migration of this ability **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| windowStage | window.WindowStage | Yes| **WindowStage** information.| - -**Example** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | windowStage | window.WindowStage | Yes| **WindowStage** information.| +**Example** + ```js class myAbility extends Ability { onWindowStageRestore(windowStage) { @@ -132,8 +132,8 @@ Called when this ability is destroyed to clear resources. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -**Example** - +**Example** + ```js class myAbility extends Ability { onDestroy() { @@ -151,8 +151,8 @@ Called when this ability is switched from the background to the foreground. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -**Example** - +**Example** + ```js class myAbility extends Ability { onForeground() { @@ -170,8 +170,8 @@ Called when this ability is switched from the foreground to the background. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -**Example** - +**Example** + ```js class myAbility extends Ability { onBackground() { @@ -191,18 +191,18 @@ Called to save data during the ability migration preparation process. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| wantParam | {[key: string]: any} | Yes| **want** parameter.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | wantParam | {[key: string]: any} | Yes| **want** parameter.| **Return value** -| Type| Description| -| -------- | -------- | -| AbilityConstant.OnContinueResult | Continuation result.| - -**Example** + | Type| Description| + | -------- | -------- | + | AbilityConstant.OnContinueResult | Continuation result.| +**Example** + ```js import AbilityConstant from "@ohos.application.AbilityConstant" class myAbility extends Ability { @@ -225,20 +225,17 @@ Called when the ability startup mode is set to singleton. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.| -| launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.| - -**Example** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.| + | launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.| +**Example** + ```js class myAbility extends Ability { - onNewWant(want, launchParams) { + onNewWant(want) { console.log('onNewWant, want:' + want.abilityName); - if (launchParams.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { - console.log('onNewWant, launchReason is continuation'); - } } } ``` @@ -254,12 +251,12 @@ Called when the configuration of the environment where the ability is running is **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| - -**Example** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| +**Example** + ```js class myAbility extends Ability { onConfigurationUpdated(config) { @@ -278,12 +275,12 @@ Dumps client information. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| params | Array\ | Yes| Parameters in the form of a command.| - -**Example** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | params | Array\ | Yes| Parameters in the form of a command.| +**Example** + ```js class myAbility extends Ability { dump(params) { @@ -293,11 +290,35 @@ Dumps client information. } ``` +## Ability.onMemoryLevel + +onMemoryLevel(level: AbilityConstant.MemoryLevel): void; + +Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible. + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | level | [AbilityConstant.MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.| + +**Example** + + ```js + class myAbility extends Ability { + onMemoryLevel(level) { + console.log('onMemoryLevel, level:' + JSON.stringify(level)); + } + } + ``` + ## Caller -Implements sending of sequenceable data to the target ability when an ability (caller) invokes the target ability (callee). +Implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability). ## Caller.call @@ -310,19 +331,19 @@ Sends sequenceable data to the target ability. **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.| + | 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| -| -------- | -------- | -| Promise<void> | Promise used to return a response.| - -**Example** + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return a response.| +**Example** + ```js import Ability from '@ohos.application.Ability'; class MyMessageAble{ // Custom sequenceable data structure @@ -383,19 +404,19 @@ Sends sequenceable data to the target ability and obtains the sequenceable data **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.| + | 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| -| -------- | -------- | -| Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability.| - -**Example** + | Type| Description| + | -------- | -------- | + | Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability.| +**Example** + ```js import Ability from '@ohos.application.Ability'; class MyMessageAble{ @@ -455,8 +476,8 @@ Releases the caller interface of the target ability. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -**Example** - +**Example** + ```js import Ability from '@ohos.application.Ability'; var caller; @@ -492,12 +513,12 @@ Registers a callback that is invoked when the stub on the target ability is disc **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.| - -**Example** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.| +**Example** + ```js import Ability from '@ohos.application.Ability'; var caller; @@ -540,12 +561,13 @@ Registers a caller notification callback, which is invoked when the target abili **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| method | string | Yes| Notification message string negotiated between the two abilities.| -| callback | CalleeCallBack | 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.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | method | string | Yes| Notification message string negotiated between the two abilities.| + | callback | CalleeCallBack | 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{ @@ -595,9 +617,9 @@ Deregisters a caller notification callback, which is invoked when the target abi **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| method | string | Yes| Registered notification message string.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | method | string | Yes| Registered notification message string.| **Example** @@ -618,17 +640,16 @@ Deregisters a caller notification callback, which is invoked when the target abi **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -| Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| (msg: string) | function | Yes| No| Prototype of the listener function registered by the caller.| - +| (msg: string) | function | Yes| No| Prototype of the listener function registered by the caller.| - ## CalleeCallBack +## CalleeCallBack (indata: rpc.MessageParcel): rpc.Sequenceable; **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -| Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the listener function registered by the callee.| +| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the listener function registered by the callee.| diff --git a/en/application-dev/reference/apis/js-apis-application-abilityConstant.md b/en/application-dev/reference/apis/js-apis-application-abilityConstant.md index ca3269353344ca06935afaf6b390ae0c906f1a1a..50e65757431e7df6b9bc784c6169da902a04bf5d 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityConstant.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityConstant.md @@ -65,7 +65,7 @@ Enumerates ability continuation results. ## AbilityConstant.WindowMode -Enumerates the window modes when an ability is started. +Enumerates the window modes in which an ability can be displayed at startup. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -76,3 +76,15 @@ Enumerates the window modes when an ability is started. | WINDOW_MODE_SPLIT_PRIMARY | 100 | The ability is displayed in the primary window in split-screen mode. | | WINDOW_MODE_SPLIT_SECONDARY | 101 | The ability is displayed in the secondary window in split-screen mode. | | WINDOW_MODE_FLOATING | 102 | The ability is displayed in a floating window.| + +## AbilityConstant.MemoryLevel + +Enumerates the memory levels. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +| Name | Value| Description | +| --- | --- | --- | +| MEMORY_LEVEL_MODERATE | 0 | Moderate memory usage. | +| MEMORY_LEVEL_LOW | 1 | Low memory usage. | +| MEMORY_LEVEL_CRITICAL | 2 | High memory usage. | diff --git a/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md b/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md index 542214482f3e5bc8a74dad3d9990e1817b3f02e8..1a6035f15c6d68dd374d21e1953163b57d1e7648 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md @@ -875,3 +875,265 @@ abilityDelegator.finishTest(msg, 0).then(() => { console.info("finishTest promise"); }); ``` + +### addAbilityStageMonitor9+ + +addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\): void; + +Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes of an ability stage. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | +| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | + +**Example** + +```js +var abilityDelegator; + +var monitor = { + moduleName: "moduleName", + srcEntrance: "srcEntrance", +} + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.addAbilityStageMonitor(monitor, (err : any) => { + console.info("addAbilityStageMonitor callback"); +}); +``` + + + +### addAbilityStageMonitor9+ + +addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\; + +Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes of an ability stage. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.| + +**Return value** + +| Type | Description | +| -------------- | ------------------- | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +var abilityDelegator; + +var monitor = { + moduleName: "moduleName", + srcEntrance: "srcEntrance", +} + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.addAbilityStageMonitor(monitor).then(() => { + console.info("addAbilityStageMonitor promise"); +}); +``` + +### removeAbilityStageMonitor9+ + +removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\): void; + +Removes an **AbilityStageMonitor** instance from the application memory. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | +| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | + +**Example** + +```js +var abilityDelegator; + +var monitor = { + moduleName: "moduleName", + srcEntrance: "srcEntrance", +} + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.removeAbilityStageMonitor(monitor, (err : any) => { + console.info("removeAbilityStageMonitor callback"); +}); +``` + + + +### removeAbilityStageMonitor9+ + +removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\; + +Removes an **AbilityStageMonitor** object from the application memory. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.| + +**Return value** + +| Type | Description | +| -------------- | ------------------- | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +var abilityDelegator; + +var monitor = { + moduleName: "moduleName", + srcEntrance: "srcEntrance", +} + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.removeAbilityStageMonitor(monitor).then(() => { + console.info("removeAbilityStageMonitor promise"); +}); +``` + +### waitAbilityStageMonitor9+ + +waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\): void; + +Waits for an **AbilityStage** instance that matches the conditions set in an **AbilityStageMonitor** instance and returns the **AbilityStage** instance. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | +| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, an **AbilityStage** instance is returned. Otherwise, no value is returned. | + +**Example** + +```js +var abilityDelegator; + +function onAbilityCreateCallback(data) { + console.info("onAbilityCreateCallback"); +} + +var monitor = { + moduleName: "moduleName", + srcEntrance: "srcEntrance", +} + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.waitAbilityStageMonitor(monitor, (err : any, data : any) => { + console.info("waitAbilityStageMonitor callback"); +}); +``` + +### waitAbilityStageMonitor9+ + +waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise\; + +Waits for an **AbilityStage** instance that matches the conditions set in an **AbilityStageMonitor** instance and returns the **AbilityStage** instance. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.| +| timeout | number | No | Maximum waiting time, in milliseconds.| + +**Return value** + +| Type | Description | +| -------------- | ------------------- | +| Promise\ | Promise used to return the result. If the operation is successful, an **AbilityStage** instance is returned. Otherwise, no value is returned.| + +**Example** + +```js +var abilityDelegator; + +function onAbilityCreateCallback(data) { + console.info("onAbilityCreateCallback"); +} + +var monitor = { + moduleName: "moduleName", + srcEntrance: "srcEntrance", +} + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.waitAbilityStageMonitor(monitor).then((data : any) => { + console.info("waitAbilityStageMonitor promise"); +}); +``` + +### waitAbilityStageMonitor9+ + +waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout: number, callback: AsyncCallback\): void; + +Waits a period of time for an **AbilityStage** instance that matches the conditions set in an **AbilityStageMonitor** instance and returns the **AbilityStage** instance. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.| +| timeout | number | No | Maximum waiting time, in milliseconds.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, an **AbilityStage** instance is returned. Otherwise, no value is returned. | + +**Example** + +```js +var abilityDelegator; +var timeout = 100; + +function onAbilityCreateCallback(data) { + console.info("onAbilityCreateCallback"); +} + +var monitor = { + moduleName: "moduleName", + srcEntrance: "srcEntrance", +} + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.waitAbilityStageMonitor(monitor, timeout, (err : any, data : any) => { + console.info("waitAbilityStageMonitor callback"); +}); +``` + +## AbilityStageMonitor + +Provides conditions for matching **AbilityStage** instances. The most recently matched **AbilityStage** instance is saved in an **AbilityStageMonitor** instance. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +| Name | Type | Readable| Writable| Description | +| ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ | +| moduleName9+ | string | Yes | Yes | Module name of the **AbilityStage** instance.| +| srcEntrance9+ | string | Yes | Yes | Source path of the **AbilityStage** instance.| diff --git a/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md b/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md index dffe0e39e69e38123bf7e89338b3d4efb14ad82a..e1b3aa3bbe5e16262db584894055c090a224b625 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md @@ -11,7 +11,7 @@ The **AbilityDelegatorArgs** module provides a global register to store the regi The ability delegator arguments are obtained by calling **getArguments** in **AbilityDelegatorRegistry**. ```js -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; var args = AbilityDelegatorRegistry.getArguments(); ``` 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 5817123ea55725ecd6c3c7a1f1d2a88b3f27b2ca..d1c8592f97d4c8b8799d5773b391bb1798663219 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilitystage.md +++ b/en/application-dev/reference/apis/js-apis-application-abilitystage.md @@ -89,6 +89,31 @@ Called when the global configuration is updated. } } ``` + +## AbilityStage.onMemoryLevel + +onMemoryLevel(level: AbilityConstant.MemoryLevel): void; + +Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible. + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | level | [AbilityConstant.MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.| + +**Example** + + ```js + class MyAbilityStage extends AbilityStage { + onMemoryLevel(level) { + console.log('onMemoryLevel, level:' + JSON.stringify(level)); + } + } + ``` + ## AbilityStage.context context: AbilityStageContext; diff --git a/en/application-dev/reference/apis/js-apis-appmanager.md b/en/application-dev/reference/apis/js-apis-appmanager.md index 1b2bd22548deeed3145803c1a3939e59399b904c..9dc3ec0c3c5f022d4aecd438f59ebc830a34ae63 100644 --- a/en/application-dev/reference/apis/js-apis-appmanager.md +++ b/en/application-dev/reference/apis/js-apis-appmanager.md @@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| 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.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | 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** @@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a **Return value** -| Type| Description| -| -------- | -------- | -| 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.| + | Type| Description| + | -------- | -------- | + | 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** @@ -72,9 +72,9 @@ Checks whether this application is running on a RAM constrained device. This API **Return value** -| Type| Description| -| -------- | -------- | -| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| **Example** @@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| **Example** @@ -119,9 +119,9 @@ Obtains the memory size of this application. This API uses a promise to return t **Return value** -| Type| Description| -| -------- | -------- | -| Promise<number> | Size of the application memory.| + | Type| Description| + | -------- | -------- | + | Promise<number> | Size of the application memory.| **Example** @@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<number> | No| Size of the application memory.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<number> | No| Size of the application memory.| **Example** @@ -157,14 +157,12 @@ Obtains the memory size of this application. This API uses an asynchronous callb ``` ## appManager.getProcessRunningInfos(deprecated) -> **NOTE** -> -> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation9+](#appmanagergetprocessrunninginformation9) instead. - getProcessRunningInfos(): Promise\>; Obtains information about the running processes. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation9+](#appmanagergetprocessrunninginformation9) instead. + **Required permissions**: ohos.permission.GET_RUNNING_INFO **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -187,14 +185,12 @@ Obtains information about the running processes. This API uses a promise to retu ## appManager.getProcessRunningInfos(deprecated) -> **NOTE** -> -> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation9+](#appmanagergetprocessrunninginformation9-1) instead. - getProcessRunningInfos(callback: AsyncCallback\>): void; Obtains information about the running processes. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation9+](#appmanagergetprocessrunninginformation9-1) instead. + **Required permissions**: ohos.permission.GET_RUNNING_INFO **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -228,7 +224,7 @@ Obtains information about the running processes. This API uses a promise to retu | Type| Description| | -------- | -------- | -| Promise\> | Promise used to return the process information.| +| Promise\> | Promise used to return the process information.| **Example** @@ -254,7 +250,7 @@ Obtains information about the running processes. This API uses an asynchronous c | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| callback | AsyncCallback\> | No| Callback used to return the process information.| +| callback | AsyncCallback\> | No| Callback used to return the process information.| **Example** @@ -269,7 +265,7 @@ Obtains information about the running processes. This API uses an asynchronous c registerApplicationStateObserver(observer: ApplicationStateObserver): number; -Registers an observer to listen for the state of all applications. +Registers an observer to listen for the state changes of all applications. **Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER @@ -307,9 +303,9 @@ Registers an observer to listen for the state of all applications. ## appManager.registerApplicationStateObserver9+ -registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array): number; +registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array\): number; -Registers an observer to listen for the state of a specified application. +Registers an observer to listen for the state changes of a specified application. **Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER @@ -322,7 +318,7 @@ Registers an observer to listen for the state of a specified application. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | observer | [ApplicationStateObserver](#applicationstateobserver) | No| Numeric code of the observer.| -| bundleNameList | Array | No| **bundleName** array to be registered for listening. The maximum value is 128.| +| bundleNameList | Array | No| **bundleName** array of the application. A maximum of 128 bundle names can be passed.| **Example** @@ -359,7 +355,7 @@ Deregisters the application state observer. This API uses an asynchronous callba **System API**: This is a system API and cannot be called by third-party applications. **Parameters** - + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | observerId | number | No| Numeric code of the observer.| @@ -491,10 +487,10 @@ Kills a process by bundle name and account ID. This API uses a promise to return **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| bundleName | string | Yes| Bundle name of an application.| -| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | bundleName | string | Yes| Bundle name of an application.| + | accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| **Example** @@ -525,11 +521,11 @@ Kills a process by bundle name and account ID. This API uses an asynchronous cal **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| bundleName | string | Yes| Bundle name of an application.| -| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | bundleName | string | Yes| Bundle name of an application.| + | accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| + | callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** @@ -708,9 +704,14 @@ Called when the application state changes. **Example** ```js -import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' -const foregroundApplicationInfo = ApplicationStateObserver.onForegroundApplicationChanged(); -console.log('-------- foregroundApplicationInfo: ---------', foregroundApplicationInfo); + var applicationStateObserver = { + onForegroundApplicationChanged(appStateData) { + console.log('------------ onForegroundApplicationChanged -----------', appStateData); + } + } + const observerCode = app.registerApplicationStateObserver(applicationStateObserver); + console.log('-------- observerCode: ---------', observerCode); + ``` ## ApplicationStateObserver.onAbilityStateChanged8+ @@ -732,9 +733,13 @@ Called when the ability state changes. **Example** ```js -import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' -const abilityStateChangedInfo = ApplicationStateObserver.onAbilityStateChanged(); -console.log('-------- abilityStateChangedInfo: ---------', abilityStateChangedInfo); + var applicationStateObserver = { + onAbilityStateChanged(abilityStateData) { + console.log('------------ onAbilityStateChanged -----------', abilityStateData); + } + } + const observerCode = app.registerApplicationStateObserver(applicationStateObserver); + console.log('-------- observerCode: ---------', observerCode); ``` ## ApplicationStateObserver.onProcessCreated8+ @@ -756,9 +761,13 @@ Called when a process is created. **Example** ```js -import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' -const processCreatedInfo = ApplicationStateObserver.onProcessCreated(); -console.log('-------- processCreatedInfo: ---------', processCreatedInfo); + var applicationStateObserver = { + onProcessCreated(processData) { + console.log('------------ onProcessCreated -----------', processData); + } + } + const observerCode = app.registerApplicationStateObserver(applicationStateObserver); + console.log('-------- observerCode: ---------', observerCode); ``` ## ApplicationStateObserver.onProcessDied8+ @@ -775,14 +784,46 @@ Called when a process is terminated. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| processData | ProcessData | No| Process information.| +| processData | [ProcessData](#processdata) | No| Process information.| **Example** ```js -import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' -const processDiedInfo = ApplicationStateObserver.onProcessDied(); -console.log('-------- processDiedInfo: ---------', processDiedInfo); + var applicationStateObserver = { + onProcessDied(processData) { + console.log('------------ onProcessDied -----------', processData); + } + } + const observerCode = app.registerApplicationStateObserver(applicationStateObserver); + console.log('-------- observerCode: ---------', observerCode); +``` + +## ApplicationStateObserver.onProcessStateChanged9+ + + onProcessStateChanged(processData: ProcessData): void; + +Called when the process state changes. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| processData | [ProcessData](#processdata) | No| Process information.| + +**Example** + +```js + var applicationStateObserver = { + onProcessStateChanged(processData) { + console.log('------------ onProcessStateChanged -----------', processData); + } + } + const observerCode = app.registerApplicationStateObserver(applicationStateObserver); + console.log('-------- observerCode: ---------', observerCode); ``` ## AppStateData @@ -815,7 +856,7 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo); ## ProcessData -**System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System API**: This is a system API and cannot be called by third-party applications. @@ -824,19 +865,19 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo); | pid8+ | number | Yes | No | Process ID. | | bundleName8+ | string | Yes | No | Bundle name of an application. | | uid8+ | number | Yes | No | User ID. | - - +| isContinuousTask9+ | boolean | Yes | No | Whether the process is a continuous task. | +| isKeepAlive9+ | boolean | Yes | No | Whether the process remains active. | ## ProcessRunningInfo -**System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission | Name | Readable/Writable| Type | Mandatory| Description | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| pid9+ | Read only | number | No | Process ID. | -| uid9+ | Read only | number | No | User ID.| -| processName9+ | Read only | string | No | Process name.| -| bundleNames9+ | Read only | Array\ | No | **bundleName** array in the running processes.| +| pid8+ | Read only | number | No | Process ID. | +| uid8+ | Read only | number | No | User ID.| +| processName8+ | Read only | string | No | Process name.| +| bundleNames8+ | Read only | Array\ | No | **bundleName** array in the running processes.| ## ApplicationStateObserver @@ -850,3 +891,44 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo); | [onAbilityStateChanged8+](#applicationstateobserveronabilitystatechanged8) | AsyncCallback\ | Yes | No | Callback invoked when the ability state changes. | | [onProcessCreated8+](#applicationstateobserveronprocesscreated8) | AsyncCallback\ | Yes | No | Callback invoked when a process is created. | | [onProcessDied8+](#applicationstateobserveronprocessdied8) | AsyncCallback\ | Yes | No | Callback invoked when a process is destroyed. | + +## ProcessRunningInformation + +Defines the process running information. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +| Name | Readable/Writable| Type | Mandatory| Description | +| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| pid9+ | Read only | number | No | Process ID. | +| uid9+ | Read only | number | No | User ID.| +| processName9+ | Read only | string | No | Process name.| +| bundleNames9+ | Read only | Array\ | No | **bundleName** array in the running processes.| + +## ApplicationState9+ + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name | Value | Description | +| -------------------- | --- | --------------------------------- | +| STATE_CREATE | 1 | State indicating that the application is being created. | +| STATE_FOREGROUND | 2 | State indicating that the application is running in the foreground. | +| STATE_ACTIVE | 3 | State indicating that the application is active. | +| STATE_BACKGROUND | 4 | State indicating that the application is running in the background. | +| STATE_DESTROY | 5 | State indicating that the application is destroyed. | + +## ProcessState9+ + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name | Value | Description | +| -------------------- | --- | --------------------------------- | +| STATE_CREATE | 1 | State indicating that the process is being created. | +| STATE_FOREGROUND | 2 | State indicating that the process is running in the foreground. | +| STATE_ACTIVE | 3 | State indicating that the process is active. | +| STATE_BACKGROUND | 4 | State indicating that the process is running in the background. | +| STATE_DESTROY | 5 | State indicating that the process is destroyed. | diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md index 341295a167878f6c3696efe01f15a29415f91cd8..0618e40a4327d72455405588df46c9f91f7262e4 100644 --- a/en/application-dev/reference/apis/js-apis-arraylist.md +++ b/en/application-dev/reference/apis/js-apis-arraylist.md @@ -12,6 +12,9 @@ When compared with **[LinkedList](js-apis-linkedlist.md)**, **ArrayList** is mor **Recommended use case**: Use **ArrayList** when elements in a container need to be frequently read. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -72,7 +75,7 @@ Adds an element at the end of this container. let result1 = arrayList.add(1); let b = [1, 2, 3]; let result2 = arrayList.add(b); - let c = {name: "lala", age: "13"}; + let c = {name: "Dylon", age: "13"}; let result3 = arrayList.add(false); ``` @@ -124,9 +127,9 @@ Checks whether this container has the specified element. ```ts let arrayList = new ArrayList(); -let result = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -arrayList.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -let result1 = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = arrayList.has("squirrel"); +arrayList.add("squirrel"); +let result1 = arrayList.has("squirrel"); ``` ### getIndexOf @@ -361,7 +364,7 @@ arrayList.add(4); arrayList.add(5); arrayList.add(4); arrayList.forEach((value, index) => { - console.log("value:" + value, index); + console.log(`value:${value}`, index); }); ``` @@ -623,14 +626,14 @@ arrayList.add(4); // Method 1: for (let item of arrayList) { - console.log("value:" + item); + console.log(`value:${item}`); } // Method 2: let iter = arrayList[Symbol.iterator](); let temp = iter.next().value; while(temp != undefined) { - console.log("value:" + temp); + console.log(`value:${temp}`); temp = iter.next().value; } ``` diff --git a/en/application-dev/reference/apis/js-apis-bluetooth.md b/en/application-dev/reference/apis/js-apis-bluetooth.md index e7bcef69308231e54d2786e4324969a3b0444923..eb54d689022397f603f9d93d2cc8591d9d1cdc82 100644 --- a/en/application-dev/reference/apis/js-apis-bluetooth.md +++ b/en/application-dev/reference/apis/js-apis-bluetooth.md @@ -1,6 +1,6 @@ # Bluetooth -The Bluetooth module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising. +The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising. > **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. @@ -281,7 +281,7 @@ let remoteDeviceName = bluetooth.getRemoteDeviceName("XX:XX:XX:XX:XX:XX"); getRemoteDeviceClass(deviceId: string): DeviceClass -Obtains the type of the remote Bluetooth device. +Obtains the class of the remote Bluetooth device. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -297,7 +297,7 @@ Obtains the type of the remote Bluetooth device. | Type | Description | | --------------------------- | -------- | -| [DeviceClass](#deviceclass) | Type of a remote device obtained.| +| [DeviceClass](#deviceclass) | Class of the remote device obtained.| **Example** @@ -389,7 +389,7 @@ startBluetoothDiscovery(): boolean Starts Bluetooth scan to discover remote devices. -**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION +**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION **System capability**: SystemCapability.Communication.Bluetooth.Core @@ -515,7 +515,7 @@ Unsubscribes from the Bluetooth device discovery events. | 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**.| +| callback | Callback<Array<string>> | No | Callback for the **bluetoothDeviceFind** event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -578,7 +578,7 @@ Unsubscribes from the pairing request events of the remote Bluetooth device. | 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**.| +| callback | Callback<[PinRequiredParam](#pinrequiredparam)> | No | Callback for the Bluetooth pairing request event. The input parameter is the pairing request parameter. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -599,7 +599,7 @@ bluetooth.off('pinRequired', onReceiveEvent); on(type: "bondStateChange", callback: Callback<BondStateParam>): void -Subscribes to the Bluetooth bond state change events. +Subscribes to the Bluetooth pairing state change events. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -609,8 +609,8 @@ Subscribes to the Bluetooth bond state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------------ | -| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth bond state change event.| -| callback | Callback<[BondStateParam](#BondStateParam)> | Yes | Callback invoked to return the bond state. You need to implement this callback. | +| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event.| +| callback | Callback<[BondStateParam](#BondStateParam)> | Yes | Callback invoked to return the pairing state. You need to implement this callback. | **Return value** @@ -619,7 +619,7 @@ No value is returned. **Example** ```js -function onReceiveEvent(data) { // data, as the input parameter of the callback, indicates the bond state. +function onReceiveEvent(data) { // data, as the input parameter of the callback, indicates the pairing state. console.info('pair state = '+ JSON.stringify(data)); } bluetooth.on('bondStateChange', onReceiveEvent); @@ -630,7 +630,7 @@ bluetooth.on('bondStateChange', onReceiveEvent); off(type: "bondStateChange", callback?: Callback<BondStateParam>): void -Unsubscribes from the Bluetooth bond state change events. +Unsubscribes from the Bluetooth pairing state change events. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -640,8 +640,8 @@ Unsubscribes from the Bluetooth bond state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth bond state change event. | -| callback | Callback<[BondStateParam](#BondStateParam)> | No | Callback used to report the change of the Bluetooth bond 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<[BondStateParam](#BondStateParam)> | No | Callback for the change of the Bluetooth pairing state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -704,7 +704,7 @@ Unsubscribes from the Bluetooth connection state change events. | 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**.| +| callback | Callback<[BluetoothState](#bluetoothstate)> | No | Callback for the Bluetooth connection state change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -990,7 +990,7 @@ Unsubscribes from the SPP read request events. | ------------ | --------------------------- | ---- | ---------------------------------------- | | 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**.| +| callback | Callback<ArrayBuffer> | No | Callback for the SPP read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -1248,7 +1248,7 @@ Unsubscribes from the BLE device discovery events. | 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**.| +| callback | Callback<Array<[ScanResult](#scanresult)>> | No | Callback for the **BLEDeviceFind** event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -1558,7 +1558,7 @@ Subscribes to the HFP connection state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | 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. | +| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the HFP connection state change event. | **Return value** @@ -1588,7 +1588,7 @@ Unsubscribes from the HFP connection state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **connectionStateChange** indicates an HFP connection state change event.| -| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback used to return the HFP connection state change event. | +| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback for the HFP connection state change event. | **Return value** @@ -1718,7 +1718,7 @@ Unsubscribes from the HidHost connection state change events. | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | --------------------------------------------------------- | | type | string | Yes | Event type. The value **connectionStateChange** indicates a HidHost connection state change event.| -| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback used to return the HidHost connection state change event. | +| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback for the HidHost connection state change event. | **Return value** @@ -1786,7 +1786,7 @@ Subscribes to the PAN connection state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **connectionStateChange** indicates a PAN connection state change event.| -| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback used to return the PAN connection state change event. | +| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the PAN connection state change event. | **Return value** @@ -1816,7 +1816,7 @@ Unsubscribes from the PAN connection state change events. | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | --------------------------------------------------------- | | type | string | Yes | Event type. The value **connectionStateChange** indicates a PAN connection state change event.| -| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback used to return the PAN connection state change event. | +| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback for the PAN connection state change event. | **Return value** @@ -2061,10 +2061,9 @@ Removes a service from this GATT server. **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** @@ -2111,10 +2110,9 @@ Notifies the connected client device when a characteristic value changes. **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** @@ -2156,10 +2154,9 @@ Sends a response to a read or write request from the GATT client. **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** @@ -2249,7 +2246,7 @@ Unsubscribes from the characteristic read request events. | 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**.| +| callback | Callback<[CharacteristicReadReq](#characteristicreadreq)> | No | Callback for the characteristic read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -2329,7 +2326,7 @@ Unsubscribes from the characteristic write request events. | 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**.| +| callback | Callback<[CharacteristicWriteReq](#characteristicwritereq)> | No | Callback for the characteristic write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -2406,7 +2403,7 @@ Unsubscribes from the descriptor read request events. | 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**.| +| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | No | Callback for the descriptor read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -2486,7 +2483,7 @@ Unsubscribes from the descriptor write request events. | 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 write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<[DescriptorWriteReq](#descriptorwritereq)> | No | Callback for the descriptor write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -2499,6 +2496,7 @@ let gattServer = bluetooth.BLE.createGattServer(); gattServer.off("descriptorWrite"); ``` + ### on('connectStateChange') on(type: "connectStateChange", callback: Callback<BLEConnectChangedState>): void @@ -2548,7 +2546,7 @@ Unsubscribes from the BLE connection state change events. | 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**.| +| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | No | Callback for the BLE connection state change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -2785,10 +2783,9 @@ Reads the characteristic value of the specific service of the remote BLE device. **Return value** -| | | +| Type | Description | | ---------------------------------------- | -------------------------- | -| Type | Description | -| Promise<[BLECharacteristic](#blecharacteristic)> | Promise used to return the characteristic value read. | +| Promise<[BLECharacteristic](#blecharacteristic)> | Promise used to return the characteristic value read.| **Example** @@ -2876,10 +2873,9 @@ Reads the descriptor contained in the specific characteristic of the remote BLE **Return value** -| | | +| Type | Description | | ---------------------------------------- | -------------------------- | -| Type | Description | -| Promise<[BLEDescriptor](#bledescriptor)> | Promise used to return the descriptor read. | +| Promise<[BLEDescriptor](#bledescriptor)> | Promise used to return the descriptor read.| **Example** @@ -2990,7 +2986,7 @@ if (retWriteDesc) { setBLEMtuSize(mtu: number): boolean -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). +Sets the maximum transmission unit (MTU) that can be transmitted between the GATT client and its remote BLE device. This API can be used only after a connection is set up by calling [connect](#connect). **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -3108,7 +3104,7 @@ Unsubscribes from the BLE characteristic change events. | 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**.| +| callback | Callback<[BLECharacteristic](#blecharacteristic)> | No | Callback for the characteristic value change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -3170,7 +3166,7 @@ Unsubscribes from the BLE connection state change events. | 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**.| +| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | No | Callback for the BLE connection state change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| **Return value** @@ -3671,13 +3667,13 @@ Defines the pairing request parameters. ## BondStateParam8+ -Defines the bond state parameters. +Defines the pairing state parameters. **System capability**: SystemCapability.Communication.Bluetooth.Core | Name | Type | Readable | Writable | Description | | -------- | ------ | ---- | ---- | ----------- | -| deviceId | string | Yes | No | ID of the device.| +| deviceId | string | Yes | No | ID of the device to pair.| | state | BondState | Yes | No | State of the device.| diff --git a/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md index 9b11bb2f18da535af770b96cda13981cef95c62a..5457c4e3154da06f26045b06b7c196eb1c5dd75d 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md @@ -1,13 +1,11 @@ # ExtensionAbilityInfo - +The **ExtensionAbilityInfo** module provides Extension ability information. Unless otherwise specified, all attributes are obtained through [getBundleInfo](js-apis-Bundle.md#bundlegetbundleinfo), and flags are obtained through [GET_BUNDLE_DEFAULT](js-apis-Bundle.md#bundleflag). > **NOTE** > > 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. -The **ExtensionAbilityInfo** module provides Extension ability information. Unless otherwise specified, all attributes are obtained through **GET_BUNDLE_DEFAULT**. - ## ExtensionAbilityInfo **System capability**: SystemCapability.BundleManager.BundleFramework diff --git a/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md index 3a00ac698a3529d153ef3741979238569555f12c..ef19c14e94b36ba0f0677d8bdc35f362f709a7ae 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md @@ -1,6 +1,6 @@ # LauncherAbilityInfo -The **LauncherAbilityInfo** module provides information about a launcher ability. +The **LauncherAbilityInfo** module provides information about the launcher ability, which is obtained through [innerBundleManager.getLauncherAbilityInfos](js-apis-Bundle-InnerBundleManager.md). > **NOTE** > @@ -12,8 +12,8 @@ The **LauncherAbilityInfo** module provides information about a launcher ability **System API**: This is a system API and cannot be called by third-party applications. -| Name | Type | Readable| Writable| Description | -| --------------- | ---------------------------------------------------- | ---- | ---- | ------------------------------------ | +| Name | Type | Readable| Writable| Description | +| --------------- | ---------------------------------------------------- | ---- | ---- | -------------------------------------- | | applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application information of the launcher ability.| | elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | No | Element name of the launcher ability. | | labelId | number | Yes | No | Label ID of the launcher ability. | diff --git a/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md b/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md index d45f34389b0cf049376e282fb2fdf2a2f3130075..9e70a90e4fc19197ebd37021ad3326ab64c3ccfc 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md @@ -1,6 +1,6 @@ # ShortcutInfo -The **ShortcutInfo** module provides shortcut information defined in the configuration file. +The **ShortcutInfo** module provides shortcut information defined in the configuration file. For details about the configuration in the FA model, see [config.json](../../quick-start/package-structure.md). For details about the configuration in the stage model, see [Internal Structure of the shortcuts Attribute](../../quick-start/stage-structure.md#internal-structure-of-the-shortcuts-attribute). > **NOTE** > diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index ac82d0b2e610751bd000849ec35337363b0dcb3a..9b20ccb9f359ed6f8109d3fc57fdebd9d4d728ed 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -824,11 +824,8 @@ This is a system API. **Example** ```js -let promise = call.reject(1); -promise.then(data => { - console.log(`reject success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`reject fail, promise: err->${JSON.stringify(err)}`); +call.reject(1, (error, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index 78db0562f97cf687e26c210d870519c829b691ee..5d57d317cb2a4ae2fa0e7ba29e61a23d95c8dbd1 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -812,7 +812,7 @@ Obtains the zoom ratio range. This API uses an asynchronous callback to return t | Name | Type | Mandatory| Description | | -------- | ------------------------------ | ---- | ------------------------ | -| callback | AsyncCallback\> | Yes | Callback used to return the result.| +| callback | AsyncCallback\> | Yes | Callback used to return an array containing the minimum and maximum zoom ratios.| **Example** @@ -838,7 +838,7 @@ Obtains the zoom ratio range. This API uses a promise to return the result. | Type | Description | | ------------------------ | ------------------------------------------- | -| Promise\> | Promise used to return the zoom ratio range.| +| Promise\> | Promise used to return an array containing the minimum and maximum zoom ratios.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-commonEvent.md b/en/application-dev/reference/apis/js-apis-commonEvent.md index 710d6ccb8820e88ed98e3519c36824efdd5e5b17..50fad38058530104fda01f09d5745c0f8051000a 100644 --- a/en/application-dev/reference/apis/js-apis-commonEvent.md +++ b/en/application-dev/reference/apis/js-apis-commonEvent.md @@ -66,15 +66,11 @@ Provides the event types supported by the **CommonEvent** module. The name and v | COMMON_EVENT_USER_STARTED | usual.event.USER_STARTED | - | Indicates the common event that the user has been started. | | COMMON_EVENT_USER_BACKGROUND | usual.event.USER_BACKGROUND | - | Indicates the common event that the user has been brought to the background. | | COMMON_EVENT_USER_FOREGROUND | usual.event.USER_FOREGROUND | - | Indicates the common event that the user has been brought to the foreground. | -| COMMON_EVENT_USER_SWITCHED | usual.event.USER_SWITCHED | ohos.permission.MANAGE_USERS | Indicates the common event that user switching is happening. | -| COMMON_EVENT_USER_STARTING | usual.event.USER_STARTING | ohos.permission.INTERACT_ACROSS_USERS | Indicates the common event that the user is going to be started. | +| COMMON_EVENT_USER_SWITCHED | usual.event.USER_SWITCHED | ohos.permission.MANAGE_LOCAL_ACCOUNTS | Indicates the common event that user switching is happening. | +| COMMON_EVENT_USER_STARTING | usual.event.USER_STARTING | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the user is going to be started. | | COMMON_EVENT_USER_UNLOCKED | usual.event.USER_UNLOCKED | - | Indicates the common event that the credential-encrypted storage has been unlocked for the current user when the device is unlocked after being restarted. | -| COMMON_EVENT_USER_STOPPING | usual.event.USER_STOPPING | ohos.permission.INTERACT_ACROSS_USERS | Indicates the common event that the user is going to be stopped. | +| COMMON_EVENT_USER_STOPPING | usual.event.USER_STOPPING | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the user is going to be stopped. | | COMMON_EVENT_USER_STOPPED | usual.event.USER_STOPPED | - | Indicates the common event that the user has been stopped. | -| COMMON_EVENT_HWID_LOGIN | common.event.HWID_LOGIN | - | Indicates the common event about a HUAWEI ID login. | -| COMMON_EVENT_HWID_LOGOUT | common.event.HWID_LOGOUT | - | Indicates the common event about a HUAWEI ID logout. | -| COMMON_EVENT_HWID_TOKEN_INVALID | common.event.HWID_TOKEN_INVALID | - | Indicates the common event that the HUAWEI ID is invalid. | -| COMMON_EVENT_HWID_LOGOFF | common.event.HWID_LOGOFF | - | Indicates the common event about a HUAWEI ID logoff. | | COMMON_EVENT_WIFI_POWER_STATE | usual.event.wifi.POWER_STATE | - | Indicates the common event about the Wi-Fi network state, such as enabled and disabled. | | COMMON_EVENT_WIFI_SCAN_FINISHED | usual.event.wifi.SCAN_FINISHED | ohos.permission.LOCATION | Indicates the common event that the Wi-Fi access point has been scanned and proven to be available. | | COMMON_EVENT_WIFI_RSSI_VALUE | usual.event.wifi.RSSI_VALUE | ohos.permission.GET_WIFI_INFO | Indicates the common event that the Wi-Fi signal strength (RSSI) has changed. | @@ -133,8 +129,8 @@ Provides the event types supported by the **CommonEvent** module. The name and v | COMMON_EVENT_CHARGING | usual.event.CHARGING | - | Indicates the common event that the system starts charging the battery. | | COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED | usual.event.DEVICE_IDLE_MODE_CHANGED | - | Indicates the common event that the system idle mode has changed. | | COMMON_EVENT_POWER_SAVE_MODE_CHANGED | usual.event.POWER_SAVE_MODE_CHANGED | - | Indicates the common event that the power saving mode of the system has changed. | -| COMMON_EVENT_USER_ADDED | usual.event.USER_ADDED | ohos.permission.MANAGE_USERS | Indicates the common event that a user has been added to the system. | -| COMMON_EVENT_USER_REMOVED | usual.event.USER_REMOVED | ohos.permission.MANAGE_USERS | Indicates the common event that a user has been removed from the system. | +| COMMON_EVENT_USER_ADDED | usual.event.USER_ADDED | ohos.permission.MANAGE_LOCAL_ACCOUNTS | Indicates the common event that a user has been added to the system. | +| COMMON_EVENT_USER_REMOVED | usual.event.USER_REMOVED | ohos.permission.MANAGE_LOCAL_ACCOUNTS | Indicates the common event that a user has been removed from the system. | | COMMON_EVENT_ABILITY_ADDED | usual.event.ABILITY_ADDED | ohos.permission.LISTEN_BUNDLE_CHANGE | Indicates the common event that an ability has been added. | | COMMON_EVENT_ABILITY_REMOVED | usual.event.ABILITY_REMOVED | ohos.permission.LISTEN_BUNDLE_CHANGE | Indicates the common event that an ability has been removed. | | COMMON_EVENT_ABILITY_UPDATED | usual.event.ABILITY_UPDATED | ohos.permission.LISTEN_BUNDLE_CHANGE | Indicates the common event that an ability has been updated. | diff --git a/en/application-dev/reference/apis/js-apis-data-storage.md b/en/application-dev/reference/apis/js-apis-data-storage.md index ff9f8d69e48847bd60741f174af4dbe92a19e2ee..f01e1a3ab8db3d7fb42d8362a35e29455066b15e 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -5,9 +5,11 @@ Lightweight storage provides applications with data processing capability and al > **NOTE** > -> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > -> - The APIs of this module are no longer maintained since API Version 9. You are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md). +> - The APIs of this module are no longer maintained since API version 9. You are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md). +> +> - The APIs of this module can be used only in the FA model. ## Modules to Import @@ -36,15 +38,15 @@ Reads the specified file and loads its data to the **Storage** instance for data **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Return value** -| Type | Description | -| ------------------- | ------------------------------------------------------ | -| [Storage](#storage) | **Storage** instance used for data storage operations. | +| Type | Description | +| ------------------- | ------------------------------------------------- | +| [Storage](#storage) | **Storage** instance used for data storage operations.| **Example** @@ -54,13 +56,13 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -let storage = data_storage.getStorageSync(path + '/mystore'); -storage.putSync('startup', 'auto'); -storage.flushSync(); + let storage = data_storage.getStorageSync(path + '/mystore'); + storage.putSync('startup', 'auto'); + storage.flushSync(); +}); ``` @@ -74,10 +76,10 @@ Reads the specified file and loads its data to the **Storage** instance for data **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | --------------------------------------------- | -| path | string | Yes | Path of the target file. | -| callback | AsyncCallback<[Storage](#storage)> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| +| callback | AsyncCallback<[Storage](#storage)> | Yes | Callback used to return the execution result. | **Example** @@ -87,18 +89,18 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -data_storage.getStorage(path + '/mystore', function (err, storage) { + data_storage.getStorage(path + '/mystore', function (err, storage) { if (err) { - console.info("Failed to get the storage. path: " + path + '/mystore'); - return; + console.info("Failed to get the storage. path: " + path + '/mystore'); + return; } storage.putSync('startup', 'auto'); storage.flushSync(); -}) + }) +}); ``` @@ -112,15 +114,15 @@ Reads the specified file and loads its data to the **Storage** instance for data **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Return value** -| Type | Description | -| ---------------------------------- | ---------------------------------- | -| Promise<[Storage](#storage)> | Promise used to return the result. | +| Type | Description | +| ---------------------------------- | ------------------------------- | +| Promise<[Storage](#storage)> | Promise used to return the result.| **Example** @@ -130,17 +132,17 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -let getPromise = data_storage.getStorage(path + '/mystore'); -getPromise.then((storage) => { + let getPromise = data_storage.getStorage(path + '/mystore'); + getPromise.then((storage) => { storage.putSync('startup', 'auto'); storage.flushSync(); -}).catch((err) => { + }).catch((err) => { console.info("Failed to get the storage. path: " + path + '/mystore'); -}) + }) +}); ``` @@ -154,9 +156,9 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Example** @@ -168,12 +170,11 @@ var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); -}); -data_storage.deleteStorageSync(path + '/mystore'); + data_storage.deleteStorageSync(path + '/mystore'); +}); ``` - ## data_storage.deleteStorage deleteStorage(path: string, callback: AsyncCallback<void>): void @@ -184,9 +185,9 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------- | -| path | string | Yes | Path of the target file. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -197,17 +198,17 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -data_storage.deleteStorage(path + '/mystore', function (err) { + data_storage.deleteStorage(path + '/mystore', function (err) { if (err) { - console.info("Failed to delete the storage with err: " + err); - return; + console.info("Failed to delete the storage with err: " + err); + return; } console.info("Succeeded in deleting the storage."); -}) + }) +}); ``` @@ -221,13 +222,14 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Return value** -| Type | Description | -| ------------------- | ------------------------------ | + +| Type | Description | +| ------------------- | ------------------------------- | | Promise<void> | Promise that returns no value. | **Example** @@ -238,16 +240,16 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -let promisedelSt = data_storage.deleteStorage(path + '/mystore'); -promisedelSt.then(() => { + let promisedelSt = data_storage.deleteStorage(path + '/mystore'); + promisedelSt.then(() => { console.info("Succeeded in deleting the storage."); -}).catch((err) => { + }).catch((err) => { console.info("Failed to delete the storage with err: " + err); -}) + }) +}); ``` @@ -260,10 +262,9 @@ Removes the singleton **Storage** instance of a file from the cache. The removed **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** - -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Example** @@ -275,9 +276,9 @@ var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); + + data_storage.removeStorageFromCacheSync(path + '/mystore'); }); - -data_storage.removeStorageFromCacheSync(path + '/mystore'); ``` @@ -291,9 +292,9 @@ Removes the singleton **Storage** instance of a file from the cache. The removed **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------- | -| path | string | Yes | Path of the target file. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -304,17 +305,17 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -data_storage.removeStorageFromCache(path + '/mystore', function (err) { + data_storage.removeStorageFromCache(path + '/mystore', function (err) { if (err) { - console.info("Failed to remove storage from cache with err: " + err); - return; + console.info("Failed to remove storage from cache with err: " + err); + return; } console.info("Succeeded in removing storage from cache."); -}) + }) +}); ``` @@ -328,14 +329,14 @@ Removes the singleton **Storage** instance of a file from the cache. The removed **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------ | -| path | string | Yes | Path of the target file. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the target file.| **Return value** -| Type | Description | -| ------------------- | ------------------------------ | +| Type | Description | +| ------------------- | ------------------------------- | | Promise<void> | Promise that returns no value. | **Example** @@ -346,24 +347,22 @@ import featureAbility from '@ohos.ability.featureAbility'; var path; var context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { - path = filePath; - console.info("======================>getFilesDirPromise====================>"); -}); + path = filePath; + console.info("======================>getFilesDirPromise====================>"); -let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore') -promiserevSt.then(() => { + let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore') + promiserevSt.then(() => { console.info("Succeeded in removing storage from cache."); -}).catch((err) => { + }).catch((err) => { console.info("Failed to remove storage from cache with err: " + err); -}) + }) +}); ``` - ## Storage Provides APIs for obtaining and modifying storage data. - ### getSync getSync(key: string, defValue: ValueType): ValueType @@ -374,16 +373,16 @@ Obtains the value corresponding to a key. If the value is null or not in the def **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ----------------------- | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| defValue | [ValueType](#valuetype) | Yes | Default value to be returned if the value of the specified key does not exist. It can be a number, string, or Boolean value. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ------------------------------------------------------------ | +| key | string | Yes | Key of the data. It cannot be empty. | +| defValue | [ValueType](#valuetype) | Yes | Default value to be returned if the value of the specified key does not exist. It can be a number, string, or Boolean value.| **Return value** -| Type | Description | -| --------- | ------------------------------------------------------------ | -| ValueType | Value corresponding to the specified key. If the value is null or not in the default value format, the default value is returned. | +| Type | Description | +| --------- | -------------------------------------------------------- | +| ValueType | Value corresponding to the specified key. If the value is null or not in the default value format, the default value is returned.| **Example** @@ -403,11 +402,11 @@ Obtains the value corresponding to a key. If the value is null or not in the def **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------ | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| defValue | [ValueType](#valuetype) | Yes | Default value to be returned. It can be a number, string, or Boolean value. | -| callback | AsyncCallback<ValueType> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------ | ---- | ----------------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty. | +| defValue | [ValueType](#valuetype) | Yes | Default value to be returned. It can be a number, string, or Boolean value.| +| callback | AsyncCallback<ValueType> | Yes | Callback used to return the execution result. | **Example** @@ -432,18 +431,19 @@ Obtains the value corresponding to a key. If the value is null or not in the def **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ----------------------- | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| defValue | [ValueType](#valuetype) | Yes | Default value to be returned. It can be a number, string, or Boolean value. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ----------------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty. | +| defValue | [ValueType](#valuetype) | Yes | Default value to be returned. It can be a number, string, or Boolean value.| **Return value** -| Type | Description | -| ------------------------ | ---------------------------------- | -| Promise<ValueType> | Promise used to return the result. | +| Type | Description | +| ------------------------ | ------------------------------- | +| Promise<ValueType> | Promise used to return the result.| **Example** + ```js let promiseget = storage.get('startup', 'default'); promiseget.then((value) => { @@ -464,15 +464,15 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ----------------------- | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value. | +| Name| Type | Mandatory| Description | +| ------ | ----------------------- | ---- | ----------------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty. | +| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value.| **Example** ```js -storage.putSync('startup', 'auto') +storage.putSync('startup', 'auto'); ``` @@ -486,10 +486,10 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ----------------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty. | +| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value.| | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -515,18 +515,19 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ----------------------- | --------- | ------------------------------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | -| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value. | +| Name| Type | Mandatory| Description | +| ------ | ----------------------- | ---- | ----------------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty. | +| value | [ValueType](#valuetype) | Yes | New value to store. It can be a number, string, or Boolean value.| **Return value** -| Type | Description | -| ------------------- | ------------------------------ | +| Type | Description | +| ------------------- | --------------------------- | | Promise<void> | Promise that returns no value. | **Example** + ```js let promiseput = storage.put('startup', 'auto'); promiseput.then(() => { @@ -547,15 +548,15 @@ Checks whether the storage object contains data with a given key. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty.| **Return value** -| Type | Description | -| ------- | ------------------------------------------------------------ | -| boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise. | +| Type | Description | +| ------- | ------------------------------------- | +| boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise.| **Example** @@ -577,16 +578,16 @@ Checks whether the storage object contains data with a given key. This API uses **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------- | --------- | --------------------------------------------- | -| key | string | Yes | Key of the data. It cannot be empty. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty.| +| callback | AsyncCallback<boolean> | Yes | Callback used to return the execution result. | **Return value** -| Type | Description | -| ------- | ------------------------------------------------------------ | -| boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise. | +| Type | Description | +| ------- | ------------------------------- | +| boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise.| **Example** @@ -613,15 +614,15 @@ Checks whether the storage object contains data with a given key. This API uses **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty.| **Return value** -| Type | Description | -| ---------------------- | ---------------------------------- | -| Promise<boolean> | Promise used to return the result. | +| Type | Description | +| ---------------------- | --------------------------- | +| Promise<boolean> | Promise used to return the result.| **Example** @@ -647,14 +648,14 @@ Deletes data with the specified key from this storage object. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | --------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty.| **Example** ```js -storage.deleteSync('startup') + storage.deleteSync('startup'); ``` @@ -668,9 +669,9 @@ Deletes data with the specified key from this storage object. This API uses an a **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------------ | -| key | string | Yes | Key of the data. It cannot be empty. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------------- | +| key | string | Yes | Key of the data. It cannot be empty.| | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -696,14 +697,14 @@ Deletes data with the specified key from this storage object. This API uses a pr **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ---------------- | -| key | string | Yes | Key of the data. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | --------------------- | +| key | string | Yes | Key of the data.| **Return value** -| Type | Description | -| ------------------- | ------------------------------ | +| Type | Description | +| ------------------- | --------------------------- | | Promise<void> | Promise that returns no value. | **Example** @@ -729,7 +730,7 @@ Saves the modification of this object to the **Storage** instance and synchroniz **Example** ```js -storage.flushSync() +storage.flushSync(); ``` @@ -743,8 +744,8 @@ Saves the modification of this object to the **Storage** instance and synchroniz **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------- | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -770,8 +771,8 @@ Saves the modification of this object to the **Storage** instance and synchroniz **Return value** -| Type | Description | -| ------------------- | ------------------------------ | +| Type | Description | +| ------------------- | --------------------------- | | Promise<void> | Promise that returns no value. | **Example** @@ -797,7 +798,7 @@ Clears this **Storage** object. **Example** ```js -storage.clearSync() +storage.clearSync(); ``` @@ -811,8 +812,8 @@ Clears this **Storage** object. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | --------- | ------------------------------- | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | Yes | Callback that returns no value. | **Example** @@ -837,9 +838,8 @@ Clears this **Storage** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Return value** - -| Type | Description | -| ------------------- | ------------------------------ | +| Type | Description | +| ------------------- | --------------------------- | | Promise<void> | Promise that returns no value. | **Example** @@ -864,10 +864,10 @@ Subscribes to data changes. The **StorageObserver** needs to be implemented. Whe **Parameters** -| Name | Type | Description | -| -------- | --------------------------------------------------- | ------------------------------------------------------------ | -| type | string | Event type. The value **change** indicates data change events. | -| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. | +| Name | Type | Description | +| -------- | --------------------------------------------------- | ---------------------------------------- | +| type | string | Event type. The value **change** indicates data change events.| +| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. | **Example** @@ -891,10 +891,10 @@ Unsubscribes from data changes. **Parameters** -| Name | Type | Description | -| -------- | --------------------------------------------------- | ------------------------------------------------------------ | -| type | string | Event type. The value **change** indicates data change events. | -| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. | +| Name | Type | Description | +| -------- | --------------------------------------------------- | ---------------------------------------- | +| type | string | Event type. The value **change** indicates data change events.| +| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. | **Example** @@ -910,9 +910,9 @@ storage.off('change', observer); **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | ------------- | -| key | string | No | Data changed. | +| Name| Type| Mandatory| Description | +| ---- | -------- | ---- | ---------------- | +| key | string | No | Data changed.| ## ValueType @@ -920,8 +920,8 @@ Enumerates the value types. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -| Type | Description | -| ------- | ----------------------------- | -| number | The value is a number. | -| string | The value is a string. | -| boolean | The value is of Boolean type. | \ No newline at end of file +| Type | Description | +| ------- | -------------------- | +| number | The value is a number. | +| string | The value is a string. | +| boolean | The value is of Boolean type.| diff --git a/en/application-dev/reference/apis/js-apis-deque.md b/en/application-dev/reference/apis/js-apis-deque.md index ea8803f444dca95990cb00a015bfbad12f590639..973cdfb78725ba03576d7cc6a561c71e6930aeb2 100644 --- a/en/application-dev/reference/apis/js-apis-deque.md +++ b/en/application-dev/reference/apis/js-apis-deque.md @@ -12,6 +12,9 @@ Double-ended queue (deque) is a sequence container implemented based on the queu **Recommended use case**: Use **Deque** when you need to frequently insert or remove elements at both the ends of a container. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -64,7 +67,7 @@ deque.insertFront("a"); deque.insertFront(1); let b = [1, 2, 3]; deque.insertFront(b); -let c = {name : "lala", age : "13"}; +let c = {name : "Dylon", age : "13"}; deque.insertFront(false); ``` @@ -90,7 +93,7 @@ deque.insertEnd("a"); deque.insertEnd(1); let b = [1, 2, 3]; deque.insertEnd(b); -let c = {name : "lala", age : "13"}; +let c = {name : "Dylon", age : "13"}; deque.insertEnd(false); ``` @@ -118,9 +121,9 @@ Checks whether this container has the specified element. ```ts let deque = new Deque(); -let result = deque.has("Ahfbrgrbgnutfodgorrogorg"); -deque.insertFront("Ahfbrgrbgnutfodgorrogorg"); -let result1 = deque.has("Ahfbrgrbgnutfodgorrogorg"); +let result = deque.has("squirrel"); +deque.insertFront("squirrel"); +let result1 = deque.has("squirrel"); ``` ### popFirst diff --git a/en/application-dev/reference/apis/js-apis-distributed-account.md b/en/application-dev/reference/apis/js-apis-distributed-account.md index efb9ce6224f75f0f56638fd209f888e45a65290c..4dc76cd2d39f631d74d5c51b61259bd88a1ea924 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-account.md +++ b/en/application-dev/reference/apis/js-apis-distributed-account.md @@ -21,12 +21,13 @@ Obtains a **DistributedAccountAbility** instance. **System capability**: SystemCapability.Account.OsAccount -- Return value +**Return value** + | Type| Description| | -------- | -------- | | [DistributedAccountAbility](#distributedaccountability) | **DistributedAccountAbility** instance obtained. This instance provides methods for querying and updating the login state of a distributed account.| -- Example +**Example** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); ``` @@ -45,12 +46,13 @@ Obtains distributed account information. This API uses an asynchronous callback **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC -- Parameters +**Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the distributed account information obtained.| -- Example +**Example** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo((err, data) => { @@ -70,12 +72,13 @@ Obtains distributed account information. This API uses a promise to return the r **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC -- Return value +**Return value** + | Type| Description| | -------- | -------- | | Promise<[DistributedInfo](#distributedinfo)> | Promise used to return the distributed account information obtained.| -- Example +**Example** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo().then((data) => { @@ -96,13 +99,14 @@ Updates distributed account information. This API uses an asynchronous callback **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS -- Parameters +**Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | accountInfo | [DistributedInfo](#distributedinfo) | Yes| Distributed account information.| | callback | AsyncCallback<void> | Yes| Callback invoked when the distributed account information is updated.| -- Example +**Example** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; @@ -121,17 +125,19 @@ Updates distributed account information. This API uses a promise to return the r **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS -- Parameters +**Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | accountInfo | [DistributedInfo](#distributedinfo) | Yes| Distributed account information.| -- Return value +**Return value** + | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example +**Example** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; diff --git a/en/application-dev/reference/apis/js-apis-effectKit.md b/en/application-dev/reference/apis/js-apis-effectKit.md index 498bc3beb398e1f7b3b6fc20657ef01fec0b8bb1..cf2bb656da8705ff8352e00a06ce9149980959a4 100644 --- a/en/application-dev/reference/apis/js-apis-effectKit.md +++ b/en/application-dev/reference/apis/js-apis-effectKit.md @@ -4,7 +4,7 @@ The **EffectKit** module provides basic image processing capabilities, including This module provides the following classes: -- [Filter](#filter): a class that provides the effect chain. +- [Filter](#filter): a class that provides the effect chain, which is a linked list of image processing effects. - [Color](#color): a class used to store the color picked. - [ColorPicker](#colorpicker): a smart color picker. @@ -155,7 +155,7 @@ Obtains the main color of the image and writes the result to a **[Color](#color) ```js colorPicker.getMainColor().then(color => { console.log('Succeeded in getting main color.'); - console.info("color[ARGB]=" + color.alpha + "," + color.red + "," + color.green + "," + color.blue); + console.info(`color[ARGB]=${color.alpha},${color.red},${color.green},${color.blue}`); }).catch(error => { console.log('Failed to get main color.'); }) diff --git a/en/application-dev/reference/apis/js-apis-filemanager.md b/en/application-dev/reference/apis/js-apis-filemanager.md index 9aa6294c56aed0d897ceecc46c4fd4ca6ecd48c6..b80660185cffaf10993bf9c54ba1f88a1f16b7f4 100644 --- a/en/application-dev/reference/apis/js-apis-filemanager.md +++ b/en/application-dev/reference/apis/js-apis-filemanager.md @@ -22,6 +22,7 @@ Obtains information about the root album or directory in asynchronous mode. This **System capability**: SystemCapability.FileManagement.UserFileService **Parameters** + | Name| Type| Mandatory| Description| | --- | --- | --- | -- | | options | Object | No| The options are as follows:
-  **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| @@ -83,6 +84,7 @@ Obtains information about the second-level album or files in asynchronous mode. **System capability**: SystemCapability.FileManagement.UserFileService **Parameters** + | Name| Type| Mandatory| Description| | --- | --- | --- | -- | | path | string | Yes| URI of the directory to query.| @@ -169,6 +171,7 @@ Creates a file in the specified path in asynchronous mode. This API uses a promi **System capability**: SystemCapability.FileManagement.UserFileService **Parameters** + | Name| Type| Mandatory| Description| | --- | --- | --- | -- | | filename | string | Yes| Name of the file to create.| diff --git a/en/application-dev/reference/apis/js-apis-formInfo.md b/en/application-dev/reference/apis/js-apis-formInfo.md index 950da73f21bd3ac1ee8e8fe8a57989714a95d6dd..8acf0e5e3e1ccb81b2295b03c65ed8fd812efa8e 100644 --- a/en/application-dev/reference/apis/js-apis-formInfo.md +++ b/en/application-dev/reference/apis/js-apis-formInfo.md @@ -3,7 +3,7 @@ The **FormInfo** module provides widget information and state. > **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 @@ -120,3 +120,14 @@ Enumerates the widget dimensions. | Dimension_2_49+ | 3 | 2 x 4. | | Dimension_4_49+ | 4 | 4 x 4. | | Dimension_2_19+ | 5 | 2 x 1. | + + +## FormInfoFilter + +Defines the widget information filter. Only the widget information that meets the filter is returned. + +**System capability**: SystemCapability.Ability.Form + +| Name | Yes | Description | +| ----------- | ---- | ------------ | +| moduleName9+ | No | Module name.| diff --git a/en/application-dev/reference/apis/js-apis-formprovider.md b/en/application-dev/reference/apis/js-apis-formprovider.md index fbe8907aed6b59d005f027af62ec4d0b0ec9a141..8ce539886e5460ffe712b486addf6e3813c44a90 100644 --- a/en/application-dev/reference/apis/js-apis-formprovider.md +++ b/en/application-dev/reference/apis/js-apis-formprovider.md @@ -3,7 +3,7 @@ The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release. > **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 @@ -183,7 +183,7 @@ Obtains the application's widget information that meets a filter criterion on th | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------- | -| filter | formInfo.FormInfoFilter | Yes| Filter criterion.| +| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md#forminfofilter) | Yes| Filter criterion.| | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Yes| Callback used to return the widget information.| **Example** @@ -214,7 +214,7 @@ Obtains the application's widget information on the device. This API uses a prom | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------- | -| filter | formInfo.FormInfoFilter | No| Filter criterion.| +| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md) | No| Filter criterion.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-hashmap.md b/en/application-dev/reference/apis/js-apis-hashmap.md index d1ac45e3bd10590be109ded2095405e4dee962de..5cf52af02dd7e1c36469882706ef2e0533cc5a5c 100644 --- a/en/application-dev/reference/apis/js-apis-hashmap.md +++ b/en/application-dev/reference/apis/js-apis-hashmap.md @@ -12,6 +12,10 @@ **Recommended use case**: Use **HashMap** when you need to quickly access, remove, and insert key-value pairs. +This topic uses the following to identify the use of generics: +- K: Key +- V: Value + ## Modules to Import ```ts @@ -90,9 +94,9 @@ Checks whether this container contains the specified key. ```ts let hashMap = new HashMap(); -let result = hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -let result1 = hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = hashMap.hasKey("squirrel"); +hashMap.set("squirrel", 123); +let result1 = hashMap.hasKey("squirrel"); ``` @@ -121,7 +125,7 @@ Checks whether this container contains the specified value. ```ts let hashMap = new HashMap(); let result = hashMap.hasValue(123); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +hashMap.set("squirrel", 123); let result1 = hashMap.hasValue(123); ``` @@ -150,9 +154,9 @@ Obtains the value of the specified key in this container. ```ts let hashMap = new HashMap(); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -hashMap.set("sdfs", 356); -let result = hashMap.get("sdfs"); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let result = hashMap.get("sparrow"); ``` @@ -174,8 +178,8 @@ Adds all elements in a **HashMap** instance to this container. ```ts let hashMap = new HashMap(); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -hashMap.set("sdfs", 356); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); let newHashMap = new HashMap(); hashMap.setAll(newHashMap); ``` @@ -194,7 +198,7 @@ Adds an element to this container. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | K | Yes| Key of the target element.| -| value | V | Yes| Value of the element.| +| value | V | Yes| Value of the target element.| **Return value** @@ -206,7 +210,7 @@ Adds an element to this container. ```ts let hashMap = new HashMap(); -let result = hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +let result = hashMap.set("squirrel", 123); ``` @@ -234,9 +238,9 @@ Removes an element with the specified key from this container. ```ts let hashMap = new HashMap(); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -hashMap.set("sdfs", 356); -let result = hashMap.remove("sdfs"); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let result = hashMap.remove("sparrow"); ``` @@ -252,8 +256,8 @@ Clears this container and sets its length to **0**. ```ts let hashMap = new HashMap(); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -hashMap.set("sdfs", 356); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); hashMap.clear(); ``` @@ -276,8 +280,8 @@ Obtains an iterator that contains all the elements in this container. ```ts let hashMap = new HashMap(); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -hashMap.set("sdfs", 356); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); let iter = hashMap.keys(); let temp = iter.next().value; while(temp != undefined) { @@ -305,8 +309,8 @@ Obtains an iterator that contains all the values in this container. ```ts let hashMap = new HashMap(); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -hashMap.set("sdfs", 356); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); let iter = hashMap.values(); let temp = iter.next().value; while(temp != undefined) { @@ -341,8 +345,8 @@ Replaces an element in this container. ```ts let hashMap = new HashMap(); -hashMap.set("sdfs", 123); -let result = hashMap.replace("sdfs", 357); +hashMap.set("sparrow", 123); +let result = hashMap.replace("sparrow", 357); ``` @@ -372,8 +376,8 @@ callbackfn ```ts let hashMap = new HashMap(); -hashMap.set("sdfs", 123); -hashMap.set("dfsghsf", 357); +hashMap.set("sparrow", 123); +hashMap.set("gull", 357); hashMap.forEach((value, key) => { console.log("value:" + value, key); }); @@ -398,8 +402,8 @@ Obtains an iterator that contains all the elements in this container. ```ts let hashMap = new HashMap(); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -hashMap.set("sdfs", 356); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); let iter = hashMap.entries(); let temp = iter.next().value; while(temp != undefined) { @@ -427,8 +431,8 @@ Obtains an iterator, each item of which is a JavaScript object. **Example** ```ts let hashMap = new HashMap(); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -hashMap.set("sdfs", 356); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); // Method 1: for (let item of hashMap) { diff --git a/en/application-dev/reference/apis/js-apis-hashset.md b/en/application-dev/reference/apis/js-apis-hashset.md index 85bbfa2719412099c1d051de61b3c39363872b27..6568c856e715a5f86da527aea4c5ce3888537bc5 100644 --- a/en/application-dev/reference/apis/js-apis-hashset.md +++ b/en/application-dev/reference/apis/js-apis-hashset.md @@ -10,6 +10,9 @@ Unlike [TreeSet](js-apis-treeset.md), which stores and accesses data in sorted o **Recommended use case**: Use **HashSet** when you need a set that has only unique elements or need to deduplicate a set. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -26,6 +29,17 @@ import HashSet from '@ohos.util.HashSet'; | -------- | -------- | -------- | -------- | -------- | | length | number | Yes| No| Number of elements in a hash set (called container later).| +**Example** + +```ts +let hashSet = new HashSet(); +hashSet.add(1); +hashSet.add(2); +hashSet.add(3); +hashSet.add(4); +hashSet.add(5); +let res = hashSet.length; +``` ### constructor @@ -88,9 +102,9 @@ Checks whether this container contains the specified element. ```ts let hashSet = new HashSet(); -let result = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -let result1 = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = hashSet.has("squirrel"); +hashSet.add("squirrel"); +let result1 = hashSet.has("squirrel"); ``` @@ -118,7 +132,7 @@ Adds an element to this container. ```ts let hashSet = new HashSet(); -let result = hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = hashSet.add("squirrel"); ``` @@ -146,9 +160,9 @@ Removes an element from this container. ```ts let hashSet = new HashSet(); -hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -hashSet.add("sdfs"); -let result = hashSet.remove("sdfs"); +hashSet.add("squirrel"); +hashSet.add("sparrow"); +let result = hashSet.remove("sparrow"); ``` @@ -164,8 +178,8 @@ Clears this container and sets its length to **0**. ```ts let hashSet = new HashSet(); -hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -hashSet.add("sdfs"); +hashSet.add("squirrel"); +hashSet.add("sparrow"); hashSet.clear(); ``` @@ -188,8 +202,8 @@ Obtains an iterator that contains all the values in this container. ```ts let hashSet = new HashSet(); -hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -hashSet.add("sdfs"); +hashSet.add("squirrel"); +hashSet.add("sparrow"); let iter = hashSet.values(); let temp = iter.next().value; while(temp != undefined) { @@ -225,8 +239,8 @@ callbackfn ```ts let hashSet = new HashSet(); -hashSet.add("sdfs"); -hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sparrow"); +hashSet.add("squirrel"); hashSet.forEach((value, key) => { console.log("value:" + value, key); }); @@ -250,8 +264,8 @@ Obtains an iterator that contains all the elements in this container. ```ts let hashSet = new HashSet(); -hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -hashSet.add("sdfs"); +hashSet.add("squirrel"); +hashSet.add("sparrow"); let iter = hashSet.entries(); let temp = iter.next().value; while(temp != undefined) { @@ -280,8 +294,8 @@ Obtains an iterator, each item of which is a JavaScript object. ```ts let hashSet = new HashSet(); -hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -hashSet.add("sdfs"); +hashSet.add("squirrel"); +hashSet.add("sparrow"); // Method 1: for (let item of hashSet) { diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md index bcbf619bf7173a405eee37f5dac86c5e87a023e9..866a5833b69feb01da451f2464fbdd7915f06172 100644 --- a/en/application-dev/reference/apis/js-apis-image.md +++ b/en/application-dev/reference/apis/js-apis-image.md @@ -115,7 +115,7 @@ const readBuffer = new ArrayBuffer(96); pixelmap.readPixelsToBuffer(readBuffer).then(() => { console.log('Succeeded in reading image pixel data.'); // Called if the condition is met. }).catch(error => { - ('Failed to read image pixel data.'); // Called if no condition is met. + console.log('Failed to read image pixel data.'); // Called if no condition is met. }) ``` @@ -261,12 +261,7 @@ image.createPixelMap(color, opts) } pixelmap.writePixels(area).then(() => { - const readArea = { pixels: new ArrayBuffer(8), - offset: 0, - stride: 8, - // region.size.width + x < opts.width, region.size.height + y < opts.height - region: { size: { height: 1, width: 2 }, x: 0, y: 0 } - } + console.info('Succeeded to write pixelmap into the specified area.'); }) }).catch(error => { console.log('error: ' + error); @@ -291,17 +286,20 @@ Writes image pixel map data to an area. This API uses an asynchronous callback t **Example** ```js -const area = new ArrayBuffer(400); +const area = { pixels: new ArrayBuffer(8), + offset: 0, + stride: 8, + region: { size: { height: 1, width: 2 }, x: 0, y: 0 } +} +let bufferArr = new Uint8Array(area.pixels); +for (var i = 0; i < bufferArr.length; i++) { + bufferArr[i] = i + 1; +} pixelmap.writePixels(area, (error) => { if (error != undefined) { console.info('Failed to write pixelmap into the specified area.'); } else { - const readArea = { - pixels: new ArrayBuffer(20), - offset: 0, - stride: 8, - region: { size: { height: 1, width: 2 }, x: 0, y: 0 }, - } + console.info('Succeeded to write pixelmap into the specified area.'); } }) ``` @@ -330,9 +328,11 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj ```js const color = new ArrayBuffer(96); -const pixelMap = new ArrayBuffer(400); let bufferArr = new Uint8Array(color); -pixelMap.writeBufferToPixels(color).then(() => { +for (var i = 0; i < bufferArr.length; i++) { + bufferArr[i] = i + 1; +} +pixelmap.writeBufferToPixels(color).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."); @@ -358,9 +358,11 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj ```js const color = new ArrayBuffer(96); -const pixelMap = new ArrayBuffer(400); let bufferArr = new Uint8Array(color); -pixelMap.writeBufferToPixels(color, function(err) { +for (var i = 0; i < bufferArr.length; i++) { + bufferArr[i] = i + 1; +} +pixelmap.writeBufferToPixels(color, function(err) { if (err) { console.error("Failed to write data from a buffer to a PixelMap."); return; @@ -387,12 +389,22 @@ Obtains pixel map information of this image. This API uses a promise to return t **Example** ```js -const pixelMap = new ArrayBuffer(400); -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."); -}); +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } } +image.createPixelMap(color, opts).then(pixelmap => { + globalpixelmap = pixelmap; + if (pixelmap == undefined) { + console.error("Failed to obtain the image pixel map information."); + } + pixelmap.getImageInfo().then(imageInfo => { + if (imageInfo == undefined) { + console.error("Failed to obtain the image pixel map information."); + } + if (imageInfo.size.height == 4 && imageInfo.size.width == 6) { + console.log("Succeeded in obtaining the image pixel map information."); + } + }) +}) ``` ### getImageInfo7+ @@ -412,8 +424,21 @@ Obtains pixel map information of this image. This API uses an asynchronous callb **Example** ```js -pixelmap.getImageInfo((imageInfo) => { - console.log("Succeeded in obtaining the image pixel map information."); +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +image.createPixelMap(color, opts, (err, pixelmap) => { + if (pixelmap == undefined) { + globalpixelmap = pixelmap; + console.error("Failed to obtain the image pixel map information."); + } + pixelmap.getImageInfo((err, imageInfo) => { + if (imageInfo == undefined) { + console.error("Failed to obtain the image pixel map information."); + } + if (imageInfo.size.height == 4 && imageInfo.size.width == 6) { + console.log("Succeeded in obtaining the image pixel map information."); + } + }) }) ``` @@ -500,9 +525,15 @@ Sets an opacity rate for this image pixel map. This API uses an asynchronous cal **Example** ```js -async function () { - await pixelMap.opacity(0.5); -} +var rate = 0.5; +pixelmap.opacity(rate, (err) => { + if (err) { + console.error("Failed to set opacity."); + return; + } else { + console.log("Succeeded in setting opacity."); + } +}) ``` ### opacity9+ @@ -529,7 +560,8 @@ Sets an opacity rate for this image pixel map. This API uses a promise to return ```js async function () { - await pixelMap.opacity(0.5); + var rate = 0.5; + await pixelmap.opacity(rate); } ``` @@ -550,12 +582,8 @@ Creates a **PixelMap** object that contains only the alpha channel information. **Example** ```js -pixelMap.createAlphaPixelmap(async (err, alphaPixelMap) => { - if (alphaPixelMap == undefined) { - console.info('Failed to obtain new pixel map.'); - } else { - console.info('Succeed in obtaining new pixel map.'); - } +async function () { + await pixelmap.createAlphaPixelmap(); }) ``` @@ -576,14 +604,13 @@ Creates a **PixelMap** object that contains only the alpha channel information. **Example** ```js -let pixelMap = await imageSource.createPixelMap(); -if (pixelMap != undefined) { - pixelMap.createAlphaPixelmap(async (err, alphaPixelMap) => { - console.info('Failed to obtain new pixel map.'); - }) -} else { - console.info('Succeed in obtaining new pixel map.'); -} +pixelmap.createAlphaPixelmap((err, alphaPixelMap) => { + if (alphaPixelMap == undefined) { + console.info('Failed to obtain new pixel map.'); + } else { + console.info('Succeed in obtaining new pixel map.'); + } +}) ``` ### scale9+ @@ -606,7 +633,7 @@ Scales this image based on the input width and height. This API uses an asynchro ```js async function () { - await pixelMap.scale(2.0, 1.0); + await pixelmap.scale(2.0, 1.0); } ``` @@ -635,7 +662,7 @@ Scales this image based on the input width and height. This API uses a promise t ```js async function () { - await pixelMap.scale(2.0, 1.0); + await pixelmap.scale(2.0, 1.0); } ``` @@ -659,7 +686,7 @@ Translates this image based on the input coordinates. This API uses an asynchron ```js async function () { - await pixelMap.translate(3.0, 1.0); + await pixelmap.translate(3.0, 1.0); } ``` @@ -688,7 +715,7 @@ Translates this image based on the input coordinates. This API uses a promise to ```js async function () { - await pixelMap.translate(3.0, 1.0); + await pixelmap.translate(3.0, 1.0); } ``` @@ -711,7 +738,7 @@ Rotates this image based on the input angle. This API uses an asynchronous callb ```js async function () { - await pixelMap.rotate(90.0); + await pixelmap.rotate(90.0); } ``` @@ -739,7 +766,7 @@ Rotates this image based on the input angle. This API uses a promise to return t ```js async function () { - await pixelMap.rotate(90.0); + await pixelmap.rotate(90.0); } ``` @@ -763,7 +790,7 @@ Flips this image horizontally or vertically, or both. This API uses an asynchron ```js async function () { - await pixelMap.flip(false, true); + await pixelmap.flip(false, true); } ``` @@ -792,7 +819,7 @@ Flips this image horizontally or vertically, or both. This API uses a promise to ```js async function () { - await pixelMap.flip(false, true); + await pixelmap.flip(false, true); } ``` @@ -815,7 +842,7 @@ Crops this image based on the input size. This API uses an asynchronous callback ```js async function () { - await pixelMap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); + await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); } ``` @@ -843,7 +870,7 @@ Crops this image based on the input size. This API uses a promise to return the ```js async function () { - await pixelMap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); + await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); } ``` @@ -954,7 +981,8 @@ Creates an **ImageSource** instance based on the URI. **Example** ```js -const imageSourceApi = image.createImageSource('/sdcard/test.jpg'); +var sourceOptions = { sourceDensity: 120 }; +let imageSource = image.createImageSource('test.png', sourceOptions); ``` ## image.createImageSource7+ @@ -1007,7 +1035,8 @@ Creates an **ImageSource** instance based on the file descriptor. **Example** ```js -const imageSourceApi = image.createImageSource(fd); +var sourceOptions = { sourceDensity: 120 }; +const imageSourceApi = image.createImageSource(0, sourceOptions); ``` ## image.createImageSource9+ @@ -1059,9 +1088,9 @@ const data = new ArrayBuffer(112); const imageSourceApi = image.createImageSource(data); ``` -## image.CreateIncrementalSource9+ +## image.createIncrementalSource9+ -CreateIncrementalSource(buf: ArrayBuffer): ImageSource +createIncrementalSource(buf: ArrayBuffer): ImageSource Creates an **ImageSource** instance in incremental mode based on the buffers. @@ -1083,12 +1112,12 @@ Creates an **ImageSource** instance in incremental mode based on the buffers. ```js const buf = new ArrayBuffer(96); -const imageSourceApi = image.CreateIncrementalSource(buf); +const imageSourceIncrementalSApi = image.createIncrementalSource(buf); ``` -## image.CreateIncrementalSource9+ +## image.createIncrementalSource9+ -CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource +createIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource Creates an **ImageSource** instance in incremental mode based on the buffers. @@ -1111,7 +1140,7 @@ Creates an **ImageSource** instance in incremental mode based on the buffers. ```js const buf = new ArrayBuffer(96); -const imageSourceApi = image.CreateIncrementalSource(buf); +const imageSourceIncrementalSApi = image.createIncrementalSource(buf); ``` ## ImageSource @@ -1124,7 +1153,7 @@ Provides APIs to obtain image information. Before calling any API in **ImageSour | Name | Type | Readable| Writable| Description | | ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | -| supportedFormats | Array\ | Yes | No | Supported image formats, including png, jpeg, wbmp, bmp, gif, webp, and heif.| +| supportedFormats | Array\ | Yes | No | Supported image formats, including PNG, JPEG, BMP, GIF, WebP, and RAW.| ### getImageInfo @@ -1282,7 +1311,7 @@ Obtains the value of a property in this image. This API uses an asynchronous cal **Example** ```js -const property = new ArrayBuffer(400); +let property = { index: 0, defaultValue: '9999' } imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => { if(error) { console.log('Failed to get the value of the specified attribute key of the image.'); @@ -1477,7 +1506,15 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses **Example** ```js -const decodingOptions = new ArrayBuffer(400); +let decodingOptions = { + sampleSize: 1, + editable: true, + desiredSize: { width: 1, height: 2 }, + rotate: 10, + desiredPixelFormat: 3, + desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 }, + index: 0 +}; imageSourceApi.createPixelMap(decodingOptions, pixelmap => { console.log('Succeeded in creating pixelmap object.'); }) @@ -1551,7 +1588,7 @@ 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. +Provides APIs to pack images. Before calling any API in **ImagePacker**, you must use **createImagePacker** to create an **ImagePacker** instance. The image formats JPEG and WebP are supported. ### Attributes @@ -1581,7 +1618,6 @@ Packs an image. This API uses an asynchronous callback to return the result. ```js let packOpts = { format:"image/jpeg", quality:98 }; -const imageSourceApi = new ArrayBuffer(400); imagePackerApi.packing(imageSourceApi, packOpts, data => {}) ``` @@ -1610,7 +1646,6 @@ Packs an image. This API uses a promise to return the result. ```js let packOpts = { format:"image/jpeg", quality:98 } -const imageSourceApi = new ArrayBuffer(400); imagePackerApi.packing(imageSourceApi, packOpts) .then( data => { console.log('packing succeeded.'); @@ -2112,7 +2147,7 @@ Describes area information in an image. | ------ | ------------------ | ---- | ---- | ------------------------------------------------------------ | | pixels | ArrayBuffer | Yes | No | Pixels of the image. | | offset | number | Yes | No | Offset for data reading. | -| stride | number | Yes | No | Number of bytes from one row of pixels in memory to the next row of pixels in memory. The value of **stride** must be greater than or equal to the value of **region.size.width** multiplied by 4. | +| stride | number | Yes | No | Number of bytes from one row of pixels in memory to the next row of pixels in memory. The value of **stride** must be greater than or equal to the value of **region.size.width** multiplied by 4. | | region | [Region](#region7) | Yes | No | Region to read or write. The width of the region to write plus the X coordinate cannot be greater than the width of the original image. The height of the region to write plus the Y coordinate cannot be greater than the height of the original image.| ## ImageInfo @@ -2146,8 +2181,8 @@ Enumerates the pixel formats of images. | ---------------------- | ------ | ----------------- | | UNKNOWN | 0 | Unknown format. | | RGB_565 | 2 | RGB_565. | -| RGBA_8888 | 3 | RGBA_8888.| -| BGRA_88889+ | 4 | BGRA_8888.| +| RGBA_8888 | 3 | RGBA_8888. | +| BGRA_88889+ | 4 | BGRA_8888. | ## AlphaType9+ @@ -2159,8 +2194,8 @@ Enumerates the alpha types of images. | -------- | ------ | ----------------------- | | UNKNOWN | 0 | Unknown alpha type. | | OPAQUE | 1 | There is no alpha or the image is opaque.| -| PREMUL | 2 | Premultiplied alpha. | -| UNPREMUL | 3 | Unpremultiplied alpha, that is, straight alpha. | +| PREMUL | 2 | Premultiplied alpha. | +| UNPREMUL | 3 | Unpremultiplied alpha, that is, straight alpha. | ## ScaleMode9+ @@ -2236,7 +2271,7 @@ Defines the option for image packing. | Name | Type | Readable| Writable| Description | | ------- | ------ | ---- | ---- | --------------------------------------------------- | -| format | string | Yes | Yes | Format of the packed image.
Currently, the following raw formats are supported: .jpg, .png, .gif, .bmp, and .webp. | +| format | string | Yes | Yes | Format of the packed image.
Currently, the JPEG and WebP formats are supported. | | quality | number | Yes | Yes | Quality of the output image during JPEG encoding. The value ranges from 1 to 100.| ## GetImagePropertyOptions7+ diff --git a/en/application-dev/reference/apis/js-apis-lightweightmap.md b/en/application-dev/reference/apis/js-apis-lightweightmap.md index 5ac480761ba58f22e2f120aeaa0aca58faed366d..4ff765d9cf8cefcbd3682d7cd9dbd216400d21cb 100644 --- a/en/application-dev/reference/apis/js-apis-lightweightmap.md +++ b/en/application-dev/reference/apis/js-apis-lightweightmap.md @@ -12,6 +12,10 @@ Compared with **[HashMap](js-apis-hashmap.md)**, which can also store KV pairs, **Recommended use case**: Use LightWeightMap when you need to store and access **KV pairs**. +This topic uses the following to identify the use of generics: +- K: Key +- V: Value + ## Modules to Import ```ts @@ -92,10 +96,10 @@ Checks whether this container contains all elements of the specified **LightWeig ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); let map = new LightWeightMap(); -map.set("sdfs", 356); +map.set("sparrow", 356); let result = lightWeightMap.hasAll(map); ``` @@ -125,9 +129,9 @@ Checks whether this container contains the specified key. ```ts let lightWeightMap = new LightWeightMap(); let result = lightWeightMap.hasKey; -lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -let result1 = lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightMap.hasKey("squirrel"); +lightWeightMap.set("squirrel", 123); +let result1 = lightWeightMap.hasKey("squirrel"); ``` @@ -156,7 +160,7 @@ Checks whether this container contains the specified value. ```ts let lightWeightMap = new LightWeightMap(); let result = lightWeightMap.hasValue(123); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +lightWeightMap.set("squirrel", 123); let result1 = lightWeightMap.hasValue(123); ``` @@ -207,9 +211,9 @@ Obtains the value of the specified key in this container. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); -let result = lightWeightMap.get("sdfs"); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); +let result = lightWeightMap.get("sparrow"); ``` @@ -237,9 +241,9 @@ Obtains the index of the first occurrence of an element with the specified key i ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); -let result = lightWeightMap.getIndexOfKey("sdfs"); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); +let result = lightWeightMap.getIndexOfKey("sparrow"); ``` @@ -267,8 +271,8 @@ Obtains the index of the first occurrence of an element with the specified value ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); let result = lightWeightMap.getIndexOfValue(123); ``` @@ -297,8 +301,8 @@ Obtains the key of an element at the specified position in this container. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); let result = lightWeightMap.getKeyAt(1); ``` @@ -321,8 +325,8 @@ Adds all elements in a **LightWeightMap** instance to this container. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); let map = new LightWeightMap(); lightWeightMap.setAll(map); ``` @@ -352,7 +356,7 @@ Adds an element to this container. ```ts let lightWeightMap = new LightWeightMap(); -let result = lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +let result = lightWeightMap.set("squirrel", 123); ``` @@ -380,9 +384,9 @@ Removes an element with the specified key from this container. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); -lightWeightMap.remove("sdfs"); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); +lightWeightMap.remove("sparrow"); ``` @@ -410,8 +414,8 @@ Removes an element at the specified position from this container. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); let result = lightWeightMap.removeAt(1); ``` @@ -441,8 +445,8 @@ Sets a value for an element at the specified position in this container. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); lightWeightMap.setValueAt(1, 3546); ``` @@ -471,8 +475,8 @@ Obtains the value of an element at the specified position in this container. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); let result = lightWeightMap.getValueAt(1); ``` @@ -489,8 +493,8 @@ Clears this container and sets its length to **0**. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); lightWeightMap.clear(); ``` @@ -513,8 +517,8 @@ Obtains an iterator that contains all the keys in this container. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.keys(); let temp = iter.next().value; while(temp != undefined) { @@ -542,8 +546,8 @@ Obtains an iterator that contains all the values in this container. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.values(); let temp = iter.next().value; while(temp != undefined) { @@ -579,8 +583,8 @@ callbackfn ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("sdfs", 123); -lightWeightMap.set("dfsghsf", 357); +lightWeightMap.set("sparrow", 123); +lightWeightMap.set("gull", 357); lightWeightMap.forEach((value, key) => { console.log("value:" + value, key); }); @@ -605,8 +609,8 @@ Obtains an iterator that contains all the elements in this container. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.entries(); let temp = iter.next().value; while(temp != undefined) { @@ -634,8 +638,8 @@ Concatenates the elements in this container into a string and returns the string ```ts let lightWeightMap = new LightWeightMap(); - lightWeightMap.set("A", 123); - lightWeightMap.set("sdfs", 356); + lightWeightMap.set("squirrel", 123); + lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.toString(); ``` @@ -657,8 +661,8 @@ Obtains an iterator, each item of which is a JavaScript object. ```ts let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.set("sdfs", 356); +lightWeightMap.set("squirrel", 123); +lightWeightMap.set("sparrow", 356); // Method 1: for (let item of lightWeightMap) { diff --git a/en/application-dev/reference/apis/js-apis-lightweightset.md b/en/application-dev/reference/apis/js-apis-lightweightset.md index 4a900d9f5476216ae7e98a0df9d762119753ad36..d64a40d1b65854d3f97ba399c6426b94b9c71bf0 100644 --- a/en/application-dev/reference/apis/js-apis-lightweightset.md +++ b/en/application-dev/reference/apis/js-apis-lightweightset.md @@ -14,6 +14,9 @@ Compared with **[HashSet](js-apis-hashset.md)**, which can also store values, ** **Recommended use case**: Use **LightWeightSet** when you need a set that has only unique elements or need to deduplicate a set. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -93,7 +96,7 @@ Adds an element to this container. ```ts let lightWeightSet = new LightWeightSet(); -let result = lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = lightWeightSet.add("squirrel"); ``` @@ -115,10 +118,10 @@ Adds all elements in a **LightWeightSet** instance to this container. ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); let set = new LightWeightSet(); -set.add("sfage"); +set.add("gull"); let result = lightWeightSet.addAll(set); ``` @@ -147,10 +150,10 @@ Checks whether this container contains all elements of the specified **LightWeig ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); let set = new LightWeightSet(); -set.add("sdfs"); +set.add("sparrow"); let result = lightWeightSet.hasAll(set); ``` @@ -209,9 +212,9 @@ Checks whether this container contains objects of the same type as the specified ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); -let obj = ["Ahfbrgrbgnutfodgorrogorgrogofdfdf", "sdfs"]; +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); +let obj = ["squirrel", "sparrow"]; let result = lightWeightSet.equal(obj); ``` @@ -262,9 +265,9 @@ Obtains the position index of the element with the specified key in this contain ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); -let result = lightWeightSet.getIndexOf("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); +let result = lightWeightSet.getIndexOf("sparrow"); ``` @@ -292,9 +295,9 @@ Removes an element of the specified key from this container. ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); -let result = lightWeightSet.remove("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); +let result = lightWeightSet.remove("sparrow"); ``` @@ -322,8 +325,8 @@ Removes the element at the specified position from this container. ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); let result = lightWeightSet.removeAt(1); ``` @@ -352,8 +355,8 @@ Obtains the value of the element at the specified position in this container. ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); let result = lightWeightSet.getValueAt(1); ``` @@ -370,8 +373,8 @@ Clears this container and sets its length to **0**. ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); lightWeightSet.clear(); ``` @@ -394,8 +397,8 @@ Obtains a string that contains all elements in this container. ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); let result = lightWeightSet.toString(); ``` @@ -418,8 +421,8 @@ Obtains an array that contains all objects in this container. ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); let result = lightWeightSet.toArray(); ``` @@ -442,8 +445,8 @@ Obtains an iterator that contains all the values in this container. ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); let iter = lightWeightSet.values(); let index = 0; while(index < lightWeightSet.length) { @@ -479,8 +482,8 @@ callbackfn ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("sdfs"); -lightWeightSet.add("dfsghsf"); +lightWeightSet.add("sparrow"); +lightWeightSet.add("gull"); lightWeightSet.forEach((value, key) => { console.log("value:" + value, key); }); @@ -505,8 +508,8 @@ Obtains an iterator that contains all the elements in this container. ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); let iter = lightWeightSet.entries(); let index = 0; while(index < lightWeightSet.length) { @@ -534,8 +537,8 @@ Obtains an iterator, each item of which is a JavaScript object. ```ts let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -lightWeightSet.add("sdfs"); +lightWeightSet.add("squirrel"); +lightWeightSet.add("sparrow"); // Method 1: for (let item of lightWeightSet) { diff --git a/en/application-dev/reference/apis/js-apis-linkedlist.md b/en/application-dev/reference/apis/js-apis-linkedlist.md index 73737f14b6078445e1f67762ca43a86a22804dbe..3265367a954c1ce027591bc056827717e889339b 100644 --- a/en/application-dev/reference/apis/js-apis-linkedlist.md +++ b/en/application-dev/reference/apis/js-apis-linkedlist.md @@ -12,6 +12,9 @@ Unlike **[List](js-apis-list.md)**, which is a singly linked list, **LinkedList* **Recommended use case**: Use **LinkedList** for frequent insertion and removal operations. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -76,7 +79,7 @@ let result = linkedList.add("a"); let result1 = linkedList.add(1); let b = [1, 2, 3]; linkedList.add(b); -let c = {name : "lala", age : "13"}; +let c = {name : "Dylon", age : "13"}; let result3 = linkedList.add(false); ``` @@ -102,7 +105,7 @@ linkedList.addFirst("a"); linkedList.addFirst(1); let b = [1, 2, 3]; linkedList.addFirst(b); -let c = {name : "lala", age : "13"}; +let c = {name : "Dylon", age : "13"}; linkedList.addFirst(false); ``` @@ -154,9 +157,9 @@ Checks whether this container has the specified element. ```ts let linkedList = new LinkedList(); -let result1 = linkedList.has("Ahfbrgrbgnutfodgorrogorg"); -linkedList.add("Ahfbrgrbgnutfodgorrogorg"); -let result = linkedList.has("Ahfbrgrbgnutfodgorrogorg"); +let result1 = linkedList.has("squirrel"); +linkedList.add("squirrel"); +let result = linkedList.has("squirrel"); ``` ### get diff --git a/en/application-dev/reference/apis/js-apis-list.md b/en/application-dev/reference/apis/js-apis-list.md index 0b839a5a0baae3fa58e4592485c3b9e959183530..4534668591a447df0a1f36d4f8ca3866a3e31692 100644 --- a/en/application-dev/reference/apis/js-apis-list.md +++ b/en/application-dev/reference/apis/js-apis-list.md @@ -10,6 +10,9 @@ Unlike [LinkedList](js-apis-linkedlist.md), which is a doubly linked list, **Lis **Recommended use case**: Use **List** for frequent insertion and removal operations. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -72,7 +75,7 @@ let result = list.add("a"); let result1 = list.add(1); let b = [1, 2, 3]; list.add(b); -let c = {name : "lala", age : "13"}; +let c = {name : "Dylon", age : "13"}; let result3 = list.add(false); ``` @@ -124,9 +127,9 @@ Checks whether this container has the specified element. ```ts let list = new List(); -let result = list.has("Ahfbrgrbgnutfodgorrogorg"); -list.add("Ahfbrgrbgnutfodgorrogorg"); -let result1 = list.has("Ahfbrgrbgnutfodgorrogorg"); +let result = list.has("squirrel"); +list.add("squirrel"); +let result1 = list.has("squirrel"); ``` ### get @@ -181,7 +184,7 @@ Obtains the index of the last occurrence of the specified element in this contai | Value Type | Description| | -------- | -------- | -| number | Returns the position index if obtained; returns **-1** otherwise.| +| number | Returns the index if obtained; returns **-1** otherwise.| **Example** @@ -265,7 +268,7 @@ obj1.add(2); obj1.add(4); obj1.add(5); list.equal(obj1); -let obj2 = {name : "lala", age : "13"}; +let obj2 = {name : "Dylon", age : "13"}; let result = list.equal(obj2); ``` diff --git a/en/application-dev/reference/apis/js-apis-media.md b/en/application-dev/reference/apis/js-apis-media.md index 96b190f1f7f9166c68ef1fda64bb9a98bf6b269d..fca68b5554d6239a03415892d68570dc1b4e8574 100644 --- a/en/application-dev/reference/apis/js-apis-media.md +++ b/en/application-dev/reference/apis/js-apis-media.md @@ -53,7 +53,7 @@ Creates a **VideoPlayer** instance. This API uses an asynchronous callback to re | Name | Type | Mandatory| Description | | -------- | ------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | Yes | Callback used to return the **VideoPlayer** instance created.| +| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | Yes | Callback used to return the **VideoPlayer** instance, which can be used to manage and play video media.| **Example** @@ -82,7 +82,7 @@ Creates a **VideoPlayer** instance. This API uses a promise to return the result | Type | Description | | ------------------------------------- | ----------------------------------- | -| Promise<[VideoPlayer](#videoplayer8)> | Promise used to return the **VideoPlayer** instance created.| +| Promise<[VideoPlayer](#videoplayer8)> | Promise used to return the **VideoPlayer** instance, which can be used to manage and play video media.| **Example** @@ -135,7 +135,7 @@ Only one **AudioRecorder** instance can be created per device. | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the **VideoRecorder** instance created.| +| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the **VideoRecorder** instance, which can be used to record video media.| **Example** @@ -165,7 +165,7 @@ Only one **AudioRecorder** instance can be created per device. | Type | Description | | ----------------------------------------- | ----------------------------------- | -| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the **VideoRecorder** instance created.| +| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the **VideoRecorder** instance, which can be used to record video media.| **Example** @@ -275,15 +275,15 @@ For details about the audio playback demo, see [Audio Playback Development](../. **System capability**: SystemCapability.Multimedia.Media.AudioPlayer -| Name | Type | Readable| Writable| Description | -| ------------------------------- | ----------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| src | string | Yes | Yes | Audio file URI. The mainstream audio formats (M4A, AAC, MPEG-3, OGG, and WAV) are supported.
**Examples of supported URI schemes**:
1. FD: fd://xx
![](figures/en-us_image_url.png)
2. HTTP: http://xx
3. HTTPS: https://xx
4. HLS: http://xx or https://xx
**Required permissions**: ohos.permission.INTERNET| -| fdSrc9+ | [AVFileDescriptor](#avfiledescriptor9) | Yes | Yes | Description of the audio file. This attribute is required when audio resources of an application are continuously stored in a file.
**Example:**
Assume that a music file that stores continuous music resources consists of the following:
Music 1 (address offset: 0, byte length: 100)
Music 2 (address offset: 101; byte length: 50)
Music 3 (address offset: 151, byte length: 150)
1. To play music 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }
2. To play music 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }
3. To play music 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }
If the file is an independent music file, use **src=fd://xx**.
| -| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. | -| audioInterruptMode9+ | [audio.InterruptMode](js-apis-audio.md#interruptmode9) | Yes | Yes | Audio interruption mode. | -| currentTime | number | Yes | No | Current audio playback position, in ms. | -| duration | number | Yes | No | Audio duration, in ms. | -| state | [AudioState](#audiostate) | Yes | No | Audio playback state. This state cannot be used as the condition for triggering the call of **play()**, **pause()**, or **stop()**.| +| Name | Type | Readable| Writable| Description | +| ------------------------------- | ------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | +| src | string | Yes | Yes | Audio file URI. The mainstream audio formats (M4A, AAC, MPEG-3, OGG, and WAV) are supported.
**Examples of supported URI schemes**:
1. FD: fd://xx
![](figures/en-us_image_url.png)
2. HTTP: http://xx
3. HTTPS: https://xx
4. HLS: http://xx or https://xx
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.INTERNET| +| fdSrc9+ | [AVFileDescriptor](#avfiledescriptor9) | Yes | Yes | Description of the audio file. This attribute is required when audio resources of an application are continuously stored in a file.
**Example:**
Assume that a music file that stores continuous music resources consists of the following:
Music 1 (address offset: 0, byte length: 100)
Music 2 (address offset: 101; byte length: 50)
Music 3 (address offset: 151, byte length: 150)
1. To play music 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }
2. To play music 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }
3. To play music 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }
If the file is an independent music file, use **src=fd://xx**.
| +| loop | boolean | Yes | Yes | Whether to loop audio playback. The value **true** means to loop audio playback, and **false** means the opposite. | +| audioInterruptMode9+ | [audio.InterruptMode](js-apis-audio.md#interruptmode9) | Yes | Yes | Audio interruption mode. | +| currentTime | number | Yes | No | Current audio playback position, in ms. | +| duration | number | Yes | No | Audio duration, in ms. | +| state | [AudioState](#audiostate) | Yes | No | Audio playback state. This state cannot be used as the condition for triggering the call of **play()**, **pause()**, or **stop()**.| ### play play(): void @@ -442,7 +442,7 @@ function printfDescription(obj) { } } -audioPlayer.getTrackDescription((error, ) => { +audioPlayer.getTrackDescription((error, arrlist) => { if (arrlist != null) { for (let i = 0; i < arrlist.length; i++) { printfDescription(arrlist[i]); @@ -680,7 +680,7 @@ For details about the video playback demo, see [Video Playback Development](../. | Name | Type | Readable| Writable| Description | | ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| url8+ | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.
**Example of supported URIs**:
1. FD: fd://xx
![](figures/en-us_image_url.png)
2. HTTP: http://xx
3. HTTPS: https://xx
4. HLS: http://xx or https://xx
**Required permissions**: ohos.permission.INTERNET| +| url8+ | string | Yes | Yes | Video media URL. The mainstream video formats (MPEG-4, MPEG-TS, WebM, and MKV) are supported.
**Example of supported URIs**:
1. FD: fd://xx
![](figures/en-us_image_url.png)
2. HTTP: http://xx
3. HTTPS: https://xx
4. HLS: http://xx or https://xx
| | fdSrc9+ | [AVFileDescriptor](#avfiledescriptor9) | Yes| Yes| Description of a video file. This attribute is required when video resources of an application are continuously stored in a file.
**Example:**
Assume that a music file that stores continuous music resources consists of the following:
Video 1 (address offset: 0, byte length: 100)
Video 2 (address offset: 101; byte length: 50)
Video 3 (address offset: 151, byte length: 150)
1. To play video 1: AVFileDescriptor {fd = resource handle; offset = 0; length = 100; }
2. To play video 2: AVFileDescriptor {fd = resource handle; offset = 101; length = 50; }
3. To play video 3: AVFileDescriptor {fd = resource handle; offset = 151; length = 150; }
To play an independent video file, use **src=fd://xx**.
| | loop8+ | boolean | Yes | Yes | Whether to loop video playback. The value **true** means to loop video playback, and **false** means the opposite. | | videoScaleType9+ | [VideoScaleType](#videoscaletype9) | Yes | Yes | Video scale type. | @@ -1795,7 +1795,7 @@ Subscribes to the audio recording events. ```js let audioRecorder = media.createAudioRecorder(); // Create an AudioRecorder instance. let audioRecorderConfig = { - audioEncoder : media.AudioEncoder.AAC_LC, , + audioEncoder : media.AudioEncoder.AAC_LC, audioEncodeBitRate : 22050, audioSampleRate : 22050, numberOfChannels : 2, @@ -1850,7 +1850,7 @@ Subscribes to audio recording error events. After an error event is reported, yo ```js let audioRecorderConfig = { - audioEncoder : media.AudioEncoder.AAC_LC, , + audioEncoder : media.AudioEncoder.AAC_LC, audioEncodeBitRate : 22050, audioSampleRate : 22050, numberOfChannels : 2, @@ -1974,29 +1974,13 @@ let videoConfig = { } // asyncallback -let videoRecorder = null; -let events = require('events'); -let eventEmitter = new events.EventEmitter(); - -eventEmitter.on('prepare', () => { - videoRecorder.prepare(videoConfig, (err) => { - if (err == null) { - console.info('prepare success'); - } else { - console.info('prepare failed and error is ' + err.message); - } - }); -}); - -media.createVideoRecorder((err, recorder) => { - if (err == null && recorder != null) { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - eventEmitter.emit('prepare'); // Trigger the 'prepare' event. +videoRecorder.prepare(videoConfig, (err) => { + if (err == null) { + console.info('prepare success'); } else { - console.info('createVideoRecorder failed and error is ' + err.message); + console.info('prepare failed and error is ' + err.message); } -}); +}) ``` ### prepare9+ @@ -2047,21 +2031,10 @@ let videoConfig = { } // promise -let videoRecorder = null; -media.createVideoRecorder().then((recorder) => { - if (recorder != null) { - videoRecorder = recorder; - console.info('createVideoRecorder success'); - videoRecorder.prepare(videoConfig).then(() => { - console.info('prepare success'); - }).catch((err) => { - console.info('prepare failed and catch error is ' + err.message); - }); - } else { - console.info('createVideoRecorder failed'); - } +videoRecorder.prepare(videoConfig).then(() => { + console.info('prepare success'); }).catch((err) => { - console.info('catch err error message is ' + err.message); + console.info('prepare failed and catch error is ' + err.message); }); ``` @@ -2475,11 +2448,10 @@ Subscribes to video recording error events. After an error event is reported, yo **Example** ```js +// This event is reported when an error occurs during the retrieval of videoRecordState. videoRecorder.on('error', (error) => { // Set the 'error' event callback. console.info(`audio error called, error: ${error}`); -} -// This event is reported when an error occurs during the retrieval of videoRecordState. -}); +}) ``` ## VideoRecordState9+ diff --git a/en/application-dev/reference/apis/js-apis-medialibrary.md b/en/application-dev/reference/apis/js-apis-medialibrary.md index e805a8d3172b2ec12f05a4fe39034be08d249905..2887044269488b47e2a4f434447b43d617a16f05 100644 --- a/en/application-dev/reference/apis/js-apis-medialibrary.md +++ b/en/application-dev/reference/apis/js-apis-medialibrary.md @@ -2,10 +2,10 @@ > **NOTE** > -> This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version. +> The APIs of this module are supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version. ## Modules to Import -``` +```js import mediaLibrary from '@ohos.multimedia.mediaLibrary'; ``` @@ -33,17 +33,18 @@ This API can be used only in the stage model. **Example (from API version 9)** -``` -var media = mediaLibrary.getMediaLibrary(this.context); +```ts +const context = getContext(this); +let media = mediaLibrary.getMediaLibrary(context); ``` **Example (API version 8)** -``` +```js import featureAbility from '@ohos.ability.featureAbility'; -var context = featureAbility.getContext() -var media = mediaLibrary.getMediaLibrary(context); +let context = featureAbility.getContext(); +let media = mediaLibrary.getMediaLibrary(context); ``` ## mediaLibrary.getMediaLibrary @@ -68,7 +69,7 @@ This API can be used only in the FA model. **Example** ```js -var media = mediaLibrary.getMediaLibrary(); +let media = mediaLibrary.getMediaLibrary(); ``` ## MediaLibrary @@ -93,24 +94,45 @@ Obtains file assets (also called files). This API uses an asynchronous callback **Example** -``` -let fileKeyObj = mediaLibrary.FileKey -let imageType = mediaLibrary.MediaType.IMAGE -let imagesfetchOp = { +```js +let fileKeyObj = mediaLibrary.FileKey; +let imageType = mediaLibrary.MediaType.IMAGE; +let imagesFetchOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', selectionArgs: [imageType.toString()], }; -media.getFileAssets(imagesfetchOp, (error, fetchFileResult) => { - if (fetchFileResult != undefined) { - console.info('mediaLibraryTest : ASSET_CALLBACK fetchFileResult success'); - fetchFileResult.getAllObject((err, fileAssetList) => { - if (fileAssetList != undefined) { - fileAssetList.forEach(function(getAllObjectInfo){ - console.info("getAllObjectInfo.displayName :" + getAllObjectInfo.displayName); - }); - } - }); +media.getFileAssets(imagesFetchOp, (error, fetchFileResult) => { + if (fetchFileResult == undefined) { + console.error('Failed to get fetchFileResult: ' + error); + return; } + const count = fetchFileResult.getCount(); + if (count < 0) { + console.error('Failed to get count from fetchFileResult: count: ' + count); + return; + } + if (count == 0) { + console.info('The count of fetchFileResult is zero'); + return; + } + + console.info('Get fetchFileResult success, count: ' + count); + fetchFileResult.getFirstObject((err, fileAsset) => { + if (fileAsset == undefined) { + console.error('Failed to get first object: ' + err); + return; + } + console.log('fileAsset.displayName ' + ': ' + fileAsset.displayName); + for (let i = 1; i < count; i++) { + fetchFileResult.getNextObject((err, fileAsset) => { + if (fileAsset == undefined) { + console.error('Failed to get next object: ' + err); + return; + } + console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); + }) + } + }); }); ``` ### getFileAssets7+ @@ -137,17 +159,38 @@ Obtains file assets. This API uses a promise to return the result. **Example** -``` -let fileKeyObj = mediaLibrary.FileKey -let imageType = mediaLibrary.MediaType.IMAGE -let imagesfetchOp = { +```js +let fileKeyObj = mediaLibrary.FileKey; +let imageType = mediaLibrary.MediaType.IMAGE; +let imagesFetchOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', selectionArgs: [imageType.toString()], }; -media.getFileAssets(imagesfetchOp).then(function(fetchFileResult){ - console.info("getFileAssets successfully: image number is "+ fetchFileResult.getCount()); +media.getFileAssets(imagesFetchOp).then(function(fetchFileResult) { + const count = fetchFileResult.getCount(); + if (count < 0) { + console.error('Failed to get count from fetchFileResult: count: ' + count); + return; + } + if (count == 0) { + console.info('The count of fetchFileResult is zero'); + return; + } + console.info('Get fetchFileResult success, count: ' + count); + fetchFileResult.getFirstObject().then(function(fileAsset) { + console.log('fileAsset.displayName ' + ': ' + fileAsset.displayName); + for (let i = 1; i < count; i++) { + fetchFileResult.getNextObject().then(function(fileAsset) { + console.log('fileAsset.displayName ' + ': ' + fileAsset.displayName); + }).catch(function(err) { + console.error('Failed to get next object: ' + err); + }) + } + }).catch(function(err) { + console.error('Failed to get first object: ' + err); + }); }).catch(function(err){ - console.info("getFileAssets failed with error:"+ err); + console.error("Failed to get file assets: " + err); }); ``` @@ -168,7 +211,7 @@ Subscribes to the media library changes. This API uses an asynchronous callback **Example** -``` +```js media.on('imageChange', () => { // image file had changed, do something }) @@ -190,13 +233,13 @@ Unsubscribes from the media library changes. This API uses an asynchronous callb **Example** -``` +```js media.off('imageChange', () => { // stop listening success }) ``` -### createAsset 8+ +### createAsset8+ createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback<FileAsset>): void @@ -217,7 +260,7 @@ Creates a media asset. This API uses an asynchronous callback to return the resu **Example** -``` +```js async function example() { // Create an image file in callback mode. let mediaType = mediaLibrary.MediaType.IMAGE; @@ -259,7 +302,7 @@ Creates a media asset. This API uses a promise to return the result. **Example** -``` +```js let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; media.getPublicDirectory(DIR_CAMERA).then(function(dicResult){ console.info("getPublicDirectory successfully:"+ JSON.stringify(dicResult)); @@ -268,6 +311,101 @@ media.getPublicDirectory(DIR_CAMERA).then(function(dicResult){ }); ``` +### deleteAsset8+ + +deleteAsset(uri: string): Promise\ + +Deletes a file asset. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------- | ---- | --------------- | +| uri | string | Yes | URI of the file asset to delete.| + +**Return value** +| Type | Description | +| ------------------- | -------------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + +```js +async function example() { + let fileKeyObj = mediaLibrary.FileKey; + let fileType = mediaLibrary.MediaType.FILE; + let option = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + }; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const fetchFileResult = await media.getFileAssets(option); + let asset = await fetchFileResult.getFirstObject(); + if (asset == undefined) { + console.error('asset not exist') + return + } + media.deleteAsset(asset.uri).then(() => { + console.info("deleteAsset successfully"); + }).catch((err) => { + console.info("deleteAsset failed with error:"+ err); + }); +} +``` + +### deleteAsset8+ +deleteAsset(uri: string, callback: AsyncCallback\): void + +Deletes a file asset. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------- | ---- | --------------- | +| uri | string | Yes | URI of the file asset to delete.| +|callback |AsyncCallback\| Yes |Callback used to return the result.| + +**Example** + +```js +async function example() { + let fileKeyObj = mediaLibrary.FileKey; + let fileType = mediaLibrary.MediaType.FILE; + let option = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + }; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const fetchFileResult = await media.getFileAssets(option); + let asset = await fetchFileResult.getFirstObject(); + if (asset == undefined) { + console.error('asset not exist') + return + } + media.deleteAsset(asset.uri, (err) => { + if (err != undefined) { + console.info("deleteAsset successfully"); + } else { + console.info("deleteAsset failed with error:"+ err); + } + }); +} +``` + ### getPublicDirectory8+ getPublicDirectory(type: DirectoryType, callback: AsyncCallback<string>): void @@ -285,7 +423,7 @@ Obtains a public directory. This API uses an asynchronous callback to return the **Example** -``` +```js let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; media.getPublicDirectory(DIR_CAMERA, (err, dicResult) => { if (dicResult == 'Camera/') { @@ -318,7 +456,7 @@ Obtains a public directory. This API uses a promise to return the result. **Example** -``` +```js async function example() { let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; const dicResult = await media.getPublicDirectory(DIR_CAMERA); @@ -349,7 +487,7 @@ Obtains the albums. This API uses an asynchronous callback to return the result. **Example** -``` +```js let AlbumNoArgsfetchOp = { selections: '', selectionArgs: [], @@ -389,7 +527,7 @@ Obtains the albums. This API uses a promise to return the result. **Example** -``` +```js let AlbumNoArgsfetchOp = { selections: '', selectionArgs: [], @@ -418,7 +556,7 @@ Call this API when you no longer need to use the APIs in the **MediaLibrary** in **Example** -``` +```js var media = mediaLibrary.getMediaLibrary(context); media.release((err) => { // do something @@ -442,7 +580,7 @@ Call this API when you no longer need to use the APIs in the **MediaLibrary** in **Example** -``` +```js media.release() ``` @@ -467,7 +605,7 @@ Stores a media asset. This API uses an asynchronous callback to return the URI t **Example** - ``` +```js let option = { src : "/data/storage/el2/base/haps/entry/image.png", mimeType : "image/*", @@ -481,7 +619,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option, (err, value) => { console.log("Media asset stored."); // Obtain the URI that stores the media asset. }); - ``` +``` ### storeMediaAsset(deprecated) @@ -510,7 +648,7 @@ Stores a media asset. This API uses a promise to return the URI that stores the **Example** - ``` +```js let option = { src : "/data/storage/el2/base/haps/entry/image.png", mimeType : "image/*", @@ -522,7 +660,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option).then((value) => { }).catch((err) => { console.log("An error occurred when storing the media assets."); }); - ``` +``` ### startImagePreview(deprecated) @@ -547,7 +685,7 @@ Starts image preview, with the first image to preview specified. This API can be **Example** - ``` +```js let images = [ "dataability:///media/xxxx/2", "dataability:///media/xxxx/3" @@ -566,7 +704,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index, (err) => { } console.log("Succeeded in previewing the images."); }); - ``` +``` ### startImagePreview(deprecated) @@ -590,7 +728,7 @@ Starts image preview. This API can be used to preview local images whose URIs st **Example** - ``` +```js let images = [ "dataability:///media/xxxx/2", "dataability:///media/xxxx/3" @@ -608,7 +746,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, (err) => { } console.log("Succeeded in previewing the images."); }); - ``` +``` ### startImagePreview(deprecated) @@ -638,7 +776,7 @@ Starts image preview, with the first image to preview specified. This API can be **Example** - ``` +```js let images = [ "dataability:///media/xxxx/2", "dataability:///media/xxxx/3" @@ -655,7 +793,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index).then(() => { }).catch((err) => { console.log("An error occurred when previewing the images."); }); - ``` +``` ### startMediaSelect(deprecated) @@ -674,13 +812,13 @@ Starts media selection. This API uses an asynchronous callback to return the lis | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------------ | -| option | [MediaSelectOption](#mediaselectoption) | Yes | Media selection option. | +| option | [MediaSelectOption](#mediaselectoptiondeprecated) | 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 = { +```js +let option : mediaLibrary.MediaSelectOption = { type : "media", count : 2 }; @@ -692,7 +830,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option, (err, value) => { console.log("Media asset selected."); // Obtain the media selection value. }); - ``` +``` ### startMediaSelect(deprecated) @@ -711,7 +849,7 @@ Starts media selection. This API uses a promise to return the list of URIs that | Name | Type | Mandatory | Description | | ------ | --------------------------------------- | ---- | ------- | -| option | [MediaSelectOption](#mediaselectoption) | Yes | Media selection option.| +| option | [MediaSelectOption](#mediaselectoptiondeprecated) | Yes | Media selection option.| **Return value** @@ -721,8 +859,8 @@ Starts media selection. This API uses a promise to return the list of URIs that **Example** - ``` -let option = { +```js +let option : mediaLibrary.MediaSelectOption = { type : "media", count : 2 }; @@ -733,7 +871,155 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => { console.log("An error occurred when selecting the media assets."); }); - ``` +``` +### getActivePeers8+ + +getActivePeers(): Promise\>; + +Obtains information about online peer devices. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.DistributedCore + +**Return value** + +| Type | Description | +| ------------------- | -------------------- | +| Promise\> | Promise used to return the online peer devices, in an array of **PeerInfo** objects.| + +**Example** + +```js +async function example() { + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + media.getActivePeers().then((devicesInfo) => { + if (devicesInfo != undefined) { + for (let i = 0; i < devicesInfo.length; i++) { + console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId); + } + } else { + console.info('get distributed info is undefined!') + } + }).catch((err) => { + console.info("get distributed info failed with error:" + err); + }); +} +``` + +### getActivePeers8+ + +getActivePeers(callback: AsyncCallback\>): void; + +Obtains information about online peer devices. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.DistributedCore + +**Return value** + +| Type | Description | +| ------------------- | -------------------- | +| callback: AsyncCallback\> | Promise used to return the online peer devices, in an array of **PeerInfo** objects.| + +**Example** + +```js +async function example() { + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + media.getActivePeers((err, devicesInfo) => { + if (devicesInfo != undefined) { + for (let i = 0; i < devicesInfo.length; i++) { + console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId); + } + } else { + console.info('get distributed fail, message = ' + err) + } + }) +} +``` + + +### getAllPeers8+ + +getAllPeers(): Promise\>; + +Obtains information about all peer devices. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.DistributedCore + +**Return value** + +| Type | Description | +| ------------------- | -------------------- | +| Promise\> | Promise used to return all peer devices, in an array of **PeerInfo** objects.| + +**Example** + +```js +async function example() { + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + media.getAllPeers().then((devicesInfo) => { + if (devicesInfo != undefined) { + for (let i = 0; i < devicesInfo.length; i++) { + console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId); + } + } else { + console.info('get distributed info is undefined!') + } + }).catch((err) => { + console.info("get distributed info failed with error:" + err); + }); +} +``` + +### getAllPeers8+ + +getAllPeers(callback: AsyncCallback\>): void; + +Obtains information about online peer devices. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_MEDIA + +**System capability**: SystemCapability.Multimedia.MediaLibrary.DistributedCore + +**Return value** + +| Type | Description | +| ------------------- | -------------------- | +| callback: AsyncCallback\> | Promise used to return all peer devices, in an array of **PeerInfo** objects.| + +**Example** + +```js +async function example() { + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + media.getAllPeers((err, devicesInfo) => { + if (devicesInfo != undefined) { + for (let i = 0; i < devicesInfo.length; i++) { + console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId); + } + } else { + console.info('get distributed fail, message = ' + err) + } + }) +} +``` ## FileAsset7+ @@ -786,7 +1072,7 @@ Checks whether this file asset is a directory. This API uses an asynchronous cal **Example** -``` +```js async function example() { let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; @@ -822,7 +1108,7 @@ Checks whether this file asset is a directory. This API uses a promise to return **Example** -``` +```js async function example() { let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; @@ -860,7 +1146,7 @@ Commits the modification in this file asset to the database. This API uses an as **Example** -``` +```js async function example() { let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; @@ -897,7 +1183,7 @@ Commits the modification in this file asset to the database. This API uses a pro **Example** -``` +```js async function example() { let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; @@ -937,7 +1223,7 @@ Opens this file asset. This API uses an asynchronous callback to return the resu **Example** -``` +```js async function example() { let mediaType = mediaLibrary.MediaType.IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; @@ -981,7 +1267,7 @@ Opens this file asset. This API uses a promise to return the result. **Example** -``` +```js async function example() { let mediaType = mediaLibrary.MediaType.IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; @@ -1016,7 +1302,7 @@ Closes this file asset. This API uses an asynchronous callback to return the res **Example** -``` +```js async function example() { let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; @@ -1032,7 +1318,7 @@ async function example() { console.info('File fd!' + fd); asset.close(fd, (closeErr) => { if (closeErr != undefined) { - console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); + console.info('mediaLibraryTest : close : FAIL ' + closeErr); console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); } else { console.info("=======asset.close success====>"); @@ -1069,7 +1355,7 @@ Closes this file asset. This API uses a promise to return the result. **Example** -``` +```js async function example() { let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; @@ -1085,7 +1371,7 @@ async function example() { console.info('File fd!' + fd); asset.close(fd).then((closeErr) => { if (closeErr != undefined) { - console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); + console.info('mediaLibraryTest : close : FAIL ' + closeErr); console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); } else { @@ -1117,7 +1403,7 @@ Obtains the thumbnail of this file asset. This API uses an asynchronous callback **Example** -``` +```js async function example() { let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; @@ -1130,7 +1416,7 @@ async function example() { const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); asset.getThumbnail((err, pixelmap) => { - console.info('mediaLibraryTest : getThumbnail successful '+ pixelmap); + console.info('mediaLibraryTest : getThumbnail Successful '+ pixelmap); }); } ``` @@ -1154,9 +1440,9 @@ Obtains the thumbnail of this file asset, with the thumbnail size passed. This A **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1168,7 +1454,7 @@ async function example() { const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); asset.getThumbnail(size, (err, pixelmap) => { - console.info('mediaLibraryTest : getThumbnail successful '+ pixelmap); + console.info('mediaLibraryTest : getThumbnail Successful '+ pixelmap); }); } ``` @@ -1197,9 +1483,9 @@ Obtains the thumbnail of this file asset, with the thumbnail size passed. This A **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1212,7 +1498,7 @@ async function example() { const asset = await fetchFileResult.getFirstObject(); asset.getThumbnail(size) .then((pixelmap) => { - console.info('mediaLibraryTest : getThumbnail successful '+ pixelmap); + console.info('mediaLibraryTest : getThumbnail Successful '+ pixelmap); }) .catch((err) => { console.info('mediaLibraryTest : getThumbnail fail'+ err); @@ -1239,9 +1525,9 @@ Favorites or unfavorites this file asset. This API uses an asynchronous callback **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1281,9 +1567,9 @@ Favorites or unfavorites this file asset. This API uses a promise to return the **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1319,9 +1605,9 @@ Checks whether this file asset is favorited. This API uses an asynchronous callb **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1359,9 +1645,9 @@ Checks whether this file asset is favorited. This API uses a promise to return t **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1400,9 +1686,9 @@ Files in the trash are not actually deleted. You can set **isTrash** to **false* **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1445,9 +1731,9 @@ Files in the trash are not actually deleted. You can set **isTrash** to **false* **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1483,9 +1769,9 @@ Checks whether this file asset is in the trash. This API uses an asynchronous ca **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1495,18 +1781,13 @@ async function example() { }; 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, istrashCallBack); - - } else { - console.info('mediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessful = ' + err); - console.info('mediaLibraryTest : ASSET_CALLBACK isTrash : FAIL'); - - } - } + asset.isTrash((err, isTrash) => { + if (isTrash == undefined) { + console.error('Failed to get trash state: ' + err); + return; + } + console.info('Get trash state success: ' + isTrash); + }); } ``` @@ -1528,22 +1809,21 @@ Checks whether this file asset is in the trash. This API uses a promise to retur **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; 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); + console.info("isTrash result: " + isTrash); }).catch(function(err){ - console.info("isTrash failed with error:"+ err); + console.error("isTrash failed with error: " + err); }); } ``` @@ -1568,9 +1848,9 @@ Obtains the total number of files in the result set. **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let fileType = mediaLibrary.MediaType.FILE; let getFileCountOneOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1599,9 +1879,9 @@ Checks whether the cursor is in the last row of the result set. **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1637,9 +1917,9 @@ Releases and invalidates this **FetchFileResult** instance. Other APIs in this i **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1668,9 +1948,9 @@ Obtains the first file asset in the result set. This API uses an asynchronous ca **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1705,9 +1985,9 @@ Obtains the first file asset in the result set. This API uses a promise to retur **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1740,9 +2020,9 @@ Obtains the next file asset in the result set. This API uses an asynchronous cal **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1777,9 +2057,9 @@ Obtains the next file asset in the result set. This API uses a promise to return **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1810,9 +2090,9 @@ Obtains the last file asset in the result set. This API uses an asynchronous cal **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1847,9 +2127,9 @@ Obtains the last file asset in the result set. This API uses a promise to return **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1879,9 +2159,9 @@ Obtains a file asset with the specified index in the result set. This API uses a **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1922,9 +2202,9 @@ Obtains a file asset with the specified index in the result set. This API uses a **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1934,9 +2214,9 @@ async function example() { }; let fetchFileResult = await media.getFileAssets(getImageOp); fetchFileResult.getPositionObject(1) .then(function (fileAsset){ - console.log('[Demo] fileAsset.displayName : ' + fileAsset.displayName); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }).catch(function (err) { - console.info("[Demo] getFileAssets failed with error:" + err); + console.info("getFileAssets failed with error:" + err); }); } ``` @@ -1957,9 +2237,9 @@ Obtains all the file assets in the result set. This API uses an asynchronous cal **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1969,11 +2249,13 @@ async function example() { }; let fetchFileResult = await media.getFileAssets(getImageOp); fetchFileResult.getAllObject((err, fileAsset) => { - if (err) { + if (err) { console.error('Failed '); return; - } - console.log('fileAsset.displayName : ' + fileAsset.displayName); + } + for (let i = 0; i < fetchFileResult.getCount(); i++) { + console.log('fileAsset.displayName : ' + fileAsset[i].displayName); + } }) } ``` @@ -1994,9 +2276,9 @@ Obtains all the file assets in the result set. This API uses a promise to return **Example** -``` +```js async function example() { - let fileKeyObj = mediaLibrary.FileKey + let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -2045,7 +2327,7 @@ Commits the modification in the album attributes to the database. This API uses **Example** -``` +```js async function example() { let AlbumNoArgsfetchOp = { selections: '', @@ -2082,7 +2364,7 @@ Commits the modification in the album attributes to the database. This API uses **Example** -``` +```js async function example() { let AlbumNoArgsfetchOp = { selections: '', @@ -2118,7 +2400,7 @@ Obtains the file assets in this album. This API uses an asynchronous callback to **Example** -``` +```js async function example() { let AlbumNoArgsfetchOp = { selections: '', @@ -2161,7 +2443,7 @@ Obtains the file assets in this album. This API uses a promise to return the res **Example** -``` +```js async function example() { let AlbumNoArgsfetchOp = { selections: '', @@ -2170,7 +2452,7 @@ async function example() { let fileNoArgsfetchOp = { selections: '', selectionArgs: [], - } + }; const albumList = await media.getAlbums(AlbumNoArgsfetchOp); const album = albumList[0]; album.getFileAssets(fileNoArgsfetchOp).then(function(albumFetchFileResult){ @@ -2184,7 +2466,8 @@ async function example() { ## PeerInfo8+ Describes information about a registered device. -This is a system API. + +**System API**: This is a system API. **System capability**: SystemCapability.Multimedia.MediaLibrary.DistributedCore @@ -2256,7 +2539,8 @@ Enumerates directory types. ## DeviceType8+ Enumerates device types. -This is a system API. + +**System API**: This is a system API. **System capability**: SystemCapability.Multimedia.MediaLibrary.DistributedCore @@ -2280,7 +2564,7 @@ Describes options for fetching media files. | ----------------------- | ------------------- | ---- | ---- | ---- | ------------------------------------------------------------ | | selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:
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](#filekey8) are used as the columns for sorting the search results. Example:
Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " ASC"
Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC" | +| order | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:
Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " ASC"
Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"| | uri8+ | string | Yes | Yes | No | File URI. | | networkId8+ | string | Yes | Yes | No | Network ID of the registered device. | | extendArgs8+ | string | Yes | Yes | No | Extended parameters for fetching the files. Currently, no extended parameters are available. | @@ -2288,6 +2572,7 @@ Describes options for fetching media files. ## Size8+ Describes the image size. + **System capability**: SystemCapability.Multimedia.MediaLibrary.Core | Name | Type | Readable | Writable | Description | diff --git a/en/application-dev/reference/apis/js-apis-osAccount.md b/en/application-dev/reference/apis/js-apis-osAccount.md index a4692039779fa40b82edb8de1dab204423ac957d..8320fceaa5601703f01f8fc8f4937bcd34d3b4d5 100644 --- a/en/application-dev/reference/apis/js-apis-osAccount.md +++ b/en/application-dev/reference/apis/js-apis-osAccount.md @@ -21,13 +21,14 @@ Obtains an **AccountManager** instance. **System capability**: SystemCapability.Account.OsAccount **Return value** + | Type | Description | | --------------------------------- | ------------------------ | | [AccountManager](#accountmanager) | Obtains an **AccountManager** instance.| **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); ``` ## OsAccountType @@ -67,10 +68,10 @@ This is a system API and cannot be called by third-party applications. **Example**: Activate OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.activateOsAccount(localId, (err)=>{ - console.log("activateOsAccount err:" + JSON.stringify(err)); + console.log('activateOsAccount err:' + JSON.stringify(err)); }); ``` @@ -100,12 +101,12 @@ This is a system API and cannot be called by third-party applications. **Example**: Activate OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.activateOsAccount(localId).then(() => { - console.log("activateOsAccount success"); + console.log('activateOsAccount success'); }).catch((err) => { - console.log("activateOsAccount err:" + JSON.stringify(err)); + console.log('activateOsAccount err:' + JSON.stringify(err)); }); ``` @@ -126,9 +127,9 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable((err, isEnabled) => { - console.log("isMultiOsAccountEnable err: " + JSON.stringify(err)); + console.log('isMultiOsAccountEnable err: ' + JSON.stringify(err)); console.log('isMultiOsAccountEnable isEnabled: ' + isEnabled); }); ``` @@ -150,11 +151,11 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable().then((isEnabled) => { console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled); }).catch((err) => { - console.log("isMultiOsAccountEnable err: " + JSON.stringify(err)); + console.log('isMultiOsAccountEnable err: ' + JSON.stringify(err)); }); ``` @@ -178,11 +179,11 @@ Checks whether an OS account is activated. This API uses an asynchronous callbac **Example**: Check whether OS account 100 is activated. ```js - const accountManager = account_osAccount.getAccountManager(); - var osLocalId = 100; + let accountManager = account_osAccount.getAccountManager(); + let osLocalId = 100; accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{ - console.log("isOsAccountActived err:" + JSON.stringify(err)); - console.log("isOsAccountActived isActive:" + isActive); + console.log('isOsAccountActived err:' + JSON.stringify(err)); + console.log('isOsAccountActived isActive:' + isActive); }); ``` @@ -211,12 +212,12 @@ Checks whether an OS account is activated. This API uses a promise to return the **Example**: Check whether OS account 100 is activated. ```js - const accountManager = account_osAccount.getAccountManager(); - var osLocalId = 100; + let accountManager = account_osAccount.getAccountManager(); + let osLocalId = 100; accountManager.isOsAccountActived(osLocalId).then((isActive) => { console.log('isOsAccountActived, isActive: ' + isActive); }).catch((err) => { - console.log("isOsAccountActived err: " + JSON.stringify(err)); + console.log('isOsAccountActived err: ' + JSON.stringify(err)); }); ``` @@ -241,11 +242,11 @@ Checks whether the specified constraint is enabled for an OS account. This API u **Example**: Check whether OS account 100 is forbidden to use Wi-Fi. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{ - console.log("isOsAccountConstraintEnable err:" + JSON.stringify(err)); - console.log("isOsAccountConstraintEnable isConstraintEnabled:" + isConstraintEnabled); + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + accountManager.isOsAccountConstraintEnable(localId, 'constraint.wifi', (err, isConstraintEnabled)=>{ + console.log('isOsAccountConstraintEnable err:' + JSON.stringify(err)); + console.log('isOsAccountConstraintEnable isConstraintEnabled:' + isConstraintEnabled); }); ``` @@ -275,12 +276,12 @@ Checks whether the specified constraint is enabled for an OS account. This API u **Example**: Check whether OS account 100 is forbidden to use Wi-Fi. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => { + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + accountManager.isOsAccountConstraintEnable(localId, 'constraint.wifi').then((isConstraintEnabled) => { console.log('isOsAccountConstraintEnable, isConstraintEnabled: ' + isConstraintEnabled); }).catch((err) => { - console.log("isOsAccountConstraintEnable err: " + JSON.stringify(err)); + console.log('isOsAccountConstraintEnable err: ' + JSON.stringify(err)); }); ``` @@ -301,9 +302,9 @@ Checks whether this OS account is a test account. This API uses an asynchronous **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount((err, isTest) => { - console.log("isTestOsAccount err: " + JSON.stringify(err)); + console.log('isTestOsAccount err: ' + JSON.stringify(err)); console.log('isTestOsAccount isTest: ' + isTest); }); ``` @@ -325,11 +326,11 @@ Checks whether this OS account is a test account. This API uses a promise to ret **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount().then((isTest) => { console.log('isTestOsAccount, isTest: ' + isTest); }).catch((err) => { - console.log("isTestOsAccount err: " + JSON.stringify(err)); + console.log('isTestOsAccount err: ' + JSON.stringify(err)); }); ``` @@ -350,9 +351,9 @@ Checks whether this OS account has been verified. This API uses an asynchronous **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { - console.log("isOsAccountVerified err: " + JSON.stringify(err)); + console.log('isOsAccountVerified err: ' + JSON.stringify(err)); console.log('isOsAccountVerified isVerified: ' + isVerified); }); ``` @@ -377,9 +378,9 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { - console.log("isOsAccountVerified err: " + JSON.stringify(err)); + console.log('isOsAccountVerified err: ' + JSON.stringify(err)); console.log('isOsAccountVerified isVerified: ' + isVerified); }); ``` @@ -409,11 +410,11 @@ Checks whether an OS account has been verified. This API uses a promise to retur **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified().then((isVerified) => { console.log('isOsAccountVerified, isVerified: ' + isVerified); }).catch((err) => { - console.log("isOsAccountVerified err: " + JSON.stringify(err)); + console.log('isOsAccountVerified err: ' + JSON.stringify(err)); }); ``` @@ -439,10 +440,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => { + let accountManager = account_osAccount.getAccountManager(); + accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => { accountManager.removeOsAccount(osAccountInfo.localId, (err)=>{ - console.log("removeOsAccount err:" + JSON.stringify(err)); + console.log('removeOsAccount err:' + JSON.stringify(err)); }); }); ``` @@ -474,12 +475,12 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ + let accountManager = account_osAccount.getAccountManager(); + accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ accountManager.removeOsAccount(osAccountInfo.localId).then(() => { console.log('removeOsAccount Success'); }).catch(() => { - console.log("removeOsAccount err: " + JSON.stringify(err)); + console.log('removeOsAccount err: ' + JSON.stringify(err)); }); }); ``` @@ -508,10 +509,10 @@ This is a system API and cannot be called by third-party applications. **Example**: Disable Wi-Fi for OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{ - console.log("setOsAccountConstraints err:" + JSON.stringify(err)); + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + accountManager.setOsAccountConstraints(localId, ['constraint.wifi'], true, (err)=>{ + console.log('setOsAccountConstraints err:' + JSON.stringify(err)); }); ``` @@ -541,15 +542,15 @@ This is a system API and cannot be called by third-party applications. | :------------------ | :---------------------------------- | | Promise<void> | Promise used to return the result.| -**Example**: Remote the constraint on the use of Wi-Fi for OS account 100. +**Example**: Remove the constraint on the use of Wi-Fi for OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => { + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => { console.log('setOsAccountConstraints Success'); }).catch((err) => { - console.log("setOsAccountConstraints err: " + JSON.stringify(err)); + console.log('setOsAccountConstraints err: ' + JSON.stringify(err)); }); ``` @@ -576,11 +577,11 @@ This is a system API and cannot be called by third-party applications. **Example**: Set the name of OS account 100 to **demoName**. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - var newName = "demoName"; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + let newName = 'demoName'; accountManager.setOsAccountName(localId, newName, (err)=>{ - console.debug("setOsAccountName err:" + JSON.stringify(err)); + console.debug('setOsAccountName err:' + JSON.stringify(err)); }); ``` @@ -612,13 +613,13 @@ This is a system API and cannot be called by third-party applications. **Example**: Set the name of OS account 100 to **demoName**. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - var nameLimit = "demoName"; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + let nameLimit = 'demoName'; accountManager.setOsAccountName(localId, nameLimit).then(() => { console.log('setOsAccountName Success'); }).catch((err) => { - console.log("setOsAccountName err: " + JSON.stringify(err)); + console.log('setOsAccountName err: ' + JSON.stringify(err)); }); ``` @@ -641,10 +642,10 @@ Obtains the number of OS accounts created. This API uses an asynchronous callbac **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{ - console.log("obtains the number of all os accounts created err:" + JSON.stringify(err)); - console.log("obtains the number of all os accounts created accountCnt:" + accountCnt); + console.log('obtains the number of all os accounts created err:' + JSON.stringify(err)); + console.log('obtains the number of all os accounts created accountCnt:' + accountCnt); }); ``` @@ -667,11 +668,11 @@ Obtains the number of OS accounts created. This API uses a promise to return the **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount().then((accountCnt) => { console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt); }).catch((err) => { - console.log("getCreatedOsAccountsCount err: " + JSON.stringify(err)); + console.log('getCreatedOsAccountsCount err: ' + JSON.stringify(err)); }); ``` @@ -692,9 +693,9 @@ Obtains the ID of the OS account to which the current process belongs. This API **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess((err, accountID) => { - console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromProcess err: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromProcess accountID: ' + accountID); }); ``` @@ -716,11 +717,11 @@ Obtains the ID of the OS account to which the current process belongs. This API **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess().then((accountID) => { console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID); }).catch((err) => { - console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromProcess err: ' + JSON.stringify(err)); }); ``` @@ -742,10 +743,10 @@ Obtains the OS account ID based on the process UID. This API uses an asynchronou **Example**: Obtain the ID of the OS account whose process UID is **12345678**. ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => { - console.log("getOsAccountLocalIdFromUid err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromUid err: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromUid: ' + accountID); }); ``` @@ -773,12 +774,12 @@ Obtains the OS account ID based on the process UID. This API uses a promise to r **Example**: Obtain the ID of the OS account whose process UID is **12345678**. ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => { console.log('getOsAccountLocalIdFromUid: ' + accountID); }).catch((err) => { - console.log("getOsAccountLocalIdFromUid err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromUid err: ' + JSON.stringify(err)); }); ``` @@ -802,10 +803,10 @@ Obtains the OS account ID based on domain account information. This API uses an **Example** ```js - var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; - const accountManager = account_osAccount.getAccountManager(); + let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; + let accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => { - console.log("getOsAccountLocalIdFromDomain: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromDomain: ' + JSON.stringify(err)); console.log('getOsAccountLocalIdFromDomain: ' + accountID); }); ``` @@ -835,12 +836,12 @@ Obtains the OS account ID based on domain account information. This API uses a p **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; + let accountManager = account_osAccount.getAccountManager(); + let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => { console.log('getOsAccountLocalIdFromDomain: ' + accountID); }).catch((err) => { - console.log("getOsAccountLocalIdFromDomain err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdFromDomain err: ' + JSON.stringify(err)); }); ``` @@ -863,10 +864,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{ - console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err)); - console.log("queryMaxOsAccountNumber maxCnt:" + maxCnt); + console.log('queryMaxOsAccountNumber err:' + JSON.stringify(err)); + console.log('queryMaxOsAccountNumber maxCnt:' + maxCnt); }); ``` @@ -889,11 +890,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber().then((maxCnt) => { console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt); }).catch((err) => { - console.log("queryMaxOsAccountNumber err: " + JSON.stringify(err)); + console.log('queryMaxOsAccountNumber err: ' + JSON.stringify(err)); }); ``` @@ -917,11 +918,11 @@ Obtains all constraints enabled for an OS account. This API uses an asynchronous **Example**: Obtain all constraints of OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{ - console.log("getOsAccountAllConstraints err:" + JSON.stringify(err)); - console.log("getOsAccountAllConstraints:" + JSON.stringify(constraints)); + console.log('getOsAccountAllConstraints err:' + JSON.stringify(err)); + console.log('getOsAccountAllConstraints:' + JSON.stringify(constraints)); }); ``` @@ -950,12 +951,12 @@ Obtains all constraints enabled for an OS account. This API uses a promise to re **Example**: Obtain all constraints of OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getOsAccountAllConstraints(localId).then((constraints) => { - console.log("getOsAccountAllConstraints, constraints: " + constraints); + console.log('getOsAccountAllConstraints, constraints: ' + constraints); }).catch((err) => { - console.log("getOsAccountAllConstraints err: " + JSON.stringify(err)); + console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err)); }); ``` @@ -980,10 +981,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ - console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err)); - console.log("queryAllCreatedOsAccounts accountArr:" + JSON.stringify(accountArr)); + console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err)); + console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr)); }); ``` @@ -1008,11 +1009,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts().then((accountArr) => { console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); }).catch((err) => { - console.log("queryAllCreatedOsAccounts err: " + JSON.stringify(err)); + console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err)); }); ``` @@ -1033,12 +1034,12 @@ Obtains information about all activated OS accounts. This API uses an asynchrono **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryActivatedOsAccountIds((err, idArray)=>{ - console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err)); - console.log("queryActivatedOsAccountIds idArray length:" + idArray.length); - for(var i=0;i { console.log('queryActivatedOsAccountIds, idArray: ' + idArray); }).catch((err) => { - console.log("queryActivatedOsAccountIds err: " + JSON.stringify(err)); + console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err)); }); ``` @@ -1091,10 +1092,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount("testName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ - console.log("createOsAccount err:" + JSON.stringify(err)); - console.log("createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); + let accountManager = account_osAccount.getAccountManager(); + accountManager.createOsAccount('testName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ + console.log('createOsAccount err:' + JSON.stringify(err)); + console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo)); }); ``` @@ -1126,11 +1127,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL).then((accountInfo) => { - console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo)); + let accountManager = account_osAccount.getAccountManager(); + accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL).then((accountInfo) => { + console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); }).catch((err) => { - console.log("createOsAccount err: " + JSON.stringify(err)); + console.log('createOsAccount err: ' + JSON.stringify(err)); }); ``` @@ -1157,11 +1158,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; + let accountManager = account_osAccount.getAccountManager(); + let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ - console.log("createOsAccountForDomain err:" + JSON.stringify(err)); - console.log("createOsAccountForDomain osAccountInfo:" + JSON.stringify(osAccountInfo)); + console.log('createOsAccountForDomain err:' + JSON.stringify(err)); + console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo)); }); ``` @@ -1193,12 +1194,12 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; + let accountManager = account_osAccount.getAccountManager(); + let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { - console.log("createOsAccountForDomain, account info: " + JSON.stringify(accountInfo)); + console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo)); }).catch((err) => { - console.log("createOsAccountForDomain err: " + JSON.stringify(err)); + console.log('createOsAccountForDomain err: ' + JSON.stringify(err)); }); ``` @@ -1221,10 +1222,10 @@ Obtains information about the OS account to which the current process belongs. T **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{ - console.log("queryCurrentOsAccount err:" + JSON.stringify(err)); - console.log("queryCurrentOsAccount curAccountInfo:" + JSON.stringify(curAccountInfo)); + console.log('queryCurrentOsAccount err:' + JSON.stringify(err)); + console.log('queryCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo)); }); ``` @@ -1247,11 +1248,11 @@ Obtains information about the OS account to which the current process belongs. T **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount().then((accountInfo) => { - console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo)); + console.log('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); }).catch((err) => { - console.log("queryCurrentOsAccount err: " + JSON.stringify(err)); + console.log('queryCurrentOsAccount err: ' + JSON.stringify(err)); }); ``` @@ -1277,11 +1278,11 @@ This is a system API and cannot be called by third-party applications. **Example**: Query information about OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ - console.log("queryOsAccountById err:" + JSON.stringify(err)); - console.log("queryOsAccountById accountInfo:" + JSON.stringify(accountInfo)); + console.log('queryOsAccountById err:' + JSON.stringify(err)); + console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo)); }); ``` @@ -1312,12 +1313,12 @@ This is a system API and cannot be called by third-party applications. **Example**: Query information about OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.queryOsAccountById(localId).then((accountInfo) => { - console.log("queryOsAccountById, accountInfo: " + JSON.stringify(accountInfo)); + console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo)); }).catch((err) => { - console.log("queryOsAccountById err: " + JSON.stringify(err)); + console.log('queryOsAccountById err: ' + JSON.stringify(err)); }); ``` @@ -1338,9 +1339,9 @@ Obtains the type of the OS account to which the current process belongs. This AP **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess((err, accountType) => { - console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err)); + console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); console.log('getOsAccountTypeFromProcess accountType: ' + accountType); }); ``` @@ -1362,11 +1363,11 @@ Obtains the type of the OS account to which the current process belongs. This AP **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess().then((accountType) => { console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); }).catch((err) => { - console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err)); + console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); }); ``` @@ -1389,9 +1390,9 @@ Obtains the ID of this distributed virtual device. This API uses an asynchronous **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId((err, virtualID) => { - console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err)); + console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err)); console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID); }); ``` @@ -1415,11 +1416,11 @@ Obtains the ID of this distributed virtual device. This API uses a promise to re **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId().then((virtualID) => { console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID); }).catch((err) => { - console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err)); + console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err)); }); ``` @@ -1445,11 +1446,11 @@ This is a system API and cannot be called by third-party applications. **Example**: Obtain the profile photo of OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ - console.log("getOsAccountProfilePhoto err:" + JSON.stringify(err)); - console.log("get photo:" + photo + " by localId: " + localId); + console.log('getOsAccountProfilePhoto err:' + JSON.stringify(err)); + console.log('get photo:' + photo + ' by localId: ' + localId); }); ``` @@ -1480,12 +1481,12 @@ This is a system API and cannot be called by third-party applications. **Example**: Obtain the profile photo of OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getOsAccountProfilePhoto(localId).then((photo) => { - console.log("getOsAccountProfilePhoto: " + photo); + console.log('getOsAccountProfilePhoto: ' + photo); }).catch((err) => { - console.log("getOsAccountProfilePhoto err: " + JSON.stringify(err)); + console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err)); }); ``` @@ -1512,14 +1513,14 @@ This is a system API and cannot be called by third-party applications. **Example**: Set a profile photo for OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ - "Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+ - "q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+ - "+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==" + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + let photo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+ + 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ + 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+ + '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==' accountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{ - console.log("setOsAccountProfilePhoto err:" + JSON.stringify(err)); + console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err)); }); ``` @@ -1551,16 +1552,16 @@ This is a system API and cannot be called by third-party applications. **Example**: Set a profile photo for OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; - var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ - "Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+ - "q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+ - "+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==" + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + let photo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+ + 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ + 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+ + '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==' accountManager.setOsAccountProfilePhoto(localId, photo).then(() => { - console.log("setOsAccountProfilePhoto success"); + console.log('setOsAccountProfilePhoto success'); }).catch((err) => { - console.log("setOsAccountProfilePhoto err: " + JSON.stringify(err)); + console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err)); }); ``` @@ -1579,14 +1580,14 @@ Obtains the OS account ID based on the SN. This API uses an asynchronous callbac | 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**. +**Example**: Obtain the ID of the OS account whose SN is 12345. ```js - const accountManager = account_osAccount.getAccountManager(); - var serialNumber = 12345; + let accountManager = account_osAccount.getAccountManager(); + let serialNumber = 12345; accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ - console.log("ger localId err:" + JSON.stringify(err)); - console.log("get localId:" + localId + " by serialNumber: " + serialNumber); + console.log('ger localId err:' + JSON.stringify(err)); + console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber); }); ``` @@ -1610,15 +1611,15 @@ Obtains the OS account ID based on the SN. This API uses a promise to return the | :-------------------- | :----------------------------------------------------------- | | Promise<number> | Promise used to return the OS account ID obtained.| -**Example**: Obtain the ID of the OS account whose SN is **12345**. +**Example**: Obtain the ID of the OS account whose SN is 12345. ```js - const accountManager = account_osAccount.getAccountManager(); - var serialNumber = 12345; + let accountManager = account_osAccount.getAccountManager(); + let serialNumber = 12345; accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => { - console.log("getOsAccountLocalIdBySerialNumber localId: " + localId); + console.log('getOsAccountLocalIdBySerialNumber localId: ' + localId); }).catch((err) => { - console.log("getOsAccountLocalIdBySerialNumber err: " + JSON.stringify(err)); + console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err)); }); ``` @@ -1637,14 +1638,14 @@ Obtains the SN of an OS account based on the account ID. This API uses an asynch | 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. +**Example**: Obtain the SN of the OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ - console.log("ger serialNumber err:" + JSON.stringify(err)); - console.log("get serialNumber:" + serialNumber + " by localId: " + localId); + console.log('ger serialNumber err:' + JSON.stringify(err)); + console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId); }); ``` @@ -1668,15 +1669,15 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise | :-------------------- | :----------------------------------------------------------- | | Promise<number> | Promise used to return the account SN obtained.| -**Example**: Obtain the SN of OS account 100. +**Example**: Obtain the SN of the OS account 100. ```js - const accountManager = account_osAccount.getAccountManager(); - var localId = 100; + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => { - console.log("getSerialNumberByOsAccountLocalId serialNumber: " + serialNumber); + console.log('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber); }).catch((err) => { - console.log("getSerialNumberByOsAccountLocalId err: " + JSON.stringify(err)); + console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err)); }); ``` @@ -1703,11 +1704,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); function onCallback(receiveLocalId){ - console.log("receive localId:" + receiveLocalId); + console.log('receive localId:' + receiveLocalId); } - accountManager.on("activating", "osAccountOnOffNameA", onCallback); + accountManager.on('activating', 'osAccountOnOffNameA', onCallback); ``` ### off @@ -1733,11 +1734,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); function offCallback(){ - console.log("off enter") + console.log('off enter') } - accountManager.off("activating", "osAccountOnOffNameA", offCallback); + accountManager.off('activating', 'osAccountOnOffNameA', offCallback); ``` ### getBundleIdFromUid9+ @@ -1760,11 +1761,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - var testUid = 1000000; + let accountManager = account_osAccount.getAccountManager(); + let testUid = 1000000; accountManager.getBundleIdFromUid(testUid, (err, bundleId) => { - console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err)); - console.info("getBundleIdFromUid bundleId:" + JSON.stringify(bundleId)); + console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err)); + console.info('getBundleIdFromUid bundleId:' + JSON.stringify(bundleId)); }); ``` ### getBundleIdFromUid9+ @@ -1792,12 +1793,12 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - var testUid = 1000000; + let accountManager = account_osAccount.getAccountManager(); + let testUid = 1000000; accountManager.getBundleIdFromUid(testUid).then((result) => { - console.info("getBundleIdFromUid bundleId:" + JSON.stringify(result)); + console.info('getBundleIdFromUid bundleId:' + JSON.stringify(result)); }).catch((err)=>{ - console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err)); + console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err)); }); ``` @@ -1822,10 +1823,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isMainOsAccount((err,result)=>{ - console.info("isMainOsAccount errInfo:" + JSON.stringify(err)); - console.info("isMainOsAccount result:" + JSON.stringify(result)); + console.info('isMainOsAccount errInfo:' + JSON.stringify(err)); + console.info('isMainOsAccount result:' + JSON.stringify(result)); }); ``` ### isMainOsAccount9+ @@ -1849,11 +1850,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); + let accountManager = account_osAccount.getAccountManager(); accountManager.isMainOsAccount().then((result) => { - console.info("isMainOsAccount result:" + JSON.stringify(result)); + console.info('isMainOsAccount result:' + JSON.stringify(result)); }).catch((err)=>{ - console.info("isMainOsAccount errInfo:" + JSON.stringify(err)); + console.info('isMainOsAccount errInfo:' + JSON.stringify(err)); }); ``` ### queryOsAccountConstraintSourceTypes9+ @@ -1879,10 +1880,10 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi",(err,sourceTypeInfos)=>{ - console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err)); - console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(sourceTypeInfos)); + let accountManager = account_osAccount.getAccountManager(); + accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi',(err,sourceTypeInfos)=>{ + console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err)); + console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(sourceTypeInfos)); }); ``` @@ -1914,11 +1915,11 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - const accountManager = account_osAccount.getAccountManager(); - accountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi").then((result) => { - console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(result)); + let accountManager = account_osAccount.getAccountManager(); + accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi').then((result) => { + console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(result)); }).catch((err)=>{ - console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err)); + console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err)); }); ``` @@ -1938,7 +1939,7 @@ This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.Account.OsAccount -**Example** +**Example** ```js let userAuth = new account_osAccount.UserAuth(); ``` @@ -1960,11 +1961,11 @@ This is a system API and cannot be called by third-party applications. | :----- | :----------- | | number | Version information obtained.| -**Example** +**Example** ```js let userAuth = new account_osAccount.UserAuth(); let version = userAuth.getVersion(); - console.log("getVersion version = " + version); + console.log('getVersion version = ' + version); ``` ### getAvailableStatus8+ @@ -1992,13 +1993,13 @@ This is a system API and cannot be called by third-party applications. | :----- | :---------------------------------------- | | number | [Result code](#resultcode8).| -**Example** +**Example** ```js let userAuth = new account_osAccount.UserAuth(); let authType = account_osAccount.AuthType.PIN; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; let status = userAuth.getAvailableStatus(authType, authTrustLevel); - console.log("getAvailableStatus status = " + status); + console.log('getAvailableStatus status = ' + status); ``` ### getProperty8+ @@ -2033,8 +2034,8 @@ This is a system API and cannot be called by third-party applications. keys: keys }; userAuth.getProperty(request, (err, result) => { - console.log("getProperty err = " + JSON.stringify(err)); - console.log("getProperty result = " + JSON.stringify(result)); + console.log('getProperty err = ' + JSON.stringify(err)); + console.log('getProperty result = ' + JSON.stringify(result)); }); ``` @@ -2075,9 +2076,9 @@ This is a system API and cannot be called by third-party applications. keys: keys }; userAuth.getProperty(request).then((result) => { - console.log("getProperty result = " + JSON.stringify(result)); + console.log('getProperty result = ' + JSON.stringify(result)); }).catch((err) => { - console.log("getProperty error = " + JSON.stringify(err)); + console.log('getProperty error = ' + JSON.stringify(err)); }); ``` @@ -2109,8 +2110,8 @@ This is a system API and cannot be called by third-party applications. setInfo: new Uint8Array([0]) }; userAuth.setProperty(request, (err, result) => { - console.log("setProperty error = " + JSON.stringify(err)); - console.log("setProperty result = " + JSON.stringify(result)); + console.log('setProperty error = ' + JSON.stringify(err)); + console.log('setProperty result = ' + JSON.stringify(result)); }); ``` @@ -2147,9 +2148,9 @@ This is a system API and cannot be called by third-party applications. setInfo: new Uint8Array([0]) }; userAuth.setProperty(request).then((result) => { - console.log("setProperty result = " + JSON.stringify(result)); + console.log('setProperty result = ' + JSON.stringify(result)); }).catch((err) => { - console.log("setProperty error = " + JSON.stringify(err)); + console.log('setProperty error = ' + JSON.stringify(err)); }); ``` @@ -2189,8 +2190,8 @@ This is a system API and cannot be called by third-party applications. let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; userAuth.auth(challenge, authType, authTrustLevel, { onResult: function(result,extraInfo){ - console.log("auth result = " + result); - console.log("auth extraInfo = " + JSON.stringify(extraInfo)); + console.log('auth result = ' + result); + console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); } }); ``` @@ -2233,8 +2234,8 @@ This is a system API and cannot be called by third-party applications. let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; userAuth.authUser(userID, challenge, authType, authTrustLevel, { onResult: function(result,extraInfo){ - console.log("authUser result = " + result); - console.log("authUser extraInfo = " + JSON.stringify(extraInfo)); + console.log('authUser result = ' + result); + console.log('authUser extraInfo = ' + JSON.stringify(extraInfo)); } }); ``` @@ -2270,12 +2271,12 @@ This is a system API and cannot be called by third-party applications. let challenge = new Uint8Array([0]); let contextID = userAuth.auth(challenge, account_osAccount.AuthType.PIN, account_osAccount.AuthTrustLevel.ATL1, { onResult: (result, extraInfo) => { - console.log("auth result = " + result); - console.log("auth extraInfo = " + JSON.stringify(extraInfo)); + console.log('auth result = ' + result); + console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); } }); let result = userAuth.cancelAuth(contextID); - console.log("cancelAuth result = " + result); + console.log('cancelAuth result = ' + result); ``` ## PINAuth8+ @@ -2294,7 +2295,7 @@ This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.Account.OsAccount -**Example** +**Example** ```js let pinAuth = new account_osAccount.PINAuth(); ``` @@ -2332,7 +2333,7 @@ This is a system API and cannot be called by third-party applications. callback.onSetData(pinSubType, password); } }); - console.log("registerInputer result = " + result); + console.log('registerInputer result = ' + result); ``` ### unregisterInputer @@ -2369,7 +2370,7 @@ This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.Account.OsAccount -**Example** +**Example** ```js let userIDM = new account_osAccount.UserIdentityManager(); ``` @@ -2396,8 +2397,8 @@ This is a system API and cannot be called by third-party applications. ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.openSession((err, challenge) => { - console.log("openSession error = " + JSON.stringify(err)); - console.log("openSession challenge = " + JSON.stringify(challenge)); + console.log('openSession error = ' + JSON.stringify(err)); + console.log('openSession challenge = ' + JSON.stringify(challenge)); }); ``` @@ -2423,9 +2424,9 @@ This is a system API and cannot be called by third-party applications. ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.openSession().then((challenge) => { - console.info("openSession challenge = " + JSON.stringify(challenge)); + console.info('openSession challenge = ' + JSON.stringify(challenge)); }).catch((err) => { - console.info("openSession error = " + JSON.stringify(err)); + console.info('openSession error = ' + JSON.stringify(err)); }); ``` @@ -2466,8 +2467,8 @@ This is a system API and cannot be called by third-party applications. userIDM.openSession((err, challenge) => { userIDM.addCredential(credentialInfo, { onResult: (result, extraInfo) => { - console.log("updateCredential result = " + result); - console.log("updateCredential extraInfo = " + extraInfo); + console.log('updateCredential result = ' + result); + console.log('updateCredential extraInfo = ' + extraInfo); } }); }); @@ -2517,8 +2518,8 @@ This is a system API and cannot be called by third-party applications. credentialInfo.token = extraInfo.token; userIDM.updateCredential(credentialInfo, { onResult: (result, extraInfo) => { - console.log("updateCredential result = " + result); - console.log("updateCredential extraInfo = " + extraInfo); + console.log('updateCredential result = ' + result); + console.log('updateCredential extraInfo = ' + extraInfo); } }); } @@ -2566,14 +2567,14 @@ This is a system API and cannot be called by third-party applications. | Type | Description | | :----- | :-------------------------------------------------------- | -| number | [Result code](#resultcode8) indicating whether the operation is successful.| +| number | [Result code](#resultcode8).| **Example** ```js let userIDM = new account_osAccount.UserIdentityManager(); let challenge = new Uint8Array([0]); let result = userIDM.cancel(challenge); - console.log("cancel result: " + result); + console.log('cancel result: ' + result); ``` ### delUser8+ @@ -2601,8 +2602,8 @@ This is a system API and cannot be called by third-party applications. let token = new Uint8Array([0]); userIDM.delUser(token, { onResult: (result, extraInfo) => { - console.log("delUser result = " + result); - console.log("delUser extraInfo = " + JSON.stringify(extraInfo)); + console.log('delUser result = ' + result); + console.log('delUser extraInfo = ' + JSON.stringify(extraInfo)); } }); ``` @@ -2634,8 +2635,8 @@ This is a system API and cannot be called by third-party applications. let token = new Uint8Array([0]); userIDM.delCred(credentialId, token, { onResult: (result, extraInfo) => { - console.log("delCred result = " + result); - console.log("delCred extraInfo = " + JSON.stringify(extraInfo)); + console.log('delCred result = ' + result); + console.log('delCred extraInfo = ' + JSON.stringify(extraInfo)); } }); ``` @@ -2656,15 +2657,15 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | -------- | -------------------------------------------------- | ---- | -------------------------------------------------- | -| callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | Yes | Callback invoked to return information about all enrolled credentials of the specified type.| +| callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | Yes | Callback invoked to return information about all the user's enrolled credentials of the specified type.| **Example** ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.getAuthInfo((err, result) => { - console.log("getAuthInfo err = " + JSON.stringify(err)); - console.log("getAuthInfo result = " + JSON.stringify(result)); + console.log('getAuthInfo err = ' + JSON.stringify(err)); + console.log('getAuthInfo result = ' + JSON.stringify(result)); }); ``` @@ -2691,8 +2692,8 @@ This is a system API and cannot be called by third-party applications. ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.getAuthInfo(account_osAccount.AuthType.PIN, (err, result) => { - console.log("getAuthInfo err = " + JSON.stringify(err)); - console.log("getAuthInfo result = " + JSON.stringify(result)); + console.log('getAuthInfo err = ' + JSON.stringify(err)); + console.log('getAuthInfo result = ' + JSON.stringify(result)); }); ``` @@ -2724,9 +2725,9 @@ This is a system API and cannot be called by third-party applications. ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.getAuthInfo(account_osAccount.AuthType.PIN).then((result) => { - console.log("getAuthInfo result = " + JSON.stringify(result)) + console.log('getAuthInfo result = ' + JSON.stringify(result)) }).catch((err) => { - console.log("getAuthInfo error = " + JSON.stringify(err)); + console.log('getAuthInfo error = ' + JSON.stringify(err)); }); ``` @@ -2805,7 +2806,7 @@ This is a system API and cannot be called by third-party applications. }; let pinAuth = new account_osAccount.PINAuth(); let result = pinAuth.registerInputer(inputer); - console.log("registerInputer result: " + result); + console.log('registerInputer result: ' + result); ``` ## IUserAuthCallback8+ @@ -2835,8 +2836,8 @@ This is a system API and cannot be called by third-party applications. ```js let authCallback = { onResult: (result, extraInfo) => { - console.log("auth result = " + result); - console.log("auth extraInfo = " + JSON.stringify(extraInfo)); + console.log('auth result = ' + result); + console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); } }; ``` @@ -2863,12 +2864,12 @@ This is a system API and cannot be called by third-party applications. ```js let authCallback = { onResult: (result, extraInfo) => { - console.log("auth result = " + result) - console.log("auth extraInfo = " + JSON.stringify(extraInfo)); + console.log('auth result = ' + result) + console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); }, onAcquireInfo: (module, acquire, extraInfo) => { - console.log("auth module = " + module); - console.log("auth acquire = " + acquire); + console.log('auth module = ' + module); + console.log('auth acquire = ' + acquire); console.info('auth extraInfo = ' + JSON.stringify(extraInfo)); } }; @@ -2899,9 +2900,9 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - var idmCallback = { + let idmCallback = { onResult: (result, extraInfo) => { - console.log("callback result = " + result) + console.log('callback result = ' + result) console.info('callback extraInfo = ' + JSON.stringify(extraInfo)); } }; @@ -2929,12 +2930,12 @@ This is a system API and cannot be called by third-party applications. ```js let idmCallback = { onResult: (result, extraInfo) => { - console.log("callback result = " + result) - console.log("callback onResult = " + JSON.stringify(extraInfo)); + console.log('callback result = ' + result) + console.log('callback onResult = ' + JSON.stringify(extraInfo)); }, onAcquireInfo: (module, acquire, extraInfo) => { - console.log("callback module = " + module); - console.log("callback acquire = " + acquire); + console.log('callback module = ' + module); + console.log('callback acquire = ' + acquire); console.log('callback onacquireinfo = ' + JSON.stringify(extraInfo)); } }; @@ -3217,8 +3218,8 @@ Domain account information. | 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.wifi | A user is not allowed to use Wi-Fi. | +| constraint.wifi.set | A user is not allowed to set Wi-Fi. | | 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. | diff --git a/en/application-dev/reference/apis/js-apis-plainarray.md b/en/application-dev/reference/apis/js-apis-plainarray.md index 4af1fc423938baa39a4ea5771202b0013a65aaec..568a479679c9457babba38a8da53e9a082f74f40 100644 --- a/en/application-dev/reference/apis/js-apis-plainarray.md +++ b/en/application-dev/reference/apis/js-apis-plainarray.md @@ -12,6 +12,9 @@ Both **PlainArray** and **[LightWeightMap](js-apis-lightweightmap.md)** are used **Recommended use case**: Use **PlainArray** when you need to store KV pairs whose keys are of the **number** type. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -93,7 +96,7 @@ Checks whether this container contains the specified key. ```ts let plainArray = new PlainArray(); plainArray.has(1); -plainArray.add(1, "sddfhf"); +plainArray.add(1, "squirrel"); let result1 = plainArray.has(1); ``` @@ -122,8 +125,8 @@ Obtains the value of the specified key in this container. ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); let result = plainArray.get(1); ``` @@ -152,8 +155,8 @@ Obtains the index of the first occurrence of an element with the specified key i ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); let result = plainArray.getIndexOfKey(2); ``` @@ -182,9 +185,9 @@ Obtains the index of the first occurrence of an element with the specified value ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); -let result = plainArray.getIndexOfValue("sddfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); +let result = plainArray.getIndexOfValue("squirrel"); ``` @@ -212,8 +215,8 @@ Obtains the key of the element at the specified position in this container. ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); let result = plainArray.getKeyAt(1); ``` @@ -241,8 +244,8 @@ Obtains the value of an element at the specified position in this container. ```ts let plainArray = new PlainArray(); - plainArray.add(1, "sddfhf"); - plainArray.add(2, "sffdfhf"); + plainArray.add(1, "squirrel"); + plainArray.add(2, "sparrow"); let result = plainArray.getKeyAt(1); ``` @@ -264,8 +267,8 @@ Clones this container and returns a copy. The modification to the copy does not ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); let newPlainArray = plainArray.clone(); ``` @@ -289,7 +292,7 @@ Adds an element to this container. ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); +plainArray.add(1, "squirrel"); ``` @@ -317,8 +320,8 @@ Removes an element with the specified key from this container. ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); plainArray.remove(2); let result = plainArray.remove(2); ``` @@ -348,8 +351,8 @@ Removes an element at the specified position from this container. ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); plainArray.removeAt(1); let result = plainArray.removeAt(1); ``` @@ -380,8 +383,8 @@ Removes elements in a specified range from this container. ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); let result = plainArray.removeRangeFrom(1, 3); ``` @@ -405,8 +408,8 @@ Sets a value for an element at the specified position in this container. ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); plainArray.setValueAt(1, 3546); ``` @@ -429,8 +432,8 @@ Obtains a string that contains all elements in this container. ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); let result = plainArray.toString(); ``` @@ -447,8 +450,8 @@ Clears this container and sets its length to **0**. ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); plainArray.clear(); ``` @@ -479,8 +482,8 @@ callbackfn ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); plainArray.forEach((value, index) => { console.log("value:" + value, index); }); @@ -505,8 +508,8 @@ Obtains an iterator object that contains key-value pairs, where the key is of th ```ts let plainArray = new PlainArray(); -plainArray.add(1, "sddfhf"); -plainArray.add(2, "sffdfhf"); +plainArray.add(1, "squirrel"); +plainArray.add(2, "sparrow"); // Method 1: for (let item of plainArray) { diff --git a/en/application-dev/reference/apis/js-apis-processrunninginfo.md b/en/application-dev/reference/apis/js-apis-processrunninginfo.md index e26e01dc8f8d7fbb6472d11217f1156ceb1b41b8..f08032456915595af5da869b74aa0ab1888ffb6b 100644 --- a/en/application-dev/reference/apis/js-apis-processrunninginfo.md +++ b/en/application-dev/reference/apis/js-apis-processrunninginfo.md @@ -1,10 +1,10 @@ -# ProcessRunningInfo +# ProcessRunningInfo(deprecated) The **ProcessRunningInfo** module provides process running information. > **NOTE** -> -> 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. +> - The APIs provided by this module are deprecated since API version 9. You are advised to use [ProcessRunningInformation9+](js-apis-processrunninginformation.md) instead. +> - The initial APIs of this module are supported since API version 8. ## Usage @@ -19,9 +19,9 @@ appManager.getProcessRunningInfos((error,data) => { ## Attributes -**System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission - | Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | | pid | number | Yes| No| Process ID.| | uid | number | Yes| No| User ID.| diff --git a/en/application-dev/reference/apis/js-apis-processrunninginformation.md b/en/application-dev/reference/apis/js-apis-processrunninginformation.md new file mode 100644 index 0000000000000000000000000000000000000000..a5add77380e1a9173f9d1d1b1e44b2dfee5be38c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-processrunninginformation.md @@ -0,0 +1,29 @@ +# ProcessRunningInformation9+ + +The **ProcessRunningInformation** module provides process running information. + +> **NOTE** +> +> 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. + +## Usage Guidelines + +The process running information is obtained through [appManager](js-apis-appmanager.md#appmanagergetprocessrunninginformation9). + +```js +import appManager from '@ohos.application.appManager'; +appManager.getProcessRunningInformation((error,data) => { + console.log("getProcessRunningInformation error: " + error.code + " data: " + JSON.stringify(data)); +}); +``` + +## Attributes + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| 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 running bundles in the process.| diff --git a/en/application-dev/reference/apis/js-apis-queue.md b/en/application-dev/reference/apis/js-apis-queue.md index a31a72649d0e0ede56771f3fa6c9bf4d25bbefe7..13ae6256d81a27c3fe53466ac175c74486051ee2 100644 --- a/en/application-dev/reference/apis/js-apis-queue.md +++ b/en/application-dev/reference/apis/js-apis-queue.md @@ -10,6 +10,9 @@ Unlike **[Deque](js-apis-deque.md)**, which supports insertion and removal at bo **Recommended use case**: Use **Queue** in FIFO scenarios. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -72,7 +75,7 @@ let result1 = queue.add(1); queue.add(1); let b = [1, 2, 3]; queue.add(b); -let c = {name : "lala", age : "13"}; +let c = {name : "Dylon", age : "13"}; let result3 = queue.add(c); ``` @@ -180,6 +183,7 @@ Obtains an iterator, each item of which is a JavaScript object. | IterableIterator<T> | Iterator obtained.| **Example** + ```ts let queue = new Queue(); queue.add(2); diff --git a/en/application-dev/reference/apis/js-apis-rpc.md b/en/application-dev/reference/apis/js-apis-rpc.md index 60cd08a08e0baf3853bf11f2628230a402805900..d1b4506837068ac88f3821befed6a673726fd327 100644 --- a/en/application-dev/reference/apis/js-apis-rpc.md +++ b/en/application-dev/reference/apis/js-apis-rpc.md @@ -16,7 +16,7 @@ import rpc from '@ohos.rpc'; ## MessageParcel -Provides methods for reading and writing basic data types and arrays, inter-process communication (IPC) objects, interface tokens, and sequenceable objects. +Provides APIs for reading and writing data in specific format. During RPC, the sender can use the **write()** method provided **MessageParcel** to write data to a **MessageParcel** object in specific format. The receiver can use the **read()** method provided by **MessageParcel** to read data in specific format from a **MessageParcel** object. The data formats include basic data types and arrays, IPC objects, interface tokens, and custom sequenceable objects. ### create @@ -28,7 +28,8 @@ Creates a **MessageParcel** object. This method is a static method. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | MessageParcel | **MessageParcel** object created.| @@ -65,12 +66,14 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | object | [IRemoteObject](#iremoteobject) | Yes| Remote object to serialize and write to the **MessageParcel** object.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -111,7 +114,8 @@ Reads the remote object from this **MessageParcel** object. You can use this met **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | [IRemoteObject](#iremoteobject) | Remote object obtained.| @@ -148,17 +152,19 @@ Reads the remote object from this **MessageParcel** object. You can use this met writeInterfaceToken(token: string): boolean -Writes an interface token to this **MessageParcel** object. +Writes an interface token to this **MessageParcel** object. The remote object can use this interface token to verify the communication. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | token | string | Yes| Interface token to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -175,12 +181,13 @@ Writes an interface token to this **MessageParcel** object. readInterfaceToken(): string -Reads the interface token from this **MessageParcel** object. The interface tokens are read in the order in which they are written into the **MessageParcel** object. +Reads the interface token from this **MessageParcel** object. The interface token is read in the sequence in which it is written to the **MessageParcel** object. The local object can use it to verify the communication. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Interface token obtained.| @@ -206,7 +213,8 @@ Obtains the data size of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Size of the **MessageParcel** object obtained, in bytes.| @@ -228,7 +236,8 @@ Obtains the capacity of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | **MessageParcel** capacity obtained, in bytes.| @@ -250,12 +259,14 @@ Sets the size of data contained in this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | size | number | Yes| Data size to set, in bytes.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -277,12 +288,14 @@ Sets the storage capacity of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | size | number | Yes| Storage capacity to set, in bytes.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -304,7 +317,8 @@ Obtains the writable capacity of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | **MessageParcel** writable capacity obtained, in bytes.| @@ -330,7 +344,8 @@ Obtains the readable capacity of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | **MessageParcel** object readable capacity, in bytes.| @@ -356,7 +371,8 @@ Obtains the read position of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Current read position of the **MessageParcel** object.| @@ -378,7 +394,8 @@ Obtains the write position of this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Current write position of the **MessageParcel** object.| @@ -401,12 +418,14 @@ Moves the read pointer to the specified position. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | pos | number | Yes| Position from which data is to read.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the read position changes; returns **false** otherwise.| @@ -433,12 +452,14 @@ Moves the write pointer to the specified position. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | pos | number | Yes| Position from which data is to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the write position changes; returns **false** otherwise.| @@ -463,12 +484,14 @@ Writes a Byte value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Byte value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -490,7 +513,8 @@ Reads the Byte value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Byte value read.| @@ -514,12 +538,14 @@ Writes a Short int value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Short int value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -541,7 +567,8 @@ Reads the Short int value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Short int value read.| @@ -565,12 +592,14 @@ Writes an Int value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Int value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -592,7 +621,8 @@ Reads the Int value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Int value read.| @@ -616,12 +646,14 @@ Writes a Long int value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Long int value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -643,7 +675,8 @@ Reads the Long int value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Long int value read.| @@ -667,12 +700,14 @@ Writes a Float value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Float value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -694,7 +729,8 @@ Reads the Float value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Float value read.| @@ -718,12 +754,14 @@ Writes a Double value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Double value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -745,7 +783,8 @@ Reads the Double value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Double value read.| @@ -769,12 +808,14 @@ Writes a Boolean value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | boolean | Yes| Boolean value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -796,7 +837,8 @@ Reads the Boolean value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Boolean value read.| @@ -820,12 +862,14 @@ Writes a Char value to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | number | Yes| Char value to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -847,7 +891,8 @@ Reads the Char value from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Char value read.| @@ -871,12 +916,14 @@ Writes a string to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | string | Yes| String to write. The length of the string must be less than 40960 bytes.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -898,7 +945,8 @@ Reads a string from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | String read.| @@ -922,12 +970,14 @@ Writes a sequenceable object to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | val | [Sequenceable](#sequenceable) | Yes| Sequenceable object to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -968,12 +1018,14 @@ Reads member variables from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | [Sequenceable](#sequenceable) | Yes| Object that reads member variables from the **MessageParcel** object.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1017,12 +1069,14 @@ Writes a byte array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | byteArray | number[] | Yes| Byte array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1045,7 +1099,8 @@ Reads a byte array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| Byte array to read.| @@ -1070,7 +1125,8 @@ Reads the byte array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Byte array read.| @@ -1095,12 +1151,14 @@ Writes a short array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | shortArray | number[] | Yes| Short array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1122,7 +1180,8 @@ Reads a short array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| Short array to read.| @@ -1146,7 +1205,8 @@ Reads the short array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Short array read.| @@ -1170,12 +1230,14 @@ Writes an integer array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | intArray | number[] | Yes| Integer array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1197,7 +1259,8 @@ Reads an integer array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| Integer array to read.| @@ -1221,7 +1284,8 @@ Reads the integer array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Integer array read.| @@ -1245,12 +1309,14 @@ Writes a long array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | longArray | number[] | Yes| Long array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1272,7 +1338,8 @@ Reads a long array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| Long array to read.| @@ -1296,7 +1363,8 @@ Reads the long array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Long array read.| @@ -1320,12 +1388,14 @@ Writes a FloatArray to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | floatArray | number[] | Yes| FloatArray to write. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1347,7 +1417,8 @@ Reads a FloatArray from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| FloatArray to read. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| @@ -1372,7 +1443,8 @@ Reads the FloatArray from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | FloatArray read.| @@ -1396,12 +1468,14 @@ Writes a DoubleArray to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | doubleArray | number[] | Yes| DoubleArray to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1423,7 +1497,8 @@ Reads a DoubleArray from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| DoubleArray to read.| @@ -1447,7 +1522,8 @@ Reads the DoubleArray from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | DoubleArray read.| @@ -1471,12 +1547,14 @@ Writes a Boolean array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | booleanArray | boolean[] | Yes| Boolean array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1498,7 +1576,8 @@ Reads a Boolean array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | boolean[] | Yes| Boolean array to read.| @@ -1522,7 +1601,8 @@ Reads the Boolean array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean[] | Boolean array read.| @@ -1545,12 +1625,14 @@ Writes a character array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | charArray | number[] | Yes| Character array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1572,7 +1654,8 @@ Reads a character array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | number[] | Yes| Character array to read.| @@ -1596,7 +1679,8 @@ Reads the character array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Character array read.| @@ -1620,12 +1704,14 @@ Writes a string array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | stringArray | string[] | Yes| String array to write. The length of a single element in the array must be less than 40960 bytes.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1647,7 +1733,8 @@ Reads a string array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | string[] | Yes| String array to read.| @@ -1671,7 +1758,8 @@ Reads the string array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string[] | String array read.| @@ -1793,12 +1881,14 @@ Writes a sequenceable array to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | sequenceableArray | Sequenceable[] | Yes| Sequenceable array to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -1842,7 +1932,8 @@ Reads a sequenceable array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | sequenceableArray | Sequenceable[] | Yes| Sequenceable array to read.| @@ -1888,12 +1979,14 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | objectArray | IRemoteObject[] | Yes| Array of **IRemoteObject** objects to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** if the operation fails or if the **IRemoteObject** array is null.| @@ -1939,7 +2032,8 @@ Reads an **IRemoteObject** array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | objects | IRemoteObject[] | Yes| **IRemoteObject** array to read.| @@ -1986,7 +2080,8 @@ Reads the **IRemoteObject** array from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | IRemoteObject[] | **IRemoteObject** object array obtained.| @@ -2034,7 +2129,8 @@ Closes a file descriptor. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | fd | number | Yes| File descriptor to close.| @@ -2057,12 +2153,14 @@ Duplicates a file descriptor. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | fd | number | Yes| File descriptor to duplicate.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | New file descriptor.| @@ -2085,7 +2183,8 @@ Checks whether this **MessageParcel** object contains a file descriptor. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the **MessageParcel** object contains a file descriptor; returns **false** otherwise.| @@ -2113,12 +2212,14 @@ Writes a file descriptor to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | fd | number | Yes| File descriptor to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2143,7 +2244,8 @@ Reads the file descriptor from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | File descriptor read.| @@ -2169,12 +2271,14 @@ Writes an anonymous shared object to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | ashmem | Ashmem | Yes| Anonymous shared object to write.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2197,7 +2301,8 @@ Reads the anonymous shared object from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Ashmem | Anonymous share object obtained.| @@ -2222,7 +2327,8 @@ Obtains the maximum amount of raw data that can be held by this **MessageParcel* **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | 128 MB, which is the maximum amount of raw data that can be held by this **MessageParcel** object.| @@ -2244,13 +2350,15 @@ Writes raw data to this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | rawData | number[] | Yes| Raw data to write.| | size | number | Yes| Size of the raw data, in bytes.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2273,12 +2381,14 @@ Reads raw data from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | size | number | Yes| Size of the raw data to read.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Raw data obtained, in bytes.| @@ -2307,12 +2417,14 @@ Marshals the sequenceable object into a **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataOut | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object to which the sequenceable object is to be marshaled.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2356,12 +2468,14 @@ Unmarshals this sequenceable object from a **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | dataIn | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object in which the sequenceable object is to be unmarshaled.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2405,12 +2519,13 @@ Provides the holder of a remote proxy object. asObject(): IRemoteObject -Obtains a proxy or remote object. This method must be implemented by its derived classes. +Obtains a proxy or remote object. This API must be implemented by its derived classes. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | [IRemoteObject](#iremoteobject) | Returns the [RemoteObject](#ashmem8) if it is the caller; returns the [IRemoteObject](#iremoteobject), the holder of this **RemoteProxy** object, if the caller is a [RemoteProxy](#remoteproxy) object.| @@ -2491,29 +2606,32 @@ Obtains the interface. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | descriptor | string | Yes| Interface descriptor.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | IRemoteBroker | **IRemoteBroker** object bound to the specified interface descriptor.| ### sendRequest(deprecated) +sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean + > **NOTE**
> This API is deprecated since API version 8. You are advised to use [sendRequestAsync9+](#sendrequestasync9). -sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean - Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2521,24 +2639,26 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| ### sendRequest8+(deprecated) -> **NOTE**
-> This API is deprecated since API Version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9). - sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> +> **NOTE**
+> This API is deprecated since API version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9). + Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2546,7 +2666,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -2559,7 +2680,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2567,7 +2689,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -2580,7 +2703,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2598,13 +2722,15 @@ Adds a callback for receiving death notifications of the remote object. This met **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to add.| | flags | number | Yes| Flag of the death notification.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| @@ -2618,13 +2744,15 @@ Removes the callback used to receive death notifications of the remote object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to remove.| | flags | number | Yes| Flag of the death notification.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the callback is removed successfully; returns **false** otherwise.| @@ -2638,7 +2766,8 @@ Obtains the interface descriptor of this object. The interface descriptor is a s **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Interface descriptor obtained.| @@ -2652,7 +2781,8 @@ Checks whether this object is dead. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the object is dead; returns **false** otherwise.| @@ -2676,17 +2806,18 @@ Provides methods to implement **IRemoteObject**. ### sendRequest(deprecated) -> **NOTE**
-> This API is deprecated since API Version 8. You are advised to use [sendRequestAsync9+](#sendrequestasync9-1). - sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean +> **NOTE**
+> This API is deprecated since API version 8. You are advised to use [sendRequestAsync9+](#sendrequestasync9-1). + Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2694,7 +2825,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -2741,17 +2873,18 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ### sendRequest8+(deprecated) -> **NOTE**
-> This API is deprecated since API Version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9-1). - sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> +> **NOTE**
+> This API is deprecated since API version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9-1). + Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2759,7 +2892,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -2818,7 +2952,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2826,7 +2961,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -2885,7 +3021,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -2946,12 +3083,14 @@ Obtains the **LocalInterface** object of an interface descriptor. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | interface | string | Yes| Interface descriptor.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | IRemoteBroker | Returns **Null** by default, which indicates a proxy interface.| @@ -2991,13 +3130,15 @@ Adds a callback for receiving the death notifications of the remote object, incl **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to add.| | flags | number | Yes| Flag of the death notification. This parameter is reserved. It is set to **0**.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| @@ -3042,13 +3183,15 @@ Removes the callback used to receive death notifications of the remote object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to remove.| | flags | number | Yes| Flag of the death notification. This parameter is reserved. It is set to **0**.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the callback is removed successfully; returns **false** otherwise.| @@ -3094,7 +3237,8 @@ Obtains the interface descriptor of this proxy object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Interface descriptor obtained.| @@ -3134,7 +3278,8 @@ Checks whether the **RemoteObject** is dead. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the **RemoteObject** is dead; returns **false** otherwise.| @@ -3188,7 +3333,8 @@ A constructor used to create a **MessageOption** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | syncFlags | number | No| Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.| | waitTime | number | No| Maximum wait time for an RPC call. The default value is **TF_WAIT_TIME**.| @@ -3203,7 +3349,8 @@ Obtains the call flag, which can be synchronous or asynchronous. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Call mode obtained.| @@ -3217,7 +3364,8 @@ Sets the call flag, which can be synchronous or asynchronous. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | flags | number | Yes| Call flag to set.| @@ -3231,7 +3379,8 @@ Obtains the maximum wait time for this RPC call. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Maximum wait time obtained.| @@ -3245,7 +3394,8 @@ Sets the maximum wait time for this RPC call. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | waitTime | number | Yes| Maximum wait time to set.| @@ -3264,7 +3414,8 @@ Obtains the system capability manager. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | [IRemoteObject](#iremoteobject) | System capability manager obtained.| @@ -3285,7 +3436,8 @@ Obtains the PID of the caller. This method is invoked by the **RemoteObject** ob **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | PID of the caller.| @@ -3311,7 +3463,8 @@ Obtains the UID of the caller. This method is invoked by the **RemoteObject** ob **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | UID of the caller.| @@ -3363,7 +3516,8 @@ Obtains the ID of the device hosting the caller's process. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Device ID obtained.| @@ -3389,7 +3543,8 @@ Obtains the local device ID. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Local device ID obtained.| @@ -3415,7 +3570,8 @@ Checks whether the remote process is a process of the local device. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the local and remote processes are on the same device; returns **false** otherwise.| @@ -3441,13 +3597,15 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | object | [IRemoteObject](#iremoteobject) | Yes| **RemoteProxy** specified. | **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | Returns **0** if the operation is successful; returns an error code if the input object is null or a **RemoteObject**, or if the operation fails.| @@ -3488,7 +3646,8 @@ Changes the UID and PID of the remote user to the UID and PID of the local user. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | String containing the UID and PID of the remote user.| @@ -3514,12 +3673,14 @@ Restores the UID and PID of the remote user. It is usually called when the UID a **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | identity | string | Yes| String containing the remote user UID and PID, which are returned by **resetCallingIdentity**.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -3556,24 +3717,26 @@ A constructor used to create a **RemoteObject** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | descriptor | string | Yes| Interface descriptor.| ### sendRequest(deprecated) -> **NOTE**
-> This API is deprecated since API Version 8. You are advised to use [sendRequestAsync9+](#sendrequestasync9-2). - sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean +> **NOTE**
+> This API is deprecated since API version 8. You are advised to use [sendRequestAsync9+](#sendrequestasync9-2). + Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -3581,7 +3744,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -3630,17 +3794,18 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ### sendRequest8+(deprecated) -> **NOTE**
-> This API is deprecated since API Version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9-2). - sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> +> **NOTE**
+> This API is deprecated since API version 9. You are advised to use [sendRequestAsync9+](#sendrequestasync9-2). + Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -3648,7 +3813,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -3709,7 +3875,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -3717,7 +3884,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| @@ -3777,7 +3945,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.| @@ -3831,16 +4000,21 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ``` -### onRemoteRequest +### onRemoteRequest8+(deprecated) + onRemoteRequest(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean +> **NOTE**
+> This API is deprecated since API version 9. You are advised to use [onRemoteRequestEx9+](#onremoterequestex9). + Provides a response to **sendRequestAsync()**. The server processes the request and returns a response in this function. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | code | number | Yes| Service request code sent by the remote end.| | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that holds the parameters called by the client.| @@ -3848,14 +4022,15 @@ Provides a response to **sendRequestAsync()**. The server processes the request | option | [MessageOption](#messageoption) | Yes| Whether the operation is synchronous or asynchronous.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** - ``` + ```ets class MyDeathRecipient { onRemoteDied() { console.log("server died"); @@ -3886,8 +4061,190 @@ Provides a response to **sendRequestAsync()**. The server processes the request } } ``` +### onRemoteRequestEx9+ + +onRemoteRequestEx(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean | Promise + +> **NOTE**
+>- You are advised to overload **onRemoteRequestEx** preferentially, which implements synchronous and asynchronous message processing. +>- If both **onRemoteRequest** and **onRemoteRequestEx** are overloaded, only **onRemoteRequestEx** takes effect. + +Provides a response to **sendRequestAsync()**. The server processes the request synchronously or asynchronously and returns the result in this API. + +**System capability**: SystemCapability.Communication.IPC.Core + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | code | number | Yes| Service request code sent by the remote end.| + | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that holds the parameters called by the client.| + | reply | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object carrying the result.| + | option | [MessageOption](#messageoption) | Yes| Whether the operation is synchronous or asynchronous.| + +**Return value** + + | Type| Description| + | -------- | -------- | + | boolean | Returns a Boolean value if the request is processed synchronously in **onRemoteRequestEx**. If the operation is successful, **true** is returned. Otherwise, **false** is returned.| + | Promise | Returns a promise object if the request is processed asynchronously in **onRemoteRequestEx**.| + + +**Example**: Overload **onRemoteRequestEx** to process a request synchronously. + + ```ets + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + onRemoteRequestEx(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: sync onRemoteRequestEx is called"); + return true; + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + } + } + ``` + **Example**: Overload **onRemoteRequestEx** to process a request asynchronously. + ```ets + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + async onRemoteRequestEx(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: async onRemoteRequestEx is called"); + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + await new Promise((resolve) => { + setTimeout(resolve, 100); + }) + return true; + } + } + ``` +**Example**: Overload **onRemoteRequestEx** and **onRemoteRequest** to process requests synchronously. + ```ets + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + onRemoteRequest(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: sync onRemoteRequestEx is called"); + return true; + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + } + // Only onRemoteRequestEx is executed when onRemoteRequestEx and onRemoteRequest are called. + onRemoteRequestEx(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: async onRemoteRequestEx is called"); + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + + return true; + } + } + ``` + **Example**: Overload **onRemoteRequestEx** and **onRemoteRequest** to process requests asynchronously. + + ```ets + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + onRemoteRequest(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: sync onRemoteRequestEx is called"); + return true; + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + } + // Only onRemoteRequestEx is executed when onRemoteRequestEx and onRemoteRequest are called. + async onRemoteRequestEx(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: async onRemoteRequestEx is called"); + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + await new Promise((resolve) => { + setTimeout(resolve, 100); + }) + return true; + } + } + ``` ### getCallingUid getCallingUid(): number @@ -3897,7 +4254,8 @@ Obtains the UID of the remote process. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | UID of the remote process obtained.| @@ -3938,7 +4296,8 @@ Obtains the PID of the remote process. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | PID of the remote process obtained.| @@ -3979,12 +4338,14 @@ Checks whether the remote object corresponding to the specified interface descri **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | descriptor | string | Yes| Interface descriptor.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | IRemoteBroker | Returns the remote object if a match is found; returns **Null** otherwise.| @@ -4025,7 +4386,8 @@ Obtains the interface descriptor. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | string | Interface descriptor obtained.| @@ -4067,7 +4429,8 @@ Binds an interface descriptor to an **IRemoteBroker** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | localInterface | IRemoteBroker | Yes| **IRemoteBroker** object.| | descriptor | string | Yes| Interface descriptor.| @@ -4128,13 +4491,15 @@ Creates an **Ashmem** object with the specified name and size. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | name | string | Yes| Name of the **Ashmem** object to create.| | size | number | Yes| Size (in bytes) of the **Ashmem** object to create.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Ashmem | Returns the **Ashmem** object if it is created successfully; returns null otherwise.| @@ -4157,12 +4522,14 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | ashmem | Ashmem | Yes| Existing **Ashmem** object.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | Ashmem | **Ashmem** object created.| @@ -4218,7 +4585,8 @@ Obtains the memory size of this **Ashmem** object. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number | **Ashmem** size obtained.| @@ -4240,12 +4608,14 @@ Creates the shared file mapping on the virtual address space of this process. Th **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | mapType | number | Yes| Protection level of the memory region to which the shared file is mapped.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -4267,7 +4637,8 @@ Maps the shared file to the readable and writable virtual address space of the p **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -4289,7 +4660,8 @@ Maps the shared file to the read-only virtual address space of the process. **System capability**: SystemCapability.Communication.IPC.Core **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -4311,12 +4683,14 @@ Sets the protection level of the memory region to which the shared file is mappe **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | protectionType | number | Yes| Protection type to set.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -4338,14 +4712,16 @@ Writes data to the shared file associated with this **Ashmem** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | buf | number[] | Yes| Data to write.| | size | number | Yes| Size of the data to write.| | offset | number | Yes| Start position of the data to write in the memory region associated with this **Ashmem** object.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | boolean | Returns **true** is the data is written successfully; returns **false** otherwise.| @@ -4370,13 +4746,15 @@ Reads data from the shared file associated with this **Ashmem** object. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** - | Name| Type| Mandatory| Description| + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | size | number | Yes| Size of the data to read.| | offset | number | Yes| Start position of the data to read in the memory region associated with this **Ashmem** object.| **Return value** - | Type| Description| + + | Type| Description| | -------- | -------- | | number[] | Data read.| diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md index 8f88d00f0d246628e3669ae376da04191efedb92..550b62ed355d0a09eb57d17c5473c37cd7e45899 100644 --- a/en/application-dev/reference/apis/js-apis-screenshot.md +++ b/en/application-dev/reference/apis/js-apis-screenshot.md @@ -55,7 +55,7 @@ Describes the size of the screen region to capture. ## screenshot.save -save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>): void +save(options: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>): void Takes a screenshot and saves it as a **PixelMap** object. This API uses an asynchronous callback to return the result. @@ -67,7 +67,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses an async | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot settings consist of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set the parameters separately.| +| options | [ScreenshotOptions](#screenshotoptions) | Yes | Screenshot settings consist of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set the parameters separately.| | callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | Yes | Callback used to return a **PixelMap** object. | **Example** @@ -97,6 +97,35 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses an async ## screenshot.save +save(callback: AsyncCallback<image.PixelMap>): void + +Takes a screenshot and saves it as a **PixelMap** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Required permissions**: ohos.permission.CAPTURE_SCREEN (available only to system applications) + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | Yes | Callback used to return a **PixelMap** object. | + +**Example** + + ```js + screenshot.save((err, pixelMap) => { + if (err) { + console.log('Failed to save screenshot: ' + JSON.stringify(err)); + return; + } + console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // Release the memory in time after the PixelMap is used. + }); + ``` + +## screenshot.save + save(options?: ScreenshotOptions): Promise<image.PixelMap> Takes a screenshot and saves it as a **PixelMap** object. This API uses a promise to return the result. diff --git a/en/application-dev/reference/apis/js-apis-socket.md b/en/application-dev/reference/apis/js-apis-socket.md index b590efb7ca3455c95c3d217b86e741848c5ac547..77dd0bc0560d11837a5cfbb68f38fd3f39075310 100644 --- a/en/application-dev/reference/apis/js-apis-socket.md +++ b/en/application-dev/reference/apis/js-apis-socket.md @@ -1041,7 +1041,7 @@ promise1.then(() => { console.log('connect success'); let promise2 = tcp.getRemoteAddress(); promise2.then(() => { - console.log('getRemoteAddress success:' + JSON.stringify(data)); + console.log('getRemoteAddress success'); }).catch(err => { console.log('getRemoteAddressfail'); }); @@ -1120,7 +1120,7 @@ promise.then(() => { console.log('connect success'); let promise1 = tcp.getState(); promise1.then(() => { - console.log('getState success:' + JSON.stringify(data)); + console.log('getState success'); }).catch(err => { console.log('getState fail'); }); diff --git a/en/application-dev/reference/apis/js-apis-stack.md b/en/application-dev/reference/apis/js-apis-stack.md index b1e10e9478bc3335b30cd85498f9feb81b07bfd1..a55afd6a634b5cb284741507140f9a35cf38a527 100644 --- a/en/application-dev/reference/apis/js-apis-stack.md +++ b/en/application-dev/reference/apis/js-apis-stack.md @@ -10,6 +10,9 @@ Unlike **[Queue](js-apis-queue.md)**, which is implemented based on the queue da **Recommended use case**: Use **Stack** in LOFI scenarios. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -73,7 +76,7 @@ let result = stack.push("a"); let result1 = stack.push(1); let b = [1, 2, 3]; stack.push(b); -let c = {name : "lala", age : "13"}; +let c = {name : "Dylon", age : "13"}; let result3 = stack.push(c); ``` diff --git a/en/application-dev/reference/apis/js-apis-statfs.md b/en/application-dev/reference/apis/js-apis-statfs.md index fc9109b25611afe452ea32255267b036e71a45b0..b9cf5106d4369769056d0ad19ed0b4a37a75f553 100644 --- a/en/application-dev/reference/apis/js-apis-statfs.md +++ b/en/application-dev/reference/apis/js-apis-statfs.md @@ -18,26 +18,26 @@ Obtains the number of free bytes of the specified file system in asynchronous mo **System capability**: SystemCapability.FileManagement.File.FileIO -- **Parameters** +**Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------- | | path | string | Yes | File path of the file system.| -- Return value +**Return value** | Type | Description | | --------------------- | -------------- | | Promise<number> | Promise used to return the number of free bytes obtained.| -- Example +**Example** ```js let path = "/dev"; - statfs.getFreeBytes(path).then(function (number){ - console.info("getFreeBytes promise successfully:"+ number); - }).catch(function(err){ - console.info("getFreeBytes failed with error:"+ err); + statfs.getFreeBytes(path).then(function (number) { + console.info("getFreeBytes promise successfully:" + number); + }).catch(function (err) { + console.info("getFreeBytes failed with error:" + err); }); ``` @@ -49,21 +49,21 @@ Obtains the number of free bytes of the specified file system in asynchronous mo **System capability**: SystemCapability.FileManagement.File.FileIO -- **Parameters** +**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.| -- Example +**Example** ```js - import featureAbility from '@ohos.ability.featureAbility'; + import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getFilesDir().then(function (path) { - statfs.getFreeBytes(path, function(err, number){ - console.info("Got free bytes successfully:"+ number); + statfs.getFreeBytes(path, function (err, number) { + console.info("getFreeBytes callback successfully:" + number); }); }); ``` @@ -76,26 +76,26 @@ Obtains the total number of bytes of the specified file system in asynchronous m **System capability**: SystemCapability.FileManagement.File.FileIO -- **Parameters** +**Parameters** | Name| Type | Mandatory| Description | | ---- | ------ | ---- | ---------------------------- | | path | string | Yes | File path of the file system.| -- Return value +**Return value** | Type | Description | | --------------------- | ------------ | | Promise<number> | Promise used to return the total number of bytes obtained.| -- Example +**Example** ```js let path = "/dev"; - statfs.getTotalBytes(path).then(function (number){ - console.info("getTotalBytes promise successfully:"+ number); - }).catch(function(err){ - console.info("getTotalBytes failed with error:"+ err); + statfs.getTotalBytes(path).then(function (number) { + console.info("getTotalBytes promise successfully:" + number); + }).catch(function (err) { + console.info("getTotalBytes failed with error:" + err); }); ``` @@ -107,21 +107,21 @@ Obtains the total number of bytes of the specified file system in asynchronous m **System capability**: SystemCapability.FileManagement.File.FileIO -- **Parameters** +**Parameters** | 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. | -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getFilesDir().then(function (path) { - statfs.getTotalBytes(path, function(err, number){ - console.info("Got total bytes successfully:"+ number); + statfs.getTotalBytes(path, function(err, number) { + console.info("getTotalBytes callback successfully:" + number); }); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-system-cipher.md b/en/application-dev/reference/apis/js-apis-system-cipher.md index cd4100d455e6f47f6d2600562a4d0522c885284a..82be7501dfcef800ba7bd6db6fc9e3759ac05bfa 100644 --- a/en/application-dev/reference/apis/js-apis-system-cipher.md +++ b/en/application-dev/reference/apis/js-apis-system-cipher.md @@ -25,7 +25,7 @@ Encrypts or decrypts data using RSA. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| action | string | Yes| Action to perform. The options are as follows:
- encrypt
- decrypt| +| action | string | Yes| Action to perform. The options are as follows:
- encrypt
- decrypt | | text | string | Yes| Text to be encrypted or decrypted.
The text to be encrypted must be common text that meets the following requirement:
Maximum text length = Key length/8 - 66
For example, if the key is of 1024 bytes, the text to be encrypted cannot exceed 62 bytes (1024/8 -66 = 62).
The text to be decrypted must be binary text encoded in Base64. The default format is used for Base64 encoding.| | key | string | Yes| RSA key. The key is used as a public key in encryption and a private key in decryption.| | transformation | string | No| RSA padding. The default value is **RSA/None/OAEPWithSHA256AndMGF1Padding**.| @@ -109,7 +109,7 @@ Encrypts or decrypts data using AES. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| action | string | Yes| Action to perform. The options are as follows:
- encrypt
- decrypt| +| action | string | Yes| Action to perform. The options are as follows:
- encrypt
- decrypt | | text | string | Yes| Text to be encrypted or decrypted.
The text to be encrypted must be common text. The text to be decrypted must be binary text encoded in Base64. The default format is used for Base64 encoding.| | key | string | Yes| Key used for encryption or decryption. It is a string encoded in Base64.| | transformation | string | No| Encryption mode and padding of the AES algorithm. The default value is **AES/CBC/PKCS5Padding**.| @@ -165,7 +165,6 @@ export default { console.log(`operation complete!`); } }); - }); } } diff --git a/en/application-dev/reference/apis/js-apis-system-sensor.md b/en/application-dev/reference/apis/js-apis-system-sensor.md index a551dea9a8f79c5d153649ce69dc912f93ddd4b6..7df5f6675bb53168935ada36ca1d0675e49da978 100644 --- a/en/application-dev/reference/apis/js-apis-system-sensor.md +++ b/en/application-dev/reference/apis/js-apis-system-sensor.md @@ -21,9 +21,9 @@ import sensor from '@system.sensor'; ## Error Codes -| Error Code | Description | -| ---- | -------------- | -| 900 | The current device does not support the corresponding sensor.| +| Error Code | Description | +| ---------- | ---------------------------------------- | +| 900 | The current device does not support the corresponding sensor. | ## sensor.subscribeAccelerometer @@ -37,19 +37,19 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------- | ---- | ---------------------------------------- | -| interval | string | Yes | Execution frequency of the callback for returning the acceleration sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.| -| success | Function | Yes | Called when the acceleration sensor data changes. | -| fail | Function | No | Callback upon failure. | +| Name | Type | Mandatory | Description | +| -------- | -------- | --------- | ---------------------------------------- | +| interval | string | Yes | Execution frequency of the callback for returning the acceleration sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios. | +| success | Function | Yes | Called when the acceleration sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback -| Name | Type | Description | -| ---- | ------ | ------- | -| x | number | Acceleration on the x-axis.| -| y | number | Acceleration on the y-axis.| -| z | number | Acceleration on the z-axis.| +| Name | Type | Description | +| ---- | ------ | --------------------------- | +| x | number | Acceleration on the x-axis. | +| y | number | Acceleration on the y-axis. | +| z | number | Acceleration on the z-axis. | **Example** @@ -97,16 +97,16 @@ Subscribes to data changes of the compass sensor. If this API is called multiple **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | --------------- | -| success | Function | Yes | Called when the compass sensor data changes.| -| fail | Function | No | Callback upon failure. | +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the compass sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback -| Name | Type | Description | -| --------- | ------ | ---------- | -| direction | number | Direction of the device, in degrees.| +| Name | Type | Description | +| --------- | ------ | ------------------------------------ | +| direction | number | Direction of the device, in degrees. | **Example** @@ -149,16 +149,16 @@ Subscribes to data changes of the proximity sensor. If this API is called multip **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | ----------------- | -| success | Function | Yes | Called when the proximity sensor data changes.| -| fail | Function | No | Callback upon failure. | +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the proximity sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback -| Name | Type | Description | -| -------- | ------ | --------------------- | -| distance | number | Distance between a visible object and the device screen.| +| Name | Type | Description | +| -------- | ------ | ---------------------------------------- | +| distance | number | Distance between a visible object and the device screen. | **Example** @@ -201,16 +201,16 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | --------------- | -| success | Function | Yes | Called when the ambient light sensor data changes| -| fail | Function | No | Callback upon failure. | +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the ambient light sensor data changes | +| fail | Function | No | Callback upon failure. | Return values of the success callback -| Name | Type | Description | -| --------- | ------ | ------------ | -| intensity | number | Light intensity, in lux.| +| Name | Type | Description | +| --------- | ------ | ------------------------ | +| intensity | number | Light intensity, in lux. | **Example** @@ -255,16 +255,16 @@ Subscribes to data changes of the step counter sensor. If this API is called mul **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | ---------------- | -| success | Function | Yes | Called when the step counter sensor data changes.| -| fail | Function | No | Callback upon failure. | +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the step counter sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback -| Name | Type | Description | -| ----- | ------ | --------------------- | -| steps | number | Number of counted steps after the sensor is restarted.
| +| Name | Type | Description | +| ----- | ------ | ---------------------------------------- | +| steps | number | Number of counted steps after the sensor is restarted.
| **Example** @@ -302,7 +302,7 @@ sensor.unsubscribeStepCounter(); ## sensor.subscribeBarometer -subcribeBarometer(Object): void +subscribeBarometer(Object): void Subscribes to data changes of the barometer sensor. If this API is called multiple times for the same application, the last call takes effect. @@ -310,16 +310,16 @@ Subscribes to data changes of the barometer sensor. If this API is called multip **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | ---------------- | -| success | Function | Yes | Called when the barometer sensor data changes.| -| fail | Function | No | Callback upon failure. | +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the barometer sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback -| Name | Type | Description | -| -------- | ------ | ----------- | -| pressure | number | Pressure, in pascal.| +| Name | Type | Description | +| -------- | ------ | -------------------- | +| pressure | number | Pressure, in pascal. | **Example** @@ -366,16 +366,16 @@ Subscribes to data changes of the heart rate sensor. If this API is called multi **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | ------------------------- | -| success | Function | Yes | Called when the heart rate sensor data changes. This callback is invoked every five seconds.| -| fail | Function | No | Callback upon failure. | +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | ---------------------------------------- | +| success | Function | Yes | Called when the heart rate sensor data changes. This callback is invoked every five seconds. | +| fail | Function | No | Callback upon failure. | Return values of the success callback -| Name | Type | Description | -| --------- | ------ | ---- | -| heartRate | number | Heart rate.| +| Name | Type | Description | +| --------- | ------ | ----------- | +| heartRate | number | Heart rate. | **Example** @@ -421,16 +421,16 @@ Subscribes to changes of the wearing state of a wearable device. If this API is **Parameters** -| Name | Type | Mandatory | Description | -| ------- | -------- | ---- | ------------- | -| success | Function | Yes | Called when the wearing state changes.| -| fail | Function | No | Callback upon failure. | +| Name | Type | Mandatory | Description | +| ------- | -------- | --------- | -------------------------------------- | +| success | Function | Yes | Called when the wearing state changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback -| Name | Type | Description | -| ----- | ------- | ------ | -| value | boolean | Whether the wearable device is worn.| +| Name | Type | Description | +| ----- | ------- | ------------------------------------ | +| value | boolean | Whether the wearable device is worn. | **Example** @@ -473,17 +473,17 @@ Obtains the wearing state of a wearable device. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------- | ---- | ------------ | -| success | Function | No | Callback upon success.| -| fail | Function | No | Callback upon failure.| -| complete | Function | No | Called when the execution is complete.| +| Name | Type | Mandatory | Description | +| -------- | -------- | --------- | -------------------------------------- | +| success | Function | No | Callback upon success. | +| fail | Function | No | Callback upon failure. | +| complete | Function | No | Called when the execution is complete. | Return values of the success callback -| Name | Type | Description | -| ----- | ------- | ------ | -| value | boolean | Whether the wearable device is worn.| +| Name | Type | Description | +| ----- | ------- | ------------------------------------ | +| value | boolean | Whether the wearable device is worn. | **Example** @@ -510,18 +510,18 @@ If this API is called multiple times for the same application, the last call tak **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------- | ---- | ---------------------------------------- | -| interval | string | Yes | Interval at which the callback is invoked to return the device orientation sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.| -| success | Function | Yes | Called when the device orientation sensor data changes. | -| fail | Function | No | Callback upon failure. | +| Name | Type | Mandatory | Description | +| -------- | -------- | --------- | ---------------------------------------- | +| interval | string | Yes | Interval at which the callback is invoked to return the device orientation sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios. | +| success | Function | Yes | Called when the device orientation sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback -| Name | Type | Description | +| Name | Type | Description | | ----- | ------ | ---------------------------------------- | -| alpha | number | Rotation angle around the Z axis when the X/Y axis of the device coincides with the X/Y axis of the earth.| -| beta | number | Rotation angle around the X axis when the Y/Z axis of the device coincides with the Y/Z axis of the earth.| -| gamma | number | Rotation angle around the Y axis when the X/Z axis of the device coincides with the X/Z axis of the earth.| +| alpha | number | Rotation angle around the Z axis when the X/Y axis of the device coincides with the X/Y axis of the earth. | +| beta | number | Rotation angle around the X axis when the Y/Z axis of the device coincides with the Y/Z axis of the earth. | +| gamma | number | Rotation angle around the Y axis when the X/Z axis of the device coincides with the X/Z axis of the earth. | **Example** @@ -571,19 +571,19 @@ If this API is called multiple times for the same application, the last call tak **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------- | ---- | ---------------------------------------- | -| interval | string | Yes | Interval at which the callback is invoked to return the gyroscope sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios.| -| success | Function | Yes | Called when the gyroscope sensor data changes. | -| fail | Function | No | Callback upon failure. | +| Name | Type | Mandatory | Description | +| -------- | -------- | --------- | ---------------------------------------- | +| interval | string | Yes | Interval at which the callback is invoked to return the gyroscope sensor data.
The default value is **normal**. The options are as follows:
- **game**: called at an interval of 20 ms, which is applicable to gaming scenarios.
- **ui**: called at an interval of 60 ms, which is applicable to UI updating scenarios.
- **normal**: called at an interval of 200 ms, which is applicable to power-saving scenarios. | +| success | Function | Yes | Called when the gyroscope sensor data changes. | +| fail | Function | No | Callback upon failure. | Return values of the success callback -| Name | Type | Description | -| ---- | ------ | --------- | -| x | number | Rotation angular velocity of the X axis.| -| y | number | Rotation angular velocity of the Y axis.| -| z | number | Rotation angular velocity of the Z axis.| +| Name | Type | Description | +| ---- | ------ | ---------------------------------------- | +| x | number | Rotation angular velocity of the X axis. | +| y | number | Rotation angular velocity of the Y axis. | +| z | number | Rotation angular velocity of the Z axis. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-testRunner.md b/en/application-dev/reference/apis/js-apis-testRunner.md index bc65de36ea0283d025deb74006dd428d7adefbd7..c82668961c8cf23f5b523024842a786dc4d0979f 100644 --- a/en/application-dev/reference/apis/js-apis-testRunner.md +++ b/en/application-dev/reference/apis/js-apis-testRunner.md @@ -29,7 +29,7 @@ export default class UserTestRunner implements TestRunner { onPrepare() { console.log("Trigger onPrepare") } -onRun(){} + onRun(){} }; ``` @@ -50,6 +50,6 @@ export default class UserTestRunner implements TestRunner { onPrepare() { console.log("Trigger onRun") } -onRun(){} + onRun(){} }; ``` diff --git a/en/application-dev/reference/apis/js-apis-treemap.md b/en/application-dev/reference/apis/js-apis-treemap.md index 7914e5bd409d29b3bcae14653aaa6bd8dd5f6f9c..001b08610c59f25b384c9fc3ada4c74f152b9313 100644 --- a/en/application-dev/reference/apis/js-apis-treemap.md +++ b/en/application-dev/reference/apis/js-apis-treemap.md @@ -12,6 +12,10 @@ Recommended use case: Use **TreeMap** when you need to store KV pairs in sorted order. +This topic uses the following to identify the use of generics: +- K: Key +- V: Value + ## Modules to Import ```ts @@ -96,9 +100,9 @@ Checks whether this container has the specified key. ```ts let treeMap = new TreeMap(); -let result = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -let result1 = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = treeMap.hasKey("squirrel"); +treeMap.set("squirrel", 123); +let result1 = treeMap.hasKey("squirrel"); ``` @@ -127,7 +131,7 @@ Checks whether this container has the specified value. ```ts let treeMap = new TreeMap(); let result = treeMap.hasValue(123); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("squirrel", 123); let result1 = treeMap.hasValue(123); ``` @@ -156,9 +160,9 @@ Obtains the value of the specified key in this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); -let result = treeMap.get("sdfs"); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); +let result = treeMap.get("sparrow"); ``` @@ -180,8 +184,8 @@ Obtains the first key in this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); let result = treeMap.getFirstKey(); ``` @@ -204,8 +208,8 @@ Obtains the last key in this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); let result = treeMap.getLastKey(); ``` @@ -228,8 +232,8 @@ Adds all elements in a **TreeMap** instance to this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); let map = new TreeMap(); treeMap.setAll(map); ``` @@ -260,7 +264,7 @@ Adds an element to this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("squirrel", 123); ``` @@ -288,9 +292,9 @@ Removes the element with the specified key from this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); -treeMap.remove("sdfs"); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); +treeMap.remove("sparrow"); ``` @@ -318,10 +322,10 @@ Obtains the key that is placed in front of the input key in this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); -treeMap.set("zdfgsd", 356); -let result = treeMap.getLowerKey("sdfs"); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); +treeMap.set("gander", 356); +let result = treeMap.getLowerKey("sparrow"); ``` @@ -349,10 +353,10 @@ Obtains the key that is placed next to the input key in this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); -treeMap.set("zdfgsd", 356); -let result = treeMap.getHigherKey("sdfs"); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); +treeMap.set("gander", 356); +let result = treeMap.getHigherKey("sparrow"); ``` ### replace @@ -380,8 +384,8 @@ Replaces an element in this container. ```ts let treeMap = new TreeMap(); -treeMap.set("sdfs", 123); -let result = treeMap.replace("sdfs", 357); +treeMap.set("sparrow", 123); +let result = treeMap.replace("sparrow", 357); ``` @@ -397,8 +401,8 @@ Clears this container and sets its length to **0**. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); treeMap.clear(); ``` @@ -421,8 +425,8 @@ Obtains an iterator that contains all the keys in this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); let iter = treeMap.keys(); let temp = iter.next().value; while(temp != undefined) { @@ -450,8 +454,8 @@ Obtains an iterator that contains all the values in this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); let iter = treeMap.values(); let temp = iter.next().value; while(temp != undefined) { @@ -487,8 +491,8 @@ callbackfn ```ts let treeMap = new TreeMap(); -treeMap.set("sdfs", 123); -treeMap.set("dfsghsf", 357); +treeMap.set("sparrow", 123); +treeMap.set("gull", 357); treeMap.forEach((value, key) => { console.log("value:" + value, key); }); @@ -513,8 +517,8 @@ Obtains an iterator that contains all the elements in this container. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); let iter = treeMap.entries(); let temp = iter.next().value; while(temp != undefined) { @@ -542,8 +546,8 @@ Obtains an iterator, each item of which is a JavaScript object. ```ts let treeMap = new TreeMap(); -treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.set("sdfs", 356); +treeMap.set("squirrel", 123); +treeMap.set("sparrow", 356); // Method 1: for (let item of treeMap) { diff --git a/en/application-dev/reference/apis/js-apis-treeset.md b/en/application-dev/reference/apis/js-apis-treeset.md index 6e50abcf23c7cf2c3a77e6029244a0078edd1562..9391eb15c944bfa5170c28e4bd1976c346a3356a 100644 --- a/en/application-dev/reference/apis/js-apis-treeset.md +++ b/en/application-dev/reference/apis/js-apis-treeset.md @@ -10,6 +10,9 @@ Recommended use case: Use **TreeSet** when you need to store data in sorted order. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -29,7 +32,7 @@ import TreeSet from '@ohos.util.TreeSet'; ### constructor -constructor(comparator?:(firstValue: T, secondValue: T) => boolean) +constructor(comparator?: (firstValue: T, secondValue: T) => boolean) A constructor used to create a **TreeSet** instance. @@ -118,8 +121,8 @@ Obtains the value of the first element in this container. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); let result = treeSet.getFirstValue(); ``` @@ -142,8 +145,8 @@ Obtains the value of the last element in this container. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); let result = treeSet.getLastValue(); ``` @@ -172,7 +175,7 @@ Adds an element to this container. ```ts let treeSet = new TreeSet(); -let result = treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = treeSet.add("squirrel"); ``` @@ -200,9 +203,9 @@ Removes the element with the specified key from this container. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); -let result = treeSet.remove("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); +let result = treeSet.remove("sparrow"); ``` @@ -230,10 +233,10 @@ Obtains the value that is placed in front of the input key in this container. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); -treeSet.add("zdfgsd"); -let result = treeSet.getLowerValue("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); +treeSet.add("gander"); +let result = treeSet.getLowerValue("sparrow"); ``` @@ -261,10 +264,10 @@ Obtains the value that is placed next to the input key in this container. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); -treeSet.add("zdfgsd"); -let result = treeSet.getHigherValue("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); +treeSet.add("gander"); +let result = treeSet.getHigherValue("sparrow"); ``` @@ -286,8 +289,8 @@ Removes the first element in this container. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); let result = treeSet.popFirst(); ``` @@ -310,8 +313,8 @@ Removes the last element in this container. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); let result = treeSet.popLast(); ``` @@ -328,8 +331,8 @@ Clears this container and sets its length to **0**. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); treeSet.clear(); ``` @@ -352,8 +355,8 @@ Obtains an iterator that contains all the values in this container. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); let iter = treeSet.values(); let temp = iter.next().value; while(temp != undefined) { @@ -389,8 +392,8 @@ callbackfn ```ts let treeSet = new TreeSet(); -treeSet.add("sdfs"); -treeSet.add("dfsghsf"); +treeSet.add("sparrow"); +treeSet.add("gull"); treeSet.forEach((value, key) => { console.log("value:" + value, key) }); @@ -415,8 +418,8 @@ Obtains an iterator that contains all the elements in this container. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); let iter = treeSet.entries(); let temp = iter.next().value; while(temp != undefined) { @@ -445,8 +448,8 @@ Obtains an iterator, each item of which is a JavaScript object. ```ts let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -treeSet.add("sdfs"); +treeSet.add("squirrel"); +treeSet.add("sparrow"); // Method 1: for (let item of treeSet) { diff --git a/en/application-dev/reference/apis/js-apis-vector.md b/en/application-dev/reference/apis/js-apis-vector.md index 5dd8e49bb0c2467b2885784b9c1281f61e46a003..24fc9e14ffe48ebbfd672aa73218c2110757c3d8 100644 --- a/en/application-dev/reference/apis/js-apis-vector.md +++ b/en/application-dev/reference/apis/js-apis-vector.md @@ -10,6 +10,9 @@ Both **Vector** and **[ArrayList](js-apis-arraylist.md)** are implemented based **Recommended use case**: Use **Vector** when the data volume is large. +This topic uses the following to identify the use of generics: +- T: Type + ## Modules to Import ```ts @@ -71,7 +74,7 @@ let result = vector.add("a"); let result1 = vector.add(1); let b = [1, 2, 3]; vector.add(b); -let c = {name : "lala", age : "13"}; +let c = {name : "Dylon", age : "13"}; let result3 = vector.add(c); ``` @@ -123,9 +126,9 @@ Checks whether this container has the specified element. ```ts let vector = new Vector(); -let result = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -vector.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -let result1 = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = vector.has("squirrel"); +vector.add("squirrel"); +let result1 = vector.has("squirrel"); ``` ### getIndexOf @@ -862,7 +865,6 @@ Obtains an iterator. Each item of the iterator is a JavaScript object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type| Description| | -------- | -------- | | IterableIterator<T> | Iterator obtained.| diff --git a/en/application-dev/reference/apis/js-apis-wifi.md b/en/application-dev/reference/apis/js-apis-wifi.md index ae5ab4c9b924e6b72457a9bbadec1cfd26ef5e6b..7f5b41145c5831f3ecd0014687a52366b598f9d4 100644 --- a/en/application-dev/reference/apis/js-apis-wifi.md +++ b/en/application-dev/reference/apis/js-apis-wifi.md @@ -25,9 +25,9 @@ Enables WLAN. **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.| ## wifi.disableWifi @@ -44,9 +44,9 @@ Disables WLAN. **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.| ## wifi.isWifiActive @@ -61,9 +61,9 @@ Checks whether WLAN is enabled. **Return value** - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if WLAN is enabled; returns **false** otherwise.| +| **Type**| **Description**| +| -------- | -------- | +| boolean | Returns **true** if WLAN is enabled; returns **false** otherwise.| ## wifi.scan @@ -78,9 +78,9 @@ Starts a scan for WLAN. **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.| ## wifi.getScanInfos @@ -95,9 +95,9 @@ Obtains the scan result. This API uses a promise to return the result. **Return value** - | **Type**| **Description**| - | -------- | -------- | - | Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the detected hotspots.| +| **Type**| **Description**| +| -------- | -------- | +| Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the detected hotspots.| ## wifi.getScanInfos @@ -112,9 +112,9 @@ Obtains the scan result. This API uses an asynchronous callback to return the re **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the detected hotspots. Otherwise, **err** is a non-zero value and **data** is empty.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the detected hotspots. Otherwise, **err** is a non-zero value and **data** is empty.| **Example** ```js @@ -247,9 +247,9 @@ Obtains the scan result. This API returns the result synchronously. **Return value** - | **Type**| **Description**| - | -------- | -------- | - |  Array<[WifiScanInfo](#wifiscaninfo)> | Scan result obtained.| +| **Type**| **Description**| +| -------- | -------- | +|  Array<[WifiScanInfo](#wifiscaninfo)> | Scan result obtained.| ## wifi.addDeviceConfig @@ -266,15 +266,15 @@ Adds network configuration. This API uses a promise to return the result. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | Promise<number> | Promise used to return the WLAN configuration ID. If **-1** is returned, the operation has failed.| +| **Type**| **Description**| +| -------- | -------- | +| Promise<number> | Promise used to return the WLAN configuration ID. If **-1** is returned, the operation has failed.| ## WifiDeviceConfig @@ -412,10 +412,10 @@ Adds network configuration. This API uses an asynchronous callback to return the **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| - | callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the network configuration ID. If **data** is **-1**, the operation has failed. If **err** is not **0**, an error has occurred.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| +| callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the network configuration ID. If **data** is **-1**, the operation has failed. If **err** is not **0**, an error has occurred.| ## wifi.addUntrustedConfig7+ @@ -430,15 +430,15 @@ Adds the configuration of an untrusted network. This API uses a promise to retur **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | Promise<boolean> | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.| +| **Type**| **Description**| +| -------- | -------- | +| Promise<boolean> | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.| ## wifi.addUntrustedConfig7+ @@ -453,10 +453,10 @@ Adds the configuration of an untrusted network. This API uses an asynchronous ca **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| - | callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is **true**. If the operation fails, **data** is **false**. If **err** is not **0**, an error has occurred.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| +| callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is **true**. If the operation fails, **data** is **false**. If **err** is not **0**, an error has occurred.| ## wifi.removeUntrustedConfig7+ @@ -471,15 +471,15 @@ Removes the configuration of an untrusted network. This API uses a promise to re **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to remove.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to remove.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | Promise<boolean> | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.| +| **Type**| **Description**| +| -------- | -------- | +| Promise<boolean> | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.| ## wifi.removeUntrustedConfig7+ @@ -494,10 +494,10 @@ Removes the configuration of an untrusted network. This API uses an asynchronous **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to remove.| - | callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is **true**. If the operation fails, **data** is **false**. If **err** is not **0**, an error has occurred.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to remove.| +| callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is **true**. If the operation fails, **data** is **false**. If **err** is not **0**, an error has occurred.| ## wifi.addCandidateConfig9+ @@ -512,15 +512,15 @@ Adds the configuration of a candidate network. This API uses a promise to return **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | Promise<number> | Promise used to return the network configuration ID.| +| **Type**| **Description**| +| -------- | -------- | +| Promise<number> | Promise used to return the network configuration ID.| ## wifi.addCandidateConfig9+ @@ -535,10 +535,10 @@ Adds the configuration of a candidate network. This API uses an asynchronous cal **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| - | callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the network configuration ID. If **data** is **-1**, the operation has failed. If **err** is not **0**, an error has occurred.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| +| callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the network configuration ID. If **data** is **-1**, the operation has failed. If **err** is not **0**, an error has occurred.| ## wifi.removeCandidateConfig9+ @@ -553,15 +553,15 @@ Removes the configuration of a candidate network. This API uses a promise to ret **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | networkId | number | Yes| ID of the network configuration to remove.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| networkId | number | Yes| ID of the network configuration to remove.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| **Type**| **Description**| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| ## wifi.removeCandidateConfig9+ @@ -576,10 +576,10 @@ Removes the configuration of a candidate network. This API uses an asynchronous **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | networkId | number | Yes| ID of the network configuration to remove.| - | callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the operation is successful, the value of **err** is **0**. If **err** is not **0**, an error has occurred.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| networkId | number | Yes| ID of the network configuration to remove.| +| callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the operation is successful, the value of **err** is **0**. If **err** is not **0**, an error has occurred.| ## wifi.getCandidateConfigs9+ @@ -594,9 +594,9 @@ Obtains candidate network configuration. **Return value** - | **Type**| **Description**| - | -------- | -------- | - |  Array<[WifiDeviceConfig](#wifideviceconfig)> | Candidate network configuration obtained.| +| **Type**| **Description**| +| -------- | -------- | +|  Array<[WifiDeviceConfig](#wifideviceconfig)> | Candidate network configuration obtained.| ## wifi.connectToCandidateConfig9+ @@ -611,9 +611,9 @@ Connects to a candidate network. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | networkId | number | Yes| ID of the candidate network configuration.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| networkId | number | Yes| ID of the candidate network configuration.| ## wifi.connectToNetwork @@ -630,15 +630,15 @@ Connects to the specified network. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | networkId | number | Yes| Network configuration ID.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| networkId | number | Yes| Network configuration ID.| **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.| ## wifi.connectToDevice @@ -656,15 +656,15 @@ Connects to the specified network. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration.| **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.| ## wifi.disconnect @@ -682,9 +682,9 @@ Disconnects the network. **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.| ## wifi.getSignalLevel @@ -699,16 +699,16 @@ Obtains the WLAN signal level. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | rssi | number | Yes| RSSI of the hotspot, in dBm.| - | band | number | Yes| Frequency band of the WLAN AP.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| rssi | number | Yes| RSSI of the hotspot, in dBm.| +| band | number | Yes| Frequency band of the WLAN AP.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | number | Signal level obtained. The value range is [0, 4].| +| **Type**| **Description**| +| -------- | -------- | +| number | Signal level obtained. The value range is [0, 4].| ## wifi.getLinkedInfo @@ -723,9 +723,9 @@ Obtains WLAN connection information. This API uses a promise to return the resul **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[WifiLinkedInfo](#wifilinkedinfo)> | Promise used to return the WLAN connection information obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[WifiLinkedInfo](#wifilinkedinfo)> | Promise used to return the WLAN connection information obtained.| ## wifi.getLinkedInfo @@ -740,9 +740,9 @@ Obtains WLAN connection information. This API uses an asynchronous callback to r **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiLinkedInfo](#wifilinkedinfo)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the WLAN connection information obtained. If **err** is not **0**, an error has occurred.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[WifiLinkedInfo](#wifilinkedinfo)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the WLAN connection information obtained. If **err** is not **0**, an error has occurred.| **Example** ```js @@ -844,9 +844,9 @@ Checks whether the WLAN is connected. **Return value** - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.| +| **Type**| **Description**| +| -------- | -------- | +| boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.| ## wifi.getSupportedFeatures7+ @@ -863,24 +863,24 @@ Obtains the features supported by this device. **Return value** - | **Type**| **Description**| - | -------- | -------- | - | number | Feature value. | +| **Type**| **Description**| +| -------- | -------- | +| number | Feature value. | **Feature IDs** | Value| Description| | -------- | -------- | -| 0x0001 | WLAN infrastructure mode| -| 0x0002 | 5 GHz feature| -| 0x0004 | Generic Advertisement Service (GAS)/Access Network Query Protocol (ANQP) feature| -| 0x0008 | Wi-Fi Direct| -| 0x0010 | SoftAP| -| 0x0040 | Wi-Fi AWare| -| 0x8000 | WLAN AP/STA concurrency| -| 0x8000000 | WPA3 Personal (WPA-3 SAE)| -| 0x10000000 | WPA3-Enterprise Suite B | -| 0x20000000 | Enhanced open feature| +| 0x0001 | WLAN infrastructure mode. | +| 0x0002 | 5 GHz feature. | +| 0x0004 | Generic Advertisement Service (GAS)/Access Network Query Protocol (ANQP) feature. | +| 0x0008 | Wi-Fi Direct. | +| 0x0010 | SoftAP. | +| 0x0040 | Wi-Fi AWare. | +| 0x8000 | WLAN AP/STA concurrency. | +| 0x8000000 | WPA3 Personal (WPA-3 SAE). | +| 0x10000000 | WPA3-Enterprise Suite B. | +| 0x20000000 | Enhanced open feature. | ## wifi.isFeatureSupported7+ @@ -896,15 +896,15 @@ Checks whether the device supports the specified WLAN feature. **Parameters** - | **Name**| **Type**| Mandatory| **Description**| - | -------- | -------- | -------- | -------- | - | featureId | number | Yes| Feature ID.| +| **Name**| **Type**| Mandatory| **Description**| +| -------- | -------- | -------- | -------- | +| featureId | number | Yes| Feature ID.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if the feature is supported; returns **false** otherwise.| +| **Type**| **Description**| +| -------- | -------- | +| boolean | Returns **true** if the feature is supported; returns **false** otherwise.| ## wifi.getDeviceMacAddress7+ @@ -921,9 +921,9 @@ Obtains the device MAC address. **Return value** - | **Type**| **Description**| - | -------- | -------- | - | string[] | MAC address obtained.| +| **Type**| **Description**| +| -------- | -------- | +| string[] | MAC address obtained.| ## wifi.getIpInfo7+ @@ -938,9 +938,9 @@ Obtains IP information. **Return value** - | **Type**| **Description**| - | -------- | -------- | - | [IpInfo](#ipinfo7) | IP information obtained.| +| **Type**| **Description**| +| -------- | -------- | +| [IpInfo](#ipinfo7) | IP information obtained.| ## IpInfo7+ @@ -972,9 +972,9 @@ Obtains the country code. **Return value** - | **Type**| **Description**| - | -------- | -------- | - | string | Country code obtained.| +| **Type**| **Description**| +| -------- | -------- | +| string | Country code obtained.| ## wifi.reassociate7+ @@ -991,9 +991,9 @@ Re-associates with the network. **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.| ## wifi.reconnect7+ @@ -1010,9 +1010,9 @@ Reconnects to the network. **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.| ## wifi.getDeviceConfigs7+ @@ -1029,9 +1029,9 @@ Obtains network configuration. **Return value** - | **Type**| **Description**| - | -------- | -------- | - |  Array<[WifiDeviceConfig](#wifideviceconfig)> | Array of network configuration obtained.| +| **Type**| **Description**| +| -------- | -------- | +|  Array<[WifiDeviceConfig](#wifideviceconfig)> | Array of network configuration obtained.| ## wifi.updateNetwork7+ @@ -1048,15 +1048,15 @@ Updates network configuration. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| New WLAN configuration.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| New WLAN configuration.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | number | ID of the updated network configuration. The value **-1** indicates that the operation has failed.| +| **Type**| **Description**| +| -------- | -------- | +| number | ID of the updated network configuration. The value **-1** indicates that the operation has failed.| ## wifi.disableNetwork7+ @@ -1073,15 +1073,15 @@ Disables network configuration. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | netId | number | Yes| ID of the network configuration to disable.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| netId | number | Yes| ID of the network configuration to disable.| **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.| ## wifi.removeAllNetwork7+ @@ -1098,9 +1098,9 @@ Removes the configuration of all networks. **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.| ## wifi.removeDevice7+ @@ -1117,15 +1117,15 @@ Removes the specified network configuration. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | id | number | Yes| ID of the network configuration to remove.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| id | number | Yes| ID of the network configuration to remove.| **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.| ## wifi.enableHotspot7+ @@ -1142,9 +1142,9 @@ Enables this hotspot. **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.| ## wifi.disableHotspot7+ @@ -1161,9 +1161,9 @@ Disables this hotspot. **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.| ## wifi.isHotspotDualBandSupported7+ @@ -1180,9 +1180,9 @@ Checks whether the hotspot supports dual band. **Return value** - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if the feature is supported; returns **false** otherwise.| +| **Type**| **Description**| +| -------- | -------- | +| boolean | Returns **true** if the feature is supported; returns **false** otherwise.| ## wifi.isHotspotActive7+ @@ -1199,9 +1199,9 @@ Checks whether this hotspot is active. **Return value** - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if the hotspot is active; returns **false** otherwise.| +| **Type**| **Description**| +| -------- | -------- | +| boolean | Returns **true** if the hotspot is active; returns **false** otherwise.| ## wifi.setHotspotConfig7+ @@ -1218,15 +1218,15 @@ Sets hotspot configuration. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [HotspotConfig](#hotspotconfig7) | Yes| Hotspot configuration to set.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [HotspotConfig](#hotspotconfig7) | Yes| Hotspot configuration to set.| **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.| ## HotspotConfig7+ @@ -1260,9 +1260,9 @@ obtains hotspot configuration. **Return value** - | **Type**| **Description**| - | -------- | -------- | - | [HotspotConfig](#hotspotconfig7) | Hotspot configuration obtained.| +| **Type**| **Description**| +| -------- | -------- | +| [HotspotConfig](#hotspotconfig7) | Hotspot configuration obtained.| ## wifi.getStations7+ @@ -1279,9 +1279,9 @@ Obtains information about the connected stations. **Return value** - | **Type**| **Description**| - | -------- | -------- | - |  Array<[StationInfo](#stationinfo7)> | Connected stations obtained.| +| **Type**| **Description**| +| -------- | -------- | +|  Array<[StationInfo](#stationinfo7)> | Connected stations obtained.| ## StationInfo7+ @@ -1311,9 +1311,9 @@ Obtains P2P link information. This API uses a promise to return the result. **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Promise used to return the P2P link information obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Promise used to return the P2P link information obtained.| @@ -1354,9 +1354,9 @@ Obtains P2P link information. This API uses an asynchronous callback to return t **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the P2P link information. If **err** is not **0**, an error has occurred.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the P2P link information. If **err** is not **0**, an error has occurred.| ## wifi.getCurrentGroup8+ @@ -1371,9 +1371,9 @@ Obtains the current P2P group information. This API uses a promise to return the **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> | Promise used to return the group information obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> | Promise used to return the group information obtained.| ## wifi.getCurrentGroup8+ @@ -1388,9 +1388,9 @@ Obtains the current P2P group information. This API uses an asynchronous callbac **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the group information obtained. If **err** is not **0**, an error has occurred.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the group information obtained. If **err** is not **0**, an error has occurred.| ## wifi.getP2pPeerDevices8+ @@ -1405,9 +1405,9 @@ Obtains the peer device list in the P2P connection. This API uses a promise to r **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[WifiP2pDevice[]](#wifip2pdevice8)> | Promise used to return the peer device list.| +| Type| Description| +| -------- | -------- | +| Promise<[WifiP2pDevice[]](#wifip2pdevice8)> | Promise used to return the peer device list.| ## wifi.getP2pPeerDevices8+ @@ -1422,9 +1422,9 @@ Obtains the peer device list in the P2P connection. This API uses an asynchronou **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pDevice[]](#wifip2pdevice8)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the peer device list obtained. If **err** is not **0**, an error has occurred.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[WifiP2pDevice[]](#wifip2pdevice8)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the peer device list obtained. If **err** is not **0**, an error has occurred.| ## WifiP2pDevice8+ @@ -1469,9 +1469,9 @@ Obtains the local device information in the P2P connection. This API uses a prom **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[WifiP2pDevice](#wifip2pdevice8)> | Promise used to return the local device information obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[WifiP2pDevice](#wifip2pdevice8)> | Promise used to return the local device information obtained.| ## wifi.getP2pLocalDevice9+ @@ -1486,9 +1486,9 @@ Obtains the local device information in the P2P connection. This API uses an asy **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pDevice](#wifip2pdevice8)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the local device information obtained. If **err** is not **0**, an error has occurred.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[WifiP2pDevice](#wifip2pdevice8)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the local device information obtained. If **err** is not **0**, an error has occurred.| ## wifi.createGroup8+ @@ -1503,15 +1503,15 @@ Creates a P2P group. **Parameters** - | **Name**| **Type**| Mandatory| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiP2PConfig](#wifip2pconfig8) | Yes| Group configuration.| +| **Name**| **Type**| Mandatory| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiP2PConfig](#wifip2pconfig8) | Yes| Group configuration.| **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.| ## WifiP2PConfig8+ @@ -1554,9 +1554,9 @@ Removes this P2P group. **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.| ## wifi.p2pConnect8+ @@ -1572,15 +1572,15 @@ Sets up a P2P connection. **Parameters** - | **Name**| **Type**| Mandatory| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiP2PConfig](#wifip2pconfig8) | Yes| P2P group configuration.| +| **Name**| **Type**| Mandatory| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiP2PConfig](#wifip2pconfig8) | Yes| P2P group configuration.| **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** @@ -1662,9 +1662,9 @@ Cancels this P2P connection. **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.| ## wifi.startDiscoverDevices8+ @@ -1679,9 +1679,9 @@ Starts to discover devices. **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.| ## wifi.stopDiscoverDevices8+ @@ -1696,9 +1696,9 @@ Stops discovering devices. **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.| ## wifi.deletePersistentGroup8+ @@ -1716,15 +1716,15 @@ Deletes a persistent group. **Parameters** - | **Name**| **Type**| Mandatory| **Description**| - | -------- | -------- | -------- | -------- | - | netId | number | Yes| ID of the group to delete.| +| **Name**| **Type**| Mandatory| **Description**| +| -------- | -------- | -------- | -------- | +| netId | number | Yes| ID of the group to delete.| **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.| ## wifi.getP2pGroups9+ @@ -1741,9 +1741,9 @@ Obtains information about all P2P groups. This API uses a promise to return the **Return value** - | Type| Description| - | -------- | -------- | - | Promise< Array<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> > | Promise used to return the group information obtained.| +| Type| Description| +| -------- | -------- | +| Promise< Array<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> > | Promise used to return the group information obtained.| ## WifiP2pGroupInfo8+ @@ -1779,9 +1779,9 @@ Obtains information about all P2P groups. This API uses an asynchronous callback **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback< Array<[WifiP2pGroupInfo](#wifip2pgroupinfo8)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the group information obtained. If **err** is not **0**, an error has occurred.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback< Array<[WifiP2pGroupInfo](#wifip2pgroupinfo8)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the group information obtained. If **err** is not **0**, an error has occurred.| ## wifi.setDeviceName8+ @@ -1798,15 +1798,15 @@ Sets the device name. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | devName | string | Yes| Device name to set.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| devName | string | Yes| Device name to set.| **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.| ## wifi.on('wifiStateChange')7+ @@ -1821,19 +1821,19 @@ Registers the WLAN state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiStateChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the WLAN state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiStateChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the WLAN state.| **WLAN states** | **Value**| **Description**| | -------- | -------- | -| 0 | Deactivated| -| 1 | Activated| -| 2 | Activating| -| 3 | Deactivating| +| 0 | Deactivated. | +| 1 | Activated. | +| 2 | Activating. | +| 3 | Deactivating. | ## wifi.off('wifiStateChange')7+ @@ -1848,25 +1848,24 @@ Unregisters the WLAN state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiStateChange**.| - | callback | Callback<number> | No| Callback used to return the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiStateChange**.| +| callback | Callback<number> | No| Callback used to return the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| **Example** ```js import wifi from '@ohos.wifi'; - var WIFI_POWER_STATE = "wifiStateChange"; var recvPowerNotifyFunc = result => { console.info("Receive power state change event: " + result); } // Register an event. - wifi.on(WIFI_POWER_STATE, recvPowerNotifyFunc); + wifi.on("wifiStateChange", recvPowerNotifyFunc); // Unregister an event. - wifi.off(WIFI_POWER_STATE, recvPowerNotifyFunc); + wifi.off("wifiStateChange", recvPowerNotifyFunc); ``` @@ -1882,17 +1881,17 @@ Registers the WLAN connection state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiConnectionChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the WLAN connection state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiConnectionChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the WLAN connection state.| **WLAN connection states** | **Value**| **Description**| | -------- | -------- | -| 0 | Disconnected| -| 1 | Connected| +| 0 | Disconnected.| +| 1 | Connected.| ## wifi.off('wifiConnectionChange')7+ @@ -1907,10 +1906,10 @@ Unregisters the WLAN connection state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiConnectionChange**.| - | callback | Callback<number> | No| Callback used to return the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiConnectionChange**.| +| callback | Callback<number> | No| Callback used to return the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('wifiScanStateChange')7+ @@ -1925,17 +1924,17 @@ Registers the WLAN scan state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiScanStateChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the WLAN scan state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiScanStateChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the WLAN scan state.| **WLAN scan states** | **Value**| **Description**| | -------- | -------- | -| 0 | Scan failed| -| 1 | Scan successful| +| 0 | Scan failed.| +| 1 | Scan successful.| ## wifi.off('wifiScanStateChange')7+ @@ -1968,10 +1967,10 @@ Registers the RSSI change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiRssiChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the RSSI, in dBm.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiRssiChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the RSSI, in dBm.| ## wifi.off('wifiRssiChange')7+ @@ -1986,10 +1985,10 @@ Unregisters the RSSI change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiRssiChange**.| - | callback | Callback<number> | No| Callback used to return the RSSI. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiRssiChange**.| +| callback | Callback<number> | No| Callback used to return the RSSI. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('hotspotStateChange')7+ @@ -2004,19 +2003,19 @@ Registers the hotspot state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **hotspotStateChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the hotspot state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **hotspotStateChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the hotspot state.| **Hotspot states** | **Value**| **Description**| | -------- | -------- | -| 0 | Deactivated| -| 1 | Activated| -| 2 | Activating| -| 3 | Deactivating| +| 0 | Deactivated. | +| 1 | Activated. | +| 2 | Activating. | +| 3 | Deactivating. | ## wifi.off('hotspotStateChange')7+ @@ -2031,10 +2030,10 @@ Unregisters the hotspot state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **hotspotStateChange**.| - | callback | Callback<number> | No| Callback used to return the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **hotspotStateChange**.| +| callback | Callback<number> | No| Callback used to return the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pStateChange')8+ @@ -2049,20 +2048,20 @@ Registers the P2P state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pStateChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the P2P state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pStateChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the P2P state.| **P2P states** | **Value**| **Description**| | -------- | -------- | -| 1 | Available| -| 2 | Opening| -| 3 | Opened| -| 4 | Closing| -| 5 | Closed| +| 1 | Available. | +| 2 | Opening. | +| 3 | Opened. | +| 4 | Closing. | +| 5 | Closed. | ## wifi.off('p2pStateChange')8+ @@ -2076,10 +2075,10 @@ Unregisters the P2P state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pStateChange**.| - | callback | Callback<number> | No| Callback used to return the P2P state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pStateChange**.| +| callback | Callback<number> | No| Callback used to return the P2P state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pConnectionChange')8+ @@ -2094,10 +2093,10 @@ Registers the P2P connection state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pConnectionChange**.| - | callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Yes| Callback invoked to return the P2P connection state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pConnectionChange**.| +| callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Yes| Callback invoked to return the P2P connection state.| ## wifi.off('p2pConnectionChange')8+ @@ -2112,10 +2111,10 @@ Unregisters the P2P connection state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pConnectionChange**.| - | callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | No| Callback used to return the P2P connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pConnectionChange**.| +| callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | No| Callback used to return the P2P connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pDeviceChange')8+ @@ -2130,10 +2129,10 @@ Registers the P2P device state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pDeviceChange**.| - | callback | Callback<[WifiP2pDevice](#wifip2pdevice8)> | Yes| Callback invoked to return the P2P device state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pDeviceChange**.| +| callback | Callback<[WifiP2pDevice](#wifip2pdevice8)> | Yes| Callback invoked to return the P2P device state.| ## wifi.off('p2pDeviceChange')8+ @@ -2148,10 +2147,10 @@ Unregisters the P2P device state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pDeviceChange**.| - | callback | Callback<[WifiP2pDevice](#wifip2pdevice8)> | No| Callback used to return the P2P device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pDeviceChange**.| +| callback | Callback<[WifiP2pDevice](#wifip2pdevice8)> | No| Callback used to return the P2P device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pPeerDeviceChange')8+ @@ -2166,10 +2165,10 @@ Registers the P2P peer device state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| - | callback | Callback<[WifiP2pDevice[]](#wifip2pdevice8)> | Yes| Callback invoked to return the P2P peer device state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| +| callback | Callback<[WifiP2pDevice[]](#wifip2pdevice8)> | Yes| Callback invoked to return the P2P peer device state.| ## wifi.off('p2pPeerDeviceChange')8+ @@ -2184,10 +2183,10 @@ Unregisters the P2P peer device state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| - | callback | Callback<[WifiP2pDevice[]](#wifip2pdevice8)> | No| Callback used to return the peer device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| +| callback | Callback<[WifiP2pDevice[]](#wifip2pdevice8)> | No| Callback used to return the peer device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pPersistentGroupChange')8+ @@ -2202,10 +2201,10 @@ Registers the P2P persistent group state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| - | callback | Callback<void> | Yes| Callback invoked to return the P2P persistent group state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| +| callback | Callback<void> | Yes| Callback invoked to return the P2P persistent group state.| ## wifi.off('p2pPersistentGroupChange')8+ @@ -2220,10 +2219,10 @@ Unregisters the P2P persistent group state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| - | callback | Callback<void> | No| Callback used to return the P2P persistent group state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| +| callback | Callback<void> | No| Callback used to return the P2P persistent group state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pDiscoveryChange')8+ @@ -2238,17 +2237,17 @@ Registers the P2P device discovery state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the P2P device discovery state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the P2P device discovery state.| **P2P discovered device states** | **Value**| **Description**| | -------- | -------- | -| 0 | Initial state| -| 1 | Discovered| +| 0 | Initial state.| +| 1 | Discovered.| ## wifi.off('p2pDiscoveryChange')8+ @@ -2263,7 +2262,7 @@ Unregisters the P2P device discovery state change events. **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| - | callback | Callback<number> | No| Callback used to return the P2P device discovery state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| +| callback | Callback<number> | No| Callback used to return the P2P device discovery state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| diff --git a/en/application-dev/reference/apis/js-apis-wifiext.md b/en/application-dev/reference/apis/js-apis-wifiext.md index e421081e97a52ec917050bbfee15dda5e0c6c74a..9ce53d76e2517eb199067f779168fb9fe9d8b032 100644 --- a/en/application-dev/reference/apis/js-apis-wifiext.md +++ b/en/application-dev/reference/apis/js-apis-wifiext.md @@ -23,6 +23,7 @@ Enables the WLAN hotspot. **System capability**: SystemCapability.Communication.WiFi.AP.Extension **Return value** + | **Type**| **Description**| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -39,6 +40,7 @@ Disables the WLAN hotspot. **System capability**: SystemCapability.Communication.WiFi.AP.Extension **Return value** + | **Type**| **Description**| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -55,6 +57,7 @@ Obtains the supported power models. This API uses a promise to return the result **System capability**: SystemCapability.Communication.WiFi.AP.Extension **Return value** + | Type| Description| | -------- | -------- | | Promise<Array<[PowerModel](#powermodel)>> | Promise used to return the power models obtained.| @@ -84,6 +87,7 @@ Obtains the supported power models. This API uses an asynchronous callback to re **System capability**: SystemCapability.Communication.WiFi.AP.Extension **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[PowerModel](#powermodel)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is 0 and **data** is the power models obtained. If **err** is not **0**, an error has occurred.| @@ -100,6 +104,7 @@ Obtains the power model. This API uses a promise to return the result. **System capability**: SystemCapability.Communication.WiFi.AP.Extension **Return value** + | Type| Description| | -------- | -------- | | Promise<[PowerModel](#powermodel)> | Promise used to return the power model obtained.| @@ -116,6 +121,7 @@ Obtains the power model. This API uses an asynchronous callback to return the re **System capability**: SystemCapability.Communication.WiFi.AP.Extension **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[PowerModel](#powermodel)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.| @@ -132,11 +138,13 @@ setPowerModel(model: PowerModel) : boolean; **System capability**: SystemCapability.Communication.WiFi.AP.Extension **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | model | AsyncCallback<[PowerModel](#powermodel)> | Yes| Power model to set.| **Return value** + | **Type**| **Description**| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md index c30f11c4a06a5b80ae2f00f88a5baa8e071ffad3..91c284004f4b1e2f22d46ba27c3249d9b05dd5bb 100644 --- a/en/application-dev/reference/apis/js-apis-window.md +++ b/en/application-dev/reference/apis/js-apis-window.md @@ -303,8 +303,8 @@ Creates a subwindow. This API uses an asynchronous callback to return the result **Example** ```js -var windowClass = null; -window.create("first", window.WindowType.TYPE_APP,(err,data) => { +let windowClass = null; +window.create('first', window.WindowType.TYPE_APP,(err,data) => { if(err.code){ console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); return; @@ -340,8 +340,8 @@ Creates a subwindow. This API uses a promise to return the result. **Example** ```js -var windowClass = null; -let promise = window.create("first", window.WindowType.TYPE_APP); +let windowClass = null; +let promise = window.create('first', window.WindowType.TYPE_APP); promise.then((data)=> { windowClass = data; console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); @@ -370,8 +370,8 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). **Example** ```js -var windowClass = null; - window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { +let windowClass = null; + window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { if (err.code) { console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); return; @@ -407,8 +407,8 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). **Example** ```js -var windowClass = null; -let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT); +let windowClass = null; +let promise = window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT); promise.then((data)=> { windowClass = data; console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); @@ -435,8 +435,8 @@ Finds a window based on the ID. This API uses an asynchronous callback to return **Example** ```js -var windowClass = null; - window.find("alertWindow", (err, data) => { +let windowClass = null; + window.find('alertWindow', (err, data) => { if (err.code) { console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); return; @@ -469,8 +469,8 @@ Finds a window based on the ID. This API uses a promise to return the result. **Example** ```js -var windowClass = null; -let promise = window.find("alertWindow"); +let windowClass = null; +let promise = window.find('alertWindow'); promise.then((data)=> { windowClass = data; console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); @@ -498,7 +498,7 @@ Obtains the top window of the current application. This API uses an asynchronous **Example** ```js -var windowClass = null; +let windowClass = null; window.getTopWindow((err, data) => { if (err.code) { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); @@ -528,7 +528,7 @@ Obtains the top window of the current application. This API uses a promise to re **Example** ```js -var windowClass = null; +let windowClass = null; let promise = window.getTopWindow(); promise.then((data)=> { windowClass = data; @@ -556,7 +556,7 @@ Obtains the top window of the current application. This API uses an asynchronous **Example** ```js -var windowClass = null; +let windowClass = null; window.getTopWindow(this.context, (err, data) => { if (err.code) { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); @@ -590,7 +590,7 @@ Obtains the top window of the current application. This API uses a promise to re **Example** ```js -var windowClass = null; +let windowClass = null; let promise = window.getTopWindow(this.context); promise.then((data)=> { windowClass = data; @@ -622,7 +622,7 @@ Minimizes all windows on a display. This API uses an asynchronous callback to re import display from '@ohos.display' import window from '@ohos.window' -var displayClass = null; +let displayClass = null; display.getDefaultDisplay((err, data) => { if(err.code) { return; @@ -665,7 +665,7 @@ Minimizes all windows on a display. This API uses a promise to return the result import display from '@ohos.display' import window from '@ohos.window' -var displayClass = null; +let displayClass = null; display.getDefaultDisplay((err, data) => { if(err.code) { return; @@ -1255,7 +1255,7 @@ Sets the type of this window. This API uses an asynchronous callback to return t **Example** ```js -var type = window.WindowType.TYPE_APP; +let type = window.WindowType.TYPE_APP; windowClass.setWindowType(type, (err, data) => { if (err.code) { console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); @@ -1294,7 +1294,7 @@ Sets the type of this window. This API uses a promise to return the result. **Example** ```js -var type = window.WindowType.TYPE_APP; +let type = window.WindowType.TYPE_APP; let promise = windowClass.setWindowType(type); promise.then((data)=> { console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)); @@ -1372,7 +1372,7 @@ Obtains the area where this window cannot be displayed, for example, the system **Example** ```js -var type = window.AvoidAreaType.TYPE_SYSTEM; +let type = window.AvoidAreaType.TYPE_SYSTEM; windowClass.getAvoidArea(type, (err, data) => { if (err.code) { console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); @@ -1405,7 +1405,7 @@ Obtains the area where this window cannot be displayed, for example, the system **Example** ```js -var type = window.AvoidAreaType.TYPE_SYSTEM; +let type = window.AvoidAreaType.TYPE_SYSTEM; let promise = windowClass.getAvoidArea(type); promise.then((data)=> { console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); @@ -1432,7 +1432,7 @@ Sets whether to enable the full-screen mode for this window. This API uses an as **Example** ```js -var isFullScreen = true; +let isFullScreen = true; windowClass.setFullScreen(isFullScreen, (err, data) => { if (err.code) { console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); @@ -1465,7 +1465,7 @@ Sets whether to enable the full-screen mode for this window. This API uses a pro **Example** ```js -var isFullScreen = true; +let isFullScreen = true; let promise = windowClass.setFullScreen(isFullScreen); promise.then((data)=> { console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); @@ -1492,7 +1492,7 @@ Sets whether to enable the full-screen mode for the window layout. This API uses **Example** ```js -var isLayoutFullScreen= true; +let isLayoutFullScreen= true; windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { if (err.code) { console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); @@ -1525,7 +1525,7 @@ Sets whether to enable the full-screen mode for the window layout. This API uses **Example** ```js -var isLayoutFullScreen = true; +let isLayoutFullScreen = true; let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); promise.then((data)=> { console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); @@ -1546,14 +1546,14 @@ Sets whether to display the status bar and navigation bar in this window. This A | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| names | Array | Yes | Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to `["status", "navigation"]`. By default, they are not displayed.| +| names | Array | Yes | Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to `['status', 'navigation']`. By default, they are not displayed.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js // In this example, the status bar and navigation bar are not displayed. -var names = []; +let names = []; windowClass.setSystemBarEnable(names, (err, data) => { if (err.code) { console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); @@ -1575,7 +1575,7 @@ Sets whether to display the status bar and navigation bar in this window. This A | Name| Type | Mandatory| Description | | ------ | ----- | ---- | ------------------------------------------------------------ | -| names | Array | Yes | Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to `["status", "navigation"]`. By default, they are not displayed.| +| names | Array | Yes | Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to `['status', 'navigation']`. By default, they are not displayed.| **Return value** @@ -1587,7 +1587,7 @@ Sets whether to display the status bar and navigation bar in this window. This A ```js // In this example, the status bar and navigation bar are not displayed. -var names = []; +let names = []; let promise = windowClass.setSystemBarEnable(names); promise.then((data)=> { console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); @@ -1614,7 +1614,7 @@ Sets the properties of the status bar and navigation bar in this window. This AP **Example** ```js -var SystemBarProperties={ +let SystemBarProperties={ statusBarColor: '#ff00ff', navigationBarColor: '#00ff00', // The following properties are supported since API version 7. @@ -1656,7 +1656,7 @@ Sets the properties of the status bar and navigation bar in this window. This AP **Example** ```js -var SystemBarProperties={ +let SystemBarProperties={ statusBarColor: '#ff00ff', navigationBarColor: '#00ff00', // The following properties are supported since API version 7. @@ -1692,7 +1692,7 @@ Sets the preferred orientation for this window. This API uses an asynchronous ca **Example** ```js -var orientation = window.Orientation.AUTO_ROTATION; +let orientation = window.Orientation.AUTO_ROTATION; windowClass.setPreferredOrientation(orientation, (err, data) => { if (err.code) { console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err)); @@ -1725,7 +1725,7 @@ Sets the preferred orientation for this window. This API uses a promise to retur **Example** ```js -var orientation = window.Orientation.AUTO_ROTATION; +let orientation = window.Orientation.AUTO_ROTATION; let promise = windowClass.setPreferredOrientation(orientation); promise.then((data)=> { console.info('Succeeded in setting the window orientation. Data: ' + JSON.stringify(data)); @@ -1752,7 +1752,7 @@ Loads content from a page to this window. This API uses an asynchronous callback **Example** ```js -windowClass.loadContent("pages/page2/page2", (err, data) => { +windowClass.loadContent('pages/page2/page2', (err, data) => { if (err.code) { console.error('Failed to load the content. Cause:' + JSON.stringify(err)); return; @@ -1784,7 +1784,7 @@ Loads content from a page to this window. This API uses a promise to return the **Example** ```js -let promise = windowClass.loadContent("pages/page2/page2"); +let promise = windowClass.loadContent('pages/page2/page2'); promise.then((data)=> { console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); }).catch((err)=>{ @@ -1816,9 +1816,9 @@ class myAbility extends Ability { storage : LocalStorage onWindowStageCreate(windowStage) { this.storage = new LocalStorage(); - this.storage.setOrCreate("storageSimpleProp",121); + this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); - windowStage.loadContent("pages/page2",this.storage,(err, data) => { + windowStage.loadContent('pages/page2',this.storage,(err, data) => { if (err.code) { console.error('Failed to load the content. Cause:' + JSON.stringify(err)); return; @@ -1859,10 +1859,10 @@ class myAbility extends Ability { storage : LocalStorage onWindowStageCreate(windowStage) { this.storage = new LocalStorage(); - this.storage.setOrCreate("storageSimpleProp",121); + this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); - var windowClass = null; - let promise = windowStage.loadContent("pages/page2",this.storage); + let windowClass = null; + let promise = windowStage.loadContent('pages/page2',this.storage); promise.then((data)=> { windowClass = data; console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); @@ -2195,7 +2195,7 @@ Unsubscribes from screenshot events. **Example** ```js -var callback = ()=>{ +let callback = ()=>{ console.info('screenshot happened'); } windowClass.on('screenshot', callback) @@ -2272,7 +2272,7 @@ Binds the modal window to the target window, and adds a callback to listen for m ```js class MyDeathRecipient { onRemoteDied() { - console.log("server died"); + console.log('server died'); } } class TestRemoteObject extends rpc.RemoteObject { @@ -2289,7 +2289,7 @@ class TestRemoteObject extends rpc.RemoteObject { return false; } } -let token = new TestRemoteObject("testObject"); +let token = new TestRemoteObject('testObject'); windowClass.bindDialogTarget(token, () => { console.info('Dialog Window Need Destroy.'); }, (err, data) => { @@ -2329,7 +2329,7 @@ Binds the modal window to the target window, and adds a callback to listen for m ```js class MyDeathRecipient { onRemoteDied() { - console.log("server died"); + console.log('server died'); } } class TestRemoteObject extends rpc.RemoteObject { @@ -2346,7 +2346,7 @@ class TestRemoteObject extends rpc.RemoteObject { return false; } } -let token = new TestRemoteObject("testObject"); +let token = new TestRemoteObject('testObject'); let promise = windowClass.bindDialogTarget(token, () => { console.info('Dialog Window Need Destroy.'); }); @@ -2535,7 +2535,7 @@ Sets the background color for this window. This API uses an asynchronous callbac **Example** ```js -var color = '#00ff33'; +let color = '#00ff33'; windowClass.setBackgroundColor(color, (err, data) => { if (err.code) { console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); @@ -2568,7 +2568,7 @@ Sets the background color for this window. This API uses a promise to return the **Example** ```js -var color = '#00ff33'; +let color = '#00ff33'; let promise = windowClass.setBackgroundColor(color); promise.then((data)=> { console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); @@ -2596,7 +2596,7 @@ Wakes up the screen. **Example** ```js -var wakeUp = true; +let wakeUp = true; windowClass.setWakeUpScreen(wakeUp); ``` @@ -2618,7 +2618,7 @@ Sets the screen brightness for this window. This API uses an asynchronous callba **Example** ```js -var brightness = 1; +let brightness = 1; windowClass.setBrightness(brightness, (err, data) => { if (err.code) { console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); @@ -2651,7 +2651,7 @@ Sets the screen brightness for this window. This API uses a promise to return th **Example** ```js -var brightness = 1; +let brightness = 1; let promise = windowClass.setBrightness(brightness); promise.then((data)=> { console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); @@ -2748,7 +2748,7 @@ Sets whether this window can gain focus. This API uses an asynchronous callback **Example** ```js -var isFocusable= true; +let isFocusable= true; windowClass.setFocusable(isFocusable, (err, data) => { if (err.code) { console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); @@ -2781,7 +2781,7 @@ Sets whether this window can gain focus. This API uses a promise to return the r **Example** ```js -var isFocusable= true; +let isFocusable= true; let promise = windowClass.setFocusable(isFocusable); promise.then((data)=> { console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); @@ -2808,7 +2808,7 @@ Sets whether to keep the screen always on. This API uses an asynchronous callbac **Example** ```js -var isKeepScreenOn = true; +let isKeepScreenOn = true; windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { if (err.code) { console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); @@ -2841,7 +2841,7 @@ Sets whether to keep the screen always on. This API uses a promise to return the **Example** ```js -var isKeepScreenOn = true; +let isKeepScreenOn = true; let promise = windowClass.setKeepScreenOn(isKeepScreenOn); promise.then((data) => { console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); @@ -2938,7 +2938,7 @@ Sets whether this window is in privacy mode. This API uses an asynchronous callb **Example** ```js -var isPrivacyMode = true; +let isPrivacyMode = true; windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { if (err.code) { console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); @@ -2972,7 +2972,7 @@ Sets whether this window is in privacy mode. This API uses a promise to return t **Example** ```js -var isPrivacyMode = true; +let isPrivacyMode = true; let promise = windowClass.setPrivacyMode(isPrivacyMode); promise.then((data)=> { console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data)); @@ -2996,7 +2996,7 @@ Sets whether to ignore this window during screen capturing or recording. | ------------- | ------- | ---- | -------------------- | | isSkip | boolean | Yes | Whether to ignore the window. The default value is `false`.
The value `true` means that the window is ignored, and `false` means the opposite.
| ```js -var isSkip = true; +let isSkip = true; windowClass.setSnapshotSkip(isSkip); ``` @@ -3018,7 +3018,7 @@ Sets whether this window is touchable. This API uses an asynchronous callback to **Example** ```js -var isTouchable = true; +let isTouchable = true; windowClass.setTouchable(isTouchable, (err, data) => { if (err.code) { console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); @@ -3052,7 +3052,7 @@ Sets whether this window is touchable. This API uses a promise to return the res **Example** ```js -var isTouchable = true; +let isTouchable = true; let promise = windowClass.setTouchable(isTouchable); promise.then((data)=> { console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)); @@ -3081,7 +3081,7 @@ Sets whether this window is forbidden to move in split-screen mode. This API use **Example** ```js -var isForbidSplitMove = true; +let isForbidSplitMove = true; windowClass.setForbidSplitMove(isForbidSplitMove, (err, data) => { if (err.code) { console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err)); @@ -3117,7 +3117,7 @@ Sets whether this window is forbidden to move in split-screen mode. This API use **Example** ```js -var isForbidSplitMove = true; +let isForbidSplitMove = true; let promise = windowClass.setForbidSplitMove(isForbidSplitMove); promise.then((data)=> { console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data)); @@ -3333,7 +3333,7 @@ Sets the scale parameters for this window. **Example** ```js -var obj : window.ScaleOptions = { +let obj : window.ScaleOptions = { x : 2.0, y : 1.0, pivotX = 0.5; @@ -3361,7 +3361,7 @@ Sets the rotation parameters for this window. **Example** ```js -var obj : window.RotateOptions = { +let obj : window.RotateOptions = { x : 1.0, y : 1.0, z : 45.0, @@ -3390,7 +3390,7 @@ Sets the translation parameters for this window. **Example** ```js -var obj : window.TranslateOptions = { +let obj : window.TranslateOptions = { x : 100.0, y : 0.0, z : 0.0 @@ -3431,7 +3431,7 @@ controller.animationForHidden = (context : window.TransitionContext) => { context.completeTransition(true) } }, () => { - var obj : window.TranslateOptions = { + let obj : window.TranslateOptions = { x : 100.0, y : 0.0, z : 0.0 @@ -3495,7 +3495,7 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - var windowClass = null; + let windowClass = null; windowStage.getMainWindow((err, data) => { if (err.code) { console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); @@ -3530,7 +3530,7 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - var windowClass = null; + let windowClass = null; let promise = windowStage.getMainWindow(); promise.then((data)=> { windowClass = data; @@ -3565,8 +3565,8 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - var windowClass = null; - windowStage.createSubWindow("mySubWindow", (err, data) => { + let windowClass = null; + windowStage.createSubWindow('mySubWindow', (err, data) => { if (err.code) { console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); return; @@ -3607,8 +3607,8 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - var windowClass = null; - let promise = windowStage.createSubWindow("mySubWindow"); + let windowClass = null; + let promise = windowStage.createSubWindow('mySubWindow'); promise.then((data)=> { windowClass = data; console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); @@ -3641,7 +3641,7 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - var windowClass = null; + let windowClass = null; windowStage.getSubWindow((err, data) => { if (err.code) { console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err)); @@ -3676,7 +3676,7 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - var windowClass = null; + let windowClass = null; let promise = windowStage.getSubWindow(); promise.then((data)=> { windowClass = data; @@ -3713,9 +3713,9 @@ class myAbility extends Ability { storage : LocalStorage onWindowStageCreate(windowStage) { this.storage = new LocalStorage(); - this.storage.setOrCreate("storageSimpleProp",121); + this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); - windowStage.loadContent("pages/page2",this.storage,(err, data) => { + windowStage.loadContent('pages/page2',this.storage,(err, data) => { if (err.code) { console.error('Failed to load the content. Cause:' + JSON.stringify(err)); return; @@ -3757,10 +3757,10 @@ class myAbility extends Ability { storage : LocalStorage onWindowStageCreate(windowStage) { this.storage = new LocalStorage(); - this.storage.setOrCreate("storageSimpleProp",121); + this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); - var windowClass = null; - let promise = windowStage.loadContent("pages/page2",this.storage); + let windowClass = null; + let promise = windowStage.loadContent('pages/page2',this.storage); promise.then((data)=> { windowClass = data; console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); @@ -3795,7 +3795,7 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - windowStage.loadContent("pages/page2", (err, data) => { + windowStage.loadContent('pages/page2', (err, data) => { if (err.code) { console.error('Failed to load the content. Cause:' + JSON.stringify(err)); return; @@ -3963,7 +3963,7 @@ controller.animationForShown = (context : window.TransitionContext) => { iterations: 1, // Number of playback times. playMode: PlayMode.Normal // Animation playback mode. }, () => { - var obj : window.TranslateOptions = { + let obj : window.TranslateOptions = { x : 100.0, y : 0.0, z : 0.0 @@ -4014,7 +4014,7 @@ controller.animationForShown = (context : window.TransitionContext) => { context.completeTransition(true) } }, () => { - var obj : window.TranslateOptions = { + let obj : window.TranslateOptions = { x : 100.0, y : 0.0, z : 0.0 @@ -4060,7 +4060,7 @@ controller.animationForHidden = (context : window.TransitionContext) => { context.completeTransition(true) } }, () => { - var obj : window.TranslateOptions = { + let obj : window.TranslateOptions = { x : 100.0, y : 0.0, z : 0.0 diff --git a/en/application-dev/reference/apis/js-apis-windowAnimationManager.md b/en/application-dev/reference/apis/js-apis-windowAnimationManager.md index fd9bb9e2d7e174e221c54fdefeedcff3473ff405..248e4977d5b215d20a67373e9608c3f6ae1588bb 100644 --- a/en/application-dev/reference/apis/js-apis-windowAnimationManager.md +++ b/en/application-dev/reference/apis/js-apis-windowAnimationManager.md @@ -2,7 +2,6 @@ The **WindowAnimationManager** module provides APIs to listen for application start/exit events and window minimization/maximization events and associate animations with these events. > **NOTE** -> > The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. > > The APIs provided by this module are system APIs. @@ -32,7 +31,7 @@ Before using other APIs of **windowAnimationManager**, you must call this API to **Example** ```js -var controller = { +let controller = { onStartAppFromLauncher(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, finishCallback: windowAnimationManager.WindowAnimationFinishedCallback): void { console.log('onStartAppFromLauncher, the startingWindowTarget is: ' + startingWindowTarget); finishCallback.onAnimationFinish(); @@ -89,8 +88,8 @@ Minimizes the window that displays the animation. This API uses an asynchronous **Example** ```js -var target: WindowAnimationTarget = undefined; -var controller = { +let target: WindowAnimationTarget = undefined; +let controller = { onStartAppFromLauncher(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, finishCallback: windowAnimationManager.WindowAnimationFinishedCallback): void { console.log('onStartAppFromLauncher, the startingWindowTarget is: ' + startingWindowTarget); finishCallback.onAnimationFinish(); @@ -128,7 +127,7 @@ var controller = { windowAnimationManager.setController(controller) -var finishedCallback = null; +let finishedCallback = null; windowAnimationManager.minimizeWindowWithAnimation(target, (err, data) => { if (err.code) { console.error('Failed to minimize the window target. Cause: ' + JSON.stringify(err)); @@ -165,8 +164,8 @@ Minimizes the window that displays the animation. This API uses a promise to ret **Example** ```js -var target: WindowAnimationTarget = undefined; -var controller = { +let target: WindowAnimationTarget = undefined; +let controller = { onStartAppFromLauncher(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, finishCallback: windowAnimationManager.WindowAnimationFinishedCallback): void { console.log('onStartAppFromLauncher, the startingWindowTarget is: ' + startingWindowTarget); finishCallback.onAnimationFinish(); diff --git a/en/application-dev/reference/apis/js-apis-xml.md b/en/application-dev/reference/apis/js-apis-xml.md index 078c1dc0009329300ab7458a7672b63c76271f61..322a8000a525eef6e32174a2a099f04573570edc 100644 --- a/en/application-dev/reference/apis/js-apis-xml.md +++ b/en/application-dev/reference/apis/js-apis-xml.md @@ -339,8 +339,8 @@ let strXml = let arrayBuffer = new ArrayBuffer(strXml.length); let bufView = new Uint8Array(arrayBuffer); let strLen = strXml.length; -for (var i = 0; i < strLen; ++i) { - bufView[i] = strXml.charCodeAt(i); +for (var tmp = 0; tmp < strLen; ++tmp) { + bufView[tmp] = strXml.charCodeAt(tmp); } let that = new xml.XmlPullParser(arrayBuffer); let arrTag = {}; diff --git a/en/application-dev/reference/arkui-js/js-components-basic-input.md b/en/application-dev/reference/arkui-js/js-components-basic-input.md index 066da49683ce647db66b9c8cdecd551550b23844..2ce4c7d3b07a6e8dbdcd47c4d3143ec8e4b285df 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-input.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-input.md @@ -20,44 +20,44 @@ Not supported In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported. -| Name | Type | Default Value | Mandatory | Description | -| -------------------------------- | ----------------------- | --------- | ---- | ---------------------------------------- | -| type | string | text
| No | Type of the input component. Available values include **text**, **email**, **date**, **time**, **number**, **password**, **button**, **checkbox**, and **radio**.
The **text**, **email**, **date**, **time**, **number**, and **password** types can be dynamically switched and modified.
The **button**, **checkbox**, and **radio** types cannot be dynamically modified.
- **button**: a button that can be clicked.
- **checkbox**: a check box.
- **radio**: a radio button that allows users to select one from multiple others with the same name.
- **text**: a single-line text field.
- **email**: a field used for an email address.
- **date**: date component, including the year, month, and day, but excluding time.
- **time**: time component, without the time zone.
- **number**: field for entering digits.
- **password**: password field, in which characters will be shielded.| -| checked | boolean | false | No | Whether the **\** component is selected. This attribute is valid only when **type** is set to **checkbox** or **radio**. | -| name | string | - | No | Name of the **\** component.
This attribute is mandatory when **type** is set to **radio**. | -| value | string | - | No | Value of the **\** component. When **type** is **radio**, this attribute is mandatory and the value must be unique for radio buttons with the same name.| -| placeholder | string | - | No | Content of the hint text. This attribute is available only when the component type is set to **text** \|email\|date\|time\|number\|**password**.| -| maxlength | number | - | No | Maximum number of characters that can be entered in the input box. The empty value indicates no limit. | -| enterkeytype | string | default | No | Type of the **Enter** key on the soft keyboard. The value cannot be dynamically updated.
Available values include:
- default
- next
- go
- done
- send
- search
Except for the **next** type, clicking the Enter key hides the soft keyboard.| -| headericon | string | - | No | Icon resource path before text input. This icon does not support click events and is unavailable for **button**, **checkbox**, and **radio** types. The supported icon image formats are JPG, PNG, and SVG.| -| showcounter5+ | boolean | false | No | Whether to display the character counter for an input box. This attribute takes effect only when **maxlength** is set. | -| menuoptions5+ | Array<MeunOption> | - | No | Menu options displayed after users click the **More** button. | -| autofocus6+ | boolean | false | No | Whether to automatically obtain focus.
This attribute setting does not take effect on the application home page. You can enable a text box on the home page to automatically obtain focus, by delaying the **focus** method call (for about 100–500 ms) in **onActive**.| -| selectedstart6+ | number | -1 | No | Start position for text selection. | -| selectedend6+ | number | -1 | No | End position for text selection. | -| softkeyboardenabled6+ | boolean | true | No | Whether to display the soft keyboard during editing. | -| showpasswordicon6+ | boolean | true | No | Whether to display the icon at the end of the password text box. This attribute is available only when **type** is set to **password**. | +| Name | Type | Default Value | Mandatory | Description | +| -------------------------------- | ----------------------- | ------------- | --------- | ---------------------------------------- | +| type | string | text
| No | Type of the input component. Available values include **text**, **email**, **date**, **time**, **number**, **password**, **button**, **checkbox**, and **radio**.
The **text**, **email**, **date**, **time**, **number**, and **password** types can be dynamically switched and modified.
The **button**, **checkbox**, and **radio** types cannot be dynamically modified.
- **button**: a button that can be clicked.
- **checkbox**: a check box.
- **radio**: a radio button that allows users to select one from multiple others with the same name.
- **text**: a single-line text field.
- **email**: a field used for an email address.
- **date**: date component, including the year, month, and day, but excluding time.
- **time**: time component, without the time zone.
- **number**: field for entering digits.
- **password**: password field, in which characters will be shielded. | +| checked | boolean | false | No | Whether the **\** component is selected. This attribute is valid only when **type** is set to **checkbox** or **radio**. | +| name | string | - | No | Name of the **\** component.
This attribute is mandatory when **type** is set to **radio**. | +| value | string | - | No | Value of the **\** component. When **type** is **radio**, this attribute is mandatory and the value must be unique for radio buttons with the same name. | +| placeholder | string | - | No | Content of the hint text. This attribute is available only when the component type is set to **text** \|email\|date\|time\|number\|**password**. | +| maxlength | number | - | No | Maximum number of characters that can be entered in the input box. The empty value indicates no limit. | +| enterkeytype | string | default | No | Type of the **Enter** key on the soft keyboard. The value cannot be dynamically updated.
Available values include:
- default
- next
- go
- done
- send
- search
Except for the **next** type, clicking the Enter key hides the soft keyboard. | +| headericon | string | - | No | Icon resource path before text input. This icon does not support click events and is unavailable for **button**, **checkbox**, and **radio** types. The supported icon image formats are JPG, PNG, and SVG. | +| showcounter5+ | boolean | false | No | Whether to display the character counter for an input box. This attribute takes effect only when **maxlength** is set. | +| menuoptions5+ | Array<MenuOption> | - | No | Menu options displayed after users click the **More** button. | +| autofocus6+ | boolean | false | No | Whether to automatically obtain focus.
This attribute setting does not take effect on the application home page. You can enable a text box on the home page to automatically obtain focus, by delaying the **focus** method call (for about 100–500 ms) in **onActive**. | +| selectedstart6+ | number | -1 | No | Start position for text selection. | +| selectedend6+ | number | -1 | No | End position for text selection. | +| softkeyboardenabled6+ | boolean | true | No | Whether to display the soft keyboard during editing. | +| showpasswordicon6+ | boolean | true | No | Whether to display the icon at the end of the password text box. This attribute is available only when **type** is set to **password**. | **Table 1** MenuOption5+ -| Name | Type | Description | -| ------- | ------ | ----------- | -| icon | string | Path of the icon for a menu option.| -| content | string | Text content of a menu option.| +| Name | Type | Description | +| ------- | ------ | ----------------------------------- | +| icon | string | Path of the icon for a menu option. | +| content | string | Text content of a menu option. | ## Styles In addition to the [universal styles](../arkui-js/js-components-common-styles.md), the following styles are supported. -| Name | Type | Default Value | Mandatory | Description | -| ------------------------ | -------------------------- | ---------- | ---- | ---------------------------------------- | -| color | <color> | \#e6000000 | No | Font color of the single-line text box or button. | -| font-size | <length> | 16px | No | Font size of the single-line text box or button. | -| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings.
If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart.| -| placeholder-color | <color> | \#99000000 | No | Color of the hint text in the single-line text box. This attribute is available only when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**. | -| font-weight | number \| string | normal | No | Font weight of the single-line text box or button. For details, see **font-weight** of the [**\**](../arkui-js/js-components-basic-text.md) component. | -| caret-color6+ | <color> | - | No | Color of the caret. | +| Name | Type | Default Value | Mandatory | Description | +| ------------------------ | ---------------- | ------------- | --------- | ---------------------------------------- | +| color | <color> | \#e6000000 | No | Font color of the single-line text box or button. | +| font-size | <length> | 16px | No | Font size of the single-line text box or button. | +| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings.
If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart. | +| placeholder-color | <color> | \#99000000 | No | Color of the hint text in the single-line text box. This attribute is available only when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**. | +| font-weight | number \| string | normal | No | Font weight of the single-line text box or button. For details, see **font-weight** of the [**\**](../arkui-js/js-components-basic-text.md) component. | +| caret-color6+ | <color> | - | No | Color of the caret. | ## Events @@ -65,31 +65,31 @@ In addition to the [universal styles](../arkui-js/js-components-common-styles.md In addition to the [universal events](../arkui-js/js-components-common-events.md), the following events are supported. - When **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**, the following events are supported. - - | Name | Parameter | Description | + + | Name | Parameter | Description | | ------------------------- | ---------------------------------------- | ---------------------------------------- | - | change | {
value: inputValue
} | Triggered when the content entered in the input box changes. The most recent content entered by the user is returned.
If you change the **value** attribute directly, this event will not be triggered.| - | enterkeyclick | {
value: enterKey
} | Triggered when the **Enter** key on the soft keyboard is clicked. The type of the **Enter** key is returned, which is of the number type. Available values are as follows:
- **2**: returned if **enterkeytype** is **go**.
- **3**: returned if **enterkeytype** is **search**.
- **4**: returned if **enterkeytype** is **send**.
- **5**: returned if **enterkeytype** is **next**.
- **6**: returned if **enterkeytype** is **default**, **done**, or is not set.| - | translate5+ | {
value: selectedText
} | Triggered when users click the translate button in the menu displayed after they select a text segment. The selected text content is returned.| - | share5+ | {
value: selectedText
} | Triggered when users click the share button in the menu displayed after they select a text segment. The selected text content is returned.| - | search5+ | {
value: selectedText
} | Triggered when users click the search button in the menu displayed after they select a text segment. The selected text content is returned.| - | optionselect5+ | {
index: optionIndex,
value: selectedText
} | Triggered when users click a menu option in the menu displayed after they select a text segment. This event is valid only when the **menuoptions** attribute is set. The option index and selected text content are returned.| - | selectchange6+ | {
start: number,
end: number
} | Triggered when the text selection changes. | + | change | {
value: inputValue
} | Triggered when the content entered in the input box changes. The most recent content entered by the user is returned.
If you change the **value** attribute directly, this event will not be triggered. | + | enterkeyclick | {
value: enterKey
} | Triggered when the **Enter** key on the soft keyboard is clicked. The type of the **Enter** key is returned, which is of the number type. Available values are as follows:
- **2**: returned if **enterkeytype** is **go**.
- **3**: returned if **enterkeytype** is **search**.
- **4**: returned if **enterkeytype** is **send**.
- **5**: returned if **enterkeytype** is **next**.
- **6**: returned if **enterkeytype** is **default**, **done**, or is not set. | + | translate5+ | {
value: selectedText
} | Triggered when users click the translate button in the menu displayed after they select a text segment. The selected text content is returned. | + | share5+ | {
value: selectedText
} | Triggered when users click the share button in the menu displayed after they select a text segment. The selected text content is returned. | + | search5+ | {
value: selectedText
} | Triggered when users click the search button in the menu displayed after they select a text segment. The selected text content is returned. | + | optionselect5+ | {
index: optionIndex,
value: selectedText
} | Triggered when users click a menu option in the menu displayed after they select a text segment. This event is valid only when the **menuoptions** attribute is set. The option index and selected text content are returned. | + | selectchange6+ | {
start: number,
end: number
} | Triggered when the text selection changes. | - When **type** is set to **checkbox** or **radio**, the following events are supported. - - | Name | Parameter | Description | - | ------ | ---------------------------------------- | ---------------------------------------- | - | change | {
checked:true \| false
} | Triggered when the checked status of the **checkbox** or **radio** button changes.| + + | Name | Parameter | Description | + | ------ | --------------------------------- | ---------------------------------------- | + | change | {
checked:true \| false
} | Triggered when the checked status of the **checkbox** or **radio** button changes. | ## Methods In addition to the [universal methods](../arkui-js/js-components-common-methods.md), the following methods are supported. -| Name | Parameter | Description | +| Name | Parameter | Description | | ------------------- | ---------------------------------------- | ---------------------------------------- | -| focus | {
focus: true\|false
}:
If **focus** is not passed, the default value **true** is used.| Obtains or loses focus. When **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**, the input method can be displayed or collapsed. | -| showError | {
error: string
} | Displays the error message. This method is available when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**. | +| focus | {
focus: true\|false
}:
If **focus** is not passed, the default value **true** is used. | Obtains or loses focus. When **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**, the input method can be displayed or collapsed. | +| showError | {
error: string
} | Displays the error message. This method is available when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**. | | delete6+ | - | Deletes text based on the current caret position when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**; deletes the last character and displays the caret if the current input component does not have a caret. | ## Example diff --git a/en/application-dev/reference/arkui-js/js-components-media-video.md b/en/application-dev/reference/arkui-js/js-components-media-video.md index 18c3fbef3bff790dfea6359d7a5d7c5516d0ecd5..c024cbe0058093b754c98f04f579b1cd7dac620f 100644 --- a/en/application-dev/reference/arkui-js/js-components-media-video.md +++ b/en/application-dev/reference/arkui-js/js-components-media-video.md @@ -3,17 +3,17 @@ > **NOTE** > -> - This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. +> - This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. > -> - Set **configChanges** under **abilities** in the **config.json** file to **orientation**. -> ``` -> "abilities": [ -> { -> "configChanges": ["orientation"], -> ... -> } -> ] -> ``` +> - Set **configChanges** under **abilities** in the **config.json** file to **orientation**. +> ``` +> "abilities": [ +> { +> "configChanges": ["orientation"], +> ... +> } +> ] +> ``` The **\