提交 6babb455 编写于 作者: D dy 提交者: Gitee

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

Signed-off-by: Ndy <dingyao5@huawei.com>
......@@ -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/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/notification/ @RayShih @jayleehw @li-weifeng2 @currydavids
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
zh-cn/application-dev/faqs/ @zengyawen
zh-cn/application-dev/file-management/ @zengyawen
zh-cn/application-dev/application-test/ @ningningW
zh-cn/application-dev/device-usage-statistics/ @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-errorCode.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
......@@ -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-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-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-bluetooth.md @cheng_guohong @RayShih @cheng_guohong @quanli125
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
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-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-effectKit.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
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
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-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-WorkSchedulerExtensionAbility.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 @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-zlib.md @shuaytao @RayShih @wangzhen107 @inter515
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
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-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-resourceschedule-backgroundTaskManager.md @wangwenli_wolf @ningningW @tangtiantian2021 @nan-xiansen
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-workScheduler.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 @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
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 @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-system-capability.md taiyipei taiyipei BlackStone
zh-cn/application-dev/reference/apis/js-apis-system-parameterV9.md @mupceet @zengyawen @handyohos @nan-xiansen
......
......@@ -65,12 +65,13 @@
- [Internationalization](internationalization/Readme-EN.md)
- [Application Test](application-test/Readme-EN.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
- [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
- [Samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md)
- [Codelabs](https://gitee.com/openharmony/codelabs)
- [Samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md)
- [Codelabs](https://gitee.com/openharmony/codelabs)
- API References
- [SystemCapability](reference/syscap.md)
- [SystemCapability List](reference/syscap-list.md)
......
......@@ -60,13 +60,7 @@ The **module.json5** of a browser application is as follows:
} catch (error) {
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}`)
}
}
}
```
The matching process is as follows:
......
......@@ -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. |
| setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | Sets the USB device configuration. |
| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets 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. |
| 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. |
| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. |
| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. |
| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file 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
......@@ -51,7 +51,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat
vendorId: 7531,
productId: 2,
clazz: 9,
subclass: 0,
subClass: 0,
protocol: 1,
devAddress: 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
id: 0,
protocol: 0,
clazz: 9,
subclass: 0,
subClass: 0,
alternateSetting: 0,
name: "1-1",
endpoints: [
......@@ -93,7 +93,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat
```
2. Obtain the device operation permissions.
2. Obtain the device operation permissions.
```js
let deviceName = deviceList[0].name;
......@@ -105,11 +105,11 @@ You can set a USB device as the USB host to connect to other USB devices for dat
});
```
3. Open the device.
3. Open the device.
```js
// 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.
interface1 must be one present in the device configuration.
......@@ -117,14 +117,16 @@ You can set a USB device as the USB host to connect to other USB devices for dat
usb.claimInterface(pipe, interface1, true);
```
4. Perform data transfer.
4. Perform data transfer.
```js
/*
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.
*/
let inEndpoint = interface1.endpoints[2];
let outEndpoint = interface1.endpoints[1];
let dataUint8Array = new Uint8Array(1024);
usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) {
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
console.info("usb readData error : " + JSON.stringify(error));
});
// 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) {
console.info("usb writeData result write length : " + dataLength);
} else {
......
# DFX
- [Development of Application Event Logging](hiappevent-guidelines.md)
- [Development of Performance Tracing](hitracemeter-guidelines.md)
- [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md)
- Application Event Logging
- [Development of Application Event Logging](hiappevent-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
- [Development of Error Manager](errormanager-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 @@
## 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.
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.
## Basic Concepts
......@@ -18,47 +16,106 @@ The APIs for distributed call chain tracing are provided by the **hiTraceChain**
**APIs for distributed call chain tracing**
| API| Return Value| Description|
| ------------------------------------------------------------------------------------------------------------------- | -------------- | ------------ |
| 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.|
| API | Return Value | Description |
| ------------------------------------------------------------------------------------------------------------------- | -------------- | ------------ |
| hiTraceChain.begin(name: string, flags: number = HiTraceFlag.DEFAULT) | HiTraceId | Starts call chain tracing. |
| hiTraceChain.end(id: HiTraceId) | void | Stops call chain tracing. |
## 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.
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:
```
import hiTraceChain from '@ohos.hiTraceChain'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
// 1. Enable distributed call chain tracing.
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
// 2. Start the service process.
console.log(`business start`);
// 3. Add a trace point.
hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.THREAD, hiTraceChain.HiTraceTracepointType.SS, asyncTraceId, "Just an example");
// 4. Keep the service process running.
console.log(`business running`);
// 5. End the service process.
console.log(`business end`);
// 6. Stop call chain tracing.
hiTraceChain.end(asyncTraceId);
}
}
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 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 hiSysEvent from '@ohos.hiSysEvent';
@Entry
@Component
struct Index {
@State message: string = 'Start writing system event';
build() {
Row() {
Column() {
Button(this.message)
.fontSize(20)
.margin(5)
.width(350)
.height(60)
.fontWeight(FontWeight.Bold)
.onClick(() => {
try {
// Enable distributed call chain tracing before the service starts.
let traceId = hiTraceChain.begin("Write a new system event", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
// Implement one-time system event logging when the service starts.
hiSysEvent.write({
domain: "RELIABILITY",
name: "STACK",
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
> **NOTE**
>
> All APIs of the **AVSession** module are system APIs and can be called only by system applications.
## Development for the Session Access End
### Basic Concepts
......@@ -28,7 +32,7 @@ Table 1 Common APIs for session access end development
```js
import avSession from '@ohos.multimedia.avsession';
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
import featureAbility from '@ohos.ability.featureAbility';
```
......@@ -50,7 +54,7 @@ avSession.createAVSession(context, "AudioAppSample", 'audio').then((session) =>
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.
- 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.
```js
// Set the session metadata.
......@@ -83,7 +87,7 @@ let wantAgentInfo = {
wants: [
{
bundleName: "com.neu.setResultOnAbilityResultTest1",
abilityName: "com.example.test.MainAbility",
abilityName: "com.example.test.EntryAbility",
}
],
operationType: wantAgent.OperationType.START_ABILITIES,
......@@ -187,7 +191,7 @@ currentSession.on('playNext', () => {
});
console.log ("Call AudioPlayer.play.");
// 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(() => {
console.info('setAVPlaybackState successfully');
}).catch((err) => {
......@@ -282,7 +286,7 @@ currentSession.off('outputDeviceChange');
// Deactivate the session and destroy the object.
currentSession.deactivate().then(() => {
currentSession.destory();
currentSession.destroy();
});
```
......@@ -365,7 +369,7 @@ Table 2 Common APIs for session control end development
```js
import avSession from '@ohos.multimedia.avsession';
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';
```
......
# AVSession Overview
> **NOTE**
>
> All APIs of the **AVSession** module are system APIs and can be called only by system applications.
## Overview
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
- 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.
- 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
// 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);
// Destroy the created objects when they are no longer needed.
OH_Drawing_BrushDestory(cBrush);
OH_Drawing_PenDestory(cPen);
OH_Drawing_PathDestory(cPath);
OH_Drawing_BrushDestroy(cBrush);
OH_Drawing_PenDestroy(cPen);
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.
......@@ -133,9 +133,9 @@ The following steps describe how to use the canvas and brush of the Native Drawi
LOGI("memcpy_s failed");
}
// Destroy the canvas object.
OH_Drawing_CanvasDestory(cCanvas);
OH_Drawing_CanvasDestroy(cCanvas);
// Destroy the bitmap object.
OH_Drawing_BitmapDestory(cBitmap);
OH_Drawing_BitmapDestroy(cBitmap);
```
## Development Procedure for Text Drawing
......
......@@ -29,20 +29,72 @@ 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_NativeWindowSetTunnelHandle(OHNativeWindow \*window, const OHExtDataHandle \*handle) | Sets the tunnel handle to the native window.|
## 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.
1. Obtain a **NativeWindow** instance. For example, use **Surface** to create a **NativeWindow** instance.
```c++
sptr<OHOS::Surface> cSurface = Surface::CreateSurfaceAsConsumer();
sptr<IBufferConsumerListener> listener = new BufferConsumerListenerTest();
cSurface->RegisterConsumerListener(listener);
sptr<OHOS::IBufferProducer> producer = cSurface->GetProducer();
sptr<OHOS::Surface> pSurface = Surface::CreateSurfaceAsProducer(producer);
OHNativeWindow* nativeWindow = OH_NativeWindow_CreateNativeWindow(&pSurface);
```
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++
napi_value exportInstance = nullptr;
napi_get_named_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance);
OH_NativeXComponent *nativeXComponent = nullptr;
napi_unwrap(env, exportInstance, reinterpret_cast<void**>(&nativeXComponent));
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**.
```c++
......@@ -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.
```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.
Region region{nullptr, 0};
......
......@@ -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.
**Table 1** Tags in the app.json5 file
**Table 1** Tags in the app.json5 file
| 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|
| 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|
| 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)|
| 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|
| 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)|
| 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|
| 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**)|
| targetAPIVersion | Target API version required for running the application.| Number| Yes (initial value: value of **compileSdkVersion** 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 **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)|
| 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"**)|
......
# 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
![hap-intall-uninstall](figures/hap-intall-uninstall.png)
**Figure 2** Process of installing and uninstalling an application (applicable to consumers)
![hap-intall-uninstall](figures/hap-install-uninstall-user.png)
\ No newline at end of file
......@@ -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 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**.
>
......
......@@ -28,12 +28,12 @@ You can use DevEco Studio to build code into one or more HAP files. Then, you ca
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:
```
// 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:
install bundle successfully.
// Uninstall
......
......@@ -224,7 +224,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba
```ts
import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) {
if (err) {
......@@ -293,7 +293,7 @@ Requests a continuous task from the system. This API uses a promise to return th
```ts
import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
let wantAgentInfo = {
wants: [
......@@ -445,7 +445,6 @@ particleAbility.disconnectAbility(connId).then((data) => {
}).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code)
});
```
## particleAbility.disconnectAbility
......@@ -491,10 +490,10 @@ var connId = particleAbility.connectAbility(
onFailed: onFailedCallback,
},
);
var result = particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data);
}).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code)
particleAbility.disconnectAbility(connId, (err) => {
console.log("particleAbilityTest disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
});
```
......
......@@ -9,7 +9,7 @@ The **Configuration** module defines environment change information.
## Modules to Import
```ts
import Configuration from '@ohos.app.ability.Configuration'
import Configuration from '@ohos.app.ability.Configuration';
```
**System capability**: SystemCapability.Ability.AbilityBase
......@@ -26,30 +26,30 @@ import Configuration from '@ohos.app.ability.Configuration'
For details about the fields, see the **ohos.app.ability.Configuration.d.ts** file.
**Example**
```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) {
let envCallback = {
onConfigurationUpdated(config) {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
let language = config.language;
let colorMode = config.colorMode;
let direction = config.direction;
let screenDensity = config.screenDensity;
let displayId = config.displayId;
let hasPointerDevice = config.hasPointerDevice;
let envCallback = {
onConfigurationUpdated(config) {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
let language = config.language;
let colorMode = config.colorMode;
let direction = config.direction;
let screenDensity = config.screenDensity;
let displayId = config.displayId;
let hasPointerDevice = config.hasPointerDevice;
}
};
try {
let applicationContext = this.context.getApplicationContext();
let callbackId = applicationContext.on("environment", envCallback);
console.log("callbackId: " + callbackId);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
};
try {
let applicationContext = this.context.getApplicationContext();
let callbackId = applicationContext.on("environment", envCallback);
console.log("callbackId: " + callbackId);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
}
}
}
```
......@@ -124,7 +124,7 @@ Updates a widget. This API uses an asynchronous callback to return the result.
**Example**
```ts
import formBindingData from '@ohos.application.formBindingData';
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288";
......@@ -173,7 +173,7 @@ Updates a widget. This API uses a promise to return the result.
**Example**
```ts
import formBindingData from '@ohos.application.formBindingData';
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288";
......@@ -349,7 +349,7 @@ Requests to publish a widget carrying data to the widget host. This API uses an
**Example**
```ts
import formBindingData from '@ohos.application.formBindingData';
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let want = {
......
......@@ -8,14 +8,17 @@ This module provides the following common ability-related functions:
- [Callee](#callee): implements callbacks for registration and deregistration of caller notifications.
> **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 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 APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import UIAbility from '@ohos.application.Ability';
```
## Attributes
......@@ -72,7 +75,7 @@ Called when a **WindowStage** is created for this ability.
**Example**
```ts
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
}
......@@ -91,7 +94,7 @@ Called when the **WindowStage** is destroyed for this ability.
**Example**
```ts
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
onWindowStageDestroy() {
console.log('onWindowStageDestroy');
}
......@@ -116,7 +119,7 @@ Called when the **WindowStage** is restored during the migration of this ability
**Example**
```ts
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
onWindowStageRestore(windowStage) {
console.log('onWindowStageRestore');
}
......@@ -133,9 +136,9 @@ Called when this ability is destroyed to clear resources.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
```ts
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
onDestroy() {
console.log('onDestroy');
}
......@@ -152,9 +155,9 @@ Called when this ability is switched from the background to the foreground.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
```ts
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
onForeground() {
console.log('onForeground');
}
......@@ -171,9 +174,9 @@ Called when this ability is switched from the foreground to the background.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
```ts
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
onBackground() {
console.log('onBackground');
}
......@@ -202,10 +205,11 @@ Called to save data during the ability migration preparation process.
| AbilityConstant.OnContinueResult | Continuation result.|
**Example**
```ts
import AbilityConstant from "@ohos.application.AbilityConstant"
class myAbility extends Ability {
import AbilityConstant from "@ohos.app.ability.AbilityConstant";
export default class EntryAbility extends UIAbility {
onContinue(wantParams) {
console.log('onContinue');
wantParams["myData"] = "my1234567";
......@@ -231,9 +235,9 @@ Called when a new Want is passed in and this UIAbility is started again.
| launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
**Example**
```ts
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
onNewWant(want, launchParams) {
console.log('onNewWant, want:' + want.abilityName);
console.log('onNewWant, launchParams:' + JSON.stringify(launchParams));
......@@ -256,9 +260,9 @@ Called when the global configuration is updated.
| config | [Configuration](js-apis-application-configuration.md) | Yes| Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode.|
**Example**
```ts
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
onConfigurationUpdated(config) {
console.log('onConfigurationUpdated, language:' + config.language);
}
......@@ -280,9 +284,9 @@ Dumps client information.
| params | Array\<string> | Yes| Parameters in the form of a command.|
**Example**
```ts
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
dump(params) {
console.log('dump, params:' + JSON.stringify(params));
return ["params"]
......@@ -305,9 +309,9 @@ Called when the system has decided to adjust the memory level. For example, this
| level | [AbilityConstant.MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
**Example**
```ts
class myAbility extends Ability {
export default class EntryAbility extends UIAbility {
onMemoryLevel(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
**Example**
```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) {
console.log('onSaveState');
wantParam["myData"] = "my1234567";
......@@ -349,8 +353,6 @@ class myAbility extends Ability {
}
```
## Caller
Implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability).
......@@ -387,7 +389,7 @@ Sends sequenceable data to the target ability.
| 16000050 | Internal Error. |
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
......@@ -545,7 +547,6 @@ Releases the caller interface of the target ability.
| 16000050 | Internal Error. |
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
......@@ -589,7 +590,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
......@@ -716,7 +717,6 @@ Deregisters a caller notification callback, which is invoked when the target abi
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
......
......@@ -9,7 +9,7 @@ The **AbilityDelegatorRegistry** module provides APIs for storing the global reg
## Modules to Import
```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
```
## AbilityLifecycleState
......
......@@ -156,7 +156,7 @@ Called when an ability is continued on another device.
**Example**
```ts
import AbilityStage from "@ohos.application.AbilityStage";
import AbilityStage from "@ohos.app.ability.AbilityStage";
var lifecycleId;
......
......@@ -10,7 +10,7 @@ The **AbilityManager** module provides APIs for obtaining, adding, and modifying
## Modules to Import
```ts
import abilityManager from '@ohos.application.abilityManager'
import abilityManager from '@ohos.application.abilityManager';
```
## AbilityState
......@@ -38,7 +38,7 @@ Updates the configuration. This API uses an asynchronous callback to return the
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
......@@ -176,7 +176,7 @@ abilityManager.getExtensionRunningInfos(upperLimit, (err,data) => {
getExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningInfo>>
Obtains the extension running information. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -232,7 +232,7 @@ abilityManager.getTopAbility((err,data) => {
getTopAbility(): Promise\<ElementName>;
Obtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
......
# @ohos.application.AccessibilityExtensionAbility
# @ohos.application.AccessibilityExtensionAbility (AccessibilityExtensionAbility)
The **AccessibilityExtensionAbility** module provides accessibility extension capabilities based on the ExtensionAbility framework.
......
......@@ -420,7 +420,7 @@ Deregisters the application state observer. This API uses a promise to return th
getForegroundApplications(callback: AsyncCallback\<Array\<AppStateData>>): void;
Obtains information about the applications that are running in the foreground. This API uses an asynchronous callback to return the result. The application information is defined by [AppStateData](js-apis-inner-application-appStateData.md).
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
......@@ -26,7 +26,6 @@ import Configuration from '@ohos.application.Configuration'
For details about the fields, see the **ohos.application.Configuration.d.ts** file.
**Example**
```ts
import hilog from '@ohos.hilog';
import UIAbility from '@ohos.app.ability.UIAbility';
......
......@@ -8,7 +8,7 @@ The **ErrorManager** module provides APIs for registering and deregistering erro
## Modules to Import
```ts
import errorManager from '@ohos.application.errorManager'
import errorManager from '@ohos.application.errorManager';
```
## ErrorManager.registerErrorObserver
......@@ -20,7 +20,7 @@ Registers an error observer.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observer | [ErrorObserver](js-apis-inner-application-errorObserver.md) | Yes| Numeric code of the observer.|
......@@ -45,7 +45,7 @@ Deregisters an error observer. This API uses an asynchronous callback to return
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observerId | number | Yes| Numeric code of the observer.|
......@@ -74,7 +74,7 @@ Deregisters an error observer. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observerId | number | Yes| Numeric code of the observer.|
......
......@@ -48,7 +48,7 @@ Creates a **FormBindingData** object.
**Example**
```ts
import formBindingData from @ohos.application.formBindingData;
import formBindingData from '@ohos.application.formBindingData';
import fs from '@ohos.file.fs';
try {
......
......@@ -94,7 +94,7 @@ Updates a widget. This API uses an asynchronous callback to return the result.
**Example**
```ts
import formBindingData from '@ohos.application.formBindingData';
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288";
......
......@@ -1001,7 +1001,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example**
```js
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
// WantAgentInfo object
let wantAgentInfo = {
......@@ -1066,7 +1066,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example**
```js
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
// WantAgentInfo object
let wantAgentInfo = {
......@@ -2222,7 +2222,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example**
```js
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
controller.getLaunchAbility().then((agent) => {
console.info(`GetLaunchAbility : SUCCESS : wantAgent : ${agent}`);
......@@ -2257,7 +2257,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example**
```js
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
controller.getLaunchAbility(function (err, agent) {
if (err) {
......
......@@ -173,7 +173,7 @@ FA model:
```js
import backgroundTaskManager from '@ohos.backgroundTaskManager';
import featureAbility from '@ohos.ability.featureAbility';
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) {
if (err) {
......@@ -207,7 +207,7 @@ Stage model:
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import backgroundTaskManager from '@ohos.backgroundTaskManager';
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) {
if (err) {
......@@ -270,7 +270,7 @@ FA model:
```js
import backgroundTaskManager from '@ohos.backgroundTaskManager';
import featureAbility from '@ohos.ability.featureAbility';
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
let wantAgentInfo = {
wants: [
......@@ -299,7 +299,7 @@ Stage model:
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import backgroundTaskManager from '@ohos.backgroundTaskManager';
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
......
# @ohos.util.Deque (Linear Container Deque)
> **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.
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.
......@@ -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.|
| 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
Provides information about an application event.
......
......@@ -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**.
```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
```
......@@ -35,13 +35,13 @@ Adds an **AbilityMonitor** instance. This API uses an asynchronous callback to r
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
let monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
......@@ -75,13 +75,13 @@ Adds an **AbilityMonitor** instance. This API uses a promise to return the resul
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
let monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
......@@ -92,8 +92,6 @@ abilityDelegator.addAbilityMonitor(monitor).then(() => {
});
```
### removeAbilityMonitor<sup>9+</sup>
removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): void;
......@@ -112,13 +110,13 @@ Removes an **AbilityMonitor** instance. This API uses an asynchronous callback t
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
let monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
......@@ -129,8 +127,6 @@ abilityDelegator.removeAbilityMonitor(monitor, (err : any) => {
});
```
### removeAbilityMonitor<sup>9+</sup>
removeAbilityMonitor(monitor: AbilityMonitor): Promise\<void>;
......@@ -154,13 +150,13 @@ Removes an **AbilityMonitor** instance. This API uses a promise to return the re
- Example
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
let monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
......@@ -171,8 +167,6 @@ abilityDelegator.removeAbilityMonitor(monitor).then(() => {
});
```
### waitAbilityMonitor<sup>9+</sup>
waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<UIAbility>): void;
......@@ -191,13 +185,13 @@ Waits for the **Ability** instance that matches the **AbilityMonitor** instance
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
let monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
......@@ -227,14 +221,14 @@ Waits a period of time for the **Ability** instance that matches the **AbilityMo
**Example**
```ts
var abilityDelegator;
var timeout = 100;
let abilityDelegator;
let timeout = 100;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
let monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
......@@ -271,13 +265,13 @@ Waits a period of time for the **Ability** instance that matches the **AbilityMo
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
let monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
......@@ -288,8 +282,6 @@ abilityDelegator.waitAbilityMonitor(monitor).then((data : any) => {
});
```
### getAppContext<sup>9+</sup>
getAppContext(): Context;
......@@ -307,14 +299,12 @@ Obtains the application context.
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var context = abilityDelegator.getAppContext();
let context = abilityDelegator.getAppContext();
```
### getAbilityState<sup>9+</sup>
getAbilityState(ability: UIAbility): number;
......@@ -338,20 +328,18 @@ Obtains the lifecycle state of an ability.
**Example**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info("getCurrentTopAbility callback");
ability = data;
var state = abilityDelegator.getAbilityState(ability);
let state = abilityDelegator.getAbilityState(ability);
console.info("getAbilityState" + state);
});
```
### getCurrentTopAbility<sup>9+</sup>
getCurrentTopAbility(callback: AsyncCallback\<UIAbility>): void;
......@@ -369,8 +357,8 @@ Obtains the top ability of this application. This API uses an asynchronous callb
**Example**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
......@@ -379,8 +367,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
});
```
### getCurrentTopAbility<sup>9+</sup>
getCurrentTopAbility(): Promise\<UIAbility>;
......@@ -398,8 +384,8 @@ Obtains the top ability of this application. This API uses a promise to return t
**Example**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility().then((data : any) => {
......@@ -408,8 +394,6 @@ abilityDelegator.getCurrentTopAbility().then((data : any) => {
});
```
### startAbility<sup>9+</sup>
startAbility(want: Want, callback: AsyncCallback\<void>): void;
......@@ -428,8 +412,8 @@ Starts an ability. This API uses an asynchronous callback to return the result.
**Example**
```ts
var abilityDelegator;
var want = {
let abilityDelegator;
let want = {
bundleName: "bundleName",
abilityName: "abilityName"
};
......@@ -440,8 +424,6 @@ abilityDelegator.startAbility(want, (err : any, data : any) => {
});
```
### startAbility<sup>9+</sup>
startAbility(want: Want): Promise\<void>;
......@@ -465,8 +447,8 @@ Starts an ability. This API uses a promise to return the result.
**Example**
```ts
var abilityDelegator;
var want = {
let abilityDelegator;
let want = {
bundleName: "bundleName",
abilityName: "abilityName"
};
......@@ -477,8 +459,6 @@ abilityDelegator.startAbility(want).then((data: any) => {
});
```
### doAbilityForeground<sup>9+</sup>
doAbilityForeground(ability: UIAbility, callback: AsyncCallback\<void>): void;
......@@ -497,8 +477,8 @@ Schedules the lifecycle state of an ability to **Foreground**. This API uses an
**Example**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
......@@ -510,8 +490,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
});
```
### doAbilityForeground<sup>9+</sup>
doAbilityForeground(ability: UIAbility): Promise\<void>;
......@@ -535,8 +513,8 @@ Schedules the lifecycle state of an ability to **Foreground**. This API uses a p
**Example**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
......@@ -548,8 +526,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
});
```
### doAbilityBackground<sup>9+</sup>
doAbilityBackground(ability: UIAbility, callback: AsyncCallback\<void>): void;
......@@ -568,8 +544,8 @@ Schedules the lifecycle state of an ability to **Background**. This API uses an
**Example**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
......@@ -581,8 +557,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
});
```
### doAbilityBackground<sup>9+</sup>
doAbilityBackground(ability: UIAbility): Promise\<void>;
......@@ -606,8 +580,8 @@ Schedules the lifecycle state of an ability to **Background**. This API uses a p
**Example**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
......@@ -619,8 +593,6 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
});
```
### printSync<sup>9+</sup>
printSync(msg: string): void;
......@@ -638,15 +610,13 @@ Prints log information to the unit test console.
**Example**
```ts
var abilityDelegator;
var msg = "msg";
let abilityDelegator;
let msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.printSync(msg);
```
### print
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
**Example**
```ts
var abilityDelegator;
var msg = "msg";
let abilityDelegator;
let msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.print(msg, (err : any) => {
......@@ -674,8 +644,6 @@ abilityDelegator.print(msg, (err : any) => {
});
```
### print
print(msg: string): Promise\<void>;
......@@ -699,8 +667,8 @@ Prints log information to the unit test console. This API uses a promise to retu
**Example**
```ts
var abilityDelegator;
var msg = "msg";
let abilityDelegator;
let msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.print(msg).then(() => {
......@@ -708,8 +676,6 @@ abilityDelegator.print(msg).then(() => {
});
```
### executeShellCommand
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
**Example**
```ts
var abilityDelegator;
var cmd = "cmd";
let abilityDelegator;
let cmd = "cmd";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, (err : any, data : any) => {
......@@ -737,8 +703,6 @@ abilityDelegator.executeShellCommand(cmd, (err : any, data : any) => {
});
```
### executeShellCommand
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
**Example**
```ts
var abilityDelegator;
var cmd = "cmd";
var timeout = 100;
let abilityDelegator;
let cmd = "cmd";
let timeout = 100;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => {
......@@ -768,8 +732,6 @@ abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => {
});
```
### executeShellCommand
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
**Example**
```ts
var abilityDelegator;
var cmd = "cmd";
var timeout = 100;
let abilityDelegator;
let cmd = "cmd";
let timeout = 100;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => {
......@@ -804,8 +766,6 @@ abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => {
});
```
### finishTest<sup>9+</sup>
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
**Example**
```ts
var abilityDelegator;
var msg = "msg";
let abilityDelegator;
let msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.finishTest(msg, 0, (err : any) => {
......@@ -834,8 +794,6 @@ abilityDelegator.finishTest(msg, 0, (err : any) => {
});
```
### finishTest<sup>9+</sup>
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
**Example**
```ts
var abilityDelegator;
var msg = "msg";
let abilityDelegator;
let msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.finishTest(msg, 0).then(() => {
......@@ -887,9 +845,9 @@ Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
var monitor = {
let monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
......@@ -900,8 +858,6 @@ abilityDelegator.addAbilityStageMonitor(monitor, (err : any) => {
});
```
### addAbilityStageMonitor<sup>9+</sup>
addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
......@@ -925,9 +881,9 @@ Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
var monitor = {
let monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
......@@ -956,9 +912,9 @@ Removes an **AbilityStageMonitor** instance from the application memory. This AP
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
var monitor = {
let monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
......@@ -969,8 +925,6 @@ abilityDelegator.removeAbilityStageMonitor(monitor, (err : any) => {
});
```
### removeAbilityStageMonitor<sup>9+</sup>
removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
......@@ -994,9 +948,9 @@ Removes an **AbilityStageMonitor** object from the application memory. This API
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
var monitor = {
let monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
......@@ -1025,13 +979,13 @@ Waits for an **AbilityStage** instance that matches the conditions set in an **A
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
let monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
......@@ -1066,13 +1020,13 @@ Waits for an **AbilityStage** instance that matches the conditions set in an **A
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
let monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
......@@ -1102,14 +1056,14 @@ Waits a period of time for an **AbilityStage** instance that matches the conditi
**Example**
```ts
var abilityDelegator;
var timeout = 100;
let abilityDelegator;
let timeout = 100;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
let monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
......
......@@ -26,7 +26,7 @@ Describes the ability delegator arguments.
**Example**
```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var args = AbilityDelegatorRegistry.getArguments();
```
......@@ -30,7 +30,7 @@ Describes an ability monitor.
**Example**
```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
......
......@@ -28,7 +28,8 @@ The ability running information is obtained by calling [getAbilityRunningInfos](
**Example**
```ts
import abilitymanager from '@ohos.application.abilityManager';
import abilitymanager from '@ohos.app.ability.abilityManager';
abilitymanager.getAbilityRunningInfos((err,data) => {
console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data));
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
The ability stage context is obtained through an **AbilityStage** instance.
```ts
import AbilityStage from '@ohos.application.AbilityStage';
import AbilityStage from '@ohos.app.ability.AbilityStage';
class MyAbilityStage extends AbilityStage {
onCreate() {
let abilityStageContext = this.context;
......
......@@ -11,7 +11,7 @@ The **AbilityStageMonitor** module provides conditions for matching **AbilitySta
**Example**
```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let monitor = {
moduleName: "feature_as1",
......
......@@ -16,7 +16,7 @@ The **ApplicationStateObserver** module defines an observer to listen for applic
**Example**
```ts
import appManager from "@ohos.application.appManager"
import appManager from "@ohos.app.ability.appManager";
let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
......
......@@ -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.
```ts
import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility'
import Want from '@ohos.application.Want'
import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility';
import Want from '@ohos.app.ability.Want';
export default class TheServiceExtension extends ServiceExtension {
onCreate(want:Want) {
console.log('ServiceAbility onCreate, want: ' + want.abilityName);
......
......@@ -17,7 +17,7 @@ The **ProcessData** module defines process data. If a lifecycle change listener
**Example**
```ts
import appManager from '@ohos.application.appManager'
import appManager from '@ohos.app.ability.appManager';
let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
......
......@@ -23,7 +23,7 @@ The process running information is obtained by using [getProcessRunningInfos](js
**Example**
```ts
import appManager from '@ohos.application.appManager';
import appManager from '@ohos.app.ability.appManager';
appManager.getProcessRunningInfos().then((data) => {
console.log('success:' + JSON.stringify(data));
......
......@@ -19,7 +19,7 @@ The result is obtained by calling [executeShellCommand](js-apis-inner-applicatio
**Example**
```ts
import AbilityDelegatorRegistry from "@ohos.application.abilityDelegatorRegistry";
import AbilityDelegatorRegistry from "@ohos.app.ability.abilityDelegatorRegistry";
let abilityDelegator;
let cmd = "cmd";
......
# @ohos.inputmethodextensionability (InputMethodExtensionAbility)
# @ohos.InputMethodExtensionAbility (InputMethodExtensionAbility)
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
## Modules to Import
```js
import InputMethodExtensionAbility from '@ohos.inputmethodextensionability';
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
```
## Attributes
......
# @ohos.inputmethodextensioncontext (InputMethodExtensionContext)
# @ohos.InputMethodExtensionContext (InputMethodExtensionContext)
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
## Modules to Import
```
import InputMethodExtensionContext from '@ohos.inputmethodextensioncontext';
import InputMethodExtensionContext from '@ohos.InputMethodExtensionContext';
```
## Usage
......@@ -19,7 +19,7 @@ import InputMethodExtensionContext from '@ohos.inputmethodextensioncontext';
Before using the **InputMethodExtensionContext** module, you must define a child class that inherits from **InputMethodExtensionAbility**.
```js
import InputMethodExtensionAbility from '@ohos.inputmethodextensionability';
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
class EntryAbility extends InputMethodExtensionAbility {
onCreate() {
let context = this.context;
......@@ -66,9 +66,9 @@ Terminates this ability. This API uses a promise to return the result.
**Example**
```js
this.context.destroy().then((data) => {
console.log('success:' + JSON.stringify(data));
this.context.destroy().then(() => {
console.log('Succeed in destroying context.');
}).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**
>
......@@ -9,7 +9,7 @@ The **inputMethodSubtype** module provides APIs for managing the attributes of i
## Modules to Import
```
import inputMethodEngine from '@ohos.inputMethodSubtype';
import InputMethodSubtype from '@ohos.InputMethodSubtype';
```
## 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.
......@@ -10,7 +10,7 @@ The **inputMethod** module provides an input method framework, which can be used
## Modules to Import
```js
import inputMethod from '@ohos.inputmethod';
import inputMethod from '@ohos.inputMethod';
```
## Constants<sup>8+</sup>
......@@ -111,7 +111,7 @@ Switches to another input method. This API uses an asynchronous callback to retu
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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**
......@@ -160,15 +160,15 @@ Switches to another input method. This API uses a promise to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
|target | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
|target | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
**Return value**
| Type | Description |
| ----------------------------------------- | ---------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
| Type | Description |
| ----------------------------------------- | ---------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
**Error codes**
......@@ -240,7 +240,7 @@ Switches to another subtype of the current input method. This API uses an asynch
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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**
......@@ -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.|
|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**
......@@ -557,7 +557,7 @@ Ends this input session. The invoking of this API takes effect only after the in
| 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**
......@@ -643,7 +643,7 @@ Shows this soft keyboard. This API must be used with the input text box and work
| 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**
......@@ -715,7 +715,7 @@ Hides this soft keyboard. This API must be used with the input text box and work
| 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**
......@@ -789,7 +789,7 @@ Ends this input session. The invoking of this API takes effect only after the in
| 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**
......@@ -1157,7 +1157,7 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
| 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**
......@@ -1291,7 +1291,7 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
| 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**
......
# @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**
>
......@@ -9,7 +9,7 @@ The **inputMethodEngine** module streamlines the interaction between input metho
## Modules to Import
```
import inputMethodEngine from '@ohos.inputmethodengine';
import inputMethodEngine from '@ohos.inputMethodEngine';
```
## Constants
......@@ -203,7 +203,7 @@ Enables listening for a keyboard event. This API uses an asynchronous callback t
| 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. |
**Example**
......@@ -418,7 +418,7 @@ Disables listening for a keyboard event. This API uses an asynchronous callback
| 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. |
**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.
......
......@@ -389,7 +389,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeFirst method cannot be bound. |
| 10200010 | The container is empty. |
| 10200010 | Container is empty. |
**Example**
......@@ -424,7 +424,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeLast method cannot be bound. |
| 10200010 | The container is empty. |
| 10200010 | Container is empty. |
**Example**
......@@ -504,7 +504,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeFirstFound method cannot be bound. |
| 10200010 | The container is empty. |
| 10200010 | Container is empty. |
**Example**
......@@ -544,7 +544,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeLastFound method cannot be bound. |
| 10200010 | The container is empty. |
| 10200010 | Container is empty. |
**Example**
......
# @ohos.reminderAgent (reminderAgent)
# @ohos.reminderAgent (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.
......
......@@ -2,7 +2,8 @@
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.
......@@ -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_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_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.|
### Download Task Status Codes
......@@ -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.
### on('progress')
on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void
......@@ -399,8 +402,8 @@ Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bytes. |
| totalSize | number | Yes| Total size of the files to upload, in bytes. |
| uploadedSize | number | Yes| Size of the uploaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to upload, in bytes.|
**Example**
......@@ -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).|
| callback | function | No| Callback for the upload progress event.|
Parameters of the callback function
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bytes. |
| totalSize | number | Yes| Total size of the files to upload, in bytes. |
| uploadedSize | number | Yes| Size of the uploaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to upload, in bytes.|
**Example**
......@@ -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.|
| 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.|
......@@ -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).|
| callback | function | Yes| Callback for the download progress event.|
Parameters of the callback function
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bytes. |
| totalSize | number | Yes| Total size of the files to download, in bytes. |
| receivedSize | number | Yes| Size of the downloaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to download, in bytes.|
**Example**
......@@ -1085,8 +1088,8 @@ Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bytes. |
| totalSize | number | Yes| Total size of the files to download, in bytes. |
| receivedSize | number | Yes| Size of the downloaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to download, in bytes.|
**Example**
......@@ -1252,7 +1255,7 @@ Removes this download task. This API uses a promise to return the result.
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
......@@ -1262,7 +1265,7 @@ Removes this download task. This API uses an asynchronous callback to return the
| 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**
......
......@@ -67,8 +67,8 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
console.info("Request suspension delay will time out.");
})
var id = delayInfo.requestId;
var time = delayInfo.actualDelayTime;
let id = delayInfo.requestId;
let time = delayInfo.actualDelayTime;
console.info("The requestId is: " + id);
console.info("The actualDelayTime is: " + time);
} catch (error) {
......@@ -258,7 +258,7 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er
```js
import UIAbility from '@ohos.app.ability.UIAbility';
import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
function callback(error, data) {
if (error) {
......@@ -282,14 +282,18 @@ export default class EntryAbility extends UIAbility {
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
try {
backgroundTaskManager.startBackgroundRunning(this.context,
backgroundTaskManager.BackgroundMode.LOCATION, wantAgentObj, callback)
} catch (error) {
console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
}
});
try {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
try {
backgroundTaskManager.startBackgroundRunning(this.context,
backgroundTaskManager.BackgroundMode.LOCATION, wantAgentObj, callback)
} catch (error) {
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
```js
import UIAbility from '@ohos.app.ability.UIAbility';
import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager';
import wantAgent from '@ohos.wantAgent';
import wantAgent from '@ohos.app.ability.wantAgent';
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
......@@ -353,18 +357,22 @@ export default class EntryAbility extends UIAbility {
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
try {
backgroundTaskManager.startBackgroundRunning(this.context,
backgroundTaskManager.BackgroundMode.LOCATION, wantAgentObj).then(() => {
console.info("Operation startBackgroundRunning succeeded");
}).catch((error) => {
try {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
try {
backgroundTaskManager.startBackgroundRunning(this.context,
backgroundTaskManager.BackgroundMode.LOCATION, wantAgentObj).then(() => {
console.info("Operation startBackgroundRunning succeeded");
}).catch((error) => {
console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
});
} catch (error) {
console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
});
} catch (error) {
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.
......
......@@ -40,32 +40,28 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | If UI execution context not found. |
| 100002 | If the uri is not exist. |
| 100003 | If the pages are pushed too much. |
| 100001 | if UI execution context not found. |
| 100002 | if the uri is not exist. |
| 100003 | if the pages are pushed too much. |
**Example**
```js
try {
router.pushUrl({
url: 'pages/routerpage2',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
router.pushUrl({
url: 'pages/routerpage2',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
}
})
.then(() => {
// success
})
.catch(err => {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
})
.then(() => {
// success
})
.catch(err => {
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>
......@@ -81,7 +77,7 @@ Navigates to a specified page in the application.
| Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | --------- |
| options | [RouterOptions](#routeroptions) | Yes | Page routing parameters.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes**
......@@ -89,32 +85,28 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | If UI execution context not found. |
| 100002 | If the uri is not exist. |
| 100003 | If the pages are pushed too much. |
| 100001 | if UI execution context not found. |
| 100002 | if the uri is not exist. |
| 100003 | if the pages are pushed too much. |
**Example**
```js
try {
router.pushUrl({
url: 'pages/routerpage2',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
}
}, (err) => {
if (err) {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
return;
router.pushUrl({
url: 'pages/routerpage2',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
console.info('pushUrl success');
});
} catch (error) {
console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`);
};
}
})
.then(() => {
// success
})
.catch(err => {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
})
```
## router.pushUrl<sup>9+</sup>
......@@ -143,32 +135,28 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | If UI execution context not found. |
| 100002 | If the uri is not exist. |
| 100003 | If the pages are pushed too much. |
| 100001 | if UI execution context not found. |
| 100002 | if the uri is not exist. |
| 100003 | if the pages are pushed too much. |
**Example**
```js
try {
router.pushUrl({
url: 'pages/routerpage2',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
router.pushUrl({
url: 'pages/routerpage2',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
}, router.RouterMode.Standard)
.then(() => {
// success
})
.catch(err => {
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.RouterMode.Standard)
.then(() => {
// success
})
.catch(err => {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
})
```
## router.pushUrl<sup>9+</sup>
......@@ -185,7 +173,7 @@ Navigates to a specified page in the application.
| ------- | ------------------------------- | ---- | ---------- |
| options | [RouterOptions](#routeroptions) | Yes | Page routing parameters. |
| mode | [RouterMode](#routermode9) | Yes | Routing mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes**
......@@ -193,32 +181,28 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | If UI execution context not found. |
| 100002 | If the uri is not exist. |
| 100003 | If the pages are pushed too much. |
| 100001 | if UI execution context not found. |
| 100002 | if the uri is not exist. |
| 100003 | if the pages are pushed too much. |
**Example**
```js
try {
router.pushUrl({
url: 'pages/routerpage2',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
}
}, router.RouterMode.Standard, (err) => {
if (err) {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
return;
router.pushUrl({
url: 'pages/routerpage2',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
console.info('pushUrl success');
});
} catch (error) {
console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`);
};
}
}, router.RouterMode.Standard, (err) => {
if (err) {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info('pushUrl success');
})
```
## router.replaceUrl<sup>9+</sup>
......@@ -247,28 +231,24 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | If UI execution context not found, only throw in standard system. |
| 200002 | If the uri is not exist. |
| 100001 | if UI execution context not found, only throw in standard system. |
| 200002 | if the uri is not exist. |
**Example**
```js
try {
router.replaceUrl({
url: 'pages/detail',
params: {
data1: 'message'
}
router.replaceUrl({
url: 'pages/detail',
params: {
data1: 'message'
}
})
.then(() => {
// success
})
.catch(err => {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
})
.then(() => {
// success
})
.catch(err => {
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>
......@@ -284,7 +264,7 @@ Replaces the current page with another one in the application and destroys the c
| Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ------------------ |
| options | [RouterOptions](#routeroptions) | Yes | Description of the new page.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes**
......@@ -292,28 +272,24 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | If UI execution context not found, only throw in standard system. |
| 200002 | If the uri is not exist. |
| 100001 | if UI execution context not found, only throw in standard system. |
| 200002 | if the uri is not exist. |
**Example**
```js
try {
router.replaceUrl({
url: 'pages/detail',
params: {
data1: 'message'
}
}, (err) => {
if (err) {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info('replaceUrl success');
});
} catch (error) {
console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`);
};
router.replaceUrl({
url: 'pages/detail',
params: {
data1: 'message'
}
}, (err) => {
if (err) {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info('replaceUrl success');
})
```
## router.replaceUrl<sup>9+</sup>
......@@ -344,28 +320,24 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | If UI execution context not found, only throw in standard system. |
| 200002 | If the uri is not exist. |
| 100001 | if UI execution context not found, only throw in standard system. |
| 200002 | if the uri is not exist. |
**Example**
```js
try {
router.replaceUrl({
url: 'pages/detail',
params: {
data1: 'message'
}
}, router.RouterMode.Standard)
.then(() => {
// success
})
.catch(err => {
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({
url: 'pages/detail',
params: {
data1: 'message'
}
}, router.RouterMode.Standard)
.then(() => {
// success
})
.catch(err => {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
})
```
## router.replaceUrl<sup>9+</sup>
......@@ -382,7 +354,7 @@ Replaces the current page with another one in the application and destroys the c
| ------- | ------------------------------- | ---- | ---------- |
| options | [RouterOptions](#routeroptions) | Yes | Description of the new page. |
| mode | [RouterMode](#routermode9) | Yes | Routing mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes**
......@@ -390,28 +362,25 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | If UI execution context not found, only throw in standard system. |
| 200002 | If the uri is not exist. |
| 100001 | if UI execution context not found, only throw in standard system. |
| 200002 | if the uri is not exist. |
**Example**
```js
try {
router.replaceUrl({
url: 'pages/detail',
params: {
data1: 'message'
}
}, router.RouterMode.Standard, (err) => {
if (err) {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info('replaceUrl success');
});
} catch (error) {
console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`);
};
router.replaceUrl({
url: 'pages/detail',
params: {
data1: 'message'
}
}, router.RouterMode.Standard, (err) => {
if (err) {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info('replaceUrl success');
});
```
## router.back
......@@ -524,7 +493,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | If UI execution context not found. |
| 100001 | if UI execution context not found. |
**Example**
......@@ -571,9 +540,9 @@ Obtains the parameters passed from the page that initiates redirection to the cu
**Return value**
| Type | Description |
| ------ | ----------------- |
| Object | Parameters passed from the page that initiates redirection to the current page.|
| Type | Description |
| ------ | ---------------------------------- |
| object | Parameters passed from the page that initiates redirection to the current page.|
**Example**
......@@ -636,7 +605,7 @@ export default {
### TypeScript-based Declarative Development Paradigm
```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'
@Entry
......@@ -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>
......@@ -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.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**System capability**: SystemCapability.ArkUI.ArkUI.Lite
**Parameters**
......@@ -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>
enableAlertBeforeBackPage(options: EnableAlertOptions): void
......
......@@ -226,7 +226,7 @@ screenlock.lock().then((data) => {
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
......
# @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.
......
......@@ -5,6 +5,8 @@ The **stationary** module provides APIs to report the device status, including a
> **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.
>
> This module does not support x86 emulators.
## Modules to Import
......
# Bluetooth
# @system.bluetooth (Bluetooth)
> **NOTE**<br/>
......
# Application Configuration
# @system.configuration (Application Configuration)
> **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.
......
# 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 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>
> - 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**
>
......
......@@ -3,8 +3,8 @@
The **system.request** module provides applications with basic upload and download capabilities.
> **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.
......@@ -25,9 +25,9 @@ Uploads a file. This API returns no value.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [UploadRequestOptions](#uploadrequestoptions) | Yes| Upload configurations.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [UploadRequestOptions](#uploadrequestoptions) | Yes| Upload configurations.|
**Example**
......@@ -61,27 +61,27 @@ Uploads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| url | string | Yes| URL of the upload server.|
| 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**.|
| header | Object | No| Request header.|
| 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.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| url | string | Yes| URL of the upload server.|
| 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**.|
| header | Object | No| Request header.|
| 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.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
**success parameter**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [UploadResponse](#uploadresponse) | Yes| Information returned when the upload task is successful.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [UploadResponse](#uploadresponse) | Yes| Information returned when the upload task is successful.|
**fail parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the upload task fails.|
| code | number | Yes| HTTP status code returned when the upload task fails.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information 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.
**System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Description|
| -------- | -------- | -------- |
| code | number | 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.|
| headers | Object | Headers returned by the server.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| code | number | Yes| HTTP status code returned by the server.|
| data | string | Yes| Content returned by the server. The value type is determined by the type in the returned headers.|
| headers | Object | Yes| Headers returned by the server.|
## RequestFile
**System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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**.|
| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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**.|
| 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.|
## RequestData
**System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the form element.|
| value | string | Yes| Value of the form element.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the form element.|
| value | string | Yes| Value of the form element.|
......@@ -129,9 +129,9 @@ Downloads a file. This API returns no value.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [DownloadRequestOptions](#downloadrequestoptions) | Yes| Download configurations.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [DownloadRequestOptions](#downloadrequestoptions) | Yes| Download configurations.|
**Example**
......@@ -164,34 +164,34 @@ Downloads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Download
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| header | Object | No| Request header.|
| description | string | No| Download description. The default value is the file name.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| header | Object | No| Request header.|
| description | string | No| Download description. The default value is the file name.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
**success parameter**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [DownloadResponse](#downloadresponse) | Yes| Information returned when the download task is successful.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [DownloadResponse](#downloadresponse) | Yes| Information returned when the download task is successful.|
**fail parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.|
## DownloadResponse
**System capability**: SystemCapability.MiscServices.Download
| Name| Type| Description|
| -------- | -------- | -------- |
| token | string | Download token, which is used to obtain the download status|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | string | Yes| Download token, which is used to obtain the download status|
## request.onDownloadComplete
......@@ -204,9 +204,9 @@ Listens for download task status. This API returns no value.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [OnDownloadCompleteOptions](#ondownloadcompleteoptions) | Yes| Configurations of the download task.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [OnDownloadCompleteOptions](#ondownloadcompleteoptions) | Yes| Configurations of the download task.|
**Example**
......@@ -231,29 +231,29 @@ Listens for download task status. This API returns no value.
**System capability**: SystemCapability.MiscServices.Download
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | string | Yes| Result token returned by the download API.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | string | Yes| Result token returned by the download API.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
**success parameter**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [OnDownloadCompleteResponse](#ondownloadcompleteresponse) | Yes| Information returned when the download task is successful.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [OnDownloadCompleteResponse](#ondownloadcompleteresponse) | Yes| Information returned when the download task is successful.|
**fail parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.|
## OnDownloadCompleteResponse
**System capability**: SystemCapability.MiscServices.Download
| Name| Type| Description|
| -------- | -------- | -------- |
| uri | string | URI of the download file.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uri | string | Yes| URI of the download file.|
......@@ -127,7 +127,7 @@ Returns to the previous page or a specified page.
| Name | Type | Mandatory | Description |
| ------- | --------------------------------------- | ---- | ----------------------- |
| options | [BackRouterOptions](#backrouteroptions) | Yes | For details, see **BackRouterOptions**.|
| options | [BackRouterOptions](#backrouteroptions) | No | For details, see **BackRouterOptions**.|
**Example**
......@@ -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.
## router.getParams
## router.getParams<sup>7+</sup>
getParams(): ParamsInterface
......@@ -397,6 +397,6 @@ Defines the **DisableAlertBeforeBackPage** parameters.
## ParamsInterface
| Name | Type | Description |
| ------------- | ------ | ------- |
| [key: string] | Object | List of routing parameters.|
| Name | Type| Description |
| ------------- | -------- | -------------- |
| [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 APIs of this module can be used only in the FA model.
> - 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.
## Modules to Import
```js
import storage from '@system.storage';
```
## storage.get
get(Object): void
get(options: GetStorageOptions): void
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**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to read.|
| 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.|
| Name | Type | Mandatory| Description |
| ------- | -------------------- | ---- | ---------- |
| options | [GetStorageOptions](#getstorageoptions) | Yes | API configuration.|
**Example**
......@@ -54,10 +49,9 @@ export default {
}
```
## storage.set
set(Object): void
get(options: SetStorageOptions): void
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**
| 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 | 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.|
| Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ---------- |
| options | [SetStorageOptions](#setstorageoptions) | Yes | API configuration.|
**Example**
......@@ -92,10 +82,9 @@ export default {
}
```
## storage.clear
clear(Object): void
clear(options?: ClearStorageOptions): void
Clears the key-value pairs from the cache.
......@@ -103,11 +92,9 @@ Clears the key-value pairs from the cache.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| success | Function | No| Called when **storage.clear()** is successful.|
| 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.|
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------- | ---- | -------------- |
| options | [ClearStorageOptions](#clearstorageoptions) | No | API configuration.|
**Example**
......@@ -126,10 +113,9 @@ export default {
}
```
## storage.delete
delete(Object): void
delete(options: DeleteStorageOptions): void
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**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to delete.|
| 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.|
| Name | Type | Mandatory| Description |
| ------- | --------------------------------------------- | ---- | -------------- |
| options | [DeleteStorageOptions](#deletestorageoptions) | Yes | API configuration.|
**Example**
......@@ -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:
A standard URI consists of the following parts:
[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.
- 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.
......@@ -226,7 +226,9 @@ Checks whether this URI is an absolute URI (whether the scheme component is defi
```js
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.
```js
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();
uriInstance1.path;
console.log(uriInstance1.path); // /path/path2/path3
```
......@@ -87,7 +87,7 @@ paramsObject.delete('fod');
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
......@@ -95,13 +95,13 @@ Obtains all the key-value pairs based on the specified name.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain all key-value pairs.|
| name | string | Yes| Target key.|
**Return value**
| Type| Description|
| -------- | -------- |
| string[] | Key-value pairs obtained.|
| string[] | All the values obtained.|
**Example**
......@@ -432,7 +432,7 @@ A no-argument constructor used to create a URL. It returns a **URL** object afte
**System capability**: SystemCapability.Utils.Lang
### parseURL<sup>9+</sup>
static parseURL(url : string, base?: string | URL): URL
Parses a URL.
......@@ -514,7 +514,7 @@ A constructor used to create a **URLSearchParams** instance.
> **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
......@@ -542,7 +542,7 @@ Appends a key-value pair into the query string.
> **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
......@@ -569,7 +569,7 @@ Deletes key-value pairs of the specified key.
> **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
......@@ -595,7 +595,7 @@ Obtains all the key-value pairs based on the specified key.
> **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
......@@ -603,7 +603,7 @@ Obtains all the key-value pairs based on the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain all key-value pairs.|
| name | string | Yes| Target key.|
**Return value**
......@@ -628,7 +628,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
> **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
......@@ -656,7 +656,7 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal
> **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
......@@ -693,7 +693,7 @@ Obtains the value of the first key-value pair based on the specified key.
> **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
......@@ -727,7 +727,7 @@ Checks whether a key has a value.
> **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
......@@ -760,7 +760,7 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t
> **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
......@@ -788,7 +788,7 @@ Sorts all key-value pairs contained in this object based on the Unicode code poi
> **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
......@@ -809,7 +809,7 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs.
> **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
......@@ -837,7 +837,7 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs.
> **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
......@@ -865,7 +865,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
> **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
......@@ -892,7 +892,7 @@ Obtains search parameters that are serialized as a string and, if necessary, per
> **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
......
......@@ -43,7 +43,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`);
vendorId: 7531,
productId: 2,
clazz: 9,
subclass: 0,
subClass: 0,
protocol: 1,
devAddress: 1,
busNum: 1,
......@@ -60,7 +60,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`);
id: 0,
protocol: 0,
clazz: 9,
subclass: 0,
subClass: 0,
alternateSetting: 0,
name: "1-1",
endpoints: [
......@@ -171,7 +171,7 @@ usb.requestRight(devicesName).then((ret) => {
## usb.claimInterface
claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number
claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number
Claims a USB interface.
......@@ -348,7 +348,7 @@ let ret = usb.getFileDescriptor(devicepipe);
## 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.
......@@ -380,7 +380,7 @@ usb.controlTransfer(devicepipe, USBControlParams).then((ret) => {
## 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.
......
......@@ -42,7 +42,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`);
vendorId: 7531,
productId: 2,
clazz: 9,
subclass: 0,
subClass: 0,
protocol: 1,
devAddress: 1,
busNum: 1,
......@@ -59,7 +59,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`);
id: 0,
protocol: 0,
clazz: 9,
subclass: 0,
subClass: 0,
alternateSetting: 0,
name: "1-1",
endpoints: [
......@@ -252,7 +252,7 @@ if (usb.addRight(bundleName, devicesName) {
## usb.claimInterface
claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number
claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number
Claims a USB interface.
......@@ -429,7 +429,7 @@ let ret = usb.getFileDescriptor(devicepipe);
## 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.
......@@ -461,7 +461,7 @@ usb.controlTransfer(devicepipe, USBControlParams).then((ret) => {
## 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.
......
# @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.
......
# @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.
......@@ -54,7 +54,7 @@ Defines the parameters for creating a subwindow or system window.
| ---------- | -------------------------- | -- | ----------------------------------- |
| name | string | Yes| Name 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.|
| 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
| 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.|
**Error codes**
......@@ -472,7 +472,7 @@ Obtains the top window of the current application. This API uses a promise to re
| 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**
......@@ -897,7 +897,7 @@ promise.then((data)=> {
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**
>
......@@ -907,12 +907,12 @@ Creates a subwindow (in API version 8) or a system window (from API version 9).
**Parameters**
| 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).|
| id | string | Yes | Window ID. |
| type | [WindowType](#windowtype7) | Yes | Window type. |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the subwindow created. |
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------ |
| ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes | Current application context. |
| id | string | Yes | Window ID. |
| type | [WindowType](#windowtype7) | Yes | Window type. |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the subwindow created.|
**Example**
......@@ -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;
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**
>
......@@ -945,7 +945,7 @@ Creates a subwindow (in API version 8) or a system window (from API version 9).
| 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. |
| type | [WindowType](#windowtype7) | Yes | Window type. |
......@@ -1121,7 +1121,7 @@ Obtains the top window of the current application. This API uses an asynchronous
| 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. |
**Example**
......@@ -1154,7 +1154,7 @@ Obtains the top window of the current application. This API uses a promise to re
| 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**
......@@ -1864,7 +1864,7 @@ Obtains the area where this window cannot be displayed, for example, the system
| Name| Type| Mandatory| Description|
| ---- |----------------------------------| -- | ------------------------------------------------------------ |
| type | [AvoidAreaType](#avoidareatype7) | Yes| Type of the area. |
| type | [AvoidAreaType](#avoidareatype7) | Yes| Type of the area.|
**Return value**
......@@ -4629,10 +4629,10 @@ Obtains the area where this window cannot be displayed, for example, the system
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------------- | --------- | ------------------------------------------------------------ |
| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. |
| callback | AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt; | Yes | Callback used to return the area. |
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------------- | --------- | --------------------------------- |
| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. |
| callback | AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt; | Yes | Callback used to return the area. |
**Example**
......@@ -4662,9 +4662,9 @@ Obtains the area where this window cannot be displayed, for example, the system
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | -------------------------------- | --------- | ------------------------------------------------------------ |
| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. |
| Name | Type | Mandatory | Description |
| ---- | -------------------------------- | --------- | ----------------- |
| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. |
**Return value**
......@@ -5237,10 +5237,10 @@ Sets a color space for this window. This API uses an asynchronous callback to re
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | ------------------------- | --------- | ----------------------------------- |
| Name | Type | Mandatory | Description |
| ---------- | -------------------------- | --------- | ----------------------------------- |
| 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. |
**Example**
......@@ -5269,8 +5269,8 @@ Sets a color space for this window. This API uses a promise to return the result
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | ------------------------- | --------- | ------------------- |
| Name | Type | Mandatory | Description |
| ---------- | -------------------------- | --------- | ------------------- |
| colorSpace | [ColorSpace](#colorspace8) | Yes | Color space to set. |
**Return value**
......@@ -5305,8 +5305,8 @@ Obtains the color space of this window. This API uses an asynchronous callback t
**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. |
**Example**
......@@ -5336,8 +5336,8 @@ Obtains the color space of this window. This API uses a promise to return the re
**Return value**
| Type | Description |
| ---------------------------------------- | ----------------------------------------------- |
| Type | Description |
| ----------------------------------------- | ----------------------------------------------- |
| Promise&lt;[ColorSpace](#colorspace8)&gt; | Promise used to return the current color space. |
**Example**
......
......@@ -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.|
| 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
......
......@@ -21,7 +21,7 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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**|
> **NOTE**
......@@ -65,7 +65,7 @@ struct ScrollBarExample {
.margin({ top: 5 })
}
}, item => item)
}.margin({ left: 52 })
}.margin({ right: 52 })
}
.scrollBar(BarState.Off)
.scrollable(ScrollDirection.Vertical)
......
......@@ -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** |
| 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** |
| 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>} |
| 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>} |
| 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>} |
| 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>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>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** |
| 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**|
......
# 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**
>
......@@ -22,7 +22,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| 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**|
| 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>|
......
......@@ -131,7 +131,7 @@ Scrolls to the item with the specified index.
> **NOTE**
>
> Only the **\<List>** component is supported.
> Only the **\<Grid>**, **\<List>**, and **\<WaterFlow>** components are supported.
**Parameters**
......
......@@ -50,7 +50,7 @@ struct TransitionExample {
})
})
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)
.transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } })
.transition({ type: TransitionType.Delete, rotate: { angle: 180 } })
......@@ -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**:
Use the **focusContrl.requestFocus** API to enable a specified component to obtain focus.
```ts
// requestFocus.ets
import prompt from '@ohos.prompt'
import promptAction from '@ohos.promptAction';
@Entry
@Component
......@@ -253,9 +253,9 @@ struct RequestFocusExample {
.onClick(() => {
var res = focusControl.requestFocus(this.selectId) // Enable the component selected by this.selectId to obtain focus.
if (res) {
prompt.showToast({message: 'Request success'})
promptAction.showToast({message: 'Request success'})
} else {
prompt.showToast({message: 'Request failed'})
promptAction.showToast({message: 'Request failed'})
}
})
}
......
此差异已折叠。
# Building a Food Data Model
On the created page, we use various items to describe food, such as food names, calories, proteins, fats, carbohydrates, and vitamin C. This form of coding is impractical in actual development. Therefore, you need to create food data models to store and manage data in a unified manner.
In real-world development, it is impractical to describe all aspects of food in code, including the food name and nutrition facts. This is where the food data model comes into the picture. With the food data model, you can store and manage data in a unified manner.
![en-us_image_0000001267767897](figures/en-us_image_0000001267767897.png)
1. Create a folder named model and create a file named FoodData.ets therein.
![en-us_image_0000001223127760](figures/en-us_image_0000001223127760.png)
2. Define a food data storage model, FoodData, and an enum variable, Category. The FoodData class contains the food ID, name, category, image, calories, protein, fat, carbohydrates, and vitamin C attributes.
The ArkTS programming language is an extension of the TS language and also supports the TS syntax.
1. Create a folder named **model** and create a file named **FoodData.ets** therein.
![en-us_image_0000001223127760](figures/en-us_image_0000001223127760.png)
```
2. Define a food data storage model, **FoodData**, and an enum variable, **Category**. The **FoodData** class contains **id**, **name**, **category**, **image**, **calories**, **protein**, **fat**, **carbohydrates**, and **vitaminC** attributes.
The ArkTS programming language is an extension of the TS language and also supports the TS syntax.
```ts
enum Category {
Fruit,
Vegetable,
......@@ -50,14 +48,21 @@ On the created page, we use various items to describe food, such as food names,
}
```
3. Store food image resources in the resources > base > media directory. Use food names as the image names.
4. Create food resource data. Create FoodDataModels.ets in the model folder and declare a food composition array, FoodComposition on the page.
In this example, you can customize more data resources when needed. Use LazyForEach to load data if a large amount of food data is involved.
3. Store food images in the **resources** > **base** > **media** directory. Use food names as the image names.
5. Create the initializeOnStartUp method to initialize the FoodData array. Export the FoodData class from FoodData.ets, and import FoodData and Category in FoodDataModels.ets.
4. Create food resource data. Create **FoodDataModels.ets** in the **model** folder and declare the food composition array **FoodComposition** on the page. The following example creates two pieces of food data.
```ts
const FoodComposition: any[] = [
{ 'name': 'Tomato', 'image': $r('app.media.Tomato'), 'category': Category.Vegetable, 'calories': 17, 'protein': 0.9, 'fat': 0.2, 'carbohydrates': 3.9, 'vitaminC': 17.8 },
{ 'name': 'Walnut', 'image': $r('app.media.Walnut'), 'category': Category.Nut, 'calories': 654 , 'protein': 15, 'fat': 65, 'carbohydrates': 14, 'vitaminC': 1.3 }
]
```
In real-world development, you can customize more data resources when needed. Use [Lazy Loading](../quick-start/arkts-rendering-control.md#lazy-loading) to load data if a large amount of food data is involved.
5. Create the **initializeOnStartUp** method to initialize the **FoodData** array. Export the **FoodData** class from **FoodData.ets**, and import **FoodData** and **Category** in **FoodDataModels.ets**.
```ts
// FoodData.ets
export enum Category {
......
......
......@@ -52,7 +52,7 @@ You can create a subwindow, such as a dialog box, and set its properties.
let windowClass = null;
// Method 1: Create a subwindow.
let config = {name: "subWindow", windowType: window.WindowType.TYPE_APP, ctx: this.context};
let config = {name: "subWindow", windowType: window.WindowType.TYPE_APP};
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册