提交 bbad08e5 编写于 作者: 肖文文

Merge branch 'master' of https://gitee.com/bio_abc/docs

...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
- [Device Usage Statistics](device-usage-statistics/Readme-EN.md) - [Device Usage Statistics](device-usage-statistics/Readme-EN.md)
- [DFX](dfx/Readme-EN.md) - [DFX](dfx/Readme-EN.md)
- [Internationalization](internationalization/Readme-EN.md) - [Internationalization](internationalization/Readme-EN.md)
- - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md)
- [Using Native APIs in Application Projects](napi/napi-guidelines.md) - [Using Native APIs in Application Projects](napi/Readme-EN.md)
- Tools - Tools
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- Hands-On Tutorials - Hands-On Tutorials
......
...@@ -46,7 +46,7 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat ...@@ -46,7 +46,7 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat
1. Define the IPC interface **ITestAbility**. 1. Define the IPC interface **ITestAbility**.
**ITestAbility** inherits the IPC base class **IRemoteBroker** and defines descriptors, functions, and message code. The functions need to be implemented on both the proxy and stub. **ITestAbility** inherits the IPC base class **IRemoteBroker** and defines descriptors, functions, and message code. The functions need to be implemented on both the proxy and stub.
``` ```
class ITestAbility : public IRemoteBroker { class ITestAbility : public IRemoteBroker {
......
...@@ -107,7 +107,7 @@ The following example shows how to implement a distributed data object synchroni ...@@ -107,7 +107,7 @@ The following example shows how to implement a distributed data object synchroni
}); });
} }
} }
// To refresh the page in changeCallback, correctly bind (this) to the changeCallback. // To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
local_object.on("change", this.changeCallback.bind(this)); local_object.on("change", this.changeCallback.bind(this));
``` ```
...@@ -171,7 +171,7 @@ The following example shows how to implement a distributed data object synchroni ...@@ -171,7 +171,7 @@ The following example shows how to implement a distributed data object synchroni
```js ```js
local_object.setSessionId(""); local_object.setSessionId("");
``` ```
## Development Example ## Samples
The following example is provided for you to better understand the development of distributed data objects: The following example is provided for you to better understand the development of distributed data objects:
...@@ -179,4 +179,4 @@ The following example is provided for you to better understand the development o ...@@ -179,4 +179,4 @@ The following example is provided for you to better understand the development o
When an event of the Notepad app occurs on a device, such as a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network. When an event of the Notepad app occurs on a device, such as a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network.
...@@ -177,5 +177,5 @@ The following uses a single KV store as an example to describe the development p ...@@ -177,5 +177,5 @@ The following uses a single KV store as an example to describe the development p
``` ```
## Samples ## Samples
The following samples are provided to help you better understand the distributed data development: The following samples are provided to help you better understand the distributed data development:
- [`KvStore`: distributed database (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore) - [`KvStore`: Distributed Data Management (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore)
- [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) - [Distributed Data Service](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData)
...@@ -116,8 +116,8 @@ The RDB provides **RdbPredicates** for you to set database operation conditions. ...@@ -116,8 +116,8 @@ The RDB provides **RdbPredicates** for you to set database operation conditions.
A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**. A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**.
> ![icon-notice.gif](../public_sys-resources/icon-notice.gif) **NOTICE**<br/> > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**<br>
> After a result set is used, you must call the **close()** method to close it explicitly.** > After a result set is used, you must call the **close()** method to close it explicitly.
**Table 7** APIs for using the result set **Table 7** APIs for using the result set
...@@ -306,3 +306,8 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -306,3 +306,8 @@ You can obtain the distributed table name for a remote device based on the local
let tableName = rdbStore.obtainDistributedTableName(deviceId, "test"); let tableName = rdbStore.obtainDistributedTableName(deviceId, "test");
let resultSet = rdbStore.querySql("SELECT * FROM " + tableName) let resultSet = rdbStore.querySql("SELECT * FROM " + tableName)
``` ```
## Samples
The following samples are provided for you to better understand the RDB development:
- [`Rdb`: eTS RDB (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Rdb)
- [`DistributedRdb`: eTS Distributed Relational Database (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedRdb)
- [Relational Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData)
...@@ -401,10 +401,6 @@ export class VideoPlayerDemo { ...@@ -401,10 +401,6 @@ export class VideoPlayerDemo {
} }
} }
sleep(time) {
for(let t = Date.now(); Date.now() - t <= time;);
}
async videoPlayerDemo() { async videoPlayerDemo() {
let videoPlayer = undefined; let videoPlayer = undefined;
let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent. let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent.
...@@ -442,27 +438,15 @@ export class VideoPlayerDemo { ...@@ -442,27 +438,15 @@ export class VideoPlayerDemo {
}, this.failureCallback).catch(this.catchCallback); }, this.failureCallback).catch(this.catchCallback);
// Set the loop playback attribute. // Set the loop playback attribute.
videoPlayer.loop = true; videoPlayer.loop = true;
// Call the play API to start playback. // Call the play API to start loop playback.
await videoPlayer.play().then(() => { await videoPlayer.play().then(() => {
console.info('play success'); console.info('play success, loop value is ' + videoPlayer.loop);
}, this.failureCallback).catch(this.catchCallback);
// After the progress bar reaches the end, the playback continues for 3 seconds and then starts from the beginning, since loop playback is configured.
await videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('seek duration success');
}, this.failureCallback).catch(this.catchCallback);
this.sleep(3000);
// Release playback resources.
await videoPlayer.release().then(() => {
console.info('release success');
}, this.failureCallback).catch(this.catchCallback); }, this.failureCallback).catch(this.catchCallback);
// Set the related instances to undefined.
videoPlayer = undefined;
surfaceID = undefined;
} }
} }
``` ```
## Samples ## Samples
The following samples are provided to help you better understand how to develop video playback: The following samples are provided to help you better understand how to develop video playback:
- [`VideoPlayer`: Video Playback (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/media/VideoPlayer) - [`VideoPlayer`: Video Playback (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/media/VideoPlayer)
# Native APIs
- [Using Native APIs in Application Projects](napi-guidelines.md)
...@@ -174,4 +174,4 @@ if (this.subscriber != null) { ...@@ -174,4 +174,4 @@ if (this.subscriber != null) {
The following sample is provided to help you better understand how to use the common event functionality: The following sample is provided to help you better understand how to use the common event functionality:
- [`CommonEvent`: eTS Common Event (API 7)](https://gitee.com/openharmony/app_samples/tree/master/Notification/CommonEvent) - [`CommonEvent`: eTS Common Event (API 8)](https://gitee.com/openharmony/app_samples/tree/master/Notification/CommonEvent)
...@@ -262,4 +262,4 @@ Notification.cancel(1, "label", cancelCallback) ...@@ -262,4 +262,4 @@ Notification.cancel(1, "label", cancelCallback)
The following sample is provided to help you better understand how to develop notification functions: The following sample is provided to help you better understand how to develop notification functions:
[`Notification`: EtsNotification (API 7)](https://gitee.com/openharmony/app_samples/tree/master/common/Notification) [`Notification`: EtsNotification (API 8)](https://gitee.com/openharmony/app_samples/tree/master/common/Notification)
\ No newline at end of file \ No newline at end of file
...@@ -20,17 +20,18 @@ ...@@ -20,17 +20,18 @@
## eTS Project Files ## eTS Project Files
- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). - **entry**: OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)).
- **src &gt; main &gt; ets** : a collection of eTS source code. - **src &gt; main &gt; ets**: a collection of eTS source code.
- **src &gt; main &gt; ets &gt; MainAbility** : entry to your application/service. - **src &gt; main &gt; ets &gt; MainAbility**: entry to your application/service.
- **src &gt; main &gt; ets &gt; MainAbility &gt; pages** : pages contained in **MainAbility**. - **src &gt; main &gt; ets &gt; MainAbility &gt; pages**: pages contained in **MainAbility**.
- **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets** : ability lifecycle file. - **src &gt; main &gt; ets &gt; MainAbility &gt; pages &gt; index.ets**: the first page in the pages list, that is, the home page of your application.
- **src &gt; main &gt; resources** : a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. - **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets**: ability lifecycle file.
- **src &gt; main &gt; config.json** : module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. - **src &gt; main &gt; resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
- **build-profile.json5** : current module information and build configuration options, including **buildOption target**. - **src &gt; main &gt; config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file.
- **hvigorfile.js** : module-level compilation and build task script. You can customize related tasks and code implementation. - **build-profile.json5**: current module information and build configuration options, including **buildOption target**.
- **build-profile.json5** : application-level configuration information, including the signature and product configuration. - **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation.
- **hvigorfile.js** : application-level compilation and build task script. - **build-profile.json5**: application-level configuration information, including the signature and product configuration.
- **hvigorfile.js**: application-level compilation and build task script.
## Building the First Page ## Building the First Page
...@@ -62,7 +63,7 @@ ...@@ -62,7 +63,7 @@
2. Add a **&lt;Button&gt;** component. 2. Add a **&lt;Button&gt;** component.
On the default page, add a **&lt;Button&gt;** component to accept user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below: On the default page, add a **&lt;Button&gt;** component to respond to user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below:
``` ```
...@@ -77,7 +78,7 @@ ...@@ -77,7 +78,7 @@
Text(this.message) Text(this.message)
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
// Add a button to accept user clicks. // Add a button to respond to user clicks.
Button() { Button() {
Text('Next') Text('Next')
.fontSize(30) .fontSize(30)
...@@ -174,7 +175,7 @@ You can implement page redirection through the page router, which finds the targ ...@@ -174,7 +175,7 @@ You can implement page redirection through the page router, which finds the targ
Text(this.message) Text(this.message)
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
// Add a button to accept user clicks. // Add a button to respond to user clicks.
Button() { Button() {
Text('Next') Text('Next')
.fontSize(30) .fontSize(30)
......
...@@ -37,10 +37,11 @@ After the project synchronization is complete, a low-code directory structure is ...@@ -37,10 +37,11 @@ After the project synchronization is complete, a low-code directory structure is
![en-us_image_0000001223558810](figures/en-us_image_0000001223558810.png) ![en-us_image_0000001223558810](figures/en-us_image_0000001223558810.png)
- **entry &gt; src &gt; main &gt; js &gt; MainAbility &gt; pages &gt; index &gt; index.js** : defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages. - **entry &gt; src &gt; main &gt; js &gt; MainAbility &gt; pages &gt; index &gt; index.js**: defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>To avoid build errors when using the low-code development page, make sure the directory where the corresponding **.js** file is located does not contain **.hml** or **.css** files. For example, in the preceding example, no **.hml** or **.css** file is allowed in **js** &gt; **MainAbility** &gt; **pages** &gt; **index**. > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>To avoid build errors when using the low-code development page, make sure the directory where the corresponding **.js** file is located does not contain **.hml** or **.css** files. For example, in the preceding example, no **.hml** or **.css** file is allowed in **js** &gt; **MainAbility** &gt; **pages** &gt; **index**.
> >
- **entry &gt; src &gt; main &gt; supervisual &gt; MainAbility &gt; pages &gt; index &gt; index.visual** : stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages. - **entry &gt; src &gt; main &gt; supervisual &gt; MainAbility &gt; pages &gt; index &gt; index.visual**: stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages.
## Building the First Page ## Building the First Page
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
## JavaScript Project Files ## JavaScript Project Files
- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). - **entry**: OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)).
- **src &gt; main &gt; js**: a collection of JS source code. - **src &gt; main &gt; js**: a collection of JS source code.
- **src &gt; main &gt; js &gt; MainAbility**: entry to your application/service. - **src &gt; main &gt; js &gt; MainAbility**: entry to your application/service.
- **src &gt; main &gt; js &gt; MainAbility &gt; i18n**: resources in different languages, for example, UI strings and image paths. - **src &gt; main &gt; js &gt; MainAbility &gt; i18n**: resources in different languages, for example, UI strings and image paths.
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
2. Add a button and bind the **onclick** method to this button. 2. Add a button and bind the **onclick** method to this button.
On the default page, add an **&lt;input&gt;** component of the button type to accept user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below: On the default page, add an **&lt;input&gt;** component of the button type to respond to user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below:
``` ```
......
# DataAbilityPredicates # DataAbilityPredicates
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -22,6 +22,7 @@ Creates an **RdbPredicates** object based on a **DataAabilityPredicates** object ...@@ -22,6 +22,7 @@ Creates an **RdbPredicates** object based on a **DataAabilityPredicates** object
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Table name in the RDB store.| | name | string | Yes| Table name in the RDB store.|
......
# Distributed Data Object # Distributed Data Object
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
import distributedObject from '@ohos.data.distributedDataObject'; import distributedObject from '@ohos.data.distributedDataObject';
``` ```
## distributedDataObject.createDistributedObject ## distributedDataObject.createDistributedObject
createDistributedObject(source: object): DistributedObject createDistributedObject(source: object): DistributedObject
......
# Result Set # Result Set
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Lightweight storage provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value (KV) pairs. Keys are of the string type, and values can be of the number, string, or Boolean type. Lightweight storage provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value (KV) pairs. Keys are of the string type, and values can be of the number, string, or Boolean type.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> >
> - 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.
> >
...@@ -30,7 +30,7 @@ import dataStorage from '@ohos.data.storage'; ...@@ -30,7 +30,7 @@ import dataStorage from '@ohos.data.storage';
getStorageSync(path: string): Storage getStorageSync(path: string): Storage
Reads a file and loads the data to the **Storage** instance in synchronous mode. Reads the specified file and load its data to the **Storage** instance for data operations.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -67,7 +67,7 @@ Reads a file and loads the data to the **Storage** instance in synchronous mode. ...@@ -67,7 +67,7 @@ Reads a file and loads the data to the **Storage** instance in synchronous mode.
getStorage(path: string, callback: AsyncCallback&lt;Storage&gt;): void getStorage(path: string, callback: AsyncCallback&lt;Storage&gt;): void
Reads a file and loads the data to the **Storage** instance. This API uses an asynchronous callback to return the execution result. Reads the specified file and loads its data to the **Storage** instance for data operations. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -105,7 +105,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses an as ...@@ -105,7 +105,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses an as
getStorage(path: string): Promise&lt;Storage&gt; getStorage(path: string): Promise&lt;Storage&gt;
Reads a file and loads the data to the **Storage** instance. This API uses a promise to return the execution result. Reads the specified file and loads its data to the **Storage** instance for data operations. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -146,7 +146,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses a pro ...@@ -146,7 +146,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses a pro
deleteStorageSync(path: string): void deleteStorageSync(path: string): void
Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a synchronous mode. Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -165,7 +165,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ...@@ -165,7 +165,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
deleteStorage(path: string, callback: AsyncCallback&lt;void&gt;): void deleteStorage(path: string, callback: AsyncCallback&lt;void&gt;): void
Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result. Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -191,7 +191,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ...@@ -191,7 +191,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
deleteStorage(path: string): Promise&lt;void&gt; deleteStorage(path: string): Promise&lt;void&gt;
Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the execution result. Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -222,8 +222,6 @@ removeStorageFromCacheSync(path: string): void ...@@ -222,8 +222,6 @@ removeStorageFromCacheSync(path: string): void
Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
...@@ -241,9 +239,7 @@ This API uses a synchronous mode. ...@@ -241,9 +239,7 @@ This API uses a synchronous mode.
removeStorageFromCache(path: string, callback: AsyncCallback&lt;void&gt;): void removeStorageFromCache(path: string, callback: AsyncCallback&lt;void&gt;): void
Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -269,9 +265,7 @@ This API uses an asynchronous callback to return the result. ...@@ -269,9 +265,7 @@ This API uses an asynchronous callback to return the result.
removeStorageFromCache(path: string): Promise&lt;void&gt; removeStorageFromCache(path: string): Promise&lt;void&gt;
Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the result.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -307,8 +301,6 @@ getSync(key: string, defValue: ValueType): ValueType ...@@ -307,8 +301,6 @@ getSync(key: string, defValue: ValueType): ValueType
Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
...@@ -333,9 +325,7 @@ This API uses a synchronous mode. ...@@ -333,9 +325,7 @@ This API uses a synchronous mode.
get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;): void get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;): void
Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. This API uses an asynchronous callback to return the result.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -362,9 +352,7 @@ This API uses an asynchronous callback to return the result. ...@@ -362,9 +352,7 @@ This API uses an asynchronous callback to return the result.
get(key: string, defValue: ValueType): Promise&lt;ValueType&gt; get(key: string, defValue: ValueType): Promise&lt;ValueType&gt;
Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. This API uses a promise to return the result.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -397,8 +385,6 @@ putSync(key: string, value: ValueType): void ...@@ -397,8 +385,6 @@ putSync(key: string, value: ValueType): void
Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
...@@ -417,9 +403,7 @@ This API uses a synchronous mode. ...@@ -417,9 +403,7 @@ This API uses a synchronous mode.
put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void
Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. This API uses an asynchronous callback to return the result.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -446,9 +430,7 @@ This API uses an asynchronous callback to return the result. ...@@ -446,9 +430,7 @@ This API uses an asynchronous callback to return the result.
put(key: string, value: ValueType): Promise&lt;void&gt; put(key: string, value: ValueType): Promise&lt;void&gt;
Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. This API uses a promise to return the result.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -480,8 +462,6 @@ hasSync(key: string): boolean ...@@ -480,8 +462,6 @@ hasSync(key: string): boolean
Checks whether the storage object contains data with a given key. Checks whether the storage object contains data with a given key.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
...@@ -507,9 +487,7 @@ This API uses a synchronous mode. ...@@ -507,9 +487,7 @@ This API uses a synchronous mode.
has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean
Checks whether the storage object contains data with a given key. Checks whether the storage object contains data with a given key. This API uses an asynchronous callback to return the result.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -542,9 +520,7 @@ This API uses an asynchronous callback to return the result. ...@@ -542,9 +520,7 @@ This API uses an asynchronous callback to return the result.
has(key: string): Promise&lt;boolean&gt; has(key: string): Promise&lt;boolean&gt;
Checks whether the storage object contains data with a given key. Checks whether the storage object contains data with a given key. This API uses a promise to return the result.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -577,8 +553,6 @@ deleteSync(key: string): void ...@@ -577,8 +553,6 @@ deleteSync(key: string): void
Deletes data with the specified key from this storage object. Deletes data with the specified key from this storage object.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
...@@ -592,13 +566,11 @@ This API uses a synchronous mode. ...@@ -592,13 +566,11 @@ This API uses a synchronous mode.
``` ```
### deletej ### delete
delete(key: string, callback: AsyncCallback&lt;void&gt;): void delete(key: string, callback: AsyncCallback&lt;void&gt;): void
Deletes data with the specified key from this storage object. Deletes data with the specified key from this storage object. This API uses an asynchronous callback to return the result.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -624,9 +596,7 @@ This API uses an asynchronous callback to return the result. ...@@ -624,9 +596,7 @@ This API uses an asynchronous callback to return the result.
delete(key: string): Promise&lt;void&gt; delete(key: string): Promise&lt;void&gt;
Deletes data with the specified key from this storage object. Deletes data with the specified key from this storage object. This API uses a promise to return the result.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -657,8 +627,6 @@ flushSync(): void ...@@ -657,8 +627,6 @@ flushSync(): void
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Example** **Example**
...@@ -671,9 +639,7 @@ This API uses a synchronous mode. ...@@ -671,9 +639,7 @@ This API uses a synchronous mode.
flush(callback: AsyncCallback&lt;void&gt;): void flush(callback: AsyncCallback&lt;void&gt;): void
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. This API uses an asynchronous callback to return the result.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -698,9 +664,7 @@ This API uses an asynchronous callback to return the result. ...@@ -698,9 +664,7 @@ This API uses an asynchronous callback to return the result.
flush(): Promise&lt;void&gt; flush(): Promise&lt;void&gt;
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. This API uses a promise to return the result.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -726,8 +690,6 @@ clearSync(): void ...@@ -726,8 +690,6 @@ clearSync(): void
Clears this **Storage** object. Clears this **Storage** object.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Example** **Example**
...@@ -740,9 +702,7 @@ This API uses a synchronous mode. ...@@ -740,9 +702,7 @@ This API uses a synchronous mode.
clear(callback: AsyncCallback&lt;void&gt;): void clear(callback: AsyncCallback&lt;void&gt;): void
Clears this **Storage** object. Clears this **Storage** object. This API uses an asynchronous callback to return the result.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -767,9 +727,7 @@ This API uses an asynchronous callback to return the result. ...@@ -767,9 +727,7 @@ This API uses an asynchronous callback to return the result.
clear(): Promise&lt;void&gt; clear(): Promise&lt;void&gt;
Clears this **Storage** object. Clears this **Storage** object. This API uses a promise to return the result.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Distributed data management provides collaboration between databases of different devices for applications. The APIs provided by distributed data management can be used to save data to the distributed database and perform operations such as adding, deleting, modifying, and querying data in the distributed database. Distributed data management provides collaboration between databases of different devices for applications. The APIs provided by distributed data management can be used to save data to the distributed database and perform operations such as adding, deleting, modifying, and querying data in the distributed database.
>![](../../public_sys-resources/icon-note.gif) **NOTE**<br/> >**NOTE**<br/>
>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. >The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -2922,6 +2922,7 @@ These value types can be used only by internal applications. ...@@ -2922,6 +2922,7 @@ These value types can be used only by internal applications.
| BOOLEAN |4 |Boolean. | | BOOLEAN |4 |Boolean. |
| DOUBLE |5 |Double (double-precision floating point). | | DOUBLE |5 |Double (double-precision floating point). |
## SingleKVStore ## SingleKVStore
Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use [getKVStore](#getkvstore) to obtain a **SingleKVStore** object. Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use [getKVStore](#getkvstore) to obtain a **SingleKVStore** object.
...@@ -3447,7 +3448,7 @@ Closes the **KvStoreResultSet** object obtained by **getResultSet**. This API us ...@@ -3447,7 +3448,7 @@ Closes the **KvStoreResultSet** object obtained by **getResultSet**. This API us
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. | | resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the execution result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. |
**Example** **Example**
......
# File Interaction # File Interaction
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br> > **NOTE**<br>
> - 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 will be deprecated and are not recommended for use. An exception will be thrown if any of the APIs is called. > - The APIs of this module will be deprecated and are not recommended for use. An exception will be thrown if any of the APIs is called.
## Modules to Import ## Modules to Import
...@@ -19,15 +19,15 @@ Chooses a file of the specified type using the file manager. This API uses a pro ...@@ -19,15 +19,15 @@ Chooses a file of the specified type using the file manager. This API uses a pro
- Parameters - Parameters
| Name| Type | Mandatory | Description | | Name| Type | Mandatory | Description |
| ------ | ------ | ---- | ---------------------------- | | ------ | ------ | ---- | ---------------------------- |
| type | string[] | No | Type of the file to choose. | | type | string[] | No | Type of the file to choose. |
- Return value - Return value
| Type | Description | | Type | Description |
| --------------------- | -------------- | | --------------------- | -------------- |
| Promise&lt;string&gt; | Promise used to return the result. An error code is returned. | | Promise&lt;string&gt; | Promise used to return the result. An error code is returned. |
- Example - Example
...@@ -44,9 +44,9 @@ Chooses a file using the file manager. This API uses an asynchronous callback to ...@@ -44,9 +44,9 @@ Chooses a file using the file manager. This API uses an asynchronous callback to
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------------------------- | | -------- | --------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. |
- Example - Example
...@@ -65,10 +65,10 @@ Chooses a file of the specified type using the file manager. This API uses an as ...@@ -65,10 +65,10 @@ Chooses a file of the specified type using the file manager. This API uses an as
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------------------------- | | -------- | --------------------------- | ---- | ---------------------------- |
| type | string[] | No | Type of the file to choose. | | type | string[] | No | Type of the file to choose. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. |
- Example - Example
...@@ -88,16 +88,16 @@ Opens a file. This API uses a promise to return the result. ...@@ -88,16 +88,16 @@ Opens a file. This API uses a promise to return the result.
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------- | | ---- | ------ | ---- | ---------------------------- |
| uri | string | Yes | URI of the file to open. | | uri | string | Yes | URI of the file to open. |
| type | string | Yes | Type of the file to open. | | type | string | Yes | Type of the file to open. |
- Return value - Return value
| Type | Description | | Type | Description |
| --------------------- | ------------ | | --------------------- | ------------ |
| Promise&lt;void&gt; | Promise used to return the result. An error code is returned. | | Promise&lt;void&gt; | Promise used to return the result. An error code is returned. |
- Example - Example
...@@ -115,11 +115,11 @@ Opens a file. This API uses an asynchronous callback to return the result. ...@@ -115,11 +115,11 @@ Opens a file. This API uses an asynchronous callback to return the result.
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------------------------- | | -------- | --------------------------- | ---- | ---------------------------- |
| uri | string | Yes | URI of the file to open. | | uri | string | Yes | URI of the file to open. |
| type | string | Yes | Type of the file to open. | | type | string | Yes | Type of the file to open. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. An error code is returned. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. An error code is returned. |
- Example - Example
......
# Emitter # Emitter
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br> > **NOTE**<br>
> The initial APIs of this module are supported since API version 7. > The initial APIs of this module are supported since API version 7.
## Modules to Import ## Modules to Import
...@@ -17,12 +17,12 @@ None ...@@ -17,12 +17,12 @@ None
Enumerates the event emit priority levels. Enumerates the event emit priority levels.
| Name | Value | Description | | Name | Value | Description |
| --------- | ---- | ------------------------------------------------- | | --------- | ---- | ------------------------------------------------- |
| IMMEDIATE | 0 | The event will be emitted immediately.<br>**System capability**: SystemCapability.Notification.Emitter | | IMMEDIATE | 0 | The event will be emitted immediately.<br>**System capability**: SystemCapability.Notification.Emitter |
| HIGH | 1 | The event will be emitted before low-priority events.<br>**System capability**: SystemCapability.Notification.Emitter | | HIGH | 1 | The event will be emitted before low-priority events.<br>**System capability**: SystemCapability.Notification.Emitter |
| LOW | 2 | The event will be emitted before idle-priority events. By default, an event is in LOW priority.<br>**System capability**: SystemCapability.Notification.Emitter | | LOW | 2 | The event will be emitted before idle-priority events. By default, an event is in LOW priority.<br>**System capability**: SystemCapability.Notification.Emitter |
| IDLE | 3 | The event will be emitted after all the other events.<br>**System capability**: SystemCapability.Notification.Emitter | | IDLE | 3 | The event will be emitted after all the other events.<br>**System capability**: SystemCapability.Notification.Emitter |
## emitter.on ## emitter.on
...@@ -34,10 +34,10 @@ Subscribes to an event in persistent manner. This API uses a callback to return ...@@ -34,10 +34,10 @@ Subscribes to an event in persistent manner. This API uses a callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------------- | ---- | ------------------------ | | -------- | ----------------------------------- | ---- | ------------------------ |
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. | | event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. |
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. | | callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. |
**Example** **Example**
...@@ -61,10 +61,10 @@ Subscribes to an event in one-shot manner and unsubscribes from it after the eve ...@@ -61,10 +61,10 @@ Subscribes to an event in one-shot manner and unsubscribes from it after the eve
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------------- | ---- | ------------------------ | | -------- | ----------------------------------- | ---- | ------------------------ |
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. | | event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. |
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. | | callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. |
**Example** **Example**
...@@ -88,9 +88,9 @@ Unsubscribes from an event. ...@@ -88,9 +88,9 @@ Unsubscribes from an event.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ------ | | ------- | ------ | ---- | ------ |
| eventId | number | Yes | Event ID. | | eventId | number | Yes | Event ID. |
**Example** **Example**
...@@ -108,10 +108,10 @@ Emits an event to the event queue. ...@@ -108,10 +108,10 @@ Emits an event to the event queue.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------ | ------------------------- | ---- | -------------- | | ------ | ------------------------- | ---- | -------------- |
| event | [InnerEvent](#innerevent) | Yes | Event to emit. | | event | [InnerEvent](#innerevent) | Yes | Event to emit. |
| data | [EventData](#eventdata) | No | Data carried by the event. | | data | [EventData](#eventdata) | No | Data carried by the event. |
**Example** **Example**
...@@ -132,15 +132,15 @@ emitter.emit(innerEvent, eventData); ...@@ -132,15 +132,15 @@ emitter.emit(innerEvent, eventData);
Describes an intra-process event. Describes an intra-process event.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable | Writable | Description |
| -------- | ------------------------------- | ---- | ---- | ---------------------------------- | | -------- | ------------------------------- | ---- | ---- | ---------------------------------- |
| eventId | number | Yes | Yes | Event ID, which is used to identify an event.<br>**System capability**: SystemCapability.Notification.Emitter | | eventId | number | Yes | Yes | Event ID, which is used to identify an event.<br>**System capability**: SystemCapability.Notification.Emitter |
| priority | [EventPriority](#eventpriority) | Yes | Yes | Emit priority of the event.<br>**System capability**: SystemCapability.Notification.Emitter | | priority | [EventPriority](#eventpriority) | Yes | Yes | Emit priority of the event.<br>**System capability**: SystemCapability.Notification.Emitter |
## EventData ## EventData
Describes the data passed in the event. Describes the data passed in the event.
| Name| Type | Readable| Writable| Description | | Name | Type | Readable | Writable | Description |
| ---- | ------------------ | ---- | ---- | -------------- | | ---- | ------------------ | ---- | ---- | -------------- |
| data | [key: string]: any | Yes | Yes | Data carried by the event. The data type can be String, Integer, or Boolean.<br>**System capability**: SystemCapability.Notification.Emitter | | data | [key: string]: any | Yes | Yes | Data carried by the event. The data type can be String, Integer, or Boolean.<br>**System capability**: SystemCapability.Notification.Emitter |
# Enterprise Device Management # Enterprise Device Management
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
>
> 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 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.
...@@ -28,12 +27,12 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -28,12 +27,12 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application.| | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application. |
| type | [AdminType](#AdminType) | Yes| Type of the device administrator to activate.| | type | [AdminType](#AdminType) | Yes | Type of the device administrator to activate. |
| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result.| | callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -71,17 +70,17 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -71,17 +70,17 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------------- | ---------------------------------------------- | ---- | ------------------------ | | -------------- | ---------------------------------------------- | ---- | ------------------------ |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application.| | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application. |
| type | [AdminType](#AdminType) | Yes | Type of the device administrator to activate. | | type | [AdminType](#AdminType) | Yes | Type of the device administrator to activate. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | --------------------------- | | ----------------- | --------------------------- |
| Promise\<boolean> | Promise used to return the result.| | Promise\<boolean> | Promise used to return the result. |
**Example** **Example**
...@@ -118,10 +117,10 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -118,10 +117,10 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------------- | ---- | ------------------------------ | | -------- | ---------------------------------------------- | ---- | ------------------------------ |
| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.| | callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -157,15 +156,15 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -157,15 +156,15 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------ | ---------------------------------------------- | ---- | ------------------ | | ------ | ---------------------------------------------- | ---- | ------------------ |
| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application.| | admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | --------------------------- | | ----------------- | --------------------------- |
| Promise\<boolean> | Promise used to return the result.| | Promise\<boolean> | Promise used to return the result. |
**Example** **Example**
...@@ -193,10 +192,10 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -193,10 +192,10 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ----------------------- | ---- | ------------------------------ | | ---------- | ----------------------- | ---- | ------------------------------ |
| bundleName | String | Yes | Bundle name of a device super administrator application. | | bundleName | String | Yes | Bundle name of a device super administrator application. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.| | callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -223,15 +222,15 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -223,15 +222,15 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ------------------------ | | ---------- | ------ | ---- | ------------------------ |
| bundleName | String | Yes | Bundle name of a device super administrator application.| | bundleName | String | Yes | Bundle name of a device super administrator application. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | --------------------------- | | ----------------- | --------------------------- |
| Promise\<boolean> | Promise used to return the result.| | Promise\<boolean> | Promise used to return the result. |
**Example** **Example**
...@@ -256,10 +255,10 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -256,10 +255,10 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------------- | ---- | -------------------------------- | | -------- | ---------------------------------------------- | ---- | -------------------------------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.| | callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -291,15 +290,15 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -291,15 +290,15 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------ | ---------------------------------------------- | ---- | -------------- | | ------ | ---------------------------------------------- | ---- | -------------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ------------------------------- | | ----------------- | ------------------------------- |
| Promise\<boolean> | Promise used to return the result.| | Promise\<boolean> | Promise used to return the result. |
**Example** **Example**
...@@ -327,10 +326,10 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -327,10 +326,10 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ----------------------- | ---- | -------------------------------- | | ---------- | ----------------------- | ---- | -------------------------------- |
| bundleName | String | Yes | Bundle name of a device super administrator application. | | bundleName | String | Yes | Bundle name of a device super administrator application. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.| | callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -359,15 +358,15 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -359,15 +358,15 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ------------------ | | ---------- | ------ | ---- | ------------------ |
| bundleName | String | Yes | Bundle name of a device super administrator application.| | bundleName | String | Yes | Bundle name of a device super administrator application. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ------------------------------- | | ----------------- | ------------------------------- |
| Promise\<boolean> | Promise used to return the result.| | Promise\<boolean> | Promise used to return the result. |
**Example** **Example**
...@@ -392,9 +391,9 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -392,9 +391,9 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback<DeviceSettingsManager&gt; | Yes | Callback used to return the **DeviceSettingsManager** object obtained.| | callback | AsyncCallback<DeviceSettingsManager&gt; | Yes | Callback used to return the **DeviceSettingsManager** object obtained. |
**Example** **Example**
...@@ -431,9 +430,9 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -431,9 +430,9 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| Promise&lt;DeviceSettingsManager&gt; | Promise used to return the **DeviceSettingsManager** object obtained.| | Promise&lt;DeviceSettingsManager&gt; | Promise used to return the **DeviceSettingsManager** object obtained. |
**Example** **Example**
...@@ -465,11 +464,11 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -465,11 +464,11 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------------- | ---------------------------------------------- | ---- | ------------------------------------ | | -------------- | ---------------------------------------------- | ---- | ------------------------------------ |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application. | | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application. |
| callback | AsyncCallback\<boolean&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback\<boolean&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -503,16 +502,16 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -503,16 +502,16 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------------- | ---------------------------------------------- | ---- | ------------------------ | | -------------- | ---------------------------------------------- | ---- | ------------------------ |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application.| | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | ----------------------------------- | | ------------------ | ----------------------------------- |
| Promise\<boolean>; | Callback used to return the result.| | Promise\<boolean>; | Callback used to return the result. |
**Example** **Example**
...@@ -545,10 +544,10 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -545,10 +544,10 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------ | ---- | ---------------------------------------- | | -------- | ------------------------------------------------------ | ---- | ---------------------------------------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
| callback | AsyncCallback&lt;[EnterpriseInfo](#EnterpriseInfo)&gt; | Yes | Callback used to return the enterprise information of the device administrator application.| | callback | AsyncCallback&lt;[EnterpriseInfo](#EnterpriseInfo)&gt; | Yes | Callback used to return the enterprise information of the device administrator application. |
**Example** **Example**
...@@ -570,7 +569,7 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => { ...@@ -570,7 +569,7 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => {
## enterpriseDeviceManager.getEnterpriseInfo ## enterpriseDeviceManager.getEnterpriseInfo
getDeviceSettingsManager(admin: Want): Promise&lt;EnterpriseInfo&gt; getEnterpriseInfo(admin: Want): Promise&lt;EnterpriseInfo&gt;
Obtains the enterprise information of a device administrator application. This API uses a promise to return the result. Obtains the enterprise information of a device administrator application. This API uses a promise to return the result.
...@@ -580,15 +579,15 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -580,15 +579,15 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------ | ---------------------------------------------- | ---- | -------------- | | ------ | ---------------------------------------------- | ---- | -------------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------------ | ------------------------------------------- | | ------------------------------------------------ | ------------------------------------------- |
| Promise&lt;[EnterpriseInfo](#EnterpriseInfo)&gt; | Promise used to return the enterprise information of the device administrator application.| | Promise&lt;[EnterpriseInfo](#EnterpriseInfo)&gt; | Promise used to return the enterprise information of the device administrator application. |
**Example** **Example**
...@@ -613,10 +612,10 @@ Describes the enterprise information of a device administrator application. ...@@ -613,10 +612,10 @@ Describes the enterprise information of a device administrator application.
SystemCapability.Customation.EnterpriseDeviceManager SystemCapability.Customation.EnterpriseDeviceManager
| Name | Readable/Writable| Type | Mandatory| Description | | Name | Readable/Writable | Type | Mandatory | Description |
| ----------- | -------- | ------ | ---- | ---------------------------------- | | ----------- | -------- | ------ | ---- | ---------------------------------- |
| name | Read only | string | Yes | Name of the enterprise to which the device administrator application belongs.| | name | Read only | string | Yes | Name of the enterprise to which the device administrator application belongs. |
| description | Read only | string | Yes | Description of the enterprise to which the device administrator application belongs.| | description | Read only | string | Yes | Description of the enterprise to which the device administrator application belongs. |
## AdminType ## AdminType
...@@ -627,7 +626,7 @@ Enumerates the administrator types of the device administrator application. ...@@ -627,7 +626,7 @@ Enumerates the administrator types of the device administrator application.
SystemCapability.Customation.EnterpriseDeviceManager SystemCapability.Customation.EnterpriseDeviceManager
| Name| Default Value| Description| | Name | Default Value | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ADMIN_TYPE_NORMAL | 0x00 | Common administrator.| | ADMIN_TYPE_NORMAL | 0x00 | Common administrator. |
| ADMIN_TYPE_SUPER | 0x01 | Super administrator.| | ADMIN_TYPE_SUPER | 0x01 | Super administrator. |
# EventHub # EventHub
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br> > **NOTE**<br>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -34,10 +34,10 @@ Subscribes to an event. ...@@ -34,10 +34,10 @@ Subscribes to an event.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| event | string | Yes| Event name. | | event | string | Yes | Event name. |
| callback | Function | Yes| Callback invoked when the event is triggered. | | callback | Function | Yes | Callback invoked when the event is triggered. |
**Example** **Example**
...@@ -72,10 +72,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes ...@@ -72,10 +72,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| event | string | Yes| Event name. | | event | string | Yes | Event name. |
| callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. | | callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. |
**Example** **Example**
...@@ -110,10 +110,10 @@ Triggers an event. ...@@ -110,10 +110,10 @@ Triggers an event.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| event | string | Yes| Event name. | | event | string | Yes | Event name. |
| ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered. | | ...args | Object[] | Yes | Variable parameters, which are passed to the callback when the event is triggered. |
**Example** **Example**
......
# Data Storage # Data Storage
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> >
> - The APIs of this module are no longer maintained since API Version 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From 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 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From API Version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md).
> >
...@@ -67,7 +67,7 @@ Sets the value in the cache based on the specified key. ...@@ -67,7 +67,7 @@ Sets the value in the cache based on the specified key.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the value to set.| | key | string | Yes| Key of the data to set.|
| value | string | Yes| New value to set. The maximum length is 128 bytes.| | value | string | Yes| New value to set. The maximum length is 128 bytes.|
| success | Function | No| Called when **storage.set()** is successful.| | success | Function | No| Called when **storage.set()** is successful.|
| fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.| | fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
......
# User Authentication # User Authentication
> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE**<br/> > **NOTE**<br>
> 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.
...@@ -122,7 +122,7 @@ Obtains an **Authenticator** object for user authentication. ...@@ -122,7 +122,7 @@ Obtains an **Authenticator** object for user authentication.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------- | ------------ | | ----------------------------------------- | ------------ |
| [Authenticator](#authenticatordeprecated) | **Authenticator** object obtained.| | [Authenticator](#authenticatordeprecated) | **Authenticator** object obtained. |
**Example** **Example**
```js ```js
...@@ -144,7 +144,7 @@ execute(type: string, level: string, callback: AsyncCallback&lt;number&gt;): voi ...@@ -144,7 +144,7 @@ execute(type: string, level: string, callback: AsyncCallback&lt;number&gt;): voi
> **NOTE**<br/> > **NOTE**<br/>
> This API is not longer maintained since API version 8. You are advised to use [auth](#auth8). > This API is not longer maintained since API version 8. You are advised to use [auth](#auth8).
Performs user authentication. This method uses asynchronous callback to return the result. Performs user authentication. This API uses asynchronous callback to return the result.
**Required permissions**: ohos.permission.ACCESS_BIOMETRIC **Required permissions**: ohos.permission.ACCESS_BIOMETRIC
...@@ -154,15 +154,15 @@ Performs user authentication. This method uses asynchronous callback to return t ...@@ -154,15 +154,15 @@ Performs user authentication. This method uses asynchronous callback to return t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.<br>**ALL** is reserved and not supported by the current version.| | type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.<br>**ALL** is reserved and not supported by the current version. |
| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).<br>Devices capable of 3D facial recognition support S3 and lower-level authentication.<br>Devices capable of 2D facial recognition support S2 and lower-level authentication.| | level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).<br>Devices capable of 3D facial recognition support S3 and lower-level authentication.<br>Devices capable of 2D facial recognition support S2 and lower-level authentication. |
| callback | AsyncCallback&lt;number&gt; | No | Callback used to return the result. | | callback | AsyncCallback&lt;number&gt; | No | Callback used to return the result. |
Parameters returned in callback Parameters returned in callback
| Type | Description | | Type | Description |
| ------ | ------------------------------------------------------------ | | ------ | ------------------------------------------------------------ |
| number | Authentication result. For details, see [AuthenticationResult](#authenticationresultdeprecated).| | number | Authentication result. For details, see [AuthenticationResult](#authenticationresultdeprecated). |
**Example** **Example**
```js ```js
...@@ -183,7 +183,7 @@ execute(type:string, level:string): Promise&lt;number&gt; ...@@ -183,7 +183,7 @@ execute(type:string, level:string): Promise&lt;number&gt;
> **NOTE**<br/> > **NOTE**<br/>
> This API is not longer maintained since API version 8. You are advised to use [auth](#auth8). > This API is not longer maintained since API version 8. You are advised to use [auth](#auth8).
Performs user authentication. This method uses a promise to return the result. Performs user authentication. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ACCESS_BIOMETRIC **Required permissions**: ohos.permission.ACCESS_BIOMETRIC
...@@ -192,13 +192,13 @@ Performs user authentication. This method uses a promise to return the result. ...@@ -192,13 +192,13 @@ Performs user authentication. This method uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.<br>**ALL** is reserved and not supported by the current version.| | type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.<br>**ALL** is reserved and not supported by the current version. |
| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).<br>Devices capable of 3D facial recognition support S3 and lower-level authentication.<br>Devices capable of 2D facial recognition support S2 and lower-level authentication.| | level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).<br>Devices capable of 3D facial recognition support S3 and lower-level authentication.<br>Devices capable of 2D facial recognition support S2 and lower-level authentication. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------------------------ | | --------------------- | ------------------------------------------------------------ |
| Promise&lt;number&gt; | Promise used to return the authentication result, which is a number. For details, see [AuthenticationResult](#authenticationresultdeprecated).| | Promise&lt;number&gt; | Promise used to return the authentication result, which is a number. For details, see [AuthenticationResult](#authenticationresultdeprecated). |
**Example** **Example**
...@@ -222,7 +222,7 @@ Enumerates the authentication results. ...@@ -222,7 +222,7 @@ Enumerates the authentication results.
| Name | Default Value| Description | | Name | Default Value| Description |
| ------------------ | ------ | -------------------------- | | ------------------ | ------ | -------------------------- |
| NO_SUPPORT | -1 | The device does not support the current authentication mode.| | NO_SUPPORT | -1 | The device does not support the current authentication mode. |
| SUCCESS | 0 | The authentication is successful. | | SUCCESS | 0 | The authentication is successful. |
| COMPARE_FAILURE | 1 | The feature comparison failed. | | COMPARE_FAILURE | 1 | The feature comparison failed. |
| CANCELED | 2 | The authentication was canceled by the user. | | CANCELED | 2 | The authentication was canceled by the user. |
...@@ -230,7 +230,7 @@ Enumerates the authentication results. ...@@ -230,7 +230,7 @@ Enumerates the authentication results.
| CAMERA_FAIL | 4 | The camera failed to start. | | CAMERA_FAIL | 4 | The camera failed to start. |
| BUSY | 5 | The authentication service is not available. Try again later. | | BUSY | 5 | The authentication service is not available. Try again later. |
| INVALID_PARAMETERS | 6 | The authentication parameters are invalid. | | INVALID_PARAMETERS | 6 | The authentication parameters are invalid. |
| LOCKED | 7 | The user account is locked because the number of authentication failures has reached the threshold.| | LOCKED | 7 | The user account is locked because the number of authentication failures has reached the threshold. |
| NOT_ENROLLED | 8 | No authentication credential is registered. | | NOT_ENROLLED | 8 | No authentication credential is registered. |
| GENERAL_ERROR | 100 | Other errors. | | GENERAL_ERROR | 100 | Other errors. |
...@@ -252,7 +252,7 @@ A constructor used to create an **authenticator** object. ...@@ -252,7 +252,7 @@ A constructor used to create an **authenticator** object.
| Type | Description | | Type | Description |
| ---------------------- | -------------------- | | ---------------------- | -------------------- |
| [UserAuth](#userauth8) | **Authenticator** object obtained.| | [UserAuth](#userauth8) | **Authenticator** object obtained. |
**Example** **Example**
...@@ -276,7 +276,7 @@ Obtains the authentication executor version. ...@@ -276,7 +276,7 @@ Obtains the authentication executor version.
| Type | Description | | Type | Description |
| ------ | ---------------------- | | ------ | ---------------------- |
| number | Authentication executor version obtained.| | number | Authentication executor version obtained. |
**Example** **Example**
...@@ -302,14 +302,14 @@ Checks whether the authentication capability of the specified trust level is ava ...@@ -302,14 +302,14 @@ Checks whether the authentication capability of the specified trust level is ava
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | ---------------------------------- | ---- | -------------------------- | | -------------- | ---------------------------------- | ---- | -------------------------- |
| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported.| | authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported. |
| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level of the authentication result. | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level of the authentication result. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------------------------------------------ | | ------ | ------------------------------------------------------------ |
| number | Whether the authentication capability of the specified trust level is available. For details, see [ResultCode](#resultcode8).| | number | Whether the authentication capability of the specified trust level is available. For details, see [ResultCode](#resultcode8). |
**Example** **Example**
...@@ -331,7 +331,7 @@ Checks whether the authentication capability of the specified trust level is ava ...@@ -331,7 +331,7 @@ Checks whether the authentication capability of the specified trust level is ava
auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array
Performs user authentication. This method uses a callback to return the result. Performs user authentication. This API uses a callback to return the result.
**Required permissions**: ohos.permission.ACCESS_BIOMETRIC **Required permissions**: ohos.permission.ACCESS_BIOMETRIC
...@@ -342,7 +342,7 @@ Performs user authentication. This method uses a callback to return the result. ...@@ -342,7 +342,7 @@ Performs user authentication. This method uses a callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | ---------------------------------------- | ---- | ------------------------ | | -------------- | ---------------------------------------- | ---- | ------------------------ |
| challenge | Uint8Array | Yes | Challenge value, which can be null. | | challenge | Uint8Array | Yes | Challenge value, which can be null. |
| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported.| | authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported. |
| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level. | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level. |
| callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback used to return the result. | | callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback used to return the result. |
...@@ -350,7 +350,7 @@ Performs user authentication. This method uses a callback to return the result. ...@@ -350,7 +350,7 @@ Performs user authentication. This method uses a callback to return the result.
| Type | Description | | Type | Description |
| ---------- | ------------------------------------------------------------ | | ---------- | ------------------------------------------------------------ |
| Uint8Array | ContextId, which is used as the input parameter of [cancelAuth](#cancelauth8).| | Uint8Array | ContextId, which is used as the input parameter of [cancelAuth](#cancelauth8). |
**Example** **Example**
...@@ -389,13 +389,13 @@ Cancels an authentication. ...@@ -389,13 +389,13 @@ Cancels an authentication.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ---------- | ---- | ------------------------------------------ | | --------- | ---------- | ---- | ------------------------------------------ |
| contextID | Uint8Array | Yes | Context ID, which is obtained using [auth](#auth8).| | contextID | Uint8Array | Yes | Context ID, which is obtained using [auth](#auth8). |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------ | | ------ | ------------------------ |
| number | Whether the authentication is canceled.| | number | Whether the authentication is canceled. |
**Example** **Example**
...@@ -429,7 +429,7 @@ Obtains the authentication result. ...@@ -429,7 +429,7 @@ Obtains the authentication result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | -------------------------- | ---- | ------------------------------------------------------------ | | --------- | -------------------------- | ---- | ------------------------------------------------------------ |
| result | number | Yes | Authentication result obtained. For details, see [ResultCode](#resultcode8). | | result | number | Yes | Authentication result obtained. For details, see [ResultCode](#resultcode8). |
| extraInfo | [AuthResult](#authresult8) | Yes | Extended information, which varies depending on the authentication result.<br>If the authentication is successful, the user authentication token will be returned in **extraInfo**.<br>If the authentication fails, the remaining number of authentication times will be returned in **extraInfo**.<br>If the authentication executor is locked, the freeze time will be returned in **extraInfo**.| | extraInfo | [AuthResult](#authresult8) | Yes | Extended information, which varies depending on the authentication result.<br>If the authentication is successful, the user authentication token will be returned in **extraInfo**.<br>If the authentication fails, the remaining number of authentication times will be returned in **extraInfo**.<br>If the authentication executor is locked, the freeze time will be returned in **extraInfo**. |
**Example** **Example**
...@@ -478,7 +478,7 @@ Obtains the tip code information during authentication. This function is optiona ...@@ -478,7 +478,7 @@ Obtains the tip code information during authentication. This function is optiona
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ------------------------------ | | --------- | ------ | ---- | ------------------------------ |
| module | number | Yes | Type of the authentication executor. | | module | number | Yes | Type of the authentication executor. |
| acquire | number | Yes | Interaction information of the authentication executor during the authentication process.| | acquire | number | Yes | Interaction information of the authentication executor during the authentication process. |
| extraInfo | any | Yes | Reserved field. | | extraInfo | any | Yes | Reserved field. |
**Example** **Example**
...@@ -523,8 +523,8 @@ Represents the authentication result object. ...@@ -523,8 +523,8 @@ Represents the authentication result object.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | ---------- | ---- | -------------------- | | ------------ | ---------- | ---- | -------------------- |
| token | Uint8Array | No | Identity authentication token. | | token | Uint8Array | No | Identity authentication token. |
| remainTimes | number | No | Number of remaining authentication operations.| | remainTimes | number | No | Number of remaining authentication operations. |
| freezingTime | number | No | Time for which the authentication operation is frozen.| | freezingTime | number | No | Time for which the authentication operation is frozen. |
## ResultCode<sup>8+</sup> ## ResultCode<sup>8+</sup>
...@@ -544,7 +544,7 @@ Enumerates the operation results. ...@@ -544,7 +544,7 @@ Enumerates the operation results.
| BUSY | 7 | Indicates the busy state. | | BUSY | 7 | Indicates the busy state. |
| INVALID_PARAMETERS | 8 | Invalid parameters are detected. | | INVALID_PARAMETERS | 8 | Invalid parameters are detected. |
| LOCKED | 9 | The authentication executor is locked. | | LOCKED | 9 | The authentication executor is locked. |
| NOT_ENROLLED | 10 | The user has not entered the authentication information.| | NOT_ENROLLED | 10 | The user has not entered the authentication information. |
## FaceTips<sup>8+</sup> ## FaceTips<sup>8+</sup>
...@@ -563,7 +563,7 @@ Enumerates the tip codes used during the facial authentication process. ...@@ -563,7 +563,7 @@ Enumerates the tip codes used during the facial authentication process.
| FACE_AUTH_TIP_TOO_LOW | 6 | Only the lower part of the face is captured because the device is angled too low. | | FACE_AUTH_TIP_TOO_LOW | 6 | Only the lower part of the face is captured because the device is angled too low. |
| FACE_AUTH_TIP_TOO_RIGHT | 7 | Only the right part of the face is captured because the device is deviated to the right. | | FACE_AUTH_TIP_TOO_RIGHT | 7 | Only the right part of the face is captured because the device is deviated to the right. |
| FACE_AUTH_TIP_TOO_LEFT | 8 | Only the left part of the face is captured because the device is deviated to the left. | | FACE_AUTH_TIP_TOO_LEFT | 8 | Only the left part of the face is captured because the device is deviated to the left. |
| FACE_AUTH_TIP_TOO_MUCH_MOTION | 9 | The face moves too fast during facial information collection.| | FACE_AUTH_TIP_TOO_MUCH_MOTION | 9 | The face moves too fast during facial information collection. |
| FACE_AUTH_TIP_POOR_GAZE | 10 | The face is not facing the camera. | | FACE_AUTH_TIP_POOR_GAZE | 10 | The face is not facing the camera. |
| FACE_AUTH_TIP_NOT_DETECTED | 11 | No face is detected. | | FACE_AUTH_TIP_NOT_DETECTED | 11 | No face is detected. |
...@@ -577,7 +577,7 @@ Enumerates the tip codes used during the fingerprint authentication process. ...@@ -577,7 +577,7 @@ Enumerates the tip codes used during the fingerprint authentication process.
| Name | Default Value| Description | | Name | Default Value| Description |
| --------------------------------- | ------ | -------------------------------------------------- | | --------------------------------- | ------ | -------------------------------------------------- |
| FINGERPRINT_AUTH_TIP_GOOD | 0 | The obtained fingerprint image is in good condition. | | FINGERPRINT_AUTH_TIP_GOOD | 0 | The obtained fingerprint image is in good condition. |
| FINGERPRINT_AUTH_TIP_DIRTY | 1 | Large fingerprint image noise is detected due to suspicious or detected dirt on the sensor.| | FINGERPRINT_AUTH_TIP_DIRTY | 1 | Large fingerprint image noise is detected due to suspicious or detected dirt on the sensor. |
| FINGERPRINT_AUTH_TIP_INSUFFICIENT | 2 | The noise of the fingerprint image is too large to be processed. | | FINGERPRINT_AUTH_TIP_INSUFFICIENT | 2 | The noise of the fingerprint image is too large to be processed. |
| FINGERPRINT_AUTH_TIP_PARTIAL | 3 | Incomplete fingerprint image is detected. | | FINGERPRINT_AUTH_TIP_PARTIAL | 3 | Incomplete fingerprint image is detected. |
| FINGERPRINT_AUTH_TIP_TOO_FAST | 4 | The fingerprint image is incomplete due to fast movement. | | FINGERPRINT_AUTH_TIP_TOO_FAST | 4 | The fingerprint image is incomplete due to fast movement. |
...@@ -592,8 +592,8 @@ Enumerates the identity authentication types. ...@@ -592,8 +592,8 @@ Enumerates the identity authentication types.
| Name | Default Value| Description | | Name | Default Value| Description |
| ----------- | ------ | ---------- | | ----------- | ------ | ---------- |
| FACE | 2 | Facial authentication.| | FACE | 2 | Facial authentication. |
| FINGERPRINT | 4 | Fingerprint authentication.| | FINGERPRINT | 4 | Fingerprint authentication. |
## AuthTrustLevel<sup>8+</sup> ## AuthTrustLevel<sup>8+</sup>
...@@ -603,7 +603,7 @@ Enumerates the trust levels of the authentication result. ...@@ -603,7 +603,7 @@ Enumerates the trust levels of the authentication result.
| Name| Default Value| Description | | Name| Default Value| Description |
| ---- | ------ | ------------------------- | | ---- | ------ | ------------------------- |
| ATL1 | 10000 | Trust level 1.| | ATL1 | 10000 | Trust level 1. |
| ATL2 | 20000 | Trust level 2.| | ATL2 | 20000 | Trust level 2. |
| ATL3 | 30000 | Trust level 3.| | ATL3 | 30000 | Trust level 3. |
| ATL4 | 40000 | Trust level 4.| | ATL4 | 40000 | Trust level 4. |
# Vibrator # Vibrator
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -23,14 +23,14 @@ Triggers vibration with a specific duration. This API uses a promise to return t ...@@ -23,14 +23,14 @@ Triggers vibration with a specific duration. This API uses a promise to return t
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------ | | -------- | ------ | ---- | ------------ |
| duration | number | Yes | Vibration duration.| | duration | number | Yes | Vibration duration. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------- | | ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully.| | Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully. |
**Example** **Example**
...@@ -54,10 +54,10 @@ Triggers vibration with a specific duration. This API uses an asynchronous callb ...@@ -54,10 +54,10 @@ Triggers vibration with a specific duration. This API uses an asynchronous callb
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ----------------------- | | -------- | ------------------------- | ---- | ----------------------- |
| duration | number | Yes | Vibration duration. | | duration | number | Yes | Vibration duration. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully. |
**Example** **Example**
``` ```
...@@ -82,14 +82,14 @@ Triggers vibration with a specific effect. This API uses a promise to return the ...@@ -82,14 +82,14 @@ Triggers vibration with a specific effect. This API uses a promise to return the
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------- | ---- | ------------- | | -------- | --------------------- | ---- | ------------- |
| effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect.| | effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------- | | ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully.| | Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully. |
**Example** **Example**
``` ```
...@@ -112,10 +112,10 @@ Triggers vibration with a specific effect. This API uses an asynchronous callbac ...@@ -112,10 +112,10 @@ Triggers vibration with a specific effect. This API uses an asynchronous callbac
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ----------------------- | | -------- | ------------------------- | ---- | ----------------------- |
| effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. | | effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully. |
**Example** **Example**
``` ```
...@@ -140,14 +140,14 @@ Stops the vibration based on the specified **stopMode**. This API uses a promise ...@@ -140,14 +140,14 @@ Stops the vibration based on the specified **stopMode**. This API uses a promise
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------- | ---- | --------------- | | -------- | ------------------------------------- | ---- | --------------- |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop.| | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------- | | ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is stopped successfully.| | Promise&lt;void&gt; | Promise used to indicate whether the vibration is stopped successfully. |
**Example** **Example**
``` ```
...@@ -170,10 +170,10 @@ Stops the vibration based on the specified **stopMode**. This API uses an asynch ...@@ -170,10 +170,10 @@ Stops the vibration based on the specified **stopMode**. This API uses an asynch
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------- | ---- | ----------------------- | | -------- | ------------------------------------- | ---- | ----------------------- |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. | | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is stopped successfully.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is stopped successfully. |
**Example** **Example**
``` ```
...@@ -193,9 +193,9 @@ Describes the vibration effect. ...@@ -193,9 +193,9 @@ Describes the vibration effect.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value | Description | | Name | Default Value | Description |
| ------------------ | -------------------- | --------------- | | ------------------ | -------------------- | --------------------------------------------------------------- |
| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer.| | EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer. |
## VibratorStopMode ## VibratorStopMode
...@@ -204,7 +204,7 @@ Describes the vibration mode to stop. ...@@ -204,7 +204,7 @@ Describes the vibration mode to stop.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value | Description | | Name | Default Value | Description |
| ------------------------- | -------- | ---------------------------------------- | | ------------------------- | -------- | ---------------------------------------- |
| VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type.| | VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type. |
| VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type.| | VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type. |
# TextArea # TextArea
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. >
The **&lt;TextArea&gt;** component provides multi-line text input. The **&lt;TextArea&gt;** component provides multi-line text input.
...@@ -90,7 +90,7 @@ Sets the position of the caret. ...@@ -90,7 +90,7 @@ Sets the position of the caret.
``` ```
@Entry @Entry
@Component @Component
struct TextAreaExample2 { struct TextAreaExample1 {
@State text: string = '' @State text: string = ''
build() { build() {
Column() { Column() {
...@@ -126,7 +126,7 @@ struct TextAreaExample2 { ...@@ -126,7 +126,7 @@ struct TextAreaExample2 {
``` ```
@Entry @Entry
@Component @Component
struct TextAreaTest { struct TextAreaExample2 {
controller: TextAreaController = new TextAreaController() controller: TextAreaController = new TextAreaController()
build() { build() {
Column() { Column() {
......
# TextInput # TextInput
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -61,13 +60,21 @@ In addition to universal attributes, the following attributes are supported. ...@@ -61,13 +60,21 @@ In addition to universal attributes, the following attributes are supported.
| InputType.Number | Digit input mode. | | InputType.Number | Digit input mode. |
### TextInputController<sup>8+</sup> ## Events
Implements the controller of the **&lt;TextInput&gt;** component.
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| caretPosition(value: number):void | Position of the input cursor.<br/>**value**: indicates the length from the start of the string to the position where the input cursor is located. | | onChange(value: string) =&gt; void | Triggered when the input changes. |
| onSubmit(callback: (enterKey: EnterKeyType) =&gt; void) | Triggered when the Enter key on the physical or soft keyboard is pressed. |
| onEditChanged(callback:&nbsp;(isEditing:&nbsp;boolean)&nbsp;=&gt;&nbsp;void)<sup>(deprecated) </sup> | Triggered when the input status changes. |
| onEditChange(callback:&nbsp;(isEditing:&nbsp;boolean)&nbsp;=&gt;&nbsp;void) <sup>8+</sup> | Triggered when the input status changes. |
| onCopy<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be copied. |
| onCut<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be cut. |
| onPaste<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be pasted. |
### TextInputController<sup>8+</sup>
Implements the controller of the **&lt;TextInput&gt;** component.
### Objects to Import ### Objects to Import
...@@ -78,7 +85,7 @@ controller: TextInputController = new TextInputController() ...@@ -78,7 +85,7 @@ controller: TextInputController = new TextInputController()
``` ```
### controller.createPosition #### caretPosition
caretPosition(value: number): void caretPosition(value: number): void
...@@ -90,18 +97,6 @@ Sets the cursor in a specified position. ...@@ -90,18 +97,6 @@ Sets the cursor in a specified position.
| value | number | Yes | - | Position of the input cursor.<br/>**value**: indicates the length from the start of the string to the position where the input cursor is located. | | value | number | Yes | - | Position of the input cursor.<br/>**value**: indicates the length from the start of the string to the position where the input cursor is located. |
## Events
| Name | Description |
| -------- | -------- |
| onChange(value: string) =&gt; void | Triggered when the input changes. |
| onSubmit(callback: (enterKey: EnterKeyType) =&gt; void) | Triggered when the Enter key on the physical or soft keyboard is pressed. |
| onEditChanged(callback:&nbsp;(isEditing:&nbsp;boolean)&nbsp;=&gt;&nbsp;void)<sup>(deprecated) </sup> | Triggered when the input status changes. |
| onEditChange(callback:&nbsp;(isEditing:&nbsp;boolean)&nbsp;=&gt;&nbsp;void) <sup>8+</sup> | Triggered when the input status changes. |
| onCopy<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be copied. |
| onCut<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be cut. |
| onPaste<sup>8+</sup>(callback:(value: string) =&gt; void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.<br/>**value**: text to be pasted. |
## Example ## Example
...@@ -112,7 +107,7 @@ Sets the cursor in a specified position. ...@@ -112,7 +107,7 @@ Sets the cursor in a specified position.
``` ```
@Entry @Entry
@Component @Component
struct TextAreaExample2 { struct TextInputExample1 {
@State text: string = '' @State text: string = ''
build() { build() {
...@@ -147,7 +142,7 @@ struct TextAreaExample2 { ...@@ -147,7 +142,7 @@ struct TextAreaExample2 {
``` ```
@Entry @Entry
@Component @Component
struct TextInputTest { struct TextInputExample2 {
@State text: string = '' @State text: string = ''
controller: TextInputController = new TextInputController() controller: TextInputController = new TextInputController()
build() { build() {
......
# Flex # Flex
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;Flex&gt;** component allows for an elastic layout. The **\<Flex>** component allows for an elastic layout.
## Required Permissions ## Required Permissions
...@@ -22,46 +22,45 @@ This component can contain child components. ...@@ -22,46 +22,45 @@ This component can contain child components.
Flex(options?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign }) Flex(options?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign })
Creates a standard **&lt;Flex&gt;** component. Creates a standard **\<Flex>** component.
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| direction | FlexDirection | No | FlexDirection.Row | Direction in which child components are arranged in the **&lt;Flex&gt;** component, that is, the direction of the main axis. | | direction | FlexDirection | No | FlexDirection.Row | Direction in which child components are arranged in the **\<Flex>** component, that is, the direction of the main axis. |
| wrap | FlexWrap | No | FlexWrap.NoWrap | Whether the **&lt;Flex&gt;** component has a single line or multiple lines. | | wrap | FlexWrap | No | FlexWrap.NoWrap | Whether the **\<Flex>** component has a single line or multiple lines. |
| justifyContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in the **&lt;Flex&gt;** component along the main axis. | | justifyContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in the **\<Flex>** component along the main axis. |
| alignItems | [ItemAlign](ts-appendix-enums.md#itemalign-enums) | No | ItemAlign.Stretch | Alignment mode of the child components in the **&lt;Flex&gt;** component along the cross axis. | | alignItems | [ItemAlign](ts-appendix-enums.md#itemalign-enums) | No | ItemAlign.Stretch | Alignment mode of the child components in the **\<Flex>** component along the cross axis. |
| alignContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **&lt;Flex&gt;** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**. | | alignContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **\<Flex>** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**. |
- FlexDirection enums - FlexDirection enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| Row | The child components are arranged in the same direction as the main axis runs along the rows. | | Row | The child components are arranged in the same direction as the main axis runs along the rows. |
| RowReverse | The child components are arranged opposite to the **Row** direction. | | RowReverse | The child components are arranged opposite to the **Row** direction. |
| Column | The child components are arranged in the same direction as the main axis runs down the columns. | | Column | The child components are arranged in the same direction as the main axis runs down the columns. |
| ColumnReverse | The child components are arranged opposite to the **Column** direction. | | ColumnReverse | The child components are arranged opposite to the **Column** direction. |
- FlexWrap enums - FlexWrap enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| NoWrap | The child components in the **&lt;Flex&gt;** component are arranged in a single line, and they may overflow. | | NoWrap | The child components in the **&lt;Flex&gt;** component are arranged in a single line, and they may overflow. |
| Wrap | The child components in the **&lt;Flex&gt;** component are arranged in multiple lines, and they may overflow. | | Wrap | The child components in the **&lt;Flex&gt;** component are arranged in multiple lines, and they may overflow. |
| WrapReverse | The child components in the **&lt;Flex&gt;** component are reversely arranged in multiple lines, and they may overflow. | | WrapReverse | The child components in the **&lt;Flex&gt;** component are reversely arranged in multiple lines, and they may overflow. |
- FlexAlign enums - FlexAlign enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| Start | The child components are aligned with the start edge of the main axis. The first component is aligned with the main-start, and subsequent components are aligned with the previous one. | | Start | The child components are aligned with the start edge of the main axis. The first component is aligned with the main-start, and subsequent components are aligned with the previous one. |
| Center | The child components are aligned in the center of the main axis. The space between the first component and the main-start is the same as that between the last component and the main-end. | | Center | The child components are aligned in the center of the main axis. The space between the first component and the main-start is the same as that between the last component and the main-end. |
| End | The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one. | | End | The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one. |
| SpaceBetween | The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same. | | SpaceBetween | The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same. |
| SpaceAround | The child components are evenly distributed along the main axis, with a half-size space on either end. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components. | | SpaceAround | The child components are evenly distributed along the main axis, with a half-size space on either end. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components. |
| SpaceEvenly | The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same. | | SpaceEvenly | The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same. |
## Example ## Example
``` ```
// Example 01 // Example 01
@Entry @Entry
......
# @Builder # @Builder
The @Builder decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the @Builder decorator are the same as those of the [build Function](ts-function-build.md). The **@Builder** decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the **@Builder** decorator are the same as those of the [build Function](ts-function-build.md).
``` ```
...@@ -42,30 +41,29 @@ struct CompA { ...@@ -42,30 +41,29 @@ struct CompA {
} }
} }
``` ```
## @BuilderParam<sup>8+<sup>
## @BuilderParam<sup>8+</sup> The **@BuilderParam** decorator is used to modify the function type attributes (for example, `@BuilderParam content: () => any;`) in a custom component. When the custom component is initialized, the attributes modified by the **@BuilderParam** decorator must be assigned values.
The @BuilderParam decorator is used to modify the function type attributes (for example, @BuilderParam content: () => any) in a custom component. When the custom component is initialized, the attributes modified by the @BuilderParam decorator must be assigned values.
### Background ### Background
In certain circumstances, you may need to add a specific function, such as a click-to-jump action, to a custom component. However, embedding an event method directly inside of the component can add the function to all places where the component is initialized. This is where the @BuilderParam decorator come into the picture. When initializing a custom component, you can assign a @Builder decorated method to the @BuilderParam decorated attribute, thereby adding the specific function to the custom component. In certain circumstances, you may need to add a specific function, such as a click-to-jump action, to a custom component. However, embedding an event method directly inside of the component will add the function to all places where the component is initialized. This is where the **@BuilderParam** decorator comes into the picture. When initializing a custom component, you can assign a **@Builder** decorated method to the **@BuilderParam** decorated attribute, thereby adding the specific function to the custom component.
### Component Initialization Through Parameters ### Component Initialization Through Parameters
When initializing a custom component through parameters, assign a **@Builder** decorated method to the **@BuilderParam** decorated attribute — **content**, and call the value of **content** in the custom component. If no parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `content: this.specificParam`), define the type of the attribute as a function without a return value (for example, `@BuilderParam content: () => void`). If any parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `callContent: this.specificParam1("111")`), define the type of the attribute as `any` (for example,`@BuilderParam callContent: any;`).
When initializing a custom component through parameters, assign a @Builder decorated method to the @BuilderParam decorated attribute —content, and call the value of content in the custom component.
``` ```
@Component @Component
struct CustomContainer { struct CustomContainer {
header: string = ""; header: string = "";
@BuilderParam content: () => any; @BuilderParam noParam: () => void;
@BuilderParam withParam: any;
footer: string = ""; footer: string = "";
build() { build() {
Column() { Column() {
Text(this.header) Text(this.header)
.fontSize(50) .fontSize(50)
this.content() this.noParam()
this.withParam()
Text(this.footer) Text(this.footer)
.fontSize(50) .fontSize(50)
} }
...@@ -75,7 +73,12 @@ struct CustomContainer { ...@@ -75,7 +73,12 @@ struct CustomContainer {
@Entry @Entry
@Component @Component
struct CustomContainerUser { struct CustomContainerUser {
@Builder specificParam(label: string) { @Builder specificNoParam() {
Column() {
Text("noParam").fontSize(50)
}
}
@Builder SpecificWithParam(label: string) {
Column() { Column() {
Text(label).fontSize(50) Text(label).fontSize(50)
} }
...@@ -85,25 +88,23 @@ struct CustomContainerUser { ...@@ -85,25 +88,23 @@ struct CustomContainerUser {
Column() { Column() {
CustomContainer({ CustomContainer({
header: "Header", header: "Header",
content: this.specificParam("111") noParam: this.specificNoParam,
withParam: this.SpecificWithParam("WithParam"),
footer: "Footer", footer: "Footer",
}) })
} }
} }
} }
``` ```
### Component Initialization Through Trailing Closure ### Component Initialization Through Trailing Closure
In a custom component, use the **@BuilderParam** decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (`CustomComponent(){}`). You can consider a trailing closure as a container and add content to it. For example, you can add a component (`{Column(){Text("content")}`) to a trailing closure. The syntax of the closure is the same as that of [build](../ui/ts-function-build.md). In this scenario, the custom component has one and only one **@BuilderParam** decorated attribute.
In a custom component, use the @BuilderParam decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (CustomComponent(){}). You can consider a trailing closure as a container and add content to it. For example, you can add a component ({Column(){Text("content")}) to the closure. The syntax of the closure is the same as that of [build](ts-function-build.md). In this scenario, the custom component has one and only one @BuilderParam decorated attribute. Example: Add a **\<Column>** component and a click event to the closure, and call the **specificParam** method decorated by **@Builder** in the new **\<Column>** component. After the **\<Column>** component is clicked, the value of the component's `header` attribute will change to `changeHeader`. In addition, when the component is initialized, the content of the trailing closure will be assigned to the `closer` attribute decorated by **@BuilderParam**.
Example: Add a &lt;Column> component and a click event to the closure, and call the specificParam method decorated by @Builder in the new &lt;Column&gt; component. After the &lt;Column&gt; component is clicked, the value of the component's header attribute will be changed to changeHeader. In addition, when the component is initialized, the content of the trailing closure will be assigned to the closer attribute decorated by @BuilderParam.
``` ```
@Component @Component
struct CustomContainer { struct CustomContainer {
header: string = ""; header: string = "";
@BuilderParam closer: () => any; @BuilderParam closer: () => void;
build() { build() {
Column() { Column() {
Text(this.header) Text(this.header)
......
# Creating a Simple Page # Creating a Simple Page
In this section, we will develop an infographic food details page, by building custom components through the container components &lt;Stack&gt; and &lt;Flex&gt; as well as basic components &lt;Image&gt; and &lt;Text&gt;. In this section, we will develop an infographic food details page, by building custom components through the container components **\<Stack>** and **\<Flex>** as well as basic components **\<Image>** and **\<Text>**.
## Building the Stack Layout ## Building the Stack Layout
1. Create a food name. 1. Create a food name.
Delete the code of the build method in the project template, create a &lt;Stack&gt; component, and place the &lt;Text&gt; component in the braces of the &lt;Stack&gt; component so that the &lt;Text&gt; component becomes a child component of the &lt;Stack&gt; component. A &lt;Stack&gt; component consists of one or more child components. The latter child component overwrites the former one. Delete the code of the build method in the project template, create a &lt;Stack&gt; component, and place the **\<Text>** component in the braces of the **\<Stack>** component so that the &lt;Text&gt; component becomes a child component of the &lt;Stack&gt; component. A **\<Stack>** component consists of one or more child components. The latter child component overwrites the former one.
``` ```
@Entry @Entry
...@@ -26,7 +26,7 @@ In this section, we will develop an infographic food details page, by building c ...@@ -26,7 +26,7 @@ In this section, we will develop an infographic food details page, by building c
![en-us_image_0000001222967780](figures/en-us_image_0000001222967780.png) ![en-us_image_0000001222967780](figures/en-us_image_0000001222967780.png)
2. Display food pictures. 2. Display food pictures.
Create an &lt;Image&gt; component and specify a URL for it. The &lt;Image&gt; and &lt;Text&gt; components are mandatory. To display the &lt;Text&gt; component above the &lt;Image&gt; component, you need to declare the &lt;Image&gt; component first. Image resources are stored in the rawfile folder in resources. When referencing the resources in the rawfile folder, use the `"$rawfile('filename')"` format, where filename indicates the relative path of the file in the rawfile folder. Currently, `$rawfile` only allows the &lt;Image&gt; component to reference image resources. Create an **\<Image>** component and specify a URL for it. The **\<Image>** and **\<Text>** components are mandatory. To display the **\<Text>** component above the **\<Image>** component, you need to declare the **\<Image>** component first. Image resources are stored in the **rawfile** folder in **resources**. When referencing the resources in the **rawfile** folder, use the `"$rawfile('filename')"` format, where filename indicates the relative path of the file in the **rawfile** folder. Currently, `$rawfile` only allows the **\<Image>** component to reference image resources.
``` ```
@Entry @Entry
...@@ -137,9 +137,9 @@ In this section, we will develop an infographic food details page, by building c ...@@ -137,9 +137,9 @@ In this section, we will develop an infographic food details page, by building c
![en-us_image_0000001222967772](figures/en-us_image_0000001222967772.png) ![en-us_image_0000001222967772](figures/en-us_image_0000001222967772.png)
7. Adjust the left and bottom margin of the &lt;Text&gt; component. Margin is a shorthand attribute. You can specify the margins of the four edges in a unified manner or separately. The configuration method is as follows: 7. Adjust the left and bottom margin of the **\<Text>** component. **Margin** is a shorthand attribute. You can specify the margins of the four edges in a unified manner or separately. The configuration method is as follows:
1. When the parameter is set to Length, the outer margins of the four edges are specified. For example, **margin(20)** indicates that the outer margins of the top, right, bottom, and left edges are all 20. 1. To set the margins of the four edges in a unified manner, use the **Margin(Length)** format. For example, **margin(20)** indicates that the outer margins of the top, right, bottom, and left edges are all 20.
2. **{top?: Length, right?: Length, bottom?: Length, left?:Length}** specifies the margins of the four edges. For example, **margin({ left: 26, bottom: 17.4 })** indicates that the left margin is 26 and the bottom margin is 17.4. 2. To set the margins of the four edges separately, use the **{top?: Length, right?: Length, bottom?: Length, left?:Length}** format. For example, **margin({ left: 26, bottom: 17.4 })** indicates that the left margin is 26 and the bottom margin is 17.4.
``` ```
...@@ -163,7 +163,8 @@ In this section, we will develop an infographic food details page, by building c ...@@ -163,7 +163,8 @@ In this section, we will develop an infographic food details page, by building c
![en-us_image_0000001222967776](figures/en-us_image_0000001222967776.png) ![en-us_image_0000001222967776](figures/en-us_image_0000001222967776.png)
8. Adjust the structure between components and semanticize component names. Create the FoodDetail page entry component, create a column in **FoodDetail**, and set the alignment to **alignItems(HorizontalAlign.Center)**. Change the name of the MyComponent component to FoodImageDisplay, which is a child component of the FoodDetail component. 8. Adjust the structure between components and semanticize component names. Create the FoodDetail page entry component, create a column in **FoodDetail**, and set the alignment to **alignItems(HorizontalAlign.Center)**. Change the name of the **MyComponent** component to **FoodImageDisplay**, which is a child component of the **FoodDetail** component.
A column is a container component whose child components are vertically arranged. It is a linear layout in essence. Therefore, only the alignment in the cross axis direction can be set. A column is a container component whose child components are vertically arranged. It is a linear layout in essence. Therefore, only the alignment in the cross axis direction can be set.
...@@ -239,10 +240,11 @@ You can use the Flex layout to build a food composition table. In this way you d ...@@ -239,10 +240,11 @@ You can use the Flex layout to build a food composition table. In this way you d
``` ```
2. Create a Flex component to display two food composition categories in the tomato: Calories and Nutrition. 2. Create a Flex component to display two food composition categories in the tomato: Calories and Nutrition.
Calories contains information about calories. Nutrition contains information about protein, fat, carbohydrates, and vitamin C.
Calories contains information about calories. Nutrition contains information about protein, fat, carbohydrates, and vitamin C.
Create the Calories class. Create a Flex component and set its height to 280, and the top, right, and left margins to 30. The Flex component contains three Text child components, which represent the category name (Calories), content name (Calories), and contain value (17 kcal), respectively. By default, child components in the Flex component are arranged horizontally.
Create the Calories class. Create a Flex component and set its height to 280, and the top, right, and left margins to 30. The Flex component contains three Text child components, which represent the category name (Calories), content name (Calories), and contain value (17 kcal), respectively. By default, child components in the Flex component are arranged horizontally.
In the following example, code of FoodImageDisplay is omitted, and only code of ContentTable is provided. In the following example, code of FoodImageDisplay is omitted, and only code of ContentTable is provided.
...@@ -279,7 +281,7 @@ You can use the Flex layout to build a food composition table. In this way you d ...@@ -279,7 +281,7 @@ You can use the Flex layout to build a food composition table. In this way you d
![en-us_image_0000001267767869](figures/en-us_image_0000001267767869.png) ![en-us_image_0000001267767869](figures/en-us_image_0000001267767869.png)
3. Adjust the layout and set the proportion (layoutWeight) of each part. Set the proportion of the category name to 1, and the total proportion of content name and content value to **2**. The content name and content value are in a same Flex, and the content name occupies all remaining space flexGrow(1). 3. Adjust the layout and set the proportion (layoutWeight) of each part. Set the proportion of the category name to **1**, and the total proportion of content name and content value to **2**. The content name and content value are in a same Flex, and the content name occupies all remaining space flexGrow(1).
``` ```
@Component @Component
...@@ -336,6 +338,7 @@ You can use the Flex layout to build a food composition table. In this way you d ...@@ -336,6 +338,7 @@ You can use the Flex layout to build a food composition table. In this way you d
![en-us_image_0000001267607901](figures/en-us_image_0000001267607901.png) ![en-us_image_0000001267607901](figures/en-us_image_0000001267607901.png)
4. Create the **Nutrient** class in a similar process. Nutrition consists of four parts: Protein, Fat, Carbohydrates, and VitaminC. The names of the last three parts are omitted in the table and represented by spaces. 4. Create the **Nutrient** class in a similar process. Nutrition consists of four parts: Protein, Fat, Carbohydrates, and VitaminC. The names of the last three parts are omitted in the table and represented by spaces.
Set **FlexDirection.Column**, **FlexAlign.SpaceBetween**, and **ItemAlign.Start**. Set **FlexDirection.Column**, **FlexAlign.SpaceBetween**, and **ItemAlign.Start**.
...@@ -467,7 +470,7 @@ You can use the Flex layout to build a food composition table. In this way you d ...@@ -467,7 +470,7 @@ You can use the Flex layout to build a food composition table. In this way you d
} }
``` ```
When the IngredientItem API is called in the build method of ContentTable, this needs to be used to invoke the method in the scope of the component to distinguish the global method call. When the ` IngredientItem` API is called in the build method of ContentTable, ` this ` needs to be used to invoke the method in the scope of the component to distinguish the global method call.
``` ```
...@@ -488,7 +491,7 @@ You can use the Flex layout to build a food composition table. In this way you d ...@@ -488,7 +491,7 @@ You can use the Flex layout to build a food composition table. In this way you d
} }
``` ```
The overall code of the ContentTable component is as follows: The overall code of the ContentTable component is as follows:
``` ```
...@@ -537,6 +540,6 @@ You can use the Flex layout to build a food composition table. In this way you d ...@@ -537,6 +540,6 @@ You can use the Flex layout to build a food composition table. In this way you d
} }
``` ```
![en-us_image_0000001222807792](figures/en-us_image_0000001222807792.png) ![en-us_image_0000001222807792](figures/en-us_image_0000001222807792.png)
You've learned how to build a simple food details page. Read on to learn how to define the page layout and connection. You've learned how to build a simple food details page. Read on to learn how to define the page layout and connection.
...@@ -12,17 +12,17 @@ To implement grid layout, the declarative paradigm provides the [GridContainer]( ...@@ -12,17 +12,17 @@ To implement grid layout, the declarative paradigm provides the [GridContainer](
## Grid System ## Grid System
The grid system works in terms of columns, margins, and gutters. The grid system works in terms of gutter, margin, and column.
![en-us_image_0000001217236574](figures/en-us_image_0000001217236574.png) ![en-us_image_0000001217236574](figures/en-us_image_0000001217236574.png)
1. Gutters: 1. Gutter:
Spacing between elements. You can define different clutter values for different device sizes as part of the overall grid layout specifications. For better results, make sure the gutter is not greater than the margin. Spacing between elements. You can define different clutter values for different device sizes as part of the overall grid layout specifications. For better results, make sure the gutter is not greater than the margin.
2. Margins: 2. Margin:
Spacing around an item in the grid container. You can define different margin values for different device sizes as part of the overall grid layout specifications. Spacing around an item in the grid container. You can define different margin values for different device sizes as part of the overall grid layout specifications.
3. Columns: 3. Column:
Main tool for positioning items in the grid layout. The grid container is divided into various numbers of columns based on the device size. The width per column is calculated based on the total number of columns while respecting the margin and clutter specifications. Main tool for positioning items in the grid layout. The grid container is divided into various numbers of columns based on the device size. The width per column is calculated based on the total number of columns while respecting the margin and clutter specifications.
......
...@@ -15,11 +15,11 @@ Invoke the **mediaquery** API to set the media query condition and the callback, ...@@ -15,11 +15,11 @@ Invoke the **mediaquery** API to set the media query condition and the callback,
First, import the mediaquery module, as shown below: First, import the mediaquery module, as shown below:
``` ```
import mediaquery from '@ohos.mediaquery' import mediaquery from '@ohos.mediaquery'
``` ```
Then, use the **matchMediaSync** API to set the media query condition and save the returned listener, as shown below: Then, use the **matchMediaSync** API to set the media query condition and save the returned listener, as shown below:
``` ```
listener = mediaquery.matchMediaSync('(orientation: landscape)') listener = mediaquery.matchMediaSync('(orientation: landscape)')
``` ```
Finally, register the callback using the saved listener, and change the page layout or implement service logic in the callback. When the media query condition is matched, the callback is triggered. The sample code is as follows: Finally, register the callback using the saved listener, and change the page layout or implement service logic in the callback. When the media query condition is matched, the callback is triggered. The sample code is as follows:
``` ```
...@@ -39,13 +39,13 @@ listener.on('change', onPortrait) ...@@ -39,13 +39,13 @@ listener.on('change', onPortrait)
``` ```
Examples are as follows: Examples are as follows:
screen and (round-screen: true) // The query is valid when the device screen is round. ` screen and (round-screen: true) ` // The query is valid when the device screen is round.
(max-height: 800) // The query is valid when the height does not exceed 800. ` (max-height: 800) ` // The query is valid when the height does not exceed 800.
(height &lt;= 800) // The query is valid when the height does not exceed 800. ` (height &lt;= 800) ` // The query is valid when the height does not exceed 800.
screen and (device-type: tv) or (resolution &lt; 2) // The query is valid only when all media features are true. ` screen and (device-type: tv) or (resolution &lt; 2) ` // The query is valid only when all media features are true.
### media-type ### media-type
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
- [Page Ability Development](ability/fa-pageability.md) - [Page Ability Development](ability/fa-pageability.md)
- [Service Ability Development](ability/fa-serviceability.md) - [Service Ability Development](ability/fa-serviceability.md)
- [Data Ability Development](ability/fa-dataability.md) - [Data Ability Development](ability/fa-dataability.md)
- [FA Widget Development](ability/fa-formability.md) - [FA Widget Development](ability/fa-formability.md)
- Stage Model - Stage Model
- [Stage Model Overview](ability/stage-brief.md) - [Stage Model Overview](ability/stage-brief.md)
- [Ability Development](ability/stage-ability.md) - [Ability Development](ability/stage-ability.md)
...@@ -276,7 +275,9 @@ ...@@ -276,7 +275,9 @@
- Vibrator - Vibrator
- [Vibrator Overview](device/vibrator-overview.md) - [Vibrator Overview](device/vibrator-overview.md)
- [Vibrator Development](device/vibrator-guidelines.md) - [Vibrator Development](device/vibrator-guidelines.md)
- - Update
- [Sample Server Overview](device/sample-server-overview.md)
- [Sample Server Development](device/sample-server-guidelines.md)
- Device Usage Statistics - Device Usage Statistics
- [Device Usage Statistics Overview](device-usage-statistics/device-usage-statistics-overview.md) - [Device Usage Statistics Overview](device-usage-statistics/device-usage-statistics-overview.md)
- [Device Usage Statistics Development](device-usage-statistics/device-usage-statistics-dev-guide.md) - [Device Usage Statistics Development](device-usage-statistics/device-usage-statistics-dev-guide.md)
...@@ -294,10 +295,10 @@ ...@@ -294,10 +295,10 @@
- [Internationalization Overview](internationalization/international-overview.md) - [Internationalization Overview](internationalization/international-overview.md)
- [Internationalization Development (intl)](internationalization/intl-guidelines.md) - [Internationalization Development (intl)](internationalization/intl-guidelines.md)
- [Internationalization Development (i18n)](internationalization/i18n-guidelines.md) - [Internationalization Development (i18n)](internationalization/i18n-guidelines.md)
- - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md)
- [Using Native APIs in Application Projects](napi/napi-guidelines.md) - Native APIs
- [Using Native APIs in Application Projects](napi/napi-guidelines.md)
- Tools - Tools
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- Hands-On Tutorials - Hands-On Tutorials
- [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md)
...@@ -556,7 +557,6 @@ ...@@ -556,7 +557,6 @@
- [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md)
- APIs - APIs
- Ability Framework - Ability Framework
- [@ohos.ability.dataUriUtils](reference/apis/js-apis-DataUriUtils.md) - [@ohos.ability.dataUriUtils](reference/apis/js-apis-DataUriUtils.md)
- [@ohos.ability.errorCode ](reference/apis/js-apis-ability-errorCode.md) - [@ohos.ability.errorCode ](reference/apis/js-apis-ability-errorCode.md)
- [@ohos.ability.wantConstant](reference/apis/js-apis-ability-wantConstant.md) - [@ohos.ability.wantConstant](reference/apis/js-apis-ability-wantConstant.md)
...@@ -598,35 +598,29 @@ ...@@ -598,35 +598,29 @@
- [PermissionRequestResult](reference/apis/js-apis-permissionrequestresult.md) - [PermissionRequestResult](reference/apis/js-apis-permissionrequestresult.md)
- [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md) - [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md)
- [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md) - [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md)
- [shellCmdResult](reference/apis/js-apis-application-shellCmdResult.md) - [shellCmdResult](reference/apis/js-apis-application-shellCmdResult.md)
- Common Event and Notification - Common Event and Notification
- [@ohos.commonEvent](reference/apis/js-apis-commonEvent.md) - [@ohos.commonEvent](reference/apis/js-apis-commonEvent.md)
- [@ohos.events.emitter](reference/apis/js-apis-emitter.md) - [@ohos.events.emitter](reference/apis/js-apis-emitter.md)
- [@ohos.notification](reference/apis/js-apis-notification.md) - [@ohos.notification](reference/apis/js-apis-notification.md)
- [@ohos.reminderAgent](reference/apis/js-apis-reminderAgent.md) - [@ohos.reminderAgent](reference/apis/js-apis-reminderAgent.md)
- [EventHub](reference/apis/js-apis-eventhub.md) - [EventHub](reference/apis/js-apis-eventhub.md)
- Bundle Management - Bundle Management
- [@ohos.bundle](reference/apis/js-apis-Bundle.md) - [@ohos.bundle](reference/apis/js-apis-Bundle.md)
- [@ohos.bundleState ](reference/apis/js-apis-deviceUsageStatistics.md) - [@ohos.bundleState ](reference/apis/js-apis-deviceUsageStatistics.md)
- [@ohos.zlib](reference/apis/js-apis-zlib.md) - [@ohos.zlib](reference/apis/js-apis-zlib.md)
- UI Page - UI Page
- [@ohos.animator](reference/apis/js-apis-animator.md) - [@ohos.animator](reference/apis/js-apis-animator.md)
- [@ohos.mediaquery](reference/apis/js-apis-mediaquery.md) - [@ohos.mediaquery](reference/apis/js-apis-mediaquery.md)
- [@ohos.prompt](reference/apis/js-apis-prompt.md) - [@ohos.prompt](reference/apis/js-apis-prompt.md)
- [@ohos.router](reference/apis/js-apis-router.md) - [@ohos.router](reference/apis/js-apis-router.md)
- Graphics - Graphics
- [@ohos.display ](reference/apis/js-apis-display.md) - [@ohos.display ](reference/apis/js-apis-display.md)
- [@ohos.screenshot](reference/apis/js-apis-screenshot.md) - [@ohos.screenshot](reference/apis/js-apis-screenshot.md)
- [@ohos.window](reference/apis/js-apis-window.md) - [@ohos.window](reference/apis/js-apis-window.md)
- [webgl](reference/apis/js-apis-webgl.md) - [webgl](reference/apis/js-apis-webgl.md)
- [webgl2](reference/apis/js-apis-webgl2.md) - [webgl2](reference/apis/js-apis-webgl2.md)
- Media - Media
- [@ohos.multimedia.audio](reference/apis/js-apis-audio.md) - [@ohos.multimedia.audio](reference/apis/js-apis-audio.md)
- [@ohos.multimedia.camera](reference/apis/js-apis-camera.md) - [@ohos.multimedia.camera](reference/apis/js-apis-camera.md)
- [@ohos.multimedia.image](reference/apis/js-apis-image.md) - [@ohos.multimedia.image](reference/apis/js-apis-image.md)
...@@ -637,32 +631,26 @@ ...@@ -637,32 +631,26 @@
- [@ohos.intl](reference/apis/js-apis-intl.md) - [@ohos.intl](reference/apis/js-apis-intl.md)
- [@ohos.resourceManager](reference/apis/js-apis-resource-manager.md) - [@ohos.resourceManager](reference/apis/js-apis-resource-manager.md)
- Resource Scheduling - Resource Scheduling
- [@ohos.backgroundTaskManager](reference/apis/js-apis-backgroundTaskManager.md) - [@ohos.backgroundTaskManager](reference/apis/js-apis-backgroundTaskManager.md)
- [@ohos.workScheduler ](reference/apis/js-apis-workScheduler.md) - [@ohos.workScheduler ](reference/apis/js-apis-workScheduler.md)
- [@ohos.WorkSchedulerExtensionAbility](reference/apis/js-apis-WorkSchedulerExtensionAbility.md) - [@ohos.WorkSchedulerExtensionAbility](reference/apis/js-apis-WorkSchedulerExtensionAbility.md)
- Custom Management - Custom Management
- [@ohos.configPolicy](reference/apis/js-apis-config-policy.md) - [@ohos.configPolicy](reference/apis/js-apis-config-policy.md)
- [@ohos.enterpriseDeviceManager](reference/apis/js-apis-enterprise-device-manager.md) - [@ohos.enterpriseDeviceManager](reference/apis/js-apis-enterprise-device-manager.md)
- Security - Security
- [@ohos.abilityAccessCtrl](reference/apis/js-apis-abilityAccessCtrl.md) - [@ohos.abilityAccessCtrl](reference/apis/js-apis-abilityAccessCtrl.md)
- [@ohos.security.huks ](reference/apis/js-apis-huks.md) - [@ohos.security.huks ](reference/apis/js-apis-huks.md)
- [@ohos.userIAM.userAuth ](reference/apis/js-apis-useriam-userauth.md) - [@ohos.userIAM.userAuth ](reference/apis/js-apis-useriam-userauth.md)
- [@system.cipher](reference/apis/js-apis-system-cipher.md) - [@system.cipher](reference/apis/js-apis-system-cipher.md)
- Data Management - Data Management
- [@ohos.data.dataAbility ](reference/apis/js-apis-data-ability.md) - [@ohos.data.dataAbility ](reference/apis/js-apis-data-ability.md)
- [@ohos.data.distributedData](reference/apis/js-apis-distributed-data.md) - [@ohos.data.distributedData](reference/apis/js-apis-distributed-data.md)
- [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md) - [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md)
- [@ohos.data.preferences](reference/apis/js-apis-data-preferences.md) - [@ohos.data.preferences](reference/apis/js-apis-data-preferences.md)
- [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md) - [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md)
- [@ohos.settings](reference/apis/js-apis-settings.md) - [@ohos.settings](reference/apis/js-apis-settings.md)
- [resultSet](reference/apis/js-apis-data-resultset.md)
- [resultSet](reference/apis/js-apis-data-resultset.md)
- File Management - File Management
- [@ohos.document](reference/apis/js-apis-document.md) - [@ohos.document](reference/apis/js-apis-document.md)
- [@ohos.environment](reference/apis/js-apis-environment.md) - [@ohos.environment](reference/apis/js-apis-environment.md)
- [@ohos.fileio](reference/apis/js-apis-fileio.md) - [@ohos.fileio](reference/apis/js-apis-fileio.md)
...@@ -670,8 +658,7 @@ ...@@ -670,8 +658,7 @@
- [@ohos.statfs](reference/apis/js-apis-statfs.md) - [@ohos.statfs](reference/apis/js-apis-statfs.md)
- [@ohos.storageStatistics](reference/apis/js-apis-storage-statistics.md) - [@ohos.storageStatistics](reference/apis/js-apis-storage-statistics.md)
- [@ohos.volumeManager](reference/apis/js-apis-volumemanager.md) - [@ohos.volumeManager](reference/apis/js-apis-volumemanager.md)
- Telephony Service - Telephony
- [@ohos.contact](reference/apis/js-apis-contact.md) - [@ohos.contact](reference/apis/js-apis-contact.md)
- [@ohos.telephony.call](reference/apis/js-apis-call.md) - [@ohos.telephony.call](reference/apis/js-apis-call.md)
- [@ohos.telephony.observer](reference/apis/js-apis-observer.md) - [@ohos.telephony.observer](reference/apis/js-apis-observer.md)
...@@ -686,14 +673,12 @@ ...@@ -686,14 +673,12 @@
- [@ohos.net.socket](reference/apis/js-apis-socket.md) - [@ohos.net.socket](reference/apis/js-apis-socket.md)
- [@ohos.net.webSocket](reference/apis/js-apis-webSocket.md) - [@ohos.net.webSocket](reference/apis/js-apis-webSocket.md)
- Connectivity - Connectivity
- [@ohos.bluetooth](reference/apis/js-apis-bluetooth.md) - [@ohos.bluetooth](reference/apis/js-apis-bluetooth.md)
- [@ohos.connectedTag](reference/apis/js-apis-connectedTag.md) - [@ohos.connectedTag](reference/apis/js-apis-connectedTag.md)
- [@ohos.rpc](reference/apis/js-apis-rpc.md) - [@ohos.rpc](reference/apis/js-apis-rpc.md)
- [@ohos.wifi](reference/apis/js-apis-wifi.md) - [@ohos.wifi](reference/apis/js-apis-wifi.md)
- [@ohos.wifiext](reference/apis/js-apis-wifiext.md) - [@ohos.wifiext](reference/apis/js-apis-wifiext.md)
- Basic Features - Basic Features
- [@ohos.accessibility](reference/apis/js-apis-accessibility.md) - [@ohos.accessibility](reference/apis/js-apis-accessibility.md)
- [@ohos.faultLogger](reference/apis/js-apis-faultLogger.md) - [@ohos.faultLogger](reference/apis/js-apis-faultLogger.md)
- [@ohos.hiAppEvent](reference/apis/js-apis-hiappevent.md) - [@ohos.hiAppEvent](reference/apis/js-apis-hiappevent.md)
...@@ -710,7 +695,6 @@ ...@@ -710,7 +695,6 @@
- [@ohos.wallpaper](reference/apis/js-apis-wallpaper.md) - [@ohos.wallpaper](reference/apis/js-apis-wallpaper.md)
- [Timer](reference/apis/js-apis-timer.md) - [Timer](reference/apis/js-apis-timer.md)
- Device Management - Device Management
- [@ohos.batteryInfo ](reference/apis/js-apis-battery-info.md) - [@ohos.batteryInfo ](reference/apis/js-apis-battery-info.md)
- [@ohos.brightness](reference/apis/js-apis-brightness.md) - [@ohos.brightness](reference/apis/js-apis-brightness.md)
- [@ohos.deviceInfo](reference/apis/js-apis-device-info.md) - [@ohos.deviceInfo](reference/apis/js-apis-device-info.md)
...@@ -729,12 +713,10 @@ ...@@ -729,12 +713,10 @@
- [@ohos.usb](reference/apis/js-apis-usb.md) - [@ohos.usb](reference/apis/js-apis-usb.md)
- [@ohos.vibrator](reference/apis/js-apis-vibrator.md) - [@ohos.vibrator](reference/apis/js-apis-vibrator.md)
- Account Management - Account Management
- [@ohos.account.appAccount](reference/apis/js-apis-appAccount.md) - [@ohos.account.appAccount](reference/apis/js-apis-appAccount.md)
- [@ohos.account.distributedAccount](reference/apis/js-apis-distributed-account.md) - [@ohos.account.distributedAccount](reference/apis/js-apis-distributed-account.md)
- [@ohos.account.osAccount](reference/apis/js-apis-osAccount.md) - [@ohos.account.osAccount](reference/apis/js-apis-osAccount.md)
- Language Base Class Library - Language Base Class Library
- [@ohos.convertxml](reference/apis/js-apis-convertxml.md) - [@ohos.convertxml](reference/apis/js-apis-convertxml.md)
- [@ohos.process](reference/apis/js-apis-process.md) - [@ohos.process](reference/apis/js-apis-process.md)
- [@ohos.uri](reference/apis/js-apis-uri.md) - [@ohos.uri](reference/apis/js-apis-uri.md)
...@@ -760,7 +742,6 @@ ...@@ -760,7 +742,6 @@
- [@ohos.application.testRunner](reference/apis/js-apis-testRunner.md) - [@ohos.application.testRunner](reference/apis/js-apis-testRunner.md)
- [@ohos.uitest](reference/apis/js-apis-uitest.md) - [@ohos.uitest](reference/apis/js-apis-uitest.md)
- APIs No Longer Maintained - APIs No Longer Maintained
- [@ohos.bytrace](reference/apis/js-apis-bytrace.md) - [@ohos.bytrace](reference/apis/js-apis-bytrace.md)
- [@ohos.data.storage](reference/apis/js-apis-data-storage.md) - [@ohos.data.storage](reference/apis/js-apis-data-storage.md)
- [@system.app](reference/apis/js-apis-system-app.md) - [@system.app](reference/apis/js-apis-system-app.md)
......
...@@ -29,7 +29,6 @@ For details, see [Contribution Process](contribution-process.md). ...@@ -29,7 +29,6 @@ For details, see [Contribution Process](contribution-process.md).
## Security Issue Disclosure<a name="en-us_topic_0000001051566732_section725624119448"></a> ## Security Issue Disclosure<a name="en-us_topic_0000001051566732_section725624119448"></a>
- [Security Issue Handling and Release Processes](https://gitee.com/openharmony/security/blob/master/en/security-process/README.md) - [Security Issue Handling and Release Processes](https://gitee.com/openharmony/security/blob/master/en/security-process/README.md)
- [OpenHarmony Security Vulnerability Notice](https://gitee.com/openharmony/security/blob/master/en/security-process/security-disclosure.md) - [OpenHarmony Security Vulnerability Notice](https://gitee.com/openharmony/security/blob/master/en/security-process/security-disclosure.md)
...@@ -43,10 +43,10 @@ ...@@ -43,10 +43,10 @@
- [Mini- and Small-System Devices](guide/device-lite.md) - [Mini- and Small-System Devices](guide/device-lite.md)
- [Standard-System Devices](guide/device-standard.md) - [Standard-System Devices](guide/device-standard.md)
- Debugging - Debugging
- [Test](subsystems/subsys-testguide-test.md) - [Test Case Development](subsystems/subsys-testguide-test.md)
- [R&D Tools](subsystems/subsys-toolchain.md) - [R&D Tools](subsystems/subsys-toolchain.md)
- XTS Certification - XTS Certification
- [XTS](subsystems/subsys-xts-guide.md) - [XTS Test Case Development](subsystems/subsys-xts-guide.md)
- Tools - Tools
- [Docker Environment](get-code/gettools-acquire.md) - [Docker Environment](get-code/gettools-acquire.md)
- [IDE](get-code/gettools-ide.md) - [IDE](get-code/gettools-ide.md)
......
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
### Function ### Function
Personal Identification Number (PIN) authentication provides user authentication capabilities and applies to identity authentication scenarios, such as device unlocking, payment, and app logins. After a user registers a PIN, the PIN authentication (pin_auth) module unlocks the device only when a correct PIN is entered. The figure below shows the architecture of PIN authentication. Personal Identification Number (PIN) authentication provides user authentication capabilities in identity authentication scenarios, such as device unlocking, payment, and app logins. After a user registers a PIN, the PIN authentication (pin_auth) module unlocks the device only when a correct PIN is entered. The figure below shows the architecture of PIN authentication.
The pin_auth driver is developed based on the Hardware Driver Foundation (HDF). The pin_auth driver model shields hardware differences and provides stable PIN authentication capabilities for the user IAM framework(UserIAM) and PIN authentication system ability (SA). The PIN authentication capabilities include obtaining the PIN authentication executor list, executor information, anti-brute force information of the specified template, comparing the template list of the executor and that of UserIAM, enrolling or deleting PINs, and performing PIN authentication. The pin_auth driver is developed based on the Hardware Driver Foundation (HDF). The pin_auth driver model shields hardware differences and provides stable PIN authentication capabilities for the user IAM framework(UserIAM) and PIN authentication system ability (SA). The PIN authentication capabilities include obtaining the PIN authentication executor list, executor information, and anti-brute force information of the specified template, comparing the template list of the executor and that of UserIAM, enrolling or deleting PINs, and performing PIN authentication.
**Figure 1** PIN authentication architecture **Figure 1** PIN authentication architecture
![image](figures/pin_auth_architecture.png "PIN authentication architecture") ![image](figures/pin_auth_architecture.png "PIN authentication architecture")
### Basic Concepts ### Basic Concepts
The identity authentication consists of UserIAM and basic authentication services (including PIN authentication and facial recognition). It supports basic functions such as setting and deleting user credentials, deletion, and performing authentication. The identity authentication consists of UserIAM and basic authentication services (including PIN authentication and facial recognition). It supports basic functions such as setting and deleting user credentials, and performing authentication.
- Executor - Executor
...@@ -37,7 +37,7 @@ The identity authentication consists of UserIAM and basic authentication service ...@@ -37,7 +37,7 @@ The identity authentication consists of UserIAM and basic authentication service
- UserIAM public key & executor public key - UserIAM public key & executor public key
To ensure user data security and authentication result accuracy, measures must be taken to protect the integrity of the key information exchanged between UserIAM and basic authentication services. Public keys need to be exchanged when the executor provided by a basic authentication service interworks with UserIAM. To ensure user data security and authentication result accuracy, measures must be taken to protect the integrity of the key information exchanged between UserIAM and basic authentication services. Public keys must be exchanged when the executor provided by a basic authentication service interworks with UserIAM.
- The executor uses the UserIAM public key to verify the scheduling instruction. - The executor uses the UserIAM public key to verify the scheduling instruction.
...@@ -50,7 +50,7 @@ The identity authentication consists of UserIAM and basic authentication service ...@@ -50,7 +50,7 @@ The identity authentication consists of UserIAM and basic authentication service
- Data verification by the executor - Data verification by the executor
UserIAM manages the mappings between user identities and credential IDs in a unified manner. When connecting to UserIAM, the executor obtains the template ID list from UserIAM, compares its template ID list with the template ID list obtained, and updates its template ID list accordingly. UserIAM manages the mappings between user identities and credential IDs in a unified manner. When connecting to UserIAM, the executor obtains the template ID list from UserIAM, and updates its template ID list based on the obtained template ID list.
### Working Principles ### Working Principles
...@@ -65,7 +65,7 @@ PIN authentication must be implemented in a TEE, and the confidential informatio ...@@ -65,7 +65,7 @@ PIN authentication must be implemented in a TEE, and the confidential informatio
## Development Guidelines ## Development Guidelines
### When to Use ### When to Use
The pin_auth driver provides basic capabilities of PIN authentication for the UserIAM and pin_auth service to ensure successful PIN authentication. The pin_auth driver provides basic PIN authentication capabilities for the UserIAM and pin_auth service to ensure successful PIN authentication.
### Available APIs ### Available APIs
...@@ -499,7 +499,7 @@ The development procedure is as follows: ...@@ -499,7 +499,7 @@ The development procedure is as follows:
return HDF_SUCCESS; return HDF_SUCCESS;
} }
// Cancel the operation of the specified scheduleId. // Cancel the operation based on the specified scheduleId.
int32_t ExecutorImpl::Cancel(uint64_t scheduleId) int32_t ExecutorImpl::Cancel(uint64_t scheduleId)
{ {
IAM_LOGI("start"); IAM_LOGI("start");
......
...@@ -88,7 +88,7 @@ Perform the following steps: ...@@ -88,7 +88,7 @@ Perform the following steps:
1. Add the touchscreen driver-related descriptions. 1. Add the touchscreen driver-related descriptions.
Currently, the input driver is developed based on the HDF and is loaded and started by the HDF. Register the driver information, such as whether to load the driver and the loading priority in the configuration file. Then, the HDF starts the registered driver modules one by one. For details about the driver configuration, see [How to Develop](driver-hdf-development.md#how-to-develop). Currently, the input driver is developed based on the HDF and is loaded and started by the HDF. Register the driver information, such as whether to load the driver and the loading priority in the configuration file. Then, the HDF starts the registered driver modules one by one. For details about the driver configuration, see [How to Develop](driver-hdf-development.md).
2. Complete the board-level configuration and private data configuration of the touchscreen. 2. Complete the board-level configuration and private data configuration of the touchscreen.
...@@ -105,7 +105,7 @@ This example describes how to develop the touchscreen driver. ...@@ -105,7 +105,7 @@ This example describes how to develop the touchscreen driver.
### Adding the Touchscreen Driver-related Description<a name="section18249155619195"></a> ### Adding the Touchscreen Driver-related Description<a name="section18249155619195"></a>
The information about modules of the input driver model is shown as follows and enables the HDF to load the modules in sequence. For details, see [Driver Development](driver-hdf-development.md). The information about modules of the input driver model is shown as follows and enables the HDF to load the modules in sequence. For details, see [Driver Development](driver-hdf-development.md).
``` ```
input :: host { input :: host {
......
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals. An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals.
The ADC APIs provide a set of common functions for ADC data transfer, including: The ADC APIs provide a set of common functions for ADC data transfer, including:
- Opening or closing an ADC device - Opening or closing an ADC device
- Obtaining the analog-to-digital (AD) conversion result - Obtaining the analog-to-digital (AD) conversion result
**Figure 1** ADC physical connection<a name="fig1"></a> **Figure 1** ADC physical connection
![](figures/ADC_physical_connection.png "ADC_physical_connection") ![](figures/ADC_physical_connection.png "ADC_physical_connection")
...@@ -51,11 +52,11 @@ The ADC APIs provide a set of common functions for ADC data transfer, including: ...@@ -51,11 +52,11 @@ The ADC APIs provide a set of common functions for ADC data transfer, including:
### How to Use<a name="section4"></a> ### How to Use<a name="section4"></a>
[Figure 2](#fig2) shows how an ADC device works. The figure below illustrates how to use the APIs.
**Figure 2** Using ADC driver APIs
**Figure 2** How ADC works<a name="fig2"></a> ![](figures/using-ADC-process.png "using-ADC-process.png")
![](figures/ADC_flowchart.png "ADC_flowchart")
### Opening an ADC Device<a name="section5"></a> ### Opening an ADC Device<a name="section5"></a>
......
...@@ -69,15 +69,15 @@ The table below describes the APIs of the DAC module. For more details, see API ...@@ -69,15 +69,15 @@ The table below describes the APIs of the DAC module. For more details, see API
| :------------------------------------------------------------| :------------ | | :------------------------------------------------------------| :------------ |
| DevHandle DacOpen(uint32_t number) | Opens a DAC device. | | DevHandle DacOpen(uint32_t number) | Opens a DAC device. |
| void DacClose(DevHandle handle) | Closes a DAC device. | | void DacClose(DevHandle handle) | Closes a DAC device. |
| int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val) | Sets the target DA value. | | int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val) | Sets a target DA value. |
### How to Develop ### How to Develop
The figure below illustrates the process of using a DAC device. The figure below illustrates how to use the APIs.
**Figure 2** Process of using a DAC device **Figure 2** Using DAC driver APIs
![](figures/process-of-using-DAC.png "Process of using a DAC") ![](figures/using-DAC-process.png "using-DAC-process.png")
#### Opening a DAC Device #### Opening a DAC Device
...@@ -111,7 +111,7 @@ if (dacHandle == NULL) { ...@@ -111,7 +111,7 @@ if (dacHandle == NULL) {
} }
``` ```
#### Setting the Target DA Value #### Setting a Target DA Value
``` ```
int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val); int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val);
......
...@@ -7,11 +7,11 @@ Generally, a general-purpose input/output \(GPIO\) controller manages all GPIO p ...@@ -7,11 +7,11 @@ Generally, a general-purpose input/output \(GPIO\) controller manages all GPIO p
The GPIO APIs define a set of standard functions for performing operations on GPIO pins, including: The GPIO APIs define a set of standard functions for performing operations on GPIO pins, including:
- Setting the pin direction, which can be input or output \(High impedance is not supported currently.\) - Setting the pin direction, which can be input or output \(high impedance is not supported currently\)
- Reading and writing level values, which can be low or high - Reading and writing level values, which can be low or high
- Setting an interrupt service routine \(ISR\) function and interrupt trigger mode for a pin - Setting an interrupt service routine \(ISR\) function and interrupt trigger mode for a pin
- Enabling or disabling a pin interrupt - Enabling or disabling interrupts for a pin
## Available APIs<a name="section589913442203"></a> ## Available APIs<a name="section589913442203"></a>
...@@ -64,17 +64,18 @@ The GPIO APIs define a set of standard functions for performing operations on GP ...@@ -64,17 +64,18 @@ The GPIO APIs define a set of standard functions for performing operations on GP
</tr> </tr>
<tr id="row396907112117"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p109694717216"><a name="p109694717216"></a><a name="p109694717216"></a>GpioEnableIrq</p> <tr id="row396907112117"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p109694717216"><a name="p109694717216"></a><a name="p109694717216"></a>GpioEnableIrq</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p2969473216"><a name="p2969473216"></a><a name="p2969473216"></a>Enables a GPIO interrupt.</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p2969473216"><a name="p2969473216"></a><a name="p2969473216"></a>Enables GPIO interrupts for a pin.</p>
</td> </td>
</tr> </tr>
<tr id="row14969117152113"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18969157182116"><a name="p18969157182116"></a><a name="p18969157182116"></a>GpioDisableIrq</p> <tr id="row14969117152113"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18969157182116"><a name="p18969157182116"></a><a name="p18969157182116"></a>GpioDisableIrq</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p19690710214"><a name="p19690710214"></a><a name="p19690710214"></a>Disables a GPIO interrupt.</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p19690710214"><a name="p19690710214"></a><a name="p19690710214"></a>Disables GPIO interrupts for a pin.</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-note.gif) **NOTE**<br> >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions provided in this document can be called only in kernel mode. >All functions provided in this document can be called only in kernel mode.
...@@ -82,22 +83,27 @@ The GPIO APIs define a set of standard functions for performing operations on GP ...@@ -82,22 +83,27 @@ The GPIO APIs define a set of standard functions for performing operations on GP
### How to Use<a name="section103477714216"></a> ### How to Use<a name="section103477714216"></a>
The GPIO APIs use the GPIO pin number to specify a pin. [Figure 1](#fig16151101653713) shows the general process of using a GPIO. The GPIO APIs use the GPIO pin number to specify a pin. The figure below illustrates how to use the APIs.
**Figure 1** Using GPIO driver APIs
![](figures/using-gpio-process.png "using-gpio-process.png")
**Figure 1** Process of using a GPIO<a name="fig16151101653713"></a> ### Determining the GPIO Pin Number<a name="section370083272117"></a>
![](figures/process-of-using-a-gpio.png "process-of-using-a-gpio")
### Determining a GPIO Pin Number<a name="section370083272117"></a> The method for converting GPIO pin numbers varies depending on the GPIO controller model, parameters, and controller driver of different system on chips \(SoCs\).
The method for converting GPIO pin numbers varies according to the GPIO controller model, parameters, and controller driver of different system on chips \(SoCs\). - Hi3516DV300
- Hi3516DV300 A controller manages 12 groups of GPIO pins. Each group contains 8 GPIO pins.
A controller manages 12 groups of GPIO pins. Each group contains 8 GPIO pins. GPIO pin number = GPIO group index x Number of GPIO pins in each group + Offset in the group
GPIO pin number = GPIO group index \(0–11\) x Number of GPIO pins in each group \(8\) + Offset in the group The group index ranges from 0 to 11.
Example: GPIO number of GPIO10\_3 = 10 x 8 + 3 = 83 Example:
GPIO pin number of GPIO10\_3 = 10 x 8 + 3 = 83
- Hi3518EV300 - Hi3518EV300
...@@ -105,14 +111,18 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -105,14 +111,18 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
GPIO pin number = GPIO group index \(0–9\) x Number of GPIO pins in each group \(10\) + Offset in the group GPIO pin number = GPIO group index \(0–9\) x Number of GPIO pins in each group \(10\) + Offset in the group
Example: GPIO pin number of GPIO7\_3 = 7 x 10 + 3 = 73 The group index ranges from 0 to 9.
Example:
GPIO pin number of GPIO7\_3 = 7 x 10 + 3 = 73
### Using APIs to Operate GPIO Pins<a name="section13604050132118"></a> ### Using APIs to Operate GPIO Pins<a name="section13604050132118"></a>
- Set the direction for a GPIO pin. - Set the direction for a GPIO pin.
Before performing read/write operations on a GPIO pin, call the following function to set the direction: Before performing read/write operations on a GPIO pin, call **GpioSetDir**() to set the direction.
int32\_t GpioSetDir\(uint16\_t gpio, uint16\_t dir\); int32\_t GpioSetDir\(uint16\_t gpio, uint16\_t dir\);
...@@ -141,12 +151,12 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -141,12 +151,12 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
</tr> </tr>
<tr id="row205931212123817"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p18312151463"><a name="p18312151463"></a><a name="p18312151463"></a>0</p> <tr id="row205931212123817"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p18312151463"><a name="p18312151463"></a><a name="p18312151463"></a>0</p>
</td> </td>
<td class="cellrowborder" valign="top" width="51.88%"><p id="p103124517618"><a name="p103124517618"></a><a name="p103124517618"></a>Succeeded in setting the direction for a GPIO pin.</p> <td class="cellrowborder" valign="top" width="51.88%"><p id="p103124517618"><a name="p103124517618"></a><a name="p103124517618"></a>The operation is successful.</p>
</td> </td>
</tr> </tr>
<tr id="row75931212153818"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p23121951261"><a name="p23121951261"></a><a name="p23121951261"></a>Negative value</p> <tr id="row75931212153818"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p23121951261"><a name="p23121951261"></a><a name="p23121951261"></a>Negative value</p>
</td> </td>
<td class="cellrowborder" valign="top" width="51.88%"><p id="p153121553610"><a name="p153121553610"></a><a name="p153121553610"></a>Failed to set the direction for a GPIO pin.</p> <td class="cellrowborder" valign="top" width="51.88%"><p id="p153121553610"><a name="p153121553610"></a><a name="p153121553610"></a>The operation failed.</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -155,7 +165,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -155,7 +165,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
- Read or write the level value for a GPIO pin. - Read or write the level value for a GPIO pin.
To read the level value of a GPIO pin, call the following function: Call **GpioRead**() to read the level value of a GPIO pin.
int32\_t GpioRead\(uint16\_t gpio, uint16\_t \*val\); int32\_t GpioRead\(uint16\_t gpio, uint16\_t \*val\);
...@@ -184,23 +194,24 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -184,23 +194,24 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
</tr> </tr>
<tr id="row3348184311486"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p1934854315487"><a name="p1934854315487"></a><a name="p1934854315487"></a>0</p> <tr id="row3348184311486"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p1934854315487"><a name="p1934854315487"></a><a name="p1934854315487"></a>0</p>
</td> </td>
<td class="cellrowborder" valign="top" width="51.88%"><p id="p103481943114814"><a name="p103481943114814"></a><a name="p103481943114814"></a>Succeeded in reading the level value.</p> <td class="cellrowborder" valign="top" width="51.88%"><p id="p103481943114814"><a name="p103481943114814"></a><a name="p103481943114814"></a>The operation is successful.</p>
</td> </td>
</tr> </tr>
<tr id="row23485436482"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p1134834310486"><a name="p1134834310486"></a><a name="p1134834310486"></a>Negative value</p> <tr id="row23485436482"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p1134834310486"><a name="p1134834310486"></a><a name="p1134834310486"></a>Negative value</p>
</td> </td>
<td class="cellrowborder" valign="top" width="51.88%"><p id="p93491343144815"><a name="p93491343144815"></a><a name="p93491343144815"></a>Failed to read the level value.</p> <td class="cellrowborder" valign="top" width="51.88%"><p id="p93491343144815"><a name="p93491343144815"></a><a name="p93491343144815"></a>The operation failed.</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
To write the level value for a GPIO pin, call the following function:
Call **GpioWrite()** to write the level value for a GPIO pin.
int32\_t GpioWrite\(uint16\_t gpio, uint16\_t val\); int32\_t GpioWrite\(uint16\_t gpio, uint16\_t val\);
**Table 4** Description of GpioWrite **Table 4** Description of GpioWrite
<a name="table1214911207520"></a> <a name="table1214911207520"></a>
<table><tbody><tr id="row6149720175218"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p18149132005216"><a name="p18149132005216"></a><a name="p18149132005216"></a><strong id="b19864427181615"><a name="b19864427181615"></a><a name="b19864427181615"></a>Parameter</strong></p> <table><tbody><tr id="row6149720175218"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p18149132005216"><a name="p18149132005216"></a><a name="p18149132005216"></a><strong id="b19864427181615"><a name="b19864427181615"></a><a name="b19864427181615"></a>Parameter</strong></p>
</td> </td>
...@@ -224,19 +235,19 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -224,19 +235,19 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
</tr> </tr>
<tr id="row111503202526"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p171501320205216"><a name="p171501320205216"></a><a name="p171501320205216"></a>0</p> <tr id="row111503202526"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p171501320205216"><a name="p171501320205216"></a><a name="p171501320205216"></a>0</p>
</td> </td>
<td class="cellrowborder" valign="top" width="51.88%"><p id="p15150102017522"><a name="p15150102017522"></a><a name="p15150102017522"></a>Succeeded in writing the level value.</p> <td class="cellrowborder" valign="top" width="51.88%"><p id="p15150102017522"><a name="p15150102017522"></a><a name="p15150102017522"></a>The operation is successful.</p>
</td> </td>
</tr> </tr>
<tr id="row1615002018528"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p15150182045212"><a name="p15150182045212"></a><a name="p15150182045212"></a>Negative value</p> <tr id="row1615002018528"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p15150182045212"><a name="p15150182045212"></a><a name="p15150182045212"></a>Negative value</p>
</td> </td>
<td class="cellrowborder" valign="top" width="51.88%"><p id="p13150320105212"><a name="p13150320105212"></a><a name="p13150320105212"></a>Failed to write the level value.</p> <td class="cellrowborder" valign="top" width="51.88%"><p id="p13150320105212"><a name="p13150320105212"></a><a name="p13150320105212"></a>The operation failed.</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
Example: Example:
``` ```
int32_t ret; int32_t ret;
uint16_t val; uint16_t val;
...@@ -265,7 +276,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -265,7 +276,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
- Set the ISR function for a GPIO pin. - Set the ISR function for a GPIO pin.
To set the ISR function for a GPIO pin, call the following function: Call **GpioSetIrq()** to set the ISR function for a GPIO pin.
int32\_t GpioSetIrq\(uint16\_t gpio, uint16\_t mode, GpioIrqFunc func, void \*arg\); int32\_t GpioSetIrq\(uint16\_t gpio, uint16\_t mode, GpioIrqFunc func, void \*arg\);
...@@ -304,21 +315,21 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -304,21 +315,21 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
</tr> </tr>
<tr id="row12299632125817"><td class="cellrowborder" valign="top" width="48.54%"><p id="p1180511189465"><a name="p1180511189465"></a><a name="p1180511189465"></a>0</p> <tr id="row12299632125817"><td class="cellrowborder" valign="top" width="48.54%"><p id="p1180511189465"><a name="p1180511189465"></a><a name="p1180511189465"></a>0</p>
</td> </td>
<td class="cellrowborder" valign="top" width="51.459999999999994%"><p id="p180521812465"><a name="p180521812465"></a><a name="p180521812465"></a>Succeeded in setting the ISR function for a GPIO pin.</p> <td class="cellrowborder" valign="top" width="51.459999999999994%"><p id="p180521812465"><a name="p180521812465"></a><a name="p180521812465"></a>The operation is successful.</p>
</td> </td>
</tr> </tr>
<tr id="row029833235815"><td class="cellrowborder" valign="top" width="48.54%"><p id="p1080591814468"><a name="p1080591814468"></a><a name="p1080591814468"></a>Negative value</p> <tr id="row029833235815"><td class="cellrowborder" valign="top" width="48.54%"><p id="p1080591814468"><a name="p1080591814468"></a><a name="p1080591814468"></a>Negative value</p>
</td> </td>
<td class="cellrowborder" valign="top" width="51.459999999999994%"><p id="p18805141884611"><a name="p18805141884611"></a><a name="p18805141884611"></a>Failed to set the ISR function for a GPIO pin.</p> <td class="cellrowborder" valign="top" width="51.459999999999994%"><p id="p18805141884611"><a name="p18805141884611"></a><a name="p18805141884611"></a>The operation failed.</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-caution.gif) **CAUTION:** >![](../public_sys-resources/icon-caution.gif) **CAUTION**<br/>
>Only one ISR function can be set for a GPIO pin at a time. If **GpioSetIrq** is called repeatedly, the previous IRS function will be replaced. >Only one ISR function can be set for a GPIO pin at a time. If **GpioSetIrq** is called repeatedly, the previous IRS function will be replaced.
If the ISR function is no longer required, call the following function to cancel the setting: If the ISR function is no longer required, call **GpioUnSetIrq()** to cancel the setting.
int32\_t GpioUnSetIrq\(uint16\_t gpio\); int32\_t GpioUnSetIrq\(uint16\_t gpio\);
...@@ -342,18 +353,18 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -342,18 +353,18 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
</tr> </tr>
<tr id="row357318466439"><td class="cellrowborder" valign="top" width="48.54%"><p id="p1573164616438"><a name="p1573164616438"></a><a name="p1573164616438"></a>0</p> <tr id="row357318466439"><td class="cellrowborder" valign="top" width="48.54%"><p id="p1573164616438"><a name="p1573164616438"></a><a name="p1573164616438"></a>0</p>
</td> </td>
<td class="cellrowborder" valign="top" width="51.459999999999994%"><p id="p857384614319"><a name="p857384614319"></a><a name="p857384614319"></a>Succeeded in canceling the ISR function.</p> <td class="cellrowborder" valign="top" width="51.459999999999994%"><p id="p857384614319"><a name="p857384614319"></a><a name="p857384614319"></a>The operation is successful.</p>
</td> </td>
</tr> </tr>
<tr id="row18573124610433"><td class="cellrowborder" valign="top" width="48.54%"><p id="p165731146134311"><a name="p165731146134311"></a><a name="p165731146134311"></a>Negative value</p> <tr id="row18573124610433"><td class="cellrowborder" valign="top" width="48.54%"><p id="p165731146134311"><a name="p165731146134311"></a><a name="p165731146134311"></a>Negative value</p>
</td> </td>
<td class="cellrowborder" valign="top" width="51.459999999999994%"><p id="p6573164613437"><a name="p6573164613437"></a><a name="p6573164613437"></a>Failed to cancel the ISR function.</p> <td class="cellrowborder" valign="top" width="51.459999999999994%"><p id="p6573164613437"><a name="p6573164613437"></a><a name="p6573164613437"></a>The operation failed.</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
After the ISR function is set, call the following function to enable a GPIO interrupt: After the ISR function is set, call **GpioEnableIrq()** to enable interrupts.
int32\_t GpioEnableIrq\(uint16\_t gpio\); int32\_t GpioEnableIrq\(uint16\_t gpio\);
...@@ -377,21 +388,21 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -377,21 +388,21 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
</tr> </tr>
<tr id="row154188171403"><td class="cellrowborder" valign="top" width="50%"><p id="p1866610292563"><a name="p1866610292563"></a><a name="p1866610292563"></a>0</p> <tr id="row154188171403"><td class="cellrowborder" valign="top" width="50%"><p id="p1866610292563"><a name="p1866610292563"></a><a name="p1866610292563"></a>0</p>
</td> </td>
<td class="cellrowborder" valign="top" width="50%"><p id="p13666182975613"><a name="p13666182975613"></a><a name="p13666182975613"></a>Succeeded in enabling a GPIO interrupt.</p> <td class="cellrowborder" valign="top" width="50%"><p id="p13666182975613"><a name="p13666182975613"></a><a name="p13666182975613"></a>The operation is successful.</p>
</td> </td>
</tr> </tr>
<tr id="row1041891720012"><td class="cellrowborder" valign="top" width="50%"><p id="p766642911562"><a name="p766642911562"></a><a name="p766642911562"></a>Negative value</p> <tr id="row1041891720012"><td class="cellrowborder" valign="top" width="50%"><p id="p766642911562"><a name="p766642911562"></a><a name="p766642911562"></a>Negative value</p>
</td> </td>
<td class="cellrowborder" valign="top" width="50%"><p id="p1566652995613"><a name="p1566652995613"></a><a name="p1566652995613"></a>Failed to enable a GPIO interrupt.</p> <td class="cellrowborder" valign="top" width="50%"><p id="p1566652995613"><a name="p1566652995613"></a><a name="p1566652995613"></a>The operation failed.</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-caution.gif) **CAUTION:** >![](../public_sys-resources/icon-caution.gif) **CAUTION**<br/>
>The configured ISR function can be responded only after the GPIO interrupt is enabled. >The configured ISR function can be responded only after the GPIO interrupt is enabled.
Use the following function to disable the GPIO interrupt: Call **GpioDisableIrq()** to disable interrupts.
int32\_t GpioDisableIrq\(uint16\_t gpio\); int32\_t GpioDisableIrq\(uint16\_t gpio\);
...@@ -415,12 +426,12 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -415,12 +426,12 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
</tr> </tr>
<tr id="row156694410112"><td class="cellrowborder" valign="top" width="50%"><p id="p14669141214"><a name="p14669141214"></a><a name="p14669141214"></a>0</p> <tr id="row156694410112"><td class="cellrowborder" valign="top" width="50%"><p id="p14669141214"><a name="p14669141214"></a><a name="p14669141214"></a>0</p>
</td> </td>
<td class="cellrowborder" valign="top" width="50%"><p id="p1266934818"><a name="p1266934818"></a><a name="p1266934818"></a>Succeeded in disabling a GPIO interrupt.</p> <td class="cellrowborder" valign="top" width="50%"><p id="p1266934818"><a name="p1266934818"></a><a name="p1266934818"></a>The operation is successful.</p>
</td> </td>
</tr> </tr>
<tr id="row176691543117"><td class="cellrowborder" valign="top" width="50%"><p id="p7669941716"><a name="p7669941716"></a><a name="p7669941716"></a>Negative value</p> <tr id="row176691543117"><td class="cellrowborder" valign="top" width="50%"><p id="p7669941716"><a name="p7669941716"></a><a name="p7669941716"></a>Negative value</p>
</td> </td>
<td class="cellrowborder" valign="top" width="50%"><p id="p4669164219"><a name="p4669164219"></a><a name="p4669164219"></a>Failed to disable a GPIO interrupt.</p> <td class="cellrowborder" valign="top" width="50%"><p id="p4669164219"><a name="p4669164219"></a><a name="p4669164219"></a>The operation failed.</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -470,11 +481,15 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -470,11 +481,15 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
## Usage Example<a name="section25941262111"></a> ## Usage Example<a name="section25941262111"></a>
In this example, we test the interrupt trigger of a GPIO pin as follows: Set the ISR function for the pin, set the trigger mode to rising edge and failing edge, write high and low levels to the pin alternately to generate level fluctuation, and observe the execution of the ISR function. The procedure is as follows:
1. Select an idle GPIO pin.
This example uses pin GPIO10\_3 on a Hi3516D V300 development board as an example. The pin number is 83. You can select an idle GPIO pin as required.
Select an idle GPIO pin. This example uses a Hi3516D V300 development board and GPIO pin GPIO10\_3, which is numbered GPIO83. 2. Set the ISR function for the pin, with the trigger mode of rising edge and failing edge.
You can select an idle GPIO pin based on the development board and schematic diagram. 3. Write high and low levels to the pin alternately, and observe the execution of the ISR function.
``` ```
#include "gpio_if.h" #include "gpio_if.h"
......
...@@ -2,19 +2,20 @@ ...@@ -2,19 +2,20 @@
## Overview<a name="section5361140416"></a> ## Overview<a name="section5361140416"></a>
- The Inter-Integrated Circuit \(I2C\) is a simple, bidirectional, and synchronous serial bus that uses merely two wires. The Inter-Integrated Circuit \(I2C\) is a simple, bidirectional, and synchronous serial bus that uses merely two wires.
- In an I2C communication, one controller communicates with one or more devices through the serial data line \(SDA\) and serial clock line \(SCL\), as shown in [Figure 1](#fig1135561232714).
- I2C data transfer must begin with a **START** condition and end with a **STOP** condition. Data is transmitted byte-by-byte from the most significant bit to the least significant bit. In an I2C communication, one controller communicates with one or more devices through the serial data line \(SDA\) and serial clock line \(SCL\), as shown in [Figure 1](#fig1135561232714).
- Each I2C node is recognized by a unique address and can serve as either a controller or a device. When the controller needs to communicate with a device, it writes the device address to the bus through broadcast. A device matching this address sends a response to set up a data transfer channel.
- The I2C APIs define a set of common functions for I2C data transfer, including: I2C data transfer must begin with a **START** condition and end with a **STOP** condition. Data is transmitted byte-by-byte from the most significant bit to the least significant bit.
- I2C controller management: opening or closing an I2C controller Each I2C node is recognized by a unique address and can serve as either a controller or a device. When the controller needs to communicate with a device, it writes the device address to the bus through broadcast. A device matching this address sends a response to set up a data transfer channel.
- I2C message transfer: custom transfer by using a message array
**Figure 1** Physical connection diagram for I2C<a name="fig1135561232714"></a> The I2C APIs define a set of common functions for I2C data transfer, including:
![](figures/physical-connection-diagram-for-i2c.png "physical-connection-diagram-for-i2c")
- I2C controller management: opening or closing an I2C controller
- I2C message transfer: custom transfer by using a message array
**Figure 1** Physical connection diagram for I2C<br/>![](figures/physical-connection-diagram-for-i2c.png "physical-connection-diagram-for-i2c")
## Available APIs<a name="section545869122317"></a> ## Available APIs<a name="section545869122317"></a>
...@@ -52,21 +53,22 @@ ...@@ -52,21 +53,22 @@
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE**<br/>
>All functions provided in this document can be called only in kernel mode. >All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section1695201514281"></a> ## Usage Guidelines<a name="section1695201514281"></a>
### How to Use<a name="section1338373417288"></a> ### How to Use<a name="section1338373417288"></a>
[Figure 2](#fig183017194234) illustrates the process of an I2C device. The figure below illustrates how to use the APIs.
**Figure 2** Process of using an I2C device<a name="fig183017194234"></a> **Figure 2** Using I2C driver APIs
![](figures/process-of-using-an-i2c-device.png "process-of-using-an-i2c-device")
![](figures/using-i2c-process.png "process-of-using-an-i2c-device")
### Opening an I2C Controller<a name="section13751110132914"></a> ### Opening an I2C Controller<a name="section13751110132914"></a>
Call the following function to open an I2C controller: Call the **I2cOpen()** function to open an I2C controller.
DevHandle I2cOpen\(int16\_t number\); DevHandle I2cOpen\(int16\_t number\);
...@@ -117,7 +119,7 @@ if (i2cHandle == NULL) { ...@@ -117,7 +119,7 @@ if (i2cHandle == NULL) {
### Performing I2C Communication<a name="section9202183372916"></a> ### Performing I2C Communication<a name="section9202183372916"></a>
Use the following function for message transfer: Call the **I2cTransfer()** function to transfer messages.
int32\_t I2cTransfer\(DevHandle handle, struct I2cMsg \*msgs, int16\_t count\); int32\_t I2cTransfer\(DevHandle handle, struct I2cMsg \*msgs, int16\_t count\);
...@@ -186,15 +188,14 @@ if (ret != 2) { ...@@ -186,15 +188,14 @@ if (ret != 2) {
} }
``` ```
>![](../public_sys-resources/icon-caution.gif) **CAUTION:** >![](../public_sys-resources/icon-caution.gif) **CAUTION**<br/>
>- The device address in the **I2cMsg** structure does not contain the read/write flag bit. The read/write information is transferred by the read/write control bit in the member variable **flags**. >- The device address in the **I2cMsg** structure does not contain the read/write flag bit. The read/write information is transferred by the read/write control bit in the member variable **flags**.
>- The **I2cTransfer** function does not limit the number of message structures, which is determined by the I2C controller. >- The **I2cTransfer** function does not limit the number of message structures and the data length of each message structure, which are determined by the I2C controller.
>- The **I2cTransfer** function does not limit the data length of each message structure, which is determined by the I2C controller.
>- The **I2cTransfer** function may cause the system to sleep and therefore cannot be called in the interrupt context. >- The **I2cTransfer** function may cause the system to sleep and therefore cannot be called in the interrupt context.
### Closing an I2C Controller<a name="section19481164133018"></a> ### Closing an I2C Controller<a name="section19481164133018"></a>
Call the following function to close the I2C controller after the communication is complete: Call the **I2cClose()** function to close the I2C controller after the communication is complete.
void I2cClose\(DevHandle \*handle\); void I2cClose\(DevHandle \*handle\);
...@@ -209,12 +210,13 @@ void I2cClose\(DevHandle \*handle\); ...@@ -209,12 +210,13 @@ void I2cClose\(DevHandle \*handle\);
</thead> </thead>
<tbody><tr id="row1926109193116"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p105419317318"><a name="p105419317318"></a><a name="p105419317318"></a>handle</p> <tbody><tr id="row1926109193116"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p105419317318"><a name="p105419317318"></a><a name="p105419317318"></a>handle</p>
</td> </td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1213245577"><a name="p1213245577"></a><a name="p1213245577"></a>Handle of an I2C controller.</p> <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1213245577"><a name="p1213245577"></a><a name="p1213245577"></a>Handle of the I2C controller to close.</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
``` ```
I2cClose(i2cHandle); /* Close the I2C controller. */ I2cClose(i2cHandle); /* Close the I2C controller. */
``` ```
...@@ -233,7 +235,7 @@ This example shows a simple register read/write operation on TouchPad on a Hi351 ...@@ -233,7 +235,7 @@ This example shows a simple register read/write operation on TouchPad on a Hi351
In this example, first we reset Touch IC. \(The development board supplies power to Touch IC by default after being powered on, and this use case does not consider the power supply\). Then, we perform a read/write operation on an internal register to test whether the I2C channel is normal. In this example, first we reset Touch IC. \(The development board supplies power to Touch IC by default after being powered on, and this use case does not consider the power supply\). Then, we perform a read/write operation on an internal register to test whether the I2C channel is normal.
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE** <br/>
>The example focuses on I2C device access and verifies the I2C channel. The read and write values of the device register are not concerned. The behavior caused by the read and write operations on the register is determined by the device itself. >The example focuses on I2C device access and verifies the I2C channel. The read and write values of the device register are not concerned. The behavior caused by the read and write operations on the register is determined by the device itself.
Example: Example:
......
...@@ -59,12 +59,11 @@ The figure below shows a simplified CSI. The D-PHY transmits data by using one p ...@@ -59,12 +59,11 @@ The figure below shows a simplified CSI. The D-PHY transmits data by using one p
### How to Use<a name="section2.1_MIPI_CSIDes"></a> ### How to Use<a name="section2.1_MIPI_CSIDes"></a>
The figure below shows the process of using a MIPI CSI device. The figure below illustrates how to use the APIs.
**Figure 2** MIPI CSI usage process<a name="fig2_MIPI_CSIDes"></a> **Figure 2** Using MIPI CSI driver APIs
![](figures/using-MIPI-CSI-process.png)
![](figures/process-of-using-MIPI-CSI.png)
### Opening the MIPI CSI Controller Operation Handle<a name="section2.2_MIPI_CSIDes"></a> ### Opening the MIPI CSI Controller Operation Handle<a name="section2.2_MIPI_CSIDes"></a>
......
# MIPI DSI<a name="EN-US_TOPIC_0000001160971534"></a> # MIPI DSI
## Overview<a name="section16806142183217"></a> ## Overview
The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals. The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals.
...@@ -11,7 +11,7 @@ MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP ...@@ -11,7 +11,7 @@ MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP
![](figures/dsi-transmitting-and-receiving-interface.png "dsi-transmitting-and-receiving-interface") ![](figures/dsi-transmitting-and-receiving-interface.png "dsi-transmitting-and-receiving-interface")
## Available APIs<a name="section12720125432316"></a> ## Available APIs
**Table 1** APIs for MIPI DSI **Table 1** APIs for MIPI DSI
...@@ -75,17 +75,17 @@ MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP ...@@ -75,17 +75,17 @@ MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-note.gif) **NOTE**<br> >![](../public_sys-resources/icon-note.gif) **NOTE**<br> All functions described in this document can be called only in kernel space.
>All functions described in this document can be called only in kernel space.
## Usage Guidelines<a name="section037231715335"></a> ## Usage Guidelines
### How to Use<a name="section49299119344"></a> ### How to Use
[Figure 2](#fig129103491241) shows the process of using a MIPI DSI device. The figure below illustrates how to use the APIs.
**Figure 2** Process of using a MIPI DSI device<a name="fig129103491241"></a> **Figure 2** Using MIPI DSI driver APIs
![](figures/process-of-using-a-mipi-dsi-device.png)
![](figures/using-mipi-dsi-process.png)
### Obtaining a MIPI DSI Device Handle<a name="section5126155683811"></a> ### Obtaining a MIPI DSI Device Handle<a name="section5126155683811"></a>
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册