提交 74ede47f 编写于 作者: F FangJinliang 提交者: Gitee

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

Signed-off-by: NFangJinliang <fangjinliang1@huawei.com>
...@@ -132,7 +132,7 @@ zh-cn/device-dev/subsystems/subsys-xts-guide.md @Austin23 ...@@ -132,7 +132,7 @@ zh-cn/device-dev/subsystems/subsys-xts-guide.md @Austin23
zh-cn/application-dev/ability/ @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen zh-cn/application-dev/ability/ @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen
zh-cn/application-dev/IDL/ @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen zh-cn/application-dev/IDL/ @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen
zh-cn/application-dev/device-usage-statistics/ @RayShih @shuaytao @wangzhen107 @inter515 zh-cn/application-dev/device-usage-statistics/ @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/ui/ @HelloCrease @huaweimaxuchu @tomatodevboy @niulihua zh-cn/application-dev/ui/ @HelloCrease @huaweimaxuchu @tomatodevboy @niulihua
zh-cn/application-dev/notification/ @RayShih @jayleehw @li-weifeng2 @currydavids zh-cn/application-dev/notification/ @RayShih @jayleehw @li-weifeng2 @currydavids
zh-cn/application-dev/windowmanager/ @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee zh-cn/application-dev/windowmanager/ @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee
...@@ -244,7 +244,7 @@ zh-cn/application-dev/reference/js-service-widget-ui/ @HelloCrease ...@@ -244,7 +244,7 @@ zh-cn/application-dev/reference/js-service-widget-ui/ @HelloCrease
zh-cn/application-dev/faqs/ @zengyawen zh-cn/application-dev/faqs/ @zengyawen
zh-cn/application-dev/file-management/ @zengyawen zh-cn/application-dev/file-management/ @zengyawen
zh-cn/application-dev/application-test/ @ningningW zh-cn/application-dev/application-test/ @ningningW
zh-cn/application-dev/device-usage-statistics/ @RayShih @shuaytao @wangzhen107 @inter515 zh-cn/application-dev/device-usage-statistics/ @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-ability-context.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen 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 zh-cn/application-dev/reference/apis/js-apis-ability-errorCode.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
...@@ -278,7 +278,7 @@ zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility. ...@@ -278,7 +278,7 @@ zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.
zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-arraylist.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-arraylist.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-audio.md @liuyuehua1 @zengyawen @magekkkk @currydavids zh-cn/application-dev/reference/apis/js-apis-audio.md @liuyuehua1 @zengyawen @magekkkk @currydavids
zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @wangwenli_wolf @ningningW @tangtiantian2021 @nan-xiansen zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-battery-info.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-battery-info.md @aqxyjay @zengyawen @aqxyjay @alien0208
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @cheng_guohong @RayShih @cheng_guohong @quanli125 zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-brightness.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-brightness.md @aqxyjay @zengyawen @aqxyjay @alien0208
...@@ -331,7 +331,7 @@ zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @shuaytao ...@@ -331,7 +331,7 @@ zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @shuaytao
zh-cn/application-dev/reference/apis/js-apis-display.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-display.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @nianCode @zengyawen @JiDong-CS @murphy1984 zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @nianCode @zengyawen @JiDong-CS @murphy1984
zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @feng-aiwen @ge-yafang @gong-a-shi @logic42 zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md @wangwenli_wolf @ningningW @tangtiantian2021 @nan-xiansen zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-document.md @panqinxu @zengyawen @bubble_mao @jinhaihw zh-cn/application-dev/reference/apis/js-apis-document.md @panqinxu @zengyawen @bubble_mao @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-effectKit.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-effectKit.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-emitter.md @jayleehw @RayShih @li-weifeng2 @currydavids zh-cn/application-dev/reference/apis/js-apis-emitter.md @jayleehw @RayShih @li-weifeng2 @currydavids
...@@ -476,8 +476,8 @@ zh-cn/application-dev/reference/apis/js-apis-wifiext.md @cheng_guohong @RayShih ...@@ -476,8 +476,8 @@ zh-cn/application-dev/reference/apis/js-apis-wifiext.md @cheng_guohong @RayShih
zh-cn/application-dev/reference/apis/js-apis-window.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-window.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-worker.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-worker.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @wangwenli_wolf @ningningW @tangtiantian2021 @nan-xiansen zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @wangwenli_wolf @ningningW @tangtiantian2021 @nan-xiansen zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-xml.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-xml.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-zlib.md @shuaytao @RayShih @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-zlib.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-webview.md @bigpumpkin @HelloCrease @litao33 @zhang-xinyue15 zh-cn/application-dev/reference/apis/js-apis-webview.md @bigpumpkin @HelloCrease @litao33 @zhang-xinyue15
...@@ -537,10 +537,10 @@ zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md @zhang-hai-feng @ze ...@@ -537,10 +537,10 @@ zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md @zhang-hai-feng @ze
zh-cn/application-dev/reference/apis/js-apis-net-sharing.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785 zh-cn/application-dev/reference/apis/js-apis-net-sharing.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-nfctech.md @cheng_guohong @RayShih @cheng_guohong @quanli125 zh-cn/application-dev/reference/apis/js-apis-nfctech.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-promptAction.md @huaweimaxuchu @HelloCrease @niulihua @tomatodevboy zh-cn/application-dev/reference/apis/js-apis-promptAction.md @huaweimaxuchu @HelloCrease @niulihua @tomatodevboy
zh-cn/application-dev/reference/apis/js-apis-reminderAgentManager.md @wangwenli_wolf @ningningW @tangtiantian2021 @nan-xiansen zh-cn/application-dev/reference/apis/js-apis-reminderAgentManager.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md @wangwenli_wolf @ningningW @tangtiantian2021 @nan-xiansen zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md @wangwenli_wolf @ningningW @tangtiantian2021 @nan-xiansen zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md @wangwenli_wolf @ningningW @tangtiantian2021 @nan-xiansen zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/reference/apis/js-apis-stationary.md @mayunteng_1 @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-stationary.md @mayunteng_1 @ningningW @cococoler @alien0208
zh-cn/application-dev/reference/apis/js-apis-system-capability.md taiyipei taiyipei BlackStone zh-cn/application-dev/reference/apis/js-apis-system-capability.md taiyipei taiyipei BlackStone
zh-cn/application-dev/reference/apis/js-apis-system-parameterV9.md @mupceet @zengyawen @handyohos @nan-xiansen zh-cn/application-dev/reference/apis/js-apis-system-parameterV9.md @mupceet @zengyawen @handyohos @nan-xiansen
......
...@@ -65,9 +65,10 @@ ...@@ -65,9 +65,10 @@
- [Internationalization](internationalization/Readme-EN.md) - [Internationalization](internationalization/Readme-EN.md)
- [Application Test](application-test/Readme-EN.md) - [Application Test](application-test/Readme-EN.md)
- [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md) - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md)
- [Using Native APIs in Application Projects](napi/Readme-EN.md) - [Native APIs](napi/Readme-EN.md)
- Tools - Tools
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- [Debugging Tools](tools/Readme-EN.md)
- Hands-On Tutorials - Hands-On Tutorials
- [Samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md) - [Samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md)
- [Codelabs](https://gitee.com/openharmony/codelabs) - [Codelabs](https://gitee.com/openharmony/codelabs)
......
...@@ -60,12 +60,6 @@ The **module.json5** of a browser application is as follows: ...@@ -60,12 +60,6 @@ The **module.json5** of a browser application is as follows:
} catch (error) { } catch (error) {
console.info(`explicit start ability failed with ${error.code}`) console.info(`explicit start ability failed with ${error.code}`)
} }
let context = getContext(this) as common.UIAbilityContext;
await context.startAbility(want)
console.info(`explicit start ability succeed`)
} catch (error) {
console.info(`explicit start ability failed with ${error.code}`)
}
} }
``` ```
......
...@@ -20,13 +20,13 @@ The following table lists the USB APIs currently available. For details, see the ...@@ -20,13 +20,13 @@ The following table lists the USB APIs currently available. For details, see the
| getDevices(): Array<Readonly\<USBDevice>> | Obtains the list of USB devices connected to the USB host. If no USB device is connected, an empty list is returned. | | getDevices(): Array<Readonly\<USBDevice>> | Obtains the list of USB devices connected to the USB host. If no USB device is connected, an empty list is returned. |
| setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | Sets the USB device configuration. | | setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | Sets the USB device configuration. |
| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. | | setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. |
| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number | Claims a USB interface. | | claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. |
| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise\<number> | Performs bulk transfer. | | bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise\<number> | Performs bulk transfer. |
| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. | | closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. |
| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. | | releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. |
| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. | | getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. |
| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. | | getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. |
| controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise\<number> | Performs control transfer. | | controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise&lt;number&gt; | Performs control transfer. |
## How to Develop ## How to Develop
...@@ -51,7 +51,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat ...@@ -51,7 +51,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat
vendorId: 7531, vendorId: 7531,
productId: 2, productId: 2,
clazz: 9, clazz: 9,
subclass: 0, subClass: 0,
protocol: 1, protocol: 1,
devAddress: 1, devAddress: 1,
busNum: 1, busNum: 1,
...@@ -68,7 +68,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat ...@@ -68,7 +68,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat
id: 0, id: 0,
protocol: 0, protocol: 0,
clazz: 9, clazz: 9,
subclass: 0, subClass: 0,
alternateSetting: 0, alternateSetting: 0,
name: "1-1", name: "1-1",
endpoints: [ endpoints: [
...@@ -109,7 +109,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat ...@@ -109,7 +109,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat
```js ```js
// Open the device, and obtain the USB device pipe for data transfer. // Open the device, and obtain the USB device pipe for data transfer.
let pipe = usb.connectDevice(deviceList[0]); let interface1 = deviceList[0].configs[0].interfaces[0];
/* /*
Claim the corresponding interface from deviceList. Claim the corresponding interface from deviceList.
interface1 must be one present in the device configuration. interface1 must be one present in the device configuration.
...@@ -124,7 +124,9 @@ You can set a USB device as the USB host to connect to other USB devices for dat ...@@ -124,7 +124,9 @@ You can set a USB device as the USB host to connect to other USB devices for dat
Read data. Select the corresponding RX endpoint from deviceList for data transfer. Read data. Select the corresponding RX endpoint from deviceList for data transfer.
(endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array.
*/ */
let inEndpoint = interface1.endpoints[2];
let outEndpoint = interface1.endpoints[1];
let dataUint8Array = new Uint8Array(1024);
usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => { usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) { if (dataLength >= 0) {
console.info("usb readData result Length : " + dataLength); console.info("usb readData result Length : " + dataLength);
...@@ -137,7 +139,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat ...@@ -137,7 +139,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat
console.info("usb readData error : " + JSON.stringify(error)); console.info("usb readData error : " + JSON.stringify(error));
}); });
// Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0) // Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0)
usb.bulkTransfer(pipe, endpoint, dataUint8Array, 15000).then(dataLength => { usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) { if (dataLength >= 0) {
console.info("usb writeData result write length : " + dataLength); console.info("usb writeData result write length : " + dataLength);
} else { } else {
......
# DFX # DFX
- [Development of Application Event Logging](hiappevent-guidelines.md) - Application Event Logging
- [Development of Performance Tracing](hitracemeter-guidelines.md) - [Development of Application Event Logging](hiappevent-guidelines.md)
- [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md) - Distributed Call Chain Tracing
- [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md)
- HiLog
- [HiLog Development](hilog-guidelines.md)
- Performance Tracing
- [Development of Performance Tracing](hitracemeter-guidelines.md)
- Error Management - Error Management
- [Development of Error Manager](errormanager-guidelines.md) - [Development of Error Manager](errormanager-guidelines.md)
- [Development of Application Recovery](apprecovery-guidelines.md) - [Development of Application Recovery](apprecovery-guidelines.md)
# HiLog Development
## Introduction
HiLog is the log system of OpenHarmony that provides logging for the system framework, services, and applications to record information on user operations and system running status.
> **NOTE**
> This development guide is applicable only when you use Native APIs for application development. For details about the APIs, see [HiLog Native API Reference](https://gitee.com/openharmony-sig/interface_native_header/blob/master/en/native_sdk/dfx/log.h).
## Available APIs
| API/Macro| Description|
| -------- | -------- |
| int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) | Outputs logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format.|
| #define OH_LOG_DEBUG(type, ...) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__))| Outputs DEBUG logs. This is a function-like macro.|
| #define OH_LOG_INFO(type, ...) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs INFO logs. This is a function-like macro.|
| #define OH_LOG_WARN(type, ...) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs WARN logs. This is a function-like macro.|
| #define OH_LOG_ERROR(type, ...) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs ERROR logs. This is a function-like macro.|
| #define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs FATAL logs. This is a function-like macro.|
| bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level) | Checks whether logs of the specified service domain, tag, and level can be printed.<br>Input arguments:<br>- **domain**: service domain.<br>- **tag**: log tag.<br>- **level**: log level.<br>Output arguments: none<br>Return value: Returns **true** if the specified logs can be printed; returns **false** otherwise.|
## Development Examples
1. Include the **hilog** header file in the source file.
```c++
#include "hilog/log.h"
```
2. Define the **domain** and **tag** macros.
```c++
#undef LOG_DOMAIN
#undef LOG_TAG
#define LOG_DOMAIN 0x3200 // Service domain. The value ranges from 0xD0000 to 0xDFFFF.
#define LOG_TAG "MY_TAG"
```
3. Print logs. For example, to print INFO logs, use the following code:
```c++
OH_LOG_INFO(LOG_APP, "Failed to visit %{private}s, reason:%{public}d.", url, errno);
```
4. View the output log information.
```
12-11 12:21:47.579 2695 2695 I A03200/MY_TAG: Failed to visit <private>, reason:11.
```
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
## Introduction ## Introduction
The hiTraceChain module provides APIs to implement call chain tracing throughout a service process. This can help you quickly obtain the run log for the call chain of a specified service process and locate faults in inter-device, inter-process, or inter-thread communications. hiTraceChain is a lightweight implementation of the cloud-based distributed call chain tracing. It allows applications to trace cross-thread, cross-process, and cross-device service calls. The hiTraceChain module generates a unique **chainId** for a service process and passes it to various information (including application events, system time, and logs) specific to the service process. During debugging and fault locating, you can use the unique **chainId** to quickly correlate various information related to the service process. The hiTraceChain module provides APIs to implement call chain tracing throughout a service process. This can help you quickly obtain the run log for the call chain of a specified service process and locate faults in inter-device, inter-process, or inter-thread communications.
hiTraceChain is a lightweight implementation of the cloud-based distributed call chain tracing. It allows applications to trace cross-thread, cross-process, and cross-device service calls. The hiTraceChain module generates a unique **chainId** for a service process and passes it to various information (including application events, system time, and logs) specific to the service process. During debugging and fault locating, you can use the unique **chainId** to quickly correlate various information related to the service process.
## Basic Concepts ## Basic Concepts
...@@ -18,47 +16,106 @@ The APIs for distributed call chain tracing are provided by the **hiTraceChain** ...@@ -18,47 +16,106 @@ The APIs for distributed call chain tracing are provided by the **hiTraceChain**
**APIs for distributed call chain tracing** **APIs for distributed call chain tracing**
| API| Return Value| Description| | API | Return Value | Description |
| ------------------------------------------------------------------------------------------------------------------- | -------------- | ------------ | | ------------------------------------------------------------------------------------------------------------------- | -------------- | ------------ |
| hiTraceChain.begin(name: string, flags: number = HiTraceFlag.DEFAULT) | HiTraceId | Starts call chain tracing.| | hiTraceChain.begin(name: string, flags: number = HiTraceFlag.DEFAULT) | HiTraceId | Starts call chain tracing. |
| hiTraceChain.tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTraceId, msg?: string) | void | Creates a trace point.| | hiTraceChain.end(id: HiTraceId) | void | Stops call chain tracing. |
| hiTraceChain.end(id: HiTraceId) | void | Stops call chain tracing.|
## How to Develop ## How to Develop
In this example, distributed call chain tracing begins when the application startup execution page is loaded and stops when the service usage is completed. The following example illustrates how to simulate one-time [system event logging](../reference/apis/js-apis-hisysevent.md) to implement cross-thread distributed call chain tracing in a single HAP service.
1. Create a JS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **js** > **default** > **pages** > **index**, and double-click **index.js**. Add the code to implement call chain tracing upon page loading. The sample code is as follows: 1. Create an eTS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **ets** > **pages** > **index.ets**, and double-click **index.ets**. Then, add a button to trigger system event logging.
``` ```ts
import hiTraceChain from '@ohos.hiTraceChain' import hiTraceChain from '@ohos.hiTraceChain';
import hiSysEvent from '@ohos.hiSysEvent';
export default {
data: { @Entry
title: "" @Component
}, struct Index {
onInit() { @State message: string = 'Start writing system event';
this.title = this.$t('strings.world');
build() {
// 1. Enable distributed call chain tracing. Row() {
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); Column() {
Button(this.message)
// 2. Start the service process. .fontSize(20)
console.log(`business start`); .margin(5)
.width(350)
// 3. Add a trace point. .height(60)
hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.THREAD, hiTraceChain.HiTraceTracepointType.SS, asyncTraceId, "Just an example"); .fontWeight(FontWeight.Bold)
.onClick(() => {
// 4. Keep the service process running. try {
console.log(`business running`); // Enable distributed call chain tracing before the service starts.
let traceId = hiTraceChain.begin("Write a new system event", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
// 5. End the service process. // Implement one-time system event logging when the service starts.
console.log(`business end`); hiSysEvent.write({
domain: "RELIABILITY",
// 6. Stop call chain tracing. name: "STACK",
hiTraceChain.end(asyncTraceId); eventType: hiSysEvent.EventType.FAULT,
params: {
PID: 1,
UID: 1,
PACKAGE_NAME: "com.demo.hitracechain",
PROCESS_NAME: "hitracechaindemo",
MSG: "no msg."
}
}).then((val) => {
console.info(`write result is ${val}`);
// Disable distributed call chain tracing when the service ends.
hiTraceChain.end(traceId);
}).catch((err) => {
console.error(`error message is ${err.message}`);
});
} catch (err) {
console.error(`error message is ${err.message}`);
}
})
}
.width('100%')
} }
.height('100%')
} }
}
```
2. Touch the run button on the IDE to run the project. Then, touch the **Start writing system event** button on the application UI to trigger system event logging.
3. View the information printed in the **Log** window. You can use **.*: \[([0-9a-zA-Z]{15}),.*].*** to access distributed call chain tracing information specific to the HAP service. The process ID of the HAP service is **8801**. Two threads, whose IDs are **8801** and **8819**, are involved in the system event logging. Based on the chain ID **edcfa53017a88e3**, you can then effectively trace the log information of the two threads.
```text
07-05 19:50:47.690 8801-8801/com.demo.hitracechain I C02d03/HiTraceC: [edcfa53017a88e3, 0, 0] HiTraceBegin name:Write a new system event flags:0x01.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 0, 0] Native2Js: chainId is edcfa53017a88e3.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 0, 0] Native2Js: spanId is 0.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 0, 0] Native2Js: parentSpanId is 0.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 0, 0] Native2Js: flags is 1.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] domain is RELIABILITY.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] name is STACK.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] eventType is 1.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain E C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] napi value type not match: valueType=3, typeName=6.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain E C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] napi value type not match: valueType=3, typeName=6.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain E C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] napi value type not match: valueType=4, typeName=6.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain E C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] napi value type not match: valueType=4, typeName=6.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain E C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] napi value type not match: valueType=4, typeName=6.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] create napi value of string type, value is JSHiSysEventWrite.
07-05 19:50:47.690 8801-8801/com.demo.hitracechain I C03900/Ace: [edcfa53017a88e3, 0, 0] [flutter_ace_view.cpp(operator())-(0)] Mark 0 id Touch Event Processed
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02800/ClientMsgHandler: [edcfa53017a88e3, 0, 0] in OnDispatchEventProcessed, enter
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02800/ANRHandler: [edcfa53017a88e3, 0, 0] in SetLastProcessedEventId, enter
07-05 19:50:47.690 8801-8819/com.demo.hitracechain D C02d08/HISYSEVENT: [edcfa53017a88e3, 0, 0] size=312, sysevent={"domain_":"RELIABILITY","name_":"STACK","type_":1,"time_":47591447690,"tz_":"+0000","pid_":8801,"tid_":8819,"uid_":20010045,"traceid_":"edcfa53017a88e3","spanid_":"0","pspanid_":"0","trace_flag_":1,"UID":1,"PID":1,"MSG":"no msg.","PROCESS_NAME":"hitracechaindemo","PACKAGE_NAME":"com.demo.hitracechain"}
07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02800/ANRHandler: [edcfa53017a88e3, 0, 0] in SetLastProcessedEventId, Processed event type:0, id:831, actionTime:6694499314, currentTime:6694501330, timeoutTime:4997984
07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02800/ANRHandler: [edcfa53017a88e3, 0, 0] in SetLastProcessedEventId, leave
07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02800/ClientMsgHandler: [edcfa53017a88e3, 0, 0] in OnDispatchEventProcessed, leave
07-05 19:50:47.691 8801-8819/com.demo.hitracechain D C02d08/HISYSEVENT: [edcfa53017a88e3, 0, 0] reset send buffer size old=245760, new=524288
07-05 19:50:47.691 8801-8819/com.demo.hitracechain D C02d08/HISYSEVENT: [edcfa53017a88e3, 0, 0] HiSysEvent send data successful
07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] create napi value of int32 type, value is 0.
07-05 19:50:47.691 8801-8801/com.demo.hitracechain E A0fefe/JsApp: [edcfa53017a88e3, 399db38, 0] write result is 0
07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 399db38, 0] Js2Native: chainId is edcfa53017a88e3.
07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 399db38, 0] Js2Native: spanId is 0.
07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 399db38, 0] Js2Native: parentSpanId is 0.
07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 399db38, 0] Js2Native: flags is 1.
07-05 19:50:47.691 8801-8801/com.demo.hitracechain I C02d03/HiTraceC: [edcfa53017a88e3, 399db38, 0] HiTraceEnd.
``` ```
2. Click the run button on the application page. Then, you'll obtain the log information for service analysis. ## About Cross-Process/Cross-Device Distributed Call Chain Tracing
Cross-process/cross-device distributed call chain tracing depends on the NAPI implementation of the corresponding service APIs of each OpenHarmony module. For details, see the [HiTraceChain Development](../../device-dev/subsystems/subsys-dfx-hitracechain.md).
# AVSession Development # AVSession Development
> **NOTE**
>
> All APIs of the **AVSession** module are system APIs and can be called only by system applications.
## Development for the Session Access End ## Development for the Session Access End
### Basic Concepts ### Basic Concepts
...@@ -28,7 +32,7 @@ Table 1 Common APIs for session access end development ...@@ -28,7 +32,7 @@ Table 1 Common APIs for session access end development
```js ```js
import avSession from '@ohos.multimedia.avsession'; import avSession from '@ohos.multimedia.avsession';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
``` ```
...@@ -50,7 +54,7 @@ avSession.createAVSession(context, "AudioAppSample", 'audio').then((session) => ...@@ -50,7 +54,7 @@ avSession.createAVSession(context, "AudioAppSample", 'audio').then((session) =>
3. Set the session information, including: 3. Set the session information, including:
- Session metadata. In addition to the current media asset ID (mandatory), you can set the title, album, author, duration, and previous/next media asset ID. For details about the session metadata, see **AVMetadata** in the API document. - Session metadata. In addition to the current media asset ID (mandatory), you can set the title, album, author, duration, and previous/next media asset ID. For details about the session metadata, see **AVMetadata** in the API document.
- Launcher ability, which is implemented by calling an API of **WantAgent**. Generally, **WantAgent** is used to encapsulate want information. For more information, see [wantAgent](../reference/apis/js-apis-wantAgent.md). - Launcher ability, which is implemented by calling an API of [WantAgent](../reference/apis/js-apis-app-ability-wantAgent.md). Generally, **WantAgent** is used to encapsulate want information.
- Playback state information. - Playback state information.
```js ```js
// Set the session metadata. // Set the session metadata.
...@@ -83,7 +87,7 @@ let wantAgentInfo = { ...@@ -83,7 +87,7 @@ let wantAgentInfo = {
wants: [ wants: [
{ {
bundleName: "com.neu.setResultOnAbilityResultTest1", bundleName: "com.neu.setResultOnAbilityResultTest1",
abilityName: "com.example.test.MainAbility", abilityName: "com.example.test.EntryAbility",
} }
], ],
operationType: wantAgent.OperationType.START_ABILITIES, operationType: wantAgent.OperationType.START_ABILITIES,
...@@ -187,7 +191,7 @@ currentSession.on('playNext', () => { ...@@ -187,7 +191,7 @@ currentSession.on('playNext', () => {
}); });
console.log ("Call AudioPlayer.play."); console.log ("Call AudioPlayer.play.");
// Set the playback state information. // Set the playback state information.
let time = (new Data()).getTime(); let time = (new Date()).getTime();
currentSession.setAVPlaybackState({state: avSession.PlaybackState.PLAYBACK_STATE_PLAY, position: {elapsedTime: 0, updateTime: time}, bufferedTime:2000}).then(() => { currentSession.setAVPlaybackState({state: avSession.PlaybackState.PLAYBACK_STATE_PLAY, position: {elapsedTime: 0, updateTime: time}, bufferedTime:2000}).then(() => {
console.info('setAVPlaybackState successfully'); console.info('setAVPlaybackState successfully');
}).catch((err) => { }).catch((err) => {
...@@ -282,7 +286,7 @@ currentSession.off('outputDeviceChange'); ...@@ -282,7 +286,7 @@ currentSession.off('outputDeviceChange');
// Deactivate the session and destroy the object. // Deactivate the session and destroy the object.
currentSession.deactivate().then(() => { currentSession.deactivate().then(() => {
currentSession.destory(); currentSession.destroy();
}); });
``` ```
...@@ -365,7 +369,7 @@ Table 2 Common APIs for session control end development ...@@ -365,7 +369,7 @@ Table 2 Common APIs for session control end development
```js ```js
import avSession from '@ohos.multimedia.avsession'; import avSession from '@ohos.multimedia.avsession';
import {Action, KeyEvent} from '@ohos.multimodalInput.KeyEvent'; import {Action, KeyEvent} from '@ohos.multimodalInput.KeyEvent';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
``` ```
......
# AVSession Overview # AVSession Overview
> **NOTE**
>
> All APIs of the **AVSession** module are system APIs and can be called only by system applications.
## Overview ## Overview
AVSession, short for audio and video session, is also known as media session. AVSession, short for audio and video session, is also known as media session.
...@@ -49,4 +53,4 @@ The **AVSession** module provides two classes: **AVSession** and **AVSessionCont ...@@ -49,4 +53,4 @@ The **AVSession** module provides two classes: **AVSession** and **AVSessionCont
- AVSession can transmit media playback information and control commands. It does not display information or execute control commands. - AVSession can transmit media playback information and control commands. It does not display information or execute control commands.
- Do not develop Media Controller for common applications. For common audio and video applications running on OpenHarmony, the default control end is Media Controller, which is a system application. You do not need to carry out additional development for Media Controller. - Do not develop Media Controller for common applications. For common audio and video applications running on OpenHarmony, the default control end is Media Controller, which is a system application. You do not need to carry out additional development for Media Controller.
- If you want to develop your own system running OpenHarmony, you can develop your own Media Controller. - If you want to develop your own system running OpenHarmony, you can develop your own Media Controller.
- For better background management of audio and video applications, the **AVSession** module enforces background control for third-party applications. Only third-party applications that have accessed AVSession can play audio in the background. Otherwise, the system forcibly pauses the playback when a third-party application switches to the background. - For better background management of audio and video applications, the **AVSession** module enforces background control for applications. Only applications that have accessed AVSession can play audio in the background. Otherwise, the system forcibly pauses the playback when an application switches to the background.
...@@ -118,9 +118,9 @@ The following steps describe how to use the canvas and brush of the Native Drawi ...@@ -118,9 +118,9 @@ The following steps describe how to use the canvas and brush of the Native Drawi
// Draw a pentagram on the canvas. The outline of the pentagram is drawn by the pen, and the color is filled in by the brush. // Draw a pentagram on the canvas. The outline of the pentagram is drawn by the pen, and the color is filled in by the brush.
OH_Drawing_CanvasDrawPath(cCanvas, cPath); OH_Drawing_CanvasDrawPath(cCanvas, cPath);
// Destroy the created objects when they are no longer needed. // Destroy the created objects when they are no longer needed.
OH_Drawing_BrushDestory(cBrush); OH_Drawing_BrushDestroy(cBrush);
OH_Drawing_PenDestory(cPen); OH_Drawing_PenDestroy(cPen);
OH_Drawing_PathDestory(cPath); OH_Drawing_PathDestroy(cPath);
``` ```
6. **Obtain pixel data.** Use `OH_Drawing_BitmapGetPixels` in `drawing_bitmap.h` to obtain the pixel address of the bitmap bound to the canvas. The memory to which the address points contains the pixel data of the drawing on the canvas. 6. **Obtain pixel data.** Use `OH_Drawing_BitmapGetPixels` in `drawing_bitmap.h` to obtain the pixel address of the bitmap bound to the canvas. The memory to which the address points contains the pixel data of the drawing on the canvas.
...@@ -133,9 +133,9 @@ The following steps describe how to use the canvas and brush of the Native Drawi ...@@ -133,9 +133,9 @@ The following steps describe how to use the canvas and brush of the Native Drawi
LOGI("memcpy_s failed"); LOGI("memcpy_s failed");
} }
// Destroy the canvas object. // Destroy the canvas object.
OH_Drawing_CanvasDestory(cCanvas); OH_Drawing_CanvasDestroy(cCanvas);
// Destroy the bitmap object. // Destroy the bitmap object.
OH_Drawing_BitmapDestory(cBitmap); OH_Drawing_BitmapDestroy(cBitmap);
``` ```
## Development Procedure for Text Drawing ## Development Procedure for Text Drawing
......
...@@ -29,19 +29,71 @@ The following scenarios are common for native window development: ...@@ -29,19 +29,71 @@ The following scenarios are common for native window development:
| OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow \*window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t \*metaData) | Sets the HDR static metadata set of the native window.| | OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow \*window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t \*metaData) | Sets the HDR static metadata set of the native window.|
| OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow \*window, const OHExtDataHandle \*handle) | Sets the tunnel handle to the native window.| | OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow \*window, const OHExtDataHandle \*handle) | Sets the tunnel handle to the native window.|
## How to Develop ## How to Develop
The following describes how to use the NAPI provided by **NativeWindow** to request a graphics buffer, write the produced graphics content to the buffer, and flush the buffer to the graphics queue. The following describes how to use the NAPI provided by **NativeWindow** to request a graphics buffer, write the produced graphics content to the buffer, and flush the buffer to the graphics queue.
1. Obtain a **NativeWindow** instance. For example, use **Surface** to create a **NativeWindow** instance. 1. Obtain a **NativeWindow** instance, which can be obtained by running the APIs provided by **OH_NativeXComponent_Callback**.
1. Define **XComponent** in an .ets file.
```ts
XComponent({ id: 'xcomponentId', type: 'surface', libraryname: 'nativerender'})
.onLoad((context) => {
this.context = context;
})
.onDestroy(() => {
})
```
2. Obtain **NativeXComponent** at the native C++ layer.
```c++ ```c++
sptr<OHOS::Surface> cSurface = Surface::CreateSurfaceAsConsumer(); napi_value exportInstance = nullptr;
sptr<IBufferConsumerListener> listener = new BufferConsumerListenerTest(); napi_get_named_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance);
cSurface->RegisterConsumerListener(listener);
sptr<OHOS::IBufferProducer> producer = cSurface->GetProducer(); OH_NativeXComponent *nativeXComponent = nullptr;
sptr<OHOS::Surface> pSurface = Surface::CreateSurfaceAsProducer(producer); napi_unwrap(env, exportInstance, reinterpret_cast<void**>(&nativeXComponent));
OHNativeWindow* nativeWindow = OH_NativeWindow_CreateNativeWindow(&pSurface);
char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = { };
uint64_t idSize = OH_XCOMPONENT_ID_LEN_MAX + 1;
OH_NativeXComponent_GetXComponentId(nativeXComponent, idStr, &idSize);
```
3. Define **OH_NativeXComponent_Callback**.
```c++
// Define the callback.
void OnSurfaceCreatedCB(OH_NativeXComponent* component, void* window)
{
// Obtain a NativeWindow instance.
OHNativeWindow* nativeWindow = window;
// ...
}
void OnSurfaceChangedCB(OH_NativeXComponent* component, void* window)
{
// Obtain a NativeWindow instance.
OHNativeWindow* nativeWindow = window;
// ...
}
void OnSurfaceDestroyedCB(OH_NativeXComponent* component, void* window)
{
// Obtain a NativeWindow instance.
OHNativeWindow* nativeWindow = window;
// ...
}
void DispatchTouchEventCB(OH_NativeXComponent* component, void* window)
{
// Obtain a NativeWindow instance.
OHNativeWindow* nativeWindow = window;
// ...
}
```
```c++
// Initialize OH_NativeXComponent_Callback.
OH_NativeXComponent_Callback callback_;
callback_->OnSurfaceCreated = OnSurfaceCreatedCB;
callback_->OnSurfaceChanged = OnSurfaceChangedCB;
callback_->OnSurfaceDestroyed = OnSurfaceDestroyedCB;
callback_->DispatchTouchEvent = DispatchTouchEventCB;
```
4. Register **OH_NativeXComponent_Callback** with **NativeXComponent**.
```c++
OH_NativeXComponent_RegisterCallback(nativeXComponent, &callback_);
``` ```
2. Set the attributes of a native window buffer by using **OH_NativeWindow_NativeWindowHandleOpt**. 2. Set the attributes of a native window buffer by using **OH_NativeWindow_NativeWindowHandleOpt**.
...@@ -90,7 +142,6 @@ The following describes how to use the NAPI provided by **NativeWindow** to requ ...@@ -90,7 +142,6 @@ The following describes how to use the NAPI provided by **NativeWindow** to requ
``` ```
5. Flush the native window buffer to the graphics queue. 5. Flush the native window buffer to the graphics queue.
```c++ ```c++
// Set the refresh region. If Rect in Region is a null pointer or rectNumber is 0, all contents in the native window buffer are changed. // Set the refresh region. If Rect in Region is a null pointer or rectNumber is 0, all contents in the native window buffer are changed.
Region region{nullptr, 0}; Region region{nullptr, 0};
......
...@@ -30,21 +30,21 @@ This document gives an overview of the **app.json5** configuration file. To star ...@@ -30,21 +30,21 @@ This document gives an overview of the **app.json5** configuration file. To star
As shown above, the **app.json5** file contains several tags. As shown above, the **app.json5** file contains several tags.
**Table 1** Tags in the app.json5 file **Table 1** Tags in the app.json5 file
| Name| Description| Data Type| Initial Value Allowed| | Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | Bundle name, which uniquely identifies an application. The value must comply with the following rules:<br>- Consists of letters, digits, underscores (_), and periods (.).<br>- Starts with a letter.<br>- Contains 7 to 127 bytes.<br>You are advised to use the reverse domain name notation, for example, *com.example.demo*, where the first part is the domain suffix **com**, the second part is the vendor/individual name, and the third part is the application name, which can be of multiple levels.<br>If an application is built with the system source code, you are advised to name it in *com.ohos.demo* notation, where **ohos** signifies that the application is an OpenHarmony system application.| String| No| | bundleName | Bundle name, which uniquely identifies an application. The value must comply with the following rules:<br>- Consists of letters, digits, underscores (_), and periods (.).<br>- Starts with a letter.<br>- Contains 7 to 127 bytes.<br>You are advised to use the reverse domain name notation, for example, *com.example.demo*, where the first part is the domain suffix **com**, the second part is the vendor/individual name, and the third part is the application name, which can be of multiple levels.<br>If an application is built with the system source code, you are advised to name it in *com.ohos.demo* notation, where **ohos** signifies that the application is an OpenHarmony system application.| String| No|
| debug | Whether the application can be debugged. This tag is generated during compilation and building in DevEco Studio.<br>- **true**: The application can be debugged.<br>- **false**: The application cannot be debugged.| Boolean| Yes (initial value: **false**)| | debug | Whether the application can be debugged. This tag is generated during compilation and building in DevEco Studio.<br>- **true**: The application can be debugged.<br>- **false**: The application cannot be debugged.| Boolean| Yes (initial value: **false**)|
| icon | [Icon of the application](../application-models/application-component-configuration-stage.md). The value is an icon resource index. | String| No| | icon | [Icon of the application](../application-models/application-component-configuration-stage.md). The value is an icon resource index.| String| No|
| label | [Name of the application](../application-models/application-component-configuration-stage.md). The value is a string resource index. | String| No| | label | [Name of the application](../application-models/application-component-configuration-stage.md). The value is a string resource index.| String| No|
| description | Description of the application. The value is a string with a maximum of 255 bytes or a resource index to the description. | String| Yes (initial value: left empty)| | description | Description of the application. The value is a string with a maximum of 255 bytes or a resource index to the description.| String| Yes (initial value: left empty)|
| vendor | Vendor of the application. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)| | vendor | Vendor of the application. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
| versionCode | Version number of the application. The value is a 32-bit non-negative integer less than 2 to the power of 31. It is used only to determine whether a version is later than another version. A larger value indicates a later version. Ensure that a new version of the application uses a value greater than any of its predecessors. | Number| No| | versionCode | Version number of the application. The value is a 32-bit non-negative integer less than 2 to the power of 31. It is used only to determine whether a version is later than another version. A larger value indicates a later version. Ensure that a new version of the application uses a value greater than any of its predecessors. | Number| No|
| versionName | Version number of the application displayed to users.<br>The value consists of only digits and dots. The four-part format *A.B.C.D* is recommended, wherein:<br>Part 1 (*A*): major version number, which ranges from 0 to 99. A major version consists of major new features or large changes.<br>Part 2 (*B*): minor version number, which ranges from 0 to 99. A minor version consists of some new features and large bug fixes.<br>Part 3 (*C*): feature version number, which ranges from 0 to 99. A feature version consists of scheduled new features.<br>Part 4 (*D*): maintenance release number or patch number, which ranges from 0 to 999. A maintenance release or patch consists of resolution to security flaws or minor bugs.<br>The value contains a maximum of 127 bytes.| String| No| | versionName | Version number of the application displayed to users.<br>The value consists of only digits and dots. The four-part format *A.B.C.D* is recommended, wherein:<br>Part 1 (*A*): major version number, which ranges from 0 to 99. A major version consists of major new features or large changes.<br>Part 2 (*B*): minor version number, which ranges from 0 to 99. A minor version consists of some new features and large bug fixes.<br>Part 3 (*C*): feature version number, which ranges from 0 to 99. A feature version consists of scheduled new features.<br>Part 4 (*D*): maintenance release number or patch number, which ranges from 0 to 999. A maintenance release or patch consists of resolution to security flaws or minor bugs.<br>The value contains a maximum of 127 bytes.| String| No|
| minCompatibleVersionCode | Minimum compatible version of the application. It is used to check whether the application is compatible with a version on other devices in the cross-device scenario.| Number| Yes (initial value: value of **versionCode**)| | minCompatibleVersionCode | Minimum compatible version of the application. It is used to check whether the application is compatible with a version on other devices in the cross-device scenario.| Number| Yes (initial value: value of **versionCode**)|
| minAPIVersion | Minimum API version required for running the application.| Number| Yes (initial value: value of **compatibleSdkVersion** in **bundle-profile.json5**)| | minAPIVersion | Minimum API version required for running the application.| Number| Yes (initial value: value of **compatibleSdkVersion** in **build-profile.json5**)|
| targetAPIVersion | Target API version required for running the application.| Number| Yes (initial value: value of **compileSdkVersion** in **bundle-profile.json5**)| | targetAPIVersion | Target API version required for running the application.| Number| Yes (initial value: value of **compileSdkVersion** in **build-profile.json5**)|
| apiReleaseType | Type of the target API version required for running the application. The value can be **"CanaryN"**, **"BetaN"**, or **"Release"**, where **N** represents a positive integer.<br>- **Canary**: indicates a restricted release.<br>- **Beta**: indicates a publicly released beta version.<br>- **Release**: indicates a publicly released official version.<br>The value is set by DevEco Studio reading the stage of the SDK in use.| String| Yes (initial value: set by DevEco Studio)| | apiReleaseType | Type of the target API version required for running the application. The value can be **"CanaryN"**, **"BetaN"**, or **"Release"**, where **N** represents a positive integer.<br>- **Canary**: indicates a restricted release.<br>- **Beta**: indicates a publicly released beta version.<br>- **Release**: indicates a publicly released official version.<br>The value is set by DevEco Studio reading the stage of the SDK in use.| String| Yes (initial value: set by DevEco Studio)|
| distributedNotificationEnabled | Whether distributed notification is enabled for the application. When distributed notification is enabled and device A and device B where the application is installed are on the same distributed network, the devices behave in this way: If device A receives a message, device B will receive a distributed notification prompting the user to check the message received on device A.<br>- **true**: Distributed notification is enabled.<br>- **false**: Distributed notification is not enabled.| Boolean| Yes (initial value: **false**)| | distributedNotificationEnabled | Whether distributed notification is enabled for the application. When distributed notification is enabled and device A and device B where the application is installed are on the same distributed network, the devices behave in this way: If device A receives a message, device B will receive a distributed notification prompting the user to check the message received on device A.<br>- **true**: Distributed notification is enabled.<br>- **false**: Distributed notification is not enabled.| Boolean| Yes (initial value: **false**)|
| entityType | Type of the application. The options are as follows:<br>- game<br>- media<br>- communication<br>- news<br>- travel<br>- utility<br>- shopping<br>- education<br>- kids<br>- business<br>- photography<br>- unspecified| String| Yes (initial value: **"unspecified"**)| | entityType | Type of the application. The options are as follows:<br>- game<br>- media<br>- communication<br>- news<br>- travel<br>- utility<br>- shopping<br>- education<br>- kids<br>- business<br>- photography<br>- unspecified| String| Yes (initial value: **"unspecified"**)|
......
# Application Installation and Uninstallation Process # Application Installation and Uninstallation Process
## Developers
Developers can install and uninstall applications by running debug commands. For details, see [Multi-HAP Development, Debugging, Release, and Deployment Process](multi-hap-release-deployment.md#debugging).
The OpenHarmony bundle manager service module provides APIs for installing, updating, and uninstalling applications. You can call these APIs when needed. After you release your application to the application market, users can install and uninstall it on their device. **Figure 1** Process of installing and uninstalling an application (applicable to developers)
![hap-intall-uninstall](figures/hap-install-uninstall-developer.png)
## Consumers
When an application has been released to the application market, consumers can install or uninstall the application on their device through the application market.
**Figure 1** Process of installing and uninstalling an application **Figure 2** Process of installing and uninstalling an application (applicable to consumers)
![hap-intall-uninstall](figures/hap-intall-uninstall.png) ![hap-intall-uninstall](figures/hap-install-uninstall-user.png)
\ No newline at end of file
...@@ -263,11 +263,11 @@ struct MyComponent { ...@@ -263,11 +263,11 @@ struct MyComponent {
> >
> - **LazyForEach** must be used in the container component. Currently, only the **\<List>**, **\<Grid>**, and **\<Swiper>** components support lazy loading (that is, only the visible part and a small amount of data before and after the visible part are loaded for caching). For other components, all data is loaded at a time. > - **LazyForEach** must be used in the container component. Currently, only the **\<List>**, **\<Grid>**, and **\<Swiper>** components support lazy loading (that is, only the visible part and a small amount of data before and after the visible part are loaded for caching). For other components, all data is loaded at a time.
> >
> - **LazyForEach** must create and only one child component in each iteration. > - **LazyForEach** must create one and only one child component in each iteration.
> >
> - The generated child components must be allowed in the parent container component of **LazyForEach**. > - The generated child components must be the ones allowed in the parent container component of **LazyForEach**.
> >
> - **LazyForEach** can be included in an **if/else** statement, but cannot contain such a statement. > - **LazyForEach** can be included in an **if/else** statement.
> >
> - For the purpose of high-performance rendering, when the **onDataChange** method of the **DataChangeListener** object is used to update the UI, the component update is triggered only when the state variable is used in the child component created by **itemGenerator**. > - For the purpose of high-performance rendering, when the **onDataChange** method of the **DataChangeListener** object is used to update the UI, the component update is triggered only when the state variable is used in the child component created by **itemGenerator**.
> >
......
...@@ -28,12 +28,12 @@ You can use DevEco Studio to build code into one or more HAP files. Then, you ca ...@@ -28,12 +28,12 @@ You can use DevEco Studio to build code into one or more HAP files. Then, you ca
uninstall bundle successfully. uninstall bundle successfully.
``` ```
* Using Bundle Manager (bm) for debugging * Using [Bundle Manager (bm)](../../application-dev/tools/bm-tool.md) for debugging
When using bm to install or update an HAP file, the HAP file path is the one on the real device. The command reference is as follows: When using bm to install or update an HAP file, the HAP file path is the one on the real device. The command reference is as follows:
``` ```
// Installation and update: Multiple file paths can be specified. // Installation and update: Multiple file paths can be specified.
bm install -p /data/app/entry.hap /data/app/ feature.hap bm install -p /data/app/entry.hap /data/app/feature.hap
// The execution result is as follows: // The execution result is as follows:
install bundle successfully. install bundle successfully.
// Uninstall // Uninstall
......
...@@ -224,7 +224,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba ...@@ -224,7 +224,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba
```ts ```ts
import notification from '@ohos.notification'; import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility'; import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) { function callback(err, data) {
if (err) { if (err) {
...@@ -293,7 +293,7 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -293,7 +293,7 @@ Requests a continuous task from the system. This API uses a promise to return th
```ts ```ts
import notification from '@ohos.notification'; import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility'; import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
let wantAgentInfo = { let wantAgentInfo = {
wants: [ wants: [
...@@ -445,7 +445,6 @@ particleAbility.disconnectAbility(connId).then((data) => { ...@@ -445,7 +445,6 @@ particleAbility.disconnectAbility(connId).then((data) => {
}).catch((error) => { }).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code) console.log('particleAbilityTest result errCode : ' + error.code)
}); });
``` ```
## particleAbility.disconnectAbility ## particleAbility.disconnectAbility
...@@ -491,10 +490,10 @@ var connId = particleAbility.connectAbility( ...@@ -491,10 +490,10 @@ var connId = particleAbility.connectAbility(
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
); );
var result = particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data); particleAbility.disconnectAbility(connId, (err) => {
}).catch((error) => { console.log("particleAbilityTest disconnectAbility err====>"
console.log('particleAbilityTest result errCode : ' + error.code) + ("json err=") + JSON.stringify(err));
}); });
``` ```
......
...@@ -9,7 +9,7 @@ The **Configuration** module defines environment change information. ...@@ -9,7 +9,7 @@ The **Configuration** module defines environment change information.
## Modules to Import ## Modules to Import
```ts ```ts
import Configuration from '@ohos.app.ability.Configuration' import Configuration from '@ohos.app.ability.Configuration';
``` ```
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
...@@ -28,9 +28,9 @@ For details about the fields, see the **ohos.app.ability.Configuration.d.ts** fi ...@@ -28,9 +28,9 @@ For details about the fields, see the **ohos.app.ability.Configuration.d.ts** fi
**Example** **Example**
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) { onCreate(want, launchParam) {
let envCallback = { let envCallback = {
onConfigurationUpdated(config) { onConfigurationUpdated(config) {
...@@ -51,5 +51,5 @@ For details about the fields, see the **ohos.app.ability.Configuration.d.ts** fi ...@@ -51,5 +51,5 @@ For details about the fields, see the **ohos.app.ability.Configuration.d.ts** fi
console.log("error: " + paramError.code + ", " + paramError.message); console.log("error: " + paramError.code + ", " + paramError.message);
} }
} }
} }
``` ```
...@@ -124,7 +124,7 @@ Updates a widget. This API uses an asynchronous callback to return the result. ...@@ -124,7 +124,7 @@ Updates a widget. This API uses an asynchronous callback to return the result.
**Example** **Example**
```ts ```ts
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = "12400633174999288";
...@@ -173,7 +173,7 @@ Updates a widget. This API uses a promise to return the result. ...@@ -173,7 +173,7 @@ Updates a widget. This API uses a promise to return the result.
**Example** **Example**
```ts ```ts
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = "12400633174999288";
...@@ -349,7 +349,7 @@ Requests to publish a widget carrying data to the widget host. This API uses an ...@@ -349,7 +349,7 @@ Requests to publish a widget carrying data to the widget host. This API uses an
**Example** **Example**
```ts ```ts
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let want = { let want = {
......
...@@ -9,13 +9,16 @@ This module provides the following common ability-related functions: ...@@ -9,13 +9,16 @@ This module provides the following common ability-related functions:
> **NOTE** > **NOTE**
> >
> The APIs of this module are deprecated since API version 9. You are advised to use [@ohos.app.ability.UIAbility (UIAbility)](js-apis-app-ability-uiAbility.md) instead.
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model. > The APIs of this module can be used only in the stage model.
## Modules to Import ## Modules to Import
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.application.Ability';
``` ```
## Attributes ## Attributes
...@@ -72,7 +75,7 @@ Called when a **WindowStage** is created for this ability. ...@@ -72,7 +75,7 @@ Called when a **WindowStage** is created for this ability.
**Example** **Example**
```ts ```ts
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
} }
...@@ -91,7 +94,7 @@ Called when the **WindowStage** is destroyed for this ability. ...@@ -91,7 +94,7 @@ Called when the **WindowStage** is destroyed for this ability.
**Example** **Example**
```ts ```ts
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
onWindowStageDestroy() { onWindowStageDestroy() {
console.log('onWindowStageDestroy'); console.log('onWindowStageDestroy');
} }
...@@ -116,7 +119,7 @@ Called when the **WindowStage** is restored during the migration of this ability ...@@ -116,7 +119,7 @@ Called when the **WindowStage** is restored during the migration of this ability
**Example** **Example**
```ts ```ts
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
onWindowStageRestore(windowStage) { onWindowStageRestore(windowStage) {
console.log('onWindowStageRestore'); console.log('onWindowStageRestore');
} }
...@@ -135,7 +138,7 @@ Called when this ability is destroyed to clear resources. ...@@ -135,7 +138,7 @@ Called when this ability is destroyed to clear resources.
**Example** **Example**
```ts ```ts
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
onDestroy() { onDestroy() {
console.log('onDestroy'); console.log('onDestroy');
} }
...@@ -154,7 +157,7 @@ Called when this ability is switched from the background to the foreground. ...@@ -154,7 +157,7 @@ Called when this ability is switched from the background to the foreground.
**Example** **Example**
```ts ```ts
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
onForeground() { onForeground() {
console.log('onForeground'); console.log('onForeground');
} }
...@@ -173,7 +176,7 @@ Called when this ability is switched from the foreground to the background. ...@@ -173,7 +176,7 @@ Called when this ability is switched from the foreground to the background.
**Example** **Example**
```ts ```ts
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
onBackground() { onBackground() {
console.log('onBackground'); console.log('onBackground');
} }
...@@ -204,8 +207,9 @@ Called to save data during the ability migration preparation process. ...@@ -204,8 +207,9 @@ Called to save data during the ability migration preparation process.
**Example** **Example**
```ts ```ts
import AbilityConstant from "@ohos.application.AbilityConstant" import AbilityConstant from "@ohos.app.ability.AbilityConstant";
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
onContinue(wantParams) { onContinue(wantParams) {
console.log('onContinue'); console.log('onContinue');
wantParams["myData"] = "my1234567"; wantParams["myData"] = "my1234567";
...@@ -233,7 +237,7 @@ Called when a new Want is passed in and this UIAbility is started again. ...@@ -233,7 +237,7 @@ Called when a new Want is passed in and this UIAbility is started again.
**Example** **Example**
```ts ```ts
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
onNewWant(want, launchParams) { onNewWant(want, launchParams) {
console.log('onNewWant, want:' + want.abilityName); console.log('onNewWant, want:' + want.abilityName);
console.log('onNewWant, launchParams:' + JSON.stringify(launchParams)); console.log('onNewWant, launchParams:' + JSON.stringify(launchParams));
...@@ -258,7 +262,7 @@ Called when the global configuration is updated. ...@@ -258,7 +262,7 @@ Called when the global configuration is updated.
**Example** **Example**
```ts ```ts
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
onConfigurationUpdated(config) { onConfigurationUpdated(config) {
console.log('onConfigurationUpdated, language:' + config.language); console.log('onConfigurationUpdated, language:' + config.language);
} }
...@@ -282,7 +286,7 @@ Dumps client information. ...@@ -282,7 +286,7 @@ Dumps client information.
**Example** **Example**
```ts ```ts
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
dump(params) { dump(params) {
console.log('dump, params:' + JSON.stringify(params)); console.log('dump, params:' + JSON.stringify(params));
return ["params"] return ["params"]
...@@ -307,7 +311,7 @@ Called when the system has decided to adjust the memory level. For example, this ...@@ -307,7 +311,7 @@ Called when the system has decided to adjust the memory level. For example, this
**Example** **Example**
```ts ```ts
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
onMemoryLevel(level) { onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level)); console.log('onMemoryLevel, level:' + JSON.stringify(level));
} }
...@@ -338,9 +342,9 @@ Called when the framework automatically saves the ability state in the case of a ...@@ -338,9 +342,9 @@ Called when the framework automatically saves the ability state in the case of a
**Example** **Example**
```ts ```ts
import AbilityConstant from '@ohos.application.AbilityConstant' import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class myAbility extends Ability { export default class EntryAbility extends UIAbility {
onSaveState(reason, wantParam) { onSaveState(reason, wantParam) {
console.log('onSaveState'); console.log('onSaveState');
wantParam["myData"] = "my1234567"; wantParam["myData"] = "my1234567";
...@@ -349,8 +353,6 @@ class myAbility extends Ability { ...@@ -349,8 +353,6 @@ class myAbility extends Ability {
} }
``` ```
## Caller ## Caller
Implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability). Implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability).
...@@ -546,7 +548,6 @@ Releases the caller interface of the target ability. ...@@ -546,7 +548,6 @@ Releases the caller interface of the target ability.
**Example** **Example**
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
...@@ -716,7 +717,6 @@ Deregisters a caller notification callback, which is invoked when the target abi ...@@ -716,7 +717,6 @@ Deregisters a caller notification callback, which is invoked when the target abi
**Example** **Example**
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
......
...@@ -9,7 +9,7 @@ The **AbilityDelegatorRegistry** module provides APIs for storing the global reg ...@@ -9,7 +9,7 @@ The **AbilityDelegatorRegistry** module provides APIs for storing the global reg
## Modules to Import ## Modules to Import
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
``` ```
## AbilityLifecycleState ## AbilityLifecycleState
......
...@@ -156,7 +156,7 @@ Called when an ability is continued on another device. ...@@ -156,7 +156,7 @@ Called when an ability is continued on another device.
**Example** **Example**
```ts ```ts
import AbilityStage from "@ohos.application.AbilityStage"; import AbilityStage from "@ohos.app.ability.AbilityStage";
var lifecycleId; var lifecycleId;
......
...@@ -10,7 +10,7 @@ The **AbilityManager** module provides APIs for obtaining, adding, and modifying ...@@ -10,7 +10,7 @@ The **AbilityManager** module provides APIs for obtaining, adding, and modifying
## Modules to Import ## Modules to Import
```ts ```ts
import abilityManager from '@ohos.application.abilityManager' import abilityManager from '@ohos.application.abilityManager';
``` ```
## AbilityState ## AbilityState
......
# @ohos.application.AccessibilityExtensionAbility # @ohos.application.AccessibilityExtensionAbility (AccessibilityExtensionAbility)
The **AccessibilityExtensionAbility** module provides accessibility extension capabilities based on the ExtensionAbility framework. The **AccessibilityExtensionAbility** module provides accessibility extension capabilities based on the ExtensionAbility framework.
......
...@@ -26,7 +26,6 @@ import Configuration from '@ohos.application.Configuration' ...@@ -26,7 +26,6 @@ import Configuration from '@ohos.application.Configuration'
For details about the fields, see the **ohos.application.Configuration.d.ts** file. For details about the fields, see the **ohos.application.Configuration.d.ts** file.
**Example** **Example**
```ts ```ts
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
......
...@@ -8,7 +8,7 @@ The **ErrorManager** module provides APIs for registering and deregistering erro ...@@ -8,7 +8,7 @@ The **ErrorManager** module provides APIs for registering and deregistering erro
## Modules to Import ## Modules to Import
```ts ```ts
import errorManager from '@ohos.application.errorManager' import errorManager from '@ohos.application.errorManager';
``` ```
## ErrorManager.registerErrorObserver ## ErrorManager.registerErrorObserver
......
...@@ -48,7 +48,7 @@ Creates a **FormBindingData** object. ...@@ -48,7 +48,7 @@ Creates a **FormBindingData** object.
**Example** **Example**
```ts ```ts
import formBindingData from @ohos.application.formBindingData; import formBindingData from '@ohos.application.formBindingData';
import fs from '@ohos.file.fs'; import fs from '@ohos.file.fs';
try { try {
......
...@@ -94,7 +94,7 @@ Updates a widget. This API uses an asynchronous callback to return the result. ...@@ -94,7 +94,7 @@ Updates a widget. This API uses an asynchronous callback to return the result.
**Example** **Example**
```ts ```ts
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288"; let formId = "12400633174999288";
......
...@@ -1001,7 +1001,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err ...@@ -1001,7 +1001,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example** **Example**
```js ```js
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
// WantAgentInfo object // WantAgentInfo object
let wantAgentInfo = { let wantAgentInfo = {
...@@ -1066,7 +1066,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err ...@@ -1066,7 +1066,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example** **Example**
```js ```js
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
// WantAgentInfo object // WantAgentInfo object
let wantAgentInfo = { let wantAgentInfo = {
...@@ -2222,7 +2222,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err ...@@ -2222,7 +2222,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example** **Example**
```js ```js
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
controller.getLaunchAbility().then((agent) => { controller.getLaunchAbility().then((agent) => {
console.info(`GetLaunchAbility : SUCCESS : wantAgent : ${agent}`); console.info(`GetLaunchAbility : SUCCESS : wantAgent : ${agent}`);
...@@ -2257,7 +2257,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err ...@@ -2257,7 +2257,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example** **Example**
```js ```js
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
controller.getLaunchAbility(function (err, agent) { controller.getLaunchAbility(function (err, agent) {
if (err) { if (err) {
......
...@@ -173,7 +173,7 @@ FA model: ...@@ -173,7 +173,7 @@ FA model:
```js ```js
import backgroundTaskManager from '@ohos.backgroundTaskManager'; import backgroundTaskManager from '@ohos.backgroundTaskManager';
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) { function callback(err, data) {
if (err) { if (err) {
...@@ -207,7 +207,7 @@ Stage model: ...@@ -207,7 +207,7 @@ Stage model:
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import backgroundTaskManager from '@ohos.backgroundTaskManager'; import backgroundTaskManager from '@ohos.backgroundTaskManager';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) { function callback(err, data) {
if (err) { if (err) {
...@@ -270,7 +270,7 @@ FA model: ...@@ -270,7 +270,7 @@ FA model:
```js ```js
import backgroundTaskManager from '@ohos.backgroundTaskManager'; import backgroundTaskManager from '@ohos.backgroundTaskManager';
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
let wantAgentInfo = { let wantAgentInfo = {
wants: [ wants: [
...@@ -299,7 +299,7 @@ Stage model: ...@@ -299,7 +299,7 @@ Stage model:
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import backgroundTaskManager from '@ohos.backgroundTaskManager'; import backgroundTaskManager from '@ohos.backgroundTaskManager';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) { onCreate(want, launchParam) {
......
# @ohos.util.Deque (Linear Container Deque) # @ohos.util.Deque (Linear Container Deque)
> **NOTE** > **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Double-ended queue (deque) is a sequence container implemented based on the queue data structure that follows the principles of First In First Out (FIFO) and Last In First Out (LIFO). It allows insertion and removal of elements at both the ends. **Deque** can dynamically adjust the capacity based on project requirements. It doubles the capacity each time. **Deque** differs from **[Queue](js-apis-queue.md)** and **[Vector](js-apis-vector.md)** mainly in the following aspects: Double-ended queue (deque) is a sequence container implemented based on the queue data structure that follows the principles of First In First Out (FIFO) and Last In First Out (LIFO). It allows insertion and removal of elements at both the ends. **Deque** can dynamically adjust the capacity based on project requirements. It doubles the capacity each time. **Deque** differs from **[Queue](js-apis-queue.md)** and **[Vector](js-apis-vector.md)** mainly in the following aspects:
......
# @ohos.deviceUsageStatistics (Device Usage Statistics) # @ohos.bundleState (Device Usage Statistics)
This module provides APIs for collecting statistics on device usage. This module provides APIs for collecting statistics on device usage.
...@@ -454,6 +454,20 @@ Provides the usage duration information of an application. ...@@ -454,6 +454,20 @@ Provides the usage duration information of an application.
| infosBeginTime | number | No | Time logged in the first application usage record in the **BundleActiveInfo** object.| | infosBeginTime | number | No | Time logged in the first application usage record in the **BundleActiveInfo** object.|
| infosEndTime | number | No | Time logged in the last application usage record in the **BundleActiveInfo** object.| | infosEndTime | number | No | Time logged in the last application usage record in the **BundleActiveInfo** object.|
### merge<sup>(deprecated)</sup>
merge(toMerge: BundleStateInfo): void
Merges the device usage statistics of applications with the same bundle name.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| toMerge | [BundleStateInfo](#bundlestateinfo) | Yes| Device usage statistics to merge.|
## BundleActiveState ## BundleActiveState
Provides information about an application event. Provides information about an application event.
......
...@@ -10,7 +10,7 @@ The **AbilityDelegator** module provides APIs for managing **AbilityMonitor** in ...@@ -10,7 +10,7 @@ The **AbilityDelegator** module provides APIs for managing **AbilityMonitor** in
An **AbilityDelegator** object is obtained by calling [getAbilityDelegator](js-apis-app-ability-abilityDelegatorRegistry.md#abilitydelegatorregistrygetabilitydelegator) in **AbilityDelegatorRegistry**. An **AbilityDelegator** object is obtained by calling [getAbilityDelegator](js-apis-app-ability-abilityDelegatorRegistry.md#abilitydelegatorregistrygetabilitydelegator) in **AbilityDelegatorRegistry**.
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
``` ```
...@@ -35,13 +35,13 @@ Adds an **AbilityMonitor** instance. This API uses an asynchronous callback to r ...@@ -35,13 +35,13 @@ Adds an **AbilityMonitor** instance. This API uses an asynchronous callback to r
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
} }
var monitor = { let monitor = {
abilityName: "abilityname", abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback onAbilityCreate: onAbilityCreateCallback
} }
...@@ -75,13 +75,13 @@ Adds an **AbilityMonitor** instance. This API uses a promise to return the resul ...@@ -75,13 +75,13 @@ Adds an **AbilityMonitor** instance. This API uses a promise to return the resul
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
} }
var monitor = { let monitor = {
abilityName: "abilityname", abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback onAbilityCreate: onAbilityCreateCallback
} }
...@@ -92,8 +92,6 @@ abilityDelegator.addAbilityMonitor(monitor).then(() => { ...@@ -92,8 +92,6 @@ abilityDelegator.addAbilityMonitor(monitor).then(() => {
}); });
``` ```
### removeAbilityMonitor<sup>9+</sup> ### removeAbilityMonitor<sup>9+</sup>
removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): void; removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): void;
...@@ -112,13 +110,13 @@ Removes an **AbilityMonitor** instance. This API uses an asynchronous callback t ...@@ -112,13 +110,13 @@ Removes an **AbilityMonitor** instance. This API uses an asynchronous callback t
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
} }
var monitor = { let monitor = {
abilityName: "abilityname", abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback onAbilityCreate: onAbilityCreateCallback
} }
...@@ -129,8 +127,6 @@ abilityDelegator.removeAbilityMonitor(monitor, (err : any) => { ...@@ -129,8 +127,6 @@ abilityDelegator.removeAbilityMonitor(monitor, (err : any) => {
}); });
``` ```
### removeAbilityMonitor<sup>9+</sup> ### removeAbilityMonitor<sup>9+</sup>
removeAbilityMonitor(monitor: AbilityMonitor): Promise\<void>; removeAbilityMonitor(monitor: AbilityMonitor): Promise\<void>;
...@@ -154,13 +150,13 @@ Removes an **AbilityMonitor** instance. This API uses a promise to return the re ...@@ -154,13 +150,13 @@ Removes an **AbilityMonitor** instance. This API uses a promise to return the re
- Example - Example
```ts ```ts
var abilityDelegator; let abilityDelegator;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
} }
var monitor = { let monitor = {
abilityName: "abilityname", abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback onAbilityCreate: onAbilityCreateCallback
} }
...@@ -171,8 +167,6 @@ abilityDelegator.removeAbilityMonitor(monitor).then(() => { ...@@ -171,8 +167,6 @@ abilityDelegator.removeAbilityMonitor(monitor).then(() => {
}); });
``` ```
### waitAbilityMonitor<sup>9+</sup> ### waitAbilityMonitor<sup>9+</sup>
waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<UIAbility>): void; waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<UIAbility>): void;
...@@ -191,13 +185,13 @@ Waits for the **Ability** instance that matches the **AbilityMonitor** instance ...@@ -191,13 +185,13 @@ Waits for the **Ability** instance that matches the **AbilityMonitor** instance
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
} }
var monitor = { let monitor = {
abilityName: "abilityname", abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback onAbilityCreate: onAbilityCreateCallback
} }
...@@ -227,14 +221,14 @@ Waits a period of time for the **Ability** instance that matches the **AbilityMo ...@@ -227,14 +221,14 @@ Waits a period of time for the **Ability** instance that matches the **AbilityMo
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var timeout = 100; let timeout = 100;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
} }
var monitor = { let monitor = {
abilityName: "abilityname", abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback onAbilityCreate: onAbilityCreateCallback
} }
...@@ -271,13 +265,13 @@ Waits a period of time for the **Ability** instance that matches the **AbilityMo ...@@ -271,13 +265,13 @@ Waits a period of time for the **Ability** instance that matches the **AbilityMo
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
} }
var monitor = { let monitor = {
abilityName: "abilityname", abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback onAbilityCreate: onAbilityCreateCallback
} }
...@@ -288,8 +282,6 @@ abilityDelegator.waitAbilityMonitor(monitor).then((data : any) => { ...@@ -288,8 +282,6 @@ abilityDelegator.waitAbilityMonitor(monitor).then((data : any) => {
}); });
``` ```
### getAppContext<sup>9+</sup> ### getAppContext<sup>9+</sup>
getAppContext(): Context; getAppContext(): Context;
...@@ -307,14 +299,12 @@ Obtains the application context. ...@@ -307,14 +299,12 @@ Obtains the application context.
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var context = abilityDelegator.getAppContext(); let context = abilityDelegator.getAppContext();
``` ```
### getAbilityState<sup>9+</sup> ### getAbilityState<sup>9+</sup>
getAbilityState(ability: UIAbility): number; getAbilityState(ability: UIAbility): number;
...@@ -338,20 +328,18 @@ Obtains the lifecycle state of an ability. ...@@ -338,20 +328,18 @@ Obtains the lifecycle state of an ability.
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var ability; let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => { abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info("getCurrentTopAbility callback"); console.info("getCurrentTopAbility callback");
ability = data; ability = data;
var state = abilityDelegator.getAbilityState(ability); let state = abilityDelegator.getAbilityState(ability);
console.info("getAbilityState" + state); console.info("getAbilityState" + state);
}); });
``` ```
### getCurrentTopAbility<sup>9+</sup> ### getCurrentTopAbility<sup>9+</sup>
getCurrentTopAbility(callback: AsyncCallback\<UIAbility>): void; getCurrentTopAbility(callback: AsyncCallback\<UIAbility>): void;
...@@ -369,8 +357,8 @@ Obtains the top ability of this application. This API uses an asynchronous callb ...@@ -369,8 +357,8 @@ Obtains the top ability of this application. This API uses an asynchronous callb
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var ability; let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => { abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
...@@ -379,8 +367,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ...@@ -379,8 +367,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
}); });
``` ```
### getCurrentTopAbility<sup>9+</sup> ### getCurrentTopAbility<sup>9+</sup>
getCurrentTopAbility(): Promise\<UIAbility>; getCurrentTopAbility(): Promise\<UIAbility>;
...@@ -398,8 +384,8 @@ Obtains the top ability of this application. This API uses a promise to return t ...@@ -398,8 +384,8 @@ Obtains the top ability of this application. This API uses a promise to return t
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var ability; let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility().then((data : any) => { abilityDelegator.getCurrentTopAbility().then((data : any) => {
...@@ -408,8 +394,6 @@ abilityDelegator.getCurrentTopAbility().then((data : any) => { ...@@ -408,8 +394,6 @@ abilityDelegator.getCurrentTopAbility().then((data : any) => {
}); });
``` ```
### startAbility<sup>9+</sup> ### startAbility<sup>9+</sup>
startAbility(want: Want, callback: AsyncCallback\<void>): void; startAbility(want: Want, callback: AsyncCallback\<void>): void;
...@@ -428,8 +412,8 @@ Starts an ability. This API uses an asynchronous callback to return the result. ...@@ -428,8 +412,8 @@ Starts an ability. This API uses an asynchronous callback to return the result.
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var want = { let want = {
bundleName: "bundleName", bundleName: "bundleName",
abilityName: "abilityName" abilityName: "abilityName"
}; };
...@@ -440,8 +424,6 @@ abilityDelegator.startAbility(want, (err : any, data : any) => { ...@@ -440,8 +424,6 @@ abilityDelegator.startAbility(want, (err : any, data : any) => {
}); });
``` ```
### startAbility<sup>9+</sup> ### startAbility<sup>9+</sup>
startAbility(want: Want): Promise\<void>; startAbility(want: Want): Promise\<void>;
...@@ -465,8 +447,8 @@ Starts an ability. This API uses a promise to return the result. ...@@ -465,8 +447,8 @@ Starts an ability. This API uses a promise to return the result.
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var want = { let want = {
bundleName: "bundleName", bundleName: "bundleName",
abilityName: "abilityName" abilityName: "abilityName"
}; };
...@@ -477,8 +459,6 @@ abilityDelegator.startAbility(want).then((data: any) => { ...@@ -477,8 +459,6 @@ abilityDelegator.startAbility(want).then((data: any) => {
}); });
``` ```
### doAbilityForeground<sup>9+</sup> ### doAbilityForeground<sup>9+</sup>
doAbilityForeground(ability: UIAbility, callback: AsyncCallback\<void>): void; doAbilityForeground(ability: UIAbility, callback: AsyncCallback\<void>): void;
...@@ -497,8 +477,8 @@ Schedules the lifecycle state of an ability to **Foreground**. This API uses an ...@@ -497,8 +477,8 @@ Schedules the lifecycle state of an ability to **Foreground**. This API uses an
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var ability; let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => { abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
...@@ -510,8 +490,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ...@@ -510,8 +490,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
}); });
``` ```
### doAbilityForeground<sup>9+</sup> ### doAbilityForeground<sup>9+</sup>
doAbilityForeground(ability: UIAbility): Promise\<void>; doAbilityForeground(ability: UIAbility): Promise\<void>;
...@@ -535,8 +513,8 @@ Schedules the lifecycle state of an ability to **Foreground**. This API uses a p ...@@ -535,8 +513,8 @@ Schedules the lifecycle state of an ability to **Foreground**. This API uses a p
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var ability; let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => { abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
...@@ -548,8 +526,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ...@@ -548,8 +526,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
}); });
``` ```
### doAbilityBackground<sup>9+</sup> ### doAbilityBackground<sup>9+</sup>
doAbilityBackground(ability: UIAbility, callback: AsyncCallback\<void>): void; doAbilityBackground(ability: UIAbility, callback: AsyncCallback\<void>): void;
...@@ -568,8 +544,8 @@ Schedules the lifecycle state of an ability to **Background**. This API uses an ...@@ -568,8 +544,8 @@ Schedules the lifecycle state of an ability to **Background**. This API uses an
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var ability; let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => { abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
...@@ -581,8 +557,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ...@@ -581,8 +557,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
}); });
``` ```
### doAbilityBackground<sup>9+</sup> ### doAbilityBackground<sup>9+</sup>
doAbilityBackground(ability: UIAbility): Promise\<void>; doAbilityBackground(ability: UIAbility): Promise\<void>;
...@@ -606,8 +580,8 @@ Schedules the lifecycle state of an ability to **Background**. This API uses a p ...@@ -606,8 +580,8 @@ Schedules the lifecycle state of an ability to **Background**. This API uses a p
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var ability; let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => { abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
...@@ -619,8 +593,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { ...@@ -619,8 +593,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
}); });
``` ```
### printSync<sup>9+</sup> ### printSync<sup>9+</sup>
printSync(msg: string): void; printSync(msg: string): void;
...@@ -638,15 +610,13 @@ Prints log information to the unit test console. ...@@ -638,15 +610,13 @@ Prints log information to the unit test console.
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var msg = "msg"; let msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.printSync(msg); abilityDelegator.printSync(msg);
``` ```
### print ### print
print(msg: string, callback: AsyncCallback\<void>): void; print(msg: string, callback: AsyncCallback\<void>): void;
...@@ -665,8 +635,8 @@ Prints log information to the unit test console. This API uses an asynchronous c ...@@ -665,8 +635,8 @@ Prints log information to the unit test console. This API uses an asynchronous c
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var msg = "msg"; let msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.print(msg, (err : any) => { abilityDelegator.print(msg, (err : any) => {
...@@ -674,8 +644,6 @@ abilityDelegator.print(msg, (err : any) => { ...@@ -674,8 +644,6 @@ abilityDelegator.print(msg, (err : any) => {
}); });
``` ```
### print ### print
print(msg: string): Promise\<void>; print(msg: string): Promise\<void>;
...@@ -699,8 +667,8 @@ Prints log information to the unit test console. This API uses a promise to retu ...@@ -699,8 +667,8 @@ Prints log information to the unit test console. This API uses a promise to retu
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var msg = "msg"; let msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.print(msg).then(() => { abilityDelegator.print(msg).then(() => {
...@@ -708,8 +676,6 @@ abilityDelegator.print(msg).then(() => { ...@@ -708,8 +676,6 @@ abilityDelegator.print(msg).then(() => {
}); });
``` ```
### executeShellCommand ### executeShellCommand
executeShellCommand(cmd: string, callback: AsyncCallback\<ShellCmdResult>): void; executeShellCommand(cmd: string, callback: AsyncCallback\<ShellCmdResult>): void;
...@@ -728,8 +694,8 @@ Executes a shell command. This API uses an asynchronous callback to return the r ...@@ -728,8 +694,8 @@ Executes a shell command. This API uses an asynchronous callback to return the r
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var cmd = "cmd"; let cmd = "cmd";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, (err : any, data : any) => { abilityDelegator.executeShellCommand(cmd, (err : any, data : any) => {
...@@ -737,8 +703,6 @@ abilityDelegator.executeShellCommand(cmd, (err : any, data : any) => { ...@@ -737,8 +703,6 @@ abilityDelegator.executeShellCommand(cmd, (err : any, data : any) => {
}); });
``` ```
### executeShellCommand ### executeShellCommand
executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback\<ShellCmdResult>): void; executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback\<ShellCmdResult>): void;
...@@ -758,9 +722,9 @@ Executes a shell command with the timeout period specified. This API uses an asy ...@@ -758,9 +722,9 @@ Executes a shell command with the timeout period specified. This API uses an asy
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var cmd = "cmd"; let cmd = "cmd";
var timeout = 100; let timeout = 100;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => { abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => {
...@@ -768,8 +732,6 @@ abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => { ...@@ -768,8 +732,6 @@ abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => {
}); });
``` ```
### executeShellCommand ### executeShellCommand
executeShellCommand(cmd: string, timeoutSecs?: number): Promise\<ShellCmdResult>; executeShellCommand(cmd: string, timeoutSecs?: number): Promise\<ShellCmdResult>;
...@@ -794,9 +756,9 @@ Executes a shell command with the timeout period specified. This API uses a prom ...@@ -794,9 +756,9 @@ Executes a shell command with the timeout period specified. This API uses a prom
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var cmd = "cmd"; let cmd = "cmd";
var timeout = 100; let timeout = 100;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => { abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => {
...@@ -804,8 +766,6 @@ abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => { ...@@ -804,8 +766,6 @@ abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => {
}); });
``` ```
### finishTest<sup>9+</sup> ### finishTest<sup>9+</sup>
finishTest(msg: string, code: number, callback: AsyncCallback\<void>): void; finishTest(msg: string, code: number, callback: AsyncCallback\<void>): void;
...@@ -825,8 +785,8 @@ Finishes the test and prints log information to the unit test console. This API ...@@ -825,8 +785,8 @@ Finishes the test and prints log information to the unit test console. This API
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var msg = "msg"; let msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.finishTest(msg, 0, (err : any) => { abilityDelegator.finishTest(msg, 0, (err : any) => {
...@@ -834,8 +794,6 @@ abilityDelegator.finishTest(msg, 0, (err : any) => { ...@@ -834,8 +794,6 @@ abilityDelegator.finishTest(msg, 0, (err : any) => {
}); });
``` ```
### finishTest<sup>9+</sup> ### finishTest<sup>9+</sup>
finishTest(msg: string, code: number): Promise\<void>; finishTest(msg: string, code: number): Promise\<void>;
...@@ -860,8 +818,8 @@ Finishes the test and prints log information to the unit test console. This API ...@@ -860,8 +818,8 @@ Finishes the test and prints log information to the unit test console. This API
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var msg = "msg"; let msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.finishTest(msg, 0).then(() => { abilityDelegator.finishTest(msg, 0).then(() => {
...@@ -887,9 +845,9 @@ Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes ...@@ -887,9 +845,9 @@ Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var monitor = { let monitor = {
moduleName: "moduleName", moduleName: "moduleName",
srcEntrance: "srcEntrance", srcEntrance: "srcEntrance",
} }
...@@ -900,8 +858,6 @@ abilityDelegator.addAbilityStageMonitor(monitor, (err : any) => { ...@@ -900,8 +858,6 @@ abilityDelegator.addAbilityStageMonitor(monitor, (err : any) => {
}); });
``` ```
### addAbilityStageMonitor<sup>9+</sup> ### addAbilityStageMonitor<sup>9+</sup>
addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>; addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
...@@ -925,9 +881,9 @@ Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes ...@@ -925,9 +881,9 @@ Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var monitor = { let monitor = {
moduleName: "moduleName", moduleName: "moduleName",
srcEntrance: "srcEntrance", srcEntrance: "srcEntrance",
} }
...@@ -956,9 +912,9 @@ Removes an **AbilityStageMonitor** instance from the application memory. This AP ...@@ -956,9 +912,9 @@ Removes an **AbilityStageMonitor** instance from the application memory. This AP
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var monitor = { let monitor = {
moduleName: "moduleName", moduleName: "moduleName",
srcEntrance: "srcEntrance", srcEntrance: "srcEntrance",
} }
...@@ -969,8 +925,6 @@ abilityDelegator.removeAbilityStageMonitor(monitor, (err : any) => { ...@@ -969,8 +925,6 @@ abilityDelegator.removeAbilityStageMonitor(monitor, (err : any) => {
}); });
``` ```
### removeAbilityStageMonitor<sup>9+</sup> ### removeAbilityStageMonitor<sup>9+</sup>
removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>; removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
...@@ -994,9 +948,9 @@ Removes an **AbilityStageMonitor** object from the application memory. This API ...@@ -994,9 +948,9 @@ Removes an **AbilityStageMonitor** object from the application memory. This API
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var monitor = { let monitor = {
moduleName: "moduleName", moduleName: "moduleName",
srcEntrance: "srcEntrance", srcEntrance: "srcEntrance",
} }
...@@ -1025,13 +979,13 @@ Waits for an **AbilityStage** instance that matches the conditions set in an **A ...@@ -1025,13 +979,13 @@ Waits for an **AbilityStage** instance that matches the conditions set in an **A
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
} }
var monitor = { let monitor = {
moduleName: "moduleName", moduleName: "moduleName",
srcEntrance: "srcEntrance", srcEntrance: "srcEntrance",
} }
...@@ -1066,13 +1020,13 @@ Waits for an **AbilityStage** instance that matches the conditions set in an **A ...@@ -1066,13 +1020,13 @@ Waits for an **AbilityStage** instance that matches the conditions set in an **A
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
} }
var monitor = { let monitor = {
moduleName: "moduleName", moduleName: "moduleName",
srcEntrance: "srcEntrance", srcEntrance: "srcEntrance",
} }
...@@ -1102,14 +1056,14 @@ Waits a period of time for an **AbilityStage** instance that matches the conditi ...@@ -1102,14 +1056,14 @@ Waits a period of time for an **AbilityStage** instance that matches the conditi
**Example** **Example**
```ts ```ts
var abilityDelegator; let abilityDelegator;
var timeout = 100; let timeout = 100;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
} }
var monitor = { let monitor = {
moduleName: "moduleName", moduleName: "moduleName",
srcEntrance: "srcEntrance", srcEntrance: "srcEntrance",
} }
......
...@@ -26,7 +26,7 @@ Describes the ability delegator arguments. ...@@ -26,7 +26,7 @@ Describes the ability delegator arguments.
**Example** **Example**
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var args = AbilityDelegatorRegistry.getArguments(); var args = AbilityDelegatorRegistry.getArguments();
``` ```
...@@ -30,7 +30,7 @@ Describes an ability monitor. ...@@ -30,7 +30,7 @@ Describes an ability monitor.
**Example** **Example**
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback"); console.info("onAbilityCreateCallback");
......
...@@ -28,7 +28,8 @@ The ability running information is obtained by calling [getAbilityRunningInfos]( ...@@ -28,7 +28,8 @@ The ability running information is obtained by calling [getAbilityRunningInfos](
**Example** **Example**
```ts ```ts
import abilitymanager from '@ohos.application.abilityManager'; import abilitymanager from '@ohos.app.ability.abilityManager';
abilitymanager.getAbilityRunningInfos((err,data) => { abilitymanager.getAbilityRunningInfos((err,data) => {
console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data)); console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data));
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
......
...@@ -14,7 +14,8 @@ This module provides APIs for accessing a specific ability stage. You can use th ...@@ -14,7 +14,8 @@ This module provides APIs for accessing a specific ability stage. You can use th
The ability stage context is obtained through an **AbilityStage** instance. The ability stage context is obtained through an **AbilityStage** instance.
```ts ```ts
import AbilityStage from '@ohos.application.AbilityStage'; import AbilityStage from '@ohos.app.ability.AbilityStage';
class MyAbilityStage extends AbilityStage { class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
let abilityStageContext = this.context; let abilityStageContext = this.context;
......
...@@ -11,7 +11,7 @@ The **AbilityStageMonitor** module provides conditions for matching **AbilitySta ...@@ -11,7 +11,7 @@ The **AbilityStageMonitor** module provides conditions for matching **AbilitySta
**Example** **Example**
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let monitor = { let monitor = {
moduleName: "feature_as1", moduleName: "feature_as1",
......
...@@ -16,7 +16,7 @@ The **ApplicationStateObserver** module defines an observer to listen for applic ...@@ -16,7 +16,7 @@ The **ApplicationStateObserver** module defines an observer to listen for applic
**Example** **Example**
```ts ```ts
import appManager from "@ohos.application.appManager" import appManager from "@ohos.app.ability.appManager";
let applicationStateObserver = { let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) { onForegroundApplicationChanged(appStateData) {
......
...@@ -31,8 +31,9 @@ To adapt to devices with different performance, an application provides three mo ...@@ -31,8 +31,9 @@ To adapt to devices with different performance, an application provides three mo
Define a **ServiceExtension** with the same name for the three modules. Define a **ServiceExtension** with the same name for the three modules.
```ts ```ts
import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility' import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility';
import Want from '@ohos.application.Want' import Want from '@ohos.app.ability.Want';
export default class TheServiceExtension extends ServiceExtension { export default class TheServiceExtension extends ServiceExtension {
onCreate(want:Want) { onCreate(want:Want) {
console.log('ServiceAbility onCreate, want: ' + want.abilityName); console.log('ServiceAbility onCreate, want: ' + want.abilityName);
......
...@@ -17,7 +17,7 @@ The **ProcessData** module defines process data. If a lifecycle change listener ...@@ -17,7 +17,7 @@ The **ProcessData** module defines process data. If a lifecycle change listener
**Example** **Example**
```ts ```ts
import appManager from '@ohos.application.appManager' import appManager from '@ohos.app.ability.appManager';
let applicationStateObserver = { let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) { onForegroundApplicationChanged(appStateData) {
......
...@@ -23,7 +23,7 @@ The process running information is obtained by using [getProcessRunningInfos](js ...@@ -23,7 +23,7 @@ The process running information is obtained by using [getProcessRunningInfos](js
**Example** **Example**
```ts ```ts
import appManager from '@ohos.application.appManager'; import appManager from '@ohos.app.ability.appManager';
appManager.getProcessRunningInfos().then((data) => { appManager.getProcessRunningInfos().then((data) => {
console.log('success:' + JSON.stringify(data)); console.log('success:' + JSON.stringify(data));
......
...@@ -19,7 +19,7 @@ The result is obtained by calling [executeShellCommand](js-apis-inner-applicatio ...@@ -19,7 +19,7 @@ The result is obtained by calling [executeShellCommand](js-apis-inner-applicatio
**Example** **Example**
```ts ```ts
import AbilityDelegatorRegistry from "@ohos.application.abilityDelegatorRegistry"; import AbilityDelegatorRegistry from "@ohos.app.ability.abilityDelegatorRegistry";
let abilityDelegator; let abilityDelegator;
let cmd = "cmd"; let cmd = "cmd";
......
# @ohos.inputmethodextensionability (InputMethodExtensionAbility) # @ohos.InputMethodExtensionAbility (InputMethodExtensionAbility)
The **InputMethodExtensionAbility** module provides APIs for developing input methods and managing their lifecycles. The **InputMethodExtensionAbility** module provides APIs for developing input methods and managing their lifecycles.
...@@ -9,7 +9,7 @@ The **InputMethodExtensionAbility** module provides APIs for developing input me ...@@ -9,7 +9,7 @@ The **InputMethodExtensionAbility** module provides APIs for developing input me
## Modules to Import ## Modules to Import
```js ```js
import InputMethodExtensionAbility from '@ohos.inputmethodextensionability'; import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
``` ```
## Attributes ## Attributes
......
# @ohos.inputmethodextensioncontext (InputMethodExtensionContext) # @ohos.InputMethodExtensionContext (InputMethodExtensionContext)
The **InputMethodExtensionContext** module, inherited from **ExtensionContext**, provides context for **InputMethodExtension** abilities. The **InputMethodExtensionContext** module, inherited from **ExtensionContext**, provides context for **InputMethodExtension** abilities.
...@@ -11,7 +11,7 @@ You can use the APIs of this module to start, terminate, connect, and disconnect ...@@ -11,7 +11,7 @@ You can use the APIs of this module to start, terminate, connect, and disconnect
## Modules to Import ## Modules to Import
``` ```
import InputMethodExtensionContext from '@ohos.inputmethodextensioncontext'; import InputMethodExtensionContext from '@ohos.InputMethodExtensionContext';
``` ```
## Usage ## Usage
...@@ -19,7 +19,7 @@ import InputMethodExtensionContext from '@ohos.inputmethodextensioncontext'; ...@@ -19,7 +19,7 @@ import InputMethodExtensionContext from '@ohos.inputmethodextensioncontext';
Before using the **InputMethodExtensionContext** module, you must define a child class that inherits from **InputMethodExtensionAbility**. Before using the **InputMethodExtensionContext** module, you must define a child class that inherits from **InputMethodExtensionAbility**.
```js ```js
import InputMethodExtensionAbility from '@ohos.inputmethodextensionability'; import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
class EntryAbility extends InputMethodExtensionAbility { class EntryAbility extends InputMethodExtensionAbility {
onCreate() { onCreate() {
let context = this.context; let context = this.context;
...@@ -66,9 +66,9 @@ Terminates this ability. This API uses a promise to return the result. ...@@ -66,9 +66,9 @@ Terminates this ability. This API uses a promise to return the result.
**Example** **Example**
```js ```js
this.context.destroy().then((data) => { this.context.destroy().then(() => {
console.log('success:' + JSON.stringify(data)); console.log('Succeed in destroying context.');
}).catch((error) => { }).catch((error) => {
console.log('failed:' + JSON.stringify(error)); console.log('Failed to destroy context: ' + JSON.stringify(error));
}); });
``` ```
# @ohos.inputmethodsubtype (Input Method Subtype) # @ohos.InputMethodSubtype (Input Method Subtype)
The **inputMethodSubtype** module provides APIs for managing the attributes of input method subtypes. Different attribute settings result in different subtypes. The **InputMethodSubtype** module provides APIs for managing the attributes of input method subtypes. Different attribute settings result in different subtypes.
> **NOTE** > **NOTE**
> >
...@@ -9,7 +9,7 @@ The **inputMethodSubtype** module provides APIs for managing the attributes of i ...@@ -9,7 +9,7 @@ The **inputMethodSubtype** module provides APIs for managing the attributes of i
## Modules to Import ## Modules to Import
``` ```
import inputMethodEngine from '@ohos.inputMethodSubtype'; import InputMethodSubtype from '@ohos.InputMethodSubtype';
``` ```
## Attributes ## Attributes
......
# @ohos.inputmethod (Input Method Framework) # @ohos.inputMethod (Input Method Framework)
The **inputMethod** module provides an input method framework, which can be used to hide the keyboard, obtain the list of installed input methods, display the dialog box for input method selection, and more. The **inputMethod** module provides an input method framework, which can be used to hide the keyboard, obtain the list of installed input methods, display the dialog box for input method selection, and more.
...@@ -10,7 +10,7 @@ The **inputMethod** module provides an input method framework, which can be used ...@@ -10,7 +10,7 @@ The **inputMethod** module provides an input method framework, which can be used
## Modules to Import ## Modules to Import
```js ```js
import inputMethod from '@ohos.inputmethod'; import inputMethod from '@ohos.inputMethod';
``` ```
## Constants<sup>8+</sup> ## Constants<sup>8+</sup>
...@@ -111,7 +111,7 @@ Switches to another input method. This API uses an asynchronous callback to retu ...@@ -111,7 +111,7 @@ Switches to another input method. This API uses an asynchronous callback to retu
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| target | [InputMethodProperty](#inputmethodproperty8) | Yes| Input method to switch to.| | target | [InputMethodProperty](#inputmethodproperty8) | Yes| Input method to switch to.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -160,15 +160,15 @@ Switches to another input method. This API uses a promise to return the result. ...@@ -160,15 +160,15 @@ Switches to another input method. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
|target | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.| |target | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------- | ---------------------------- | | ----------------------------------------- | ---------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.| | Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
**Error codes** **Error codes**
...@@ -240,7 +240,7 @@ Switches to another subtype of the current input method. This API uses an asynch ...@@ -240,7 +240,7 @@ Switches to another subtype of the current input method. This API uses an asynch
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| target | [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Input method subtype to switch to.| | target | [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Input method subtype to switch to.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -376,7 +376,7 @@ Switches to a specified subtype of a specified input method. This API uses an as ...@@ -376,7 +376,7 @@ Switches to a specified subtype of a specified input method. This API uses an as
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
|inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.| |inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
|inputMethodSubtype | [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Input method subtype to switch to.| |inputMethodSubtype | [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Input method subtype to switch to.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -557,7 +557,7 @@ Ends this input session. The invoking of this API takes effect only after the in ...@@ -557,7 +557,7 @@ Ends this input session. The invoking of this API takes effect only after the in
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -643,7 +643,7 @@ Shows this soft keyboard. This API must be used with the input text box and work ...@@ -643,7 +643,7 @@ Shows this soft keyboard. This API must be used with the input text box and work
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -715,7 +715,7 @@ Hides this soft keyboard. This API must be used with the input text box and work ...@@ -715,7 +715,7 @@ Hides this soft keyboard. This API must be used with the input text box and work
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -789,7 +789,7 @@ Ends this input session. The invoking of this API takes effect only after the in ...@@ -789,7 +789,7 @@ Ends this input session. The invoking of this API takes effect only after the in
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Example** **Example**
...@@ -1157,7 +1157,7 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono ...@@ -1157,7 +1157,7 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. | | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -1291,7 +1291,7 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono ...@@ -1291,7 +1291,7 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. | | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example** **Example**
......
# @ohos.inputmethodengine (Input Method Service) # @ohos.inputMethodEngine (Input Method Service)
The **inputMethodEngine** module streamlines the interaction between input methods and applications. By calling APIs of this module, applications can be bound to input method services to accept text input through the input methods, request the keyboard to display or hide, listen for the input method status, and much more. The **inputMethodEngine** module streamlines the interactions between input methods and applications. By calling APIs of this module, applications can be bound to input method services to accept text input, request the keyboard to display or hide, listen for the input method status, and much more.
> **NOTE** > **NOTE**
> >
...@@ -9,7 +9,7 @@ The **inputMethodEngine** module streamlines the interaction between input metho ...@@ -9,7 +9,7 @@ The **inputMethodEngine** module streamlines the interaction between input metho
## Modules to Import ## Modules to Import
``` ```
import inputMethodEngine from '@ohos.inputmethodengine'; import inputMethodEngine from '@ohos.inputMethodEngine';
``` ```
## Constants ## Constants
...@@ -203,7 +203,7 @@ Enables listening for a keyboard event. This API uses an asynchronous callback t ...@@ -203,7 +203,7 @@ Enables listening for a keyboard event. This API uses an asynchronous callback t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>- The value **'keyboardShow'** indicates the keyboard display event.<br>- The value **'keyboardHide'** indicates the keyboard hiding event. | | type | string | Yes | Listening type.<br>- The value **'keyboardShow'** indicates the keyboard display event.<br>- The value **'keyboardHide'** indicates the keyboard hiding event.|
| callback | () => void | Yes | Callback used to return the result. | | callback | () => void | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -418,7 +418,7 @@ Disables listening for a keyboard event. This API uses an asynchronous callback ...@@ -418,7 +418,7 @@ Disables listening for a keyboard event. This API uses an asynchronous callback
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'keyboardShow'** indicates the keyboard display event.<br>The value **'keyboardHide'** indicates the keyboard hiding event.| | type | string | Yes | Listening type.<br>- The value **'keyboardShow'** indicates the keyboard display event.<br>- The value **'keyboardHide'** indicates the keyboard hiding event.|
| callback | () => void | No | Callback used to return the result. | | callback | () => void | No | Callback used to return the result. |
**Example** **Example**
......
# @ohos.bundle.launcherBundleManager # @ohos.bundle.launcherBundleManager (launcherBundleManager)
The **bundle.launcherBundleManager** module providers APIs for the **Home Screen** application to obtain the launcher ability information and shortcut information. The **bundle.launcherBundleManager** module providers APIs for the **Home Screen** application to obtain the launcher ability information and shortcut information.
......
...@@ -389,7 +389,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco ...@@ -389,7 +389,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 10200011 | The removeFirst method cannot be bound. | | 10200011 | The removeFirst method cannot be bound. |
| 10200010 | The container is empty. | | 10200010 | Container is empty. |
**Example** **Example**
...@@ -424,7 +424,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco ...@@ -424,7 +424,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 10200011 | The removeLast method cannot be bound. | | 10200011 | The removeLast method cannot be bound. |
| 10200010 | The container is empty. | | 10200010 | Container is empty. |
**Example** **Example**
...@@ -504,7 +504,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco ...@@ -504,7 +504,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 10200011 | The removeFirstFound method cannot be bound. | | 10200011 | The removeFirstFound method cannot be bound. |
| 10200010 | The container is empty. | | 10200010 | Container is empty. |
**Example** **Example**
...@@ -544,7 +544,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco ...@@ -544,7 +544,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 10200011 | The removeLastFound method cannot be bound. | | 10200011 | The removeLastFound method cannot be bound. |
| 10200010 | The container is empty. | | 10200010 | Container is empty. |
**Example** **Example**
......
# @ohos.reminderAgent (reminderAgent) # @ohos.reminderAgent (Reminder Agent)
The **reminderAgent** module provides APIs for publishing scheduled reminders through the reminder agent. The **reminderAgent** module provides APIs for publishing scheduled reminders through the reminder agent.
......
# @ohos.reminderAgentManager (reminderAgentManager) # @ohos.reminderAgentManager (Reminder Agent Management)
The **reminderAgentManager** module provides APIs for publishing scheduled reminders through the reminder agent. The **reminderAgentManager** module provides APIs for publishing scheduled reminders through the reminder agent.
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
The **request** module provides applications with basic upload, download, and background transmission agent capabilities. The **request** module provides applications with basic upload, download, and background transmission agent capabilities.
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -77,7 +78,7 @@ The table below lists the causes of download pause that may be returned by [getT ...@@ -77,7 +78,7 @@ The table below lists the causes of download pause that may be returned by [getT
| PAUSED_QUEUED_FOR_WIFI<sup>7+</sup> | number | 0 | Download paused and queuing for a WLAN connection, because the file size exceeds the maximum value allowed by a mobile network session.| | PAUSED_QUEUED_FOR_WIFI<sup>7+</sup> | number | 0 | Download paused and queuing for a WLAN connection, because the file size exceeds the maximum value allowed by a mobile network session.|
| PAUSED_WAITING_FOR_NETWORK<sup>7+</sup> | number | 1 | Download paused due to a network connection problem, for example, network disconnection.| | PAUSED_WAITING_FOR_NETWORK<sup>7+</sup> | number | 1 | Download paused due to a network connection problem, for example, network disconnection.|
| PAUSED_WAITING_TO_RETRY<sup>7+</sup> | number | 2 | Download paused and then retried.| | PAUSED_WAITING_TO_RETRY<sup>7+</sup> | number | 2 | Download paused and then retried.|
| PAUSED_BY_USER<sup>9+</sup> | number | 3 | The user paused the session. | | PAUSED_BY_USER<sup>9+</sup> | number | 3 | The user paused the session.|
| PAUSED_UNKNOWN<sup>7+</sup> | number | 4 | Download paused due to unknown reasons.| | PAUSED_UNKNOWN<sup>7+</sup> | number | 4 | Download paused due to unknown reasons.|
### Download Task Status Codes ### Download Task Status Codes
...@@ -378,6 +379,8 @@ Uploads files. This API uses an asynchronous callback to return the result. ...@@ -378,6 +379,8 @@ Uploads files. This API uses an asynchronous callback to return the result.
Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object through [request.uploadFile<sup>9+</sup>](#requestuploadfile9) in promise mode or [request.uploadFile<sup>9+</sup>](#requestuploadfile9-1) in callback mode. Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object through [request.uploadFile<sup>9+</sup>](#requestuploadfile9) in promise mode or [request.uploadFile<sup>9+</sup>](#requestuploadfile9-1) in callback mode.
### on('progress') ### on('progress')
on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void
...@@ -399,8 +402,8 @@ Parameters of the callback function ...@@ -399,8 +402,8 @@ Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bytes. | | uploadedSize | number | Yes| Size of the uploaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to upload, in bytes. | | totalSize | number | Yes| Total size of the files to upload, in bytes.|
**Example** **Example**
...@@ -504,12 +507,12 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -504,12 +507,12 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).|
| callback | function | No| Callback for the upload progress event.| | callback | function | No| Callback for the upload progress event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bytes. | | uploadedSize | number | Yes| Size of the uploaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to upload, in bytes. | | totalSize | number | Yes| Total size of the files to upload, in bytes.|
**Example** **Example**
...@@ -764,7 +767,7 @@ Removes this upload task. This API uses an asynchronous callback to return the r ...@@ -764,7 +767,7 @@ Removes this upload task. This API uses an asynchronous callback to return the r
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| filename | string | Yes| File name in the header when **multipart** is used.| | filename | string | Yes| File name in the header when **multipart** is used.|
| name | string | Yes| Name of a form item when **multipart** is used. The default value is **file**.| | name | string | Yes| Name of a form item when **multipart** is used. The default value is **file**.|
| uri | string | Yes| Local path for storing files.<br>The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. Below are examples:<br>dataability:///com.domainname.dataability.persondata/person/10/file.txt<br><br>internal://cache/path/to/file.txt | | uri | string | Yes| Local path for storing files.<br>Only the **internal** protocol type is supported. In the value, **internal://cache/** is mandatory. Example:<br>internal://cache/path/to/file.txt |
| type | string | Yes| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.| | type | string | Yes| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.|
...@@ -1047,12 +1050,12 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -1047,12 +1050,12 @@ Subscribes to a download event. This API uses an asynchronous callback to return
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).| | type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).|
| callback | function | Yes| Callback for the download progress event.| | callback | function | Yes| Callback for the download progress event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bytes. | | receivedSize | number | Yes| Size of the downloaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to download, in bytes. | | totalSize | number | Yes| Total size of the files to download, in bytes.|
**Example** **Example**
...@@ -1085,8 +1088,8 @@ Parameters of the callback function ...@@ -1085,8 +1088,8 @@ Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bytes. | | receivedSize | number | Yes| Size of the downloaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to download, in bytes. | | totalSize | number | Yes| Total size of the files to download, in bytes.|
**Example** **Example**
...@@ -1252,7 +1255,7 @@ Removes this download task. This API uses a promise to return the result. ...@@ -1252,7 +1255,7 @@ Removes this download task. This API uses a promise to return the result.
delete(callback: AsyncCallback&lt;boolean&gt;): void delete(callback: AsyncCallback&lt;boolean&gt;): void
Removes this download task. This API uses an asynchronous callback to return the result. Deletes this download task. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -1262,7 +1265,7 @@ Removes this download task. This API uses an asynchronous callback to return the ...@@ -1262,7 +1265,7 @@ Removes this download task. This API uses an asynchronous callback to return the
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the task removal result.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the task deletion result. |
**Example** **Example**
......
...@@ -67,8 +67,8 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er ...@@ -67,8 +67,8 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
console.info("Request suspension delay will time out."); console.info("Request suspension delay will time out.");
}) })
var id = delayInfo.requestId; let id = delayInfo.requestId;
var time = delayInfo.actualDelayTime; let time = delayInfo.actualDelayTime;
console.info("The requestId is: " + id); console.info("The requestId is: " + id);
console.info("The actualDelayTime is: " + time); console.info("The actualDelayTime is: " + time);
} catch (error) { } catch (error) {
...@@ -258,7 +258,7 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er ...@@ -258,7 +258,7 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er
```js ```js
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
function callback(error, data) { function callback(error, data) {
if (error) { if (error) {
...@@ -282,6 +282,7 @@ export default class EntryAbility extends UIAbility { ...@@ -282,6 +282,7 @@ export default class EntryAbility extends UIAbility {
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}; };
try {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
try { try {
backgroundTaskManager.startBackgroundRunning(this.context, backgroundTaskManager.startBackgroundRunning(this.context,
...@@ -290,6 +291,9 @@ export default class EntryAbility extends UIAbility { ...@@ -290,6 +291,9 @@ export default class EntryAbility extends UIAbility {
console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`); console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
} }
}); });
} catch (error) {
console.error(`Operation getWantAgent failed. code is ${error.code} message is ${error.message}`);
}
} }
}; };
``` ```
...@@ -337,7 +341,7 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er ...@@ -337,7 +341,7 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er
```js ```js
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) { onCreate(want, launchParam) {
...@@ -353,6 +357,7 @@ export default class EntryAbility extends UIAbility { ...@@ -353,6 +357,7 @@ export default class EntryAbility extends UIAbility {
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}; };
try {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
try { try {
backgroundTaskManager.startBackgroundRunning(this.context, backgroundTaskManager.startBackgroundRunning(this.context,
...@@ -365,6 +370,9 @@ export default class EntryAbility extends UIAbility { ...@@ -365,6 +370,9 @@ export default class EntryAbility extends UIAbility {
console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`); console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
} }
}); });
} catch (error) {
console.error(`Operation getWantAgent failed. code is ${error.code} message is ${error.message}`);
}
} }
}; };
``` ```
......
# @ohos.resourceschedule.workScheduler (workScheduler) # @ohos.resourceschedule.workScheduler (Work Scheduler)
The **workScheduler** module provides the APIs for registering, canceling, and querying Work Scheduler tasks, which do not have real-time constraints. The **workScheduler** module provides the APIs for registering, canceling, and querying Work Scheduler tasks, which do not have real-time constraints.
......
...@@ -40,15 +40,14 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -40,15 +40,14 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | If UI execution context not found. | | 100001 | if UI execution context not found. |
| 100002 | If the uri is not exist. | | 100002 | if the uri is not exist. |
| 100003 | If the pages are pushed too much. | | 100003 | if the pages are pushed too much. |
**Example** **Example**
```js ```js
try { router.pushUrl({
router.pushUrl({
url: 'pages/routerpage2', url: 'pages/routerpage2',
params: { params: {
data1: 'message', data1: 'message',
...@@ -56,16 +55,13 @@ try { ...@@ -56,16 +55,13 @@ try {
data3: [123, 456, 789] data3: [123, 456, 789]
} }
} }
}) })
.then(() => { .then(() => {
// success // success
}) })
.catch(err => { .catch(err => {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
}) })
} catch (error) {
console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`);
};
``` ```
## router.pushUrl<sup>9+</sup> ## router.pushUrl<sup>9+</sup>
...@@ -89,15 +85,14 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -89,15 +85,14 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | If UI execution context not found. | | 100001 | if UI execution context not found. |
| 100002 | If the uri is not exist. | | 100002 | if the uri is not exist. |
| 100003 | If the pages are pushed too much. | | 100003 | if the pages are pushed too much. |
**Example** **Example**
```js ```js
try { router.pushUrl({
router.pushUrl({
url: 'pages/routerpage2', url: 'pages/routerpage2',
params: { params: {
data1: 'message', data1: 'message',
...@@ -105,16 +100,13 @@ try { ...@@ -105,16 +100,13 @@ try {
data3: [123, 456, 789] data3: [123, 456, 789]
} }
} }
}, (err) => { })
if (err) { .then(() => {
// success
})
.catch(err => {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
return; })
}
console.info('pushUrl success');
});
} catch (error) {
console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`);
};
``` ```
## router.pushUrl<sup>9+</sup> ## router.pushUrl<sup>9+</sup>
...@@ -143,15 +135,14 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -143,15 +135,14 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | If UI execution context not found. | | 100001 | if UI execution context not found. |
| 100002 | If the uri is not exist. | | 100002 | if the uri is not exist. |
| 100003 | If the pages are pushed too much. | | 100003 | if the pages are pushed too much. |
**Example** **Example**
```js ```js
try { router.pushUrl({
router.pushUrl({
url: 'pages/routerpage2', url: 'pages/routerpage2',
params: { params: {
data1: 'message', data1: 'message',
...@@ -159,16 +150,13 @@ try { ...@@ -159,16 +150,13 @@ try {
data3: [123, 456, 789] data3: [123, 456, 789]
} }
} }
}, router.RouterMode.Standard) }, router.RouterMode.Standard)
.then(() => { .then(() => {
// success // success
}) })
.catch(err => { .catch(err => {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
}) })
} catch (error) {
console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`);
};
``` ```
## router.pushUrl<sup>9+</sup> ## router.pushUrl<sup>9+</sup>
...@@ -193,15 +181,14 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -193,15 +181,14 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | If UI execution context not found. | | 100001 | if UI execution context not found. |
| 100002 | If the uri is not exist. | | 100002 | if the uri is not exist. |
| 100003 | If the pages are pushed too much. | | 100003 | if the pages are pushed too much. |
**Example** **Example**
```js ```js
try { router.pushUrl({
router.pushUrl({
url: 'pages/routerpage2', url: 'pages/routerpage2',
params: { params: {
data1: 'message', data1: 'message',
...@@ -209,16 +196,13 @@ try { ...@@ -209,16 +196,13 @@ try {
data3: [123, 456, 789] data3: [123, 456, 789]
} }
} }
}, router.RouterMode.Standard, (err) => { }, router.RouterMode.Standard, (err) => {
if (err) { if (err) {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
return; return;
} }
console.info('pushUrl success'); console.info('pushUrl success');
}); })
} catch (error) {
console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`);
};
``` ```
## router.replaceUrl<sup>9+</sup> ## router.replaceUrl<sup>9+</sup>
...@@ -247,28 +231,24 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -247,28 +231,24 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | If UI execution context not found, only throw in standard system. | | 100001 | if UI execution context not found, only throw in standard system. |
| 200002 | If the uri is not exist. | | 200002 | if the uri is not exist. |
**Example** **Example**
```js ```js
try { router.replaceUrl({
router.replaceUrl({
url: 'pages/detail', url: 'pages/detail',
params: { params: {
data1: 'message' data1: 'message'
} }
}) })
.then(() => { .then(() => {
// success // success
}) })
.catch(err => { .catch(err => {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
}) })
} catch (error) {
console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`);
};
``` ```
## router.replaceUrl<sup>9+</sup> ## router.replaceUrl<sup>9+</sup>
...@@ -292,28 +272,24 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -292,28 +272,24 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | If UI execution context not found, only throw in standard system. | | 100001 | if UI execution context not found, only throw in standard system. |
| 200002 | If the uri is not exist. | | 200002 | if the uri is not exist. |
**Example** **Example**
```js ```js
try { router.replaceUrl({
router.replaceUrl({
url: 'pages/detail', url: 'pages/detail',
params: { params: {
data1: 'message' data1: 'message'
} }
}, (err) => { }, (err) => {
if (err) { if (err) {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
return; return;
} }
console.info('replaceUrl success'); console.info('replaceUrl success');
}); })
} catch (error) {
console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`);
};
``` ```
## router.replaceUrl<sup>9+</sup> ## router.replaceUrl<sup>9+</sup>
...@@ -344,28 +320,24 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -344,28 +320,24 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | If UI execution context not found, only throw in standard system. | | 100001 | if UI execution context not found, only throw in standard system. |
| 200002 | If the uri is not exist. | | 200002 | if the uri is not exist. |
**Example** **Example**
```js ```js
try { router.replaceUrl({
router.replaceUrl({
url: 'pages/detail', url: 'pages/detail',
params: { params: {
data1: 'message' data1: 'message'
} }
}, router.RouterMode.Standard) }, router.RouterMode.Standard)
.then(() => { .then(() => {
// success // success
}) })
.catch(err => { .catch(err => {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
}) })
} catch (error) {
console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`);
};
``` ```
## router.replaceUrl<sup>9+</sup> ## router.replaceUrl<sup>9+</sup>
...@@ -390,28 +362,25 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -390,28 +362,25 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | If UI execution context not found, only throw in standard system. | | 100001 | if UI execution context not found, only throw in standard system. |
| 200002 | If the uri is not exist. | | 200002 | if the uri is not exist. |
**Example** **Example**
```js ```js
try { router.replaceUrl({
router.replaceUrl({
url: 'pages/detail', url: 'pages/detail',
params: { params: {
data1: 'message' data1: 'message'
} }
}, router.RouterMode.Standard, (err) => { }, router.RouterMode.Standard, (err) => {
if (err) { if (err) {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
return; return;
} }
console.info('replaceUrl success'); console.info('replaceUrl success');
}); });
} catch (error) {
console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`);
};
``` ```
## router.back ## router.back
...@@ -524,7 +493,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -524,7 +493,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | If UI execution context not found. | | 100001 | if UI execution context not found. |
**Example** **Example**
...@@ -572,8 +541,8 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -572,8 +541,8 @@ Obtains the parameters passed from the page that initiates redirection to the cu
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ----------------- | | ------ | ---------------------------------- |
| Object | Parameters passed from the page that initiates redirection to the current page.| | object | Parameters passed from the page that initiates redirection to the current page.|
**Example** **Example**
...@@ -636,7 +605,7 @@ export default { ...@@ -636,7 +605,7 @@ export default {
### TypeScript-based Declarative Development Paradigm ### TypeScript-based Declarative Development Paradigm
```ts ```ts
// Navigate to the target page through router.push with the params parameter carried. // Navigate to the target page through router.pushUrl with the params parameter carried.
import router from '@ohos.router' import router from '@ohos.router'
@Entry @Entry
...@@ -745,37 +714,6 @@ router.push({ ...@@ -745,37 +714,6 @@ router.push({
} }
}); });
``` ```
## router.push<sup>(deprecated)</sup>
push(options: RouterOptions, mode: RouterMode): void
Navigates to a specified page in the application.
This API is deprecated since API version 9. You are advised to use [pushUrl<sup>9+</sup>](#routerpushurl9) instead.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------- |
| options | [RouterOptions](#routeroptions) | Yes | Page routing parameters. |
| mode | [RouterMode](#routermode9) | Yes | Routing mode.|
**Example**
```js
router.push({
url: 'pages/routerpage2/routerpage2',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
}
},router.RouterMode.Standard);
```
## router.replace<sup>(deprecated)</sup> ## router.replace<sup>(deprecated)</sup>
...@@ -785,7 +723,7 @@ Replaces the current page with another one in the application and destroys the c ...@@ -785,7 +723,7 @@ Replaces the current page with another one in the application and destroys the c
This API is deprecated since API version 9. You are advised to use [replaceUrl<sup>9+</sup>](#routerreplaceurl9) instead. This API is deprecated since API version 9. You are advised to use [replaceUrl<sup>9+</sup>](#routerreplaceurl9) instead.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Lite
**Parameters** **Parameters**
...@@ -804,34 +742,6 @@ router.replace({ ...@@ -804,34 +742,6 @@ router.replace({
}); });
``` ```
## router.replace<sup>(deprecated)</sup>
replace(options: RouterOptions, mode: RouterMode): void
Replaces the current page with another one in the application and destroys the current page.
This API is deprecated since API version 9. You are advised to use [replaceUrl<sup>9+</sup>](#routerreplaceurl9) instead.
**System capability**: SystemCapability.ArkUI.ArkUI.Lite
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------- |
| options | [RouterOptions](#routeroptions) | Yes | Description of the new page. |
| mode | [RouterMode](#routermode9) | Yes | Routing mode.|
**Example**
```js
router.replace({
url: 'pages/detail/detail',
params: {
data1: 'message'
}
}, router.RouterMode.Standard);
```
## router.enableAlertBeforeBackPage<sup>(deprecated)</sup> ## router.enableAlertBeforeBackPage<sup>(deprecated)</sup>
enableAlertBeforeBackPage(options: EnableAlertOptions): void enableAlertBeforeBackPage(options: EnableAlertOptions): void
......
...@@ -226,7 +226,7 @@ screenlock.lock().then((data) => { ...@@ -226,7 +226,7 @@ screenlock.lock().then((data) => {
onSystemEvent(callback: Callback&lt;SystemEvent&gt;): boolean onSystemEvent(callback: Callback&lt;SystemEvent&gt;): boolean
Registers a callback for system events related to screen locking. Registers a callback for system events related to screen locking. This API can be called only by system screen lock applications.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
......
# @ohos.screenshot # @ohos.screenshot (Screenshot)
The **Screenshot** module provides APIs for you to set information such as the region to capture and the size of the screen region when capturing a screen. The **Screenshot** module provides APIs for you to set information such as the region to capture and the size of the screen region when capturing a screen.
......
...@@ -5,6 +5,8 @@ The **stationary** module provides APIs to report the device status, including a ...@@ -5,6 +5,8 @@ The **stationary** module provides APIs to report the device status, including a
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The 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 does not support x86 emulators.
## Modules to Import ## Modules to Import
......
# Bluetooth # @system.bluetooth (Bluetooth)
> **NOTE**<br/> > **NOTE**<br/>
......
# Application Configuration # @system.configuration (Application Configuration)
> **NOTE**<br> > **NOTE**<br>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.i18n`](js-apis-i18n.md) and [`@ohos.intl`](js-apis-intl.md) instead. > - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.i18n`](js-apis-i18n.md) and [`@ohos.intl`](js-apis-intl.md) instead.
......
# Data Request # @system.fetch (Data Request)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**
>
> - The APIs of this module are no longer maintained since API version 6. You are advised to use [`@ohos.net.http`](js-apis-http.md) instead. > - The APIs of this module are no longer maintained since API version 6. You are advised to use [`@ohos.net.http`](js-apis-http.md) instead.
> >
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# File Storage # @system.file (File Storage)
> **NOTE**<br> > **NOTE**<br>
> - The APIs of this module are no longer maintained since API version 6. You are advised to use [`@ohos.fileio`](js-apis-fileio.md). > - The APIs of this module are no longer maintained since API version 6. You are advised to use [`@ohos.fileio`](js-apis-fileio.md).
......
# Geographic Location # @system.geolocation (Geographic Location)
> **NOTE** > **NOTE**
> >
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
The **system.request** module provides applications with basic upload and download capabilities. The **system.request** module provides applications with basic upload and download capabilities.
> **NOTE** > **NOTE**
> - The APIs of this module are deprecated since API version 9. You are advised to use [@ohos.request](js-apis-request.md) instead.
> >
> - The APIs of this module are deprecated since API version 9. You are advised to use [`@ohos.request`](js-apis-request.md) instead.
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -25,9 +25,9 @@ Uploads a file. This API returns no value. ...@@ -25,9 +25,9 @@ Uploads a file. This API returns no value.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [UploadRequestOptions](#uploadrequestoptions) | Yes| Upload configurations.| | options | [UploadRequestOptions](#uploadrequestoptions) | Yes| Upload configurations.|
**Example** **Example**
...@@ -61,27 +61,27 @@ Uploads a file. This API returns no value. ...@@ -61,27 +61,27 @@ Uploads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| url | string | Yes| URL of the upload server.| | url | string | Yes| URL of the upload server.|
| data | Array&lt;[RequestData](#requestdata)&gt; | No| Form data in the request body.| | data | Array&lt;[RequestData](#requestdata)&gt; | No| Form data in the request body.|
| files | Array&lt;[RequestFile](#requestfile)&gt; | Yes| List of files to upload, which is submitted through **multipart/form-data**.| | files | Array&lt;[RequestFile](#requestfile)&gt; | Yes| List of files to upload, which is submitted through **multipart/form-data**.|
| header | Object | No| Request header.| | header | Object | No| Request header.|
| method | string | No| Request method, which can be **'POST'** or **'PUT'**. The default value is **POST**.| | method | string | No| Request method, which can be **'POST'** or **'PUT'**. The default value is **POST**.|
| success | Function | No| Called when API call is successful.| | success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.| | fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.| | complete | Function | No| Called when API call is complete.|
**success parameter** **success parameter**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | [UploadResponse](#uploadresponse) | Yes| Information returned when the upload task is successful.| | data | [UploadResponse](#uploadresponse) | Yes| Information returned when the upload task is successful.|
**fail parameters** **fail parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the upload task fails.| | data | any | Yes| Header information returned when the upload task fails.|
| code | number | Yes| HTTP status code returned when the upload task fails.| | code | number | Yes| HTTP status code returned when the upload task fails.|
...@@ -89,33 +89,33 @@ Uploads a file. This API returns no value. ...@@ -89,33 +89,33 @@ Uploads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| code | number | HTTP status code returned by the server.| | code | number | Yes| HTTP status code returned by the server.|
| data | string | Content returned by the server. The value type is determined by the type in the returned headers.| | data | string | Yes| Content returned by the server. The value type is determined by the type in the returned headers.|
| headers | Object | Headers returned by the server.| | headers | Object | Yes| Headers returned by the server.|
## RequestFile ## RequestFile
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| filename | string | No| File name in the header when **multipart** is used.| | filename | string | No| File name in the header when **multipart** is used.|
| name | string | No| Name of a form item when **multipart** is used. The default value is **file**.| | name | string | No| Name of a form item when **multipart** is used. The default value is **file**.|
| uri | string | Yes| Local path for storing files.| | uri | string | Yes| Local path for storing files.|
| type | string | No| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.| | type | string | No| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.|
## RequestData ## RequestData
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the form element.| | name | string | Yes| Name of the form element.|
| value | string | Yes| Value of the form element.| | value | string | Yes| Value of the form element.|
...@@ -129,9 +129,9 @@ Downloads a file. This API returns no value. ...@@ -129,9 +129,9 @@ Downloads a file. This API returns no value.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [DownloadRequestOptions](#downloadrequestoptions) | Yes| Download configurations.| | options | [DownloadRequestOptions](#downloadrequestoptions) | Yes| Download configurations.|
**Example** **Example**
...@@ -164,34 +164,34 @@ Downloads a file. This API returns no value. ...@@ -164,34 +164,34 @@ Downloads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| url | string | Yes| Resource URL.| | url | string | Yes| Resource URL.|
| filename | string | No| Name of the file to download. The value is obtained from the current request or resource URL by default.| | filename | string | No| Name of the file to download. The value is obtained from the current request or resource URL by default.|
| header | Object | No| Request header.| | header | Object | No| Request header.|
| description | string | No| Download description. The default value is the file name.| | description | string | No| Download description. The default value is the file name.|
| success | Function | No| Called when API call is successful.| | success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.| | fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.| | complete | Function | No| Called when API call is complete.|
**success parameter** **success parameter**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | [DownloadResponse](#downloadresponse) | Yes| Information returned when the download task is successful.| | data | [DownloadResponse](#downloadresponse) | Yes| Information returned when the download task is successful.|
**fail parameters** **fail parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.| | data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.| | code | number | Yes| HTTP status code returned when the download task fails.|
## DownloadResponse ## DownloadResponse
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
| Name| Type| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| token | string | Download token, which is used to obtain the download status| | token | string | Yes| Download token, which is used to obtain the download status|
## request.onDownloadComplete ## request.onDownloadComplete
...@@ -204,9 +204,9 @@ Listens for download task status. This API returns no value. ...@@ -204,9 +204,9 @@ Listens for download task status. This API returns no value.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [OnDownloadCompleteOptions](#ondownloadcompleteoptions) | Yes| Configurations of the download task.| | options | [OnDownloadCompleteOptions](#ondownloadcompleteoptions) | Yes| Configurations of the download task.|
**Example** **Example**
...@@ -231,29 +231,29 @@ Listens for download task status. This API returns no value. ...@@ -231,29 +231,29 @@ Listens for download task status. This API returns no value.
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| token | string | Yes| Result token returned by the download API.| | token | string | Yes| Result token returned by the download API.|
| success | Function | No| Called when API call is successful.| | success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.| | fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.| | complete | Function | No| Called when API call is complete.|
**success parameter** **success parameter**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | [OnDownloadCompleteResponse](#ondownloadcompleteresponse) | Yes| Information returned when the download task is successful.| | data | [OnDownloadCompleteResponse](#ondownloadcompleteresponse) | Yes| Information returned when the download task is successful.|
**fail parameters** **fail parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.| | data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.| | code | number | Yes| HTTP status code returned when the download task fails.|
## OnDownloadCompleteResponse ## OnDownloadCompleteResponse
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
| Name| Type| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uri | string | URI of the download file.| | uri | string | Yes| URI of the download file.|
...@@ -127,7 +127,7 @@ Returns to the previous page or a specified page. ...@@ -127,7 +127,7 @@ Returns to the previous page or a specified page.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | --------------------------------------- | ---- | ----------------------- | | ------- | --------------------------------------- | ---- | ----------------------- |
| options | [BackRouterOptions](#backrouteroptions) | Yes | For details, see **BackRouterOptions**.| | options | [BackRouterOptions](#backrouteroptions) | No | For details, see **BackRouterOptions**.|
**Example** **Example**
...@@ -188,7 +188,7 @@ export default { ...@@ -188,7 +188,7 @@ export default {
> >
> In the example, the **uri** field indicates the page route, which is specified by the **pages** list in the **config.json** file. > In the example, the **uri** field indicates the page route, which is specified by the **pages** list in the **config.json** file.
## router.getParams ## router.getParams<sup>7+</sup>
getParams(): ParamsInterface getParams(): ParamsInterface
...@@ -397,6 +397,6 @@ Defines the **DisableAlertBeforeBackPage** parameters. ...@@ -397,6 +397,6 @@ Defines the **DisableAlertBeforeBackPage** parameters.
## ParamsInterface ## ParamsInterface
| Name | Type | Description | | Name | Type| Description |
| ------------- | ------ | ------- | | ------------- | -------- | -------------- |
| [key: string] | Object | List of routing parameters.| | [key: string] | object | List of routing parameters.|
# Data Storage # @system.storage (Data Storage)
> **NOTE**<br/> > **NOTE**
> >
> - The APIs of this module are no longer maintained since API Version 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From API Version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md). > - The APIs of this module are no longer maintained since API version 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From API version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md).
> >
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module can be used only in the FA model. > - The APIs of this module can be used only in the FA model.
## Modules to Import ## Modules to Import
```js ```js
import storage from '@system.storage'; import storage from '@system.storage';
``` ```
## storage.get ## storage.get
get(Object): void get(options: GetStorageOptions): void
Reads the value stored in the cache based on the specified key. Reads the value stored in the cache based on the specified key.
...@@ -25,13 +24,9 @@ Reads the value stored in the cache based on the specified key. ...@@ -25,13 +24,9 @@ Reads the value stored in the cache based on the specified key.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------- | -------------------- | ---- | ---------- |
| key | string | Yes| Key of the data to read.| | options | [GetStorageOptions](#getstorageoptions) | Yes | API configuration.|
| default | string | No| Default value returned when the **key** does not exist.|
| success | Function | No| Called to return the value obtained when **storage.get()** is successful.|
| fail | Function | No| Called when **storage.get()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.get()** is complete.|
**Example** **Example**
...@@ -54,10 +49,9 @@ export default { ...@@ -54,10 +49,9 @@ export default {
} }
``` ```
## storage.set ## storage.set
set(Object): void get(options: SetStorageOptions): void
Sets the value in the cache based on the specified key. Sets the value in the cache based on the specified key.
...@@ -65,13 +59,9 @@ Sets the value in the cache based on the specified key. ...@@ -65,13 +59,9 @@ Sets the value in the cache based on the specified key.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------- | ------------------- | ---- | ---------- |
| key | string | Yes| Key of the data to set.| | options | [SetStorageOptions](#setstorageoptions) | Yes | API configuration.|
| value | string | Yes| New value to set. The length must be less than 128 bytes.|
| success | Function | No| Called when **storage.set()** is successful.|
| fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.set()** is complete.|
**Example** **Example**
...@@ -92,10 +82,9 @@ export default { ...@@ -92,10 +82,9 @@ export default {
} }
``` ```
## storage.clear ## storage.clear
clear(Object): void clear(options?: ClearStorageOptions): void
Clears the key-value pairs from the cache. Clears the key-value pairs from the cache.
...@@ -103,11 +92,9 @@ Clears the key-value pairs from the cache. ...@@ -103,11 +92,9 @@ Clears the key-value pairs from the cache.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------- | ------------------------------------------- | ---- | -------------- |
| success | Function | No| Called when **storage.clear()** is successful.| | options | [ClearStorageOptions](#clearstorageoptions) | No | API configuration.|
| fail | Function | No| Called when **storage.clear()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.clear()** is complete.|
**Example** **Example**
...@@ -126,10 +113,9 @@ export default { ...@@ -126,10 +113,9 @@ export default {
} }
``` ```
## storage.delete ## storage.delete
delete(Object): void delete(options: DeleteStorageOptions): void
Deletes the key-value pair based on the specified key. Deletes the key-value pair based on the specified key.
...@@ -137,12 +123,9 @@ Deletes the key-value pair based on the specified key. ...@@ -137,12 +123,9 @@ Deletes the key-value pair based on the specified key.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------- | --------------------------------------------- | ---- | -------------- |
| key | string | Yes| Key of the data to delete.| | options | [DeleteStorageOptions](#deletestorageoptions) | Yes | API configuration.|
| success | Function | No| Called when **storage.delete()** is successful.|
| fail | Function | No| Called when **storage.delete()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.delete()** is complete.|
**Example** **Example**
...@@ -161,3 +144,52 @@ export default { ...@@ -161,3 +144,52 @@ export default {
} }
} }
``` ```
## GetStorageOptions
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Type | Mandatory| Description |
| -------- | ---------------- | ---- | ------------------- |
| key | string | Yes | Key of the target data. |
| default | string | No | Default value returned when the specified key does not exist. |
| success | (data: any) => void | No | Called to return the result when **storage.get()** is called successfully. **data** is the value indexed by the specified key. |
| fail | (data: string, code: number) => void | No | Called to return the result when **storage.get()** fails to be called. **data** is the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when **storage.get()** is complete. |
## SetStorageOptions
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | -------------------- |
| key | string | Yes | Key of the data to set. |
| value | string | Yes | New value to set. The length must be less than 128 bytes. |
| success | () => void | No | Called when **storage.set()** is called successfully. |
| fail | (data: string, code: number) => void | No | Called to return the result when **storage.get()** fails to be called. **data** is the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when **storage.get()** is complete. |
## ClearStorageOptions
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- |
| success | () => void | No | Called when **storage.clear()** is called successfully. |
| fail | (data: string, code: number) => void | No | Called to return the result when **storage.clear()** fails to be called. **data** is the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when **storage.clear()** is complete. |
## DeleteStorageOptions
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------ |
| key | string | Yes | Key of the data to delete. |
| success | () => void | No | Called when **storage.delete()** is called successfully. |
| fail | (data: string, code: number) => void | No | Called to return the result when **storage.delete()** fails to be called. **data** is the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when **storage.delete()** is complete. |
# @ohos.taskpool (Using the Task Pool)
The task pool provides a multi-thread running environment for applications. It helps reduce resource consumption and improve system performance. It also frees you from caring about the lifecycle of thread instances. You can use the **TaskPool** APIs to create background tasks and perform operations on them, for example, executing or canceling a task. Theoretically, you can create an unlimited number of tasks, but this is not recommended for memory considerations. In addition, you are not advised performing blocking operations in a task, especially indefinite blocking. Long-time blocking operations occupy worker threads and may block other task scheduling, adversely affecting your application performance.
You can determine the execution sequence of tasks with the same priority. They are executed in the same sequence as you call the task execution APIs. The default task priority is **MEDIUM**. (The task priority mechanism is not supported yet.)
If the number of tasks to be executed is greater than the number of worker threads in the task pool, the task pool scales out based on load balancing to minimize the waiting duration. Similarly, when the number of tasks to be executed falls below the number of worker threads, the task pool scales in to reduce the number of worker threads. (The load balancing mechanism is not supported yet.)
The **TaskPool** APIs return error codes in numeric format. For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> **NOTE**<br>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import taskpool from '@ohos.taskpool';
```
## Priority
Enumerates the priorities available for created tasks. (This enum is not supported yet.)
**System capability**: SystemCapability.Utils.Lang
| Name| Value| Description|
| -------- | -------- | -------- |
| HIGH | 0 | The task has a high priority.|
| MEDIUM | 1 | The task has a medium priority.|
| LOW | 2 | The task has a low priority.|
## Task
Implements a task. Before using any of the following APIs, you must create a **Task** instance.
### constructor
constructor(func: Function, ...args: unknown[])
A constructor used to create a **Task** instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | --------- | ---- | -------------------------------------------------------------------- |
| func | Function | Yes | Function to be passed in for task execution. For details about the supported return value types of the function, see [Sequenceable Data Types](#sequenceable-data-types). |
| args | unknown[] | No | Arguments of the function. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message |
| -------- | --------------------------------------- |
| 10200014 | The function is not mark as concurrent. |
**Example**
```js
function func(args) {
"use concurrent"
console.log("func: " + args);
return args;
}
let task = new taskpool.Task(func, "this is my first Task");
```
### Attributes
**System capability**: SystemCapability.Utils.Lang
| Name | Type | Readable| Writable| Description |
| --------- | --------- | ---- | ---- | ------------------------------------------------------------------------- |
| function | Function | Yes | Yes | Function to be passed in during task creation. For details about the supported return value types of the function, see [Sequenceable Data Types](#sequenceable-data-types). |
| arguments | unknown[] | Yes | Yes | Arguments of the function. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
## taskpool.execute
execute(func: Function, ...args: unknown[]): Promise\<unknown>
Executes a task in the task pool. You must pass in a function and arguments to execute the task, and the task executed in this mode cannot be canceled.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | --------- | ---- | ---------------------------------------------------------------------- |
| func | Function | Yes | Function used to execute the task. For details about the supported return value types of the function, see [Sequenceable Data Types](#sequenceable-data-types). |
| args | unknown[] | No | Arguments of the function. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
**Return value**
| Type | Description |
| ----------------- | ------------------------------------ |
| Promise\<unknown> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message |
| -------- | ----------------------------------------- |
| 10200003 | Worker initialization failure. |
| 10200006 | Serializing an uncaught exception failed. |
| 10200014 | The function is not mark as concurrent. |
**Example**
```js
function func(args) {
"use concurrent"
console.log("func: " + args);
return args;
}
let value = taskpool.execute(func, 100);
```
## taskpool.execute
execute(task: Task, priority?: Priority): Promise\<unknown>
Executes a task in the task pool. You must pass in a created task, and the task executed in this mode can be canceled.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------ |
| task | [Task](#task) | Yes | Task to be executed. |
| priority | [Priority](#priority) | No | Priority of the task (not supported yet).|
**Return value**
| Type | Description |
| ---------------- | ------------------------------ |
| Promise\<unknown> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message |
| -------- | ----------------------------------------- |
| 10200003 | Worker initialization failure. |
| 10200006 | Serializing an uncaught exception failed. |
| 10200014 | The function is not mark as concurrent. |
**Example**
```js
function func(args) {
"use concurrent"
console.log("func: " + args);
return args;
}
let task = new taskpool.Task(func, "this is my first Task");
let value = taskpool.execute(task);
```
## taskpool.cancel
cancel(task: Task): void
Cancels a task in the task pool.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------------- | ---- | -------------------- |
| task | [Task](#task) | Yes | Task to cancel.|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message |
| -------- | ------------------------- |
| 10200015 | If the task is not exist. |
| 10200016 | If the task is running. |
**Example**
```js
function func(args) {
"use concurrent"
console.log("func: " + args);
return args;
}
let task = new taskpool.Task(func, "this is first Task");
let value = taskpool.execute(task);
taskpool.cancel(task);
```
## Additional Information
### Sequenceable Data Types
The following sequenceable data types are supported: All Primitive Type (excluding symbol), Date, String, RegExp, Array, Map, Set, Object, ArrayBuffer, and TypedArray.
### Precautions
A task in the task pool can reference only variables passed in by input parameters or imported variables. It does not support closure variables.
```js
// 1. Reference a variable passed in by the input parameter.
function func(args) {
"use concurrent"
console.log("func: " + args);
return args;
}
let task = new taskpool.Task(func, "create task, then execute");
let val1 = taskpool.execute(task);
let val2 = taskpool.execute(func, "execute task by func");
```
```js
// 2. Reference an imported variable.
// b.ts
export var c = 2000;
// a.ts
import { c } from './b'
function test(a) {
"use concurrent"
console.log(a);
console.log(c);
return a;
}
let task = new taskpool.Task(test, "create task, then execute");
let val1 = taskpool.execute(task);
let val2 = taskpool.execute(test, "execute task by func");
```
...@@ -35,7 +35,7 @@ Naming format: ...@@ -35,7 +35,7 @@ Naming format:
A standard URI consists of the following parts: A standard URI consists of the following parts:
[scheme:]scheme-specific-part[#fragment] [scheme:]scheme-specific-part[#fragment]
- Scheme: scheme component, which is mandatory. Example values: **http**, **https**, **ftp**, **datashare**, and **dataability**. - scheme: scheme component. Set this parameter as required. Example values: **http**, **https**, **ftp**, **datashare**, and **dataability**.
- scheme-specific-part: specific part of the URI decoding scheme. The value consists of [//][authority][path][?query]. Set this parameter as required. - scheme-specific-part: specific part of the URI decoding scheme. The value consists of [//][authority][path][?query]. Set this parameter as required.
- authority: decoding authority component of the URI. The value consists of [userinfo@]host[:port]. Set this parameter as required. - authority: decoding authority component of the URI. The value consists of [userinfo@]host[:port]. Set this parameter as required.
- userinfo: user information. Set this parameter as required. - userinfo: user information. Set this parameter as required.
...@@ -226,7 +226,9 @@ Checks whether this URI is an absolute URI (whether the scheme component is defi ...@@ -226,7 +226,9 @@ Checks whether this URI is an absolute URI (whether the scheme component is defi
```js ```js
const uriInstance = new uri.URI('https://username:password@www.qwer.com:8080?query=pppppp'); const uriInstance = new uri.URI('https://username:password@www.qwer.com:8080?query=pppppp');
uriInstance.checkIsAbsolute(); console.log(uriInstance.checkIsAbsolute()); // true
const uriInstance1 = new uri.URI('xxx.com/suppliers.htm');
console.log(uriInstance1.checkIsAbsolute()); // false
``` ```
...@@ -248,6 +250,7 @@ Normalizes the path of this URI. ...@@ -248,6 +250,7 @@ Normalizes the path of this URI.
```js ```js
const uriInstance = new uri.URI('https://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp'); const uriInstance = new uri.URI('https://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp');
console.log(uriInstance.path); // /path/path1/../path2/./path3
let uriInstance1 = uriInstance.normalize(); let uriInstance1 = uriInstance.normalize();
uriInstance1.path; console.log(uriInstance1.path); // /path/path2/path3
``` ```
...@@ -87,7 +87,7 @@ paramsObject.delete('fod'); ...@@ -87,7 +87,7 @@ paramsObject.delete('fod');
getAll(name: string): string[] getAll(name: string): string[]
Obtains all the key-value pairs based on the specified name. Obtains all the values based on the specified key.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -95,13 +95,13 @@ Obtains all the key-value pairs based on the specified name. ...@@ -95,13 +95,13 @@ Obtains all the key-value pairs based on the specified name.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain all key-value pairs.| | name | string | Yes| Target key.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| string[] | Key-value pairs obtained.| | string[] | All the values obtained.|
**Example** **Example**
...@@ -514,7 +514,7 @@ A constructor used to create a **URLSearchParams** instance. ...@@ -514,7 +514,7 @@ A constructor used to create a **URLSearchParams** instance.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>](#constructor9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.constructor<sup>9+</sup>](#constructor9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -542,7 +542,7 @@ Appends a key-value pair into the query string. ...@@ -542,7 +542,7 @@ Appends a key-value pair into the query string.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.append<sup>9+</sup>](#append9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.append<sup>9+</sup>](#append9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -569,7 +569,7 @@ Deletes key-value pairs of the specified key. ...@@ -569,7 +569,7 @@ Deletes key-value pairs of the specified key.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.delete<sup>9+</sup>](#delete9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.delete<sup>9+</sup>](#delete9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -595,7 +595,7 @@ Obtains all the key-value pairs based on the specified key. ...@@ -595,7 +595,7 @@ Obtains all the key-value pairs based on the specified key.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.getAll<sup>9+</sup>](#getall9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.getAll<sup>9+</sup>](#getall9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -603,7 +603,7 @@ Obtains all the key-value pairs based on the specified key. ...@@ -603,7 +603,7 @@ Obtains all the key-value pairs based on the specified key.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain all key-value pairs.| | name | string | Yes| Target key.|
**Return value** **Return value**
...@@ -628,7 +628,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th ...@@ -628,7 +628,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.entries<sup>9+</sup>](#entries9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.entries<sup>9+</sup>](#entries9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -656,7 +656,7 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal ...@@ -656,7 +656,7 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.forEach<sup>9+</sup>](#foreach9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.forEach<sup>9+</sup>](#foreach9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -693,7 +693,7 @@ Obtains the value of the first key-value pair based on the specified key. ...@@ -693,7 +693,7 @@ Obtains the value of the first key-value pair based on the specified key.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.get<sup>9+</sup>](#get9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.get<sup>9+</sup>](#get9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -727,7 +727,7 @@ Checks whether a key has a value. ...@@ -727,7 +727,7 @@ Checks whether a key has a value.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.has<sup>9+</sup>](#has9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.has<sup>9+</sup>](#has9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -760,7 +760,7 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t ...@@ -760,7 +760,7 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.set<sup>9+</sup>](#set9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.set<sup>9+</sup>](#set9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -788,7 +788,7 @@ Sorts all key-value pairs contained in this object based on the Unicode code poi ...@@ -788,7 +788,7 @@ Sorts all key-value pairs contained in this object based on the Unicode code poi
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.sort<sup>9+</sup>](#sort9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.sort<sup>9+</sup>](#sort9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -809,7 +809,7 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs. ...@@ -809,7 +809,7 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.keys<sup>9+</sup>](#keys9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.keys<sup>9+</sup>](#keys9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -837,7 +837,7 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs. ...@@ -837,7 +837,7 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.values<sup>9+</sup>](#values9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.values<sup>9+</sup>](#values9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -865,7 +865,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th ...@@ -865,7 +865,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [Symbol.iterator]<sup>9+</sup>](#symboliterator9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.[Symbol.iterator]<sup>9+</sup>](#symboliterator9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -892,7 +892,7 @@ Obtains search parameters that are serialized as a string and, if necessary, per ...@@ -892,7 +892,7 @@ Obtains search parameters that are serialized as a string and, if necessary, per
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tostring<sup>9+</sup>](#tostring9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.tostring<sup>9+</sup>](#tostring9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
......
...@@ -43,7 +43,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`); ...@@ -43,7 +43,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`);
vendorId: 7531, vendorId: 7531,
productId: 2, productId: 2,
clazz: 9, clazz: 9,
subclass: 0, subClass: 0,
protocol: 1, protocol: 1,
devAddress: 1, devAddress: 1,
busNum: 1, busNum: 1,
...@@ -60,7 +60,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`); ...@@ -60,7 +60,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`);
id: 0, id: 0,
protocol: 0, protocol: 0,
clazz: 9, clazz: 9,
subclass: 0, subClass: 0,
alternateSetting: 0, alternateSetting: 0,
name: "1-1", name: "1-1",
endpoints: [ endpoints: [
...@@ -171,7 +171,7 @@ usb.requestRight(devicesName).then((ret) => { ...@@ -171,7 +171,7 @@ usb.requestRight(devicesName).then((ret) => {
## usb.claimInterface ## usb.claimInterface
claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number
Claims a USB interface. Claims a USB interface.
...@@ -348,7 +348,7 @@ let ret = usb.getFileDescriptor(devicepipe); ...@@ -348,7 +348,7 @@ let ret = usb.getFileDescriptor(devicepipe);
## usb.controlTransfer ## usb.controlTransfer
controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout?: number): Promise&lt;number&gt; controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise&lt;number&gt;
Performs control transfer. Performs control transfer.
...@@ -380,7 +380,7 @@ usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { ...@@ -380,7 +380,7 @@ usb.controlTransfer(devicepipe, USBControlParams).then((ret) => {
## usb.bulkTransfer ## usb.bulkTransfer
bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise&lt;number&gt; bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise&lt;number&gt;
Performs bulk transfer. Performs bulk transfer.
......
...@@ -42,7 +42,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`); ...@@ -42,7 +42,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`);
vendorId: 7531, vendorId: 7531,
productId: 2, productId: 2,
clazz: 9, clazz: 9,
subclass: 0, subClass: 0,
protocol: 1, protocol: 1,
devAddress: 1, devAddress: 1,
busNum: 1, busNum: 1,
...@@ -59,7 +59,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`); ...@@ -59,7 +59,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`);
id: 0, id: 0,
protocol: 0, protocol: 0,
clazz: 9, clazz: 9,
subclass: 0, subClass: 0,
alternateSetting: 0, alternateSetting: 0,
name: "1-1", name: "1-1",
endpoints: [ endpoints: [
...@@ -252,7 +252,7 @@ if (usb.addRight(bundleName, devicesName) { ...@@ -252,7 +252,7 @@ if (usb.addRight(bundleName, devicesName) {
## usb.claimInterface ## usb.claimInterface
claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number
Claims a USB interface. Claims a USB interface.
...@@ -429,7 +429,7 @@ let ret = usb.getFileDescriptor(devicepipe); ...@@ -429,7 +429,7 @@ let ret = usb.getFileDescriptor(devicepipe);
## usb.controlTransfer ## usb.controlTransfer
controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout?: number): Promise&lt;number&gt; controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise&lt;number&gt;
Performs control transfer. Performs control transfer.
...@@ -461,7 +461,7 @@ usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { ...@@ -461,7 +461,7 @@ usb.controlTransfer(devicepipe, USBControlParams).then((ret) => {
## usb.bulkTransfer ## usb.bulkTransfer
bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise&lt;number&gt; bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise&lt;number&gt;
Performs bulk transfer. Performs bulk transfer.
......
# @ohos.wantAgent # @ohos.wantAgent (wantAgent)
The **WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object. The **WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object.
......
# @ohos.web.webview (Webview) # @ohos.web.webview (Webview)
The **Webview** module provides APIs for web control. The **Webview** module provides APIs for web control.
...@@ -262,6 +264,45 @@ struct WebComponent { ...@@ -262,6 +264,45 @@ struct WebComponent {
} }
``` ```
### setWebDebuggingAccess
static setWebDebuggingAccess(webDebuggingAccess: boolean): void
Sets whether to enable web debugging.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name | Type | Mandatory | Description|
| ------------------ | ------- | ---- | ------------- |
| webDebuggingAccess | boolean | Yes | Whether to enable web debugging.|
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
aboutToAppear():void {
try {
web_webview.WebviewController.setWebDebuggingAccess(true);
} catch(error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
}
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### loadUrl ### loadUrl
loadUrl(url: string | Resource, headers?: Array\<HeaderV9>): void loadUrl(url: string | Resource, headers?: Array\<HeaderV9>): void
...@@ -1469,10 +1510,8 @@ struct WebComponent { ...@@ -1469,10 +1510,8 @@ struct WebComponent {
try { try {
// 1. Create two message ports. // 1. Create two message ports.
this.ports = this.controller.createWebMessagePorts(); this.ports = this.controller.createWebMessagePorts();
// 2. Send one of the message ports to the HTML side, which can then save and use the port. // 2. Register a callback on a message port (for example, port 1) on the application side.
this.controller.postMessage('__init_port__', [this.ports[0]], '*'); this.ports[1].onMessageEvent((result: web_webview.WebMessage) => {
// 3. Register a callback for the other message port on the application side.
this.ports[1].onMessageEvent((result: WebMessage) => {
var msg = 'Got msg from HTML:'; var msg = 'Got msg from HTML:';
if (typeof(result) == "string") { if (typeof(result) == "string") {
console.log("received string message from html5, string is:" + result); console.log("received string message from html5, string is:" + result);
...@@ -1489,12 +1528,14 @@ struct WebComponent { ...@@ -1489,12 +1528,14 @@ struct WebComponent {
} }
this.receivedFromHtml = msg; this.receivedFromHtml = msg;
}) })
// 3. Send another message port (for example, port 0) to the HTML side, which can then save the port for future use.
this.controller.postMessage('__init_port__', [this.ports[0]], '*');
} catch (error) { } catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
} }
}) })
// 4. Use the port on the application side to send messages to the message port that has been sent to the HTML. // 4. Use the port on the application side to send messages to the port that has been sent to the HTML side.
Button('SendDataToHTML') Button('SendDataToHTML')
.onClick(() => { .onClick(() => {
try { try {
...@@ -1526,7 +1567,7 @@ struct WebComponent { ...@@ -1526,7 +1567,7 @@ struct WebComponent {
<h1>WebView Message Port Demo</h1> <h1>WebView Message Port Demo</h1>
<div> <div>
<input type="button" value="SendToEts" onclick="PostMsgToEts(msgFromJS.value);"/><br/> <input type="button" value="SendToEts" onclick="PostMsgToEts(msgFromJS.value);"/><br/>
<input id="msgFromJs" type="text" value="send this message from HTML to ets"/><br/> <input id="msgFromJS" type="text" value="send this message from HTML to ets"/><br/>
</div> </div>
<p class="output">display received message send from ets</p> <p class="output">display received message send from ets</p>
</body> </body>
...@@ -2748,6 +2789,104 @@ struct WebComponent { ...@@ -2748,6 +2789,104 @@ struct WebComponent {
} }
``` ```
### pageUp
pageUp(top:boolean): void
Scrolls the page up by half the view port or jumps to the top of the page.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------------------------------------------------ |
| top | boolean | Yes | Whether to jump to the top of the page. The value **true** means to jump to the top of the page; and **false** means to scroll the page up by half the view port.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 17100001 | Init error. The WebviewController must be associated with a Web component. |
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('pageUp')
.onClick(() => {
try {
this.controller.pageUp(false);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### pageDown
pageDown(bottom:boolean): void
Scrolls the page down by half the view port or jumps to the bottom of the page.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------------------------------------------------ |
| bottom | boolean | Yes | Whether to jump to the bottom of the page. The value **true** means to jump to the bottom of the page; and **false** means to scroll the page down by half the view port.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 17100001 | Init error. The WebviewController must be associated with a Web component. |
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('pageDown')
.onClick(() => {
try {
this.controller.pageDown(false);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### getBackForwardEntries ### getBackForwardEntries
getBackForwardEntries(): BackForwardList getBackForwardEntries(): BackForwardList
...@@ -2797,6 +2936,122 @@ struct WebComponent { ...@@ -2797,6 +2936,122 @@ struct WebComponent {
} }
``` ```
### serializeWebState
serializeWebState(): Uint8Array
Serializes the page status history of the current Webview.
**System capability**: SystemCapability.Web.Webview.Core
**Return value**
| Type | Description |
| ---------- | --------------------------------------------- |
| Uint8Array | Serialized data of the page status history of the current WebView.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 17100001 | Init error. The WebviewController must be associated with a Web component. |
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
import fileio from '@ohos.fileio';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('serializeWebState')
.onClick(() => {
try {
let state = this.controller.serializeWebState();
let path = globalThis.AbilityContext.cacheDir;
path += '/WebState';
let fd = fileio.openSync(path, 0o2 | 0o100, 0o666);
fileio.writeSync(fd, state.buffer);
fileio.closeSync(fd);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### restoreWebState
restoreWebState(state: Uint8Array): void
Restores the page status history from the serialized data of the current WebView.
**System capability**: SystemCapability.Web.Webview.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ---------- | ---- | ---------------------------- |
| state | Uint8Array | Yes | Serialized data of the page status history.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 17100001 | Init error. The WebviewController must be associated with a Web component. |
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
import fileio from '@ohos.fileio';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('RestoreWebState')
.onClick(() => {
try {
let path = globalThis.AbilityContext.cacheDir;
path += '/WebState';
let fd = fileio.openSync(path, 0o002, 0o666);
let stat = fileio.fstatSync(fd);
let size = stat.size;
let buf = new ArrayBuffer(size);
fileio.read(fd, buf, (err, data) => {
if (data) {
this.controller.restoreWebState(new Uint8Array(data.buffer));
}
fileio.closeSync(fd);
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### customizeSchemes ### customizeSchemes
static customizeSchemes(schemes: Array\<WebCustomScheme\>): void static customizeSchemes(schemes: Array\<WebCustomScheme\>): void
...@@ -4080,6 +4335,10 @@ Stores this web page. This API uses a promise to return the result. ...@@ -4080,6 +4335,10 @@ Stores this web page. This API uses a promise to return the result.
Implements a **GeolocationPermissions** object. Implements a **GeolocationPermissions** object.
### Required Permissions
**ohos.permission.LOCATION**, **ohos.permission.APPROXIMATELY_LOCATION**, and **ohos.permission.LOCATION_IN_BACKGROUND**, which are required for accessing the location information. For details about the permissions, see [@ohos.geolocation (Geolocation)](./js-apis-geolocation.md).
### allowGeolocation ### allowGeolocation
static allowGeolocation(origin: string): void static allowGeolocation(origin: string): void
...@@ -4467,6 +4726,8 @@ Provides the element information of the area being clicked. For details about th ...@@ -4467,6 +4726,8 @@ Provides the element information of the area being clicked. For details about th
Describes the data types supported for [WebMessagePort](#webmessageport). Describes the data types supported for [WebMessagePort](#webmessageport).
**System capability**: SystemCapability.Web.Webview.Core
| Type | Description | | Type | Description |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| string | String type.| | string | String type.|
...@@ -4491,9 +4752,9 @@ Provides the historical information list of the current webview. ...@@ -4491,9 +4752,9 @@ Provides the historical information list of the current webview.
**System capability**: SystemCapability.Web.Webview.Core **System capability**: SystemCapability.Web.Webview.Core
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------------ | ------ | ---- | ---- | ---------------------------- | | ------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
| currentIndex | number | Yes | No | Index of the current page in the page history stack.| | currentIndex | number | Yes | No | Index of the current page in the page history stack. |
| size | number | Yes | No | Number of indexes in the history stack. | | size | number | Yes | No | Number of indexes in the history stack. The maximum value is 50. If this value is exceeded, the earliest index will be overwritten.|
### getItemAtIndex ### getItemAtIndex
......
# @ohos.window # @ohos.window (Window)
The **Window** module provides basic window management capabilities, such as creating and destroying the current window, setting properties for the current window, and managing and scheduling windows. The **Window** module provides basic window management capabilities, such as creating and destroying the current window, setting properties for the current window, and managing and scheduling windows.
...@@ -54,7 +54,7 @@ Defines the parameters for creating a subwindow or system window. ...@@ -54,7 +54,7 @@ Defines the parameters for creating a subwindow or system window.
| ---------- | -------------------------- | -- | ----------------------------------- | | ---------- | -------------------------- | -- | ----------------------------------- |
| name | string | Yes| Name of the window. | | name | string | Yes| Name of the window. |
| windowType | [WindowType](#windowtype7) | Yes| Type of the window. | | windowType | [WindowType](#windowtype7) | Yes| Type of the window. |
| ctx | BaseContext | No| Current application context.<br>For details about the context in the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the context in the stage model, see [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md). If this parameter is not set, no context is used.<br>A system window is created when **Context** is [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md).| | ctx | [BaseContext](js-apis-inner-application-baseContext.md) | No| Current application context. If this parameter is not set, no context is used.<br>You do not need to set this parameter to create a subwindow in the FA model or a system window in the stage model. |
| displayId | number | No| ID of the current physical screen. If this parameter is not set, the default value **-1** is used.| | displayId | number | No| ID of the current physical screen. If this parameter is not set, the default value **-1** is used.|
| parentId | number | No| ID of the parent window. If this parameter is not set, the default value **-1** is used. | | parentId | number | No| ID of the parent window. If this parameter is not set, the default value **-1** is used. |
...@@ -430,7 +430,7 @@ Obtains the top window of the current application. This API uses an asynchronous ...@@ -430,7 +430,7 @@ Obtains the top window of the current application. This API uses an asynchronous
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------------------------------------- | -- | ---------------------------------------- | | -------- | -------------------------------------- | -- | ---------------------------------------- |
| ctx | BaseContext | Yes| Current application context.<br>For details about the context in the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the context in the stage model, see [Context](js-apis-ability-context.md).| | ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Current application context.|
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes| Callback used to return the top window obtained.| | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes| Callback used to return the top window obtained.|
**Error codes** **Error codes**
...@@ -472,7 +472,7 @@ Obtains the top window of the current application. This API uses a promise to re ...@@ -472,7 +472,7 @@ Obtains the top window of the current application. This API uses a promise to re
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------ | ----------- | ---- | ------------------------------------------------------------ | | ------ | ----------- | ---- | ------------------------------------------------------------ |
| ctx | BaseContext | Yes | Current application context.<br>For details about the context in the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the context in the stage model, see [Context](js-apis-ability-context.md).| | ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes | Current application context.|
**Return value** **Return value**
...@@ -897,7 +897,7 @@ promise.then((data)=> { ...@@ -897,7 +897,7 @@ promise.then((data)=> {
create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
Creates a subwindow (in API version 8) or a system window (from API version 9). This API uses an asynchronous callback to return the result. Creates a system window. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
...@@ -908,11 +908,11 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). ...@@ -908,11 +908,11 @@ Creates a subwindow (in API version 8) or a system window (from API version 9).
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------- | ---- | ------------------------------------ |
| ctx | BaseContext | Yes | Current application context.<br>For details about the context in the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the context in the stage model, see [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md).| | ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes | Current application context. |
| id | string | Yes | Window ID. | | id | string | Yes | Window ID. |
| type | [WindowType](#windowtype7) | Yes | Window type. | | type | [WindowType](#windowtype7) | Yes | Window type. |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the subwindow created. | | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the subwindow created.|
**Example** **Example**
...@@ -933,7 +933,7 @@ window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, ...@@ -933,7 +933,7 @@ window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT,
create(ctx: BaseContext, id: string, type: WindowType): Promise&lt;Window&gt; create(ctx: BaseContext, id: string, type: WindowType): Promise&lt;Window&gt;
Creates a subwindow (in API version 8) or a system window (from API version 9). This API uses a promise to return the result. Creates a system window. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
...@@ -945,7 +945,7 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). ...@@ -945,7 +945,7 @@ Creates a subwindow (in API version 8) or a system window (from API version 9).
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------- | ---- | ------------------------------------------------------------ | | ------ | ------------------------- | ---- | ------------------------------------------------------------ |
| ctx | BaseContext | Yes | Current application context.<br>For details about the context in the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the context in the stage model, see [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md).| | ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes | Current application context.|
| id | string | Yes | Window ID. | | id | string | Yes | Window ID. |
| type | [WindowType](#windowtype7) | Yes | Window type. | | type | [WindowType](#windowtype7) | Yes | Window type. |
...@@ -1121,7 +1121,7 @@ Obtains the top window of the current application. This API uses an asynchronous ...@@ -1121,7 +1121,7 @@ Obtains the top window of the current application. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| ctx | BaseContext | Yes | Current application context.<br>For details about the context in the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the context in the stage model, see [Context](js-apis-ability-context.md).| | ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes | Current application context.|
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the top window obtained. | | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the top window obtained. |
**Example** **Example**
...@@ -1154,7 +1154,7 @@ Obtains the top window of the current application. This API uses a promise to re ...@@ -1154,7 +1154,7 @@ Obtains the top window of the current application. This API uses a promise to re
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ----------- | ---- | ------------------------------------------------------------ | | ------ | ----------- | ---- | ------------------------------------------------------------ |
| ctx | BaseContext | Yes | Current application context.<br>For details about the context in the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the context in the stage model, see [Context](js-apis-ability-context.md).| | ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes | Current application context.|
**Return value** **Return value**
...@@ -1864,7 +1864,7 @@ Obtains the area where this window cannot be displayed, for example, the system ...@@ -1864,7 +1864,7 @@ Obtains the area where this window cannot be displayed, for example, the system
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ---- |----------------------------------| -- | ------------------------------------------------------------ | | ---- |----------------------------------| -- | ------------------------------------------------------------ |
| type | [AvoidAreaType](#avoidareatype7) | Yes| Type of the area. | | type | [AvoidAreaType](#avoidareatype7) | Yes| Type of the area.|
**Return value** **Return value**
...@@ -4630,7 +4630,7 @@ Obtains the area where this window cannot be displayed, for example, the system ...@@ -4630,7 +4630,7 @@ Obtains the area where this window cannot be displayed, for example, the system
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------------------------- | --------- | ------------------------------------------------------------ | | -------- | --------------------------------------------- | --------- | --------------------------------- |
| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. | | type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. |
| callback | AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt; | Yes | Callback used to return the area. | | callback | AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt; | Yes | Callback used to return the area. |
...@@ -4663,7 +4663,7 @@ Obtains the area where this window cannot be displayed, for example, the system ...@@ -4663,7 +4663,7 @@ Obtains the area where this window cannot be displayed, for example, the system
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | -------------------------------- | --------- | ------------------------------------------------------------ | | ---- | -------------------------------- | --------- | ----------------- |
| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. | | type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. |
**Return value** **Return value**
...@@ -5238,7 +5238,7 @@ Sets a color space for this window. This API uses an asynchronous callback to re ...@@ -5238,7 +5238,7 @@ Sets a color space for this window. This API uses an asynchronous callback to re
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ------------------------- | --------- | ----------------------------------- | | ---------- | -------------------------- | --------- | ----------------------------------- |
| colorSpace | [ColorSpace](#colorspace8) | Yes | Color space to set. | | colorSpace | [ColorSpace](#colorspace8) | Yes | Color space to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
...@@ -5270,7 +5270,7 @@ Sets a color space for this window. This API uses a promise to return the result ...@@ -5270,7 +5270,7 @@ Sets a color space for this window. This API uses a promise to return the result
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ------------------------- | --------- | ------------------- | | ---------- | -------------------------- | --------- | ------------------- |
| colorSpace | [ColorSpace](#colorspace8) | Yes | Color space to set. | | colorSpace | [ColorSpace](#colorspace8) | Yes | Color space to set. |
**Return value** **Return value**
...@@ -5306,7 +5306,7 @@ Obtains the color space of this window. This API uses an asynchronous callback t ...@@ -5306,7 +5306,7 @@ Obtains the color space of this window. This API uses an asynchronous callback t
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------------- | --------- | ------------------------------------------------------------ | | -------- | ----------------------------------------------- | --------- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;[ColorSpace](#colorspace8)&gt; | Yes | Callback used to return the result. When the color space is obtained successfully, **err** is **undefined**, and **data** is the current color space. | | callback | AsyncCallback&lt;[ColorSpace](#colorspace8)&gt; | Yes | Callback used to return the result. When the color space is obtained successfully, **err** is **undefined**, and **data** is the current color space. |
**Example** **Example**
...@@ -5337,7 +5337,7 @@ Obtains the color space of this window. This API uses a promise to return the re ...@@ -5337,7 +5337,7 @@ Obtains the color space of this window. This API uses a promise to return the re
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ----------------------------------------------- | | ----------------------------------------- | ----------------------------------------------- |
| Promise&lt;[ColorSpace](#colorspace8)&gt; | Promise used to return the current color space. | | Promise&lt;[ColorSpace](#colorspace8)&gt; | Promise used to return the current color space. |
**Example** **Example**
......
...@@ -24,7 +24,7 @@ DataPanel(options:{values: number[], max?: number, type?: DataPanelType}) ...@@ -24,7 +24,7 @@ DataPanel(options:{values: number[], max?: number, type?: DataPanelType})
| ----------------- | -------- | ----- | -------- | | ----------------- | -------- | ----- | -------- |
| values | number[] | Yes | Data value list. A maximum of nine values are supported. If more than nine values are set, only the first nine ones are used. If the value is less than 0, the value 0 is used.| | values | number[] | Yes | Data value list. A maximum of nine values are supported. If more than nine values are set, only the first nine ones are used. If the value is less than 0, the value 0 is used.|
| max | number | No | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.<br>- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion.<br>Default value: **100**| | max | number | No | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.<br>- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion.<br>Default value: **100**|
| type<sup>8+</sup> | [DataPanelType](#datapaneltype) | No| Type of the data panel.<br>Default value: **DataPanelType.Circle**| | type<sup>8+</sup> | [DataPanelType](#datapaneltype) | No| Type of the data panel (dynamic modification is not supported).<br>Default value: **DataPanelType.Circle**|
## DataPanelType ## DataPanelType
......
...@@ -21,7 +21,7 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B ...@@ -21,7 +21,7 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| scroller | [Scroller](ts-container-scroll.md#scroller) | Yes| Scroller, which can be bound to scrollable components.| | scroller | [Scroller](ts-container-scroll.md#scroller) | Yes| Scroller, which can be bound to scrollable components.|
| direction | ScrollBarDirection | No| Scrollbar direction in which scrollable components scroll.<br>Default value: **ScrollBarDirection.Vertical**| | direction | [ScrollBarDirection](#scrollbardirection) | No| Scrollbar direction in which scrollable components scroll.<br>Default value: **ScrollBarDirection.Vertical**|
| state | [BarState](ts-appendix-enums.md#barstate) | No| Scrollbar state.<br>Default value: **BarState.Auto**| | state | [BarState](ts-appendix-enums.md#barstate) | No| Scrollbar state.<br>Default value: **BarState.Auto**|
> **NOTE** > **NOTE**
...@@ -65,7 +65,7 @@ struct ScrollBarExample { ...@@ -65,7 +65,7 @@ struct ScrollBarExample {
.margin({ top: 5 }) .margin({ top: 5 })
} }
}, item => item) }, item => item)
}.margin({ left: 52 }) }.margin({ right: 52 })
} }
.scrollBar(BarState.Off) .scrollBar(BarState.Off)
.scrollable(ScrollDirection.Vertical) .scrollable(ScrollDirection.Vertical)
......
...@@ -35,9 +35,9 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -35,9 +35,9 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| selectedBackgroundColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected item.<br>Default value: **0x1F0A59F7** | | selectedBackgroundColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected item.<br>Default value: **0x1F0A59F7** |
| popupBackground | [ResourceColor](ts-types.md#resourcecolor) | Background color of the pop-up text.<br>Default value: **0xFFF1F3F5** | | popupBackground | [ResourceColor](ts-types.md#resourcecolor) | Background color of the pop-up text.<br>Default value: **0xFFF1F3F5** |
| usingPopup | boolean | Whether to use pop-up text.<br>Default value: **false** | | usingPopup | boolean | Whether to use pop-up text.<br>Default value: **false** |
| selectedFont | [Font](ts-types.md#font) | Font style of the selected text.<br>Default value:<br>{<br>fontSize:10,<br> fontStyle:FontStyle.Normal,<br> fontWeight:FontWeight.Normal,<br> fontFamily:HarmonyOS Sans<br>} | | selectedFont | [Font](ts-types.md#font) | Font style of the selected text.<br>Default value:<br>{<br>size:10,<br> style:FontStyle.Normal,<br> weight:FontWeight.Normal,<br> family:'HarmonyOS Sans'<br>} |
| popupFont | [Font](ts-types.md#font) | Font style of the pop-up text.<br>Default value:<br>{<br>fontSize:10,<br> fontStyle:FontStyle.Normal,<br> fontWeight:FontWeight.Normal,<br> fontFamily:HarmonyOS Sans<br>} | | popupFont | [Font](ts-types.md#font) | Font style of the pop-up text.<br>Default value:<br>{<br>size:10,<br> style:FontStyle.Normal,<br> weight:FontWeight.Normal,<br> family:'HarmonyOS Sans'<br>} |
| font | [Font](ts-types.md#font) | Default font style of the alphabetic index bar.<br>Default value:<br>{<br>fontSize:10,<br> fontStyle:FontStyle.Normal,<br> fontWeight:FontWeight.Normal,<br> fontFamily:HarmonyOS Sans<br>} | | font | [Font](ts-types.md#font) | Default font style of the alphabetic index bar.<br>Default value:<br>{<br>size:10,<br> style:FontStyle.Normal,<br> weight:FontWeight.Normal,<br> family:'HarmonyOS Sans'<br>} |
| itemSize | string \| number | Size of an item in the alphabetic index bar. The item is a square, and the side length needs to be set. This attribute cannot be set to a percentage.<br>Default value: **24.0** | | itemSize | string \| number | Size of an item in the alphabetic index bar. The item is a square, and the side length needs to be set. This attribute cannot be set to a percentage.<br>Default value: **24.0** |
| alignStyle | IndexerAlign | Alignment style of the alphabetic index bar. Left alignment and right alignment are supported.<br>Default value: **IndexerAlign.Right**| | alignStyle | IndexerAlign | Alignment style of the alphabetic index bar. Left alignment and right alignment are supported.<br>Default value: **IndexerAlign.Right**|
| selected | number | Index of the selected item.<br>Default value: **0**| | selected | number | Index of the selected item.<br>Default value: **0**|
......
# ListItem # ListItem
The **\<ListItem>** component displays specific items in the list. Its width occupies the **\<List>** component by default and must be used together with **\<List>**. The **\<ListItem>** component displays specific items in the list. It must be used together with **\<List>**.
> **NOTE** > **NOTE**
> >
...@@ -22,7 +22,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -22,7 +22,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| sticky<sup>(deprecated)</sup> | [Sticky](#stickydeprecated) | Sticky effect of the list item.<br>Default value: **Sticky.None**<br>This API is deprecated since API version 9. You are advised to use **sticky** of the [\<List>](ts-container-list.md#attributes) component. | | sticky<sup>(deprecated)</sup> | [Sticky](#stickydeprecated) | Sticky effect of the list item.<br>Default value: **Sticky.None**<br>This API is deprecated since API version 9. You are advised to use **sticky** of the [\<List>](ts-container-list.md#attributes) component.|
| editable<sup>(deprecated)</sup> | boolean \| [EditMode](#editmodedeprecated) | Whether to enter editing mode, where the list item can be deleted or moved.<br>This API is deprecated since API version 9.<br>Default value: **false**| | editable<sup>(deprecated)</sup> | boolean \| [EditMode](#editmodedeprecated) | Whether to enter editing mode, where the list item can be deleted or moved.<br>This API is deprecated since API version 9.<br>Default value: **false**|
| selectable<sup>8+</sup> | boolean | Whether the current list item is selectable by mouse drag.<br>**NOTE**<br>This attribute takes effect only when mouse frame selection is enabled for the parent **\<List>** container.<br>Default value: **true**| | selectable<sup>8+</sup> | boolean | Whether the current list item is selectable by mouse drag.<br>**NOTE**<br>This attribute takes effect only when mouse frame selection is enabled for the parent **\<List>** container.<br>Default value: **true**|
| swipeAction<sup>9+</sup> | {<br>start?: CustomBuilder,<br>end?:CustomBuilder,<br>edgeEffect?: [SwipeEdgeEffect](#swipeedgeeffect9),<br>} | Component displayed when the list item is swiped out from the screen edge.<br>- **start**: component on the left of the list item when the item is swiped to the right (in vertical list layout) or component above the list item when the item is swiped down (in horizontal list layout).<br>- **end**: component on the right of the list item when the item is swiped to the left (in vertical list layout) or component below the list item when the item is swiped up (in horizontal list layout).<br>- **edgeEffect**: scroll effect.<br>| | swipeAction<sup>9+</sup> | {<br>start?: CustomBuilder,<br>end?:CustomBuilder,<br>edgeEffect?: [SwipeEdgeEffect](#swipeedgeeffect9),<br>} | Component displayed when the list item is swiped out from the screen edge.<br>- **start**: component on the left of the list item when the item is swiped to the right (in vertical list layout) or component above the list item when the item is swiped down (in horizontal list layout).<br>- **end**: component on the right of the list item when the item is swiped to the left (in vertical list layout) or component below the list item when the item is swiped up (in horizontal list layout).<br>- **edgeEffect**: scroll effect.<br>|
......
...@@ -131,7 +131,7 @@ Scrolls to the item with the specified index. ...@@ -131,7 +131,7 @@ Scrolls to the item with the specified index.
> **NOTE** > **NOTE**
> >
> Only the **\<List>** component is supported. > Only the **\<Grid>**, **\<List>**, and **\<WaterFlow>** components are supported.
**Parameters** **Parameters**
......
...@@ -50,7 +50,7 @@ struct TransitionExample { ...@@ -50,7 +50,7 @@ struct TransitionExample {
}) })
}) })
if (this.flag) { if (this.flag) {
// Apply different transition effects to the appearance and disappearance of the image. // Apply different transition effects to the showing and hiding of the image.
Image($r('app.media.testImg')).width(300).height(300) Image($r('app.media.testImg')).width(300).height(300)
.transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } }) .transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } })
.transition({ type: TransitionType.Delete, rotate: { angle: 180 } }) .transition({ type: TransitionType.Delete, rotate: { angle: 180 } })
...@@ -60,4 +60,20 @@ struct TransitionExample { ...@@ -60,4 +60,20 @@ struct TransitionExample {
} }
``` ```
![animateTo](figures/animateTo.gif) Diagrams:
When the image is completely displayed:
![animationComponent1](figures/animationComponent1.png)
When the transition effect of 180° clockwise rotation is applied to the hiding of the image:
![animationComponent3](figures/animationComponent3.png)
When the image disappears completely:
![animationComponent2](figures/animationComponent2.png)
When the transition effect of zooming in twice horizontally is applied to the image displayed:
![animationComponent4](figures/animationComponent4.png)
...@@ -201,7 +201,7 @@ Sample code for **focusControl.requestFocus**: ...@@ -201,7 +201,7 @@ Sample code for **focusControl.requestFocus**:
Use the **focusContrl.requestFocus** API to enable a specified component to obtain focus. Use the **focusContrl.requestFocus** API to enable a specified component to obtain focus.
```ts ```ts
// requestFocus.ets // requestFocus.ets
import prompt from '@ohos.prompt' import promptAction from '@ohos.promptAction';
@Entry @Entry
@Component @Component
...@@ -253,9 +253,9 @@ struct RequestFocusExample { ...@@ -253,9 +253,9 @@ struct RequestFocusExample {
.onClick(() => { .onClick(() => {
var res = focusControl.requestFocus(this.selectId) // Enable the component selected by this.selectId to obtain focus. var res = focusControl.requestFocus(this.selectId) // Enable the component selected by this.selectId to obtain focus.
if (res) { if (res) {
prompt.showToast({message: 'Request success'}) promptAction.showToast({message: 'Request success'})
} else { } else {
prompt.showToast({message: 'Request failed'}) promptAction.showToast({message: 'Request failed'})
} }
}) })
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
## When to Use ## When to Use
The [Ability Privilege Level (APL)](accesstoken-overview.md#app-apls) of an application can be **normal**, **system_basic**, or **system_core**. The default APL is **normal**. The [permission types](accesstoken-overview.md#permission-types) include **system_grant** and **user_grant**. For details about the permissions for apps, see the [Application Permission List](permission-list.md). The [Ability Privilege Level (APL)](accesstoken-overview.md#app-apls) of an application can be **normal**, **system_basic**, or **system_core**. The default APL is **normal**. The [permission types](accesstoken-overview.md#permission-types) include **system_grant** and **user_grant**. For details about the permissions for applications, see the [Application Permission List](permission-list.md).
This document describes the following operations: This document describes:
- [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file) - [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file)
- [Declaring Permissions in the ACL](#declaring-permissions-in-the-acl) - [Declaring Permissions in the ACL](#declaring-permissions-in-the-acl)
...@@ -119,23 +119,22 @@ For example, if an application needs to access audio files of a user and capture ...@@ -119,23 +119,22 @@ For example, if an application needs to access audio files of a user and capture
If an application needs to access user privacy information or use system abilities, for example, accessing location or calendar information or using the camera to take photos or record videos, it must request the permission from users. A permission verification is performed first to determine whether the current invoker has the corresponding permission. If the application has not obtained that permission, a dialog box will be displayed to request user authorization. The following figure shows an example. If an application needs to access user privacy information or use system abilities, for example, accessing location or calendar information or using the camera to take photos or record videos, it must request the permission from users. A permission verification is performed first to determine whether the current invoker has the corresponding permission. If the application has not obtained that permission, a dialog box will be displayed to request user authorization. The following figure shows an example.
<img src="figures/permission-read_calendar.png" width="40%;" /> <img src="figures/permission-read_calendar.png" width="40%;" />
> **NOTE**<br>Each time before an API protected by a permission is accessed, the [**requestPermissionsFromUser()**](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) API will be called to request user authorization. After a permission is dynamically granted, the user may revoke the permission. Therefore, the previously granted authorization status cannot be persistent. > **NOTE**<br>Each time before an API protected by a permission is accessed, [**requestPermissionsFromUser()**](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) will be called to request user authorization. After a permission is dynamically granted, the user may revoke the permission. Therefore, the previously granted authorization status cannot be persistent.
### Stage Model ### Stage Model
Example: Request the permission to read calendar information for an app. Example: Request the permission for an application to access calendar information.
1. Apply for the **ohos.permission.READ_CALENDAR** permission. For details, see [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file). 1. Apply for the **ohos.permission.READ_CALENDAR** permission. For details, see [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file).
2. Call [**requestPermissionsFromUser()**](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) in the **onWindowStageCreate()** callback of the UIAbility to dynamically apply for the permission, or request user authorization on the UI based on service requirements. The return value of [requestPermissionsFromUser()](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) indicates whether the app has the target permission. If yes, the target API can be called normally. 2. Call [**requestPermissionsFromUser()**](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) in the **onWindowStageCreate()** callback of the UIAbility to dynamically apply for the permission, or request user authorization on the UI based on service requirements. The return value of [requestPermissionsFromUser()](../reference/apis/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) indicates whether the application has the target permission. If yes, the target API can be called normally.
Request user authorization in UIAbility. Request user authorization in UIAbility.
```typescript ```typescript
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window'; import window from '@ohos.window';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
import { Permissions } from '@ohos.abilityAccessCtrl';
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
// ... // ...
...@@ -143,10 +142,10 @@ Example: Request the permission to read calendar information for an app. ...@@ -143,10 +142,10 @@ Example: Request the permission to read calendar information for an app.
onWindowStageCreate(windowStage: window.WindowStage) { onWindowStageCreate(windowStage: window.WindowStage) {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
let context = this.context; let context = this.context;
let AtManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
// The return value of requestPermissionsFromUser determines whether to display a dialog box to request user authorization. // The return value of requestPermissionsFromUser determines whether to display a dialog box to request user authorization.
const permissions: Array<Permissions> = ['ohos.permission.READ_CALENDAR']; const permissions: Array<Permissions> = ['ohos.permission.READ_CALENDAR'];
AtManager.requestPermissionsFromUser(context, permissions).then((data) => { atManager.requestPermissionsFromUser(context, permissions).then((data) => {
console.info(`[requestPermissions] data: ${JSON.stringify(data)}`); console.info(`[requestPermissions] data: ${JSON.stringify(data)}`);
let grantStatus: Array<number> = data.authResults; let grantStatus: Array<number> = data.authResults;
if (grantStatus[0] === -1) { if (grantStatus[0] === -1) {
...@@ -165,8 +164,7 @@ Example: Request the permission to read calendar information for an app. ...@@ -165,8 +164,7 @@ Example: Request the permission to read calendar information for an app.
Request user authorization on the UI. Request user authorization on the UI.
```typescript ```typescript
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
import { Permissions } from '@ohos.abilityAccessCtrl';
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
@Entry @Entry
...@@ -174,10 +172,10 @@ Example: Request the permission to read calendar information for an app. ...@@ -174,10 +172,10 @@ Example: Request the permission to read calendar information for an app.
struct Index { struct Index {
reqPermissions() { reqPermissions() {
let context = getContext(this) as common.UIAbilityContext; let context = getContext(this) as common.UIAbilityContext;
let AtManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
// The return value of requestPermissionsFromUser determines whether to display a dialog box to request user authorization. // The return value of requestPermissionsFromUser determines whether to display a dialog box to request user authorization.
const permissions: Array<Permissions> = ['ohos.permission.READ_CALENDAR']; const permissions: Array<Permissions> = ['ohos.permission.READ_CALENDAR'];
AtManager.requestPermissionsFromUser(context, permissions).then((data) => { atManager.requestPermissionsFromUser(context, permissions).then((data) => {
console.info(`[requestPermissions] data: ${JSON.stringify(data)}`); console.info(`[requestPermissions] data: ${JSON.stringify(data)}`);
let grantStatus: Array<number> = data.authResults; let grantStatus: Array<number> = data.authResults;
if (grantStatus[0] === -1) { if (grantStatus[0] === -1) {
...@@ -217,11 +215,11 @@ onWindowStageCreate() { ...@@ -217,11 +215,11 @@ onWindowStageCreate() {
} }
``` ```
## Pre-Authorizing user_grant Permissions ## Pre-Authorizing user_grant Permissions
By default, the **user_grant** permissions must be dynamically authorized by the user through a dialog box. However, for pre-installed apps, you can pre-authroize the permissions, for example, the **ohos.permission.MICROPHONE** permission, in the [**install_list_permission.json**](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) file to prevent the user authorization dialog box from being displayed. The **install_list_permissions.json** file is in the **/system/etc/app/** directory on a device. When the device is started, the **install_list_permissions.json** file is loaded. When the application is installed, the **user_grant** permissions in the file are granted. The **install_list_permissions.json** file contains the following fields: By default, the **user_grant** permissions must be dynamically authorized by the user through a dialog box. However, for pre-installed applications, you can pre-authorize the permissions, for example, the **ohos.permission.MICROPHONE** permission for camera applications, in the [**install_list_permission.json**] file to prevent the user authorization dialog box from being displayed. The [**install_list_permissions.json** file](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) is in the **/system/etc/app/** directory on a device. When the device is started, the **install_list_permissions.json** file is loaded. When the application is installed, the **user_grant** permissions in the file are granted. The **install_list_permissions.json** file contains the following fields:
- **bundleName**: bundle name of the application. - **bundleName**: bundle name of the application.
- `app_signature`: fingerprint information of the application. For details, see **Configuration in install_list_capability.json** in [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). - **app_signature**: fingerprint information of the application. For details, see **Configuration in install_list_capability.json** in [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md).
- **permissions**: **name** specifies the name of the **user_grant** permission to pre-authorize. **userCancellable** specifies whether the user can revoke the pre-authorization. The value **true** means the user can revoke the pre-authorization; the vaue **false** means the opposite. - **permissions**: **name** specifies the name of the **user_grant** permission to pre-authorize. **userCancellable** specifies whether the user can revoke the pre-authorization. The value **true** means the user can revoke the pre-authorization; the value **false** means the opposite.
> **NOTE**<br>This file is available only for preinstalled applications. > **NOTE**<br>This file is available only for preinstalled applications.
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册