提交 da411403 编写于 作者: K king_he 提交者: Gitee

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

此差异已折叠。
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
## Overview ## Overview
### Concepts ### Concepts
The Page ability implements the ArkUI and provides the capability of interacting with developers. When you create an ability in the integrated development environment (IDE), the IDE automatically creates template code. The capabilities related to the Page ability are implemented through the **featureAbility**, and the lifecycle callbacks are implemented through the callbacks in **app.js/app.ets**. The Page ability implements the ArkUI and provides the capability of interacting with developers. When you create an ability in DevEco Studio, DevEco Studio automatically creates template code. The capabilities related to the Page ability are implemented through the **featureAbility**, and the lifecycle callbacks are implemented through the callbacks in **app.js** or **app.ets**.
### Page Ability Lifecycle ### Page Ability Lifecycle
**Ability lifecycle** **Ability lifecycle**
The Page ability lifecycle is a general term for all states of a Page ability, such as **INACTIVE**, **ACTIVE**, and **BACKGROUND**. The Page ability lifecycle defines all states of a Page ability, such as **INACTIVE**, **ACTIVE**, and **BACKGROUND**.
The following figure shows the lifecycle state transition of the Page ability. The following figure shows the lifecycle state transition of the Page ability.
...@@ -17,25 +17,25 @@ The following figure shows the lifecycle state transition of the Page ability. ...@@ -17,25 +17,25 @@ The following figure shows the lifecycle state transition of the Page ability.
Description of ability lifecycle states: Description of ability lifecycle states:
- **UNINITIALIZED**: The Page ability is not initialized. This is a temporary state. A Page ability changes directly to the **INITIAL** state upon its creation. - **UNINITIALIZED**: The Page ability is not initialized. This is a temporary state, from which a Page ability changes directly to the **INITIAL** state upon its creation.
- **INITIAL**: This state refers to the initial or stopped state. The Page ability in this state is not running. The Page ability enters the **INACTIVE** state after it is started. - **INITIAL**: The Page ability is initialized but not running. The Page ability enters the **INACTIVE** state after it is started.
- **INACTIVE**: The ability is visible but does not gain focus. - **INACTIVE**: The Page ability is visible but does not gain focus.
- **ACTIVE**: The ability runs in the foreground and gains focus. - **ACTIVE**: The Page ability runs in the foreground and has focus.
- **BACKGROUND**: The Page ability returns to the background. After being re-activated, the Page ability enters the **ACTIVE** state. After being destroyed, the Page ability enters the **INITIAL** state. - **BACKGROUND**: The Page ability runs in the background. After being re-activated, the Page ability enters the **ACTIVE** state. After being destroyed, the Page ability enters the **INITIAL** state.
**The following figure shows the relationship between lifecycle callbacks and lifecycle states of the Page ability.** **The following figure shows the relationship between lifecycle callbacks and lifecycle states of the Page ability.**
![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) ![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png)
You can override the lifecycle callbacks provided by the Page ability in the **app.js/app.ets** file. Currently, the **app.js** file provides only the **onCreate** and **onDestroy** callbacks, and the **app.ets** file provides the full lifecycle callbacks. You can override the lifecycle callbacks provided by the Page ability in the **app.js** or **app.ets** file. Currently, the **app.js** file provides only the **onCreate** and **onDestroy** callbacks, and the **app.ets** file provides the full lifecycle callbacks.
### Launch Type ### Launch Type
The ability supports two launch types: singleton and multi-instance. The ability supports two launch types: singleton and multi-instance.
The **launchType** item in the **config.json** file is used to specify the launch type. You can specify the launch type by setting **launchType** in the **config.json** file.
| Launch Type | Description |Description | | Launch Type | Description |Description |
| ----------- | ------- |---------------- | | ----------- | ------- |---------------- |
...@@ -55,7 +55,7 @@ By default, **singleton** is used. ...@@ -55,7 +55,7 @@ By default, **singleton** is used.
| void startAbility(parameter: StartAbilityParameter) | Starts an ability. | | void startAbility(parameter: StartAbilityParameter) | Starts an ability. |
| Context getContext(): | Obtains the application context.| | Context getContext(): | Obtains the application context.|
| void terminateSelf() | Terminates the ability. | | void terminateSelf() | Terminates the ability. |
| bool hasWindowFocus() | Checks whether the ability gains focus. | | bool hasWindowFocus() | Checks whether the ability has focus. |
### Starting a Local Page Ability ### Starting a Local Page Ability
...@@ -76,37 +76,10 @@ By default, **singleton** is used. ...@@ -76,37 +76,10 @@ By default, **singleton** is used.
action: "", action: "",
entities: [""], entities: [""],
type: "", type: "",
options: {
// Grant the permission to perform read operations on the URI.
authReadUriPermission: true,
// Grant the permission to perform write operations on the URI.
authWriteUriPermission: true,
// Support forwarding the Want result to the ability.
abilityForwardResult: true,
// Enable abiligy continuation.
abilityContinuation: true,
// Specify that a component does not belong to ohos.
notOhosComponent: true,
// Specify that an ability is started.
abilityFormEnabled: true,
// Grant the permission for possible persisting on the URI.
authPersistableUriPermission: true,
// Grant the permission for possible persisting on the prefix URI.
authPrefixUriPermission: true,
// Support distributed scheduling system startup on multiple devices.
abilitySliceMultiDevice: true,
// A service ability is started regardless of whether the host application has been started.
startForegroundAbility: true,
// Install the specified ability if it is not installed.
installOnDemand: true,
// Return the result to the ability slice.
abilitySliceForwardResult: true,
// Install the specified ability with background mode if it is not installed.
installWithBackgroundMode: true
},
deviceId: "", deviceId: "",
bundleName: "com.example.startability", bundleName: "com.example.myapplication",
abilityName: "com.example.startability.MainAbility", /* In the FA model, abilityName consists of package and ability name. */
abilityName: "com.example.entry.secondAbility",
uri: "" uri: ""
}, },
}, },
...@@ -122,10 +95,10 @@ You can also include **parameters** in the **want** parameter and set its value ...@@ -122,10 +95,10 @@ You can also include **parameters** in the **want** parameter and set its value
featureAbility.startAbility({ featureAbility.startAbility({
want: want:
{ {
bundleName: "com.example.startability", bundleName: "com.example.myapplication",
uri: "", uri: "",
parameters: { parameters: {
abilityName: "com.example.startability.MainAbility" abilityName: "com.example.entry.secondAbility"
} }
}, },
}, },
...@@ -227,15 +200,15 @@ In the cross-device scenario, the application must also apply for the data synch ...@@ -227,15 +200,15 @@ In the cross-device scenario, the application must also apply for the data synch
| API | Description | | API | Description |
| ------------ | ------------------------------------------------------------ | | ------------ | ------------------------------------------------------------ |
| onShow() | Called when the ability is switched from the background to the foreground. In this case, the ability is visible to users.| | onShow() | Called when the ability is switched from the background to the foreground. In this case, the ability is visible to users.|
| onHide() | Called when the ability is switched from the foreground to the background. In this case, the ability is invisible.| | onHide() | Called when the ability is switched from the foreground to the background. In this case, the ability is invisible to users.|
| onDestroy() | Called when the ability is destroyed. In this callback, you can make preparations for app exit, such as recycling resources and clearing the cache.| | onDestroy() | Called when the ability is destroyed. In this callback, you can make preparations for application exit, such as recycling resources and clearing the cache.|
| onCreate() | Called when the ability is created for the first time. You can initialize the application in this callback.| | onCreate() | Called when the ability is created for the first time. You can initialize the application in this callback.|
| onInactive() | Called when the ability loses focus. An ability loses focus before entering the background state.| | onInactive() | Called when the ability loses focus. An ability loses focus when it is about to enter the background state.|
| onActive() | Called when the ability is switched to the foreground and gains focus. | | onActive() | Called when the ability is switched to the foreground and gains focus. |
**Example** **Example**
You need to override the lifecycle callbacks in **app.js/app.ets**. The IDE template generates **onCreate()** and **onDestroy()** by default. You need to override the other callbacks. You need to override the lifecycle callbacks except **onCreate()** and **onDestroy()** in **app.js** or **app.ets**. The **onCreate()** and **onDestroy()** callbacks are automatically generated in the template code provided by DevEco Studio.
```javascript ```javascript
export default { export default {
...@@ -261,4 +234,5 @@ export default { ...@@ -261,4 +234,5 @@ export default {
``` ```
## Samples ## Samples
The following sample is provided to help you better understand how to develop a Page ability: The following sample is provided to help you better understand how to develop a Page ability:
- [`DMS`: Distributed Demo (eTS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS)
- [`DMS`: Distributed Demo (eTS, API version 7)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS)
...@@ -8,13 +8,17 @@ The following figure shows the ability call process. ...@@ -8,13 +8,17 @@ The following figure shows the ability call process.
![stage-call](figures/stage-call.png) ![stage-call](figures/stage-call.png)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The startup mode of the callee must be **singleton**.
> Currently, only system applications and Service Extension abilities can use the **Call** APIs to access the callee.
## Available APIs ## Available APIs
The table below describes the ability call APIs. For details, see [Ability](../reference/apis/js-apis-application-ability.md#caller). The table below describes the ability call APIs. For details, see [Ability](../reference/apis/js-apis-application-ability.md#caller).
**Table 1** Ability call APIs **Table 1** Ability call APIs
|API|Description| |API|Description|
|:------|:------| |:------|:------|
|Promise<Caller> startAbilityByCall(want: Want)|Obtains the caller interface of the specified ability, and if the specified ability is not started, starts the ability in the background.| |Promise<Caller> startAbilityByCall(want: Want)|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.|
|void on(method: string, callback: CalleeCallBack)|Callee.on: callback invoked when the callee registers a method.| |void on(method: string, callback: CalleeCallBack)|Callee.on: callback invoked when the callee registers a method.|
|void off(method: string)|Callee.off: callback invoked when the callee deregisters a method.| |void off(method: string)|Callee.off: callback invoked when the callee deregisters a method.|
|Promise<void> call(method: string, data: rpc.Sequenceable)|Caller.call: sends agreed sequenceable data to the callee.| |Promise<void> call(method: string, data: rpc.Sequenceable)|Caller.call: sends agreed sequenceable data to the callee.|
...@@ -77,7 +81,7 @@ export default class MySequenceable { ...@@ -77,7 +81,7 @@ export default class MySequenceable {
``` ```
4. Implement **Callee.on** and **Callee.off**. 4. Implement **Callee.on** and **Callee.off**.
The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **CalleeSortMethod** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns them. You need to implement processing based on service requirements. The sample code is as follows: The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **CalleeSortMethod** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows:
```ts ```ts
const TAG: string = '[CalleeAbility]' const TAG: string = '[CalleeAbility]'
const MSG_SEND_METHOD: string = 'CallSendMsg' const MSG_SEND_METHOD: string = 'CallSendMsg'
...@@ -196,7 +200,7 @@ context.requestPermissionsFromUser(permissions).then((data) => { ...@@ -196,7 +200,7 @@ context.requestPermissionsFromUser(permissions).then((data) => {
``` ```
3. Send agreed sequenceable data. 3. Send agreed sequenceable data.
The sequenceable data can be sent to the callee in either of the following ways: without a return value or obtaining data returned by the callee. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code is as follows: The sequenceable data can be sent to the callee with or without a return value. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code is as follows:
```ts ```ts
const MSG_SEND_METHOD: string = 'CallSendMsg' const MSG_SEND_METHOD: string = 'CallSendMsg'
async onButtonCall() { async onButtonCall() {
...@@ -242,9 +246,6 @@ try { ...@@ -242,9 +246,6 @@ try {
} }
``` ```
## Development Example ## Samples
The following sample is provided to help you better understand how to develop an ability call in the stage model: The following sample is provided to help you better understand how to develop an ability call in the stage model:
- [`StageCallAbility`: Stage Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
[StageCallAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
In this sample, the **AbilityStage** APIs are implemented in the **AbilityStage.ts** file in the **Application** directory, the **Ability** APIs are implemented in the **MainAbility** directory, and **pages/index** is the pages of the ability. Another ability and callee are implemented in the **CalleeAbility** directory, and its pages are the content configured in **pages/second**. The **MainAbility** functions as the caller, and the **CalleeAbility** functions as the callee. After starting the **CalleeAbility**, the **MainAbility** obtains the caller interface, processes the string entered by the user, and transfers the processed string to the **CalleeAbility**. The **CalleeAbility** refreshes the page based on the received data and returns the result to the **MainAbility**.
...@@ -19,4 +19,4 @@ In OpenHarmony documents, proxy represents the service requester, and stub repre ...@@ -19,4 +19,4 @@ In OpenHarmony documents, proxy represents the service requester, and stub repre
## Related Modules ## Related Modules
Distributed Scheduler [Distributed Scheduler](https://gitee.com/openharmony/distributedschedule_dms_fwk)
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
- Relational Database - Relational Database
- [RDB Overview](database-relational-overview.md) - [RDB Overview](database-relational-overview.md)
- [RDB Development](database-relational-guidelines.md) - [RDB Development](database-relational-guidelines.md)
- Lightweight Data Store - Preferences
- [Lightweight Data Store Overview](database-preference-overview.md) - [Preferences Overview](database-preference-overview.md)
- [Lightweight Data Store Development](database-preference-guidelines.md) - [Preferences Development](database-preference-guidelines.md)
- Distributed Data Object - Distributed Data Object
- [Distributed Data Object Overview](database-distributedobject-overview.md) - [Distributed Data Object Overview](database-distributedobject-overview.md)
- [Distributed Data Object Development](database-distributedobject-guidelines.md) - [Distributed Data Object Development](database-distributedobject-guidelines.md)
# Lightweight Data Store Development # Preferences Development
## When to Use ## When to Use
The lightweight data store is ideal for storing lightweight and frequently used data, but not for storing a large amount of data or data with frequent changes. The application data is persistently stored on a device in the form of files. Note that the instance accessed by an application contains all data of the file. The data is always loaded to the memory of the device until the application removes it from the memory. The application can perform data operations using the **Storage** APIs. Preferences are ideal for storing data frequently used by applications, but not for storing a large amount of data or data with frequent changes. The application data is persistently stored on a device in the form of files. Note that the instance accessed by an application contains all data of the file. The data is always loaded to the memory of the device until the application removes it from the memory. The application can perform data operations using the **Preferences** APIs.
## Available APIs ## Available APIs
The lightweight data store 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. Preferences provide capabilities for processing data in the form of key-value (KV) pairs and support data persistence, modification, and query. In KV pairs, keys are of the string type, and values can be of the number, string, or Boolean type.
**Creating a Storage Instance** ### Creating a Preferences Instance
Create a **Storage** instance for data operations. A **Storage** instance is created after data is read from a specified file and loaded to the instance. Create a **Preferences** instance for data operations. A **Preferences** instance is created after data is read from a specified file and loaded to the instance.
**Table 1** API for creating a **Storage** instance **Table 1** API for creating a **Preferences** instance
| Package | API | Description | | Package | API | Description |
| ----------------- | ------------------------------------------- | ------------------------------------------- | | ----------------- | ------------------------------------------- | ------------------------------------------- |
| ohos.data.storage | getStorage(path: string): Promise\<Storage> | Obtains the **Storage** singleton corresponding to a file for data operations.| | ohos.data.preferences | getPreferences(context: Context, name: string): Promise\<Preferences> | Obtains a **Preferences** instance for data operations.|
**Writing Data** ### Writing Data
Call the **put()** method to add or modify data in a **Storage** instance. Call the **put()** method to add or modify data in a **Preferences** instance.
**Table 2** API for writing data **Table 2** API for writing data
| Class | API | Description | | Class | API | Description |
| ------- | -------------------------------------------------- | ----------------------------------------------- | | ------- | -------------------------------------------------- | ----------------------------------------------- |
| Storage | put(key: string, value: ValueType): Promise\<void> | Writes data of the number, string, and Boolean types.| | Preferences | put(key: string, value: ValueType): Promise\<void> | Writes data of the number, string, and Boolean types.|
**Reading Data** ### Reading Data
Call the **get()** method to read data from a **Storage** instance. Call the **get()** method to read data from a **Preferences** instance.
**Table 3** API for reading data **Table 3** API for reading data
| Class | API | Description | | Class | API | Description |
| ------- | ---------------------------------------------------------- | ----------------------------------------------- | | ------- | ---------------------------------------------------------- | ----------------------------------------------- |
| Storage | get(key: string, defValue: ValueType): Promise\<ValueType> | Reads data of the number, string, and Boolean types.| | Preferences | get(key: string, defValue: ValueType): Promise\<ValueType> | Reads data of the number, string, and Boolean types.|
**Storing Data Persistently** ### Storing Data Persistently
Call the **flush()** method to write the cached data back to its text file for persistent storage. Call the **flush()** method to write the cached data back to its text file for persistent storage.
...@@ -46,119 +46,120 @@ Call the **flush()** method to write the cached data back to its text file for p ...@@ -46,119 +46,120 @@ Call the **flush()** method to write the cached data back to its text file for p
| Class | API | Description | | Class | API | Description |
| ------- | ----------------------- | --------------------------------------- | | ------- | ----------------------- | --------------------------------------- |
| Storage | flush(): Promise\<void> | Writes data in the **Storage** instance back to its file through an asynchronous thread.| | Preferences | flush(): Promise\<void> | Writes data from the **Preferences** instance back to its file through an asynchronous thread.|
**Observing Data Changes** ### Observing Data Changes
Specify **StorageObserver** as the callback to subscribe to data changes. When the value of the subscribed key is changed and the **flush()** method is executed, **StorageObserver** will be invoked. You can subscribe to data changes. When the value of the subscribed key is changed by **flush()**, a callback will be invoked to return the new data.
**Table 5** APIs for observing data changes **Table 5** APIs for observing **Preferences** changes
| Class | API | Description | | Class | API | Description |
| ------- | ------------------------------------------------------------ | -------------- | | ------- | ------------------------------------------------------------ | -------------- |
| Storage | on(type: 'change', callback: Callback\<StorageObserver>): void | Subscribe to data changes.| | Preferences | on(type: 'change', callback: Callback<{ key : string }>): void | Subscribes to data changes.|
| Storage | off(type: 'change', callback: Callback\<StorageObserver>): void | Unsubscribes from data changes. | | Preferences | off(type: 'change', callback: Callback<{ key : string }>): void | Unsubscribes from data changes. |
**Deleting Data** ### Deleting Data
Use the following APIs to delete a **Storage** instance or data file. Use the following APIs to delete a **Preferences** instance or data file.
**Table 6** APIs for deleting data **Table 6** APIs for deleting **Preferences**
| Package | API | Description | | Package | API | Description |
| ----------------- | ---------------------------------------------------- | ------------------------------------------------------------ | | ----------------- | ---------------------------------------------------- | ------------------------------------------------------------ |
| ohos.data.storage | deleteStorage(path: string): Promise\<void> | Deletes a **Storage** instance from the cache and deletes its file from the device.| | ohos.data.preferences | deletePreferences(context: Context, name: string): Promise<void>; | Deletes a **Preferences** instance from the cache and deletes its file from the device.|
| ohos.data.storage | removeStorageFromCache(path: string): Promise\<void> | Deletes a **Storage** instance from the cache to release memory. | | ohos.data.preferences | removePreferencesFromCache(context: Context, name: string): Promise\<void>; | Removes a **Preferences** instance from the memory to release memory.
## How to Develop ## How to Develop
1. Import @ohos.data.storage and related modules to the development environment. 1. Import @ohos.data.preferences and related modules to the development environment.
```js ```js
import dataStorage from '@ohos.data.storage' import data_preferences from '@ohos.data.preferences'
import featureAbility from '@ohos.ability.featureAbility' // Used to obtain the file storage path.
``` ```
2. Create a **Storage** instance. 2. Create a **Preferences** instance.
Read the specified file and load its data to the **Storage** instance for data operations. Read the specified file and load its data to the **Preferences** instance for data operations.
```js ```js
var context = featureAbility.getContext() let promise = data_preferences.getPreferences(this.context, 'mystore')
context.getFilesDir().then(() => {
console.info("======================>getFilesDirPromsie====================>");
});
let promise = dataStorage.getStorage(path + '/mystore')
``` ```
3. Write data. 3. Write data.
Use the **put()** method of the **Storage** class to write data to the cached **Storage** instance. Use the **put()** method of the **Preferences** class to write data to the cached **Preferences** instance.
```js ```js
promise.then((storage) => { promise.then((preferences) => {
let getPromise = storage.put('startup', 'auto') // Save data to the Storage instance. let getPromise = preferences.put('startup', 'auto')
getPromise.then(() => { getPromise.then(() => {
console.info("Put the value of startup successfully.") console.info("Put the value of startup successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Put the value of startup failed with err: " + err) console.info("Failed to put the value of startup with err: " + err)
}) })
}).catch((err) => { }).catch((err) => {
console.info("Get the storage failed") console.info("Failed to get the preferences")
}) })
``` ```
4. Read data. 4. Read data.
Use the **get()** method of the **Storage** class to read data. Use the **get()** method of the **Preferences** class to read data.
```js ```js
promise.then((storage) => { promise.then((preferences) => {
let getPromise = storage.get('startup', 'default') let getPromise = preferences.get('startup', 'default')
getPromise.then((value) => { getPromise.then((value) => {
console.info("The value of startup is " + value) console.info("The value of startup is " + value)
}).catch((err) => { }).catch((err) => {
console.info("Get the value of startup failed with err: " + err) console.info("Failed to get the value of startup with err: " + err)
}) })
}).catch((err) => { }).catch((err) => {
console.info("Get the storage failed")}) console.info("Failed to get the preferences")})
``` ```
5. Store data persistently. 5. Store data persistently.
Use the **flush()** or **flushSync()** method to flush data in the **Storage** instance to its file. Use the **flush()** method to flush data from the **Preferences** instance to its file.
```js ```js
storage.flush(); preferences.flush();
``` ```
6. Observe data changes. 6. Observe data changes.
Specify **StorageObserver** as the callback to subscribe to data changes for an application. When the value of the subscribed key is changed and the **flush()** method is executed, **StorageObserver** will be invoked. Unregister the **StorageObserver** when it is no longer required. Specify an observer as the callback to subscribe to data changes for an application. When the value of the subscribed key is changed and the **flush()** method is executed, the observe callback will be invoked to return the change.
```js ```js
promise.then((storage) => { var observer = function (key) {
var observer = function (key) { console.info("The key of " + key + " changed.")
console.info("The key of " + key + " changed.") }
} preferences.on('change', observer)
storage.on('change', observer) preferences.put('startup', 'auto', function (err) {
storage.putSync('startup', 'auto') // Modify data in the Storage instance. if (err) {
storage.flushSync() // Trigger the StorageObserver callback. console.info("Failed to put the value of startup with err: " + err)
return
storage.off(...change..., observer) // Unsubscribe from the data changes. }
}).catch((err) => { console.info("Put the value of startup successfully.")
console.info("Get the storage failed") preferences.flush(function (err) {
}) if (err) {
console.info("Failed to flush data to file with err: " + err)
return
}
console.info("Flushed to file successfully.") // Observer will be called.
})
})
``` ```
7. Delete the specified file. 7. Delete the specified file.
Use the **deleteStorage** method to delete the **Storage** singleton of the specified file from the memory, and delete the specified file, its backup file, and damaged files. After the specified files are deleted, the application cannot use that instance to perform any data operation. Otherwise, data inconsistency will occur. The deleted data and files cannot be restored. Use the **deletePreferences** method to delete the **Preferences** singleton of the specified file from the memory, and delete the specified file, its backup file, and corrupted files. After the specified files are deleted, the application cannot use that instance to perform any data operation. Otherwise, data inconsistency will occur. The deleted data and files cannot be restored.
```js ```js
let promise = dataStorage.deleteStorage(path + '/mystore') let proDelete = data_preferences.deletePreferences(context, 'mystore')
promise.then(() => { proDelete.then(() => {
console.info("Deleted successfully.") console.info("Data deleted successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Deleted failed with err: " + err)}) console.info("Failed to delete data with err: " + err)
})
``` ```
# Lightweight Data Store Overview<a name="EN-US_TOPIC_0000001230752103"></a> # Preferences Overview
Lightweight data store is applicable to access and persistence operations on the data in key-value pairs. When an application accesses a lightweight **Storage** instance, data in the **Storage** instance will be cached in the memory for faster access. The cached data can also be written back to the text file for persistent storage. Since file read and write consume system resources, you are advised to minimize the frequency of reading and writing persistent files. Preferences are used for access and persistence operations on the data in the key-value structure. When an application accesses a **Preferences** instance, the data in the instance will be cached in the memory for faster access. The cached data can also be written back to the text file for persistent storage. Since file read and write consume system resources, you are advised to minimize the frequency of reading and writing persistent files.
## Basic Concepts<a name="section1055404171115"></a> ## Basic Concepts
- **Key-Value data structure** - **Key-value data structure**
A type of data structure. The key is the unique identifier for a piece of data, and the value is the specific data being identified. A type of data structure. The key is the unique identifier for a piece of data, and the value is the specific data being identified.
- **Non-relational database** - **Non-relational database**
A database not in compliance with the atomicity, consistency, isolation, and durability \(ACID\) database management properties of relational data transactions. The data in a non-relational database is independent. A database not in compliance with the atomicity, consistency, isolation, and durability (ACID) database management properties of relational data transactions. The data in a non-relational database is independent.
## Working Principles
## Working Principles<a name="section682631371115"></a> When an application loads data from a **Preferences** file to a **Preferences** instance, the system stores the instance in the memory through a static container. Each file of an application or process has only one **Preferences** instance in the memory, till the application removes the instance from the memory or deletes the **Preferences** file.
1. When an application loads data from a specified **Storage** file to a **Storage** instance, the system stores the instance in the memory through a static container. Each file of an application or process has only one **Storage** instance in the memory, till the application removes the instance from the memory or deletes the **Storage** file. When obtaining a **Preferences** instance, the application can read data from or write data to the instance. The data in the instance can be flushed to its **Preferences** file by calling the **flush()** method.
2. When obtaining a **Storage** instance, the application can read data from or write data to the instance. The data in the **Storage** instance can be flushed to its **Storage** file by calling the **flush** or **flushSync** method.
**Figure 1** How lightweight data store works<a name="fig1657785713509"></a> **Figure 1** How **Preferences** work
![](figures/preferences.png)
![](figures/en-us_image_0000001199139454.png) ## Constraints
## Constraints<a name="section17243172883219"></a>
- **Storage** instances are loaded to the memory. To minimize non-memory overhead, the number of data records stored in a **Storage** instance cannot exceed 10,000. Delete the instances that are no longer used in a timely manner.
- The key in the key-value pairs is of the string type. It cannot be empty or exceed 80 characters.
- If the value in the key-value pairs is of the string type, it can be empty or contain a maximum of 8192 characters.
- **Preferences** instances are loaded to the memory. To minimize non-memory overhead, the number of data records stored in a **Preferences** instance cannot exceed 10,000. Delete the instances that are no longer used in a timely manner.
- The key in key-value pairs is of the string type. It cannot be empty or exceed 80 bytes.
- The value of the string type in key-value pairs can be empty, but cannot exceed 8192 bytes if not empty.
...@@ -13,3 +13,6 @@ ...@@ -13,3 +13,6 @@
- Vibrator - Vibrator
- [Vibrator Overview](vibrator-overview.md) - [Vibrator Overview](vibrator-overview.md)
- [Vibrator Development](vibrator-guidelines.md) - [Vibrator Development](vibrator-guidelines.md)
- Update Servcie
- [Sample Server Overview](sample-server-overview.md)
- [Sample Server Development](sample-server-guidelines.md)
# Sample Server Development
## When to Use
The sample server provides a package search server for checking update packages and obtaining the update package download URLs, which was previously unavailable in the real-world update service. The sample server supports update service testing and secondary development function verification, building an end-to-end environment to cater for diverse update service use cases.
## How to Develop
1. Generate an SSL certificate.
Generate the **serverKey.pem** and **serverCert.cer** files for SSL communication of the sample server.
```
openssl req -newkey rsa:2048 -nodes -keyout serverKey.pem -x509 -days 365 -out serverCert.cer -subj "/C=CN/ST=GD/L=GZ/O=abc/OU=defg/CN=hijk/emailAddress=test.com"
```
2. Modify the **bundle.json** file.
Add **sub_component** to the **build** field.
```
"sub_component": [
"//base/update/updateservice/server_sample:testserver",
...
],
```
3. Create a code directory.
Go to the **update_updateservice** directory and run the following commands to create a code directory:
```
mkdir server_sample // Create the server_sample folder.
touch server_sample/BUILD.gn // Create the BUILD.gn file.
mkdir server_sample/include // Create the include folder to store the header file of the sample server.
touch server_process.h // Create the server_process.h header file.
mkdir server_sample/src // Create the src folder to store the C/C++ files of the sample server.
touch server_sample/src/server_process.c // Create the server_process.c file.
touch server_sample/src/main.cpp // Create the main.cpp file.
```
4. Write the **BUILD.gn** file.
The **BUILD.gn** file contains two **ohos** components: **ohos_shared_library** file named **libserver_process.z.so** and **ohos_executable** file named **testserver**.
```
import("//build/ohos.gni")
ohos_shared_library("server_process") {
sources = [
"//base/update/updateservice/server_sample/src/server_process.c",
]
include_dirs = [
"//base/update/updateservice/server_sample/include",
"//third_party/openssl/include",
]
deps = [
"//base/update/updater/services/log:libupdaterlog",
"//third_party/bounds_checking_function:libsec_static",
"//third_party/openssl:crypto_source",
"//third_party/openssl:ssl_source",
"//utils/native/base:utils",
]
part_name = "update_service"
}
ohos_executable("testserver") {
sources = [
"//base/update/updateservice/server_sample/src/main.cpp",
]
include_dirs = [
"//base/update/updateservice/server_sample/include",
]
deps = [
"//base/update/updateservice/server_sample:server_process",
]
part_name = "update_service"
}
```
5. Write the **server_process.h** file.
Declare the sample server APIs in the **server_process.h** file.
```c++
#ifndef __SERVER_PROCESS_H__
#define __SERVER_PROCESS_H__
/*
Init: creates a socket environment and presets certain attributes.
*/
int Init();
/*
SetParam: sets all plug-in parameters.
*/
int SetParam(const char *key, const char *value);
/*
GetParam: obtains all plug-in parameters.
*/
int GetParam(const char *key, char *value);
/*
ReverseSetParamCallback: callback.
*/
int ReverseSetParamCallback(int(*setParam)(const char *key, const char *value));
/*
Open: starts the service.
*/
int Open();
/*
MainLoop: invoked every 100 ms.
*/
int MainLoop();
/*
Close: stops the service and releases related resources.
*/
int Close();
#endif //__SERVER_PROCESS_H__
```
6. Write the **server_process.c** and **main.cpp** files.
In the **server_process.c** file, mainly declare **respondContent**, the format of the response message returned by the server. Write the **main.cpp** file based on instructions for the common SSL protocol server. Be sure to include related header files and load the **serverKey.pem** and **serverCert.cer** files.
```c
#include "server_process.h"
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "openssl/err.h"
#include "openssl/ssl.h"
#define SERVER_PEM "/data/sdcard/serverKey.pem" // Use an absolute path.
#define SERVER_CER "/data/sdcard/serverCert.cer" // Use an absolute path.
#define LOG_PRINT(fmt, ...) printf("[ServerProcess][%s:%d] " fmt "\n", __func__, __LINE__, ##__VA_ARGS__)
#define DO_CHECK(cond, log, ...) \
if (!(cond)) {\
LOG_PRINT(log);\
__VA_ARGS__;\
return -1;\
}
// Implement the function by referring to the APIs in the server_process.h file. Pay attention to the format of the response message from the server.
respondContent = "{"
"\"searchStatus\": 0,"
"\"errMsg\": \"success\","
"\"checkResults\": [{"
"\"versionName\": \"sampleVersionName\","
"\"versionCode\": \"sampleVersionCode\","
"\"verifyInfo\": \"sampleVerifyInfoSha256Value\","
"\"size\": 1234567,"
"\"packageType\": 1,"
"\"descriptPackageId\": \"abcdefg1234567ABCDEFG\","
"}],"
"\"descriptInfo\": [{"
"\"descriptPackageId\": \"abcdefg1234567ABCDEFG\","
"\"content\": \"This package message is used for sampleContent\""
"}]"
"}";
```
7. Start building.
The **testserver** and **libserver_process.z.so** files are added to the build output directory.
8. Develop an update package.
For details, see the [update_packaging_tools repository](https://gitee.com/openharmony/update_packaging_tools).
9. Start the package search server.
Create a directory that contains only English characters on the development board. Place the **testserver**, **libserver_process.z.so**, **serverCert.cer**, and **serverKey.pem** files in the directory, go to the directory, and run the following command to start the package search server:
```
./testserver ./libserver_process.z.so &
```
# Sample Server Overview
The sample server provides a simple server instance for deploying update packages. It can be used as an auxiliary test environment for the UpdateService subsystem.
## Basic Concepts
- Package search service: one of the service capabilities provided by the UpdateService. It depends on the server that supports the TCP and SSL protocols.
- Package search server: a server that provisions the package search service through the TCP connection and the SSL protocol. The sample server mentioned in this document is such a package search server.
- Download server: an HTTP server.
- update.serverip.search: a system parameter that indicates the IP address of the package search server configured on the UpdateService. The default value is **127.0.0.1**.
## Constraints
The following is an example of the JSON response returned by the server. Note that the **verifyInfo** field indicates the SHA-256 value of the update package, and the **size** field indicates the size of the update package, in bytes.
```json
{
"searchStatus": 0,
"errMsg": "success",
"checkResults": [{
"versionName": "versionNameSample",
"versionCode": "versionCodeSample",
"verifyInfo": "verifyInfoSHA256Value1234567",
"size": 1234567,
"packageType": 1,
"url": "http://serverAddressSample/packageNameSample.fileTypeSample",
"descriptPackageId": "abcdefg1234567ABCDEFG"
}],
"descriptInfo": [{
"descriptPackageId": "abcdefg1234567ABCDEFG",
"content": "This package is used for update."
}]
}
```
...@@ -133,7 +133,7 @@ var subscriber = { ...@@ -133,7 +133,7 @@ var subscriber = {
##### Enabling Notification ##### Enabling Notification
Before publishing a notification, check whether the notification feature is enabled for your application. By default, the feature is disabled. The application can use **Notification.requestEnableNotification** to prompt the user to enable the feature. Before publishing a notification, check whether the notification feature is enabled for your application. By default, the feature is disabled. The application calls **Notification.requestEnableNotification** to prompt the user to enable the feature.
```js ```js
Notification.requestEnableNotification() .then((data) => { Notification.requestEnableNotification() .then((data) => {
......
...@@ -6,10 +6,9 @@ ...@@ -6,10 +6,9 @@
- [Getting Started with eTS in the Low-Code Approach](start-with-ets-low-code.md) - [Getting Started with eTS in the Low-Code Approach](start-with-ets-low-code.md)
- [Getting Started with JavaScript in the Traditional Coding Approach](start-with-js.md) - [Getting Started with JavaScript in the Traditional Coding Approach](start-with-js.md)
- [Getting Started with JavaScript in the Low-Code Approach](start-with-js-low-code.md) - [Getting Started with JavaScript in the Low-Code Approach](start-with-js-low-code.md)
- Development Fundamentals - Development Fundamentals
- [Application Package Structure Configuration File (FA Model)](package-structure.md) - [Application Package Structure Configuration File (FA Model)](package-structure.md)
- [Application Package Structure Configuration File (Stage Model)](module-structure.md) - [Application Package Structure Configuration File (Stage Model)](stage-structure.md)
- [Resource File Categories](basic-resource-file-categories.md) - [Resource File Categories](basic-resource-file-categories.md)
- [SysCap](syscap.md) - [SysCap](syscap.md)
...@@ -175,12 +175,12 @@ Table 2 Internal structure of the app tag ...@@ -175,12 +175,12 @@ Table 2 Internal structure of the app tag
| vendor | Application vendor. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) | | vendor | Application vendor. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) |
| versionCode | Version number of the application. The value is a 32-bit non-negative integer and less than 2 to the power of 31. It is used only to determine whether a version is later than another version. A larger value indicates a later version. Ensure that a new version of the application uses a value greater than any of its predecessors. | Number | No | | versionCode | Version number of the application. The value is a 32-bit non-negative integer and less than 2 to the power of 31. It is used only to determine whether a version is later than another version. A larger value indicates a later version. Ensure that a new version of the application uses a value greater than any of its predecessors. | Number | No |
| versionName | Text description of the version number, which is displayed to users.<br>The value consists of only digits and dots. The four-segment format *A.B.C.D* is recommended, wherein:<br>Segment 1: major version number, which ranges from 0 to 99. A major version consists of major new features or large changes.<br>Segment 2: minor version number, which ranges from 0 to 99. A minor version consists of some new features and large bug fixes.<br>Segment 3: feature version number, which ranges from 0 to 99. A feature version consists of scheduled new features.<br>Segment 4: maintenance release number or patch number, which ranges from 0 to 999. A maintenance release or patch consists of resolution to security flaws or minor bugs.| String | No | | versionName | Text description of the version number, which is displayed to users.<br>The value consists of only digits and dots. The four-segment format *A.B.C.D* is recommended, wherein:<br>Segment 1: major version number, which ranges from 0 to 99. A major version consists of major new features or large changes.<br>Segment 2: minor version number, which ranges from 0 to 99. A minor version consists of some new features and large bug fixes.<br>Segment 3: feature version number, which ranges from 0 to 99. A feature version consists of scheduled new features.<br>Segment 4: maintenance release number or patch number, which ranges from 0 to 999. A maintenance release or patch consists of resolution to security flaws or minor bugs.| String | No |
| minCompatibleVersionCode | Minimum API version required for running the application. | Number | Yes (initial value: value of **versionCode**)| | minCompatibleVersionCode | Minimum API version compatible with the application. | Number | Yes (initial value: value of **versionCode**)|
| minAPIVersion | Target API version required for running the application. | Number | No | | minAPIVersion | Minimum API version required for running the application. | Number | No |
| targetAPIVersion | Target API version required for running the application. | Integer | No | | targetAPIVersion | Target API version required for running the application. | Integer | No |
| apiReleaseType | Type of the target API version required for running the application. The value can be **CanaryN**, **BetaN**, or **Release**, where **N** represents a positive integer.<br>**Canary**: indicates a restricted release.<br>**Beta**: indicates a publicly released beta version.<br>**Release**: indicates a publicly released official version.| String | Yes (initial value: **"Release"**) | | apiReleaseType | Type of the target API version required for running the application. The value can be **CanaryN**, **BetaN**, or **Release**, where **N** represents a positive integer.<br>**Canary**: indicates a restricted release.<br>**Beta**: indicates a publicly released beta version.<br>**Release**: indicates a publicly released official version.| String | Yes (initial value: **"Release"**) |
| distributedNotificationEnabled | Whether the distributed notification feature is enabled for the application. | Boolean | Yes (initial value: **true**) | | distributedNotificationEnabled | Whether the distributed notification feature is enabled for the application. | Boolean | Yes (initial value: **true**) |
| entityType | Category of the application, which can be **game**, **media**, **communication**, **news**, **travel**, **utility**, **shopping**, **education**, **kids**, **business**, and **photography**.| String | Yes (initial value: unspecified) | | entityType | Type of the application, which can be **game**, **media**, **communication**, **news**, **travel**, **utility**, **shopping**, **education**, **kids**, **business**, and **photography**.| String | Yes (initial value: unspecified) |
### Internal Structure of the module Tag ### Internal Structure of the module Tag
...@@ -212,9 +212,9 @@ Table 4 System-defined deviceTypes values ...@@ -212,9 +212,9 @@ Table 4 System-defined deviceTypes values
| Device Type | Value | Description | | Device Type | Value | Description |
| ------------ | ------------ | -------------------------------------------------------- | | ------------ | ------------ | -------------------------------------------------------- |
| tablet | tablet | Tablet, speaker with a screen | | tablet | tablet | Tablet, speaker with a screen |
| smart TV | tv | | | smart TV | tv | N/A |
| smart watch | wearable | Smart watch, kids' watch, especially a watch that provides call features| | smart watch | wearable | Smart watch, kids' watch, especially a watch that provides call features|
| head unit | car | | | head unit | car | N/A |
| router | router | Router | | router | router | Router |
Example of the **deviceTypes** attribute structure: Example of the **deviceTypes** attribute structure:
...@@ -309,7 +309,7 @@ Table 6 Internal structure of the abilities attribute ...@@ -309,7 +309,7 @@ Table 6 Internal structure of the abilities attribute
| icon | Icon of the ability. The value is the index to the resource file. This attribute can be left empty, and the default value is an empty array.<br>If **ability** is set to **MainElement**, this attribute is mandatory.| String | Yes (initial value: left empty)<br>If **ability** is set to **MainElement**, this attribute is mandatory.| | icon | Icon of the ability. The value is the index to the resource file. This attribute can be left empty, and the default value is an empty array.<br>If **ability** is set to **MainElement**, this attribute is mandatory.| String | Yes (initial value: left empty)<br>If **ability** is set to **MainElement**, this attribute is mandatory.|
| permissions | A set of permissions that need to be applied for when the capability of another application is invoked. The value is a string array. Each array element is a permission name, which is usually represented by a reverse domain name (a maximum of 255 bytes). The permission can be predefined by the system or customized by the application. For the latter, the value must be the same as the **name** value of a permission defined in the **defPermissions** attribute. | String array| Yes (initial value: left empty) | | permissions | A set of permissions that need to be applied for when the capability of another application is invoked. The value is a string array. Each array element is a permission name, which is usually represented by a reverse domain name (a maximum of 255 bytes). The permission can be predefined by the system or customized by the application. For the latter, the value must be the same as the **name** value of a permission defined in the **defPermissions** attribute. | String array| Yes (initial value: left empty) |
| metadata | Metadata about the ability. For details about metadata, see [Internal Structure of the metadata Attribute](#internal-structure-of-the-metadata-attribute).| Array | Yes (initial value: left empty) | | metadata | Metadata about the ability. For details about metadata, see [Internal Structure of the metadata Attribute](#internal-structure-of-the-metadata-attribute).| Array | Yes (initial value: left empty) |
| visible | Indicates whether the ability can be invoked by other applications. The value **true** means that the ability can be invoked by other applications, and **false** means the opposite.| Boolean | Yes (initial value: **false**) | | visible | Whether the ability can be invoked by other applications. The value **true** means that the ability can be invoked by other applications, and **false** means the opposite.| Boolean | Yes (initial value: **false**) |
| continuable | Whether the ability can be migrated. The value **true** means that the ability can be migrated, and **false** means the opposite.| Boolean | Yes (initial value: **false**) | | continuable | Whether the ability can be migrated. The value **true** means that the ability can be migrated, and **false** means the opposite.| Boolean | Yes (initial value: **false**) |
| skills | Feature set of wants that can be received by the ability.<br>Configuration rule: In an entry package, you can configure multiple abilities with the **skills** attribute (where **action.system.home** and **entity.system.home** are configured) that has the entry capability. The **label** and **icon** in the first ability that has **skills** configured are used as the **label** and **icon** of the entire service/application.<br>The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application,<br>but not for an OpenHarmony service.<br>For details about the internal structure of **skills**, see [Internal Structure of the skills Attribute](#internal-structure-of-the-skills-attribute).| Array | Yes (initial value: left empty) | | skills | Feature set of wants that can be received by the ability.<br>Configuration rule: In an entry package, you can configure multiple abilities with the **skills** attribute (where **action.system.home** and **entity.system.home** are configured) that has the entry capability. The **label** and **icon** in the first ability that has **skills** configured are used as the **label** and **icon** of the entire service/application.<br>The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application,<br>but not for an OpenHarmony service.<br>For details about the internal structure of **skills**, see [Internal Structure of the skills Attribute](#internal-structure-of-the-skills-attribute).| Array | Yes (initial value: left empty) |
| backgroundModes | Continuous task modes of the ability.<br>Continuous tasks are classified into the following types:<br>**dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices<br>**audioPlayback**: audio playback service<br>**audioRecording**: audio recording service<br>**location**: location and navigation services<br>**bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables)<br>**multiDeviceConnection**: multi-device interconnection service<br>**wifiInteraction**: Wi-Fi scanning, connection, and transmission services (multi-screen cloning)<br>**voip**: voice/video call and VoIP services<br>**taskKeeping**: computing service<br>| String | Yes (initial value: left empty) | | backgroundModes | Continuous task modes of the ability.<br>Continuous tasks are classified into the following types:<br>**dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices<br>**audioPlayback**: audio playback service<br>**audioRecording**: audio recording service<br>**location**: location and navigation services<br>**bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables)<br>**multiDeviceConnection**: multi-device interconnection service<br>**wifiInteraction**: Wi-Fi scanning, connection, and transmission services (multi-screen cloning)<br>**voip**: voice/video call and VoIP services<br>**taskKeeping**: computing service<br>| String | Yes (initial value: left empty) |
...@@ -361,7 +361,7 @@ Table 7 Internal structure of the skills attribute ...@@ -361,7 +361,7 @@ Table 7 Internal structure of the skills attribute
| -------- | ------------------------------------------------------------ | ---------- | -------------------- | | -------- | ------------------------------------------------------------ | ---------- | -------------------- |
| actions | A set of want action values that can be received. The value can be a value predefined by the system or a custom value.| String array| Yes (initial value: left empty)| | actions | A set of want action values that can be received. The value can be a value predefined by the system or a custom value.| String array| Yes (initial value: left empty)|
| entities | Categories of abilities that can receive the want. The value can be a value predefined by the system or a custom value.| String array| Yes (initial value: left empty)| | entities | Categories of abilities that can receive the want. The value can be a value predefined by the system or a custom value.| String array| Yes (initial value: left empty)|
| uris | Data specifications to be added to the want filter. The specification can be of data type only (**mimeType** attribute), URI only, or both. For details about the internal structure of **uris**, see Table 8.| Object array | Yes (initial value: left empty)| | uris | Data specification to be added to the want filter. The specification can be of data type only (**mimeType** attribute), URI only, or both. For details about the internal structure of **uris**, see Table 8.| Object array | Yes (initial value: left empty)|
Table 8 Internal structure of the uris attribute Table 8 Internal structure of the uris attribute
...@@ -612,7 +612,7 @@ Table 13 Internal structure of the shortcuts attribute ...@@ -612,7 +612,7 @@ Table 13 Internal structure of the shortcuts attribute
| Attribute | Description | Data Type| Initial Value Allowed | | Attribute | Description | Data Type| Initial Value Allowed |
| ---------- | ------------------------------------------------------------ | -------- | -------------------------- | | ---------- | ------------------------------------------------------------ | -------- | -------------------------- |
| shortcutId | Shortcut ID. The value is a string with a maximum of 63 bytes. | String | No | | shortcutId | ID of the shortcut. The value is a string with a maximum of 63 bytes. | String | No |
| label | Label of the shortcut, that is, the text description displayed by the shortcut. The value can be a string or a resource index to the description. The value is a string with a maximum of 63 bytes.| String | Yes (initial value: left empty) | | label | Label of the shortcut, that is, the text description displayed by the shortcut. The value can be a string or a resource index to the description. The value is a string with a maximum of 63 bytes.| String | Yes (initial value: left empty) |
| icon | Icon of the shortcut. The value is the index to the resource file. | String | Yes (initial value: left empty)| | icon | Icon of the shortcut. The value is the index to the resource file. | String | Yes (initial value: left empty)|
| wants | Wants to which the shortcut points. The attribute consists of the **bundleName** and **abilityName** sub-attributes.<br>**bundleName**: target bundle name of the shortcut; string type.<br>**abilityName**: target component name of the shortcut; string type.| Object | Yes (initial value: left empty) | | wants | Wants to which the shortcut points. The attribute consists of the **bundleName** and **abilityName** sub-attributes.<br>**bundleName**: target bundle name of the shortcut; string type.<br>**abilityName**: target component name of the shortcut; string type.| Object | Yes (initial value: left empty) |
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
- [TypeScript-based Declarative Development Paradigm](arkui-ts/Readme-EN.md) - [TypeScript-based Declarative Development Paradigm](arkui-ts/Readme-EN.md)
- [APIs](apis/Readme-EN.md) - [APIs](apis/Readme-EN.md)
- [JS (eTS Included) APIs](reference/apis/Readme-EN.md) - [JS (eTS Included) APIs](apis/Readme-EN.md)
- Native APIs - Native APIs
- [Standard Library](reference/native-lib/third_party_libc/musl.md) - [Standard Library](native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md) - [Node_API](native-lib/third_party_napi/napi.md)
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
> **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.
> API version 9 is a canary version for trial use. The APIs of this version may be unstable.
## Modules to Import ## Modules to Import
``` ```
...@@ -463,7 +463,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { ...@@ -463,7 +463,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback<Array\<ApplicationInfo>>) : void; getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback<Array\<ApplicationInfo>>) : void;
Obtains the information about all applications of the specified user. This API uses an asynchronous callback to return the result. Obtains the information about all applications. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -649,7 +649,7 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => { ...@@ -649,7 +649,7 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => {
isAbilityEnabled(info: AbilityInfo): Promise\<boolean> isAbilityEnabled(info: AbilityInfo): Promise\<boolean>
Checks whether an ability is enabled based on a given want. This API uses a promise to return the result. Checks whether an ability is enabled based on a given **AbilityInfo** object. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -690,7 +690,7 @@ bundle.isAbilityEnabled(Info) ...@@ -690,7 +690,7 @@ bundle.isAbilityEnabled(Info)
isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\<boolean>): void isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\<boolean>): void
Checks whether an ability is enabled based on a given want. This API uses an asynchronous callback to return the result. Checks whether an ability is enabled based on a given **AbilityInfo** object. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -727,7 +727,7 @@ bundle.isAbilityEnabled(Info, (err, data) => { ...@@ -727,7 +727,7 @@ bundle.isAbilityEnabled(Info, (err, data) => {
isApplicationEnabled(bundleName: string): Promise\<boolean> isApplicationEnabled(bundleName: string): Promise\<boolean>
Checks whether an application is enabled based on a given want. This API uses a promise to return the result. Checks whether an application is enabled based on a given bundle name. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -857,7 +857,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -857,7 +857,7 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ---------------------------------- | ---- | ------------------------------------- | | ----------- | ---------------------------------- | ---- | ------------------------------------- |
| want | Want | Yes | Want that contains the bundle name. | | want | Want | Yes | Want that contains the bundle name. |
| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0. | | bundleFlags | number | Yes | Type of the ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
| callback | AsyncCallback<Array\<AbilityInfo>> | Yes | Callback used to return the ability information. | | callback | AsyncCallback<Array\<AbilityInfo>> | Yes | Callback used to return the ability information. |
...@@ -894,7 +894,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -894,7 +894,7 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ---------------------------------- | ---- | ------------------------------------- | | ----------- | ---------------------------------- | ---- | ------------------------------------- |
| want | Want | Yes | Want that contains the bundle name. | | want | Want | Yes | Want that contains the bundle name. |
| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0. | | bundleFlags | number | Yes | Type of the ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback | AsyncCallback<Array\<AbilityInfo>> | Yes | Callback used to return the ability information. | | callback | AsyncCallback<Array\<AbilityInfo>> | Yes | Callback used to return the ability information. |
**Example** **Example**
...@@ -1056,7 +1056,7 @@ bundle.getNameForUid(uid, (err, data) => { ...@@ -1056,7 +1056,7 @@ bundle.getNameForUid(uid, (err, data) => {
getAbilityIcon(bundleName: string, abilityName: string): Promise\<image.PixelMap>; getAbilityIcon(bundleName: string, abilityName: string): Promise\<image.PixelMap>;
Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the corresponding icon based on a given bundle name and ability name. This API uses a promise to return the result. Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the icon corresponding to a given bundle name and ability name. This API uses a promise to return the result.
**Required permissions** **Required permissions**
...@@ -1095,7 +1095,7 @@ bundle.getAbilityIcon(bundleName, abilityName) ...@@ -1095,7 +1095,7 @@ bundle.getAbilityIcon(bundleName, abilityName)
getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void; getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void;
Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the corresponding icon based on a given bundle name and ability name. This API uses an asynchronous callback to return the result. Obtains the [PixelMap](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-image.md) of the icon corresponding to a given bundle name and ability name. This API uses an asynchronous callback to return the result.
**Required permissions** **Required permissions**
...@@ -1274,13 +1274,13 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => { ...@@ -1274,13 +1274,13 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, (err, data) => {
| Name | Default Value | Description | | Name | Default Value | Description |
| ---------------------------------------- | ---- | ------------------------- | | ---------------------------------------- | ---- | ------------------------- |
| SUCCESS | 0 | Installation succeeded. | | SUCCESS | 0 | Installation succeeded. |
| STATUS_INSTALL_FAILURE | 1 | Installation failed. (The application to be installed does not exist.) | | STATUS_INSTALL_FAILURE | 1 | Installation failed. (The application to be installed is not found.) |
| STATUS_INSTALL_FAILURE_ABORTED | 2 | Installation aborted. | | STATUS_INSTALL_FAILURE_ABORTED | 2 | Installation aborted. |
| STATUS_INSTALL_FAILURE_INVALID | 3 | Invalid installation parameter. | | STATUS_INSTALL_FAILURE_INVALID | 3 | Invalid installation parameter. |
| STATUS_INSTALL_FAILURE_CONFLICT | 4 | Installation conflict. (The basic information about the application to upgrade is inconsistent with that of the existing application.) | | STATUS_INSTALL_FAILURE_CONFLICT | 4 | Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.) |
| STATUS_INSTALL_FAILURE_STORAGE | 5 | Failed to store the bundle information. | | STATUS_INSTALL_FAILURE_STORAGE | 5 | Failed to store the bundle information. |
| STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | Installation incompatible. (A downgrade occurs or the signature information is incorrect.) | | STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | Installation incompatibility. (A downgrade occurs or the signature information is incorrect.) |
| STATUS_UNINSTALL_FAILURE | 7 | Uninstallation failed. (The application to be uninstalled does not exist.) | | STATUS_UNINSTALL_FAILURE | 7 | Uninstallation failed. (The application to be uninstalled is not found.) |
| STATUS_UNINSTALL_FAILURE_BLOCKED | 8 | Uninstallation aborted. (This error code is not in use.) | | STATUS_UNINSTALL_FAILURE_BLOCKED | 8 | Uninstallation aborted. (This error code is not in use.) |
| STATUS_UNINSTALL_FAILURE_ABORTED | 9 | Uninstallation aborted. (Invalid parameters.) | | STATUS_UNINSTALL_FAILURE_ABORTED | 9 | Uninstallation aborted. (Invalid parameters.) |
| STATUS_UNINSTALL_FAILURE_CONFLICT | 10 | Uninstallation conflict. (Failed to uninstall a system application or end the application process.)| | STATUS_UNINSTALL_FAILURE_CONFLICT | 10 | Uninstallation conflict. (Failed to uninstall a system application or end the application process.)|
...@@ -1311,7 +1311,7 @@ Enumerates bundle flags. ...@@ -1311,7 +1311,7 @@ Enumerates bundle flags.
| GET_ABILITY_INFO_WITH_METADATA<sup>8+</sup> | 0x00000020 | Obtains the ability metadata information. | | GET_ABILITY_INFO_WITH_METADATA<sup>8+</sup> | 0x00000020 | Obtains the ability metadata information. |
| GET_BUNDLE_WITH_EXTENSION_ABILITY<sup>9+</sup> | 0x00000020 | Obtains the bundle information with the Extension ability information. | | GET_BUNDLE_WITH_EXTENSION_ABILITY<sup>9+</sup> | 0x00000020 | Obtains the bundle information with the Extension ability information. |
| GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | Obtains the application metadata information. | | GET_APPLICATION_INFO_WITH_METADATA<sup>8+</sup> | 0x00000040 | Obtains the application metadata information. |
| GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup> | 0x00000080 | Obtains the ability information with information about system applications. | | GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup> | 0x00000080 | Obtains the ability information of system applications.|
| GET_ABILITY_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000100 | Obtains information about disabled abilities. | | GET_ABILITY_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000100 | Obtains information about disabled abilities. |
| GET_APPLICATION_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000200 | Obtains information about disabled applications. | | GET_APPLICATION_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000200 | Obtains information about disabled applications. |
| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information. | | GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information. |
...@@ -1355,7 +1355,7 @@ Describes the application bundle information. ...@@ -1355,7 +1355,7 @@ Describes the application bundle information.
| cpuAbi | string | Yes | No | cpuAbi information of the bundle. | | cpuAbi | string | Yes | No | cpuAbi information of the bundle. |
| isSilentInstallation | string | Yes | No | Whether to install the bundle in silent mode. | | isSilentInstallation | string | Yes | No | Whether to install the bundle in silent mode. |
| minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. | | minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. |
| entryInstallationFree | boolean | Yes | No | Whether installation-free is supported for the entry. | | entryInstallationFree | boolean | Yes | No | Whether installation-free is supported for the entry module. |
| reqPermissionStates<sup>8+</sup> | Array\<number> | Yes | No | Permission grant state. | | reqPermissionStates<sup>8+</sup> | Array\<number> | Yes | No | Permission grant state. |
| extensionAbilityInfo<sup>9+</sup> | Array\<ExtensionAbilityInfo> | Yes | No | Extended information of the ability. | | extensionAbilityInfo<sup>9+</sup> | Array\<ExtensionAbilityInfo> | Yes | No | Extended information of the ability. |
...@@ -1376,7 +1376,7 @@ Describes the application information. ...@@ -1376,7 +1376,7 @@ Describes the application information.
| labelId | string | Yes | No | Application label ID. | | labelId | string | Yes | No | Application label ID. |
| icon | string | Yes | No | Application icon. | | icon | string | Yes | No | Application icon. |
| iconId | string | Yes | No | Application icon ID. | | iconId | string | Yes | No | Application icon ID. |
| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used by default. | | process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used.|
| supportedModes | number | Yes | No | Running modes supported by the application. | | supportedModes | number | Yes | No | Running modes supported by the application. |
| moduleSourceDirs | Array\<string> | Yes | No | Relative paths for storing application resources. | | moduleSourceDirs | Array\<string> | Yes | No | Relative paths for storing application resources. |
| permissions | Array\<string> | Yes | No | Permissions required for accessing the application. | | permissions | Array\<string> | Yes | No | Permissions required for accessing the application. |
...@@ -1599,7 +1599,7 @@ Enumerates color modes. ...@@ -1599,7 +1599,7 @@ Enumerates color modes.
## GrantStatus ## GrantStatus
Enumerates permission grant statuses. Enumerates permission grant states.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
......
# AbilityDelegator # AbilityDelegator
> **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.
...@@ -423,7 +423,7 @@ Starts an ability. This API uses an asynchronous callback to return the result. ...@@ -423,7 +423,7 @@ Starts an ability. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------ | | -------- | -------------------------------------- | ---- | ------------------ |
| want | [Want](js-apis-featureAbility.md#Want) | Yes | **Want** parameter for starting the ability. | | want | [Want](js-apis-application-Want.md) | Yes | **Want** parameter for starting the ability. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -455,7 +455,7 @@ Starts an ability. This API uses a promise to return the result. ...@@ -455,7 +455,7 @@ Starts an ability. This API uses a promise to return the result.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | --------------- | | ------ | -------------------------------------- | ---- | --------------- |
| want | [Want](js-apis-featureAbility.md#Want) | Yes | **Want** parameter for starting the ability.| | want | [Want](js-apis-application-Want.md) | Yes | **Want** parameter for starting the ability.|
**Return value** **Return value**
......
# Relational Database # Relational Database
> ![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.
## Modules to Import ## Modules to Import
```js ```js
......
# Display # Display
> ![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.
## Modules to Import ## Modules to Import
...@@ -56,7 +56,7 @@ getDefaultDisplay(callback: AsyncCallback&lt;Display&gt;): void ...@@ -56,7 +56,7 @@ getDefaultDisplay(callback: AsyncCallback&lt;Display&gt;): void
Obtains the default display object. Obtains the default display object.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -82,7 +82,7 @@ getDefaultDisplay(): Promise&lt;Display&gt; ...@@ -82,7 +82,7 @@ getDefaultDisplay(): Promise&lt;Display&gt;
Obtains the default display object. Obtains the default display object.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value** **Return value**
...@@ -107,7 +107,7 @@ getAllDisplay(callback: AsyncCallback&lt;Array&lt;Display&gt;&gt;): void ...@@ -107,7 +107,7 @@ getAllDisplay(callback: AsyncCallback&lt;Array&lt;Display&gt;&gt;): void
Obtains all the display objects. Obtains all the display objects.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
...@@ -133,7 +133,7 @@ getAllDisplay(): Promise&lt;Array&lt;Display&gt;&gt; ...@@ -133,7 +133,7 @@ getAllDisplay(): Promise&lt;Array&lt;Display&gt;&gt;
Obtains all the display objects. Obtains all the display objects.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value** **Return value**
...@@ -158,7 +158,7 @@ on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void ...@@ -158,7 +158,7 @@ on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void
Enables listening. Enables listening.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -182,7 +182,7 @@ off(type: 'add'|'remove'|'change', callback?: Callback&lt;number&gt;): void ...@@ -182,7 +182,7 @@ off(type: 'add'|'remove'|'change', callback?: Callback&lt;number&gt;): void
Disables listening. Disables listening.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
......
# FormExtension # FormExtension
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
Provides **FormExtension** APIs. Provides **FormExtension** APIs.
...@@ -35,7 +35,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been ...@@ -35,7 +35,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | | ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-featureAbility.md#want) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| | want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
**Return value** **Return value**
......
# HiDebug # HiDebug
> ![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.
You can run the hidebug command to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data. You can run the hidebug command to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data.
...@@ -18,6 +18,8 @@ getNativeHeapSize(): bigint ...@@ -18,6 +18,8 @@ getNativeHeapSize(): bigint
Obtains the total size of the native heap memory. Obtains the total size of the native heap memory.
This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value** **Return value**
...@@ -39,6 +41,8 @@ getNativeHeapAllocatedSize(): bigint ...@@ -39,6 +41,8 @@ getNativeHeapAllocatedSize(): bigint
Obtains the size of the allocated native heap memory. Obtains the size of the allocated native heap memory.
This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
...@@ -60,6 +64,8 @@ getNativeHeapFreeSize(): bigint ...@@ -60,6 +64,8 @@ getNativeHeapFreeSize(): bigint
Obtains the size of the free native heap memory. Obtains the size of the free native heap memory.
This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
......
...@@ -155,6 +155,7 @@ Sets a trace ID. This API works in synchronous manner. ...@@ -155,6 +155,7 @@ Sets a trace ID. This API works in synchronous manner.
**Example** **Example**
```js ```js
let asyncTraceId;
let traceId = hiTraceChain.begin("business"); let traceId = hiTraceChain.begin("business");
// Set the current trace ID after the service logic is executed for several times. // Set the current trace ID after the service logic is executed for several times.
hiTraceChain.setId(asyncTraceId); hiTraceChain.setId(asyncTraceId);
...@@ -297,7 +298,7 @@ Enables the specified trace flag in the **HiTraceId** instance. This API works i ...@@ -297,7 +298,7 @@ Enables the specified trace flag in the **HiTraceId** instance. This API works i
```js ```js
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
hiTraceChain.enable(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); hiTraceChain.enableFlag(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
// The value of enabledDoNotCreateSpanFlag is true. // The value of enabledDoNotCreateSpanFlag is true.
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
``` ```
\ No newline at end of file
...@@ -34,7 +34,6 @@ If the trace tasks with the same name are not performed at the same time, the sa ...@@ -34,7 +34,6 @@ If the trace tasks with the same name are not performed at the same time, the sa
```js ```js
hiTraceMeter.startTrace("myTestFunc", 1); hiTraceMeter.startTrace("myTestFunc", 1);
hiTraceMeter.startTrace("myTestFunc", 1, 5); // The expected duration of the trace task is 5 ms.
``` ```
......
# Media Library Management # Media Library Management
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -208,7 +208,7 @@ async function example() { ...@@ -208,7 +208,7 @@ async function example() {
let mediaType = mediaLibrary.MediaType.IMAGE; let mediaType = mediaLibrary.MediaType.IMAGE;
let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
const path = await media.getPublicDirectory(DIR_IMAGE); const path = await media.getPublicDirectory(DIR_IMAGE);
mediaLibrary.createAsset(mediaType, 'imageCallBack.jpg', path + 'myPicture/', (err, fileAsset) => { media.createAsset(mediaType, 'imageCallBack.jpg', path + 'myPicture/', (err, fileAsset) => {
if (fileAsset != undefined) { if (fileAsset != undefined) {
console.info('createAsset successfully, message = ' + err); console.info('createAsset successfully, message = ' + err);
} else { } else {
...@@ -250,7 +250,7 @@ async function example() { ...@@ -250,7 +250,7 @@ async function example() {
let mediaType = mediaLibrary.MediaType.IMAGE; let mediaType = mediaLibrary.MediaType.IMAGE;
let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
const path = await media.getPublicDirectory(DIR_IMAGE); const path = await media.getPublicDirectory(DIR_IMAGE);
mediaLibrary.createAsset(mediaType, "image01.jpg", path + 'myPicture/').then (function (asset) { media.createAsset(mediaType, "image01.jpg", path + 'myPicture/').then (function (asset) {
console.info("createAsset successfully:"+ JSON.stringify(asset)); console.info("createAsset successfully:"+ JSON.stringify(asset));
}).catch(function(err){ }).catch(function(err){
console.info("createAsset failed with error:"+ err); console.info("createAsset failed with error:"+ err);
...@@ -720,29 +720,29 @@ Provides APIs for encapsulating file asset attributes. ...@@ -720,29 +720,29 @@ Provides APIs for encapsulating file asset attributes.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable | Writable | Description | | Name | Type | Readable| Writable| Description |
| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ | | ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
| id | number | Yes | No | File asset ID. | | id | number | Yes | No | File asset ID. |
| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. | | uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. |
| mimeType | string | Yes | No | Extended file attributes. | | mimeType | string | Yes | No | Extended file attributes. |
| mediaType<sup>8+</sup> | [MediaType](#mediatype8) | Yes | No | Media type. | | mediaType<sup>8+</sup> | [MediaType](#mediatype8) | Yes | No | Media type. |
| displayName | string | Yes | Yes | Display file name, including the file name extension. | | displayName | string | Yes | Yes | Display file name, including the file name extension. |
| title | string | Yes | Yes | Title in the file. | | title | string | Yes | Yes | Title in the file. |
| relativePath<sup>8+</sup> | string | Yes | Yes | Relative public directory of the file. | | relativePath<sup>8+</sup> | string | Yes | Yes | Relative public directory of the file. |
| parent<sup>8+</sup> | number | Yes | No | Parent directory ID. | | parent<sup>8+</sup> | number | Yes | No | Parent directory ID. |
| size | number | Yes | No | File size, in bytes. | | size | number | Yes | No | File size, in bytes. |
| dateAdded | number | Yes | No | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.) | | dateAdded | number | Yes | No | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.) |
| dateModified | number | Yes | No | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.) | | dateModified | number | Yes | No | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.) |
| dateTaken | number | Yes | No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) | | dateTaken | number | Yes | No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) |
| artist<sup>8+</sup> | string | Yes | No | Artist of the file. | | artist<sup>8+</sup> | string | Yes | No | Artist of the file. |
| audioAlbum<sup>8+</sup> | string | Yes | No | Audio album. | | audioAlbum<sup>8+</sup> | string | Yes | No | Audio album. |
| width | number | Yes | No | Image width, in pixels. | | width | number | Yes | No | Image width, in pixels. |
| height | number | Yes | No | Image height, in pixels. | | height | number | Yes | No | Image height, in pixels. |
| orientation | number | Yes | Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees). | | orientation | number | Yes | Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees).|
| duration<sup>8+</sup> | number | Yes | No | Duration, in seconds. | | duration<sup>8+</sup> | number | Yes | No | Duration, in seconds. |
| albumId | number | Yes | No | ID of the album to which the file belongs. | | albumId | number | Yes | No | ID of the album to which the file belongs. |
| albumUri<sup>8+</sup> | string | Yes | No | URI of the album to which the file belongs. | | albumUri<sup>8+</sup> | string | Yes | No | URI of the album to which the file belongs. |
| albumName | string | Yes | No | Name of the album to which the file belongs. | | albumName | string | Yes | No | Name of the album to which the file belongs. |
### isDirectory<sup>8+</sup> ### isDirectory<sup>8+</sup>
...@@ -757,9 +757,9 @@ Checks whether this file asset is a directory. This API uses an asynchronous cal ...@@ -757,9 +757,9 @@ Checks whether this file asset is a directory. This API uses an asynchronous cal
**Parameters** **Parameters**
| Parameter | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------- | ---- | ------------------- | | -------- | ---------------------------- | ---- | ------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return whether the file asset is a directory. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return whether the file asset is a directory.|
**Example** **Example**
......
# missionManager # missionManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
Provides mission management. You can use the APIs to lock, unlock, and clear missions, and switch a mission to the foreground. missionManager provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
## Modules to Import ## Modules to Import
...@@ -34,7 +34,7 @@ Registers a listener to observe the mission status. ...@@ -34,7 +34,7 @@ Registers a listener to observe the mission status.
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns the index of the listener, which is created by the system and allocated when the mission status listener is registered. Each listener has a unique index.| | number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.|
**Example** **Example**
...@@ -55,7 +55,7 @@ Registers a listener to observe the mission status. ...@@ -55,7 +55,7 @@ Registers a listener to observe the mission status.
unregisterMissionListener(listenerId: number, callback: AsyncCallback&lt;void&gt;): void; unregisterMissionListener(listenerId: number, callback: AsyncCallback&lt;void&gt;): void;
Unregisters a mission status listener. This API uses an asynchronous callback to return the result. Deregisters a mission status listener. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
...@@ -63,7 +63,7 @@ Unregisters a mission status listener. This API uses an asynchronous callback to ...@@ -63,7 +63,7 @@ Unregisters a mission status listener. This API uses an asynchronous callback to
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.| | listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -88,7 +88,7 @@ Unregisters a mission status listener. This API uses an asynchronous callback to ...@@ -88,7 +88,7 @@ Unregisters a mission status listener. This API uses an asynchronous callback to
unregisterMissionListener(listenerId: number): Promise&lt;void&gt;; unregisterMissionListener(listenerId: number): Promise&lt;void&gt;;
Unregisters a mission status listener. This API uses a promise to return the result. Deregisters a mission status listener. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
...@@ -96,7 +96,7 @@ Unregisters a mission status listener. This API uses a promise to return the res ...@@ -96,7 +96,7 @@ Unregisters a mission status listener. This API uses a promise to return the res
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.| | listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
**Return value** **Return value**
...@@ -126,7 +126,7 @@ Unregisters a mission status listener. This API uses a promise to return the res ...@@ -126,7 +126,7 @@ Unregisters a mission status listener. This API uses a promise to return the res
getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;MissionInfo&gt;): void; getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;MissionInfo&gt;): void;
Obtains the information of a given mission. This API uses an asynchronous callback to return the result. Obtains the information about a given mission. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
...@@ -159,7 +159,7 @@ Obtains the information of a given mission. This API uses an asynchronous callba ...@@ -159,7 +159,7 @@ Obtains the information of a given mission. This API uses an asynchronous callba
getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;; getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;;
Obtains the information of a given mission. This API uses a promise to return the result. Obtains the information about a given mission. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
...@@ -191,7 +191,7 @@ Obtains the information of a given mission. This API uses a promise to return th ...@@ -191,7 +191,7 @@ Obtains the information of a given mission. This API uses a promise to return th
getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Array&lt;MissionInfo&gt;&gt;): void; getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Array&lt;MissionInfo&gt;&gt;): void;
Obtains information of all missions. This API uses an asynchronous callback to return the result. Obtains information about all missions. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
...@@ -220,7 +220,7 @@ Obtains information of all missions. This API uses an asynchronous callback to r ...@@ -220,7 +220,7 @@ Obtains information of all missions. This API uses an asynchronous callback to r
getMissionInfos(deviceId: string, numMax: number): Promise&lt;Array&lt;MissionInfo&gt;&gt;; getMissionInfos(deviceId: string, numMax: number): Promise&lt;Array&lt;MissionInfo&gt;&gt;;
Obtains information of all missions. This API uses a promise to return the result. Obtains information about all missions. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
...@@ -617,7 +617,7 @@ Switches a given mission to the foreground. This API uses an asynchronous callba ...@@ -617,7 +617,7 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void; moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void;
Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses an asynchronous callback to return the result. Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
...@@ -651,7 +651,7 @@ Switches a given mission to the foreground, with the startup parameters for the ...@@ -651,7 +651,7 @@ Switches a given mission to the foreground, with the startup parameters for the
moveMissionToFront(missionId: number, options?: StartOptions): Promise&lt;void&gt;; moveMissionToFront(missionId: number, options?: StartOptions): Promise&lt;void&gt;;
Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses a promise to return the result. Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
...@@ -697,7 +697,7 @@ Describes the mission information. ...@@ -697,7 +697,7 @@ Describes the mission information.
| runningState | number | Yes| Yes| Running state of the mission.| | runningState | number | Yes| Yes| Running state of the mission.|
| lockedState | boolean | Yes| Yes| Locked state of the mission.| | lockedState | boolean | Yes| Yes| Locked state of the mission.|
| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.| | timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
| want | [Want](js-apis-featureAbility.md#want) | Yes| Yes| **Want** information of the mission.| | want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.|
| label | string | Yes| Yes| Label of the mission.| | label | string | Yes| Yes| Label of the mission.|
| iconPath | string | Yes| Yes| Path of the mission icon.| | iconPath | string | Yes| Yes| Path of the mission icon.|
| continuable | boolean | Yes| Yes| Whether the mission is continuable.| | continuable | boolean | Yes| Yes| Whether the mission is continuable.|
# ParticleAbility Module # ParticleAbility Module
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
## Constraints ## Constraints
...@@ -260,16 +260,16 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -260,16 +260,16 @@ Requests a continuous task from the system. This API uses a promise to return th
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| id | number | Yes| Notification ID of a continuous task.| | id | number | Yes | Notification ID of a continuous task. |
| request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.| | request | NotificationRequest | Yes | Notification parameter, which is used to display information in the notification bar. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------- | | -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result. |
**Example** **Example**
...@@ -323,9 +323,9 @@ Requests to cancel a continuous task from the system. This API uses an asynchron ...@@ -323,9 +323,9 @@ Requests to cancel a continuous task from the system. This API uses an asynchron
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -354,9 +354,9 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -354,9 +354,9 @@ Requests a continuous task from the system. This API uses a promise to return th
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------- | | -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result. |
**Example** **Example**
...@@ -382,21 +382,21 @@ Connects this ability to a specific Service ability. This API uses a callback to ...@@ -382,21 +382,21 @@ Connects this ability to a specific Service ability. This API uses a callback to
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------- | -------------- | ---- | ---------------------------- | | ------- | -------------- | ---- | ---------------------------- |
| request | [Want](js-apis-featureAbility.md#want) | Yes | Service ability to connect.| | request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect. |
| options | ConnectOptions | Yes | Callback used to return the result. | | options | ConnectOptions | Yes | Callback used to return the result. |
ConnectOptions **ConnectOptions**
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory | Description | | Name | Readable/Writable | Type | Mandatory | Description |
| ------------ | ---- | -------- | ---- | ------------------------- | | ------------ | ---- | -------- | ---- | ------------------------- |
| onConnect | Read only | function | Yes | Callback invoked when the connection is successful. | | onConnect | Read only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. | | onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called.| | onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called. |
**Example** **Example**
...@@ -440,9 +440,9 @@ Disconnects this ability from the Service ability. This API uses a callback to r ...@@ -440,9 +440,9 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -486,9 +486,9 @@ Disconnects this ability from the Service ability. This API uses a promise to re ...@@ -486,9 +486,9 @@ Disconnects this ability from the Service ability. This API uses a promise to re
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------- | | -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result. |
**Example** **Example**
......
...@@ -279,7 +279,7 @@ A data record is an abstract definition of the content on the pasteboard. The pa ...@@ -279,7 +279,7 @@ A data record is an abstract definition of the content on the pasteboard. The pa
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| htmlText<sup>7+</sup> | string | Yes | No | HTML text. | | htmlText<sup>7+</sup> | string | Yes | No | HTML text. |
| want<sup>7+</sup> | [Want](js-apis-featureAbility.md#want) | Yes | No | Want text. | | want<sup>7+</sup> | [Want](js-apis-application-Want.md) | Yes | No | Want text. |
| mimeType<sup>7+</sup> | string | Yes | No | Data type. | | mimeType<sup>7+</sup> | string | Yes | No | Data type. |
| plainText<sup>7+</sup> | string | Yes | No | Plain text. | | plainText<sup>7+</sup> | string | Yes | No | Plain text. |
| uri<sup>7+</sup> | string | Yes | No | URI text. | | uri<sup>7+</sup> | string | Yes | No | URI text. |
...@@ -506,7 +506,7 @@ The pasteboard supports a maximum number of 128 data records. ...@@ -506,7 +506,7 @@ The pasteboard supports a maximum number of 128 data records.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#want) | Yes | Want object. | | want | [Want](js-apis-application-Want.md) | Yes | Want object. |
**Example** **Example**
......
# Page Routing # Page Routing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
> - Page routing APIs can be invoked only after page rendering is complete. Do not call the APIs in **onInit** and **onReady** when the page is still in the rendering phase. > - Page routing APIs can be invoked only after page rendering is complete. Do not call the APIs in **onInit** and **onReady** when the page is still in the rendering phase.
...@@ -24,13 +24,13 @@ Navigates to a specified page in the application. ...@@ -24,13 +24,13 @@ Navigates to a specified page in the application.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [RouterOptions](#routeroptions) | Yes| Page routing parameters.| | options | [RouterOptions](#routeroptions) | Yes| Page routing parameters.|
**Example** **Example**
``` ```js
// Current page // Current page
export default { export default {
pushPage() { pushPage() {
...@@ -46,7 +46,7 @@ Navigates to a specified page in the application. ...@@ -46,7 +46,7 @@ Navigates to a specified page in the application.
} }
} }
``` ```
``` ```js
// routerpage2 page // routerpage2 page
export default { export default {
data: { data: {
...@@ -72,12 +72,13 @@ Replaces the current page with another one in the application and destroys the c ...@@ -72,12 +72,13 @@ Replaces the current page with another one in the application and destroys the c
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [RouterOptions](#routeroptions) | Yes| Description of the new page.| | options | [RouterOptions](#routeroptions) | Yes| Description of the new page.|
**Example** **Example**
```
```js
// Current page // Current page
export default { export default {
replacePage() { replacePage() {
...@@ -91,7 +92,7 @@ Replaces the current page with another one in the application and destroys the c ...@@ -91,7 +92,7 @@ Replaces the current page with another one in the application and destroys the c
} }
``` ```
``` ```js
// detail page // detail page
export default { export default {
data: { data: {
...@@ -112,12 +113,12 @@ Returns to the previous page or a specified page. ...@@ -112,12 +113,12 @@ Returns to the previous page or a specified page.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [RouterOptions](#routeroptions) | Yes| Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.| | options | [RouterOptions](#routeroptions) | Yes| Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.|
**Example** **Example**
``` ```js
// index page // index page
export default { export default {
indexPushPage() { indexPushPage() {
...@@ -128,7 +129,7 @@ Returns to the previous page or a specified page. ...@@ -128,7 +129,7 @@ Returns to the previous page or a specified page.
} }
``` ```
``` ```js
// detail page // detail page
export default { export default {
detailPushPage() { detailPushPage() {
...@@ -139,7 +140,7 @@ Returns to the previous page or a specified page. ...@@ -139,7 +140,7 @@ Returns to the previous page or a specified page.
} }
``` ```
``` ```js
// Navigate from the mall page to the detail page through router.back(). // Navigate from the mall page to the detail page through router.back().
export default { export default {
mallBackPage() { mallBackPage() {
...@@ -148,7 +149,7 @@ Returns to the previous page or a specified page. ...@@ -148,7 +149,7 @@ Returns to the previous page or a specified page.
} }
``` ```
``` ```js
// Navigate from the detail page to the index page through router.back(). // Navigate from the detail page to the index page through router.back().
export default { export default {
defaultBack() { defaultBack() {
...@@ -157,7 +158,7 @@ Returns to the previous page or a specified page. ...@@ -157,7 +158,7 @@ Returns to the previous page or a specified page.
} }
``` ```
``` ```js
// Return to the detail page through router.back(). // Return to the detail page through router.back().
export default { export default {
backToDetail() { backToDetail() {
...@@ -175,12 +176,12 @@ Clears all historical pages in the stack and retains only the current page at th ...@@ -175,12 +176,12 @@ Clears all historical pages in the stack and retains only the current page at th
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example** **Example**
``` ```js
export default { export default {
clearPage() { clearPage() {
router.clear(); router.clear();
} }
} }js
``` ```
## router.getLength ## router.getLength
...@@ -190,12 +191,12 @@ getLength(): string ...@@ -190,12 +191,12 @@ getLength(): string
Obtains the number of pages in the current stack. Obtains the number of pages in the current stack.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Number of pages in the stack. The maximum value is **32**.| | string | Number of pages in the stack. The maximum value is **32**.|
**Example** **Example**
``` ```js
export default { export default {
getLength() { getLength() {
var size = router.getLength(); var size = router.getLength();
...@@ -222,14 +223,14 @@ Describes the page routing state. ...@@ -222,14 +223,14 @@ Describes the page routing state.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| index | number | Index of the current page in the stack.<br>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**NOTE**<br>>&nbsp;The index starts from 1 from the bottom to the top of the stack.| | index | number | Index of the current page in the stack.<br>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**NOTE**<br>>&nbsp;The index starts from 1 from the bottom to the top of the stack.|
| name | string | Name of the current page, that is, the file name.| | name | string | Name of the current page, that is, the file name.|
| path | string | Path of the current page.| | path | string | Path of the current page.|
**Example** **Example**
``` ```js
export default { export default {
getState() { getState() {
var page = router.getState(); var page = router.getState();
...@@ -249,13 +250,13 @@ Enables the display of a confirm dialog box before returning to the previous pag ...@@ -249,13 +250,13 @@ Enables the display of a confirm dialog box before returning to the previous pag
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [EnableAlertOptions](#enablealertoptions) | Yes| Description of the dialog box.| | options | [EnableAlertOptions](#enablealertoptions) | Yes| Description of the dialog box.|
**Example** **Example**
``` ```js
export default { export default {
enableAlertBeforeBackPage() { enableAlertBeforeBackPage() {
router.enableAlertBeforeBackPage({ router.enableAlertBeforeBackPage({
...@@ -289,7 +290,7 @@ Disables the display of a confirm dialog box before returning to the previous pa ...@@ -289,7 +290,7 @@ Disables the display of a confirm dialog box before returning to the previous pa
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example** **Example**
``` ```js
export default { export default {
disableAlertBeforeBackPage() { disableAlertBeforeBackPage() {
router.disableAlertBeforeBackPage(); router.disableAlertBeforeBackPage();
...@@ -314,7 +315,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -314,7 +315,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu
**Example** **Example**
- Web-like example - Web-like example
``` ```js
// Current page // Current page
export default { export default {
pushPage() { pushPage() {
...@@ -327,7 +328,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -327,7 +328,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu
} }
} }
``` ```
``` ```js
// detail page // detail page
export default { export default {
onInit() { onInit() {
...@@ -338,7 +339,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -338,7 +339,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu
- Declarative example - Declarative example
``` ```ts
// Navigate to the target page through router.push with the params parameter carried. // Navigate to the target page through router.push with the params parameter carried.
import router from '@ohos.router' import router from '@ohos.router'
...@@ -384,7 +385,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -384,7 +385,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu
} }
``` ```
``` ```ts
// Receive the transferred parameters on the second page. // Receive the transferred parameters on the second page.
import router from '@ohos.router' import router from '@ohos.router'
...@@ -392,8 +393,8 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -392,8 +393,8 @@ Obtains the parameters passed from the page that initiates redirection to the cu
@Component @Component
struct Second { struct Second {
private content: string = "This is the second page." private content: string = "This is the second page."
@State text: string = router.getParams().text @State text: string = router.getParams()['text']
@State data: any = router.getParams().data @State data: any = router.getParams()['data']
@State secondData : string = '' @State secondData : string = ''
build() { build() {
......
# Screenshot # Screenshot
> ![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.
## Modules to Import ## Modules to Import
...@@ -54,7 +54,7 @@ save(options?: ScreenshotOptions, callback: AsyncCallback&lt;image.PixelMap&gt;) ...@@ -54,7 +54,7 @@ save(options?: ScreenshotOptions, callback: AsyncCallback&lt;image.PixelMap&gt;)
Takes a screenshot and saves it as a **PixelMap** object. This method uses a callback to return the result. Takes a screenshot and saves it as a **PixelMap** object. This method uses a callback to return the result.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Required permissions**: ohos.permission.CAPTURE_SCREEN **Required permissions**: ohos.permission.CAPTURE_SCREEN
...@@ -94,15 +94,15 @@ save(options?: ScreenshotOptions): Promise&lt;image.PixelMap&gt; ...@@ -94,15 +94,15 @@ save(options?: ScreenshotOptions): Promise&lt;image.PixelMap&gt;
Takes a screenshot and saves it as a **PixelMap** object. This method uses a promise to return the result. Takes a screenshot and saves it as a **PixelMap** object. This method uses a promise to return the result.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Required permissions**: ohos.permission.CAPTURE_SCREEN **Required permissions**: ohos.permission.CAPTURE_SCREEN
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.|
**Return value** **Return value**
......
...@@ -9,7 +9,7 @@ This module provides APIs for setting data items. ...@@ -9,7 +9,7 @@ This module provides APIs for setting data items.
## Modules to Import ## Modules to Import
``` ```typescript
import settings from '@ohos.settings'; import settings from '@ohos.settings';
``` ```
...@@ -34,7 +34,7 @@ Obtains the URI of a data item. ...@@ -34,7 +34,7 @@ Obtains the URI of a data item.
| string | URI of the data item.| | string | URI of the data item.|
- Example - Example
``` ```typescript
// Obtain the URI of a data item. // Obtain the URI of a data item.
let urivar = settings.getUriSync('settings.screen.brightness'); let urivar = settings.getUriSync('settings.screen.brightness');
``` ```
...@@ -61,7 +61,7 @@ Obtains the value of a data item. ...@@ -61,7 +61,7 @@ Obtains the value of a data item.
| string | Value of the data item.| | string | Value of the data item.|
- Example - Example
``` ```typescript
import featureAbility from '@ohos.featureAbility'; import featureAbility from '@ohos.featureAbility';
// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database). // Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
...@@ -96,7 +96,7 @@ If the specified data item exists in the database, the **setValueSync** method u ...@@ -96,7 +96,7 @@ If the specified data item exists in the database, the **setValueSync** method u
| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.| | boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
- Example - Example
``` ```typescript
import featureAbility from '@ohos.featureAbility'; import featureAbility from '@ohos.featureAbility';
// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync // Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync
......
# Application Context # Application Context
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use the new APIs. > - The APIs of this module are no longer maintained since API version 7. You are advised to use the new APIs.
> >
> - The initial APIs of this module are supported since API version 3. 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 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -138,7 +138,8 @@ Sets the maximum size (in bytes) of the image data cached in the memory before d ...@@ -138,7 +138,8 @@ Sets the maximum size (in bytes) of the image data cached in the memory before d
export default { export default {
onCreate() { onCreate() {
app.setImageRawDataCacheSize(100) // Set the upper limit of the memory for caching image data before decoding to 100 MB. app.setImageRawDataCacheSize(104857600)
// Set the upper limit of the memory for caching image data before decoding to 100 MB. (100 x 1024 x 1024 B =104857600 B = 100 MB).
console.info('Application onCreate') console.info('Application onCreate')
}, },
onDestroy() { onDestroy() {
...@@ -168,7 +169,8 @@ Sets the maximum size of the image file cache (in bytes) to speed up the loading ...@@ -168,7 +169,8 @@ Sets the maximum size of the image file cache (in bytes) to speed up the loading
export default { export default {
onCreate() { onCreate() {
app.setImageFileCacheSize(200) // Set the upper limit of the image file cache to 200 MB. app.setImageFileCacheSize(209715200)
// Set the upper limit of the image file cache to 200 MB. (200 x 1024 x 1024 B= 209715200 B = 200 MB).
console.info('Application onCreate') console.info('Application onCreate')
}, },
onDestroy() { onDestroy() {
......
# URI String Parsing # URI String Parsing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **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,15 +10,12 @@ ...@@ -10,15 +10,12 @@
import uri from '@ohos.uri' import uri from '@ohos.uri'
``` ```
## System Capabilities
SystemCapability.Utils.Lang
## URI ## URI
### Attributes ### Attributes
**System capability**: SystemCapability.Utils.Lang
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| scheme | string | Yes| No| Scheme in the URI.| | scheme | string | Yes| No| Scheme in the URI.|
...@@ -38,6 +35,8 @@ constructor(uri: string) ...@@ -38,6 +35,8 @@ constructor(uri: string)
A constructor used to create a URI instance. A constructor used to create a URI instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type.| Readable| Writable| Description| | Name| Type.| Readable| Writable| Description|
...@@ -59,6 +58,8 @@ new uri.URI('http://username:password@host:8080'); // Output 'http://username:pa ...@@ -59,6 +58,8 @@ new uri.URI('http://username:password@host:8080'); // Output 'http://username:pa
toString(): string toString(): string
**System capability**: SystemCapability.Utils.Lang
Obtains the query string applicable to this URL. Obtains the query string applicable to this URL.
**Return value** **Return value**
...@@ -81,6 +82,8 @@ equals(other: URI): boolean ...@@ -81,6 +82,8 @@ equals(other: URI): boolean
Checks whether this URI is the same as another URI object. Checks whether this URI is the same as another URI object.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type.| Mandatory| Description| | Name| Type.| Mandatory| Description|
...@@ -107,6 +110,8 @@ checkIsAbsolute(): boolean ...@@ -107,6 +110,8 @@ checkIsAbsolute(): boolean
Checks whether this URI is an absolute URI (whether the scheme component is defined). Checks whether this URI is an absolute URI (whether the scheme component is defined).
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type.| Description| | Type.| Description|
...@@ -127,6 +132,8 @@ normalize(): URI ...@@ -127,6 +132,8 @@ normalize(): URI
Normalizes the path of this URI. Normalizes the path of this URI.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type.| Description| | Type.| Description|
......
# URL String Parsing # URL String Parsing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
...@@ -10,10 +10,6 @@ ...@@ -10,10 +10,6 @@
import Url from '@ohos.url' import Url from '@ohos.url'
``` ```
## System Capabilities
SystemCapability.Utils.Lang
## URLSearchParams ## URLSearchParams
...@@ -23,11 +19,13 @@ constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearc ...@@ -23,11 +19,13 @@ constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearc
Creates a **URLSearchParams** instance. Creates a **URLSearchParams** instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| init | string[][]&nbsp;\|&nbsp;Record&lt;string,&nbsp;string&gt;&nbsp;\|&nbsp;string&nbsp;\|&nbsp;URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record&lt;string,&nbsp;string&gt;**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object| | init | string[][]&nbsp;\|&nbsp;Record&lt;string,&nbsp;string&gt;&nbsp;\|&nbsp;string&nbsp;\|&nbsp;URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>-&nbsp;**Record&lt;string,&nbsp;string&gt;**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object |
**Example** **Example**
...@@ -46,6 +44,8 @@ append(name: string, value: string): void ...@@ -46,6 +44,8 @@ append(name: string, value: string): void
Appends a key-value pair into the query string. Appends a key-value pair into the query string.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -68,6 +68,8 @@ delete(name: string): void ...@@ -68,6 +68,8 @@ delete(name: string): void
Deletes key-value pairs of the specified key. Deletes key-value pairs of the specified key.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -89,6 +91,8 @@ getAll(name: string): string[] ...@@ -89,6 +91,8 @@ getAll(name: string): string[]
Obtains all the key-value pairs based on the specified key. Obtains all the key-value pairs based on the specified key.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -117,6 +121,8 @@ entries(): IterableIterator<[string, string]> ...@@ -117,6 +121,8 @@ entries(): IterableIterator<[string, string]>
Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively. Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -139,6 +145,8 @@ forEach(callbackfn: (value: string, key: string, searchParams: this) => void, th ...@@ -139,6 +145,8 @@ forEach(callbackfn: (value: string, key: string, searchParams: this) => void, th
Traverses the key-value pairs in the **URLSearchParams** instance by using a callback. Traverses the key-value pairs in the **URLSearchParams** instance by using a callback.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -170,6 +178,8 @@ get(name: string): string | null ...@@ -170,6 +178,8 @@ get(name: string): string | null
Obtains the value of the first key-value pair based on the specified key. Obtains the value of the first key-value pair based on the specified key.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -199,6 +209,8 @@ has(name: string): boolean ...@@ -199,6 +209,8 @@ has(name: string): boolean
Checks whether a key has a value. Checks whether a key has a value.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -226,6 +238,8 @@ set(name: string, value: string): void ...@@ -226,6 +238,8 @@ set(name: string, value: string): void
Sets the value for a key. If key-value pairs matching the specified key exist, the value of the first key-value pair will be set to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair will be appended to the query string. Sets the value for a key. If key-value pairs matching the specified key exist, the value of the first key-value pair will be set to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair will be appended to the query string.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -246,8 +260,9 @@ paramsObject.set('baz', 3); // Add a third parameter. ...@@ -246,8 +260,9 @@ paramsObject.set('baz', 3); // Add a third parameter.
sort(): void sort(): void
Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained.
Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained. **System capability**: SystemCapability.Utils.Lang
**Example** **Example**
...@@ -262,9 +277,10 @@ console.log(searchParamsObject.toString()); // Display the sorted query string / ...@@ -262,9 +277,10 @@ console.log(searchParamsObject.toString()); // Display the sorted query string /
keys(): IterableIterator&lt;string&gt; keys(): IterableIterator&lt;string&gt;
Obtains an ES6 iterator that contains the keys of all the key-value pairs. Obtains an ES6 iterator that contains the keys of all the key-value pairs.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -287,6 +303,8 @@ values(): IterableIterator&lt;string&gt; ...@@ -287,6 +303,8 @@ values(): IterableIterator&lt;string&gt;
Obtains an ES6 iterator that contains the values of all the key-value pairs. Obtains an ES6 iterator that contains the values of all the key-value pairs.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -307,9 +325,10 @@ for (var value of searchParams.values()) { ...@@ -307,9 +325,10 @@ for (var value of searchParams.values()) {
[Symbol.iterator]\(): IterableIterator&lt;[string, string]&gt; [Symbol.iterator]\(): IterableIterator&lt;[string, string]&gt;
Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively. Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -330,9 +349,10 @@ for (const [name, value] of paramsObject) { ...@@ -330,9 +349,10 @@ for (const [name, value] of paramsObject) {
toString(): string toString(): string
Obtains search parameters that are serialized as a string and, if necessary, percent-encodes the characters in the string. Obtains search parameters that are serialized as a string and, if necessary, percent-encodes the characters in the string.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -351,9 +371,10 @@ console.log(params.toString()); ...@@ -351,9 +371,10 @@ console.log(params.toString());
## URL ## URL
### Attributes ### Attributes
**System capability**: SystemCapability.Utils.Lang
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| hash | string | Yes| Yes| String that contains a harsh mark (#) followed by the fragment identifier of a URL.| | hash | string | Yes| Yes| String that contains a harsh mark (#) followed by the fragment identifier of a URL.|
...@@ -374,9 +395,10 @@ console.log(params.toString()); ...@@ -374,9 +395,10 @@ console.log(params.toString());
constructor(url: string, base?: string | URL) constructor(url: string, base?: string | URL)
Creates a URL. Creates a URL.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -408,6 +430,8 @@ toString(): string ...@@ -408,6 +430,8 @@ toString(): string
Converts the parsed URL into a string. Converts the parsed URL into a string.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -426,9 +450,10 @@ url.toString() ...@@ -426,9 +450,10 @@ url.toString()
toJSON(): string toJSON(): string
Converts the parsed URL into a JSON string. Converts the parsed URL into a JSON string.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
......
# USB # USB
> ![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.
## Modules to Import ## Modules to Import
......
# webgl # webgl
> ![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.
...@@ -13,10 +13,10 @@ Create a **<canvas\>** component in the HML file. The following is an example: ...@@ -13,10 +13,10 @@ Create a **<canvas\>** component in the HML file. The following is an example:
``` ```
<div class="container">
<canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
<button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button> <button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
</div>
``` ```
Obtain the **<canvas\>** component instance in the JS file. The following is an example: Obtain the **<canvas\>** component instance in the JS file. The following is an example:
......
# webgl2 # webgl2
> ![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.
...@@ -13,10 +13,10 @@ Create a **<canvas\>** component in the HML file. The following is an example: ...@@ -13,10 +13,10 @@ Create a **<canvas\>** component in the HML file. The following is an example:
``` ```
<div class="container">
<canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
<button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button> <button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
</div>
``` ```
Obtain the **<canvas\>** component instance in the JS file. The following is an example: Obtain the **<canvas\>** component instance in the JS file. The following is an example:
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
The **Window** module provides basic capabilities for managing windows, including creating and destroying windows and setting serial port attributes. The **Window** module provides basic capabilities for managing windows, including creating and destroying windows and setting serial port attributes.
> ![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.
>
## Modules to Import ## Modules to Import
...@@ -96,7 +95,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -96,7 +95,7 @@ This is a system API and cannot be called by third-party applications.
## Rect<sup>7+</sup> ## Rect<sup>7+</sup>
Describes a rectangle. Describes the rectangular area of the window.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -371,6 +370,8 @@ getTopWindow(callback: AsyncCallback&lt;Window&gt;): void ...@@ -371,6 +370,8 @@ getTopWindow(callback: AsyncCallback&lt;Window&gt;): void
Obtains the top window of the current application. This API uses an asynchronous callback to return the result. Obtains the top window of the current application. This API uses an asynchronous callback to return the result.
This API is discarded since API version 8. You are advised to use [window.getTopWindow<sup>8+</sup>](#windowgettopwindow8) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
...@@ -399,6 +400,8 @@ getTopWindow(): Promise&lt;Window&gt; ...@@ -399,6 +400,8 @@ getTopWindow(): Promise&lt;Window&gt;
Obtains the top window of the current application. This API uses a promise to return the result. Obtains the top window of the current application. This API uses a promise to return the result.
This API is discarded since API version 8. You are advised to use [window.getTopWindow<sup>8+</sup>](#windowgettopwindow8) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value** **Return value**
...@@ -2393,7 +2396,7 @@ loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -2393,7 +2396,7 @@ loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void
Loads content to this window stage. This API uses an asynchronous callback to return the result. Loads content to this window stage. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Coretype with the value 'windowSizeChange' **System capability**: SystemCapability.WindowManager.WindowManager.Coretype with the value **windowSizeChange**
**Parameters** **Parameters**
......
# XML Parsing and Generation # XML Parsing and Generation
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **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,10 +10,6 @@ ...@@ -10,10 +10,6 @@
import xml from '@ohos.xml'; import xml from '@ohos.xml';
``` ```
## System Capabilities
SystemCapability.Utils.Lang
## XmlSerializer ## XmlSerializer
...@@ -23,6 +19,8 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) ...@@ -23,6 +19,8 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string)
A constructor used to create an **XmlSerializer** instance. A constructor used to create an **XmlSerializer** instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -45,6 +43,8 @@ setAttributes(name: string, value: string): void ...@@ -45,6 +43,8 @@ setAttributes(name: string, value: string): void
Sets an attribute. Sets an attribute.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -66,6 +66,8 @@ addEmptyElement(name: string): void ...@@ -66,6 +66,8 @@ addEmptyElement(name: string): void
Adds an empty element. Adds an empty element.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -86,6 +88,8 @@ setDeclaration(): void ...@@ -86,6 +88,8 @@ setDeclaration(): void
Sets a declaration. Sets a declaration.
**System capability**: SystemCapability.Utils.Lang
**Example** **Example**
```js ```js
...@@ -100,6 +104,8 @@ startElement(name: string): void ...@@ -100,6 +104,8 @@ startElement(name: string): void
Writes the start tag based on the given element name. Writes the start tag based on the given element name.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -122,6 +128,8 @@ endElement(): void ...@@ -122,6 +128,8 @@ endElement(): void
Writes the end tag of the element. Writes the end tag of the element.
**System capability**: SystemCapability.Utils.Lang
**Example** **Example**
```js ```js
...@@ -140,6 +148,8 @@ setNamespace(prefix: string, namespace: string): void ...@@ -140,6 +148,8 @@ setNamespace(prefix: string, namespace: string): void
Sets the namespace for an element tag. Sets the namespace for an element tag.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -164,6 +174,8 @@ setComment(text: string): void ...@@ -164,6 +174,8 @@ setComment(text: string): void
Sets the comment. Sets the comment.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -187,6 +199,8 @@ setCDATA(text: string): void ...@@ -187,6 +199,8 @@ setCDATA(text: string): void
Sets CDATA attributes. Sets CDATA attributes.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -208,6 +222,8 @@ setText(text: string): void ...@@ -208,6 +222,8 @@ setText(text: string): void
Sets **Text**. Sets **Text**.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -232,6 +248,8 @@ setDocType(text: string): void ...@@ -232,6 +248,8 @@ setDocType(text: string): void
Sets **DocType**. Sets **DocType**.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -256,6 +274,8 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) ...@@ -256,6 +274,8 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string)
Creates and returns an **XmlPullParser** object. The **XmlPullParser** object passes two parameters. The first parameter is the memory of the **ArrayBuffer** or **DataView** type, and the second parameter is the file format (UTF-8 by default). Creates and returns an **XmlPullParser** object. The **XmlPullParser** object passes two parameters. The first parameter is the memory of the **ArrayBuffer** or **DataView** type, and the second parameter is the file format (UTF-8 by default).
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -289,6 +309,8 @@ parse(option: ParseOptions): void ...@@ -289,6 +309,8 @@ parse(option: ParseOptions): void
Parses XML information. Parses XML information.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -329,6 +351,8 @@ that.parse(options); ...@@ -329,6 +351,8 @@ that.parse(options);
Defines the XML parsing options. Defines the XML parsing options.
**System capability**: SystemCapability.Utils.Lang
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -349,6 +373,8 @@ getColumnNumber(): number ...@@ -349,6 +373,8 @@ getColumnNumber(): number
Obtains the column line number, which starts from 1. Obtains the column line number, which starts from 1.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -362,6 +388,8 @@ getDepth(): number ...@@ -362,6 +388,8 @@ getDepth(): number
Obtains the depth of this element. Obtains the depth of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -375,6 +403,8 @@ getLineNumber(): number ...@@ -375,6 +403,8 @@ getLineNumber(): number
Obtains the current line number, starting from 1. Obtains the current line number, starting from 1.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -388,6 +418,8 @@ getName(): string ...@@ -388,6 +418,8 @@ getName(): string
Obtains the name of this element. Obtains the name of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -401,6 +433,8 @@ getNamespace(): string ...@@ -401,6 +433,8 @@ getNamespace(): string
Obtains the namespace of this element. Obtains the namespace of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -414,6 +448,8 @@ getPrefix(): string ...@@ -414,6 +448,8 @@ getPrefix(): string
Obtains the prefix of this element. Obtains the prefix of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -427,6 +463,8 @@ getText(): string ...@@ -427,6 +463,8 @@ getText(): string
Obtains the text of the current event. Obtains the text of the current event.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -440,6 +478,8 @@ isEmptyElementTag(): boolean ...@@ -440,6 +478,8 @@ isEmptyElementTag(): boolean
Checks whether the current element is empty. Checks whether the current element is empty.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -453,6 +493,8 @@ isWhitespace(): boolean ...@@ -453,6 +493,8 @@ isWhitespace(): boolean
Checks whether the current text event contains only whitespace characters. Checks whether the current text event contains only whitespace characters.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -466,6 +508,8 @@ getAttributeCount(): number ...@@ -466,6 +508,8 @@ getAttributeCount(): number
Obtains the number of attributes for the current start tag. Obtains the number of attributes for the current start tag.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
...@@ -476,6 +520,8 @@ Obtains the number of attributes for the current start tag. ...@@ -476,6 +520,8 @@ Obtains the number of attributes for the current start tag.
Enumerates the events. Enumerates the events.
**System capability**: SystemCapability.Utils.Lang
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| START_DOCUMENT | 0 | Indicates a start document event.| | START_DOCUMENT | 0 | Indicates a start document event.|
......
...@@ -106,5 +106,5 @@ ...@@ -106,5 +106,5 @@
- [Event Parameter](js-components-custom-event-parameter.md) - [Event Parameter](js-components-custom-event-parameter.md)
- [slot](js-components-custom-slot.md) - [slot](js-components-custom-slot.md)
- [Lifecycle Definition](js-components-custom-lifecycle.md) - [Lifecycle Definition](js-components-custom-lifecycle.md)
- [Type Attributes](js-appendix-types.md) - Appendix
- [Type Attributes](js-appendix-types.md)
# Multi-Language Capability
Applications designed based on the JS UI framework apply to different countries and regions. With the multi-language capability, you do not need to develop application versions in different languages, and your users can switch between various locales. This also facilitates project maintenance.
You only need to perform operations in [Resource Files](#resource-files) and [Resource Reference](#resource-reference) to use the multi-language capability of this framework. For details about how to obtain the current system language, see [Language Acquisition](#language-acquisition).
## Resource Files
Resource files store application content in multiple languages. This framework uses JSON files to store resource definitions. Place the resource file of each locale in the i18n directory described in [File Organization](js-framework-file.md).
Resource files should be named in _language-script-region_.json format. For example, the resource file for Hong Kong Chinese in the traditional script is named zh-Hant-HK. You can omit the region, for example, zh-CN for simplified Chinese, or omit both the script and region, for example, zh for Chinese.
```
language[-script-region].json
```
The following table describes the requirements for the qualifiers of resource file names.
Table 1 Requirements for qualifier values
| Qualifier Type | Description and Value Range |
| -------- | -------- |
| Language | Indicates the language used by the device. The value consists of two or three lowercase letters, for example, zh indicates Chinese, en indicates English, and mai indicates Maithili.<br/>For details about the value range, refer to ISO 639 (codes for the representation of names of languages). |
| Script | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters, for example, Hans indicates simplified Chinese and Hant indicates traditional Chinese.<br/>For details about the value range, refer to ISO 15924 (codes for the representation of names of scripts). |
| Country/Region | Indicates the country or region where a user is located. The value consists of two or three uppercase letters or three digits, for example, CN indicates China and GB indicates the United Kingdom.<br/>For details about the value range, refer to ISO 3166-1 (codes for the representation of names of countries and their subdivisions). |
If there is no resource file of the locale that matches the system language, content in the en-US.json file will be used by default.
The format of the resource file content is as follows:
**en-US.json**
```
{
"strings": {
"hello": "Hello world!",
"object": "Object parameter substitution-{name}",
"array": "Array type parameter substitution-{0}",
"symbol": "@#$%^&*()_+-={}[]\\|:;\"'<>,./?"
},
"files": {
"image": "image/en_picture.PNG"
}
}
```
Different languages have different matching rules for singular and plural forms. In the resource file, zero, one, two, few, many, and other are used to define the string content in different singular and plural forms. For example, there is only the other scenario in Chinese since the language does not have singular and plural forms. one and other scenarios are applicable to English. All six scenarios are needed for Arabic.
The following example takes en-US.json and ar-AE.json as examples:
**en-US.json**
```
{
"strings": {
"people": {
"one": "one person",
"other": "{count} people"
}
}
}
```
ar-AE.json
```
{
"strings": {
"people": {
"zero": "لا أحد",
"one": "وحده",
"two": "اثنان",
"few": "ستة اشخاص",
"many": "خمسون شخص",
"other": "مائة شخص"
}
}
}
```
## Resource Reference
Multi-language syntax used on application development pages (including simple formatting and singular-plural formatting) can be used in .hml or .js files.
- Simple formatting
Use the `$t` function to reference to resources of different locales. The `$t` function is available for both .hml and .js files. The system displays content based on a resource file path specified via $t and the specified resource file whose locale matches the current system language.
Table 2 Simple formatting
| Attribute | Type | Parameter | Mandatory | Description |
| -------- | -------- | -------- | -------- | -------- |
| $t | Function | See Table3 | Yes | Sets the parameters based on the system language, for example, this.$t('strings.hello'). |
Table 3 $t function parameters
| Parameter | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| path | string | Yes | Path of the language resource key |
| params | Array\|Object | No | Content used to replace placeholders during runtime. There are two types of placeholders available:<br/>- Named placeholder, for example, {name}. The actual content must be of the object type, for example, \```$t('strings.object', {name:'Hello world'})```.<br/>- Digit placeholder, for example, {0}. The actual content must be of the array type, for example, \```$t('strings.array', [Hello world']```. |
- Example code for simple formatting
```
<!-- xxx.hml -->
<div>
<!-- Display Hello world! without using a placeholder. -->
<text>{{ $t('strings.hello') }}</text>
<!-- Replace named placeholder {name} with Hello world and display it. -->
<text>{{ $t('strings.object', { name: 'Hello world' }) }}</text>
<!-- Replace digit placeholder {0} with Hello world and display it. -->
<text>{{ $t('strings.array', ['Hello world']) }}</text>
<!-- Obtain the resource content from the .js file and display Hello world. -->
<text>{{ hello }}</text>
<!-- Obtain the resource content from the .js file, replace named placeholder {name} with Hello world, and display Substitution in an object: Hello world. -->
<text>{{ replaceObject }}</text>
<!-- Obtain the resource content from the .js file, replace digit placeholder {0} with Hello world, and display Substitution in an array: Hello world. -->
<text>{{ replaceArray }}</text>
<!-- Display the image in the specified file path. -->
<image src="{{ $t('files.image') }}" class="image"></image>
<!-- Obtain the image file path from the .js file and display the image. -->
<image src="{{ replaceSrc }}" class="image"></image>
</div>
```
```
// xxx.js
// The following example uses the $t function in the .js file.
export default {
data: {
hello: '',
replaceObject: '',
replaceArray: '',
replaceSrc: '',
},
onInit() {
this.hello = this.$t('strings.hello');
this.replaceObject = this.$t('strings.object', { name: 'Hello world' });
this.replaceArray = this.$t('strings.array', ['Hello world']);
this.replaceSrc = this.$t('files.image');
},
}
```
- Singular-plural formatting
Table 4 Singular-plural formatting
| Attribute | Type | Parameter | Mandatory | Description |
| -------- | -------- | -------- | -------- | -------- |
| $tc | Function | See Table 5. | Yes | Converts between the singular and plural forms based on the system language, for example, this.$tc('strings.people').<br/>> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>> The resource content is distinguished by the following JSON keys: zero, one, two, few, many, and other. |
Table 5 $tc function parameters
| Parameter | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| path | string | Yes | Path of the language resource key |
| count | number | Yes | Number |
- Sample code for singular-plural formatting
```
<!--xxx.hml-->
<div>
<!-- When the value 0 is passed, "0 people" matches the Arabic string whose key is zero. -->
<text>{{ $tc('strings.people', 0) }}</text>
<!-- When the value 1 is passed, "1 person" matches the Arabic string whose key is one. -->
<text>{{ $tc('strings.people', 1) }}</text>
<!-- When the value 2 is passed, "2 people" matches the Arabic string whose key is two. -->
<text>{{ $tc('strings.people', 2) }}</text>
<!-- When the value 6 is passed, "6 people" matches the Arabic string whose key is few. -->
<text>{{ $tc('strings.people', 6) }}</text>
<!-- When the value 50 is passed, "50 people" matches the Arabic string whose key is many. -->
<text>{{ $tc('strings.people', 50) }}</text>
<!-- When the value 100 is passed, "100 people" matches the Arabic string whose key is other. -->
<text>{{ $tc('strings.people', 100) }}</text>
</div>
```
## Language Acquisition
For details about how to obtain the language, see the Application Configuration section.
...@@ -139,10 +139,10 @@ The driver loading information required by the HDF comes from the driver device ...@@ -139,10 +139,10 @@ The driver loading information required by the HDF comes from the driver device
```bash ```bash
$openharmony_src_root/vendor/hisilicon/hispark_taurus/hdf_config # Directory for storing the kernel-mode configuration file. There are no user-mode configuration files. $openharmony_src_root/vendor/hisilicon/hispark_taurus/hdf_config # Directory for storing the kernel-mode configuration file. There are no user-mode configuration files.
$openharmony_src_root/vendor/hisilicon/Hi3516DV300/hdf_config/khdf # Directory for storing the kernel-mode configuration file. $openharmony_src_root/vendor/hisilicon/hispark_taurus_standard/hdf_config/khdf # Directory for storing the kernel-mode configuration file.
$openharmony_src_root/vendor/hisilicon/Hi3516DV300/hdf_config/uhdf # Directory for storing the user-mode configuration file. $openharmony_src_root/vendor/hisilicon/hispark_taurus_standard/hdf_config/uhdf # Directory for storing the user-mode configuration file.
$openharmony_src_root/vendor/hisilicon/Hi3516DV300/hdf_config/khdf/device_info/device_info.hcs # Device description file of the kernel-mode driver. $openharmony_src_root/vendor/hisilicon/hispark_taurus_standard/hdf_config/khdf/device_info/device_info.hcs # Device description file of the kernel-mode driver.
$openharmony_src_root/vendor/hisilicon/Hi3516DV300/hdf_config/khdf/lcd/lcd_config.hcs # Private configuration file of the kernel-mode driver. $openharmony_src_root/vendor/hisilicon/hispark_taurus_standard/hdf_config/khdf/lcd/lcd_config.hcs # Private configuration file of the kernel-mode driver.
``` ```
#### [Rule] Use existing configuration information and inherit existing configuration templates during driver configuration. #### [Rule] Use existing configuration information and inherit existing configuration templates during driver configuration.
...@@ -373,9 +373,9 @@ If a driver has private configurations, you can add a driver configuration file ...@@ -373,9 +373,9 @@ If a driver has private configurations, you can add a driver configuration file
[Example] [Example]
```bash ```bash
$openharmony_src_root/vendor/hisilicon/Hi3516DV300/hdf_config/khdf/sample/sample_config.hcs # Correct. The private configuration file is stored in the sample directory. $openharmony_src_root/vendor/hisilicon/hispark_taurus_standard/hdf_config/khdf/sample/sample_config.hcs # Correct. The private configuration file is stored in the sample directory.
$openharmony_src_root/vendor/hisilicon/Hi3516DV300/hdf_config/khdf/sample_config.hcs # Incorrect. The private configuration file is placed in the root directory. $openharmony_src_root/vendor/hisilicon/hispark_taurus_standard/hdf_config/khdf/sample_config.hcs # Incorrect. The private configuration file is placed in the root directory.
``` ```
#### [Rule] Add the private configuration file of a driver to the hdf.hcs file in the hdf_config directory. #### [Rule] Add the private configuration file of a driver to the hdf.hcs file in the hdf_config directory.
......
...@@ -27,7 +27,7 @@ In addition, OpenHarmony provides a wide array of system components that can be ...@@ -27,7 +27,7 @@ In addition, OpenHarmony provides a wide array of system components that can be
## Document Outline<a name="section19810171681218"></a> ## Document Outline<a name="section19810171681218"></a>
**Table 1** Mini and small system development guidelines (reference memory < 128 MB) **Table 1** Mini and small system development guidelines (reference memory < 128 MiB)
| Topic| Development Scenario| Related Documentation| | Topic| Development Scenario| Related Documentation|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -41,7 +41,7 @@ In addition, OpenHarmony provides a wide array of system components that can be ...@@ -41,7 +41,7 @@ In addition, OpenHarmony provides a wide array of system components that can be
| Reference| Referring to development specifications| [FAQs](faqs/faqs-overview.md) | | Reference| Referring to development specifications| [FAQs](faqs/faqs-overview.md) |
**Table 2** Standard system development guidelines (reference memory ≥ 128 MB) **Table 2** Standard system development guidelines (reference memory ≥ 128 MiB)
| Topic| Development Scenario| Related Documentation| | Topic| Development Scenario| Related Documentation|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| About OpenHarmony| Getting familiar with OpenHarmony| -&nbsp;[About OpenHarmony](https://gitee.com/openharmony)<br>-&nbsp;[Glossary](../glossary.md) | | About OpenHarmony| Getting familiar with OpenHarmony| -&nbsp;[About OpenHarmony](https://gitee.com/openharmony)<br>-&nbsp;[Glossary](../glossary.md) |
......
# Platform Driver Development<a name="EN-US_TOPIC_0000001160769576"></a>
- **[ADC](driver-platform-adc-develop.md)**
- **[DAC](driver-platform-dac-develop.md)**
- **[GPIO](driver-platform-gpio-develop.md)**
- **[HDMI](driver-platform-hdmi-develop.md)**
- **[I2C](driver-platform-i2c-develop.md)**
- **[I3C](driver-platform-i3c-develop.md)**
- **[MIPI CSI](driver-platform-mipicsi-develop.md)**
- **[MIPI DSI](driver-platform-mipidsi-develop.md)**
- **[MMC](driver-platform-mmc-develop.md)**
- **[PWM](driver-platform-pwm-develop.md)**
- **[RTC](driver-platform-rtc-develop.md)**
- **[SDIO](driver-platform-sdio-develop.md)**
- **[SPI](driver-platform-spi-develop.md)**
- **[UART](driver-platform-uart-develop.md)**
- **[Watchdog](driver-platform-watchdog-develop.md)**
# HDF<a name="EN-US_TOPIC_0000001157319419"></a>
- **[HDF Overview](driver-hdf-overview.md)**
- **[Driver Development](driver-hdf-development.md)**
- **[Driver Service Management](driver-hdf-servicemanage.md)**
- **[Driver Message Mechanism Management](driver-hdf-message-management.md)**
- **[Driver Configuration Management](driver-hdf-manage.md)**
- **[HDF Development Example](driver-hdf-sample.md)**
...@@ -273,7 +273,7 @@ int32_t CodecDaiHwParams(const struct AudioCard *card, const struct AudioPcmHwPa ...@@ -273,7 +273,7 @@ int32_t CodecDaiHwParams(const struct AudioCard *card, const struct AudioPcmHwPa
#### Registering and Binding Codec to HDF #### Registering and Binding Codec to HDF
This process depends on the driver implementation mode of the HDF. For details, see [HDF](https://gitee.com/openharmony/docs/blob/master/en/device-dev/driver/driver-hdf.md). This process depends on the driver implementation mode of the HDF. For details, see [HDF](https://gitee.com/openharmony/docs/blob/master/en/device-dev/driver/Readme-EN.md).
Fill in the **g_codecDriverEntry** structure. Ensure that the value of **moduleName** is the same as that in **device_info.hcs**. Implement the pointers to the **Bind**, **Init**, and **Release** functions. Fill in the **g_codecDriverEntry** structure. Ensure that the value of **moduleName** is the same as that in **device_info.hcs**. Implement the pointers to the **Bind**, **Init**, and **Release** functions.
...@@ -335,7 +335,7 @@ Configure the driver node, loading sequence, and service name in the .hcs file. ...@@ -335,7 +335,7 @@ Configure the driver node, loading sequence, and service name in the .hcs file.
Path of the standard-system configuration file: Path of the standard-system configuration file:
**vendor/hisilicon/Hi3516DV300/hdf_config/khdf/** **vendor/hisilicon/hispark_taurus_standard/hdf_config/khdf/**
Path of the small-system configuration file: Path of the small-system configuration file:
...@@ -779,7 +779,7 @@ int32_t Tfa9879DaiHwParams(const struct AudioCard *card, const struct AudioPcmHw ...@@ -779,7 +779,7 @@ int32_t Tfa9879DaiHwParams(const struct AudioCard *card, const struct AudioPcmHw
#### Registering and Binding Accessory to HDF #### Registering and Binding Accessory to HDF
This process depends on the driver implementation mode of the HDF. For details, see [HDF](https://gitee.com/openharmony/docs/blob/master/en/device-dev/driver/driver-hdf.md). This process depends on the driver implementation mode of the HDF. For details, see [HDF](https://gitee.com/openharmony/docs/blob/master/en/device-dev/driver/Readme-EN.md).
Fill in the **g_tfa9879DriverEntry** structure. Ensure that the value of **moduleName** is the same as that in **device_info.hcs**. Implement the pointers to the **Bind**, **Init**, and **Release** functions. Fill in the **g_tfa9879DriverEntry** structure. Ensure that the value of **moduleName** is the same as that in **device_info.hcs**. Implement the pointers to the **Bind**, **Init**, and **Release** functions.
...@@ -900,7 +900,7 @@ int32_t Hi3516DmaPointer(struct PlatformData *data, uint32_t *pointer); ...@@ -900,7 +900,7 @@ int32_t Hi3516DmaPointer(struct PlatformData *data, uint32_t *pointer);
#### Registering and Binding Platform to HDF #### Registering and Binding Platform to HDF
This process depends on the driver implementation mode of the HDF. For details, see [HDF](https://gitee.com/openharmony/docs/blob/master/en/device-dev/driver/driver-hdf.md). This process depends on the driver implementation mode of the HDF. For details, see [HDF](https://gitee.com/openharmony/docs/blob/master/en/device-dev/driver/Readme-EN.md).
- Fill in the **g_platformDriverEntry** structure. - Fill in the **g_platformDriverEntry** structure.
- Ensure that the value of **moduleName** is the same as that in **device_info.hcs**. - Ensure that the value of **moduleName** is the same as that in **device_info.hcs**.
...@@ -1064,7 +1064,7 @@ int32_t DaiStartup(const struct AudioCard *card, const struct DaiDevice *device) ...@@ -1064,7 +1064,7 @@ int32_t DaiStartup(const struct AudioCard *card, const struct DaiDevice *device)
#### Registering and Binding DAI to HDF #### Registering and Binding DAI to HDF
This process depends on the driver implementation mode of the HDF. For details, see [HDF](https://gitee.com/openharmony/docs/blob/master/en/device-dev/driver/driver-hdf.md). This process depends on the driver implementation mode of the HDF. For details, see [HDF](https://gitee.com/openharmony/docs/blob/master/en/device-dev/driver/Readme-EN.md).
- Fill in the **g_daiDriverEntry** structure. - Fill in the **g_daiDriverEntry** structure.
- Ensure that the value of **moduleName** is the same as that in **device_info.hcs**. - Ensure that the value of **moduleName** is the same as that in **device_info.hcs**.
...@@ -1215,7 +1215,7 @@ HCS Files and Directory ...@@ -1215,7 +1215,7 @@ HCS Files and Directory
``` ```
Standard system: Standard system:
vendor/hisilicon/Hi3516DV300/ vendor/hisilicon/hispark_taurus_standard/
└── hdf_config └── hdf_config
└── khdf └── khdf
├── audio ├── audio
......
# Peripheral Driver Usage<a name="EN-US_TOPIC_0000001157319411"></a>
- **[LCD](driver-peripherals-lcd-des.md)**
- **[Touchscreen](driver-peripherals-touch-des.md)**
- **[Sensor](driver-peripherals-sensor-des.md)**
- **[WLAN](driver-peripherals-external-des.md)**
- **[Audio](driver-peripherals-audio-des.md)**
- **[USB](driver-peripherals-usb-des.md)**
- **[Camera](driver-peripherals-camera-des.md)**
# Driver Platform Usage<a name="en-us_TOPIC_0000001111199424"></a>
- **[ADC](driver-platform-adc-des.md)**
- **[DAC](driver-platform-dac-des.md)**
- **[GPIO](driver-platform-gpio-des.md)**
- **[HDMI](driver-platform-hdmi-des.md)**
- **[I2C](driver-platform-i2c-des.md)**
- **[I3C](driver-platform-i3c-des.md)**
- **[MIPI CSI](driver-platform-mipicsi-des.md)**
- **[MIPI DSI](driver-platform-mipidsi-des.md)**
- **[Pin](driver-platform-pin-des.md)**
- **[PWM](driver-platform-pwm-des.md)**
- **[RTC](driver-platform-rtc-des.md)**
- **[SDIO](driver-platform-sdio-des.md)**
- **[SPI](driver-platform-spi-des.md)**
- **[UART](driver-platform-uart-des.md)**
- **[Watchdog](driver-platform-watchdog-des.md)**
# Drivers<a name="EN-US_TOPIC_0000001111039544"></a>
- **[HDF](driver-hdf.md)**
- **[Platform Driver Development](driver-develop.md)**
- **[Platform Driver Usage](driver-platform.md)**
- **[Peripheral Driver Usage](driver-peripherals.md)**
# Startup and Recovery # Startup
## System Startup Interrupted Due to "parse failed!" Error ## System Startup Interrupted Due to "parse failed!" Error
......
...@@ -156,7 +156,7 @@ Run the following script to start building for standard-system devices \(referen ...@@ -156,7 +156,7 @@ Run the following script to start building for standard-system devices \(referen
./build.sh --product-name {product_name} --ccache ./build.sh --product-name {product_name} --ccache
``` ```
**product\_name** indicates the platform supported by the current distribution, for example, Hi3516DV300 and rk3568. **product\_name** indicates the platform supported by the current distribution, for example, hispark_taurus_standard and rk3568.
Files generated during building are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory. Files generated during building are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory.
......
...@@ -6,7 +6,7 @@ Use the camera module APIs to capture frames \(photographing\). ...@@ -6,7 +6,7 @@ Use the camera module APIs to capture frames \(photographing\).
## Available APIs<a name="en-us_topic_0000001052170554_section56549532016"></a> ## Available APIs<a name="en-us_topic_0000001052170554_section56549532016"></a>
**Table 1** APIs for photographing **Table 1** APIs for photographing
<a name="en-us_topic_0000001052170554_table2069447114914"></a> <a name="en-us_topic_0000001052170554_table2069447114914"></a>
<table><thead align="left"><tr id="en-us_topic_0000001052170554_row4903852104914"><th class="cellrowborder" valign="top" width="18.811881188118814%" id="mcps1.2.4.1.1"><p id="en-us_topic_0000001052170554_p2903252174918"><a name="en-us_topic_0000001052170554_p2903252174918"></a><a name="en-us_topic_0000001052170554_p2903252174918"></a>Class</p> <table><thead align="left"><tr id="en-us_topic_0000001052170554_row4903852104914"><th class="cellrowborder" valign="top" width="18.811881188118814%" id="mcps1.2.4.1.1"><p id="en-us_topic_0000001052170554_p2903252174918"><a name="en-us_topic_0000001052170554_p2903252174918"></a><a name="en-us_topic_0000001052170554_p2903252174918"></a>Class</p>
......
# Development Guidelines<a name="EN-US_TOPIC_0000001054903130"></a> # Screen and Camera Control Development<a name="EN-US_TOPIC_0000001054903130"></a>
- **[Photographing](device-camera-control-demo-photoguide.md)** - **[Photographing](device-camera-control-demo-photoguide.md)**
......
...@@ -5,7 +5,7 @@ This use case takes **camera\_sample** \(contained in the source code\) as an ...@@ -5,7 +5,7 @@ This use case takes **camera\_sample** \(contained in the source code\) as an
- You can obtain source code of the sample from **applications/sample/camera/media/camera\_sample.cpp**. - You can obtain source code of the sample from **applications/sample/camera/media/camera\_sample.cpp**.
- Before running the sample camera, you need to compile, burn, and run the image. For details, see [Hi3516 Development Board](../quick-start/quickstart-lite-introduction-hi3516#section26131214194212). - Before running the sample camera, you need to compile, burn, and run the image. For details, see [Hi3516 Development Board](../quick-start/quickstart-lite-introduction-hi3516#section26131214194212).
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE**<br/>
>After the development board is started, the home screen is loaded and displayed above the media layer by default. To prevent covering **camera\_sample**, you should remove the home screen during compilation or packaging. >After the development board is started, the home screen is loaded and displayed above the media layer by default. To prevent covering **camera\_sample**, you should remove the home screen during compilation or packaging.
>How to Remove: In **build/lite/components/applications.json**, comment out or delete the **//applications/sample/camera/launcher:launcher\_hap** line from the **target** field of **camera\_sample\_app**. >How to Remove: In **build/lite/components/applications.json**, comment out or delete the **//applications/sample/camera/launcher:launcher\_hap** line from the **target** field of **camera\_sample\_app**.
...@@ -18,7 +18,7 @@ This use case takes **camera\_sample** \(contained in the source code\) as an ...@@ -18,7 +18,7 @@ This use case takes **camera\_sample** \(contained in the source code\) as an
Recompile the source code repository and burn the code into the development board. Then you can find the **camera\_sample** file in the **bin** directory of the board. Recompile the source code repository and burn the code into the development board. Then you can find the **camera\_sample** file in the **bin** directory of the board.
>![](../public_sys-resources/icon-notice.gif) **NOTICE:** >![](../public_sys-resources/icon-notice.gif) **NOTICE**<br/>
>You should insert a TF card \(up to 128 GB supported\) for photographing and video recording before system startup. This way, the TF card will be automatically mounted to the **/sdcard** directory. If you insert the TF card after the system is started, you have to manually mount the TF card. >You should insert a TF card \(up to 128 GB supported\) for photographing and video recording before system startup. This way, the TF card will be automatically mounted to the **/sdcard** directory. If you insert the TF card after the system is started, you have to manually mount the TF card.
>To view the photos and videos in the TF card, copy them to a computer. If you just want to preview photos and videos, you do not need to insert a TF card. >To view the photos and videos in the TF card, copy them to a computer. If you just want to preview photos and videos, you do not need to insert a TF card.
...@@ -26,14 +26,14 @@ This use case takes **camera\_sample** \(contained in the source code\) as an ...@@ -26,14 +26,14 @@ This use case takes **camera\_sample** \(contained in the source code\) as an
1. Run the **cd** command to go to the end path of the executable program and start **camera\_sample** by running the command in the following figure. 1. Run the **cd** command to go to the end path of the executable program and start **camera\_sample** by running the command in the following figure.
**Figure 1** Starting camera\_sample<a name="fig380985885020"></a> **Figure 1** Starting camera\_sample<a name="fig380985885020"></a>
![](figures/starting-camera_sample.png "starting-camera_sample") ![](figures/starting-camera_sample.png "starting-camera_sample")
The control commands are displayed as shown in the preceding figure. Press **S** to stop the current operation \(including video recording and preview\), and press **Q** to exit the program. The control commands are displayed as shown in the preceding figure. Press **S** to stop the current operation \(including video recording and preview\), and press **Q** to exit the program.
2. Press **1** to take a photo in JPG format. The photo is saved in the **/sdcard** directory and named **Capture\***. 2. Press **1** to take a photo in JPG format. The photo is saved in the **/sdcard** directory and named **Capture\***.
**Figure 2** Serial port logs displayed after the photographing command is executed<a name="fig17819185018384"></a> **Figure 2** Serial port logs displayed after the photographing command is executed<a name="fig17819185018384"></a>
![](figures/serial-port-logs-displayed-after-the-photographing-command-is-executed.png "serial-port-logs-displayed-after-the-photographing-command-is-executed") ![](figures/serial-port-logs-displayed-after-the-photographing-command-is-executed.png "serial-port-logs-displayed-after-the-photographing-command-is-executed")
To view the saved file, exit the program and enter the file system. To start the program again, return to the previous step. To view the saved file, exit the program and enter the file system. To start the program again, return to the previous step.
...@@ -41,24 +41,24 @@ This use case takes **camera\_sample** \(contained in the source code\) as an ...@@ -41,24 +41,24 @@ This use case takes **camera\_sample** \(contained in the source code\) as an
**Figure 3** Saved files<a name="fig166391743154619"></a> **Figure 3** Saved files<a name="fig166391743154619"></a>
![](figures/saved-files.png "saved-files") ![](figures/saved-files.png "saved-files")
3. Press **2** to start recording. The video file is in MP4 format and saved in the **/sdcard** directory with the name **Record\***. Press **S** to stop recording. 3. Press **2** to start recording. The video file is in MP4 format and saved in the **/sdcard** directory with the name **Record\***. Press **S** to stop recording.
**Figure 4** Serial port logs displayed after the recording command is executed<a name="fig6340814174317"></a> **Figure 4** Serial port logs displayed after the recording command is executed<a name="fig6340814174317"></a>
![](figures/serial-port-logs-displayed-after-the-recording-command-is-executed.png "serial-port-logs-displayed-after-the-recording-command-is-executed") ![](figures/serial-port-logs-displayed-after-the-recording-command-is-executed.png "serial-port-logs-displayed-after-the-recording-command-is-executed")
4. Press **3** to start preview. The preview is displayed on the screen. Press **S** to stop preview. 4. Press **3** to start preview. The preview is displayed on the screen. Press **S** to stop preview.
**Figure 5** Serial port logs displayed after the preview command is executed<a name="fig9658148124414"></a> **Figure 5** Serial port logs displayed after the preview command is executed<a name="fig9658148124414"></a>
![](figures/serial-port-logs-displayed-after-the-preview-command-is-executed.png "serial-port-logs-displayed-after-the-preview-command-is-executed") ![](figures/serial-port-logs-displayed-after-the-preview-command-is-executed.png "serial-port-logs-displayed-after-the-preview-command-is-executed")
The following figure shows the preview. The following figure shows the preview.
**Figure 6** Preview effect<a name="fig24541759597"></a> **Figure 6** Preview effect<a name="fig24541759597"></a>
![](figures/preview-effect.jpg "preview-effect") ![](figures/preview-effect.jpg "preview-effect")
5. Press **Q** to exit. 5. Press **Q** to exit.
**Figure 7** Serial port logs displayed after the exit command is executed<a name="fig1755682174514"></a> **Figure 7** Serial port logs displayed after the exit command is executed<a name="fig1755682174514"></a>
![](figures/serial-port-logs-displayed-after-the-exit-command-is-executed.png "serial-port-logs-displayed-after-the-exit-command-is-executed") ![](figures/serial-port-logs-displayed-after-the-exit-command-is-executed.png "serial-port-logs-displayed-after-the-exit-command-is-executed")
# Overview<a name="EN-US_TOPIC_0000001055101239"></a> # Screen and Camera Control Overview<a name="EN-US_TOPIC_0000001055101239"></a>
This document describes how to use the IoT camera development board \(Hi3516D V300\) and its camera and screen to implement photographing, video recording, and video preview. This document describes how to use the IoT camera development board \(Hi3516D V300\) and its camera and screen to implement photographing, video recording, and video preview.
This document helps you take a deep dive into OpenHarmony camera control. With this reference, you can develop devices, such as peephole cameras, smart rear-view mirrors, and smart displays. This document helps you take a deep dive into OpenHarmony camera control. With this reference, you can develop devices, such as peephole cameras, smart rear-view mirrors, and smart displays.
If you want to view the running effect first, see [Use Case](device-camera-control-example.md). To customize application behavior, modify the sample code by referring to APIs described in the "Development Guidelines" section. If you want to view the running effect first, see [Use Case](device-camera-control-example.md). To customize application behavior, modify the sample code by referring to APIs described in the "Development Guidelines" section.
For basic concepts of camera development, see [Camera Development Overview](../subsystems/subsys-multimedia-camera-overview.md). For basic concepts of camera development, see [Camera Development Overview](../subsystems/subsys-multimedia-camera-overview.md).
# Screen and Camera Control<a name="EN-US_TOPIC_0000001111199426"></a> # Screen and Camera Control<a name="EN-US_TOPIC_0000001111199426"></a>
- **[Overview](device-camera-control-overview.md)** - **[Screen and Camera Control Overview](device-camera-control-overview.md)**
- **[Development Guidelines](device-camera-control-demo.md)** - **[Screen and Camera Control Development](device-camera-control-demo.md)**
- **[Use Case](device-camera-control-example.md)** - **[Use Case](device-camera-control-example.md)**
......
# Development Guidelines<a name="EN-US_TOPIC_0000001055086133"></a> # Camera Control Development<a name="EN-US_TOPIC_0000001055086133"></a>
- **[Photographing](device-iotcamera-control-demo-photodevguide.md)** - **[Photographing](device-iotcamera-control-demo-photodevguide.md)**
......
# Overview<a name="EN-US_TOPIC_0000001055366100"></a> # Camera Control Overview<a name="EN-US_TOPIC_0000001055366100"></a>
This document describes how to use the IoT camera development board and the built-in camera of the development kit to implement photographing and video recording. This document describes how to use the IoT camera development board and the built-in camera of the development kit to implement photographing and video recording.
You can perform operations provided in [Use Case](device-iotcamera-control-example.md) to learn more about development board peripheral control and then develop devices such as cameras. You can perform operations provided in [Use Case](device-iotcamera-control-example.md) to learn more about development board peripheral control and then develop devices such as cameras.
If you want to view the sample effect first, see [Use Case](device-iotcamera-control-example.md). To customize application behavior, modify the sample code by referring to APIs described in the next section. If you want to view the sample effect first, see [Use Case](device-iotcamera-control-example.md). To customize application behavior, modify the sample code by referring to APIs described in the next section.
For details about basic concepts for camera development, see the [camera development overview](../subsystems/subsys-multimedia-camera-overview.md). For details about basic concepts for camera development, see [Camera Overview](../subsystems/subsys-multimedia-camera-overview.md).
# Camera Control<a name="EN-US_TOPIC_0000001157319429"></a> # Camera Control<a name="EN-US_TOPIC_0000001157319429"></a>
- **[Overview](device-iotcamera-control-overview.md)** - **[Camera Control Overview](device-iotcamera-control-overview.md)**
- **[Development Guidelines](device-iotcamera-control-demo.md)** - **[Camera Control Development](device-iotcamera-control-demo.md)**
- **[Use Case](device-iotcamera-control-example.md)** - **[Use Case](device-iotcamera-control-example.md)**
......
此差异已折叠。
# Appendix<a name="EN-US_TOPIC_0000001123948061"></a> # Appendix
- **[Kernel Coding Specification](kernel-mini-appx-code.md)** - **[Kernel Coding Specification](kernel-mini-appx-code.md)**
- **[Basic Data Structure](kernel-mini-appx-data.md)** - **[Doubly Linked List](kernel-mini-appx-data-list.md)**
- **[Standard Libraries](kernel-mini-appx-lib.md)** - **[Standard Libraries](kernel-mini-appx-lib.md)**
# Kernel Coding Specification<a name="EN-US_TOPIC_0000001079036432"></a> # Kernel Coding Specification<a name="EN-US_TOPIC_0000001079036432"></a>
- [Principle](#section9512812145915)
- [Directory Structure](#section1355317267017)
- [Naming](#section1375364815017)
- [Comments](#section1692516179119)
- [Format](#section10888536113)
- [Macros](#section12276501124)
- [Header Files](#section158507231319)
- [Data Types](#section91351731446)
- [Variables](#section575493915417)
- [Assertions](#section13864440410)
- [Functions](#section671919481745)
This kernel coding specification is developed based on the general programming specifications in the industry. It defines the programming styles for kernel developers to follow. This kernel coding specification is developed based on the general programming specifications in the industry. It defines the programming styles for kernel developers to follow.
## Principle<a name="section9512812145915"></a> ## Principle
Overall principle: Overall principle:
...@@ -25,13 +14,13 @@ Overall principle: ...@@ -25,13 +14,13 @@ Overall principle:
Comply with this specification in most cases. When third-party open-source code needs to modified or a large number of open-source code APIs are used, follow the specifications applied to the third-party open-source code. Flexibly use this specification based on general principles. Comply with this specification in most cases. When third-party open-source code needs to modified or a large number of open-source code APIs are used, follow the specifications applied to the third-party open-source code. Flexibly use this specification based on general principles.
## Directory Structure<a name="section1355317267017"></a> ## Directory Structure
You are advised to divide directories by function module and then define the header file directory and source file directory for each module. You are advised to divide directories by function module and then define the header file directory and source file directory for each module.
Unless otherwise specified, use lowercase letters separated by underscores \(\_\) for directory names and file names. Unless otherwise specified, use lowercase letters separated by underscores \(\_\) for directory names and file names.
## **Naming**<a name="section1375364815017"></a> ## **Naming**
The CamelCase style is recommended. The rules are as follows: The CamelCase style is recommended. The rules are as follows:
...@@ -106,7 +95,7 @@ OsTaskScan ...@@ -106,7 +95,7 @@ OsTaskScan
OsMuxInit OsMuxInit
``` ```
## Comments<a name="section1692516179119"></a> ## Comments
Generally, clear software architecture and appropriate symbol naming improve code readability. Generally, clear software architecture and appropriate symbol naming improve code readability.
...@@ -142,7 +131,7 @@ You are advised to align multiple consecutive comments on the right. For example ...@@ -142,7 +131,7 @@ You are advised to align multiple consecutive comments on the right. For example
#define CONST_B 2000 /* Const B */ #define CONST_B 2000 /* Const B */
``` ```
## **Format**<a name="section10888536113"></a> ## **Format**
Indent code of each level with four spaces rather than tabs \('\\t'\) for a better readability. Indent code of each level with four spaces rather than tabs \('\\t'\) for a better readability.
...@@ -233,7 +222,7 @@ int Foo(const char * restrict p); // OK: When there is the restrict modifier, a ...@@ -233,7 +222,7 @@ int Foo(const char * restrict p); // OK: When there is the restrict modifier, a
sz = sizeof(int*); // OK: There is no variable on the right, and * follows the data type. sz = sizeof(int*); // OK: There is no variable on the right, and * follows the data type.
``` ```
## Macros<a name="section12276501124"></a> ## Macros
If a function-like macro can be replaced by a function, use a function instead. Use inline functions for performance-critical scenarios. If a function-like macro can be replaced by a function, use a function instead. Use inline functions for performance-critical scenarios.
...@@ -293,11 +282,11 @@ Do not reference external function APIs or variables in declaration mode. Use th ...@@ -293,11 +282,11 @@ Do not reference external function APIs or variables in declaration mode. Use th
It is recommended that header files be included by stability in the following sequence: header file corresponding to the source code, C standard library, operating system library, platform library, project public library, and other dependencies. It is recommended that header files be included by stability in the following sequence: header file corresponding to the source code, C standard library, operating system library, platform library, project public library, and other dependencies.
## Data Types<a name="section91351731446"></a> ## Data Types
You are advised to use the basic data types defined in **los\_compiler.h**. For example, define the 32-bit unsigned integer as **UINT32**. You are advised to use the basic data types defined in **los\_compiler.h**. For example, define the 32-bit unsigned integer as **UINT32**.
## Variables<a name="section575493915417"></a> ## Variables
Avoid large stack allocations, such as large local arrays. Avoid large stack allocations, such as large local arrays.
...@@ -309,7 +298,7 @@ Do not return the address of a local variable outside its scope. ...@@ -309,7 +298,7 @@ Do not return the address of a local variable outside its scope.
A variable that points to a resource handle or descriptor is assigned a new value immediately after the resource is released. If the scope of the variable ends immediately, no new value needs to be assigned. Variables that point to resource handles or descriptors include pointers, file descriptors, socket descriptors, and other variables that point to resources. A variable that points to a resource handle or descriptor is assigned a new value immediately after the resource is released. If the scope of the variable ends immediately, no new value needs to be assigned. Variables that point to resource handles or descriptors include pointers, file descriptors, socket descriptors, and other variables that point to resources.
## Assertions<a name="section13864440410"></a> ## Assertions
Assertions must be defined using macros and take effect only in the debugging version. Assertions must be defined using macros and take effect only in the debugging version.
...@@ -319,7 +308,7 @@ Do not change the running environment in an assertion. ...@@ -319,7 +308,7 @@ Do not change the running environment in an assertion.
An assertion is used to check only one error. An assertion is used to check only one error.
## Functions<a name="section671919481745"></a> ## Functions
The validity of data sent from a process to another process and data sent from an application to the kernel must be verified. The verification includes but is not limited to the following: The validity of data sent from a process to another process and data sent from an application to the kernel must be verified. The verification includes but is not limited to the following:
......
# Doubly Linked List<a name="EN-US_TOPIC_0000001078588390"></a> # Doubly Linked List
- [Basic Concepts](#section1990715203418)
- [Available APIs](#section848334511411)
- [How to Develop](#section01781261552)
- [Development Example](#section67569495514)
- [Example Description](#section48761994551)
- [Sample Code](#section1280202685519)
- [Verification](#section5811249105512)
## Basic Concepts
## Basic Concepts<a name="section1990715203418"></a>
A doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains a pointer to the previous node and a pointer to the next node in the sequence of nodes. The pointer head is unique. A doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains a pointer to the previous node and a pointer to the next node in the sequence of nodes. The pointer head is unique.
...@@ -109,7 +101,7 @@ The doubly linked list module provides the following APIs. For more details abou ...@@ -109,7 +101,7 @@ The doubly linked list module provides the following APIs. For more details abou
</tbody> </tbody>
</table> </table>
## How to Develop<a name="section01781261552"></a> ## How to Develop
The typical development process of the doubly linked list is as follows: The typical development process of the doubly linked list is as follows:
...@@ -136,7 +128,7 @@ This example implements the following: ...@@ -136,7 +128,7 @@ This example implements the following:
3. Delete a node. 3. Delete a node.
4. Check whether the operation is performed successfully. 4. Check whether the operation is performed successfully.
### Sample Code<a name="section1280202685519"></a> ### Sample Code
The sample code is as follows: The sample code is as follows:
...@@ -178,7 +170,7 @@ static UINT32 ListSample(VOID) ...@@ -178,7 +170,7 @@ static UINT32 ListSample(VOID)
} }
``` ```
### Verification<a name="section5811249105512"></a> ### Verification
The development is successful if the return result is as follows: The development is successful if the return result is as follows:
......
# Basic Data Structure<a name="EN-US_TOPIC_0000001123863115"></a> # Basic Data Structure
- **[Doubly Linked List](kernel-mini-appx-data-list.md)** - **[Doubly Linked List](kernel-mini-appx-data-list.md)**
......
# CMSIS Support<a name="EN-US_TOPIC_0000001124074753"></a> # CMSIS Support
- [Basic Concepts](#section131091144111615) ## Basic Concepts
- [Development Guidelines](#section57653573161)
- [Available APIs](#section1795910417173)
- [How to Develop](#section48301225131720)
- [Development Example](#section524434761713)
## Basic Concepts<a name="section131091144111615"></a>
The Cortex Microcontroller Software Interface Standard \([CMSIS](https://developer.arm.com/tools-and-software/embedded/cmsis)\) is a vendor-independent hardware abstraction layer for microcontrollers based on Arm Cortex processors. Of the CMSIS components, the Real Time Operating System \(RTOS\) defines a set of universal and standardized APIs to reduce the dependency of application developers on specific RTOS and facilitate software porting and reuse. The CMSIS provides CMSIS-RTOS v1 and CMSIS-RTOS v2. The OpenHarmony LiteOS-M supports only the implementation of CMSIS-RTOS v2. The Cortex Microcontroller Software Interface Standard \([CMSIS](https://developer.arm.com/tools-and-software/embedded/cmsis)\) is a vendor-independent hardware abstraction layer for microcontrollers based on Arm Cortex processors. Of the CMSIS components, the Real Time Operating System \(RTOS\) defines a set of universal and standardized APIs to reduce the dependency of application developers on specific RTOS and facilitate software porting and reuse. The CMSIS provides CMSIS-RTOS v1 and CMSIS-RTOS v2. The OpenHarmony LiteOS-M supports only the implementation of CMSIS-RTOS v2.
## Development Guidelines<a name="section57653573161"></a> ## Development Guidelines
### Available APIs<a name="section1795910417173"></a> ### Available APIs
The following table describes CMSIS-RTOS v2 APIs. For more details about the APIs, see the API reference. The following table describes CMSIS-RTOS v2 APIs. For more details about the APIs, see the API reference.
...@@ -102,7 +95,7 @@ The following table describes CMSIS-RTOS v2 APIs. For more details about the API ...@@ -102,7 +95,7 @@ The following table describes CMSIS-RTOS v2 APIs. For more details about the API
| | osMessageQueuePut | Puts the message into the queue or times out if the queue is full.| | | osMessageQueuePut | Puts the message into the queue or times out if the queue is full.|
| | osMessageQueueReset | Initialized the message queue to the empty state (not implemented yet).| | | osMessageQueueReset | Initialized the message queue to the empty state (not implemented yet).|
### How to Develop<a name="section48301225131720"></a> ### How to Develop
The CMSIS-RTOS v2 component can be provided as a library \(shown in the figure\) or source code. By adding the CMSIS-RTOS v2 component \(typically configuration files\), you can implement RTOS capabilities on CMSIS-based applications. You only need to include the **cmsis\_os2.h** header file. RTOS APIs can then be called to process RTOS kernel-related events. You do not need to recompile the source code when the kernel is replaced. The CMSIS-RTOS v2 component can be provided as a library \(shown in the figure\) or source code. By adding the CMSIS-RTOS v2 component \(typically configuration files\), you can implement RTOS capabilities on CMSIS-based applications. You only need to include the **cmsis\_os2.h** header file. RTOS APIs can then be called to process RTOS kernel-related events. You do not need to recompile the source code when the kernel is replaced.
...@@ -110,7 +103,7 @@ The RTOS object control block definition needs to be called for static object al ...@@ -110,7 +103,7 @@ The RTOS object control block definition needs to be called for static object al
![](figures/how-to-develop.png) ![](figures/how-to-develop.png)
### Development Example<a name="section524434761713"></a> ### Development Example
``` ```
#include ... #include ...
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册