提交 fea57fa0 编写于 作者: Y Yao.inhome 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into tiankehui_canvas_0401

要显示的变更太多。

To preserve performance only 1000 of 1000+ files are displayed.
...@@ -16,11 +16,11 @@ This repository stores device and application development documents provided by ...@@ -16,11 +16,11 @@ This repository stores device and application development documents provided by
- master: the latest version. - master: the latest version.
- OpenHarmony 3.1 Beta. [Learn more](en/release-notes/OpenHarmony-v3.1-beta.md) - OpenHarmony 3.1 Release. [Learn more](en/release-notes/OpenHarmony-v3.1-release.md)
- OpenHarmony 3.0 LTS. [Learn more](en/release-notes/OpenHarmony-v3.0-LTS.md) - OpenHarmony 3.0 LTS. [Learn more](en/release-notes/OpenHarmony-v3.0-LTS.md)
This version is upgraded to OpenHarmony 3.0.2 LTS. [Learn more](en/release-notes/OpenHarmony-v3.0.2-LTS.md) This version is upgraded to OpenHarmony 3.0.3 LTS. [Learn more](en/release-notes/OpenHarmony-v3.0.3-LTS.md)
- OpenHarmony 2.2 Beta2. [Learn more](en/release-notes/OpenHarmony-v2.2-beta2.md) - OpenHarmony 2.2 Beta2. [Learn more](en/release-notes/OpenHarmony-v2.2-beta2.md)
......
...@@ -20,7 +20,7 @@ master:最新开发版本。 ...@@ -20,7 +20,7 @@ master:最新开发版本。
发布OpenHarmony 3.1 Release版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.1-release.md) 发布OpenHarmony 3.1 Release版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.1-release.md)
发布OpenHarmony 3.0 LTS版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.0-LTS.md)。该版本已更新至OpenHarmony 3.0.2 LTS,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.0.2-LTS.md) 发布OpenHarmony 3.0 LTS版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.0-LTS.md)。该版本已更新至OpenHarmony 3.0.3 LTS,[了解版本详情](zh-cn/release-notes/OpenHarmony-v3.0.3-LTS.md)
发布 OpenHarmony v2.2 Beta2版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v2.2-beta2.md) 发布 OpenHarmony v2.2 Beta2版本,[了解版本详情](zh-cn/release-notes/OpenHarmony-v2.2-beta2.md)
......
...@@ -10,14 +10,14 @@ OpenHarmony is designed with a layered architecture, which from bottom to top, c ...@@ -10,14 +10,14 @@ OpenHarmony is designed with a layered architecture, which from bottom to top, c
![](figures/1.png) ![](figures/1.png)
**Kernel Layer** **Kernel layer**
- Kernel subsystem: OpenHarmony uses a multi-kernel design \(Linux or LiteOS\) so that different kernels can be selected for devices with different resource limitations. The kernel abstraction layer \(KAL\) hides differences in kernel implementations and provides the upper layer with basic kernel capabilities, including process and thread management, memory management, file system, network management, and peripheral management. - Kernel subsystem: OpenHarmony uses a multi-kernel design \(Linux or LiteOS\) so that different kernels can be selected for devices with different resource limitations. The kernel abstraction layer \(KAL\) hides differences in kernel implementations and provides the upper layer with basic kernel capabilities, including process and thread management, memory management, file system, network management, and peripheral management.
- Driver subsystem: Hardware Driver Foundation \(HDF\) lays the foundation for an open OpenHarmony hardware ecosystem. It allows for unified access from peripheral devices and provides foundation for driver development and management. - Driver subsystem: Hardware Driver Foundation \(HDF\) lays the foundation for an open OpenHarmony hardware ecosystem. It allows for unified access from peripheral devices and provides foundation for driver development and management.
**System Service Layer** **System service layer**
The system service layer provides a complete set of capabilities essential for OpenHarmony to offer services for apps through the framework layer. This layer consists of the following parts: The system service layer provides a complete set of capabilities essential for OpenHarmony to offer services for apps through the framework layer. This layer consists of the following parts:
...@@ -329,6 +329,19 @@ The following table describes the subsystems of OpenHarmony. For details about t ...@@ -329,6 +329,19 @@ The following table describes the subsystems of OpenHarmony. For details about t
</tbody> </tbody>
</table> </table>
## Supported Development Boards<a name="section25831825174123"></a>
Currently, OpenHarmony supports the development boards listed in the following table.
| System Type| Board Model| Chip Model| Function Description| Application Scenario| Code Repository| Daily Build|
| -------- | -------- | -------- | -------- | -------- | -------- | -------- |
| Standard system| Hi3516DV300 | Hi3516DV300 | Hi3516D V300 is a the next-generation system on chip (SoC) for smart HD IP cameras. It integrates the next-generation image signal processor (ISP), H.265 video compression encoder, and high-performance NNIE engine, and delivers exceptional performance in terms of low bit rate, high image quality, intelligent processing and analysis, and low power consumption.| Devices with screens, such as refrigerators and head units.| [device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br>[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)<br>[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon) | http://ci.openharmony.cn/dailybuilds|
| Standard system| Runhe HH-SCDAYU200| RK3568 | Bolstered by the Rockchip RK3568, the HH-SCDAYU200 development board integrates a dual-core GPU and high-efficiency NPU. Its quad-core 64-bit Cortex-A55 processor uses the advanced 22 nm fabrication process and is clocked at up to 2.0 GHz. The board is packed with Bluetooth, WiFi, audio, video, and camera features, with a wide range of expansion ports as well as video input and output ports. It comes with dual GE auto-sensing RJ45 ports, so it can be used in multi-connectivity products, such as network video recorders (NVRs) and industrial gateways.| Video and audio entertainment, smart travel, and smart home, such as kitchen hoods, ovens, and treadmills.| [device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br>[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)<br>[vendor_hihope](https://gitee.com/openharmony/vendor_hihope) |
| Lightweight| Goodix GR5515-STARTER-KIT| GR5515 | The GR5515-STARTER-KIT development board is a Bluetooth 5.1-capable single-mode Bluetooth low energy (BLE) SoC and comes with multifunctional keys and LED indicators.| Smart hardware, such as watches, wristbands, and price tags.| [device_soc_goodix](https://gitee.com/openharmony/device_soc_goodix)<br>[device_board_goodix](https://gitee.com/openharmony/device_board_goodix) |
| Lightweight| Langguo LANGO200| ASR582X | The LANGO200 IoT development board integrates the high-performance WiFi-BLE dual-mode chip ASR5822, external storage chip, voice playing chip, and analog-to-digital converter. It supports common peripheral interfaces like SPI, and can be connected to an external OLED display and infrared remote control.| Connection modules for smart home products.| [device_soc_asrmicro](https://gitee.com/openharmony/device_soc_asrmicro)<br>[device_board_lango](https://gitee.com/openharmony/device_board_lango)<br>[vendor_asrmicro](https://gitee.com/openharmony/vendor_asrmicro) |
| Lightweight| Fn-Link multi-modal V200ZR| BES2600 | The multi-modal V200Z-R development board is a high-performance, multi-functional, and cost-effective AIoT SoC powered by the BES2600WM chip of Bestechnic. It integrates a quad-core ARM processor with a frequency of up to 1 GHz as well as dual-mode WiFi and dual-mode Bluetooth. The board supports the 802.11 a/b/g/n/ and BT/BLE 5.2 standards. It is able to accommodate RAM of up to 42 MB and flash memory of up to 32 MB, and supports the MIPI display serial interface (DSI) and camera serial interface (CSI). It is applicable to various AIoT multi-modal VUI and GUI interaction scenarios.| Smart hardware with screens, such as speakers and watches.| [device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)<br>[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)<br>[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic) |
| Lightweight| BearPi-HM_Nano| Hi3861 | The BearPi-HM_Nano development board is specially designed for OpenHarmony. It is equipped with the highly integrated 2.4 GHz WiFi SoC chip Hi3861, near field communication (NFC) circuits, and standard E53 interfaces, which can be used to connect to smart humidifiers, smart desk lamps, smart security facilities, and intelligent smoke detectors.| Connection devices like smart street lamps, smart logistics sensors, and human body infrared sensors.| [device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br>[device_board_bearpi](https://gitee.com/openharmony/device_board_bearpi)<br>[vendor_bearpi](https://gitee.com/openharmony/vendor_bearpi) |
## Getting Started<a name="section44681652104210"></a> ## Getting Started<a name="section44681652104210"></a>
- Device development: [device-dev/quick-start/Readme.md](device-dev/quick-start/Readme-EN.md) - Device development: [device-dev/quick-start/Readme.md](device-dev/quick-start/Readme-EN.md)
...@@ -361,7 +374,7 @@ For details about how to obtain the source code of OpenHarmony, see [Source Cod ...@@ -361,7 +374,7 @@ For details about how to obtain the source code of OpenHarmony, see [Source Cod
For details about how to join in the OpenHarmony community, see [OpenHarmony Community](https://gitee.com/openharmony/community/blob/master/README.md). For details about how to join in the OpenHarmony community, see [OpenHarmony Community](https://gitee.com/openharmony/community/blob/master/README.md).
For details about how to contribute, see [Contribution](https://gitee.com/openharmony/docs/blob/master/en/contribute/contribution.md). For details about how to contribute, see [How to Contribute](contribute/how-to-contribute.md).
## License Agreement<a name="section1245517472115"></a> ## License Agreement<a name="section1245517472115"></a>
......
...@@ -3,11 +3,19 @@ ...@@ -3,11 +3,19 @@
- [Application Development Overview](application-dev-guide.md) - [Application Development Overview](application-dev-guide.md)
- About OpenHarmony - About OpenHarmony
- [OpenHarmony Project](../OpenHarmony-Overview.md) - [OpenHarmony Project](../OpenHarmony-Overview.md)
- [Glossary](../device-dev/glossary/glossary.md) - [Glossary](../glossary.md)
- [OpenHarmony Release Notes](../release-notes/Readme.md) - [OpenHarmony Release Notes](../release-notes/Readme.md)
- Getting Started - Quick Start
- [Getting Started with Application Development](quick-start/Readme-EN.md) - Getting Started
- [Directory Structure](quick-start/package-structure.md) - - [Preparations](quick-start/start-overview.md)
- [Getting Started with eTS](quick-start/start-with-ets.md)
- [Getting Started with JavaScript in the Traditional Coding Approach](quick-start/start-with-js.md)
- [Getting Started with JavaScript in the Low-Code Approach](quick-start/start-with-js-low-code.md)
- Development Fundamentals
- [Application Development Package Structure (FA Model)](quick-start/package-structure.md)
- [Application Development Package Structure (Stage Model)](quick-start/module-structure.md)
- [Resource File Categories](quick-start/basic-resource-file-categories.md)
- [SysCap](quick-start/syscap.md)
- Development - Development
- [Ability Development](ability/Readme-EN.md) - [Ability Development](ability/Readme-EN.md)
- [UI Development](ui/Readme-EN.md) - [UI Development](ui/Readme-EN.md)
......
...@@ -276,9 +276,9 @@ The basic dependency packages include: ...@@ -276,9 +276,9 @@ The basic dependency packages include:
The following sample is provided to help you better understand how to develop a Data ability: The following sample is provided to help you better understand how to develop a Data ability:
- [eTSDataAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSDataAbility) - [DataAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/DataAbility)
This **eTSDataAbility** sample shows how to: This sample shows how to:
Create a Data ability in the **data.ts** file in the **DataAbility** directory. Create a Data ability in the **data.ts** file in the **DataAbility** directory.
......
...@@ -330,6 +330,6 @@ Now you've got a widget shown below. ...@@ -330,6 +330,6 @@ Now you've got a widget shown below.
The following sample is provided to help you better understand how to develop a widget on the FA model: The following sample is provided to help you better understand how to develop a widget on the FA model:
[eTSFormAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSFormAbility) [FormAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/FormAbility)
This **eTSFormAbility** sample provides a widget. Users can create, update, and delete widgets on the home screen of their phones or by using their own widget host. This sample also implements widget information persistence by using lightweight data storage. This sample provides a widget. Users can create, update, and delete widgets on the home screen of their phones or by using their own widget host. This sample also implements widget information persistence by using lightweight data storage.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
## Overview ## Overview
### Concepts ### Concepts
The Page ability implements the ArkUI and provides the capability of interacting with users. 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 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**.
### Page Ability Lifecycle ### Page Ability Lifecycle
...@@ -39,11 +39,11 @@ The **launchType** item in the **config.json** file is used to specify the launc ...@@ -39,11 +39,11 @@ The **launchType** item in the **config.json** file is used to specify the launc
| Launch Type | Description |Description | | Launch Type | Description |Description |
| ----------- | ------- |---------------- | | ----------- | ------- |---------------- |
| stand | Multi-instance | A new instance is started each time an ability starts.| | standard | Multi-instance | A new instance is started each time an ability starts.|
| singleton | Singleton | Only one instance exists in the system. If an instance already exists when an ability is started, that instance is reused.| | singleton | Singleton | Only one instance exists in the system. If an instance already exists when an ability is started, that instance is reused.|
| specified | Instance-specific| The internal service of an ability determines whether to create multiple instances during running.| | specified | Instance-specific| The internal service of an ability determines whether to create multiple instances during running.|
By default, **stand** is used. By default, **standard** is used.
## Development Guidelines ## Development Guidelines
......
...@@ -77,7 +77,7 @@ To set information about the target Service ability, you can first construct a * ...@@ -77,7 +77,7 @@ To set information about the target Service ability, you can first construct a *
The following code snippet shows how to start a Service ability running on the local device: The following code snippet shows how to start a Service ability running on the local device:
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
let promise = await featureAbility.startAbility( let promise = await featureAbility.startAbility(
{ {
want: want:
...@@ -97,7 +97,7 @@ After the preceding code is executed, the **startAbility()** API is called to st ...@@ -97,7 +97,7 @@ After the preceding code is executed, the **startAbility()** API is called to st
### Stopping a Service ability ### Stopping a Service ability
Once created, the Service ability keeps running in the background. The system does not stop or destroy it unless memory resources must be reclaimed. You can call **terminateSelf()** on a Service ability to stop it or call **stopAbility()** on another ability to stop the specified Service ability. Once created, the Service ability keeps running in the background. The system does not stop or destroy it unless memory resources must be reclaimed. You can call **terminateSelf()** on a Service ability to stop it.
...@@ -126,12 +126,17 @@ function onConnectCallback(element, remote){ ...@@ -126,12 +126,17 @@ function onConnectCallback(element, remote){
let reply = new rpc.MessageParcel(); let reply = new rpc.MessageParcel();
data.writeInt(1); data.writeInt(1);
data.writeInt(99); data.writeInt(99);
await mRemote.sendRequest(1, data, reply, option); mRemote.sendRequest(1, data, reply, option).then((result) => {
let msg = reply.readInt(); console.log('sendRequest success');
prompt.showToast({ let msg = reply.readInt();
message: "onConnectLocalService connect result: " + msg, prompt.showToast({
duration: 3000 message: "onConnectLocalService connect result: " + msg,
duration: 3000
});
}).catch((e) => {
console.log('sendRequest error:' + e);
}); });
} }
function onDisconnectCallback(element){ function onDisconnectCallback(element){
...@@ -146,7 +151,7 @@ function onFailedCallback(code){ ...@@ -146,7 +151,7 @@ function onFailedCallback(code){
The following code snippet shows how to connect to a local Service ability: The following code snippet shows how to connect to a local Service ability:
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
let connId = featureAbility.connectAbility( let connId = featureAbility.connectAbility(
{ {
bundleName: "com.jstest.serviceability", bundleName: "com.jstest.serviceability",
...@@ -234,11 +239,15 @@ function onConnectCallback(element, remote){ ...@@ -234,11 +239,15 @@ function onConnectCallback(element, remote){
let reply = new rpc.MessageParcel(); let reply = new rpc.MessageParcel();
data.writeInt(1); data.writeInt(1);
data.writeInt(99); data.writeInt(99);
await mRemote.sendRequest(1, data, reply, option); mRemote.sendRequest(1, data, reply, option).then((result) => {
let msg = reply.readInt(); console.log('sendRequest success');
prompt.showToast({ let msg = reply.readInt();
message: "onConnectLocalService connect result: " + msg, prompt.showToast({
duration: 3000 message: "onConnectLocalService connect result: " + msg,
duration: 3000
});
}).catch((e) => {
console.log('sendRequest error:' + e);
}); });
} }
...@@ -274,7 +283,7 @@ function getRemoteDeviceId() { ...@@ -274,7 +283,7 @@ function getRemoteDeviceId() {
The following code snippet shows how to connect to a remote Service ability: The following code snippet shows how to connect to a remote Service ability:
```ts ```ts
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
let connId = featureAbility.connectAbility( let connId = featureAbility.connectAbility(
{ {
deviceId: getRemoteDeviceId(), deviceId: getRemoteDeviceId(),
...@@ -386,25 +395,8 @@ export default { ...@@ -386,25 +395,8 @@ export default {
}; };
``` ```
## Development Example ## Samples
### The following sample is provided to help you better understand how to develop a Service ability:
- [eTSServiceAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSServiceAbility)
This **eTSServiceAbility** sample shows how to:
Create a local Service ability in the **service.ts** file in the **ServiceAbility** directory.
Encapsulate the process of starting and connecting to the local Service ability in the **MainAbility** directory.
### The following sample is provided to help you better understand how to develop a remote Service ability:
- [DMS](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS)
This **DMS** sample shows how to:
Create a remote Service ability in the **service.ts** file in the **ServiceAbility** directory.
Encapsulate the process of connecting to the remote Service ability in the **RemoteAbility** directory. The following samples are provided to help you better understand how to develop a Service ability:
- [`ServiceAbility`: Service Ability Creation and Use (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceAbility)
- [`DMS`: Distributed Demo (eTS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS)
...@@ -7,7 +7,7 @@ The stage model is an application development model introduced in API version 9. ...@@ -7,7 +7,7 @@ The stage model is an application development model introduced in API version 9.
- Request certain permissions from end users. - Request certain permissions from end users.
- Notify the ability stage and ability of environment configuration changes. - Notify the ability stage and ability of environment configuration changes.
- Call common components. For details, see [Call Development](stage-call.md). - Call common components. For details, see [Call Development](stage-call.md).
- Connect to and disconnect from the Service ability. For details, see [Service Extension Ability Development](stage-serviceextension.md). - Connect to and disconnect from the Service Extension ability. For details, see [Service Extension Ability Development](stage-serviceextension.md).
- Continue the application on another device. For details, see [Ability Continuation Development](stage-ability-continuation.md). - Continue the application on another device. For details, see [Ability Continuation Development](stage-ability-continuation.md).
### Launch Type ### Launch Type
...@@ -16,11 +16,11 @@ The **launchType** item in the **module.json** file is used to specify the launc ...@@ -16,11 +16,11 @@ The **launchType** item in the **module.json** file is used to specify the launc
| Launch Type | Description |Description | | Launch Type | Description |Description |
| ----------- | ------- |---------------- | | ----------- | ------- |---------------- |
| stand | Multi-instance | A new instance is started each time an ability starts.| | standard | Multi-instance | A new instance is started each time an ability starts.|
| singleton | Singleton | Only one instance exists in the system. If an instance already exists when an ability is started, that instance is reused.| | singleton | Singleton | Only one instance exists in the system. If an instance already exists when an ability is started, that instance is reused.|
| specified | Instance-specific| The internal service of an ability determines whether to create multiple instances during running.| | specified | Instance-specific| The internal service of an ability determines whether to create multiple instances during running.|
By default, **stand** is used. By default, **standard** is used.
## Available APIs ## Available APIs
The table below describes the APIs provided by the **AbilityStage** class, which has the **context** attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md). The table below describes the APIs provided by the **AbilityStage** class, which has the **context** attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md).
...@@ -274,6 +274,6 @@ export default class MainAbility extends Ability { { ...@@ -274,6 +274,6 @@ export default class MainAbility extends Ability { {
## Development Example ## Development Example
The following sample is provided to help you better understand how to develop an ability on the stage model: The following sample is provided to help you better understand how to develop an ability on the stage model:
[eTSStageCallAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSStageCallAbility) [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 is implemented in the **CalleeAbility** directory, and its pages are the content configured in **pages/second**. The callee ability can be started from the main ability. 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 is implemented in the **CalleeAbility** directory, and its pages are the content configured in **pages/second**. The callee ability can be started from the main ability.
...@@ -35,7 +35,7 @@ The following figure shows the basic concepts in the stage model. ...@@ -35,7 +35,7 @@ The following figure shows the basic concepts in the stage model.
- **Application**: runtime class of a bundle, which is invisible to developers in the runtime. - **Application**: runtime class of a bundle, which is invisible to developers in the runtime.
- **Context**: provides various capabilities that can be invoked by developers during the runtime. The **Ability** and **ExtensionAbility** classes have their own context classes, which inherit the base class **Context**. The base class provides information such as the bundle name, module name, and path. - **Context**: provides various capabilities that can be invoked by developers during the runtime. The **Ability** and **ExtensionAbility** classes have their own context classes, which inherit the base class **Context**. The base class provides information such as the bundle name, module name, and path.
- **Ability**: provides lifecycle callback, holds the **AbilityContext** class, and supports component continuation and collaboration. - **Ability**: provides lifecycle callback, holds the **AbilityContext** class, and supports component continuation and collaboration.
- **ExtensionAbility**: general name of scenario-based service extension abilities. The system defines multiple scenario-based **ExtensionAbility** classes, each of which has its own **ExtensionAbilityContext**. - **ExtensionAbility**: general name of scenario-based service extension abilities. The system defines multiple scenario-based **ExtensionAbility** classes, each of which has its own **ExtensionContext**.
- **WindowStage**: local window manager. - **WindowStage**: local window manager.
- **Window**: basic unit managed by the window manager. It has an ArkUI engine instance. - **Window**: basic unit managed by the window manager. It has an ArkUI engine instance.
- **ArkUI Page**: displays declarative ArkUI. - **ArkUI Page**: displays declarative ArkUI.
...@@ -49,6 +49,23 @@ The ability and ability stage lifecycles are the most important concepts in the ...@@ -49,6 +49,23 @@ The ability and ability stage lifecycles are the most important concepts in the
To implement multi-device-form tailoring and multi-window scalability, OpenHarmony decouples the component manager from the window manager. The ability lifecycle defined in the stage model includes only the creation, destruction, foreground, and background states. The gain focus and lose focus states that are closely related to UI content are defined in the window stage. This implements weak coupling between the abilities and windows. On the service side, the window manager notifies the component manager of the foreground and background changes, so the component manager only senses the foreground and background changes but not the focus changes. To implement multi-device-form tailoring and multi-window scalability, OpenHarmony decouples the component manager from the window manager. The ability lifecycle defined in the stage model includes only the creation, destruction, foreground, and background states. The gain focus and lose focus states that are closely related to UI content are defined in the window stage. This implements weak coupling between the abilities and windows. On the service side, the window manager notifies the component manager of the foreground and background changes, so the component manager only senses the foreground and background changes but not the focus changes.
### Ability Instances and Missions
Abilities can be started in any of the following modes:
+ **Singleton**: For each type of ability, only one instance exists in the application process. **Ability1** in the figure below is started in singleton mode.
+ **Standard**: Each time **startAbility** is called, an instance of the specified ability type is created in the application process. **Ability2** in the figure below is started in standard mode.
+ **Specified**: Before creating an **AbilityRecord**, you can create a key for the instance. Each time **startAbility** is called, the system asks the application which ability instance (corresponding to a key) will be used. **Ability3** in the figure below is started in specified mode.
Each ability instance corresponds to a mission in **Launcher Recent**.
The mission corresponding to each ability instance has a snapshot of the ability instance. After the ability instance is destroyed, the ability class information and snapshot are retained in the mission until the user deletes the information or the storage space exceeds the upper limit.
![AbilityComponentInstanceMission](figures/AbilityComponentInstanceMission.png)
### ExtensionAbility Mechanism ### ExtensionAbility Mechanism
Different from the ability used for page display, the extension ability provides a restricted service running environment. It has the following features: Different from the ability used for page display, the extension ability provides a restricted service running environment. It has the following features:
......
...@@ -245,6 +245,6 @@ try { ...@@ -245,6 +245,6 @@ try {
## Development Example ## Development Example
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:
[eTSStageCallAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSStageCallAbility) [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**. 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**.
...@@ -343,6 +343,6 @@ Now you've got a widget shown below. ...@@ -343,6 +343,6 @@ Now you've got a widget shown below.
The following sample is provided to help you better understand how to develop a widget on the stage model: The following sample is provided to help you better understand how to develop a widget on the stage model:
[eTSFormExtAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSFormExtAbility) [FormExtAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/FormExtAbility)
This **eTSFormExtAbility** sample provides a widget. Users can create, update, and delete widgets on the home screen of their phones or by using their own widget host. This sample also implements widget information persistence by using lightweight data storage. This sample provides a widget. Users can create, update, and delete widgets on the home screen of their phones or by using their own widget host. This sample also implements widget information persistence by using lightweight data storage.
...@@ -80,8 +80,8 @@ Declare the Service Extension ability in the **module.json** file by setting its ...@@ -80,8 +80,8 @@ Declare the Service Extension ability in the **module.json** file by setting its
The following sample is provided to help you better understand how to develop a Service Extension ability: The following sample is provided to help you better understand how to develop a Service Extension ability:
- [ServiceExtensionAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/eTSServiceExtAbility) - [ServiceExtensionAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceExtAbility)
This **ServiceExtensionAbility** sample shows how to: This sample shows how to:
Create a Service Extension ability in the **ServiceExtAbility.ts** file in the **ServiceExtensionAbility** directory. Create a Service Extension ability in the **ServiceExtAbility.ts** file in the **ServiceExtensionAbility** directory.
...@@ -6,11 +6,11 @@ The documents are carefully organized as follows: ...@@ -6,11 +6,11 @@ The documents are carefully organized as follows:
### Getting Started ### Getting Started
[Here](quick-start/Readme-EN.md) you can learn how to better prepare yourself for application development. [Here](quick-start/Readme-EN.md) you'll learn how to quickly get started with OpenHarmony application development.
Browse the documents on how to use DevEco Studio and how to quickly build your first application. Browse the documents on the instructions for quickly building your first application and the basics about OpenHarmony applications.
Don't forget to check out the package structure of OpenHarmony applications and resource file categories. Check out the development fundamentals, which comprise descriptions of the package structure configuration file for OpenHarmony applications and the instructions for use of resource files.
### Development ### Development
...@@ -35,6 +35,7 @@ Then, equip yourself for developing the key features, with the following guideli ...@@ -35,6 +35,7 @@ Then, equip yourself for developing the key features, with the following guideli
- [Device Management](device/Readme-EN.md) - [Device Management](device/Readme-EN.md)
- [Device Usage Statistics](device-usage-statistics/Readme-EN.md) - [Device Usage Statistics](device-usage-statistics/Readme-EN.md)
- [DFX](dfx/Readme-EN.md) - [DFX](dfx/Readme-EN.md)
- [Internationalization](internationalization/Readme-EN.md)
### Tools ### Tools
......
...@@ -6,11 +6,11 @@ The documents are carefully organized as follows: ...@@ -6,11 +6,11 @@ The documents are carefully organized as follows:
### Getting Started ### Getting Started
[Here](quick-start/start-overview.md) you can learn how to better prepare yourself for application development. [Here](quick-start/start-overview.md) you'll learn how to quickly get started with OpenHarmony application development.
Browse the documents on how to use DevEco Studio and how to quickly build your first application. Browse the documents on the instructions for quickly building your first application and the basics about OpenHarmony applications.
Don't forget to check out the package structure of OpenHarmony applications and resource file categories. Check out the development fundamentals, which comprise descriptions of the package structure configuration file for OpenHarmony applications and the instructions for use of resource files.
### Development ### Development
...@@ -18,7 +18,7 @@ To facilitate your application development, we provide development guidelines fo ...@@ -18,7 +18,7 @@ To facilitate your application development, we provide development guidelines fo
First thing first, familiarize yourself with the two cornerstone frameworks in OpenHarmony applications: First thing first, familiarize yourself with the two cornerstone frameworks in OpenHarmony applications:
- Application framework: [Ability Development](ability/ability-brief.md) - Application framework: [Ability Development](ability/fa-brief.md)
- UI framework: [UI Development](ui/arkui-overview.md) - UI framework: [UI Development](ui/arkui-overview.md)
All applications should be developed on top of these frameworks. All applications should be developed on top of these frameworks.
...@@ -35,6 +35,7 @@ Then, equip yourself for developing the key features, with the following guideli ...@@ -35,6 +35,7 @@ Then, equip yourself for developing the key features, with the following guideli
- [Device](device/usb-overview.md) - [Device](device/usb-overview.md)
- [Device Usage Statistics](device-usage-statistics/device-usage-statistics-overview.md) - [Device Usage Statistics](device-usage-statistics/device-usage-statistics-overview.md)
- [DFX](dfx/hiappevent-overview.md) - [DFX](dfx/hiappevent-overview.md)
- [Internationalization](internationalization/international-overview.md)
### Tools ### Tools
...@@ -50,6 +51,6 @@ To make you better understand how functions work together and jumpstart your app ...@@ -50,6 +51,6 @@ To make you better understand how functions work together and jumpstart your app
API references encompass all components and APIs available in OpenHarmony, helping you use and integrate APIs more effectively. API references encompass all components and APIs available in OpenHarmony, helping you use and integrate APIs more effectively.
They are organized as follows: They are organized as follows:
- [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/js-components-common-attribute.md) - [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/js-components-common-attributes.md)
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/ts-universal-events-click.md) - [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/ts-universal-events-click.md)
- [API Reference](reference/apis/js-apis-DataUriUtils.md) - [API Reference](reference/apis/js-apis-DataUriUtils.md)
...@@ -2,8 +2,14 @@ ...@@ -2,8 +2,14 @@
- [Application Development Overview](application-dev-guide.md) - [Application Development Overview](application-dev-guide.md)
- Quick Start - Quick Start
- [Directory Structure](quick-start/package-structure.md) - Getting Started
- [Resource File Categories](quick-start/basic-resource-file-categories.md) - [Preparations](quick-start/start-overview.md)
- [Getting Started with eTS](quick-start/start-with-ets.md)
- [Getting Started with JavaScript in the Traditional Coding Approach](quick-start/start-with-js.md)
- [Getting Started with JavaScript in the Low-Code Approach](quick-start/start-with-js-low-code.md)
- Development Fundamentals
- [Directory Structure](quick-start/package-structure.md)
- [Resource File Categories](quick-start/basic-resource-file-categories.md)
- Development - Development
- [Ability Development](ability/Readme-EN.md) - [Ability Development](ability/Readme-EN.md)
- [Ability Framework Overview](ability/ability-brief.md) - [Ability Framework Overview](ability/ability-brief.md)
...@@ -16,8 +22,8 @@ ...@@ -16,8 +22,8 @@
- Other - Other
- [Ability Assistant Usage](ability/ability-assistant-guidelines.md) - [Ability Assistant Usage](ability/ability-assistant-guidelines.md)
- [UI](ui/Readme-EN.md) - UI
- [ArkUI Overview](arkui-overview.md) - [ArkUI Overview](ui/arkui-overview.md)
- JavaScript-based Web-Like Development Paradigm - JavaScript-based Web-Like Development Paradigm
- [Overview](ui/ui-js-overview.md) - [Overview](ui/ui-js-overview.md)
- Framework - Framework
...@@ -45,18 +51,39 @@ ...@@ -45,18 +51,39 @@
- [Defining Page Routes](ui/ui-js-building-ui-routes.md) - [Defining Page Routes](ui/ui-js-building-ui-routes.md)
- Common Component Development Guidelines - Common Component Development Guidelines
- Container Components - Container Components
- [List](ui/ui-js-components-list.md) - [List Development](ui/ui-js-components-list.md)
- [Dialog](ui/ui-js-components-dialog.md) - [Dialog Development](ui/ui-js-components-dialog.md)
- [Form](ui/ui-js-components-form.md) - [Form Development](ui/ui-js-components-form.md)
- [Stepper](ui/ui-js-components-stepper.md) - [Stepper Development](ui/ui-js-components-stepper.md)
- [Tabs](ui/ui-js-component-tabs.md) - [Tabs Development](ui/ui-js-component-tabs.md)
- [Swiper Development](ui/ui-js-components-swiper.md)
- Basic Components - Basic Components
- [Text](ui/ui-js-components-text.md) - [Text Development](ui/ui-js-components-text.md)
- [Input](ui/ui-js-components-input.md) - [Input Development](ui/ui-js-components-input.md)
- [Button](ui/ui-js-components-button.md) - [Button Development](ui/ui-js-components-button.md)
- [Picker](ui/ui-js-components-picker.md) - [Picker Development](ui/ui-js-components-picker.md)
- [Image](ui/ui-js-components-images.md) - [Image Development](ui/ui-js-components-images.md)
- Animation Development Guidelines - [Image-animator Development](ui/ui-js-components-image-animator.md)
- [Rating Development](ui/ui-js-components-rating.md)
- [Slider Development](ui/ui-js-components-slider.md)
- [Chart Development](ui/ui-js-components-chart.md)
- [Switch Development](ui/ui-js-components-switch.md)
- [Toolbar Development](ui/ui-js-components-toolbar.md)
- [Menu Development](ui/ui-js-components-menu.md)
- [Marquee Development](ui/ui-js-components-marquee.md)
- [Qrcode Development](ui/ui-js-components-qrcode.md)
- [Search Development](ui/ui-js-components-search.md)
- Canvas Development
- [CanvasRenderingContext2D](ui/ui-js-components-canvasrenderingcontext2d.md)
- [Path2D](ui/ui-js-components-path2d.md)
- [OffscreenCanvas](ui/ui-js-components-offscreencanvas.md)
- [Grid-container Development](ui/ui-js-components-calendar.md)
- Svg
- [Basics](ui/ui-js-components-svg-overview.md)
- [Graph Drawing](ui/ui-js-components-svg-graphics.md)
- [Path Drawing](ui/ui-js-components-svg-path.md)
- [Text Drawing](ui/ui-js-components-svg-text.md)
- Animation Development Guidelines
- CSS Animation - CSS Animation
- [Defining Attribute Style Animations](ui/ui-js-animate-attribute-style.md) - [Defining Attribute Style Animations](ui/ui-js-animate-attribute-style.md)
- [Defining Animations with the transform Attribute](ui/ui-js-animate-transform.md) - [Defining Animations with the transform Attribute](ui/ui-js-animate-transform.md)
...@@ -122,6 +149,13 @@ ...@@ -122,6 +149,13 @@
- [Custom Component Lifecycle Callbacks](ui/ts-custom-component-lifecycle-callbacks.md) - [Custom Component Lifecycle Callbacks](ui/ts-custom-component-lifecycle-callbacks.md)
- [Example: Component Creation and Re-Initialization](ui/ts-component-creation-re-initialization.md) - [Example: Component Creation and Re-Initialization](ui/ts-component-creation-re-initialization.md)
- [Syntactic Sugar](ui/ts-syntactic-sugar.md) - [Syntactic Sugar](ui/ts-syntactic-sugar.md)
- Common Component Development Guidelines
- [Button](ui/ui-ts-basic-components-button.md)
- [Web](ui/ui-ts-components-web.md)
- Common Layout Development Guidelines
- [Flex Layout](ui/ui-ts-layout-flex.md)
- [Grid Layout](ui/ui-ts-layout-grid-container.md)
- [Media Query](ui/ui-ts-layout-mediaquery.md)
- Experiencing the Declarative UI - Experiencing the Declarative UI
- [Creating a Declarative UI Project](ui/ui-ts-creating-project.md) - [Creating a Declarative UI Project](ui/ui-ts-creating-project.md)
- [Getting to Know Components](ui/ui-ts-components.md) - [Getting to Know Components](ui/ui-ts-components.md)
...@@ -149,9 +183,9 @@ ...@@ -149,9 +183,9 @@
- Audio - Audio
- [Audio Overview](media/audio-overview.md) - [Audio Overview](media/audio-overview.md)
- [Audio Playback Development](media/audio-playback.md) - [Audio Playback Development](media/audio-playback.md)
- [Audio Playback Development Using AudioRenderer](media/audio-renderer.md) - [Audio Rendering Development](media/audio-renderer.md)
- [Audio Recording Development](media/audio-recorder.md) - [Audio Recording Development](media/audio-recorder.md)
- [Audio Recorder Development Using AudioCapturer](media/audio-capturer) - [Audio Capture Development](media/audio-capturer)
- Video - Video
- [Video Playback Development](media/video-playback.md) - [Video Playback Development](media/video-playback.md)
- [Video Recording Development](media/video-recorder.md) - [Video Recording Development](media/video-recorder.md)
...@@ -195,11 +229,8 @@ ...@@ -195,11 +229,8 @@
- Sensor - Sensor
- [Sensor Overview](device/sensor-overview.md) - [Sensor Overview](device/sensor-overview.md)
- [Sensor Development](device/sensor-guidelines.md) - [Sensor Development](device/sensor-guidelines.md)
- Sensor
- [Sensor Overview](device/sensor-overview.md)
- [Sensor Development](device/sensor-guidelines.md)
- Vibrator - Vibrator
- [vibrator-Overview.md](device/vibrator-overview.md) - [Vibrator Overview](device/vibrator-overview.md)
- [Vibrator Development](device/vibrator-guidelines.md) - [Vibrator Development](device/vibrator-guidelines.md)
- Device Usage Statistics - Device Usage Statistics
- [Device Usage Statistics Overview](device-usage-statistics/device-usage-statistics-overview.md) - [Device Usage Statistics Overview](device-usage-statistics/device-usage-statistics-overview.md)
...@@ -214,6 +245,10 @@ ...@@ -214,6 +245,10 @@
- Distributed Call Chain Tracing - Distributed Call Chain Tracing
- [Overview of Distributed Call Chain Tracing](dfx/hitracechain-overview.md) - [Overview of Distributed Call Chain Tracing](dfx/hitracechain-overview.md)
- [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md) - [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md)
- Internationalization
- [Overview](internationalization/international-overview.md)
- [Internationalization Development (intl)](internationalization/intl-guidelines.md)
- [Internationalization Development (i18n)](internationalization/i18n-guidelines.md)
- Tools - Tools
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- Hands-On Tutorials - Hands-On Tutorials
...@@ -469,9 +504,9 @@ ...@@ -469,9 +504,9 @@
- [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md)
- APIs - APIs
- Ability Framework - Ability Framework
- [@ohos.ability.dataUriUtils](reference/apis/js-apis-DataUriUtils.md) - [@ohos.ability.dataUriUtils](reference/apis/js-apis-DataUriUtils.md)
- [@ohos.ability.errorCode ](reference/apis/js-apis-ability-errorcode.md) - [@ohos.ability.errorCode ](reference/apis/js-apis-ability-errorCode.md)
- [@ohos.ability.wantConstant](reference/apis/js-apis-ability-wantConstant.md) - [@ohos.ability.wantConstant](reference/apis/js-apis-ability-wantConstant.md)
- [@ohos.application.Ability](reference/apis/js-apis-application-ability.md) - [@ohos.application.Ability](reference/apis/js-apis-application-ability.md)
- [@ohos.application.AbilityConstant](reference/apis/js-apis-application-abilityConstant.md) - [@ohos.application.AbilityConstant](reference/apis/js-apis-application-abilityConstant.md)
...@@ -513,65 +548,69 @@ ...@@ -513,65 +548,69 @@
- [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md) - [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md)
- [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md) - [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md)
- [shellCmdResult](reference/apis/js-apis-application-shellCmdResult.md) - [shellCmdResult](reference/apis/js-apis-application-shellCmdResult.md)
- Common Event and Notification - Common Event and Notification
- [@ohos.commonEvent](reference/apis/js-apis-commonEvent.md) - [@ohos.commonEvent](reference/apis/js-apis-commonEvent.md)
- [@ohos.events.emitter](reference/apis/js-apis-emitter.md) - [@ohos.events.emitter](reference/apis/js-apis-emitter.md)
- [@ohos.notification](reference/apis/js-apis-notification.md) - [@ohos.notification](reference/apis/js-apis-notification.md)
- [@ohos.reminderAgent](reference/apis/js-apis-reminderAgent.md) - [@ohos.reminderAgent](reference/apis/js-apis-reminderAgent.md)
- [EventHub](reference/apis/js-apis-eventhub.md) - [EventHub](reference/apis/js-apis-eventhub.md)
- Bundle Management - Bundle Management
- [@ohos.bundle](reference/apis/js-apis-Bundle.md) - [@ohos.bundle](reference/apis/js-apis-Bundle.md)
- [@ohos.bundleState ](reference/apis/js-apis-deviceUsageStatistics.md) - [@ohos.bundleState ](reference/apis/js-apis-deviceUsageStatistics.md)
- [@ohos.zlib](reference/apis/js-apis-zlib.md) - [@ohos.zlib](reference/apis/js-apis-zlib.md)
- UI Page - UI Page
- [@ohos.animator](reference/apis/js-apis-animator.md) - [@ohos.animator](reference/apis/js-apis-animator.md)
- [@ohos.mediaquery](reference/apis/js-apis-mediaquery.md)
- [@ohos.prompt](reference/apis/js-apis-prompt.md)
- [@ohos.router](reference/apis/js-apis-router.md)
- Graphics - Graphics
- [@ohos.display ](reference/apis/js-apis-display.md) - [@ohos.display ](reference/apis/js-apis-display.md)
- [@ohos.screenshot](reference/apis/js-apis-screenshot.md) - [@ohos.screenshot](reference/apis/js-apis-screenshot.md)
- [@ohos.window](reference/apis/js-apis-window.md) - [@ohos.window](reference/apis/js-apis-window.md)
- [webgl](reference/apis/js-apis-webgl.md) - [webgl](reference/apis/js-apis-webgl.md)
- [webgl2](reference/apis/js-apis-webgl2.md) - [webgl2](reference/apis/js-apis-webgl2.md)
- Media - Media
- [@ohos.multimedia.audio](reference/apis/js-apis-audio.md) - [@ohos.multimedia.audio](reference/apis/js-apis-audio.md)
- [@ohos.multimedia.camera](reference/apis/js-apis-camera.md) - [@ohos.multimedia.camera](reference/apis/js-apis-camera.md)
- [@ohos.multimedia.image](reference/apis/js-apis-image.md) - [@ohos.multimedia.image](reference/apis/js-apis-image.md)
- [@ohos.multimedia.media](reference/apis/js-apis-media.md) - [@ohos.multimedia.media](reference/apis/js-apis-media.md)
- [@ohos.multimedia.medialibrary](reference/apis/js-apis-medialibrary.md) - [@ohos.multimedia.medialibrary](reference/apis/js-apis-medialibrary.md)
- Resource Management - Resource Management
- [@ohos.i18n](reference/apis/js-apis-i18n.md) - [@ohos.i18n](reference/apis/js-apis-i18n.md)
- [@ohos.intl](reference/apis/js-apis-intl.md) - [@ohos.intl](reference/apis/js-apis-intl.md)
- [@ohos.resourceManager](reference/apis/js-apis-resource-manager.md) - [@ohos.resourceManager](reference/apis/js-apis-resource-manager.md)
- Resource Scheduling - Resource Scheduling
- [@ohos.backgroundTaskManager](reference/apis/js-apis-backgroundTaskManager.md) - [@ohos.backgroundTaskManager](reference/apis/js-apis-backgroundTaskManager.md)
- [@ohos.workScheduler ](reference/apis/js-apis-workScheduler.md) - [@ohos.workScheduler ](reference/apis/js-apis-workScheduler.md)
- [@ohos.WorkSchedulerExtensionAbility](reference/apis/js-apis-WorkSchedulerExtensionAbility.md) - [@ohos.WorkSchedulerExtensionAbility](reference/apis/js-apis-WorkSchedulerExtensionAbility.md)
- Custom Management - Custom Management
- [@ohos.configPolicy](reference/apis/js-apis-config-policy.md) - [@ohos.configPolicy](reference/apis/js-apis-config-policy.md)
- [@ohos.enterpriseDeviceManager](reference/apis/js-apis-enterprise-device-manager.md) - [@ohos.enterpriseDeviceManager](reference/apis/js-apis-enterprise-device-manager.md)
- Security - Security
- [@ohos.abilityAccessCtrl](reference/apis/js-apis-abilityAccessCtrl.md) - [@ohos.abilityAccessCtrl](reference/apis/js-apis-abilityAccessCtrl.md)
- [@ohos.security.huks ](reference/apis/js-apis-huks.md) - [@ohos.security.huks ](reference/apis/js-apis-huks.md)
- [@ohos.userIAM.userAuth ](reference/apis/js-apis-useriam-userauth.md) - [@ohos.userIAM.userAuth ](reference/apis/js-apis-useriam-userauth.md)
- [@system.cipher](reference/apis/js-apis-system-cipher.md)
- Data Management - Data Management
- [@ohos.data.dataAbility ](reference/apis/js-apis-data-ability.md) - [@ohos.data.dataAbility ](reference/apis/js-apis-data-ability.md)
- [@ohos.data.distributedData](reference/apis/js-apis-distributed-data.md) - [@ohos.data.distributedData](reference/apis/js-apis-distributed-data.md)
- [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md) - [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md)
...@@ -579,18 +618,18 @@ ...@@ -579,18 +618,18 @@
- [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md) - [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md)
- [@ohos.settings](reference/apis/js-apis-settings.md) - [@ohos.settings](reference/apis/js-apis-settings.md)
- [resultSet](reference/apis/js-apis-data-resultset.md) - [resultSet](reference/apis/js-apis-data-resultset.md)
- File Management - File Management
- [@ohos.environment](reference/apis/js-apis-environment.md) - [@ohos.environment](reference/apis/js-apis-environment.md)
- [@ohos.fileio](reference/apis/js-apis-fileio.md) - [@ohos.fileio](reference/apis/js-apis-fileio.md)
- [@ohos.fileManager](reference/apis/js-apis-filemanager.md) - [@ohos.fileManager](reference/apis/js-apis-filemanager.md)
- [@ohos.statfs](reference/apis/js-apis-statfs.md) - [@ohos.statfs](reference/apis/js-apis-statfs.md)
- [@ohos.storageStatistics](reference/apis/js-apis-storage-statistics.md) - [@ohos.storageStatistics](reference/apis/js-apis-storage-statistics.md)
- [@ohos.volumeManager](reference/apis/js-apis-volumemanager.md) - [@ohos.volumeManager](reference/apis/js-apis-volumemanager.md)
- Telephony Service - Telephony Service
- [@ohos.contact](reference/apis/js-apis-contact.md) - [@ohos.contact](reference/apis/js-apis-contact.md)
- [@ohos.telephony.call](reference/apis/js-apis-call.md) - [@ohos.telephony.call](reference/apis/js-apis-call.md)
- [@ohos.telephony.observer](reference/apis/js-apis-observer.md) - [@ohos.telephony.observer](reference/apis/js-apis-observer.md)
...@@ -598,23 +637,24 @@ ...@@ -598,23 +637,24 @@
- [@ohos.telephony.sim](reference/apis/js-apis-sim.md) - [@ohos.telephony.sim](reference/apis/js-apis-sim.md)
- [@ohos.telephony.sms](reference/apis/js-apis-sms.md) - [@ohos.telephony.sms](reference/apis/js-apis-sms.md)
- [@ohos.telephony.data](reference/apis/js-apis-telephony-data.md) - [@ohos.telephony.data](reference/apis/js-apis-telephony-data.md)
- Network Management - Network Management
- [@ohos.net.connection](reference/apis/js-apis-net-connection.md) - [@ohos.net.connection](reference/apis/js-apis-net-connection.md)
- [@ohos.net.http](reference/apis/js-apis-http.md) - [@ohos.net.http](reference/apis/js-apis-http.md)
- [@ohos.request](reference/apis/js-apis-request.md) - [@ohos.request](reference/apis/js-apis-request.md)
- [@ohos.net.socket](reference/apis/js-apis-socket.md) - [@ohos.net.socket](reference/apis/js-apis-socket.md)
- [@ohos.net.webSocket](reference/apis/js-apis-webSocket.md) - [@ohos.net.webSocket](reference/apis/js-apis-webSocket.md)
- Connectivity - Connectivity
- [@ohos.bluetooth](reference/apis/js-apis-bluetooth.md) - [@ohos.bluetooth](reference/apis/js-apis-bluetooth.md)
- [@ohos.connectedTag](reference/apis/js-apis-connectedTag.md)
- [@ohos.rpc](reference/apis/js-apis-rpc.md) - [@ohos.rpc](reference/apis/js-apis-rpc.md)
- [@ohos.wifi](reference/apis/js-apis-wifi.md) - [@ohos.wifi](reference/apis/js-apis-wifi.md)
- [@ohos.wifiext](reference/apis/js-apis-wifiext.md) - [@ohos.wifiext](reference/apis/js-apis-wifiext.md)
- Basic Features - Basic Features
- [@ohos.accessibility](reference/apis/js-apis-accessibility.md) - [@ohos.accessibility](reference/apis/js-apis-accessibility.md)
- [@ohos.faultLogger](reference/apis/js-apis-faultLogger.md) - [@ohos.faultLogger](reference/apis/js-apis-faultLogger.md)
- [@ohos.hiAppEvent](reference/apis/js-apis-hiappevent.md) - [@ohos.hiAppEvent](reference/apis/js-apis-hiappevent.md)
...@@ -630,9 +670,9 @@ ...@@ -630,9 +670,9 @@
- [@ohos.systemTime](reference/apis/js-apis-system-time.md) - [@ohos.systemTime](reference/apis/js-apis-system-time.md)
- [@ohos.wallpaper](reference/apis/js-apis-wallpaper.md) - [@ohos.wallpaper](reference/apis/js-apis-wallpaper.md)
- [Timer](reference/apis/js-apis-timer.md) - [Timer](reference/apis/js-apis-timer.md)
- Device Management - Device Management
- [@ohos.batteryInfo ](reference/apis/js-apis-battery-info.md) - [@ohos.batteryInfo ](reference/apis/js-apis-battery-info.md)
- [@ohos.brightness](reference/apis/js-apis-brightness.md) - [@ohos.brightness](reference/apis/js-apis-brightness.md)
- [@ohos.deviceInfo](reference/apis/js-apis-device-info.md) - [@ohos.deviceInfo](reference/apis/js-apis-device-info.md)
...@@ -650,15 +690,15 @@ ...@@ -650,15 +690,15 @@
- [@ohos.update](reference/apis/js-apis-update.md) - [@ohos.update](reference/apis/js-apis-update.md)
- [@ohos.usb](reference/apis/js-apis-usb.md) - [@ohos.usb](reference/apis/js-apis-usb.md)
- [@ohos.vibrator](reference/apis/js-apis-vibrator.md) - [@ohos.vibrator](reference/apis/js-apis-vibrator.md)
- Account Management - Account Management
- [@ohos.account.appAccount](reference/apis/js-apis-appAccount.md) - [@ohos.account.appAccount](reference/apis/js-apis-appAccount.md)
- [@ohos.account.distributedAccount](reference/apis/js-apis-distributed-account.md) - [@ohos.account.distributedAccount](reference/apis/js-apis-distributed-account.md)
- [@ohos.account.osAccount](reference/apis/js-apis-osAccount.md) - [@ohos.account.osAccount](reference/apis/js-apis-osAccount.md)
- Language Base Class Library - Language Base Class Library
- [@ohos.convertxml](reference/apis/js-apis-convertxml.md) - [@ohos.convertxml](reference/apis/js-apis-convertxml.md)
- [@ohos.process](reference/apis/js-apis-process.md) - [@ohos.process](reference/apis/js-apis-process.md)
- [@ohos.uri](reference/apis/js-apis-uri.md) - [@ohos.uri](reference/apis/js-apis-uri.md)
...@@ -680,19 +720,30 @@ ...@@ -680,19 +720,30 @@
- [@ohos.util.Vector](reference/apis/js-apis-vector.md) - [@ohos.util.Vector](reference/apis/js-apis-vector.md)
- [@ohos.worker](reference/apis/js-apis-worker.md) - [@ohos.worker](reference/apis/js-apis-worker.md)
- [@ohos.xml](reference/apis/js-apis-xml.md) - [@ohos.xml](reference/apis/js-apis-xml.md)
- Test - Test
- [@ohos.application.testRunner](reference/apis/js-apis-testRunner.md) - [@ohos.application.testRunner](reference/apis/js-apis-testRunner.md)
- [@ohos.uitest](reference/apis/js-apis-uitest.md) - [@ohos.uitest](reference/apis/js-apis-uitest.md)
- APIs No Longer Maintained - APIs No Longer Maintained
- [@ohos.bytrace](reference/apis/js-apis-bytrace.md) - [@ohos.bytrace](reference/apis/js-apis-bytrace.md)
- [@ohos.data.storage](reference/apis/js-apis-data-storage.md) - [@ohos.data.storage](reference/apis/js-apis-data-storage.md)
- [@system.app](reference/apis/js-apis-system-app.md) - [@system.app](reference/apis/js-apis-system-app.md)
- [@system.bluetooth](reference/apis/js-apis-system-bluetooth.md) - [@system.battery](reference/apis/js-apis-system-battery.md)
- [@system.brightness](reference/apis/js-apis-system-brightness.md)
- [@system.configuration](reference/apis/js-apis-system-configuration.md)
- [@system.device](reference/apis/js-apis-system-device.md)
- [@system.fetch](reference/apis/js-apis-system-fetch.md)
- [@system.file](reference/apis/js-apis-system-file.md)
- [@system.geolocation](reference/apis/js-apis-system-location.md)
- [@system.mediaquery](reference/apis/js-apis-system-mediaquery.md) - [@system.mediaquery](reference/apis/js-apis-system-mediaquery.md)
- [@system.network](reference/apis/js-apis-system-network.md)
- [@system.package](reference/apis/js-apis-system-package.md)
- [@system.prompt](reference/apis/js-apis-system-prompt.md)
- [@system.request](reference/apis/js-apis-system-request.md)
- [@system.router](reference/apis/js-apis-system-router.md) - [@system.router](reference/apis/js-apis-system-router.md)
- [@system.sensor](reference/apis/js-apis-system-sensor.md) - [@system.sensor](reference/apis/js-apis-system-sensor.md)
- [@system.storage](reference/apis/js-apis-system-storage.md)
- [@system.vibrator](reference/apis/js-apis-system-vibrate.md) - [@system.vibrator](reference/apis/js-apis-system-vibrate.md)
- [console](reference/apis/js-apis-logs.md) - [console](reference/apis/js-apis-logs.md)
\ No newline at end of file
...@@ -350,7 +350,7 @@ You can set your application to call the **ReminderRequest** class to create s ...@@ -350,7 +350,7 @@ You can set your application to call the **ReminderRequest** class to create s
**ReminderRequestCalendar** extends **ReminderRequest** and defines a reminder for a calendar event. **ReminderRequestCalendar** extends **ReminderRequest** and defines a reminder for a calendar event.
For the application to run properly, if both **repeatMonths** and **repeatDays** are not specified, the earliest reminder time must be later than the current time. For the application to run properly, if both **repeatMonths** and **repeatDays** are not specified, the earliest reminder time must be later than the current time.
**Table 8** ReminderRequestCalendar instance **Table 8** ReminderRequestCalendar instance
...@@ -542,7 +542,7 @@ For the application to run properly, if both **repeatMonths** and **repeatDays** ...@@ -542,7 +542,7 @@ For the application to run properly, if both **repeatMonths** and **repeatDays**
## How to Develop<a name="section4207112818418"></a> ## How to Develop<a name="section4207112818418"></a>
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE:**
>To publish a reminder, your application needs to apply for the **ohos.permission.PUBLISH\_AGENT\_REMINDER** permission. >To publish a reminder, your application needs to apply for the **ohos.permission.PUBLISH\_AGENT\_REMINDER** permission.
Publish a 10-second countdown reminder. Publish a 10-second countdown reminder.
...@@ -553,7 +553,10 @@ Publish a 10-second countdown reminder. ...@@ -553,7 +553,10 @@ Publish a 10-second countdown reminder.
import reminderAgent from '@ohos.reminderAgent'; import reminderAgent from '@ohos.reminderAgent';
import notification from '@ohos.notification'; import notification from '@ohos.notification';
export default { export default {
timer: { // In JS Project:
// timer: {
// In eTS Project:
let timer : reminderAgent.ReminderRequestTimer = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10, triggerTimeInSeconds: 10,
actionButton: [ actionButton: [
...@@ -563,12 +566,12 @@ Publish a 10-second countdown reminder. ...@@ -563,12 +566,12 @@ Publish a 10-second countdown reminder.
} }
], ],
wantAgent: { wantAgent: {
pkgName: "com.example.phone", pkgName: "com.example.device",
abilityName: "com.example.phone.MainAbility" abilityName: "com.example.device.MainAbility"
}, },
maxScreenWantAgent: { maxScreenWantAgent: {
pkgName: "com.example.phone", pkgName: "com.example.device",
abilityName: "com.example.phone.MainAbility" abilityName: "com.example.device.MainAbility"
}, },
title: "this is title", title: "this is title",
content: "this is content", content: "this is content",
...@@ -602,7 +605,10 @@ Publish a 10-second countdown reminder. ...@@ -602,7 +605,10 @@ Publish a 10-second countdown reminder.
Sample code for defining a calendar reminder instance: Sample code for defining a calendar reminder instance:
``` ```
calendar: { // In JS Project:
// calendar: {
// In eTS Project:
let calendar : reminderAgent.ReminderRequestCalendar = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_CALENDAR, reminderType: reminderAgent.ReminderType.REMINDER_TYPE_CALENDAR,
dateTime: { dateTime: {
year: 2050, year: 2050,
...@@ -625,12 +631,12 @@ calendar: { ...@@ -625,12 +631,12 @@ calendar: {
}, },
], ],
wantAgent: { wantAgent: {
pkgName: "com.example.phone", pkgName: "com.example.device",
abilityName: "com.example.phone.MainAbility" abilityName: "com.example.device.MainAbility"
}, },
maxScreenWantAgent: { maxScreenWantAgent: {
pkgName: "com.example.phone", pkgName: "com.example.device",
abilityName: "com.example.phone.MainAbility" abilityName: "com.example.device.MainAbility"
}, },
ringDuration: 5, ringDuration: 5,
snoozeTimes: 2, snoozeTimes: 2,
...@@ -647,7 +653,10 @@ calendar: { ...@@ -647,7 +653,10 @@ calendar: {
Sample code for defining an alarm reminder instance: Sample code for defining an alarm reminder instance:
``` ```
alarm: { // In JS Project:
// alarm: {
// In eTS Project:
let alarm : reminderAgent.ReminderRequestAlarm = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_ALARM, reminderType: reminderAgent.ReminderType.REMINDER_TYPE_ALARM,
hour: 11, hour: 11,
minute: 14, minute: 14,
...@@ -663,12 +672,12 @@ alarm: { ...@@ -663,12 +672,12 @@ alarm: {
}, },
], ],
wantAgent: { wantAgent: {
pkgName: "com.example.phone", pkgName: "com.example.device",
abilityName: "com.example.phone.MainAbility" abilityName: "com.example.device.MainAbility"
}, },
maxScreenWantAgent: { maxScreenWantAgent: {
pkgName: "com.example.phone", pkgName: "com.example.device",
abilityName: "com.example.phone.MainAbility" abilityName: "com.example.device.MainAbility"
}, },
ringDuration: 5, ringDuration: 5,
snoozeTimes: 2, snoozeTimes: 2,
......
...@@ -120,7 +120,7 @@ For details about **wantAgent**, see [WantAgent](../reference/apis/js-apis-wantA ...@@ -120,7 +120,7 @@ For details about **wantAgent**, see [WantAgent](../reference/apis/js-apis-wantA
| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection.| multiDeviceConnection | | MULTI_DEVICE_CONNECTION | 6 | Multi-device connection.| multiDeviceConnection |
| WIFI_INTERACTION | 7 | WLAN-related task (reserved).| wifiInteraction | | WIFI_INTERACTION | 7 | WLAN-related task (reserved).| wifiInteraction |
| VOIP | 8 | Voice and video call (reserved).| voip | | VOIP | 8 | Voice and video call (reserved).| voip |
| TASK_KEEPING | 9 | Computing task (for PC only).| taskKeeping | | TASK_KEEPING | 9 | Computing task (for specific devices only).| taskKeeping |
## How to Develop ## How to Develop
......
...@@ -28,9 +28,9 @@ Adhere to the following constraints and rules when using transient tasks: ...@@ -28,9 +28,9 @@ Adhere to the following constraints and rules when using transient tasks:
- **When to request**: An application can request a transient task only when it is running in the foreground or before it is suspended in the background. Otherwise, the application may be suspended, resulting in request failure. By default, an application has 6–12 seconds of running time (subject to the application scenario) before it is suspended in the background. - **When to request**: An application can request a transient task only when it is running in the foreground or before it is suspended in the background. Otherwise, the application may be suspended, resulting in request failure. By default, an application has 6–12 seconds of running time (subject to the application scenario) before it is suspended in the background.
- **Timeout**: The system notifies the application of the suspension delay timeout by using a callback. The application must then cancel the delayed suspension or apply for delayed suspension again. Otherwise, the application will be forcibly suspended. - **Timeout**: If a suspension delay is about to time out, the system notifies the application of the timeout by using a callback. The application must then cancel the delayed suspension. Otherwise, the application will be forcibly terminated.
- **When to cancel**: The requesting application shall cancel the request when the transient task is complete. If the request is forcibly canceled by the system, the time frame allowed for the application to run in the background will be affected. - **When to cancel**: The requesting application shall proactively cancel the request when the transient task is complete, rather than waiting for a system callback. Otherwise, the time frame allowed for the application to run in the background will be affected.
- **Quota mechanism**: To prevent abuse of the keepalive, each application has a certain quota every day (dynamically adjusted based on user habits). After using up the quota, an application cannot request transient tasks. Therefore, applications should cancel their request immediately after the transient tasks are complete, to avoid quota consumption. (Note: The quota refers to the requested duration and does not include the time when the application runs in the background.) - **Quota mechanism**: To prevent abuse of the keepalive, each application has a certain quota every day (dynamically adjusted based on user habits). After using up the quota, an application cannot request transient tasks. Therefore, applications should cancel their request immediately after the transient tasks are complete, to avoid quota consumption. (Note: The quota refers to the requested duration and does not include the time when the application runs in the background.)
...@@ -52,7 +52,7 @@ OpenHarmony provides 9 background modes for services that require continuous tas ...@@ -52,7 +52,7 @@ OpenHarmony provides 9 background modes for services that require continuous tas
| multiDeviceConnection | Distributed interconnection| A distributed task is running.| | | multiDeviceConnection | Distributed interconnection| A distributed task is running.| |
| wifiInteraction | WLAN transmission| A WLAN-related task is running.| System API, which is available only to system applications| | wifiInteraction | WLAN transmission| A WLAN-related task is running.| System API, which is available only to system applications|
| voip | Voice and video calls over VoIP| A call-related task is running.| System API, which is available only to system applications| | voip | Voice and video calls over VoIP| A call-related task is running.| System API, which is available only to system applications|
| taskKeeping | Computing task| A computing task is running| PC-specific, valid only on PCs| | taskKeeping | Computing task| A computing task is running| Effective only for specific devices|
### Restrictions on Using Continuous Tasks ### Restrictions on Using Continuous Tasks
- If a user triggers a perceivable task, such as broadcasting and navigation, the corresponding background mode is triggered. When the task is started, the system forcibly displays a notification to the user. - If a user triggers a perceivable task, such as broadcasting and navigation, the corresponding background mode is triggered. When the task is started, the system forcibly displays a notification to the user.
......
# Connectivity # Connectivity
- [IPC & RPC](ipc-rpc.md) - [IPC & RPC]
- [IPC & RPC Overview](ipc-rpc-overview.md) - [IPC & RPC Overview](ipc-rpc-overview.md)
- [IPC & RPC Development Guidelines](ipc-rpc-development-guideline.md)
- [IPC & RPC Development](ipc-rpc-development-guideline.md)
- [Subscribing to State Changes of a Remote Object](subscribe-remote-state.md) - [Subscribing to State Changes of a Remote Object](subscribe-remote-state.md)
# IPC & RPC Development Guidelines<a name="EN-US_TOPIC_0000001103710988"></a> # IPC & RPC Development<a name="EN-US_TOPIC_0000001103710988"></a>
## When to Use<a name="section18502174174019"></a> ## When to Use<a name="section18502174174019"></a>
......
...@@ -15,7 +15,7 @@ Call **createDistributedObject()** to create a distributed data object instance. ...@@ -15,7 +15,7 @@ Call **createDistributedObject()** to create a distributed data object instance.
**Table 1** API for creating a distributed data object instance **Table 1** API for creating a distributed data object instance
| Package| API| Description| | Package| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.| | ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.<br>- &nbsp;**source**: attributes of the **distributedObject** set.<br>- &nbsp;**DistributedObject**: returns the distributed object created.|
### Generating a Session ID ### Generating a Session ID
...@@ -33,7 +33,7 @@ Call setSessionId() to set the session ID for a distributed data object. The ses ...@@ -33,7 +33,7 @@ Call setSessionId() to set the session ID for a distributed data object. The ses
**Table 3** API for setting a session ID **Table 3** API for setting a session ID
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.| | DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.<br>&nbsp;**sessionId**: ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
### Observing Data Changes ### Observing Data Changes
...@@ -43,7 +43,7 @@ Call **on()** to subscribe to data changes of a distributed data object. When th ...@@ -43,7 +43,7 @@ Call **on()** to subscribe to data changes of a distributed data object. When th
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Subscribes to data changes.| | DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Subscribes to data changes.|
| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Unsubscribes from data changes.| | DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Unsubscribes from data changes. Callback used to return changes of the distributed object. If this parameter is not specified, all callbacks related to data changes will be unregistered.|
### Observing Online or Offline Status ### Observing Online or Offline Status
...@@ -72,6 +72,7 @@ The following example shows how to implement a distributed data object synchroni ...@@ -72,6 +72,7 @@ The following example shows how to implement a distributed data object synchroni
```js ```js
var local_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true, var local_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true,
parent:undefined, list:undefined}); parent:undefined, list:undefined});
var sessionId = distributedObject.genSessionId();
``` ```
...@@ -82,13 +83,13 @@ The following example shows how to implement a distributed data object synchroni ...@@ -82,13 +83,13 @@ The following example shows how to implement a distributed data object synchroni
```js ```js
// Local object // Local object
var local_object = distributedObject.createDistributedObject({name:"jack", age:18, isVis:true, var local_object = distributedObject.createDistributedObject({name:"jack", age:18, isVis:true,
parent:{mother:"jack mom",father:"jack Dad"},[{mother:"jack mom"}, {father:"jack Dad"}]}; parent:{mother:"jack mom",father:"jack Dad"},list:[{mother:"jack mom"}, {father:"jack Dad"}]});
local_object.setsessionId(sessionId); local_object.setSessionId(sessionId);
// Remote object // Remote object
var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true, var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true,
parent:undefined, list:undefined}); parent:undefined, list:undefined});
remote_object.setsessionId(sessionId); remote_object.setSessionId(sessionId);
// After obtaining that the device status goes online, the remote object synchronizes data. That is, name changes to jack and age to 18. // After obtaining that the device status goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
``` ```
...@@ -97,7 +98,7 @@ The following example shows how to implement a distributed data object synchroni ...@@ -97,7 +98,7 @@ The following example shows how to implement a distributed data object synchroni
The sample code is as follows: The sample code is as follows:
```js ```js
changeCallback : function (sessionId, changeData) { function changeCallback(sessionId, changeData) {
console.info("change" + sessionId); console.info("change" + sessionId);
if (changeData != null && changeData != undefined) { if (changeData != null && changeData != undefined) {
...@@ -147,22 +148,22 @@ The following example shows how to implement a distributed data object synchroni ...@@ -147,22 +148,22 @@ The following example shows how to implement a distributed data object synchroni
8. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline. 8. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline.
The sample code is as follows: The sample code is as follows:
```js ```js
statusCallback : function (sessionId, networkid, status) { function statusCallback(sessionId, networkId, status) {
this.response += "status changed " + sessionId + " " + status + " " + networkId; this.response += "status changed " + sessionId + " " + status + " " + networkId;
} }
local_object.on("status", this.changeCallback); local_object.on("status", this.statusCallback);
``` ```
9. Unsubscribe from the status changes of the distributed data object. You can specify the callback to unsubscribe from. If you do not specify the callback, all status change callbacks will be unsubscribe from. 9. Unsubscribe from the status changes of the distributed data object. You can specify the callback to unsubscribe from. If you do not specify the callback, all status change callbacks will be unsubscribe from.
The sample code is as follows: The sample code is as follows:
```js ```js
// Unsubscribe from changeCallback. // Unsubscribe from statusCallback.
local_object.off("status", changeCallback); local_object.off("status", statusCallback);
// unsubscribe from all status change callbacks. // Unsubscribe from all status change callbacks.
local_object.off("status"); local_object.off("status");
``` ```
10. Remove the distributed data object from the synchronization network. After the distributed data object is removed from the network, the data changes on the local end will not be synchronized to the remote end. 10. Remove a distributed data object from the synchronization network. After the distributed data object is removed from the network, the data changes on the local end will not be synchronized to the remote end.
The sample code is as follows: The sample code is as follows:
```js ```js
......
...@@ -7,7 +7,7 @@ On the basis of the SQLite database, the relational database (RDB) allows you to ...@@ -7,7 +7,7 @@ On the basis of the SQLite database, the relational database (RDB) allows you to
## Available APIs ## Available APIs
**Creating and Deleting an RDB Store** ### Creating or Deleting an RDB Store
The following table describes the APIs available for creating and deleting an RDB store. The following table describes the APIs available for creating and deleting an RDB store.
...@@ -17,51 +17,55 @@ The following table describes the APIs available for creating and deleting an RD ...@@ -17,51 +17,55 @@ The following table describes the APIs available for creating and deleting an RD
| -------- | -------- | | -------- | -------- |
|getRdbStore(config:&nbsp;StoreConfig,&nbsp;version:&nbsp;number,&nbsp;callback:&nbsp;AsyncCallback&lt;RdbStore&gt;):&nbsp;void | Obtains an RDB store. This method uses a callback to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.<br>-&nbsp;**config**: configuration of the RDB store.<br>-&nbsp;**version**: RDB version.<br>-&nbsp;**callback**: callback invoked to return the RDB store obtained.| |getRdbStore(config:&nbsp;StoreConfig,&nbsp;version:&nbsp;number,&nbsp;callback:&nbsp;AsyncCallback&lt;RdbStore&gt;):&nbsp;void | Obtains an RDB store. This method uses a callback to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.<br>-&nbsp;**config**: configuration of the RDB store.<br>-&nbsp;**version**: RDB version.<br>-&nbsp;**callback**: callback invoked to return the RDB store obtained.|
|getRdbStore(config:&nbsp;StoreConfig,&nbsp;version:&nbsp;number):&nbsp;Promise&lt;RdbStore&gt; | Obtains an RDB store. This method uses a promise to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.<br>-&nbsp;**config**: configuration of the RDB store.<br>-&nbsp;**version**: RDB version.| |getRdbStore(config:&nbsp;StoreConfig,&nbsp;version:&nbsp;number):&nbsp;Promise&lt;RdbStore&gt; | Obtains an RDB store. This method uses a promise to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.<br>-&nbsp;**config**: configuration of the RDB store.<br>-&nbsp;**version**: RDB version.|
|deleteRdbStore(name:&nbsp;string,&nbsp;callback:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | Deletes an RDB store. This method uses a callback to return the result. <br>-&nbsp;**name**: RDB store to delete.<br>-&nbsp;**callback**: callback invoked to return the result. If the RDB store is deleted, **true** will be returned. Otherwise, **false** will be returned.| |deleteRdbStore(name:&nbsp;string,&nbsp;callback:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | Deletes an RDB store. This method uses a callback to return the result. <br>-&nbsp;**name**: RDB store to delete.<br>-&nbsp;**callback**: callback invoked to return the result.|
| deleteRdbStore(name:&nbsp;string):&nbsp;Promise&lt;void&gt; | Deletes an RDB store. This method uses a promise to return the result.<br>-&nbsp;**name**: RDB store to delete.| | deleteRdbStore(name:&nbsp;string):&nbsp;Promise&lt;void&gt; | Deletes an RDB store. This method uses a promise to return the result.<br>-&nbsp;**name**: RDB store to delete.|
**Managing Data in an RDB Store** ### Managing Data in an RDB Store
The RDB provides APIs for inserting, deleting, updating, and querying data in the local RDB store. The RDB provides APIs for inserting, deleting, updating, and querying data in the local RDB store.
- **Inserting data**<br/> - **Inserting data**
The RDB provides APIs for inserting data through a **ValuesBucket** in a data table. If the data is inserted, the row ID of the data inserted will be returned; otherwise, **-1** will be returned. The RDB provides APIs for inserting data through a **ValuesBucket** in a data table. If the data is inserted, the row ID of the data inserted will be returned; otherwise, **-1** will be returned.
**Table 2** APIs for inserting data **Table 2** APIs for inserting data
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| RdbStore | insert(name:&nbsp;string,&nbsp;values:&nbsp;ValuesBucket,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void | Inserts a row of data into a table. This method uses a callback to return the result.<br>-&nbsp;**name**: name of the target table.<br>-&nbsp;**values**: data to be inserted into the table.<br>-&nbsp;**callback**: callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| | RdbStore | insert(name:&nbsp;string,&nbsp;values:&nbsp;ValuesBucket,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void | Inserts a row of data into a table. This method uses a callback to return the result.<br>-&nbsp;**name**: name of the target table.<br>-&nbsp;**values**: data to be inserted into the table.<br>-&nbsp;**callback**: callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
| RdbStore | insert(name:&nbsp;string,&nbsp;values:&nbsp;ValuesBucket):&nbsp;Promise&lt;number&gt; | Inserts a row of data into a table. This method uses a promise to return the result.<br>-&nbsp;**name**: name of the target table.<br>-&nbsp;**values**: data to be inserted into the table.| | RdbStore | insert(name:&nbsp;string,&nbsp;values:&nbsp;ValuesBucket):&nbsp;Promise&lt;number&gt; | Inserts a row of data into a table. This method uses a promise to return the result.<br>-&nbsp;**name**: name of the target table.<br>-&nbsp;**values**: data to be inserted into the table.|
- **Updating data**<br/> - **Updating data**
Call the **update()** method to pass new data and specify the update conditions by using **RdbPredicates**. If the data is updated, the number of rows of the updated data will be returned; otherwise, **0** will be returned. Call the **update()** method to pass new data and specify the update conditions by using **RdbPredicates**. If the data is updated, the number of rows of the updated data will be returned; otherwise, **0** will be returned.
**Table 3** APIs for updating data **Table 3** APIs for updating data
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| RdbStore | update(values:&nbsp;ValuesBucket,&nbsp;rdbPredicates:&nbsp;RdbPredicates,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.<br>-&nbsp;**values**: data to update, which is stored in a **ValuesBucket**.<br>-&nbsp;**rdbPredicates**: conditions for updating data.<br>-&nbsp;**callback**: callback invoked to return the number of rows updated.| | RdbStore | update(values:&nbsp;ValuesBucket,&nbsp;rdbPredicates:&nbsp;RdbPredicates,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.<br>-&nbsp;**values**: data to update, which is stored in a **ValuesBucket**.<br>-&nbsp;**rdbPredicates**: conditions for updating data.<br>-&nbsp;**callback**: callback invoked to return the number of rows updated.|
| RdbStore | update(values:&nbsp;ValuesBucket,&nbsp;rdbPredicates:&nbsp;RdbPredicates):&nbsp;Promise | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result.<br>-&nbsp;**values**: data to update, which is stored in a **ValuesBucket**.<br>-&nbsp;**rdbPredicates**: conditions for updating data.| | RdbStore | update(values:&nbsp;ValuesBucket,&nbsp;rdbPredicates:&nbsp;RdbPredicates):&nbsp;Promise | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result.<br>-&nbsp;**values**: data to update, which is stored in a **ValuesBucket**.<br>-&nbsp;**rdbPredicates**: conditions for updating data.|
- **Deleting data**<br/> - **Deleting data**
Call the **delete()** method to delete data meeting the conditions specified by **RdbPredicates**. If the data is deleted, the number of rows of the deleted data will be returned; otherwise, **0** will be returned. Call the **delete()** method to delete data meeting the conditions specified by **RdbPredicates**. If the data is deleted, the number of rows of the deleted data will be returned; otherwise, **0** will be returned.
**Table 4** APIs for deleting data **Table 4** APIs for deleting data
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| RdbStore | delete(rdbPredicates:&nbsp;RdbPredicates,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.<br>-&nbsp;**rdbPredicates**: conditions for deleting data.<br>-&nbsp;**callback**: callback invoked to return the number of rows deleted.| | RdbStore | delete(rdbPredicates:&nbsp;RdbPredicates,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.<br>-&nbsp;**rdbPredicates**: conditions for deleting data.<br>-&nbsp;**callback**: callback invoked to return the number of rows deleted.|
| RdbStore | delete(rdbPredicates:&nbsp;RdbPredicates):&nbsp;Promise | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result.<br>-&nbsp;**rdbPredicates**: conditions for deleting data.| | RdbStore | delete(rdbPredicates:&nbsp;RdbPredicates):&nbsp;Promise | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result.<br>-&nbsp;**rdbPredicates**: conditions for deleting data.|
- **Querying data**
- **Querying data**<br/>
You can query data in an RDB store in either of the following ways: You can query data in an RDB store in either of the following ways:
- Call the **query()** method to query data based on the predicates, without passing any SQL statement. - Call the **query()** method to query data based on the predicates, without passing any SQL statement.
- Run the native SQL statement. - Run the native SQL statement.
**Table 5** APIs for querying data **Table 5** APIs for querying data
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| RdbStore | query(rdbPredicates:&nbsp;RdbPredicates,&nbsp;columns:&nbsp;Array,&nbsp;callback:&nbsp;AsyncCallback&lt;ResultSet&gt;):&nbsp;void | Queries data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.<br>-&nbsp;**rdbPredicates**: conditions for querying data.<br>-&nbsp;**columns**: columns to query. If this parameter is not specified, the query applies to all columns.<br>-&nbsp;**callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| | RdbStore | query(rdbPredicates:&nbsp;RdbPredicates,&nbsp;columns:&nbsp;Array,&nbsp;callback:&nbsp;AsyncCallback&lt;ResultSet&gt;):&nbsp;void | Queries data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.<br>-&nbsp;**rdbPredicates**: conditions for querying data.<br>-&nbsp;**columns**: columns to query. If this parameter is not specified, the query applies to all columns.<br>-&nbsp;**callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
...@@ -69,7 +73,7 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th ...@@ -69,7 +73,7 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
| RdbStore | querySql(sql:&nbsp;string,&nbsp;bindArgs:&nbsp;Array&lt;ValueType&gt;,&nbsp;callback:&nbsp;AsyncCallback&lt;ResultSet&gt;):void | Queries data in the RDB store using the specified SQL statement. This method uses a callback to return the result.<br>-&nbsp;**sql**: SQL statement.<br>-&nbsp;**bindArgs**: arguments in the SQL statement.<br>-&nbsp;**callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| | RdbStore | querySql(sql:&nbsp;string,&nbsp;bindArgs:&nbsp;Array&lt;ValueType&gt;,&nbsp;callback:&nbsp;AsyncCallback&lt;ResultSet&gt;):void | Queries data in the RDB store using the specified SQL statement. This method uses a callback to return the result.<br>-&nbsp;**sql**: SQL statement.<br>-&nbsp;**bindArgs**: arguments in the SQL statement.<br>-&nbsp;**callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
| RdbStore | querySql(sql:&nbsp;string,&nbsp;bindArgs?:&nbsp;Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt; | Queries data in the RDB store using the specified SQL statement. This method uses a promise to return the result.<br>-&nbsp;**sql**: SQL statement.<br>-&nbsp;**bindArgs**: arguments in the SQL statement.| | RdbStore | querySql(sql:&nbsp;string,&nbsp;bindArgs?:&nbsp;Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt; | Queries data in the RDB store using the specified SQL statement. This method uses a promise to return the result.<br>-&nbsp;**sql**: SQL statement.<br>-&nbsp;**bindArgs**: arguments in the SQL statement.|
**Using Predicates** ### Using Predicates
The RDB provides **RdbPredicates** for you to set database operation conditions. The RDB provides **RdbPredicates** for you to set database operation conditions.
...@@ -108,12 +112,12 @@ The RDB provides **RdbPredicates** for you to set database operation conditions. ...@@ -108,12 +112,12 @@ The RDB provides **RdbPredicates** for you to set database operation conditions.
| RdbPredicates | in(field:&nbsp;string,&nbsp;value:&nbsp;Array&lt;ValueType&gt;):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array&#60;ValueType&#62;** and value within the specified range.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: array of **ValueType** to match.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| | RdbPredicates | in(field:&nbsp;string,&nbsp;value:&nbsp;Array&lt;ValueType&gt;):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array&#60;ValueType&#62;** and value within the specified range.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: array of **ValueType** to match.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
| RdbPredicates | notIn(field:&nbsp;string,&nbsp;value:&nbsp;Array&lt;ValueType&gt;):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array&#60;ValueType&#62;** and value out of the specified range.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: array of **ValueType** to match.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.| | RdbPredicates | notIn(field:&nbsp;string,&nbsp;value:&nbsp;Array&lt;ValueType&gt;):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array&#60;ValueType&#62;** and value out of the specified range.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: array of **ValueType** to match.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
**Using the Result Set** ### Using the Result Set
A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**. A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**.
> ![icon-notice.gif](../public_sys-resources/icon-notice.gif) **NOTICE**<br/> > ![icon-notice.gif](../public_sys-resources/icon-notice.gif) **NOTICE**<br/>
> After a result set is used, you must call the **close()** method to close it explicitly. > After a result set is used, you must call the **close()** method to close it explicitly.**
**Table 7** APIs for using the result set **Table 7** APIs for using the result set
...@@ -133,26 +137,13 @@ A result set can be regarded as a row of data in the queried results. It allows ...@@ -133,26 +137,13 @@ A result set can be regarded as a row of data in the queried results. It allows
| ResultSet | isColumnNull(columnIndex:&nbsp;number):&nbsp;boolean | Checks whether the value in the specified column of the current row is null.| | ResultSet | isColumnNull(columnIndex:&nbsp;number):&nbsp;boolean | Checks whether the value in the specified column of the current row is null.|
| ResultSet | close():&nbsp;void | Closes the result set.| | ResultSet | close():&nbsp;void | Closes the result set.|
**Changing the Encryption Key for an RDB Store**
You can encrypt an RDB store.
When creating an RDB store, you can add a key for security purposes. After that, the RDB store can be accessed only with the correct key. You can change the key but cannot delete it.
Once an RDB store is created without a key, you can no longer add a key for it.
**Table 8** APIs for changing the encryption key ### Setting Distributed Tables
| Class| API| Description|
| -------- | -------- | -------- |
| RdbStore | changeEncryptKey(newEncryptKey:Uint8Array,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void; | Changes the encryption key for this RDB store. This method uses a callback to return the result. If the operation is successful, **0** will be returned. Otherwise, a non-zero value will be returned.|
| RdbStore | changeEncryptKey(newEncryptKey:Uint8Array):&nbsp;Promise&lt;number&gt;; | Changes the encryption key for this RDB store. This method uses a promise to return the result. If the operation is successful, **0** will be returned. Otherwise, a non-zero value will be returned.|
**Setting Distributed Tables** **Setting Distributed Tables**
You can set a list of distributed tables for data operations across devices. **Table 8** APIs for setting distributed tables
**Table 9** APIs for setting distributed tables
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -163,7 +154,7 @@ You can set a list of distributed tables for data operations across devices. ...@@ -163,7 +154,7 @@ You can set a list of distributed tables for data operations across devices.
You can obtain the distributed table name for a remote device based on the local table name. The distributed table name can be used to query the RDB store of the remote device. You can obtain the distributed table name for a remote device based on the local table name. The distributed table name can be used to query the RDB store of the remote device.
**Table 10** API for obtaining the distributed table name of a remote device **Table 9** APIs for obtaining the distributed table name of a remote device
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -172,17 +163,16 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -172,17 +163,16 @@ You can obtain the distributed table name for a remote device based on the local
**Synchronizing Data Between Devices** **Synchronizing Data Between Devices**
**Table 11** APIs for synchronizing data between devices **Table 10** APIs for synchronizing data between devices
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array<[string, number]>>): void;| Synchronizes data between devices. This method uses a callback to return the result.<br>-&nbsp;**mode**: data synchronization mode. **SYNC\_MODE\_PUSH** means to push data from the local device to a remote device. **SYNC\_MODE\_PULL** means to pull data from a remote device to the local device.<br>-&nbsp;**predicates**: data and devices to be synchronized.<br>-&nbsp;**callback**: callback invoked to return the result. In the result, **string** indicates the device ID, and **number** indicates the synchronization status of each device. The value **0** indicates a success, and other values indicate a failure.| | RdbStore | sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array<[string, number]>>): void;| Synchronizes data between devices. This method uses a callback to return the result.<br>-&nbsp;**mode**: data synchronization mode. **SYNC\_MODE\_PUSH** means to push data from the local device to a remote device. **SYNC\_MODE\_PULL** means to pull data from a remote device to the local device.<br>-&nbsp;**predicates**: data and devices to be synchronized.<br>-&nbsp;**callback**: callback invoked to return the result. In the result, **string** indicates the device ID, and **number** indicates the synchronization status of each device. The value **0** indicates a success, and other values indicate a failure.|
| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates): Promise<Array<[string, number]>>;| Synchronizes data between devices. This method uses a promise to return the result.<br>-&nbsp;**mode**: data synchronization mode. **SYNC\_MODE\_PUSH** means to push data from the local device to a remote device. **SYNC\_MODE\_PULL** means to pull data from a remote device to the local device.<br>-&nbsp;**predicates**: data and devices to be synchronized. | | RdbStore | sync(mode: SyncMode, predicates: RdbPredicates): Promise<Array<[string, number]>>;| Synchronizes data between devices. This method uses a promise to return the result.<br>-&nbsp;**mode**: data synchronization mode. **SYNC\_MODE\_PUSH** means to push data from the local device to a remote device. **SYNC\_MODE\_PULL** means to pull data from a remote device to the local device.<br>-&nbsp;**predicates**: data and devices to be synchronized. |
**Registering an RDB Store Observer** **Registering an RDB Store Observer**
**Table 12** API for registering an observer **Table 11** API for registering an observer
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -190,7 +180,7 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -190,7 +180,7 @@ You can obtain the distributed table name for a remote device based on the local
**Unregistering an RDB Store Observer** **Unregistering an RDB Store Observer**
**Table 13** API for unregistering an observer **Table 12** API for unregistering an observer
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -211,9 +201,10 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -211,9 +201,10 @@ You can obtain the distributed table name for a remote device based on the local
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
const STORE_CONFIG = {name: "rdbstore.db",} const STORE_CONFIG = {name: "rdbstore.db",}
data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) {
let rdbStore = await data_rdb.getRdbStore(STORE_CONFIG, 1); rdbStore.executeSql(SQL_CREATE_TABLE)
await rdbStore.executeSql(CREATE_TABLE_TEST); console.info('create table done.')
})
``` ```
2. Insert data. 2. Insert data.
...@@ -238,16 +229,16 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -238,16 +229,16 @@ You can obtain the distributed table name for a remote device based on the local
``` ```
let predicates = new data_rdb.RdbPredicates("test"); let predicates = new data_rdb.RdbPredicates("test");
predicates.equalTo("name", "Tom") predicates.equalTo("name", "Tom")
let resultSet = await rdbStore.query(predicates) let promisequery = rdbStore.query(predicates)
promisequery.then((resultSet) => {
resultSet.goToFirstRow() resultSet.goToFirstRow()
const id = await resultSet.getLong(resultSet.getColumnIndex("id")) const id = resultSet.getLong(resultSet.getColumnIndex("id"))
const name = await resultSet.getString(resultSet.getColumnIndex("name")) const name = resultSet.getString(resultSet.getColumnIndex("name"))
const age = await resultSet.getLong(resultSet.getColumnIndex("age")) const age = resultSet.getLong(resultSet.getColumnIndex("age"))
const salary = await resultSet.getDouble(resultSet.getColumnIndex("salary")) const salary = resultSet.getDouble(resultSet.getColumnIndex("salary"))
const blobType = await resultSet.getBlob(resultSet.getColumnIndex("blobType")) const blobType = resultSet.getBlob(resultSet.getColumnIndex("blobType"))
resultSet.close()
resultSet.close() })
``` ```
4. Set the distributed tables to be synchronized. 4. Set the distributed tables to be synchronized.
...@@ -261,7 +252,7 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -261,7 +252,7 @@ You can obtain the distributed table name for a remote device based on the local
promise.then(() => { promise.then(() => {
console.info("setDistributedTables success.") console.info("setDistributedTables success.")
}).catch((err) => { }).catch((err) => {
console.info("setDistributedTables failed."") console.info("setDistributedTables failed.")
}) })
``` ```
...@@ -276,7 +267,7 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -276,7 +267,7 @@ You can obtain the distributed table name for a remote device based on the local
let predicate = new data_rdb.RdbPredicates('test') let predicate = new data_rdb.RdbPredicates('test')
predicate.inDevices(['12345678abcde']) predicate.inDevices(['12345678abcde'])
let promise = rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicate) let promise = rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicate)
promise.then(result) { promise.then((result) => {
console.log('sync done.') console.log('sync done.')
for (let i = 0; i < result.length; i++) { for (let i = 0; i < result.length; i++) {
console.log('device=' + result[i][0] + ' status=' + result[i][1]) console.log('device=' + result[i][0] + ' status=' + result[i][1])
......
# RDB Overview<a name="EN-US_TOPIC_0000001231030607"></a> # RDB Overview
The relational database \(RDB\) manages data based on relational models. With the underlying SQLite database, the RDB provides a complete mechanism for managing local databases. To satisfy different needs in complicated scenarios, the RDB offers a series of methods for performing operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. The relational database (RDB) manages data based on relational models. With the underlying SQLite database, the RDB provides a complete mechanism for managing local databases. To satisfy different needs in complicated scenarios, the RDB offers a series of methods for performing operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements.
## Basic Concepts<a name="section1063573420813"></a> ## Basic concepts
- **RDB** - **RDB**
A type of database based on the relational model of data. The RDB stores data in rows and columns. An RDB is also called RDB store. A type of database created on the basis of relational models. The RDB stores data in rows and columns. A RDB is also called RDB store.
- **Predicate** - **Predicate**
A representation of the property or feature of a data entity, or the relationship between data entities. It is mainly used to define operation conditions. A representation of the property or feature of a data entity, or the relationship between data entities. It is mainly used to define operation conditions.
- **Result set** - **Result set**
A set of query results used to access the data. You can access the required data in a result set in flexible modes. A set of query results used to access data. You can access the required data in a result set in flexible modes.
- **SQLite database** - **SQLite database**
A lightweight open-source relational database management system that complies with Atomicity, Consistency, Isolation, and Durability \(ACID\). A lightweight open-source relational database management system that complies with Atomicity, Consistency, Isolation, and Durability (ACID).
## Working Principles
## Working Principles<a name="section4810552814"></a> The RDB provides common operation APIs for external systems. It uses the SQLite as the underlying persistent storage engine, which supports all SQLite database features.
The RDB provides a common operation interface for external systems. It uses the SQLite as the underlying persistent storage engine, which supports all SQLite database features. **Figure 1** How RDB works
**Figure 1** How RDB works<a name="fig1826214361535"></a> ![how-rdb-works](figures/how-rdb-works.png)
![](figures/how-rdb-works.png "how-rdb-works")
## Default Settings<a name="section176091243121218"></a> ## Default Settings
- The default database logging mode is write-ahead logging \(WAL\). - The default RDB logging mode is Write Ahead Log (WAL).
- The default database flush mode is Full mode. - The default data flushing mode is **FULL** mode.
- The default shared memory used by the OpenHarmony database is 2 MB. - The default size of the shared memory used by an OpenHarmony database is 2 MB.
## Constraints<a name="section929813398308"></a> ## Constraints
- A maximum of four connection pools can be connected to an RDB to manage read and write operations. - A maximum of four connection pools can be connected to an RDB to manage read and write operations.
- To ensure data accuracy, the RDB supports only one write operation at a time.
- To ensure data accuracy, the RDB supports only one write operation at a time.
...@@ -111,3 +111,15 @@ ...@@ -111,3 +111,15 @@
The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**. The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**.
![en-us_image_0000001241733907](figures/en-us_image_0000001241733907.png) ![en-us_image_0000001241733907](figures/en-us_image_0000001241733907.png)
If the API fails to be called, you are advised to use the **try/catch** statement to capture error information that may occur in the code. Example:
```
try {
sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) {
console.info("Data obtained successfully. data=" + data);// The call is successful, and the obtained sensor data is printed.
});
} catch (error) {
console.error(error);
}
```
# Internationalization # Internationalization
- [Overview](international-overview.md) - [Internationalization Overview](international-overview.md)
- [Internationalization Development (intl)](intl-guidelines.md) - [Internationalization Development (intl)](intl-guidelines.md)
- [Internationalization Development (i18n)](i18n-guidelines.md) - [Internationalization Development (i18n)](i18n-guidelines.md)
# Overview # Internationalization Overview
If an application is targeted for users and markets in different regions with different languages and time zones, it is necessary for you to provide localized versions to ensure good experience for your users. If an application is targeted for users and markets in different regions with different languages and time zones, it is necessary for you to provide localized versions to ensure good experience for your users.
......
...@@ -3,15 +3,12 @@ ...@@ -3,15 +3,12 @@
- Audio - Audio
- [Audio Overview](audio-overview.md) - [Audio Overview](audio-overview.md)
- [Audio Playback Development](audio-playback.md) - [Audio Playback Development](audio-playback.md)
- [Audio Rendering Development](audio-renderer.md)
- [Audio Recording Development](audio-recorder.md) - [Audio Recording Development](audio-recorder.md)
- [Audio Rendering Development](audio-renderer.md)
- [Audio Capture Development](audio-capturer) - [Audio Capture Development](audio-capturer)
- Video - Video
- [Video Playback Development](video-playback.md) - [Video Playback Development](video-playback.md)
...@@ -21,3 +18,4 @@ ...@@ -21,3 +18,4 @@
- Image - Image
- [Image Development](image.md) - [Image Development](image.md)
...@@ -16,7 +16,7 @@ You can use audio playback APIs to convert audio data into audible analog signal ...@@ -16,7 +16,7 @@ You can use audio playback APIs to convert audio data into audible analog signal
## How to Develop ## How to Develop
For details about the APIs used for audio playback, see [AudioPlayer in the Media API](../reference/apis/js-apis-media.md). For details about the APIs, see [AudioPlayer in the Media API](../reference/apis/js-apis-media.md).
### Full-Process Scenario ### Full-Process Scenario
...@@ -84,7 +84,8 @@ let audioPlayer = media.createAudioPlayer(); ...@@ -84,7 +84,8 @@ let audioPlayer = media.createAudioPlayer();
SetCallBack(audioPlayer); // Set the event callbacks. SetCallBack(audioPlayer); // Set the event callbacks.
// 2. Set the URI of the audio file selected by the user. // 2. Set the URI of the audio file selected by the user.
let fdPath = 'fd://' let fdPath = 'fd://'
let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command.
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3';
await fileIO.open(path).then(fdNumber) => { await fileIO.open(path).then(fdNumber) => {
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + fdNumber;
console.info('open fd sucess fd is' + fdPath); console.info('open fd sucess fd is' + fdPath);
...@@ -147,7 +148,8 @@ let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer inst ...@@ -147,7 +148,8 @@ let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer inst
SetCallBack(audioPlayer); // Set the event callbacks. SetCallBack(audioPlayer); // Set the event callbacks.
/* Set the FD (local playback) of the audio file selected by the user. */ /* Set the FD (local playback) of the audio file selected by the user. */
let fdPath = 'fd://' let fdPath = 'fd://'
let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command.
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3';
await fileIO.open(path).then(fdNumber) => { await fileIO.open(path).then(fdNumber) => {
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + fdNumber;
console.info('open fd sucess fd is' + fdPath); console.info('open fd sucess fd is' + fdPath);
...@@ -185,7 +187,8 @@ let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer inst ...@@ -185,7 +187,8 @@ let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer inst
SetCallBack(audioPlayer); // Set the event callbacks. SetCallBack(audioPlayer); // Set the event callbacks.
/* Set the FD (local playback) of the audio file selected by the user. */ /* Set the FD (local playback) of the audio file selected by the user. */
let fdPath = 'fd://' let fdPath = 'fd://'
let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command.
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3';
await fileIO.open(path).then(fdNumber) => { await fileIO.open(path).then(fdNumber) => {
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + fdNumber;
console.info('open fd sucess fd is' + fdPath); console.info('open fd sucess fd is' + fdPath);
...@@ -201,7 +204,8 @@ audioPlayer.reset(); ...@@ -201,7 +204,8 @@ audioPlayer.reset();
/* Set the FD (local playback) of the audio file selected by the user. */ /* Set the FD (local playback) of the audio file selected by the user. */
let fdNextPath = 'fd://' let fdNextPath = 'fd://'
let nextPath = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/accounts/account_0/appdata" command.
let nextPath = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/02.mp3';
await fileIO.open(nextPath).then(fdNumber) => { await fileIO.open(nextPath).then(fdNumber) => {
fdNextPath = fdNextPath + '' + fdNumber; fdNextPath = fdNextPath + '' + fdNumber;
console.info('open fd sucess fd is' + fdNextPath); console.info('open fd sucess fd is' + fdNextPath);
...@@ -239,6 +243,7 @@ SetCallBack(audioPlayer); // Set the event callbacks. ...@@ -239,6 +243,7 @@ SetCallBack(audioPlayer); // Set the event callbacks.
/* Set the FD (local playback) of the audio file selected by the user. */ /* Set the FD (local playback) of the audio file selected by the user. */
let fdPath = 'fd://' let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command.
let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3';
await fileIO.open(path).then(fdNumber) => { await fileIO.open(path).then(fdNumber) => {
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + fdNumber;
...@@ -252,3 +257,13 @@ await fileIO.open(path).then(fdNumber) => { ...@@ -252,3 +257,13 @@ await fileIO.open(path).then(fdNumber) => {
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
audioPlayer.loop = true; // Set the loop playback attribute. audioPlayer.loop = true; // Set the loop playback attribute.
``` ```
## Samples
The following samples are provided to help you better understand how to develop audio playback:
- [`JsDistributedMusicPlayer`: Distributed Music Player (JS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer)
- [`JsAudioPlayer`: Audio Playback and Management (JS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer)
- [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS)
...@@ -16,7 +16,7 @@ You can use video playback APIs to convert video data into visible signals, play ...@@ -16,7 +16,7 @@ You can use video playback APIs to convert video data into visible signals, play
Note: Video playback requires hardware capabilities such as display, audio, and codec. Note: Video playback requires hardware capabilities such as display, audio, and codec.
1. A third-party application obtains a surface ID from the Xcomponent. 1. A third-party application obtains a surface ID from the XComponent.
2. The third-party application transfers the surface ID to the VideoPlayer JS. 2. The third-party application transfers the surface ID to the VideoPlayer JS.
3. The media service flushes the frame data to the surface buffer. 3. The media service flushes the frame data to the surface buffer.
...@@ -43,16 +43,18 @@ The full video playback process includes creating an instance, setting the URL, ...@@ -43,16 +43,18 @@ The full video playback process includes creating an instance, setting the URL,
For details about the **url** media source input types supported by **VideoPlayer**, see the [url attribute](../reference/apis/js-apis-media.md#videoplayer_attributes). For details about the **url** media source input types supported by **VideoPlayer**, see the [url attribute](../reference/apis/js-apis-media.md#videoplayer_attributes).
For details about how to create an Xcomponent, see [Xcomponent Creation](#Xcomponent). For details about how to create an XComponent, see [XComponent Creation](#xcomponent-creation).
*Note: **SetSurface** must be called after the URL is set but before **Prepare** is called.
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fileIO from '@ohos.fileio'
let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API.
let surfaceID = undefined; // Used to save the surface ID returned by the Xcomponent interface. let surfaceID = undefined; // Used to save the surface ID returned by the XComponent interface.
// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded. // The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the XComponent is loaded.
LoadXcomponent() { LoadXcomponent() {
surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); surfaceID = this.$element('Xcomponent').getXComponentSurfaceId();
console.info('LoadXcomponent surfaceID is' + surfaceID); console.info('LoadXcomponent surfaceID is' + surfaceID);
...@@ -93,7 +95,8 @@ await media.createVideoPlayer().then((video) => { ...@@ -93,7 +95,8 @@ await media.createVideoPlayer().then((video) => {
// Set the FD (local playback) of the video file selected by the user. // Set the FD (local playback) of the video file selected by the user.
let fdPath = 'fd://' let fdPath = 'fd://'
let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command.
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4';
await fileIO.open(path).then(fdNumber) => { await fileIO.open(path).then(fdNumber) => {
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + fdNumber;
console.info('open fd sucess fd is' + fdPath); console.info('open fd sucess fd is' + fdPath);
...@@ -184,9 +187,9 @@ import media from '@ohos.multimedia.media' ...@@ -184,9 +187,9 @@ import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fileIO from '@ohos.fileio'
let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API.
let surfaceID = undefined; // Used to save the surface ID returned by the Xcomponent interface. let surfaceID = undefined; // Used to save the surface ID returned by the XComponent interface.
// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded. // The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the XComponent is loaded.
LoadXcomponent() { LoadXcomponent() {
surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); surfaceID = this.$element('Xcomponent').getXComponentSurfaceId();
console.info('LoadXcomponent surfaceID is' + surfaceID); console.info('LoadXcomponent surfaceID is' + surfaceID);
...@@ -235,7 +238,8 @@ SetCallBack(videoPlayer); ...@@ -235,7 +238,8 @@ SetCallBack(videoPlayer);
// Set the FD (local playback) of the video file selected by the user. // Set the FD (local playback) of the video file selected by the user.
let fdPath = 'fd://' let fdPath = 'fd://'
let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command.
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4';
await fileIO.open(path).then(fdNumber) => { await fileIO.open(path).then(fdNumber) => {
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + fdNumber;
console.info('open fd sucess fd is' + fdPath); console.info('open fd sucess fd is' + fdPath);
...@@ -270,9 +274,9 @@ import media from '@ohos.multimedia.media' ...@@ -270,9 +274,9 @@ import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fileIO from '@ohos.fileio'
let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API.
let surfaceID = undefined; // Used to save the surface ID returned by the Xcomponent interface. let surfaceID = undefined; // Used to save the surface ID returned by the XComponent interface.
// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded. // The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the XComponent is loaded.
LoadXcomponent() { LoadXcomponent() {
surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); surfaceID = this.$element('Xcomponent').getXComponentSurfaceId();
console.info('LoadXcomponent surfaceID is' + surfaceID); console.info('LoadXcomponent surfaceID is' + surfaceID);
...@@ -321,7 +325,8 @@ SetCallBack(videoPlayer); ...@@ -321,7 +325,8 @@ SetCallBack(videoPlayer);
// Set the FD (local playback) of the video file selected by the user. // Set the FD (local playback) of the video file selected by the user.
let fdPath = 'fd://' let fdPath = 'fd://'
let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command.
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4';
await fileIO.open(path).then(fdNumber) => { await fileIO.open(path).then(fdNumber) => {
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + fdNumber;
console.info('open fd sucess fd is' + fdPath); console.info('open fd sucess fd is' + fdPath);
...@@ -356,7 +361,8 @@ await videoPlayer.reset().then(() => { ...@@ -356,7 +361,8 @@ await videoPlayer.reset().then(() => {
// Set the FD (local playback) of the video file selected by the user. // Set the FD (local playback) of the video file selected by the user.
let fdNextPath = 'fd://' let fdNextPath = 'fd://'
let nextPath = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/02.mp4'; // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/accounts/account_0/appdata" command.
let nextPath = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/02.mp4';
await fileIO.open(nextPath).then(fdNumber) => { await fileIO.open(nextPath).then(fdNumber) => {
fdNextPath = fdNextPath + '' + fdNumber; fdNextPath = fdNextPath + '' + fdNumber;
console.info('open fd sucess fd is' + fdNextPath); console.info('open fd sucess fd is' + fdNextPath);
...@@ -391,9 +397,9 @@ import media from '@ohos.multimedia.media' ...@@ -391,9 +397,9 @@ import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fileIO from '@ohos.fileio'
let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API. let videoPlayer = undefined; // Used to store instances created by calling the createVideoPlayer API.
let surfaceID = undefined; // Used to save the surface ID returned by the Xcomponent interface. let surfaceID = undefined; // Used to save the surface ID returned by the XComponent interface.
// The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the Xcomponent is loaded. // The LoadXcomponent() API is used to obtain the surface ID and save it to the **surfaceID** variable. This API is automatically called when the XComponent is loaded.
LoadXcomponent() { LoadXcomponent() {
surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); surfaceID = this.$element('Xcomponent').getXComponentSurfaceId();
console.info('LoadXcomponent surfaceID is' + surfaceID); console.info('LoadXcomponent surfaceID is' + surfaceID);
...@@ -442,7 +448,8 @@ SetCallBack(videoPlayer); ...@@ -442,7 +448,8 @@ SetCallBack(videoPlayer);
// Set the FD (local playback) of the video file selected by the user. // Set the FD (local playback) of the video file selected by the user.
let fdPath = 'fd://' let fdPath = 'fd://'
let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" command.
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4';
await fileIO.open(path).then(fdNumber) => { await fileIO.open(path).then(fdNumber) => {
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + fdNumber;
console.info('open fd sucess fd is' + fdPath); console.info('open fd sucess fd is' + fdPath);
...@@ -473,15 +480,15 @@ await videoPlayer.play().then(() => { ...@@ -473,15 +480,15 @@ await videoPlayer.play().then(() => {
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
``` ```
### Xcomponent Creation ### XComponent Creation
The Xcomponent is used to obtain the surface ID during video playback. You need to create an xxx.hml file and add the following code to the xxx.hml file, where xxx is the same as that in the xxx.js file: The XComponent is used to obtain the surface ID during video playback. You need to create an xxx.hml file and add the following code to the xxx.hml file, where xxx is the same as that in the xxx.js file:
```js ```js
<xcomponent id = 'Xcomponent' <xcomponent id = 'Xcomponent'
if = "{{isFlush}}" // Refresh the surface ID. To enable automatic loading of the Xcomponent and obtain the new surface ID, assign **false** to **isFlush** and then assign **true** to **isFlush**. if = "{{isFlush}}" // Refresh the surface ID. To enable automatic loading of the XComponent and obtain the new surface ID, assign **false** to **isFlush** and then assign **true** to **isFlush**.
type = 'surface' type = 'surface'
onload = 'LoadXcomponent' // Default interface for loading the Xcomponent. onload = 'LoadXcomponent' // Default interface for loading the XComponent.
style = "width:720px;height:480px;border-color:red;border-width:5px;"> // Set the window width, height, and other attributes. style = "width:720px;height:480px;border-color:red;border-width:5px;"> // Set the window width, height, and other attributes.
</xcomponent>
``` ```
...@@ -43,7 +43,7 @@ var subscribeInfo = { ...@@ -43,7 +43,7 @@ var subscribeInfo = {
3. Create a subscriber object and save the returned object for subsequent operations such as subscription and unsubscription. 3. Create a subscriber object and save the returned object for subsequent operations such as subscription and unsubscription.
```javascript ```javascript
// Callback for subscriber creation // Callback for subscriber creation.
commonEvent.createSubscriber(subscribeInfo, (err, subscriber) => { commonEvent.createSubscriber(subscribeInfo, (err, subscriber) => {
if (err.code) { if (err.code) {
console.error("[CommonEvent]CreateSubscriberCallBack err=" + JSON.stringify(err)) console.error("[CommonEvent]CreateSubscriberCallBack err=" + JSON.stringify(err))
...@@ -58,7 +58,7 @@ commonEvent.createSubscriber(subscribeInfo, (err, subscriber) => { ...@@ -58,7 +58,7 @@ commonEvent.createSubscriber(subscribeInfo, (err, subscriber) => {
4. Create a subscription callback, which is triggered when an event is received. The data returned by the subscription callback contains information such as the common event name and data carried by the publisher. For details about the data types and parameters of the common event data, see [CommonEventData](../reference/apis/js-apis-commonEvent.md#commoneventdata). 4. Create a subscription callback, which is triggered when an event is received. The data returned by the subscription callback contains information such as the common event name and data carried by the publisher. For details about the data types and parameters of the common event data, see [CommonEventData](../reference/apis/js-apis-commonEvent.md#commoneventdata).
```javascript ```javascript
// Callback for common event subscription // Callback for common event subscription.
if (this.subscriber != null) { if (this.subscriber != null) {
commonEvent.subscribe(this.subscriber, (err, data) => { commonEvent.subscribe(this.subscriber, (err, data) => {
if (err.code) { if (err.code) {
...@@ -174,6 +174,6 @@ if (this.subscriber != null) { ...@@ -174,6 +174,6 @@ if (this.subscriber != null) {
The following sample is provided to help you better understand how to use the common event functionality: The following sample is provided to help you better understand how to use the common event functionality:
- [EtsCommonEvent](https://gitee.com/openharmony/app_samples/tree/master/ability/EtsCommonEvent) - [CommonEvent](https://gitee.com/openharmony/app_samples/tree/master/ability/CommonEvent)
This sample shows how to use **CommonEvent** APIs in Extended TypeScript (eTS) to create subscribers and subscribe to, publish, and unsubscribe from common events. This sample shows how to use **CommonEvent** APIs in Extended TypeScript (eTS) to create subscribers and subscribe to, publish, and unsubscribe from common events.
...@@ -131,33 +131,7 @@ var subscriber = { ...@@ -131,33 +131,7 @@ var subscriber = {
### Publishing Notifications ### Publishing Notifications
Before publishing a notification, check whether the notification feature is enabled for the respective application. By default, the feature is disabled for newly installed apps. Before publishing a notification, make sure the notification feature is enabled for your application. This feature is disabled by default and can be enabled in the notification settings.
##### Enabling Notification
Check whether notification is enabled.
```js
var bundle = {
bundle: "bundleName1",
}
Notification.isNotificationEnabled(bundle).then((data) => {
console.info("===>isNotificationEnabled success===>");
});
```
If the check result is **false**, notification is disabled. In this case, enable it.
```js
var bundle = {
bundle: "bundleName1",
}
Notification.enableNotification(bundle, true, async(err) => {
console.log("===>enableNotification success===>");
});
```
##### Publishing Notifications ##### Publishing Notifications
...@@ -170,7 +144,7 @@ Normal Text Notification ...@@ -170,7 +144,7 @@ Normal Text Notification
var notificationRequest = { var notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "test_title", title: "test_title",
text: "test_text", text: "test_text",
...@@ -197,25 +171,18 @@ For details about how to use **WantAgent**, see [WantAgent Development](https:// ...@@ -197,25 +171,18 @@ For details about how to use **WantAgent**, see [WantAgent Development](https://
```js ```js
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.wantAgent';
import { OperationType, Flags } from '@ohos.wantagent';
// WantAgentInfo object // WantAgentInfo object
var wantAgentInfo = { var wantAgentInfo = {
wants: [ wants: [
{ {
deviceId: 'deviceId', bundleName: 'ohos.samples.eTSNotification',
bundleName: 'com.example.myapplication', abilityName: 'ohos.samples.eTSNotification.MainAbility',
abilityName: 'com.example.myapplication.MainAbility', }
action: 'REMINDER_EVENT_REMOVE_NOTIFICATION', ],
entities: ['entity1'], operationType: wantAgent.OperationType.START_ABILITY,
type: 'MIMETYPE', requestCode: 0,
uri: 'key={true,true,false}', wantAgentFlags:[wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
parameters: { myKey0: 1111 },
}
],
operationType: OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[Flags.UPDATE_PRESENT_FLAG]
} }
// WantAgent object // WantAgent object
...@@ -241,7 +208,7 @@ wantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) ...@@ -241,7 +208,7 @@ wantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
// Create a NotificationRequest object. // Create a NotificationRequest object.
var notificationRequest = { var notificationRequest = {
content: { content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "AceApplication_Title", title: "AceApplication_Title",
text: "AceApplication_Text", text: "AceApplication_Text",
...@@ -251,7 +218,7 @@ var notificationRequest = { ...@@ -251,7 +218,7 @@ var notificationRequest = {
id: 1, id: 1,
label: 'TEST', label: 'TEST',
wantAgent: WantAgent, wantAgent: WantAgent,
slotType: notify.SlotType.OTHER_TYPES, slotType: Notification.SlotType.OTHER_TYPES,
deliveryTime: new Date().getTime() deliveryTime: new Date().getTime()
} }
...@@ -279,11 +246,3 @@ Notification.cancel(1, "label", cancelCallback) ...@@ -279,11 +246,3 @@ Notification.cancel(1, "label", cancelCallback)
``` ```
## Development Example
The following sample is provided to help you better understand how to develop notification functions:
- notification
This sample shows how to use **Notification** APIs in Extended TypeScript (eTS) to subscribe to, unsubscribe from, publish, and cancel notifications as well as enable the notification feature and check whether the feature is enabled.
# Basics # Quick Start
- Getting Started - Getting Started
- [Preparations](start-overview.md) - [Preparations](start-overview.md)
- [Getting Started with eTS](start-with-ets.md) - [Getting Started with eTS in the Traditional Coding Approach](start-with-ets.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
- [Directory Structure](package-structure.md) - [Application Development Package Structure (FA Model)](package-structure.md)
- [Resource File](basic-resource-file-categories.md) - [Application Development Package Structure (Stage Model)](module-structure.md)
- [Resource File Categories](basic-resource-file-categories.md)
- [SysCap](syscap.md)
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
DevEco Studio is a one-stop, distributed platform developed based on the IntelliJ IDEA Community (Open Source) Edition. It helps you develop versatile all-device, all-scenario applications, offering distributed multi-device development, debugging, and simulation, as well as comprehensive quality and security safeguards. DevEco Studio is a one-stop, distributed platform developed based on the IntelliJ IDEA Community (Open Source) Edition. It helps you develop versatile all-device, all-scenario applications, offering distributed multi-device development, debugging, and simulation, as well as comprehensive quality and security safeguards.
DevEco Studio 3.0 Beta3 (released on March 30, 2022) stands out in the following aspects: [DevEco Studio 3.0 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) stands out in the following aspects:
- One-stop information acquisition platform - One-stop information acquisition platform
- A wide range of device project templates - A wide range of device project templates
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册