提交 5e7b9c0b 编写于 作者: J jiangminsen 提交者: Gitee

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

Signed-off-by: Njiangminsen <jiangminsen@huawei.com>
......@@ -276,6 +276,7 @@ zh-cn/application-dev/faqs/ @zengyawen
zh-cn/application-dev/file-management/ @zengyawen
zh-cn/application-dev/application-test/ @ningningW
zh-cn/application-dev/device-usage-statistics/ @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/web/ @bigpumpkin @HelloCrease @litao33 @zhang-xinyue15
zh-cn/application-dev/reference/apis/js-apis-ability-context.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-ability-errorCode.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
......
......@@ -46,19 +46,19 @@
- Custom Component
- [Creating a Custom Component](quick-start/arkts-create-custom-components.md)
- [Page and Custom Component Lifecycle](quick-start/arkts-page-custom-components-lifecycle.md)
- [\@Builder: Custom Builder Function](quick-start/arkts-builder.md)
- [\@BuilderParam: \@Builder Function Reference](quick-start/arkts-builderparam.md)
- [\@Styles: Definition of Resusable Styles](quick-start/arkts-style.md)
- [\@Extend: Extension of Built-in Components](quick-start/arkts-extend.md)
- [\@Builder Decorator: Custom Builder Function](quick-start/arkts-builder.md)
- [\@BuilderParam Decorator: \@Builder Function Reference](quick-start/arkts-builderparam.md)
- [\@Styles Decorator: Definition of Resusable Styles](quick-start/arkts-style.md)
- [\@Extend Decorator: Extension of Built-in Components](quick-start/arkts-extend.md)
- [stateStyles: Polymorphic Style](quick-start/arkts-statestyles.md)
- State Management
- [State Management Overview](quick-start/arkts-state-management-overview.md)
- Component State Management
- [\@State: State Owned by Component](quick-start/arkts-state.md)
- [\@Prop: One-Way Synchronization from Parent to Child Components](quick-start/arkts-prop.md)
- [\@Link: Two-Way Synchronization Between Parent and Child Components](quick-start/arkts-link.md)
- [\@Provide and \@Consume: Two-Way Synchronization with Descendant Components](quick-start/arkts-provide-and-consume.md)
- [\@Observed and \@ObjectLink: Observing Attribute Changes in Nested Class Objects](quick-start/arkts-observed-and-objectlink.md)
- [\@State Decorator: State Owned by Component](quick-start/arkts-state.md)
- [\@Prop Decorator: One-Way Synchronization from Parent to Child Components](quick-start/arkts-prop.md)
- [\@Link Decorator: Two-Way Synchronization Between Parent and Child Components](quick-start/arkts-link.md)
- [\@Provide and \@Consume Decorators: Two-Way Synchronization with Descendant Components](quick-start/arkts-provide-and-consume.md)
- [\@Observed and \@ObjectLink Decorators: Observing Attribute Changes in Nested Class Objects](quick-start/arkts-observed-and-objectlink.md)
- Application State Management
- [Application State Management Overview](quick-start/arkts-application-state-management-overview.md)
- [LocalStorage: UI State Storage](quick-start/arkts-localstorage.md)
......@@ -67,7 +67,7 @@
- [Environment: Device Environment Query](quick-start/arkts-environment.md)
- Other State Management Features
- [Overview of Other State Management Features](quick-start/arkts-other-state-mgmt-functions-overview.md)
- [\@Watch: Getting Notified of State Variable Changes](quick-start/arkts-watch.md)
- [\@Watch Decorator: Getting Notified of State Variable Changes](quick-start/arkts-watch.md)
- [$$ Syntax: Two-Way Synchronization of Built-in Components](quick-start/arkts-two-way-sync.md)
- Rendering Control
- [Overview of Rendering Control](quick-start/arkts-rendering-control-overview.md)
......@@ -106,12 +106,12 @@
- [SystemCapability List](reference/syscap-list.md)
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md)
- [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md)
- [JS Service Widget UI Components](reference/js-service-widget-ui/Readme-EN.md)
- APIs
- [ArkTS and JS APIs](reference/apis/Readme-EN.md)
- [JavaScript Service Widget UI Component Reference](reference/js-service-widget-ui/Readme-EN.md)
- API Reference
- [ArkTS and JavaScript APIs](reference/apis/Readme-EN.md)
- [Error Codes](reference/errorcodes/Readme-EN.md)
- Native APIs
- [Native API Reference](reference/native-apis/Readme-EN.md)
- Native API Reference
- [Native APIs](reference/native-apis/Readme-EN.md)
- [Standard Libraries](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md)
- [FAQs](faqs/Readme-EN.md)
......
......@@ -6,7 +6,7 @@ The documents are carefully organized as follows:
### Getting Started
[Here](quick-start/Readme-EN.md) you'll learn how to quickly get started with OpenHarmony application development.
[Here](quick-start/Readme-EN.md) you can learn how to better prepare yourself for application development.
Browse the documents on the instructions for quickly building your first application and the basics about OpenHarmony applications.
......@@ -51,7 +51,7 @@ DevEco Studio is a high-performance integrated development environment (IDE) rec
### Hands-On Tutorials
To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md) and [codelabs](https://gitee.com/openharmony/codelabs).
To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md).
### API References
......@@ -61,16 +61,15 @@ They are organized as follows:
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md)
- [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md)
- [JS Service Widget UI Components](reference/js-service-widget-ui/Readme-EN.md)
- APIs
- [JS and TS APIs](reference/apis/Readme-EN.md)
- Native APIs
- [Standard Library](reference/native-lib/third_party_libc/musl.md)
- [JavaScript Service Widget UI Component Reference](reference/js-service-widget-ui/Readme-EN.md)
- API Reference
- [ArkTS and JavaScript APIs](reference/apis/Readme-EN.md)
- Native API Reference
- [Native APIs](reference/native-apis/Readme-EN.md)
- [Standard Libraries](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md)
### Readme
For details about the principles and basic information of each subsystem, see the README file in [docs/en/readme](../readme).
<!--no_check-->
\ No newline at end of file
......@@ -6,7 +6,7 @@ The documents are carefully organized as follows:
## Getting Started
[Here](quick-start/start-overview.md) you'll learn how to quickly get started with OpenHarmony application development.
[Here](quick-start/start-overview.md) you can learn how to better prepare yourself for application development.
Browse the documents on the instructions for quickly building your first application and the basics about OpenHarmony applications.
......@@ -36,12 +36,12 @@ Then, equip yourself for developing the key features, with the following guideli
- [Data Management](database/data-mgmt-overview.md)
- [File Management](file-management/file-management-overview.md)
- [Task Management](task-management/background-task-overview.md)
- [Device](device/usb-overview.md)
- [Device Management](device/usb-overview.md)
- [Device Usage Statistics](device-usage-statistics/device-usage-statistics-overview.md)
- [DFX](dfx/hiappevent-guidelines.md)
- [Internationalization](internationalization/international-overview.md)
- [Application Test](application-test/arkxtest-guidelines.md)
- [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md)
- [IDL Specifications and User Guide](IDL/idl-guidelines.md)
- [Using Native APIs in Application Projects](napi/napi-guidelines.md)
## Tools
......@@ -51,7 +51,7 @@ DevEco Studio is a high-performance integrated development environment (IDE) rec
## Hands-On Tutorials
To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md) and [codelabs](https://gitee.com/openharmony/codelabs).
To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md).
## API References
......@@ -59,13 +59,12 @@ API references encompass all components and APIs available in OpenHarmony, helpi
They are organized as follows:
- [ArkTS API Reference](reference/apis/development-intro.md)
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/ts-components-summary.md)
- [Component Reference (JavaScript-compatible Web-like Development Paradigm-ArkUI.Full)](reference/arkui-js/js-components-common-attributes.md)
- [Component Reference (JavaScript-compatible Web-like Development Paradigm-ArkUI.Lite)](reference/arkui-js-lite/js-framework-file.md)
- [JS Service Widget UI Components](reference/js-service-widget-ui/js-service-widget-file.md)
- [JS and TS APIs](reference/apis/development-intro.md)
- Native APIs
- [Standard Library](reference/native-lib/third_party_libc/musl.md)
- [JavaScript Service Widget UI Component Reference](reference/js-service-widget-ui/js-service-widget-file.md)
- Native API Reference
- [Native APIs](reference/native-apis/_o_h___native_x_component.md)
- [Standard Libraries](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md)
<!--no_check-->
\ No newline at end of file
# Widget Event Capability Overview
The ArkTS widget provides the **postCardAction()** API for interaction between the widget internal and the provider application. Currently, this API supports the router, message, and call events and can be called only in the widget.
The ArkTS widget provides the **postCardAction()** API for interaction between the widget internal and the widget provider. Currently, this API supports the router, message, and call events and can be called only in the widget.
![WidgetPostCardAction](figures/WidgetPostCardAction.png)
......@@ -8,26 +8,28 @@ The ArkTS widget provides the **postCardAction()** API for interaction between t
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| component | Object | Yes| Instance of the current custom component. Generally, **this** is transferred.|
| component | Object | Yes| Instance of the current custom component. Generally, **this** is passed in.|
| action | Object | Yes| Action description. For details, see the following table.|
**Description of the action parameter**
| Key | Value | Description|
| -------- | -------- | -------- |
| "action" | string | Action type.<br>- **"router"**: redirection to the specified UIAbility of the widget provider.<br>- **"message"**: custom message. If this type of action is triggered, the [onFormEvent()](../reference/apis/js-apis-app-form-formExtensionAbility.md#onformevent) lifecycle callback of the provider FormExtensionAbility is called.<br>- **"call"**: launch of the widget provider in the background. If this type of action is triggered, the specified UIAbility of the widget provider is started in the background, but not displayed in the foreground. This action type requires that the widget provider should have the [ohos.permission.KEEP_BACKGROUND_RUNNING](../security/permission-list.md#ohospermissionkeep_background_running) permission.|
| "action" | string | Action type.<br>- **"router"**: redirection to the specified UIAbility of the widget provider.<br>- **"message"**: custom message. If this type of action is triggered, the [onFormEvent()](../reference/apis/js-apis-app-form-formExtensionAbility.md#onformevent) lifecycle callback of the provider FormExtensionAbility is called.<br>- **"call"**: launch of the widget provider in the background. If this type of action is triggered, the specified UIAbility (whose [launch type](uiability-launch-type.md) must be singleton) of the widget provider is started in the background, but not displayed in the foreground. This action type requires that the widget provider should have the [ohos.permission.KEEP_BACKGROUND_RUNNING](../security/permission-list.md#ohospermissionkeep_background_running) permission.|
| "bundleName" | string | Name of the target bundle when **action** is **"router"** or **"call"**. This parameter is optional.|
| "moduleName" | string | Name of the target module when **action** is **"router"** or **"call"**. This parameter is optional.|
| "abilityName" | string | Name of the target UIAbility when **action** is **"router"** or **"call"**. This parameter is mandatory.|
| "params" | Object | Additional parameters carried in the current action. The value is a key-value pair in JSON format. For the **"call"** action type, the **method** parameter must be set and its value type must be string. This parameter is mandatory.|
| "params" | Object | Additional parameters carried in the current action. The value is a key-value pair in JSON format. For the **"call"** action type, the **method** parameter (mandatory) must be set and its value type must be string.|
Sample code of the **postCardAction()** API:
```typescript
Button ('Jump')
Button ('Redirect')
.width('40%')
.height('20%')
.onClick(() => {
......@@ -51,7 +53,7 @@ Button ('Start in Background')
'abilityName': 'EntryAbility',
'params': {
'method': 'fun', // Set the name of the method to call. It is mandatory.
'message': 'testForcall' // Customize the message to send.
'message': 'testForCall' // Customize the message to send.
}
});
})
......
......@@ -16,7 +16,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o
build() {
Column() {
Button ('Jump')
Button ('Redirect')
.margin('20%')
.onClick(() => {
console.info('postCardAction to EntryAbility');
......
......@@ -2,9 +2,7 @@
## When to Use
A static subscriber is started once it receives a target event published by the system or application. At the same time, the [onReceiveEvent()](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md#staticsubscriberextensionabilityonreceiveevent) callback is triggered.
You can implement the service logic in the [onReceiveEvent()](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md#staticsubscriberextensionabilityonreceiveevent) callback. For example, if an application needs to execute some initialization tasks during device power-on, the application can subscribe to the power-on event in static mode. After receiving the power-on event, the application is started to execute the initialization tasks.
A static subscriber is started once it receives a target event published by the system or application. At the same time, the [onReceiveEvent()](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md#staticsubscriberextensionabilityonreceiveevent) callback is triggered, in which you can implement the service logic. For example, if an application needs to execute some initialization tasks during device power-on, the application can subscribe to the power-on event in static mode. After receiving the power-on event, the application is started to execute the initialization tasks.
Subscribing to a common event in static mode is achieved by configuring a declaration file and implementing a class that inherits from [StaticSubscriberExtensionAbility](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md).
......@@ -18,7 +16,7 @@ Subscribing to a common event in static mode is achieved by configuring a declar
To declare a static subscriber, create an ExtensionAbility, which is derived from the **StaticSubscriberExtensionAbility** class, in the project.
You can implement service logic in the **onReceiveEvent()** callback.
You can implement service logic in the [**onReceiveEvent()**](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md#staticsubscriberextensionabilityonreceiveevent) callback.
```ts
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
......@@ -93,23 +91,24 @@ Subscribing to a common event in static mode is achieved by configuring a declar
- **permission**: permission required for the publisher. If a publisher without the required permission attempts to publish an event, the event is regarded as invalid and will not be published.
- **events**: list of target events to subscribe to.
4. Modify the [preset configuration file](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) of the device, that is, the **/system/etc/app/install_list_permission.json** file on the device. When the device is started, this file is read. During application installation, the common event type specified by **allowCommonEvent** in the file is authorized. The **install_list_permission.json** file contains the following fields:
4. Modify the [preset configuration file](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_capability.json) of the device, that is, the **/system/etc/app/install_list_capability.json** file on the device. When the device is started, this file is read. During application installation, the common event type specified by **allowCommonEvent** in the file is authorized. The **install_list_capability.json** file contains the following fields:
- **bundleName**: bundle name of the application.
- **app_signature**: fingerprint information of the application. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md#configuration-in-install_list_capabilityjson).
- **app_signature**: fingerprint information of the application. For details, see [Configuration in install_list_capability.json](../../device-dev/subsystems/subsys-app-privilege-config-guide.md#configuration-in-install_list_capabilityjson).
- **allowCommonEvent**: type of common event that can be started by static broadcast.
> **NOTE**
>
> The **install_list_permissions.json** file is available only for preinstalled applications.
```json
[
...
{
"bundleName": "com.example.myapplication",
"app_signature": ["****"],
"allowCommonEvent": ["usual.event.A", "usual.event.B"]
"bundleName": "com.example.myapplication", // Bundle name.
"app_signature": ["****"], // Fingerprint information.
"allowCommonEvent": ["usual.event.A", "usual.event.B"] // Type of common event that can be started by static broadcast.
}
]
```
> **NOTE**
>
> The **install_list_capability.json** file is available only for preinstalled applications.
......@@ -12,7 +12,7 @@ import dataAbility from '@ohos.data.dataAbility'
import relationalStore from '@ohos.data.relationalStore'
const TABLE_NAME = 'book'
const STORE_CONFIG = { name: 'book.db' }
const STORE_CONFIG = { name: 'book.db',securityLevel: 1 }
const SQL_CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS book(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, introduction TEXT NOT NULL)'
let rdbStore: relationalStore.RdbStore = undefined
......
......@@ -63,8 +63,7 @@ The system matches the **action** attribute in the **want** parameter passed by
- If **action** in the passed **want** parameter is specified, and **actions** under **skills** of an application component is specified but does not contain **action** in the passed **want** parameter, the matching fails.
**Figure 1** Matching rules of action in the want parameter
![want-action](figures/want-action.png)
![want-action](figures/want-action.png)
### Matching Rules of entities in the want Parameter
......@@ -82,8 +81,7 @@ The system matches the **entities** attribute in the **want** parameter passed b
- If **entities** in the passed **want** parameter is specified, and **entities** under **skills** of an application component is specified but does not contain **entities** in the passed **want** parameter, the matching fails.
**Figure 2** Matching rules of entities in the want parameter
![want-entities](figures/want-entities.png)
![want-entities](figures/want-entities.png)
### Matching Rules of uri and type in the want Parameter
......@@ -100,6 +98,7 @@ There are four combinations of **uri** and **type** settings. The matching rules
- Only **uri** is specified in the **want** parameter.
- If the **uris** array under **skills** of an application component is unspecified, the matching fails.
- If the **uris** array under **skills** of an application component contains an element whose [uri is matched](#matching-rules-of-uri) and **type** is unspecified, the matching is successful. Otherwise, the matching fails.
- If the matching fails for the preceding two scenarios and the input URI is a file path URI, the system obtains the MIME type of the file based on the file name extension. If the MIME type matches **type** configured under **skills**, the matching is successful.
- Only **type** is specified in the **want** parameter.
- If the **uris** array under **skills** of an application component is unspecified, the matching fails.
......@@ -112,8 +111,7 @@ There are four combinations of **uri** and **type** settings. The matching rules
Leftmost URI matching: When only **scheme**, a combination of **scheme** and **host**, or a combination of **scheme**, **host**, and **port** is configured in the **uris** array under **skills** of the application component, the matching is successful only if the leftmost URI in the passed **want** parameter matches **scheme**, the combination of **scheme** and **host**, or the combination of **scheme**, **host**, and **port**.
**Figure 3** Matching rules when uri and type are specified in the want parameter
![want-uri-type1](figures/want-uri-type1.png)
![want-uri-type1](figures/want-uri-type1.png)
To simplify the description:
......@@ -121,8 +119,7 @@ To simplify the description:
- **type** in the **want** parameter passed in by the caller is called **w_type**; the type in the **uris** array under **skills** of the application component to match is called **s_type**.
**Figure 4** Matching rules of uri and type in the want parameter
![want-uri-type2](figures/want-uri-type2.png)
![want-uri-type2](figures/want-uri-type2.png)
### Matching Rules of uri
......
......@@ -2,7 +2,7 @@
## Overview
[ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md) is an ExtensionAbility component of the service type that provides capabilities related to background services. It holds an internal [ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md), which provides a variety of APIs are provided for external systems.
[ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md) is an ExtensionAbility component of the service type that provides capabilities related to background services. It holds an internal [ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md), which provides a variety of APIs for external systems.
In this document, the started ServiceExtensionAbility is called the server, and the component that starts the ServiceExtensionAbility is called the client.
......@@ -28,7 +28,7 @@ Note the following:
## Lifecycle
The [ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md) class provides the lifecycle callbacks **onCreate()**, **onRequest()**, **onConnect()**, **onDisconnect()**, and **onDestory()**. Override them as required. The following figure shows the ServiceExtensionAbility lifecycle.
The [ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md) class provides the lifecycle callbacks **onCreate()**, **onRequest()**, **onConnect()**, **onDisconnect()**, and **onDestroy()**. Override them as required. The following figure shows the ServiceExtensionAbility lifecycle.
**Figure 1** ServiceExtensionAbility lifecycle
![ServiceExtensionAbility-lifecycle](figures/ServiceExtensionAbility-lifecycle.png)
......@@ -249,7 +249,6 @@ A system application uses the [startServiceExtensionAbility()](../reference/apis
>
> - The background service calls the [terminateSelf()](../reference/apis/js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextterminateself) method to automatically stop itself.
> - Another component calls the [stopServiceExtensionAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstopserviceextensionability) method to stop the background service.
>
## Connecting to a Background Service
......@@ -382,7 +381,7 @@ When a ServiceExtensionAbility is used to provide sensitive services, the client
- **Verifying the client identity based on callerUid**
Call the [getCallingUid()](../reference/apis/js-apis-rpc.md#getcallinguid) method to obtain the UID of the client, and then call the [getBundleNameByUid()](../reference/apis/js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid) method to obtain the corresponding bundle name. In this way, the client identify is verified. Note that [getBundleNameByUid()](../reference/apis/js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid) is asynchronous, and therefore the server cannot return the verification result to the client. This verification mode applies when the client sends an asynchronous task request to the server. The sample code is as follows:
Call the [getCallingUid()](../reference/apis/js-apis-rpc.md#getcallinguid) method to obtain the UID of the client, and then call the [getBundleNameByUid()](../reference/apis/js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid) method to obtain the corresponding bundle name. In this way, the client identity is verified. Note that [getBundleNameByUid()](../reference/apis/js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid) is asynchronous, and therefore the server cannot return the verification result to the client. This verification mode applies when the client sends an asynchronous task request to the server. The sample code is as follows:
```ts
import rpc from '@ohos.rpc';
......
......@@ -75,7 +75,7 @@ During camera application development, you can listen for the camera status, inc
Register the 'cameraStatus' event and return the listening result through a callback, which carries the **CameraStatusInfo** parameter. For details about the parameter, see [CameraStatusInfo](../reference/apis/js-apis-camera.md#camerastatusinfo).
```ts
cameraManager.on('cameraStatus', (cameraStatusInfo) => {
cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
console.info(`camera: ${cameraStatusInfo.camera.cameraId}`);
console.info(`status: ${cameraStatusInfo.status}`);
})
......
......@@ -48,7 +48,7 @@ During camera application development, you can listen for the status of metadata
- Register the 'metadataObjectsAvailable' event to listen for metadata objects that are available. When a valid metadata object is detected, the callback function returns the metadata. This event can be registered when a **MetadataOutput** object is created.
```ts
metadataOutput.on('metadataObjectsAvailable', (metadataObjectArr) => {
metadataOutput.on('metadataObjectsAvailable', (err, metadataObjectArr) => {
console.info(`metadata output metadataObjectsAvailable`);
})
```
......
......@@ -22,7 +22,7 @@ if (!cameraManager) {
}
// Listen for camera status changes.
cameraManager.on('cameraStatus', (cameraStatusInfo) => {
cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
console.log(`camera : ${cameraStatusInfo.camera.cameraId}`);
console.log(`status: ${cameraStatusInfo.status}`);
})
......
......@@ -21,7 +21,7 @@ if (!cameraManager) {
return;
}
// Listen for camera status changes.
cameraManager.on('cameraStatus', (cameraStatusInfo) => {
cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
console.info(`camera : ${cameraStatusInfo.camera.cameraId}`);
console.info(`status: ${cameraStatusInfo.status}`);
})
......
......@@ -136,7 +136,7 @@ During camera application development, you can listen for the status of the phot
- Register the 'captureStart' event to listen for photographing start events. This event can be registered when a **PhotoOutput** object is created and is triggered when the bottom layer starts exposure for photographing for the first time. The capture ID is returned.
```ts
photoOutput.on('captureStart', (captureId) => {
photoOutput.on('captureStart', (err, captureId) => {
console.info(`photo capture stated, captureId : ${captureId}`);
})
```
......@@ -144,7 +144,7 @@ During camera application development, you can listen for the status of the phot
- Register the 'captureEnd' event to listen for photographing end events. This event can be registered when a **PhotoOutput** object is created and is triggered when the photographing is complete. [CaptureEndInfo](../reference/apis/js-apis-camera.md#captureendinfo) is returned.
```ts
photoOutput.on('captureEnd', (captureEndInfo) => {
photoOutput.on('captureEnd', (err, captureEndInfo) => {
console.info(`photo capture end, captureId : ${captureEndInfo.captureId}`);
console.info(`frameCount : ${captureEndInfo.frameCount}`);
})
......
......@@ -47,19 +47,19 @@
- Custom Component
- [Creating a Custom Component](arkts-create-custom-components.md)
- [Page and Custom Component Lifecycle](arkts-page-custom-components-lifecycle.md)
- [\@Builder: Custom Builder Function](arkts-builder.md)
- [\@BuilderParam: @Builder Function Reference](arkts-builderparam.md)
- [\@Styles: Definition of Resusable Styles](arkts-style.md)
- [\@Extend: Extension of Built-in Components](arkts-extend.md)
- [stateStyles: Polymorphic Style](arkts-statestyles.md)
- [\@Builder Decorator: Custom Builder Function](arkts-builder.md)
- [\@BuilderParam Decorator: @Builder Function Reference](arkts-builderparam.md)
- [\@Styles Decorator: Definition of Resusable Styles](arkts-style.md)
- [\@Extend Decorator: Extension of Built-in Components](arkts-extend.md)
- [stateStyles Decorator: Polymorphic Style](arkts-statestyles.md)
- State Management
- [State Management Overview](arkts-state-management-overview.md)
- Component State Management
- [\@State: State Owned by Component](arkts-state.md)
- [\@Prop: One-Way Synchronization from Parent to Child Components](arkts-prop.md)
- [\@Link: Two-Way Synchronization Between Parent and Child Components](arkts-link.md)
- [\@Provide and \@Consume: Two-Way Synchronization with Descendant Components](arkts-provide-and-consume.md)
- [\@Observed and \@ObjectLink: Observing Attribute Changes in Nested Class Objects](arkts-observed-and-objectlink.md)
- [\@State Decorator: State Owned by Component](arkts-state.md)
- [\@Prop Decorator: One-Way Synchronization from Parent to Child Components](arkts-prop.md)
- [\@Link Decorator: Two-Way Synchronization Between Parent and Child Components](arkts-link.md)
- [\@Provide and \@Consume Decorators: Two-Way Synchronization with Descendant Components](arkts-provide-and-consume.md)
- [\@Observed and \@ObjectLink Decorators: Observing Attribute Changes in Nested Class Objects](arkts-observed-and-objectlink.md)
- Application State Management
- [Application State Management Overview](arkts-application-state-management-overview.md)
- [LocalStorage: UI State Storage](arkts-localstorage.md)
......
# \@Builder: Custom Builder Function
# \@Builder Decorator: Custom Builder Function
As previously described, you can reuse UI elements by creating a custom component, which comes with a fixed internal UI structure and allows for data transfer only with its caller. ArkUI also provides a more lightweight mechanism for reusing UI elements: \@Builder. An \@Builder decorated function is a special function that serves similar purpose as the build function. The \@Builder function body follows the same syntax rules as the **build** function. You can abstract reusable UI elements into a method and call the method in **build**.
......
# \@BuilderParam: @Builder Function Reference
# \@BuilderParam Decorator: @Builder Function Reference
In certain circumstances, you may need to add a specific function, such as a click-to-jump action, to a custom component. However, embedding an event method directly inside of the component will add the function to all places where the component is imported. This is where the \@BuilderParam decorator comes into the picture. \@BuilderParam is used to decorate a custom component member variable of type reference to an \@Builder method. When initializing a custom component, you can assign a value to the variable, thereby adding the specific function to the custom component. This decorator can be used to declare an element of any UI description, similar to a slot placeholder.
......
# \@Extend: Extension of Built-in Components
# \@Extend Decorator: Extension of Built-in Components
Apart from\@Styles used to extend styles, AkrUI also provides \@Extend, which allows you to add a new attribute feature to a built-in component.
......
# \@Link: Two-Way Synchronization Between Parent and Child Components
# \@Link Decorator: Two-Way Synchronization Between Parent and Child Components
An \@Link decorated variable can create two-way synchronization with a variable of its parent component.
......
# \@Observed and \@ObjectLink: Observing Attribute Changes in Nested Class Objects
# \@Observed and \@ObjectLink Decorators: Observing Attribute Changes in Nested Class Objects
The decorators described above can observe only the changes of the first layer. However, in real-world application development, the application may encapsulate its own data model based on development requirements. In the case of multi-layer nesting, for example, a two-dimensional array, an array item class, or a class insider another class as an attribute, the attribute changes at the second layer cannot be observed. This is where the \@Observed and \@ObjectLink decorators come in handy.
......
......@@ -24,6 +24,7 @@ Persistence of data is a relatively slow operation. Applications should avoid th
The preceding situations may overload the change process of persisted data. As a result, the PersistentStorage implementation may limit the change frequency of persisted attributes.
PersistentStorage is associated with UIContext and can be called to persist data only when [UIContext](../reference/apis/js-apis-arkui-UIContext.md#uicontext) is specified. The context can be identified in [runScopedTask](../reference/apis/js-apis-arkui-UIContext.md#runscopedtask).
## Application Scenarios
......@@ -77,7 +78,7 @@ struct Index {
```
- First running after fresh application installation:
1. **PersistProp** is called to initialize PersistentStorage. A search for the **aProp** attribute on the PersistentStorage disk returns no result, because the application has just been installed.
1. **PersistProp** is called to initialize PersistentStorage. A search for the **aProp** attribute on the PersistentStorage disk returns no result, because the application has just been installed.
2. A search for the attribute **aProp** in AppStorage still returns no result.
3. Create the **aProp** attribute of the number type in AppStorge and initialize it with the value 47.
4. PersistentStorage writes the **aProp** attribute and its value **47** to the disk. The value of **aProp** in AppStorage and its subsequent changes are persisted.
......
# \@Prop: One-Way Synchronization from Parent to Child Components
# \@Prop Decorator: One-Way Synchronization from Parent to Child Components
An \@Prop decorated variable can create one-way synchronization with a variable of its parent component. \@Prop decorated variables are mutable, but changes are not synchronized to the parent component.
......
# \@Provide and \@Consume: Two-Way Synchronization with Descendant Components
# \@Provide and \@Consume Decorators: Two-Way Synchronization with Descendant Components
\@Provide and \@Consume are used for two-way data synchronization with descendant components in scenarios where state data needs to be transferred between multiple levels. They do not involve passing a variable from component to component multiple times.
......
# \@State: State Owned by Component
# \@State Decorator: State Owned by Component
An \@State decorated variable, also called a state variable, is a variable that holds the state property and is used to render the owning custom component. When it changes, the UI is re-rendered accordingly.
......
# stateStyles: Polymorphic Style
# stateStyles Decorator: Polymorphic Style
Unlike \@Styles and \@Extend, which are used to reuse styles only on static pages, stateStyles enables you to set state-specific styles.
......
# \@Styles: Definition of Resusable Styles
# \@Styles Decorator: Definition of Resusable Styles
If the style of each component needs to be set separately, this will result in a large amount of repeated code during development. Though copy and paste is available, it is inefficient and error-prone. To maximize code efficiency and maintainability, the \@Styles decorator is introduced.
......
......@@ -61,8 +61,7 @@ This topic gives an overview of the **module.json5** configuration file. To star
]
},
"targetModuleName": "feature",
"targetPriority": 50,
"isolationMode": "nonisolationFirst"
"targetPriority": 50
}
```
......@@ -74,7 +73,7 @@ As shown above, the **module.json5** file contains several tags.
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| name | Name of the module. The value is a string with a maximum of 31 bytes and must be unique in the entire application. | String| No|
| name | Name of the module. The value is a string with a maximum of 31 bytes and must be unique in the entire application. During application upgrade, this name can be changed. If it is changed, migration of module-related directories is required for the application. You can use the [file operation API](../reference/apis/js-apis-file-fs.md#fscopydir10) for migration.| String| No|
| type | Type of the module. The options are as follows:<br>- **entry**: main module of the application.<br>- **feature**: dynamic feature module of the application.<br>- **har**: static shared module.<br>- **shared**: dynamic shared module.| String| No|
| srcEntry | Code path corresponding to the module. The value is a string with a maximum of 127 bytes.| String| Yes (initial value: left empty)|
| description | Description of the module. The value is a string with a maximum of 255 bytes or a string resource index.| String| Yes (initial value: left empty)|
......@@ -94,9 +93,11 @@ As shown above, the **module.json5** file contains several tags.
| [dependencies](#dependencies)| List of shared libraries on which the current module depends during running.| Object array| Yes (initial value: left empty) |
| targetModuleName | Target module of the bundle. The value is a string with a maximum of 31 bytes. It must be unique in the entire application.|String|Yes (if the initial value is used, the target module is not a module with the overlay feature)|
| targetPriority | Priority of the module. When **targetModuleName** is set, the module is a module with the overlay feature. The value ranges from 1 to 100.|Number|Yes (initial value: **1**)|
| [proxyDatas](#proxydatas) | List of data proxies provided by the module.| Object array| Yes (initial value: left empty)|
| [proxyDatas<sup>(deprecated)</sup>](#proxydatasdeprecated) | This API is deprecated since API version 10. You are advised to use **proxydata** instead. List of data proxies provided by the module.| Object array| Yes (initial value: left empty)|
| [proxyData](#proxydata) | List of data proxies provided by the module.| Object array| Yes (initial value: left empty)|
| isolationMode | Multi-process configuration of the module. The options are as follows:<br>- **nonisolationFirst**: The module preferentially runs in a non-independent process.<br>- **isolationFirst**: The module preferentially runs in an independent process.<br>- **isolationOnly**: The module runs only in an independent process.<br>- **nonisolationOnly**: The module runs only in non-independent processes.|String|Yes (initial value: **nonisolationFirst**)|
| generateBuildHash |Whether the hash value of the HAP or HSP file is generated by the packaging tool. The hash value (if any) is used to determine whether the application needs to be updated when the system is updated in OTA mode but the **versionCode** value of the application remains unchanged.<br>This tag is enabled only when the **generateBuildHash** tag in the [app.json5](./app-configuration-file.md) file is **false**.<br>**NOTE**<br>This tag applies only to system applications.|Boolean|Yes (initial value: **false**)|
| generateBuildHash |Whether the hash value of the HAP or HSP file is generated by the packaging tool. The hash value (if any) is used to determine whether the application needs to be updated when the system is updated in OTA mode but the **versionCode** value of the application remains unchanged.<br>This tag is enabled only when the **generateBuildHash** tag in the [app.json5](./app-configuration-file.md) file is **false**.**<br>**NOTE**<br>This tag applies only to system applications.**|Boolean|Yes (initial value: **false**)|
| compressNativeLibs | Whether the **libs** libraries are packaged in the HAP file after being compressed.<br>- **true**: The **libs** libraries are packaged in the HAP file after being compressed.<br>- **false**: The **libs** libraries are stored without being compressed and will be directly loaded during the installation of the HAP file.| Boolean| Yes (initial value: **true**)|
## deviceTypes
......@@ -256,7 +257,7 @@ The **abilities** tag represents the UIAbility configuration of the module, whic
| minWindowWidth | Minimum window width supported by the UIAbility component, in vp. The minimum value is 0, and the value cannot be less than the minimum window width allowed by the platform or greater than the value of **maxWindowWidth**. For details about the window size, see [Constraints](../windowmanager/window-overview.md#constraints).| Number| Yes (initial value: minimum window width supported by the platform)|
| maxWindowHeight | Maximum window height supported by the UIAbility component, in vp. The minimum value is 0, and the value cannot be less than the value of **minWindowHeight** or greater than the maximum window height allowed by the platform. For details about the window size, see [Constraints](../windowmanager/window-overview.md#constraints).| Number| Yes (initial value: maximum window height supported by the platform)|
| minWindowHeight | Minimum window height supported by the UIAbility component, in vp. The minimum value is 0, and the value cannot be less than the minimum window height allowed by the platform or greater than the value of **maxWindowHeight**. For details about the window size, see [Constraints](../windowmanager/window-overview.md#constraints).| Number| Yes (initial value: minimum window height supported by the platform)|
| excludeFromMissions | Whether the UIAbility component is displayed in the recent task list.<br>- **true**: displayed in the recent task list.<br>- **false**: not displayed in the recent task list.<br>**NOTE**<br>This attribute applies only to system applications and does not take effect for third-party applications.| Boolean| Yes (initial value: **false**)|
| excludeFromMissions | Whether the UIAbility component is displayed in the recent task list.<br>- **true**: displayed in the recent task list.<br>- **false**: not displayed in the recent task list.<br>**NOTE**<br>This attribute applies only to system applications and requires the **AllowAbilityExcludeFromMissions** privilege. Learn [Application Privilege Configuration](../../device-dev/subsystems/subsys-app-privilege-config-guide.md).| Boolean| Yes (initial value: **false**)|
| recoverable | Whether the application can be recovered to its previous state in case of a detected fault.<br>- **true**: The application can be recovered to its previous state in case of a detected fault.<br>- **false**: The application cannot be recovered to its previous state in case of a detected fault.| Boolean| Yes (initial value: **false**)|
| unclearableMission | Whether the UIAbility component is unclearable in the recent tasks list.<br>- **true**: The UIAbility component is unclearable in the recent tasks list.<br>- **false**: The UIAbility component is clearable in the recent tasks list.<br>**NOTE**<br>This attribute works only after the [AllowMissionNotCleared](../../device-dev/subsystems/subsys-app-privilege-config-guide.md) privilege is obtained.| Boolean| Yes (initial value: **false**)|
......@@ -379,7 +380,7 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie
| type | Type of the ExtensionAbility component. The options are as follows:<br>- **form**: ExtensionAbility of a widget.<br>- **workScheduler**: ExtensionAbility of a Work Scheduler task.<br>- **inputMethod**: ExtensionAbility of an input method.<br>- **service**: service component running in the background.<br>- **accessibility**: ExtensionAbility of an accessibility feature.<br>- **dataShare**: ExtensionAbility for data sharing.<br>- **fileShare**: ExtensionAbility for file sharing.<br>- **staticSubscriber**: ExtensionAbility for static broadcast.<br>- **wallpaper**: ExtensionAbility of the wallpaper.<br>- **backup**: ExtensionAbility for data backup.<br>- **window**: ExtensionAbility of a window. This type of ExtensionAbility creates a window during startup for which you can develop the GUI. The window is then combined with other application windows through **abilityComponent**.<br>- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.<br>- **preview**: ExtensionAbility for preview. This type of ExtensionAbility can parse the file and display it in a window. You can combine the window with other application windows.<br>- **print**: ExtensionAbility for the print framework.<br>- **push**: ExtensionAbility to be pushed.<br>- **driver**: ExtensionAbility for the driver framework.<br>**NOTE**<br>The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications.| String| No|
| permissions | Permissions required for another application to access the ExtensionAbility component.<br>The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of permission names predefined by the system or customized. The name of a customized permission must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty)|
| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.<br>**NOTE**<br>This attribute is mandatory when the type of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)|
|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.<br>Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application, but not for an OpenHarmony service.| Array| Yes (initial value: left empty)|
|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.<br>Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application,<br>but not for an OpenHarmony service.| Array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)|
| exported | Whether the ExtensionAbility component can be called by other applications. <br>- **true**: The ExtensionAbility component can be called by other applications.<br>- **false**: The ExtensionAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
......@@ -737,7 +738,9 @@ Example of the **dependencies** structure:
}
```
## proxyDatas
## proxyDatas<sup>(deprecated)</sup>
>This API is supported since API version 10 and deprecated since API version 10. You are advised to use [proxyData](#proxydata) instead.
The **proxyDatas** tag provides the list of data proxies provided by the module. It can be configured only for entry and feature modules.
......@@ -768,3 +771,35 @@ Example of the **proxyDatas** structure:
}
}
```
## proxyData
The **proxyDatas** tag provides the list of data proxies provided by the module. It can be configured only for entry and feature modules.
**Table 21** proxyData
| Name | Description | Data Type| Initial Value Allowed|
| ----------- | ------------------------------ | -------- | ---------- |
| uri | URI of the data proxy. The URIs configured for different data proxies must be unique and must be in the *datashareproxy://Current application package name/xxx* format. | String | No|
| requiredReadPermission | Permission required for reading data from the data proxy. For non-system applications, this field is mandatory, and the permission level must be system_basic or system_core. For system applications, this field is optional, and the permission level is not limited. For details about the permission level, see [Application Permission List](../security/permission-list.md).| String | Yes (initial value: left empty)|
| requiredWritePermission | Permission required for writing data to the data proxy. For non-system applications, this field is mandatory, and the permission level must be system_basic or system_core. For system applications, this field is optional, and the permission level is not limited. For details about the permission level, see [Application Permission List](../security/permission-list.md).| String | Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata of the data proxy. Only the **name** and **resource** fields can be configured.| Object| Yes (initial value: left empty)|
Example of the **proxyData** structure:
```json
{
"module": {
"proxyData": [
{
"uri":"datashareproxy://com.ohos.datashare/event/Meeting",
"requiredReadPermission": "ohos.permission.GET_BUNDLE_INFO",
"requiredWritePermission": "ohos.permission.GET_BUNDLE_INFO",
"metadata": {
"name": "datashare_metadata",
"resource": "$profile:datashare"
}
}
]
}
}
```
......@@ -29,8 +29,9 @@ The application model is the abstraction of capabilities required by OpenHarmony
Along its evolution, OpenHarmony has provided two application models:
- Feature Ability (FA) model. This model is supported by OpenHarmony API version 7 and 8. It is no longer recommended. For details about development based on the FA model, see [FA Model Development Overview](../application-models/fa-model-development-overview.md).
- Stage model. This model is supported since OpenHarmony API version 9. It is recommended and will evolve for a long time. In this model, classes such as **AbilityStage** and **WindowStage** are provided as the stage of application components and windows. That's why it is named stage model. For details about development based on the stage model, see [Stage Model Development Overview](../application-models/fa-model-development-overview.md).
- **Stage model**: This model is supported since API version 9. It is recommended. In this model, classes such as **AbilityStage** and **WindowStage** are provided as the stage of application components and windows. That's why it is named stage model. For details about development based on the stage model, see [Stage Model Development Overview](../application-models/stage-model-development-overview.md). The examples in this document are all based on the stage model.
- **Feature Ability (FA) model**: This model is supported since API version 7. It is no longer recommended. For details about development based on the FA model, see [FA Model Development Overview](../application-models/fa-model-development-overview.md).
For details about the differences between the FA model and stage model, see [Interpretation of the Application Model](../application-models/application-model-description.md).
......@@ -39,8 +40,8 @@ To help you better understand the preceding basic concepts and application devel
## Tool Preparation
1. Download the latest version of [DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio).
1. Download the latest version of [DevEco Studio](../../release-notes/OpenHarmony-v4.0-beta1.md#version-mapping).
2. Install DevEco Studio and configure the development environment. For details, see [Setting Up the Development Environment](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/environment_config-0000001052902427-V3).
When you are done, follow the instructions in [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md), [Getting Started with ArkTS in FA Model](start-with-ets-fa.md), and [Getting Started with JavaScript in FA Model](start-with-js-fa.md).
When you are done, follow the instructions in [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md).
# Getting Started with ArkTS in Stage Model
> **NOTE**
>
> To use ArkTS, your DevEco Studio must be V3.0.0.900 Beta3 or later.
>
> For best possible results, use [DevEco Studio 3.1 Beta2](https://developer.harmonyos.com/cn/develop/deveco-studio) for your development.
> **NOTE**
>
> To use ArkTS, your DevEco Studio must be V3.0.0.900 Beta3 or later.
>
> In this document, DevEco Studio 4.0 Beta1 is used. You can download it [here](../../release-notes/OpenHarmony-v4.0-beta1.md#version-mapping).
## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
The procedure for creating a project varies, depending on whether the API version is later than 9 or not.
The following describes how to create the OpenHarmony projects of API 10 and API 9.
### Creating a Project of API Version 10
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar.
2. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png)
2. On the project configuration page, set **Compile SDK** to **9**, **Model** to **Stage**, and retain the default values for other parameters.
3. On the project configuration page, set **Compile SDK** to **3.1.0(API 9** and retain the default values for other parameters.
![chooseStageModel](figures/chooseStageModel.png)
......@@ -25,27 +32,102 @@
> On the low-code development pages, you can design your application UI in an efficient, intuitive manner, with a wide array of UI editing features.
>
> To use the low-code development mode, turn on **Enable Super Visual** on the page shown above.
3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created.
4. After the project is created, in the **entry** > **build-profile.json5** file, change **runtimeOS** under **targets** to **OpenHarmony**, and click **Sync Now** in the upper right corner to start development.
4. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created.
5. After the project is created, in the project-level **build-profile.json5** file, move the **compileSdkVersion** and **compatibleSdkVersion** fields from under **app** to under the current **products**. You can identify the current **products** by clicking the ![en-us_image_0000001609333677](figures/en-us_image_0000001609333677.png) icon in the upper right corner of the editing area.
![changeToAPI10](figures/changeToAPI10.png)
6. Change the value of **targetSdkVersion** from **9** to **10** and set **runtimeOS** to **OpenHarmony**.
![targetSdkVersion](figures/targetSdkVersion.png)
7. Delete the **runtimeOS** configuration from the **targets** field in all module-level **build-profile.json5** files.
![deleteRuntimeOS](figures/deleteRuntimeOS.png)
8. Click **Sync Now** and wait until the synchronization is complete. A project of API version 10 is now created.
### Creating a Project of API Version 9
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar.
2. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png)
3. On the project configuration page, set **Compile SDK** to **3.1.0(API 9** and retain the default values for other parameters.
![chooseStageModel](figures/chooseStageModel.png)
> **NOTE**
>
> You can use the low-code development mode apart from the traditional coding approach.
>
> On the low-code development pages, you can design your application UI in an efficient, intuitive manner, with a wide array of UI editing features.
>
> To use the low-code development mode, turn on **Enable Super Visual** on the page shown above.
4. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created.
5. In the module-level **entry** > **build-profile.json5** file, set **runtimeOS** in **targets** to **OpenHarmony**.
6. Click **Sync Now** and wait until the synchronization is complete. A project of API version 9 is now created.
## ArkTS Project Directory Structure (Stage Model, API Version 10)
![en-us_image_0000001364054489](figures/en-us_image_0000001364054489.png)
- **AppScope > app.json5**: application-level configuration information.
- **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)).
- **src > main > ets**: a collection of ArkTS source code.
- **src > main > ets > entryability**: entry to your application/service.
- **src > main > ets > pages**: pages included in your application/service.
- **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. For details about resource files, see [Resource Categories and Access](resource-categories-and-access.md#resource-categories).
- **src > main > module.json5**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [module.json5 Configuration File](module-configuration-file.md).
- **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**.
- **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation in this file.
- **oh_modules**: third-party library dependency information. For details about how to adapt a historical npm project to ohpm, see [Manually Migrating Historical Projects](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212).
- **build-profile.json5**: application-level configuration options, including **signingConfigs** and **products**. The **runtimeOS** field in **products** indicates the runtime OS. Its default value is **HarmonyOS**. If you are developing an OpenHarmony application, change the value to **OpenHarmony**.
## ArkTS Project Directory Structure (Stage Model)
- **hvigorfile.ts**: application-level build script.
## ArkTS Project Directory Structure (Stage Model, API Version 9)
![en-us_image_0000001364054489](figures/en-us_image_0000001364054489.png)
- **AppScope** > **app.json5**: global configuration of your application.
- **AppScope > app.json5**: application-level configuration information.
- **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)).
- **src > main > ets**: a collection of ArkTS source code.
- **src > main > ets > entryability**: entry to your application/service.
- **src > main > ets > pages**: pages included in your application/service.
- **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. For details about resource files, see [Resource Categories and Access](resource-categories-and-access.md#resource-categories).
- **src > main > module.json5**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [module.json5 Configuration File](module-configuration-file.md).
- **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. Under **targets**, you can set **runtimeOS** to **HarmonyOS** (default) or **OpenHarmony**, depending on the OS of your application.
- **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation.
- **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. The **runtimeOS** field in **targets** indicates the runtime OS. Its default value is **HarmonyOS**. If you are developing an OpenHarmony application, change the value to **OpenHarmony**.
- **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation in this file.
- **oh_modules**: third-party library dependency information. For details about how to adapt a historical npm project to ohpm, see [Manually Migrating Historical Projects](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212).
- **build-profile.json5**: application-level configuration information, including the signature and product configuration.
- **build-profile.json5**: application-level configuration information, including the **signingConfigs** and **products** configuration.
- **hvigorfile.ts**: application-level build script.
......@@ -127,7 +209,7 @@
![secondPage](figures/secondPage.png)
> **NOTE**
> **NOTE**
>
> You can also right-click the **pages** folder and choose **New** > **Page** from the shortcut menu. In this scenario, you do not need to manually configure page routes.
- Configure the route for the second page: In the **Project** window, choose **entry** > **src** > **main** > **resources** > **base** > **profile**. In the **main_pages.json** file, set **pages/Second** under **src**. The sample code is as follows:
......
# Development References
- [SystemCapability](syscap.md)
- [SystemCapability List](syscap-list.md)
- [ArkTS API Reference](apis/Readme-EN.md)
- [Component Reference (ArkTS-based Declarative Development Paradigm)](arkui-ts/Readme-EN.md)
- [Component Reference (JavaScript-compatible Web-like Development Paradigm)](arkui-js/Readme-EN.md)
- [JS Service Widget UI Component Reference](js-service-widget-ui/Readme-EN.md)
- [API Reference (ArkTS and JS APIs)](apis/Readme-EN.md)
- [Component Reference (JavaScript-compatible Web-like Development Paradigm - ArkUI.Full)](arkui-js/Readme-EN.md)
- [Component Reference (JavaScript-compatible Web-like Development Paradigm - ArkUI.Lite)](arkui-js-lite/Readme-EN.md)
- [JavaScript Service Widget UI Component Reference](js-service-widget-ui/Readme-EN.md)
- [Error Codes](errorcodes/Readme-EN.md)
- API Reference (Native APIs)
- [Standard Libraries Supported by Native APIs](native-lib/Readme-EN.md)
- Native API Reference
- [Native APIs](native-apis/Readme-EN.md)
- [Standard Libraries](native-lib/Readme-EN.md)
......@@ -397,7 +397,7 @@
- [@ohos.enterprise.networkManager (Network Management)](js-apis-enterprise-networkManager.md)
- [@ohos.enterprise.wifiManager (Wi-Fi Management)](js-apis-enterprise-wifiManager.md)
- Language Base Class Library
- Common Library
- [@ohos.buffer (Buffer)](js-apis-buffer.md)
- [@ohos.convertxml (XML-to-JavaScript Conversion)](js-apis-convertxml.md)
- [@ohos.process (Obtaining Process Information)](js-apis-process.md)
......
# Common Events of the Account Subsystem
This document lists the common system events provided by the account subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_USER_ADDED
Indicates that a user has been added to the system.
- Value: usual.event.USER_ADDED
- Required subscriber permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS
When a system account is created, the event notification service is triggered to publish this event carrying the system account ID.
APIs related to this event: **createOsAccount** and **createOsAccountForDomain**. These APIs are system APIs. For details, see [@ohos.account.osAccount (OS Account Management)](../js-apis-osAccount.md).
## COMMON_EVENT_USER_REMOVED
Indicates that a user has been removed from the system.
- Value: usual.event.USER_REMOVED
- Required subscriber permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS
When a system account is removed, the event notification service is triggered to publish this event carrying the system account ID.
APIs related to this event: **removeOsAccount**. This API is a system API. For details, see [@ohos.account.osAccount (OS Account Management)](../js-apis-osAccount.md).
## COMMON_EVENT_DOMAIN_ACCOUNT_STATUS_CHANGED<sup>10+<sup>
Indicates that the status of the domain account status changes.
- Value: usual.event.DOMAIN_ACCOUNT_STATUS_CHANGED
- Required subscriber permissions: ohos.permission.GET_LOCAL_ACCOUNTS
When a domain user account is authenticated, deleted, or has the token updated, the event notification service is triggered to publish this event carrying the system account ID, domain name, and account status.
APIs related to this event: **removeOsAccount**, **DomainAccountManager.auth**, and **updateAccountToken**. These APIs are system APIs. For details, see [@ohos.account.osAccount (OS Account Management)](../js-apis-osAccount.md).
## COMMON_EVENT_USER_SWITCHED
Indicates that user switching is in progress.
- Value: usual.event.USER_SWITCHED
- Required subscriber permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS
When the system account is switched, the event notification service is triggered to publish this event carrying the system account ID.
APIs related to this event: **activateOsAccount**. This API is a system API. For details, see [@ohos.account.osAccount (OS Account Management)](../js-apis-osAccount.md).
## COMMON_EVENT_USER_INFO_UPDATED<sup>9+<sup>
Indicates that the user information has been updated.
- Value: **usual.event.USER_INFO_UPDATED**
- Required subscriber permissions: none
When the distributed account information, system account profile picture, or system account name is changed, the event notification service is triggered to publish this event carrying the system account ID.
APIs related to this event: **setOsAccountName**, **setOsAccountProfilePhoto**, and **setOsAccountDistributedInfon**. The first two are system APIs, and the last is a public API. For details, see [@ohos.account.osAccount (OS Account Management)](../js-apis-osAccount.md).
## COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGIN
(Reserved, not supported yet) Indicates a successful login to a distributed account.
- Value: usual.event.DISTRIBUTED_ACCOUNT_LOGIN
- Required subscriber permissions: none
## COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT
(Reserved, not supported yet) Indicates a successful logout of a distributed account.
- Value: usual.event.DISTRIBUTED_ACCOUNT_LOGOUT
- Required subscriber permissions: none
## COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID
(Reserved, not supported yet) Indicates the token of a distributed account is invalid.
- Value: usual.event.DISTRIBUTED_ACCOUNT_TOKEN_INVALID
- Required subscriber permissions: none
## COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF
(Reserved, not supported yet) Indicates that a distributed account is deregistered.
- Value: usual.event.DISTRIBUTED_ACCOUNT_LOGOFF
- Required subscriber permissions: none
# Common Events of the File Management Subsystem
This document lists the common system events provided by the file management subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_VOLUME_REMOVED<sup>9+<sup>
Indicates that an external storage device was removed.
- Value: usual.event.data.VOLUME_REMOVED
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
When an external storage device is removed, the event notification service is triggered to publish this event.
## COMMON_EVENT_VOLUME_UNMOUNTED<sup>9+<sup>
Indicates that an external storage device was unmounted.
- Value: usual.event.data.VOLUME_UNMOUNTED
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
When an external storage device is successfully unmounted by calling [unmount](../js-apis-file-volumemanager.md) or by removing the device, the event notification service is triggered to publish this event.
## COMMON_EVENT_VOLUME_MOUNTED<sup>9+<sup>
Indicates that an external storage device was mounted.
- Value: usual.event.data.VOLUME_MOUNTED
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
When an external storage device is mounted by calling [mount](../js-apis-file-volumemanager.md) or by inserting the device, the event notification service is triggered to publish this event.
## COMMON_EVENT_VOLUME_BAD_REMOVAL<sup>9+<sup>
Indicates that an external storage device was removed without being unmounted.
- Value: usual.event.data.VOLUME_BAD_REMOVAL
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
When an external storage device is directly removed without being umounted, the event notification service is triggered to publish this event.
## COMMON_EVENT_VOLUME_EJECT<sup>9+<sup>
Indicates that an external storage device is about to be ejected.
- Value: usual.event.data.VOLUME_EJECT
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
When the user calls [unmount](../js-apis-file-volumemanager.md) on a mounted external storage device or removes the device, the event notification service is triggered to publish this event.
# Common Events of the SMS Application
This document lists the common system events provided by the SMS application to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_SMS_RECEIVE_COMPLETED
Indicates that a new SMS message has been received.
- Value: usual.event.SMS_RECEIVE_COMPLETED
- Required subscriber permissions: none
When the device receives a new SMS message, the event notification service is triggered to publish this event.
# Common Events of the Network Management Subsystem
This document lists the common system events provided by the network management subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_CONNECTIVITY_CHANGE<sup>10+<sup>
Indicates that the network connection state has changed.
- Value: usual.event.CONNECTIVITY_CHANGE
- Required subscriber permissions: none
When the (Ethernet, Wi-Fi, or cellular) network connection state changes (to disconnected, connecting, or connected), the event notification service is triggered to publish this event.
## COMMON_EVENT_AIRPLANE_MODE_CHANGED<sup>10+<sup>
Indicates that the airplane mode state has changed.
- Value: usual.event.AIRPLANE_MODE
- Required subscriber permissions: none
When the airplane mode is set, the event notification service is triggered to publish this event.
## COMMON_EVENT_HTTP_PROXY_CHANGE<sup>10+<sup>
Indicates that the HTTP proxy configuration has changed.
- Value: usual.event.HTTP_PROXY_CHANGE
- Required subscriber permissions: none
When the configuration of the global or network-specific (such as Ethernet and Wi-Fi) HTTP proxy changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_NET_QUOTA_WARNING<sup>10+<sup>
Indicates that the network data usage has reached the alarm threshold.
- Value: usual.event.QUOTA_WARNING
- Required subscriber permissions: none
When the network data usage reaches 80% of the limit, the event notification service is triggered to publish this event.
## COMMON_EVENT_NET_QUOTA_LIMIT_REMINDED<sup>10+<sup>
Indicates that the network data usage has reached the upper limit, and network access is still available.
- Value: usual.event.NET_QUOTA_LIMIT_REMINDED
- Required subscriber permissions: none
When the network data usage reaches the upper limit and the user chooses to continue to use the network, the event notification service is triggered to publish this event.
## COMMON_EVENT_NET_QUOTA_LIMIT<sup>10+<sup>
Indicates that the network data usage has reached the upper limit, and network access becomes unavailable.
- Value: usual.event.NET_QUOTA_LIMIT
- Required subscriber permissions: none
When the network data usage reaches the upper limit and continuing to use the network is not allowed, the event notification service is triggered to publish this event.
# Common Events of the NFC Subsystem
This document lists the common system events provided by the NFC subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED
Indicates that the state of the device NFC adapter has changed.
- Value: usual.event.nfc.action.ADAPTER_STATE_CHANGED
- Required subscriber permissions: none
When the state of the device NFC adapter changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED
Indicates that the NFC RF field is on.
- Value: usual.event.nfc.action.RF_FIELD_ON_DETECTED
- Required subscriber permissions: ohos.permission.MANAGE_SECURE_SETTINGS
When the NFC RF field becomes available, the event notification service is triggered to publish this event.
## COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED
Indicates that the NFC RF field is off.
- Value: usual.event.nfc.action.RF_FIELD_OFF_DETECTED
- Required subscriber permissions: ohos.permission.MANAGE_SECURE_SETTINGS
When the NFC RF field becomes unavailable, the event notification service is triggered to publish this event.
# Common Events of the Power Management Subsystem
This document lists the common system events provided by the power management subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_BATTERY_CHANGED
Indicates that the charging state, level, and other information about the battery have changed.
- Value: usual.event.BATTERY_CHANGED
- Required subscriber permissions: none
When any of the following information changes, the event notification service is triggered to publish this event: battery level, battery voltage, battery temperature, battery health status, type of the charger connected to the device, maximum current of the charger, maximum voltage of the charger, battery charging status, number of charging times, total battery capacity, remaining battery capacity, battery model, current of the battery, and battery charging type.
## COMMON_EVENT_BATTERY_LOW
Indicates that the battery level is low.
- Value: usual.event.BATTERY_LOW
- Required subscriber permissions: none
When the battery level drops to lower than the low battery level set for the device, the event notification service is triggered to publish this event. For details about how to set the low battery level, see [Battery Level Customization](../../../../device-dev/subsystems/subsys-power-battery-level-customization.md).
## COMMON_EVENT_BATTERY_OKAY
Indicates that the battery level is normal.
- Value: usual.event.BATTERY_OKAY
- Required subscriber permissions: none
When the battery level changes from the low level to normal level, the event notification service is triggered to publish this event.
## COMMON_EVENT_POWER_CONNECTED
Indicates that the device is connected to an external power supply.
- Value: usual.event.POWER_CONNECTED
- Required subscriber permissions: none
When the device connects to an external charger, the event notification service is triggered to publish this event.
## COMMON_EVENT_POWER_DISCONNECTED
Indicates that the device is disconnected from the external power supply.
- Value: usual.event.POWER_DISCONNECTED
- Required subscriber permissions: none
When the device is disconnected from the external power supply, the event notification service is triggered to publish this event.
## COMMON_EVENT_DISCHARGING
Indicates that the system stops charging the battery.
- Value: usual.event.DISCHARGING
- Required subscriber permissions: none
When the system stops charging the battery, the event notification service is triggered to publish this event.
## COMMON_EVENT_CHARGING
Indicates that the system starts charging the battery.
- Value: usual.event.CHARGING
- Required subscriber permissions: none
When the system starts charging the battery, the event notification service is triggered to publish this event.
## COMMON_EVENT_CHARGE_TYPE_CHANGED
Indicates that the system charging type has changed. This event is available only for system applications.
- Value: usual.event.CHARGE_TYPE_CHANGED
- Required subscriber permissions: none
When the system charging type changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_SHUTDOWN
Indicates that the device is being and will be shut down.
- Value: usual.event.SHUTDOWN
- Required subscriber permissions: none
When the device is being shut down until it is powered off, the event notification service is triggered to publish this event.
## COMMON_EVENT_SCREEN_OFF
Indicates that the device screen is off and the device is in sleep mode.
- Value: usual.event.SCREEN_OFF
- Required subscriber permissions: none
When the device screen is turned off and the device is in sleep mode, the event notification service is triggered to publish this event.
## COMMON_EVENT_SCREEN_ON
Indicates that the device screen is on and the device is in the active state.
- Value: usual.event.SCREEN_ON
- Required subscriber permissions: none
When the device screen is turned on and in the active state, the event notification service is triggered to publish this event.
## COMMON_EVENT_POWER_SAVE_MODE_CHANGED
Indicates that the system power saving mode has changed.
- Value: usual.event.POWER_SAVE_MODE_CHANGED
- Required subscriber permissions: none
When the system power saving mode changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_THERMAL_LEVEL_CHANGED
Indicates that the device's thermal level has changed.
- Value: usual.event.THERMAL_LEVEL_CHANGED
- Required subscriber permissions: none
When the device's thermal level changes, the event notification service is triggered to publish this event. For details about how to configure the thermal level, see [Thermal Level Customization](../../../../device-dev/subsystems/subsys-thermal_level.md).
# Common Events of the Theme Framework - Lock Screen
This document lists the common system events provided by the theme framework - lock screen to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_SCREEN_LOCKED
Indicates that the screen has been locked.
- Value: usual.event.SCREEN_LOCKED
- Required subscriber permissions: none
When the screen is locked, the event notification service is triggered to publish this event.
## COMMON_EVENT_SCREEN_UNLOCKED
Indicates that the screen has been unlocked.
- Value: usual.event.SCREEN_UNLOCKED
- Required subscriber permissions: none
When the screen is unlocked, the event notification service is triggered to publish this event.
# Common Events of the Time and Time Zone Subsystem
This document lists the common system events provided by the time and time zone subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_TIME_CHANGED
Indicates that the system time has been set.
- Value: usual.event.TIME_CHANGED
- Required subscriber permissions: none
When the system time is set, the event notification service is triggered to publish this event.
## COMMON_EVENT_TIME_TICK
Indicates that the system time has changed.
- Value: usual.event.TIME_TICK
- Required subscriber permissions: none
When the system time changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_TIMEZONE_CHANGED
Indicates that the system time zone has changed.
- Value: usual.event.TIMEZONE_CHANGED
- Required subscriber permissions: none
When the system time zone changes, the event notification service is triggered to publish this event.
# Common Events of the Wi-Fi Subsystem
This document lists the common system events provided by the Wi-Fi subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
## COMMON_EVENT_WIFI_POWER_STATE
Indicates that the Wi-Fi state has changed, for example, enabled or disabled.
- Value: usual.event.wifi.POWER_STATE
- Required subscriber permissions: none
When the Wi-Fi state changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_SCAN_FINISHED
Indicates that the Wi-Fi access point has been detected and proven to be available.
- Value: usual.event.wifi.SCAN_FINISHED
- Required subscriber permissions: ohos.permission.LOCATION
When a Wi-Fi access point is detected and proven to be available, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_SCAN_STATE
Indicates that the Wi-Fi access point state has changed.
- Value: usual.event.wifi.SCAN_STATE
- Required subscriber permissions: ohos.permission.LOCATION
When the Wi-Fi access point state changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_RSSI_VALUE
Indicates that the Wi-Fi signal strength (RSSI) has changed.
- Value: usual.event.wifi.RSSI_VALUE
- Required subscriber permissions: ohos.permission.GET_WIFI_INFO
When the Wi-Fi signal strength (RSSI) changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_CONN_STATE
Indicates that the Wi-Fi connection state has changed.
- Value: usual.event.wifi.CONN_STATE
- Required subscriber permissions: none
When the Wi-Fi connection state changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_HOTSPOT_STATE
Indicates that the Wi-Fi hotspot state has changed, for example, enabled or disabled.
- Value: usual.event.wifi.HOTSPOT_STATE
- Required subscriber permissions: none
When the Wi-Fi hotspot state changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_AP_STA_JOIN
Indicates that a client has joined the Wi-Fi hotspot of the current device.
- Value: usual.event.wifi.WIFI_HS_STA_JOIN
- Required subscriber permissions: ohos.permission.GET_WIFI_INFO
When a client joins the Wi-Fi hotspot of the current device, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_AP_STA_LEAVE
Indicates that a client has disconnected from the Wi-Fi hotspot of the current device.
- Value: usual.event.wifi.WIFI_HS_STA_LEAVE
- Required subscriber permissions: ohos.permission.GET_WIFI_INFO
When a client is disconnected from the Wi-Fi hotspot of the current device, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE
Indicates that the state of MPLINK (an enhanced Wi-Fi feature) has changed.
- Value: usual.event.wifi.mplink.STATE_CHANGE
- Required subscriber permissions: ohos.permission.MPLINK_CHANGE_STATE
When the state of MPLINK (an enhanced Wi-Fi feature) changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_P2P_CONN_STATE
Indicates that the Wi-Fi P2P connection state has changed.
- Value: usual.event.wifi.p2p.CONN_STATE_CHANGE
- Required subscriber permissions: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION
When the Wi-Fi P2P connection state changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_P2P_STATE_CHANGED
Indicates that the Wi-Fi P2P state has changed, for example, enabled or disabled.
- Value: usual.event.wifi.p2p.STATE_CHANGE
- Required subscriber permissions: ohos.permission.GET_WIFI_INFO
When the Wi-Fi P2P state changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED
Indicates that the state of the Wi-Fi P2P peer device has changed.
- Value: usual.event.wifi.p2p.DEVICES_CHANGE
- Required subscriber permissions: ohos.permission.GET_WIFI_INFO
When the state of the Wi-Fi P2P peer device changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED
Indicates that the Wi-Fi P2P discovery state has changed.
- Value: usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE
- Required subscriber permissions: ohos.permission.GET_WIFI_INFO
When the Wi-Fi P2P discovery state changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED
Indicates that the state of the Wi-Fi P2P local device has changed.
- Value: usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE
- Required subscriber permissions: ohos.permission.GET_WIFI_INFO
When the state of the Wi-Fi P2P local device changes, the event notification service is triggered to publish this event.
## COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED
Indicates that the Wi-Fi P2P group information has changed.
- Value: usual.event.wifi.p2p.GROUP_STATE_CHANGED
- Required subscriber permissions: ohos.permission.GET_WIFI_INFO
When the Wi-Fi P2P group information changes, the event notification service is triggered to publish this event.
# Common Events of the Window Management Subsystem
This document lists the common system events provided by the window management subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events.
### COMMON_EVENT_SPLIT_SCREEN<sup>10+</sup>
Indicates a screen splitting action.
- Value: usual.event.SPLIT_SCREEN
- Required subscriber permissions: none
When any of the following actions is performed, the event notification service is triggered to publish this event: accessing the recent tasks screen, creating a split-screen bar, and destroying a split-screen bar.
......@@ -707,7 +707,7 @@ let connectId = featureAbility.connectAbility(
);
featureAbility.disconnectAbility(connectId).then((data) => {
console.log('data: ${data)}';
console.log('data: ${data)}')
}).catch((error)=>{
console.error('featureAbilityTest result errCode : ${error.code}');
});
......
......@@ -7,7 +7,10 @@ The **Animator** module provides APIs for applying animation effects, including
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md).
>
> The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see [UIContext](./js-apis-arkui-UIContext.md#uicontext).
>
> Since API version 10, you can use the [createAnimator](./js-apis-arkui-UIContext.md#createanimator) API in [UIContext](./js-apis-arkui-UIContext.md#uicontext) to obtain the UI context.
## Modules to Import
......
......@@ -298,7 +298,7 @@ appManager.getRunningProcessInformation((err, data) => {
});
```
## appManager.isSharedBundleRunning
## appManager.isSharedBundleRunning<sup>10+</sup>
isSharedBundleRunning(bundleName: string, versionCode: number): Promise\<boolean>;
......@@ -323,11 +323,20 @@ Checks whether the shared library is in use. This API uses a promise to return t
| -------- | -------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the shared library is in use, and **false** means the opposite.|
**Error codes**
| ID | Error Message |
| 16000050 | Internal error. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
import appManager from '@ohos.app.ability.appManager';
const bundleName = "this is a bundleName";
const versionCode = 1;
appManager.isSharedBundleRunning(bundleName, versionCode).then((data) => {
console.log('The shared bundle running is: ${JSON.stringify(data)}');
}).catch((error) => {
......@@ -335,7 +344,7 @@ appManager.isSharedBundleRunning(bundleName, versionCode).then((data) => {
});
```
## appManager.isSharedBundleRunning
## appManager.isSharedBundleRunning<sup>10+</sup>
isSharedBundleRunning(bundleName: string, versionCode: number, callback: AsyncCallback\<boolean>): void;
......@@ -353,18 +362,22 @@ Checks whether the shared library is in use. This API uses an asynchronous callb
| --------- | ---------------------------------------- | ---- | -------------- |
| bundleName | string | Yes | Bundle name of the shared library.|
| versionCode | number | Yes | Version number of the shared library. |
|AsyncCallback\<boolean>> | Callback used to return the result. The value **true** means that the shared library is in use, and **false** means the opposite.|
**Return value**
**Error codes**
| Type| Description|
| -------- | -------- |
|AsyncCallback\<boolean>> | Callback used to return the result. The value **true** means that the shared library is in use, and **false** means the opposite.|
| ID | Error Message |
| 16000050 | Internal error. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
import appManager from '@ohos.app.ability.appManager';
const bundleName = "this is a bundleName";
const versionCode = 1;
appManager.isSharedBundleRunning(bundleName, versionCode, (err, data) => {
if (err) {
console.error('err: ${JSON.stringify(err)}');
......
......@@ -173,6 +173,8 @@ Saves the ability state, which will be used for recovery. This API can be used t
```ts
import appRecovery from '@ohos.app.ability.appRecovery';
import errorManager from '@ohos.app.ability.errorManager';
let observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg);
......
......@@ -324,7 +324,7 @@ setRequestResult(result: RequestResult): void;
Sets the result of the request for the modal dialog box.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
......
......@@ -7,4 +7,10 @@
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import ExtensionAbility from '@ohos.app.ability.ExtensionAbility';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
......@@ -946,7 +946,7 @@ Clears all unlocked missions. This API uses a promise to return the result.
import missionManager from '@ohos.app.ability.missionManager';
try {
missionManager.clearAllMissions(bundleName).then((data) => {
missionManager.clearAllMissions().then((data) => {
console.info('clearAllMissions successfully. Data: ${JSON.stringify(data)}');
}).catch(err => {
console.error('clearAllMissions failed: ${err.message}');
......
......@@ -57,10 +57,10 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
**Parameters**
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Error codes**
......@@ -116,15 +116,15 @@ Applies a quick fix patch. This API uses a promise to return the result.
**Parameters**
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
......@@ -225,9 +225,9 @@ Obtains the quick fix information of the application. This API uses a promise to
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
| Type| Description|
| -------- | -------- |
| Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
**Error codes**
......@@ -267,10 +267,10 @@ Revokes quick fix. This API uses an asynchronous callback to return the result.
**Parameters**
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Name of the bundle for which the patch needs to be revoked.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Name of the bundle for which the patch needs to be revoked.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Error codes**
......@@ -312,15 +312,15 @@ Revokes quick fix. This API uses a promise to return the result.
**Parameters**
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Name of the bundle for which the patch needs to be revoked.|
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Name of the bundle for which the patch needs to be revoked.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
......@@ -349,5 +349,3 @@ If an error occurs during patch installation, the error code and message are ret
console.info("revokeQuickFix " + bundleName +" failed, error code is ", JSON.stringify((err)));
});
```
<!--no_check-->
\ No newline at end of file
......@@ -19,7 +19,7 @@ import StartOptions from '@ohos.app.ability.StartOptions';
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| [windowMode](js-apis-app-ability-abilityConstant.md#abilityconstantwindowmode) | number | No| Window mode.|
| [windowMode](js-apis-app-ability-abilityConstant.md#abilityconstantwindowmode) | number | No| Window mode.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| displayId | number | No| Display ID. The default value is **0**, indicating the current display.|
**Example**
......
......@@ -339,6 +339,51 @@ class MyUIAbility extends UIAbility {
}
```
## UIAbility.onPrepareToTerminate<sup>10+</sup>
onPrepareToTerminate(): boolean;
Triggered when this UIAbility is about to terminate in case that the system parameter **persist.sys.prepare_terminate** is set to **true**. You can define an operation in this callback to determine whether to continue terminating the UIAbility. If a confirmation from the user is required, you can define a pre-termination operation in the callback and use it together with [terminateSelf](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateself), for example, displaying a dialog box to ask the user whether to terminate the UIAbility. The UIAbility termination process is canceled when **persist.sys.prepare_terminate** is set to **true**.
**Required permissions**: ohos.permission.PREPARE_APP_TERMINATE
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Return value**
| Type| Description|
| -- | -- |
| boolean | Whether to terminate the UIAbility. The value **true** means that the termination process is canceled and the UIAbility is not terminated. The value **false** means to continue terminating the UIAbility.|
**Example**
```ts
export default class EntryAbility extends UIAbility {
onPrepareToTerminate() {
// Define a pre-termination operation,
// for example, starting another UIAbility and performing asynchronous termination based on the startup result.
let want:Want = {
bundleName: "com.example.myapplication",
moduleName: "entry",
abilityName: "SecondAbility"
}
this.context.startAbilityForResult(want)
.then((result)=>{
// Obtain the startup result and terminate the current UIAbility when resultCode in the return value is 0.
console.log('startAbilityForResult success, resultCode is ' + result.resultCode);
if (result.resultCode === 0) {
this.context.terminateSelf();
}
}).catch((err)=>{
// Exception handling.
console.log('startAbilityForResult failed, err:' + JSON.stringify(err));
this.context.terminateSelf();
})
return true; // The pre-termination operation is defined. The value true means that the UIAbility termination process is canceled.
}
}
```
## Caller
......@@ -623,11 +668,12 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
let caller;
let dstDeviceId: string;
export default class MainAbility extends UIAbility {
onWindowStageCreate(windowStage: Window.WindowStage) {
onWindowStageCreate(windowStage: window.WindowStage) {
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
......@@ -643,7 +689,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
}
}).catch((err) => {
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
});
})
}
}
```
......
......@@ -176,13 +176,14 @@ import Want from '@ohos.app.ability.Want';
bundleName: 'com.example.myapplication1',
abilityName: 'ServiceExtensionAbility',
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
```ts
// (2) The ServiceExtensionAbility starts UIAbility2, carrying **"ability.params.backToOtherMissionStack": true** during the startup.
let context = ...; // ServiceExtensionContext
let context ; // ServiceExtensionContext
let want = {
bundleName: 'com.example.myapplication2',
abilityName: 'MainAbility',
......
......@@ -25,7 +25,7 @@ Defines **Params** (specifying the action that can be performed) in the Want.
| DLP_PARAMS_MODULE_NAME | ohos.dlp.params.moduleName | Action of obtaining the DLP module name.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| DLP_PARAMS_ABILITY_NAME | ohos.dlp.params.abilityName | Action of obtaining the DLP ability name.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| DLP_PARAMS_INDEX | ohos.dlp.params.index | Action of obtaining the DLP index.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| ABILITY_BACK_TO_OTHER_MISSION_STACK | ability.params.backToOtherMissionStack | Whether to support redirection back across mission stacks.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| ABILITY_BACK_TO_OTHER_MISSION_STACK | ability.params.backToOtherMissionStack | Whether to support redirection back across mission stacks. |
| ABILITY_RECOVERY_RESTART<sup>10+</sup> | ohos.ability.params.abilityRecoveryRestart | Action of recovering an ability from a fault and restarting it.|
| CONTENT_TITLE_KEY<sup>10+</sup> | ohos.extra.param.key.contentTitle | Action of sharing the content title. |
| SHARE_ABSTRACT_KEY<sup>10+</sup> | ohos.extra.param.key.shareAbstract | Action of sharing the abstract. |
......
......@@ -1563,7 +1563,7 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstall event.|
| callback | Callback&lt;string&gt; | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.<br>To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formUninstall')**. |
| callback | Callback&lt;string&gt; | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.<br>To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formUninstall')**.|
**Error codes**
......@@ -1698,8 +1698,8 @@ Unsubscribes from widget removal events. This API uses an asynchronous callback
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Event type. The value **'formRemove'** indicates a widget removal event.|
| callback | Callback&lt;formInfo.RunningFormInfo&gt; | No| Callback used to return **RunningFormInfo**. By default, all the subscriptions to the specified event are canceled.<br>To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formRemove')**. |
| bundleName | string | No| Name of the bundle that functions as the widget host.<br>To cancel the subscription for a given bundle name, this parameter must be set to the same value as **bundleName** in **on('formRemove')**.<br>By default, the subscriptions for all the widget hosts are canceled. |
| callback | Callback&lt;formInfo.RunningFormInfo&gt; | No| Callback used to return **RunningFormInfo**. By default, all the subscriptions to the specified event are canceled.<br>To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formRemove')**.|
| bundleName | string | No| Name of the bundle that functions as the widget host.<br>To cancel the subscription for a given bundle name, this parameter must be set to the same value as **bundleName** in **on('formRemove')**.<br>By default, the subscriptions for all the widget hosts are canceled.|
**Example**
......@@ -2148,6 +2148,8 @@ Requests data from the widget provider. This API uses an asynchronous callback t
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
......@@ -2162,9 +2164,11 @@ import formHost from '@ohos.app.form.formHost';
let formId = '12400633174999288';
try {
formHost.acquireFormData(formId, (error) => {
formHost.acquireFormData(formId, (error, data) => {
if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost acquireFormData, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
......@@ -2192,12 +2196,14 @@ Requests data from the widget provider. This API uses a promise to return the re
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
| Promise<{[key: string]: Object}>| Promise used to return the API call result and the shared data.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
......@@ -2210,8 +2216,8 @@ import formHost from '@ohos.app.form.formHost';
let formId = '12400633174999288';
try {
formHost.acquireFormData(formId).then(() => {
console.log('formHost acquireFormData success');
formHost.acquireFormData(formId).then((data) => {
console.log('formHost acquireFormData success' + data);
}).catch((error) => {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
......@@ -2248,9 +2254,14 @@ For details about the error codes, see [Form Error Codes](../errorcodes/errorcod
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
```ts
import formHost from '@ohos.app.form.formHost';
......@@ -2273,7 +2284,7 @@ try {
## getRunningFormInfosByFilter<sup>10+</sup>
getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void
getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter, callback: AsyncCallback&lt;Array&lt;formInfo.RunningFormInfo&gt;&gt;): void
Obtains the information about widget hosts based on the widget provider information. This API uses an asynchronous callback to return the result.
......@@ -2285,8 +2296,8 @@ Obtains the information about widget hosts based on the widget provider informat
| Name | Type | Mandatory| Description |
| ----------- | --------------- | ---- | -------------------------------- |
| formProviderFilter | formInfo.FormProviderFilter [formInfo.FormProviderFilter](js-apis-app-form-formInfo.md#formProviderFilter) | Yes | Information about the widget provider.|
| callback | AsyncCallback&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | Yes| Callback used to return the result. If the widget host information is obtained, **error** is **undefined** and **data** is the information obtained; otherwise, **data** is an error object.|
| formProviderFilter | [formInfo.FormProviderFilter](js-apis-app-form-formInfo.md#formProviderFilter) | Yes | Information about the widget provider.|
| callback | AsyncCallback&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | Yes| Callback used to return the result. If the widget host information is obtained, **error** is **undefined** and **data** is the information obtained; otherwise, **error** is an error object.|
**Error codes**
......@@ -2294,9 +2305,14 @@ For details about the error codes, see [Form Error Codes](../errorcodes/errorcod
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
```ts
import formHost from '@ohos.app.form.formHost';
......@@ -2321,7 +2337,8 @@ try {
## getRunningFormInfoById<sup>10+</sup>
getRunningFormInfoById(formId: string): Promise&lt;Array&lt;formInfo.RunningFormInfo&gt;&gt;
function getRunningFormInfoById(formId: string): Promise&lt;formInfo.RunningFormInfo&gt;
Obtains the information about widget hosts based on the widget ID. This API uses a promise to return the result.
......@@ -2339,7 +2356,7 @@ Obtains the information about widget hosts based on the widget ID. This API uses
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;Array&lt;formInfo.RunningFormInfo[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | Promise used to return the widget host information obtained. |
| Promise&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt; | Promise used to return the widget host information obtained.|
**Error codes**
......@@ -2347,9 +2364,14 @@ For details about the error codes, see [Form Error Codes](../errorcodes/errorcod
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
```ts
import formHost from '@ohos.app.form.formHost';
let formId = '12400633174999288';
......@@ -2366,7 +2388,7 @@ try {
## getRunningFormInfoById<sup>10+</sup>
getRunningFormInfoById(formId: string, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void
getRunningFormInfoById(formId: string, callback: AsyncCallback&lt;formInfo.RunningFormInfo&gt;): void
Obtains the information about widget hosts based on the widget ID. This API uses an asynchronous callback to return the result.
......@@ -2379,7 +2401,7 @@ Obtains the information about widget hosts based on the widget ID. This API uses
| Name | Type | Mandatory| Description |
| ----------- | --------------- | ---- | -------------------------------- |
| formId | string | Yes | Widget ID.|
| callback | AsyncCallback&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | Yes| Callback used to return the result. If the widget host information is obtained, **error** is **undefined** and **data** is the information obtained; otherwise, **data** is an error object.|
| callback | AsyncCallback&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt; | Yes| Callback used to return the result. If the widget host information is obtained, **error** is **undefined** and **data** is the information obtained; otherwise, **error** is an error object.|
**Error codes**
......@@ -2387,7 +2409,11 @@ For details about the error codes, see [Form Error Codes](../errorcodes/errorcod
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
```ts
......@@ -2406,3 +2432,145 @@ try {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
## on('notifyVisible')<sup>10+</sup>
on(type: 'notifyVisible', observerCallback: Callback&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt;, bundleName?: string): void
Subscribes to events indicating that a widget becomes visible.
This event is triggered when **notifyVisibleForms** is called to make a widget visible.
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. This value **'notifyVisible'** indicates a widget visibility event. |
| callback | Callback &lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | Yes | Callback used to return **RunningFormInfo** of the widget. |
| bundleName | string | No | Name of the bundle that functions as the widget host, on which the widget visibility state changes are subscribed.|
**Example**
```ts
import formHost from '@ohos.app.form.formHost';
let bundleName = 'ohos.samples.FormApplication';
let callback = function(data) {
console.log('form change visibility, data: ${JSON.stringify(data)');
}
formHost.on('notifyVisible', callback);
formHost.on('notifyVisible', callback, bundleName);
```
## off('notifyVisible')<sup>10+</sup>
off(type: "notifyVisible", observerCallback?: Callback&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt;, bundleName?: string): void
Unsubscribes from events indicating that a widget becomes visible.
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. This value **'notifyVisible'** indicates a widget visibility event.|
| callback | Callback &lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | No | Callback registered during the subscription. By default, all the subscriptions to the specified event are canceled.<br> To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('notifyVisible')**.|
| bundleName | string | No | Name of the bundle that functions as the widget host, on which the widget visibility state changes are subscribed.<br>To cancel the subscription for a given bundle name, this parameter must be set to the same value as **bundleName** in **on('notifyVisible')**. |
**Example**
```ts
import formHost from '@ohos.app.form.formHost';
let bundleName = 'ohos.samples.FormApplication';
let callback = function(data) {
console.log('form change visibility, data: ${JSON.stringify(data)');
}
formHost.off('notifyVisible', callback);
formHost.off('notifyVisible', callback, bundleName);
```
> **NOTE**
>
> - **on('notifyVisible', callback)** and **off('notifyVisible', callback)** must be used in pairs.
> - **on('notifyVisible', callback, bundleName)** and **off('notifyVisible', callback, bundleName)** must be used in pairs.
> - To cancel the subscription with a given callback or for a given bundle name, the **callback** or **bundleName** parameter in **off()** must be set to the same value as that in **on()**.
## on('notifyInvisible')<sup>10+</sup>
on(type: 'notifyInvisible', observerCallback: Callback&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;>, bundleName?: string): void
Subscribes to events indicating that a widget becomes invisible.
This event is triggered when **notifyInvisibleForms** is called to make a widget invisible.
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. This value **'notifyInvisible'** indicates a widget invisibility event. |
| callback | Callback &lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | Yes | Callback used to return **RunningFormInfo** of the widget. |
| bundleName | string | No | Name of the bundle that functions as the widget host, on which the widget visibility state changes are subscribed.|
**Example**
```ts
import formHost from '@ohos.app.form.formHost';
let bundleName = 'ohos.samples.FormApplication';
let callback = function(data) {
console.log('form change invisibility, data: ${JSON.stringify(data)');
}
formHost.on('notifyInvisible', callback);
formHost.on('notifyInvisible', callback, bundleName);
```
## off('notifyInvisible')<sup>10+</sup>
off(type: "notifyInvisible", observerCallback?: Callback&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)>&gt;, bundleName?: string): void
Unsubscribes from events indicating that a widget becomes invisible.
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. This value **'notifyInvisible'** indicates a widget invisibility event. |
| callback | Callback &lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | No | Callback registered during the subscription. By default, all the subscriptions to the specified event are canceled.<br> To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('notifyInvisible')**.|
| bundleName | string | No | Name of the bundle that functions as the widget host, on which the widget visibility state changes are subscribed.<br>To cancel the subscription for a given bundle name, this parameter must be set to the same value as **bundleName** in **on('notifyInvisible')**. |
**Example**
```ts
import formHost from '@ohos.app.form.formHost';
let bundleName = 'ohos.samples.FormApplication';
let callback = function(data) {
console.log('form change invisibility, data: ${JSON.stringify(data)');
}
formHost.off('notifyInvisible', callback);
formHost.off('notifyInvisible', callback, bundleName);
```
> **NOTE**
>
> - **on('notifyInvisible', callback)** and **off('notifyInvisible', callback)** must be used in pairs.
> - **on('notifyInvisible', callback, bundleName)** and **off('notifyInvisible', callback, bundleName)** must be used in pairs.
> - To cancel the subscription with a given callback or for a given bundle name, the **callback** or **bundleName** parameter in **off()** must be set to the same value as that in **on()**.
......@@ -18,8 +18,6 @@ Describes widget information.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable | Writable | Description |
| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
| bundleName | string | Yes | No | Name of the bundle to which the widget belongs. |
......@@ -27,6 +25,7 @@ Describes widget information.
| abilityName | string | Yes | No | Name of the ability to which the widget belongs. |
| name | string | Yes | No | Widget name. |
| description | string | Yes | No | Description of the widget. |
| descriptionId | number | Yes | No | ID of the widget description. |
| type | [FormType](#formtype) | Yes | No | Type of the widget. Currently, only JS widgets are supported.|
| jsComponentName | string | Yes | No | Name of the component used in the JS widget. |
| colorMode | [ColorMode](#colormode) | Yes | No | Color mode of the widget. |
......@@ -102,7 +101,7 @@ Enumerates the widget parameters.
| HEIGHT_KEY | 'ohos.extra.param.key.form_height' | Widget height. |
| TEMPORARY_KEY | 'ohos.extra.param.key.form_temporary' | Temporary widget. |
| ABILITY_NAME_KEY | 'ohos.extra.param.key.ability_name' | Ability name. |
| DEVICE_ID_KEY | 'ohos.extra.param.key.device_id' <br>**System API**: This is a system API and cannot be called by third-party applications. | Device ID. |
| DEVICE_ID_KEY | 'ohos.extra.param.key.device_id' | Device ID.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| BUNDLE_NAME_KEY | 'ohos.extra.param.key.bundle_name' | Key that specifies the target bundle name.|
| LAUNCH_REASON_KEY<sup>10+</sup> | 'ohos.extra.param.key.form_launch_reason' | Reason for creating the widget. |
| PARAM_FORM_CUSTOMIZE_KEY<sup>10+</sup> | 'ohos.extra.param.key.form_customize' | Custom data. |
......@@ -128,9 +127,9 @@ Defines the widget information filter. Only the widget information that meets th
**System capability**: SystemCapability.Ability.Form
| Name | Type | Description |
| ----------- | ---- | ------------ |
| moduleName | string | Optional. Only the information about the widget whose **moduleName** is the same as the provided value is returned.<br>If this parameter is not set, **moduleName** is not used for filtering. |
| Name | Type | Mandatory |Description |
| ----------- | ---- | ------------ |------------ |
| moduleName | string |No | Optional. Only the information about the widget whose **moduleName** is the same as the provided value is returned.<br>If this parameter is not set, **moduleName** is not used for filtering. |
## VisibilityType
......@@ -140,7 +139,7 @@ Enumerates the visibility types of the widget.
| Name | Value | Description |
| ----------- | ---- | ------------ |
| UNKNOWN | 0 | The visibility type of the widget is unknown.|
| UNKNOWN<sup>10+</sup> | 0 | The visibility type of the widget is unknown.|
| FORM_VISIBLE | 1 | The widget is visible.|
| FORM_INVISIBLE | 2 | The widget is invisible.|
......@@ -150,6 +149,8 @@ Defines the information about the widget host.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable | Writable | Description |
| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
| formId | string | Yes | No | Widget ID. |
......
......@@ -539,7 +539,7 @@ Checks whether a widget can be published to the widget host. This API uses an as
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 202 | If the application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
......@@ -602,7 +602,7 @@ Checks whether a widget can be published to the widget host. This API uses a pro
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 202 | If the application is not a system application. |
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
......
......@@ -307,9 +307,9 @@ Creates a session controller based on the session ID. Multiple session controlle
**Return value**
| Type | Description |
| ----------------------------------------------------- | ------------------------------------------------------------ |
| Promise<[AVSessionController](#avsessioncontroller10)\> | Promise used to return the session controller created, which can be used to obtain the session ID,<br>send commands and events to sessions, and obtain metadata and playback state information.|
| Type | Description |
| ------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<[AVSessionController](#avsessioncontroller10)\> | Promise used to return the session controller created, which can be used to obtain the session ID, send commands and events to sessions, and obtain metadata and playback state information. |
**Error codes**
......@@ -1119,6 +1119,10 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example**
```js
import image from '@ohos.multimedia.image';
import resourceManager from '@ohos.resourceManager';
let value : Uint8Array = await resourceManager.getRawFile('IMAGE_URI');
let imageSource : imageImageSource = image.createImageSource(value.buffer);
let imagePixel : image.PixelMap = await imageSource.createPixelMap({desiredSize:{width: 150, height: 150}});
let queueItemDescription_1 = {
......@@ -1139,7 +1143,7 @@ let queueItemDescription_2 = {
title: 'music_name',
subtitle: 'music_sub_name',
description: 'music_description',
icon: PIXELMAP_OBJECT,
icon: imagePixel,
iconUri: 'http://www.xxx.com',
extras: {'extras':'any'}
};
......@@ -1182,6 +1186,10 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example**
```js
import image from '@ohos.multimedia.image';
import resourceManager from '@ohos.resourceManager';
let value : Uint8Array = await resourceManager.getRawFile('IMAGE_URI');
let imageSource : imageImageSource = image.createImageSource(value.buffer);
let imagePixel : image.PixelMap = await imageSource.createPixelMap({desiredSize:{width: 150, height: 150}});
let queueItemDescription_1 = {
......@@ -1202,7 +1210,7 @@ let queueItemDescription_2 = {
title: 'music_name',
subtitle: 'music_sub_name',
description: 'music_description',
icon: PIXELMAP_OBJECT,
icon: imagePixel,
iconUri: 'http://www.icon.uri.com',
extras: {'extras':'any'}
};
......@@ -2252,7 +2260,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID| Error Message|
| -------- | ------------------------------ |
| 6600101 | Session service exception. |
| 6600103 | The session controller does not exist. |
| 6600102 | The session does not exist. |
**Example**
......@@ -2531,6 +2539,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID| Error Message|
| -------- | ---------------- |
| 6600101 | Session service exception. |
| 6600102 | The session does not exist. |
**Example**
......@@ -2795,6 +2804,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| -------- | ---------------------------------------- |
| 6600101 | Session service exception. |
| 6600102 | The session does not exist. |
| 6600103 | The session controller does not exist. |
**Example**
......@@ -2830,6 +2840,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| -------- | ---------------------------------------- |
| 6600101 | Session service exception. |
| 6600102 | The session does not exist. |
| 6600103 | The session controller does not exist. |
**Example**
......@@ -3002,6 +3013,8 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| 6600101 | Session service exception. |
| 6600102 | The session does not exist. |
| 6600103 | The session controller does not exist. |
| 6600105 | Invalid session command. |
| 6600107 | Too many commands or events. |
**Example**
```js
......@@ -3033,6 +3046,8 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| 6600101 | Session service exception. |
| 6600102 | The session does not exist. |
| 6600103 | The session controller does not exist. |
| 6600105 | Invalid session command. |
| 6600107 | Too many commands or events. |
**Example**
```js
......@@ -4025,6 +4040,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID| Error Message|
| -------- | ---------------- |
| 6600101 | Session service exception. |
| 6600103 | The session controller does not exist. |
**Example**
......@@ -4054,6 +4070,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID| Error Message|
| -------- | ---------------- |
| 6600101 | Session service exception. |
| 6600103 | The session controller does not exist. |
**Example**
......@@ -4083,6 +4100,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID| Error Message|
| -------- | ---------------- |
| 6600101 | Session service exception. |
| 6600103 | The session controller does not exist. |
**Example**
......@@ -4112,6 +4130,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID| Error Message|
| -------- | ---------------- |
| 6600101 | Session service exception. |
| 6600103 | The session controller does not exist. |
**Example**
......@@ -4141,6 +4160,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID| Error Message|
| -------- | ---------------- |
| 6600101 | Session service exception. |
| 6600103 | The session controller does not exist. |
**Example**
......@@ -4201,6 +4221,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID| Error Message|
| -------- | ---------------- |
| 6600101 | Session service exception. |
| 6600103 | The session controller does not exist. |
**Example**
......@@ -4230,6 +4251,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID| Error Message|
| -------- | ---------------- |
| 6600101 | Session service exception. |
| 6600103 | The session controller does not exist. |
**Example**
......@@ -4259,6 +4281,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID| Error Message |
| -------- | ---------------- |
| 6600101 | Session service exception. |
| 6600103 | The session controller does not exist. |
**Example**
......@@ -4288,6 +4311,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| ID | Error Message |
| -------- | ---------------- |
| 6600101 | Session service exception. |
| 6600103 | The session controller does not exist. |
**Example**
......
......@@ -36,6 +36,7 @@ Provides the detailed information of the permissions to request from the system.
| Name | Type | Readable| Writable| Description |
| --------------------- | ----------------------- | ---- | ---- | ---------------------|
| name | string | Yes | Yes | Name of the permission to request. |
| moduleName<sup>10+</sup> | string | Yes | Yes | Name of the module that requests the permission. |
| reason | string | Yes | Yes | Reason for requesting the permission. |
| reasonId | number | Yes | Yes | ID of the reason for requesting the permission.|
| usedScene | [UsedScene](#usedscene) | Yes | Yes | Application scenario and timing for using the permission.|
......
......@@ -576,7 +576,7 @@ Listens for camera mute status changes. This API uses an asynchronous callback t
**Example**
```js
cameraManager.on('cameraMute', (curMuetd) => {
cameraManager.on('cameraMute', (err, curMuetd) => {
let isMuted = curMuetd;
})
```
......@@ -1770,7 +1770,7 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure
| Name | Type | Mandatory| Description |
| -------- | -------------------------------| ---- | ------------------- |
| exposureBias | number | Yes | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If the value passed is not within the supported range, the nearest critical point is used. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
| exposureBias | number | Yes | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If the value passed is not within the supported range, the nearest critical point is used. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
**Error codes**
......@@ -1804,7 +1804,7 @@ Obtains the exposure value in use.
| Type | Description |
| ---------- | ----------------------------- |
| number | Exposure value obtained. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
| number | Exposure value obtained. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
**Error codes**
......@@ -2281,7 +2281,7 @@ Listens for focus state changes. This API uses an asynchronous callback to retur
**Example**
```js
captureSession.on('focusStateChange', (focusState) => {
captureSession.on('focusStateChange', (err, focusState) => {
console.log(`Focus state : ${focusState}`);
})
```
......@@ -2883,7 +2883,7 @@ Listens for shooting start events. This API uses an asynchronous callback to ret
**Example**
```js
photoOutput.on('captureStart', (captureId) => {
photoOutput.on('captureStart', (err, captureId) => {
console.log(`photo capture stated, captureId : ${captureId}`);
})
```
......@@ -2906,7 +2906,7 @@ Listens for frame shutter events. This API uses an asynchronous callback to retu
**Example**
```js
photoOutput.on('frameShutter', (frameShutterInfo) => {
photoOutput.on('frameShutter', (err, frameShutterInfo) => {
console.log(`photo capture end, captureId : ${frameShutterInfo.captureId}`);
console.log(`Timestamp for frame : ${frameShutterInfo.timestamp}`);
})
......@@ -2930,7 +2930,7 @@ Listens for shooting end events. This API uses an asynchronous callback to retur
**Example**
```js
photoOutput.on('captureEnd', (captureEndInfo) => {
photoOutput.on('captureEnd', (err, captureEndInfo) => {
console.log(`photo capture end, captureId : ${captureEndInfo.captureId}`);
console.log(`frameCount : ${captureEndInfo.frameCount}`);
})
......@@ -3378,7 +3378,7 @@ Listens for metadata objects. This API uses an asynchronous callback to return t
**Example**
```js
metadataOutput.on('metadataObjectsAvailable', (metadataObjectArr) => {
metadataOutput.on('metadataObjectsAvailable', (err, metadataObjectArr) => {
console.log(`metadata output metadataObjectsAvailable`);
})
```
......
......@@ -25,9 +25,9 @@ Implements initialization for the interpolation curve, which is used to create a
**Parameters**
| Name| Type | Mandatory| Default Value | Description |
| ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- |
| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve.Linear | Curve type.|
| Name| Type | Mandatory| Description |
| ------ | ----------------------------------------------- | ---- | ----------------------------------- |
| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve type.<br>Default value: **Curve.Linear**|
**Return value**
......@@ -151,16 +151,16 @@ Creates a spring animation curve. If multiple spring animations are applied to t
| Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ----- |
| response | number | No | Duration of one complete oscillation,<br>Default value: **0.55**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.|
| response | number | No | Duration of one complete oscillation.<br>Default value: **0.55**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.|
| dampingFraction | number | No | Damping coefficient.<br>**0**: undamped. In this case, the spring oscillates forever.<br>> 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position.<br>**1**: critically damped.<br>> 1: overdamped. In this case, the spring approaches equilibrium gradually.<br>Default value: **0.825**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.|
| overlapDuration | number | No | Duration for animations to overlap, in seconds. When animations overlap, if the **response** values of the two animations are different, they will transit smoothly over this duration.<br><br>Default value: **0**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0**.<br>The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the **[interpolate](#interpolate)** function of the curve.|
| overlapDuration | number | No | Duration for animations to overlap, in seconds. When animations overlap, if the **response** values of the two animations are different, they will transit smoothly over this duration.<br><br>Default value: **0**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0**.<br>The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the **interpolate** function of the curve.|
**Return value**
| Type | Description |
| ---------------------------------- | ---------------- |
| [ICurve](#icurve)| Curve.<br>**NOTE**<br>The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the **[interpolate](#interpolate)** function of the curve.|
| [ICurve](#icurve)| Curve.<br>**NOTE**<br>The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the **interpolate** function of the curve.|
**Example**
......@@ -187,13 +187,13 @@ Creates a responsive spring animation curve. It is a special case of [springMoti
| --------- | ------ | ---- | ----- |
| response | number | No | See **response** in **springMotion**.<br>Default value: **0.15**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.15**.|
| dampingFraction | number | No | See **dampingFraction** in **springMotion**.<br>Default value: **0.86**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.86**.|
| overlapDuration | number | No | See **overlapDuration** in **springMotion**.<br>Default value: **0.25**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.25**.<br> To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.<br>The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). In addition, the interpolation cannot be obtained by using the [interpolate](#interpolate) function of the curve.|
| overlapDuration | number | No | See **overlapDuration** in **springMotion**.<br>Default value: **0.25**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.25**.<br> To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.<br>The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). In addition, the interpolation cannot be obtained by using the **interpolate** function of the curve.|
**Return value**
| Type | Description |
| ---------------------------------- | ---------------- |
| [ICurve](#icurve)| Curve.<br>**NOTE**<br>1. To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.<br>2. The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in **animation** or **animateTo**. In addition, the interpolation cannot be obtained by using the [interpolate](#interpolate) function of the curve.|
| [ICurve](#icurve)| Curve.<br>**NOTE**<br>1. To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.<br>2. The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in **animation** or **animateTo**. In addition, the interpolation cannot be obtained by using the [interpolate](#interpolate9) function of the curve.|
**Example**
......@@ -260,7 +260,7 @@ import Curves from '@ohos.curves'
interpolate(fraction) {
return Math.sqrt(fraction);
}
Curves.customCurve(this.interpolate) // Create a custom curve.
private curve = Curves.customCurve(this.interpolate) // Create a custom curve.
```
......@@ -268,7 +268,7 @@ Curves.customCurve(this.interpolate) // Create a custom curve.
## ICurve
### interpolate
### interpolate<sup>9+</sup>
interpolate(fraction: number): number
......@@ -310,9 +310,9 @@ Implements initialization to create a curve. This API is deprecated since API ve
**Parameters**
| Name| Type | Mandatory| Default Value | Description |
| ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- |
| curve |[Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve.Linear | Curve type.|
| Name| Type | Mandatory| Description |
| ------ | ----------------------------------------------- | ---- | ----------------------------------- |
| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve type.<br>Default value: **Curve.Linear**|
## Curves.steps<sup>(deprecated)</sup>
......
......@@ -7,6 +7,10 @@ The **font** module provides APIs for registering custom fonts.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
>
> The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see [UIContext](./js-apis-arkui-UIContext.md#uicontext).
>
> Since API version 10, you can use the [getFont](./js-apis-arkui-UIContext.md#getfont) API in [UIContext](./js-apis-arkui-UIContext.md#uicontext) to obtain the [Font](./js-apis-arkui-UIContext.md#font) object associated with the current UI context.
## Modules to Import
......@@ -165,3 +169,4 @@ struct FontExample {
}
}
```
......@@ -14,11 +14,13 @@ Called when the mission continuation is complete.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| result | number | No| Mission continuation result.|
| result | number | Yes| Mission continuation result.|
**Example**
......
......@@ -23,7 +23,7 @@ Before using the **ServiceExtensionContext** module, you must first obtain a **F
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
class MyFormExtensionAbility extends FormExtensionAbility {
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm(want) {
let formContext = this.context; // Obtain a FormExtensionContext instance.
// ...
......
......@@ -1617,8 +1617,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
let want = {
bundleName: 'com.acts.actscalleeabilityrely',
moduleName: 'entry',
abilityName: 'EntryAbility'
deviceId: ''
abilityName: 'EntryAbility',
deviceId: '',
parameters: {
// If the value of 'ohos.aafwk.param.callAbilityToForeground' is true, the ability is started in the foreground. If the value is false or not set, the ability is started in the background.
'ohos.aafwk.param.callAbilityToForeground': true
......
......@@ -1228,7 +1228,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
// Process service logic errors.
console.error(`terminateSelf failed, code is ${err.code}, message is ${err.message}`);
});
} catch (error) {
} catch (err) {
// Capture the synchronization parameter error.
console.error(`terminateSelf failed, code is ${err.code}, message is ${err.message}`);
}
......@@ -2577,8 +2577,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
let want = {
bundleName: 'com.acts.actscalleeabilityrely',
moduleName: 'entry',
abilityName: 'EntryAbility'
deviceId: ''
abilityName: 'EntryAbility',
deviceId: '',
parameters: {
// If the value of 'ohos.aafwk.param.callAbilityToForeground' is true, the ability is started in the foreground. If the value is false or not set, the ability is started in the background.
'ohos.aafwk.param.callAbilityToForeground': true
......
......@@ -8,7 +8,7 @@
| Name | Type | Readable| Writable| Description |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| events | Array\<string> | Yes | No | Name of the common event to publish. |
| events | Array\<string> | Yes | No | Common events to subscribe to. |
| publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. |
| publisherDeviceId | string | Yes | No | Device ID. The value must be the ID of a device on the same network. |
| userId | number | Yes | No | User ID. The value must be an existing user ID in the system. If this parameter is not specified, the default value, which is the ID of the current user, will be used. |
......
......@@ -112,7 +112,7 @@ Provides attributes of the measured text.
| Name | Type | Mandatory| Description |
| -------------- | -------------------------------------------------------------------------------------------------- | ---- | ----------------------------------------------- |
| textContent<sup>10+</sup> | string | Yes | Content of the measured text. |
| textContent | string | Yes | Content of the measured text. |
| constraintWidth<sup>10+</sup> | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Layout width of the measured text.<br>The default unit is vp. |
| fontSize | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Font size of the measured text. If the value is of the number type, the unit fp is used.<br>Default value: **16fp**<br>**NOTE**<br>The value cannot be a percentage. |
| fontStyle | number \| [FontStyle](../arkui-ts/ts-appendix-enums.md#fontstyle) | No | Font style of the measured text.<br>Default value: **FontStyle.Normal** |
......
......@@ -7,6 +7,10 @@ The **mediaquery** module provides different styles for different media types.
> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
>
> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md).
>
> The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see [UIContext](./js-apis-arkui-UIContext.md#uicontext).
>
> Since API version 10, you can use the [getMediaQuery](./js-apis-arkui-UIContext.md#getmediaquery) API in [UIContext](./js-apis-arkui-UIContext.md#uicontext) to obtain the [MediaQuery](./js-apis-arkui-UIContext.md#mediaquery) object associated with the current UI context.
## Modules to Import
......
......@@ -7,6 +7,10 @@ The **PromptAction** module provides APIs for creating and showing toasts, dialo
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md).
>
> The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see [UIContext](./js-apis-arkui-UIContext.md#uicontext).
>
> Since API version 10, you can use the [getPromptAction](./js-apis-arkui-UIContext.md#getpromptaction) API in [UIContext](./js-apis-arkui-UIContext.md#uicontext) to obtain the [PromptAction](./js-apis-arkui-UIContext.md#promptaction) object associated with the current UI context.
## Modules to Import
......@@ -62,7 +66,7 @@ Describes the options for showing the toast.
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| message | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>9+</sup>| Yes | Text to display. |
| duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used. If the value greater than 10000 ms is set, the upper limit 10000 ms is used.|
| bottom | string\| number | No | Distance between the toast border and the bottom of the screen. |
| bottom | string\| number | No | Distance between the toast border and the bottom of the screen.<br>Default value: **80vp** |
## promptAction.showDialog
......@@ -319,7 +323,7 @@ Describes the options for showing the action menu.
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| title | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>9+</sup>| No | Title of the dialog box. |
| buttons | [[Button](#button),[Button](#button)?,[Button](#button)?,[Button](#button)?,[Button](#button)?,[Button](#button)?] | Yes | Array of menu item buttons. The array structure is **{text:'button', color: '\#666666'}**. Up to six buttons are supported. If there are more than six buttons, extra buttons will not be displayed.|
| buttons | [[Button](#button),[Button](#button)?,[Button](#button)?,[Button](#button)?,[Button](#button)?,[Button](#button)?] | Yes | Array of menu item buttons. The array structure is **{text:'button', color: '\#666666'}**. Up to six buttons are supported. If there are more than six buttons, only the first six buttons will be displayed.|
## ActionMenuSuccessResponse
......
......@@ -152,6 +152,7 @@
- [ImageBitmap](ts-components-canvas-imagebitmap.md)
- [ImageData](ts-components-canvas-imagedata.md)
- [Matrix2D](ts-components-canvas-matrix2d.md)
- [OffscreenCanvas](ts-components-offscreencanvas.md)
- [OffscreenCanvasRenderingContext2D](ts-offscreencanvasrenderingcontext2d.md)
- [Path2D](ts-components-canvas-path2d.md)
- Animation
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册